feat: add startOffset parameter to gltf playAnimation

This commit is contained in:
Nick Fisher
2024-07-29 16:13:45 +08:00
parent 96ad9dee18
commit a30e2f295f
16 changed files with 29 additions and 62 deletions

View File

@@ -456,7 +456,7 @@ external bool set_bone_transform(
@ffi.Native<
ffi.Void Function(ffi.Pointer<ffi.Void>, ffi.Int, ffi.Int, ffi.Bool,
ffi.Bool, ffi.Bool, ffi.Float)>()
ffi.Bool, ffi.Bool, ffi.Float, ffi.Float)>()
external void play_animation(
ffi.Pointer<ffi.Void> sceneManager,
int entity,
@@ -465,6 +465,7 @@ external void play_animation(
bool reverse,
bool replaceActive,
double crossfade,
double startOffset,
);
@ffi.Native<
@@ -1301,19 +1302,6 @@ external void apply_weights_ffi(
int count,
);
@ffi.Native<
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Bool,
ffi.Bool, ffi.Bool, ffi.Float)>()
external void play_animation_ffi(
ffi.Pointer<ffi.Void> sceneManager,
int asset,
int index,
bool loop,
bool reverse,
bool replaceActive,
double crossfade,
);
@ffi.Native<
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Int)>()
external void set_animation_frame_ffi(

View File

@@ -1592,25 +1592,6 @@ external void apply_weights_ffi(
int count,
);
@ffi.Native<
ffi.Void Function(
ffi.Pointer<ffi.Void>,
EntityId,
ffi.Int,
ffi.Bool,
ffi.Bool,
ffi.Bool,
ffi.Float)>(symbol: '_play_animation_ffi', assetId: 'thermion_dart')
external void play_animation_ffi(
ffi.Pointer<ffi.Void> sceneManager,
int asset,
int index,
bool loop,
bool reverse,
bool replaceActive,
double crossfade,
);
@ffi.Native<
ffi.Void Function(ffi.Pointer<ffi.Void>, EntityId, ffi.Int, ffi.Int)>(
symbol: '_set_animation_frame_ffi', assetId: 'thermion_dart')

View File

@@ -339,7 +339,8 @@ class ThermionViewerJSDartBridge {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) =>
double crossfade = 0.0,
double startOffset = 0.0}) =>
viewer
.playAnimation(
entity,
@@ -348,6 +349,7 @@ class ThermionViewerJSDartBridge {
reverse: reverse,
replaceActive: replaceActive,
crossfade: crossfade,
startOffset: startOffset
)
.toJS;

View File

@@ -368,9 +368,10 @@ class ThermionViewerJS implements ThermionViewer {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) async {
double crossfade = 0.0,
double startOffset = 0.0}) async {
await _shim
.playAnimation(entity, index, loop, reverse, replaceActive, crossfade)
.playAnimation(entity, index, loop, reverse, replaceActive, crossfade, startOffset)
.toDart;
}

View File

@@ -184,6 +184,7 @@ extension type ThermionViewerJSShim(JSObject _) implements JSObject {
bool reverse,
bool replaceActive,
double crossfade,
double startOffset,
);
@JS('playAnimationByName')

View File

@@ -698,7 +698,8 @@ class ThermionViewerWasm implements ThermionViewer {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) async {
double crossfade = 0.0,
double startOffset = 0.0}) async {
_module.ccall(
"play_animation",
"void",
@@ -709,6 +710,7 @@ class ThermionViewerWasm implements ThermionViewer {
"bool".toJS,
"bool".toJS,
"bool".toJS,
"float".toJS,
"float".toJS
].toJS,
[

View File

@@ -386,7 +386,8 @@ abstract class ThermionViewer {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0});
double crossfade = 0.0,
double startOffset = 0.0});
///
/// Schedules the glTF animation at [index] in [entity] to start playing on the next frame.

View File

@@ -980,9 +980,10 @@ class ThermionViewerFFI extends ThermionViewer {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) async {
double crossfade = 0.0,
double startOffset = 0.0}) async {
play_animation(
_sceneManager!, entity, index, loop, reverse, replaceActive, crossfade);
_sceneManager!, entity, index, loop, reverse, replaceActive, crossfade, startOffset);
}
///

View File

@@ -333,7 +333,8 @@ class ThermionViewerStub extends ThermionViewer {
{bool loop = false,
bool reverse = false,
bool replaceActive = true,
double crossfade = 0.0}) {
double crossfade = 0.0,
double startOffset=0.0}) {
// TODO: implement playAnimation
throw UnimplementedError();
}