add setAnimationFrame
This commit is contained in:
@@ -77,7 +77,6 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
|
||||
if found != nil {
|
||||
path = found?.path
|
||||
print("FOUND \(found)")
|
||||
} else {
|
||||
if(uriString.hasPrefix("file://")) {
|
||||
path = String(uriString.dropFirst(7))
|
||||
@@ -357,6 +356,13 @@ public class SwiftPolyvoxFilamentPlugin: NSObject, FlutterPlugin, FlutterTexture
|
||||
let reverse = args[3] as! Bool;
|
||||
play_animation(assetPtr, animationIndex, loop, reverse)
|
||||
result("OK");
|
||||
case "setAnimationFrame":
|
||||
let args = call.arguments as! Array<Any?>
|
||||
let assetPtr = UnsafeMutableRawPointer.init(bitPattern: args[0] as! Int)
|
||||
let animationIndex = args[1] as! Int32;
|
||||
let animationFrame = args[2] as! Int32;
|
||||
set_animation_frame(assetPtr, animationIndex, animationFrame)
|
||||
result("OK");
|
||||
case "stopAnimation":
|
||||
let args = call.arguments as! Array<Any?>
|
||||
let assetPtr = UnsafeMutableRawPointer.init(bitPattern: args[0] as! Int)
|
||||
|
||||
@@ -78,6 +78,7 @@ void set_animation(
|
||||
// );
|
||||
|
||||
void play_animation(void* asset, int index, bool loop, bool reverse);
|
||||
void set_animation_frame(void* asset, int animationIndex, int animationFrame);
|
||||
void stop_animation(void* asset, int index);
|
||||
|
||||
int get_animation_count(void* asset);
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
#ifndef SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||
#define SwiftPolyvoxFilamentPlugin_Bridging_Header_h
|
||||
|
||||
// void* filament_viewer_new_ios(void* texture, void* loadResource, void* freeResource, void* resources);
|
||||
|
||||
#import "PolyvoxFilamentIOSApi.h"
|
||||
#import "PolyvoxFilamentApi.h"
|
||||
|
||||
|
||||
@@ -196,6 +196,10 @@ extern "C" {
|
||||
((SceneAsset*)asset)->playAnimation(index, loop, reverse);
|
||||
}
|
||||
|
||||
void set_animation_frame(void* asset, int animationIndex, int animationFrame) {
|
||||
((SceneAsset*)asset)->setAnimationFrame(animationIndex, animationFrame);
|
||||
}
|
||||
|
||||
int get_animation_count(void* asset) {
|
||||
auto names = ((SceneAsset*)asset)->getAnimationNames();
|
||||
return names->size();
|
||||
|
||||
@@ -327,6 +327,12 @@ void SceneAsset::setTexture() {
|
||||
|
||||
}
|
||||
|
||||
void SceneAsset::setAnimationFrame(int animationIndex, int animationFrame) {
|
||||
auto offset = 60 * animationFrame * 1000; // TODO - don't hardcore 60fps framerate
|
||||
_animator->applyAnimation(animationIndex, offset);
|
||||
_animator->updateBoneMatrices();
|
||||
}
|
||||
|
||||
void SceneAsset::updateEmbeddedAnimations() {
|
||||
auto now = high_resolution_clock::now();
|
||||
int animationIndex = 0;
|
||||
|
||||
@@ -70,6 +70,8 @@ abstract class FilamentController {
|
||||
Future<List<String>> getAnimationNames(FilamentAsset asset);
|
||||
Future removeAsset(FilamentAsset asset);
|
||||
Future clearAssets();
|
||||
Future setAnimationFrame(
|
||||
FilamentAsset asset, int animationIndex, int animationFrame);
|
||||
Future playAnimation(FilamentAsset asset, int index,
|
||||
{bool loop = false, bool reverse = false});
|
||||
Future playAnimations(FilamentAsset asset, List<int> indices,
|
||||
@@ -332,6 +334,12 @@ class PolyvoxFilamentController extends FilamentController {
|
||||
await _channel.invokeMethod("playAnimation", [asset, index, loop, reverse]);
|
||||
}
|
||||
|
||||
Future setAnimationFrame(
|
||||
FilamentAsset asset, int index, int animationFrame) async {
|
||||
await _channel
|
||||
.invokeMethod("setAnimationFrame", [asset, index, animationFrame]);
|
||||
}
|
||||
|
||||
Future playAnimations(FilamentAsset asset, List<int> indices,
|
||||
{bool loop = false, bool reverse = false}) async {
|
||||
return Future.wait(indices.map((index) {
|
||||
|
||||
Reference in New Issue
Block a user