throw error on web for setCameraModelMatrix

This commit is contained in:
Nick Fisher
2024-05-19 14:17:24 +08:00
parent 43b5cb040a
commit 4f9672cbbf

View File

@@ -2,6 +2,7 @@
library flutter_filament_js; library flutter_filament_js;
import 'dart:js_interop'; import 'dart:js_interop';
import 'dart:math';
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';
@@ -156,8 +157,10 @@ class DartFilamentJSExportViewer {
@JSExport() @JSExport()
JSPromise setMorphTargetWeights( JSPromise setMorphTargetWeights(
FilamentEntity entity, List<double> weights) => FilamentEntity entity, JSArray<JSNumber> weights) {
viewer.setMorphTargetWeights(entity, weights).toJS; var dartWeights = weights.toDart.map((w) => w.toDartDouble).toList();
return viewer.setMorphTargetWeights(entity, dartWeights).toJS;
}
@JSExport() @JSExport()
JSPromise<JSArray<JSString>> getMorphTargetNames( JSPromise<JSArray<JSString>> getMorphTargetNames(
@@ -195,7 +198,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);
@@ -214,8 +217,6 @@ class DartFilamentJSExportViewer {
.onError((err, st) { .onError((err, st) {
print("ERROR SETTING MORPH ANIMATION DATA : $err\n$st"); print("ERROR SETTING MORPH ANIMATION DATA : $err\n$st");
return null; return null;
}).then((r) {
print("set morph animation data complete");
}); });
return result.toJS; return result.toJS;
} catch (err, st) { } catch (err, st) {
@@ -418,8 +419,11 @@ class DartFilamentJSExportViewer {
throw UnimplementedError(); throw UnimplementedError();
// viewer.setCameraRotation(quaternion.toDartQuaternion()).toJS; // viewer.setCameraRotation(quaternion.toDartQuaternion()).toJS;
@JSExport() @JSExport()
JSPromise setCameraModelMatrix(List<double> matrix) => JSPromise setCameraModelMatrix(JSArray<JSNumber> matrix) {
viewer.setCameraModelMatrix(matrix).toJS; throw UnimplementedError();
// viewer.setCameraModelMatrix(matrix).toJS;
}
@JSExport() @JSExport()
JSPromise setMaterialColor(FilamentEntity entity, String meshName, JSPromise setMaterialColor(FilamentEntity entity, String meshName,
int materialIndex, double r, double g, double b, double a) => int materialIndex, double r, double g, double b, double a) =>