add web/JS export implementation for addBoneAnimation
This commit is contained in:
@@ -3,7 +3,8 @@ library flutter_filament_js;
|
|||||||
|
|
||||||
import 'dart:js_interop';
|
import 'dart:js_interop';
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
import 'package:vector_math/vector_math_64.dart' as v64;
|
||||||
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
import 'package:animation_tools_dart/src/morph_animation_data.dart';
|
import 'package:animation_tools_dart/src/morph_animation_data.dart';
|
||||||
import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
||||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||||
@@ -88,7 +89,7 @@ class DartFilamentJSExportViewer {
|
|||||||
double dirX,
|
double dirX,
|
||||||
double dirY,
|
double dirY,
|
||||||
double dirZ,
|
double dirZ,
|
||||||
double falloffRadius,
|
double falloffRadius,
|
||||||
double spotLightConeInner,
|
double spotLightConeInner,
|
||||||
double spotLightConeOuter,
|
double spotLightConeOuter,
|
||||||
double sunAngularRadius,
|
double sunAngularRadius,
|
||||||
@@ -96,23 +97,15 @@ class DartFilamentJSExportViewer {
|
|||||||
double sunHaloFallof,
|
double sunHaloFallof,
|
||||||
bool castShadows) {
|
bool castShadows) {
|
||||||
return viewer
|
return viewer
|
||||||
.addLight(
|
.addLight(LightType.values[type], colour, intensity, posX, posY, posZ,
|
||||||
LightType.values[type],
|
dirX, dirY, dirZ,
|
||||||
colour,
|
falloffRadius: falloffRadius,
|
||||||
intensity,
|
spotLightConeInner: spotLightConeInner,
|
||||||
posX,
|
spotLightConeOuter: spotLightConeOuter,
|
||||||
posY,
|
sunAngularRadius: sunAngularRadius,
|
||||||
posZ,
|
sunHaloSize: sunHaloSize,
|
||||||
dirX,
|
sunHaloFallof: sunHaloFallof,
|
||||||
dirY,
|
castShadows: castShadows)
|
||||||
dirZ,
|
|
||||||
falloffRadius:falloffRadius,
|
|
||||||
spotLightConeInner:spotLightConeInner,
|
|
||||||
spotLightConeOuter: spotLightConeOuter,
|
|
||||||
sunAngularRadius: sunAngularRadius,
|
|
||||||
sunHaloSize: sunHaloSize,
|
|
||||||
sunHaloFallof: sunHaloFallof,
|
|
||||||
castShadows: castShadows)
|
|
||||||
.then((entity) => entity.toJS)
|
.then((entity) => entity.toJS)
|
||||||
.toJS;
|
.toJS;
|
||||||
}
|
}
|
||||||
@@ -192,6 +185,15 @@ class DartFilamentJSExportViewer {
|
|||||||
return morphTargetNames.toJS;
|
return morphTargetNames.toJS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JSExport()
|
||||||
|
JSPromise<JSArray<JSString>> getBoneNames(
|
||||||
|
FilamentEntity entity, int skinIndex) {
|
||||||
|
return viewer
|
||||||
|
.getBoneNames(entity, skinIndex: skinIndex)
|
||||||
|
.then((v) => v.map((s) => s.toJS).toList().toJS)
|
||||||
|
.toJS;
|
||||||
|
}
|
||||||
|
|
||||||
@JSExport()
|
@JSExport()
|
||||||
JSPromise<JSArray<JSString>> getAnimationNames(FilamentEntity entity) =>
|
JSPromise<JSArray<JSString>> getAnimationNames(FilamentEntity entity) =>
|
||||||
viewer
|
viewer
|
||||||
@@ -219,7 +221,7 @@ class DartFilamentJSExportViewer {
|
|||||||
var animationDataDart = animation.toDart
|
var animationDataDart = animation.toDart
|
||||||
.map((x) => x.toDart.map((y) => y.toDartDouble).toList())
|
.map((x) => x.toDart.map((y) => y.toDartDouble).toList())
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
var morphAnimationData = MorphAnimationData(
|
var morphAnimationData = MorphAnimationData(
|
||||||
animationDataDart, morphTargetsDart,
|
animationDataDart, morphTargetsDart,
|
||||||
frameLengthInMs: frameLengthInMs);
|
frameLengthInMs: frameLengthInMs);
|
||||||
@@ -251,15 +253,35 @@ class DartFilamentJSExportViewer {
|
|||||||
JSPromise resetBones(FilamentEntity entity) => viewer.resetBones(entity).toJS;
|
JSPromise resetBones(FilamentEntity entity) => viewer.resetBones(entity).toJS;
|
||||||
|
|
||||||
@JSExport()
|
@JSExport()
|
||||||
JSPromise addBoneAnimation(FilamentEntity entity, JSObject animation) {
|
JSPromise addBoneAnimation(
|
||||||
throw UnimplementedError();
|
FilamentEntity entity,
|
||||||
|
JSArray<JSString> bones,
|
||||||
|
JSArray<JSString> meshNames,
|
||||||
|
JSArray<JSArray<JSArray<JSNumber>>> frameData,
|
||||||
|
JSNumber frameLengthInMs,
|
||||||
|
JSBoolean isModelSpace) {
|
||||||
|
var frameDataDart = frameData.toDart
|
||||||
|
.map((frame) => frame.toDart.map((v) {
|
||||||
|
var values = v.toDart;
|
||||||
|
var trans = v64.Vector3(values[0].toDartDouble, values[1].toDartDouble,
|
||||||
|
values[2].toDartDouble);
|
||||||
|
var rot = v64.Quaternion(
|
||||||
|
values[3].toDartDouble,
|
||||||
|
values[4].toDartDouble,
|
||||||
|
values[5].toDartDouble,
|
||||||
|
values[6].toDartDouble);
|
||||||
|
return (rotation:rot, translation:trans);
|
||||||
|
}).cast<BoneAnimationFrame>().toList())
|
||||||
|
.toList();
|
||||||
|
|
||||||
|
var data = BoneAnimationData(
|
||||||
|
bones.toDart.map((n) => n.toDart).toList(),
|
||||||
|
meshNames.toDart.map((n) => n.toDart).toList(),
|
||||||
|
frameDataDart,
|
||||||
|
frameLengthInMs.toDartDouble);
|
||||||
|
|
||||||
|
return viewer.addBoneAnimation(entity, data).toJS;
|
||||||
}
|
}
|
||||||
// viewer
|
|
||||||
// .addBoneAnimation(
|
|
||||||
// entity,
|
|
||||||
// BoneAnimationData._fromJSObject(animation),
|
|
||||||
// )
|
|
||||||
// .toJS;
|
|
||||||
|
|
||||||
@JSExport()
|
@JSExport()
|
||||||
JSPromise removeEntity(FilamentEntity entity) =>
|
JSPromise removeEntity(FilamentEntity entity) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user