fix: shadow JS<->WASM bridge methods

This commit is contained in:
Nick Fisher
2024-07-04 16:29:08 +08:00
parent 5dec13f00b
commit ce71e09f65
3 changed files with 20 additions and 4 deletions

View File

@@ -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;
}
}

View File

@@ -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

View File

@@ -412,7 +412,7 @@ extension type ThermionViewerJSShim(JSObject _) implements JSObject {
@JS('setShadowType')
external JSPromise setShadowType(
ShadowType shadowType);
int shadowType);
@JS('setSoftShadowOptions')
external JSPromise setSoftShadowOptions(