From ce71e09f65221399c4f863c794df9c0e9996b4d9 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 4 Jul 2024 16:29:08 +0800 Subject: [PATCH] fix: shadow JS<->WASM bridge methods --- .../interop/thermion_viewer_dart_bridge.dart | 20 +++++++++++++++++-- .../web/interop/thermion_viewer_js.dart | 2 +- .../web/interop/thermion_viewer_js_shim.dart | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_dart_bridge.dart b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_dart_bridge.dart index 85db072c..4878e0fa 100644 --- a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_dart_bridge.dart +++ b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_dart_bridge.dart @@ -135,8 +135,8 @@ class ThermionViewerJSDartBridge { .loadGlb(path, numInstances: numInstances) .then((entity) => entity.toJS) .catchError((err) { - print("Error: $err"); - }).toJS; + print("Error: $err"); + }).toJS; } @JSExport() @@ -720,4 +720,20 @@ class ThermionViewerJSDartBridge { {JSFunction? callback, bool affectsTransform = false}) { throw UnimplementedError(); } + + @JSExport() + JSPromise setShadowsEnabled(bool enabled) { + return viewer.setShadowsEnabled(enabled).toJS; + } + + @JSExport() + JSPromise setShadowType(int shadowType) { + return viewer.setShadowType(ShadowType.values[shadowType]).toJS; + } + + @JSExport() + JSPromise setSoftShadowOptions( + double penumbraScale, double penumbraRatioScale) { + return viewer.setSoftShadowOptions(penumbraScale, penumbraRatioScale).toJS; + } } diff --git a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js.dart b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js.dart index 6c924179..18acf36c 100644 --- a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js.dart +++ b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js.dart @@ -829,7 +829,7 @@ class ThermionViewerJS implements ThermionViewer { @override Future setShadowType(ShadowType shadowType) { - return _shim.setShadowType(shadowType).toDart; + return _shim.setShadowType(shadowType.index).toDart; } @override diff --git a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js_shim.dart b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js_shim.dart index b7492b4a..3b4fadfd 100644 --- a/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js_shim.dart +++ b/thermion_dart/lib/thermion_dart/compatibility/web/interop/thermion_viewer_js_shim.dart @@ -412,7 +412,7 @@ extension type ThermionViewerJSShim(JSObject _) implements JSObject { @JS('setShadowType') external JSPromise setShadowType( - ShadowType shadowType); + int shadowType); @JS('setSoftShadowOptions') external JSPromise setSoftShadowOptions(