diff --git a/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_dart_bridge.dart b/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_dart_bridge.dart deleted file mode 100644 index 70e2b061..00000000 --- a/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_dart_bridge.dart +++ /dev/null @@ -1,759 +0,0 @@ -// @JS() -// library thermion_flutter_js; - -// import 'dart:js_interop'; -// import 'package:logging/logging.dart'; -// import 'package:vector_math/vector_math_64.dart' as v64; -// import 'package:animation_tools_dart/animation_tools_dart.dart'; -// import 'dart:js_interop_unsafe'; -// import 'package:vector_math/vector_math_64.dart'; -// import '../../../viewer.dart'; -// import 'thermion_viewer_js_shim.dart'; - -// /// -// /// A (Dart) class that wraps a (Dart) instance of [ThermionViewer], -// /// but exported to JS by binding to a global property. -// /// This is effectively an implementation of [ThermionViewerJSShim]; -// /// allowing users to interact with an instance of [ThermionViewer] -// /// (presumably compiled to WASM) from any Javascript context (including -// /// the browser console). -// /// -// @JSExport() -// class ThermionViewerJSDartBridge { -// final _logger = Logger("ThermionViewerJSDartBridge"); -// final ThermionViewer viewer; - -// ThermionViewerJSDartBridge(this.viewer); - -// void bind({String globalPropertyName = "thermionViewer"}) { -// var wrapper = createJSInteropWrapper(this) -// as ThermionViewerJSShim; -// globalContext.setProperty(globalPropertyName.toJS, wrapper); -// } - -// JSPromise get initialized { -// return viewer.initialized.then((v) => v.toJS).toJS; -// } - -// @JSExport() -// JSBoolean get rendering => viewer.rendering.toJS; - -// @JSExport() -// JSPromise setRendering(bool render) { -// return viewer.setRendering(render).toJS; -// } - -// @JSExport() -// JSPromise render() => viewer.render().toJS; - -// @JSExport() -// JSPromise capture() { -// return viewer.capture().then((captured) => captured.toJS).toJS; -// } - -// @JSExport() -// JSPromise setFrameRate(int framerate) => viewer.setFrameRate(framerate).toJS; - -// @JSExport() -// JSPromise dispose() => viewer.dispose().toJS; - -// @JSExport() -// JSPromise setBackgroundImage(String path, {bool fillHeight = false}) => -// viewer.setBackgroundImage(path, fillHeight: fillHeight).toJS; - -// @JSExport() -// JSPromise setBackgroundImagePosition(double x, double y, -// {bool clamp = false}) => -// viewer.setBackgroundImagePosition(x, y, clamp: clamp).toJS; - -// @JSExport() -// JSPromise clearBackgroundImage() => viewer.clearBackgroundImage().toJS; - -// @JSExport() -// JSPromise setBackgroundColor(double r, double g, double b, double alpha) => -// viewer.setBackgroundColor(r, g, b, alpha).toJS; - -// @JSExport() -// JSPromise loadSkybox(String skyboxPath) => viewer.loadSkybox(skyboxPath).toJS; - -// @JSExport() -// JSPromise removeSkybox() => viewer.removeSkybox().toJS; - -// @JSExport() -// JSPromise loadIbl(String lightingPath, double intensity) { -// _logger.info("Loading IBL from $lightingPath with intensity $intensity"); -// return viewer.loadIbl(lightingPath, intensity: intensity).toJS; -// } - -// @JSExport() -// JSPromise rotateIbl(JSArray rotation) { -// var matrix = -// Matrix3.fromList(rotation.toDart.map((v) => v.toDartDouble).toList()); -// return viewer.rotateIbl(matrix).toJS; -// } - -// @JSExport() -// JSPromise removeIbl() => viewer.removeIbl().toJS; - -// @JSExport() -// JSPromise addLight( -// int type, -// double colour, -// double intensity, -// double posX, -// double posY, -// double posZ, -// double dirX, -// double dirY, -// double dirZ, -// double falloffRadius, -// double spotLightConeInner, -// double spotLightConeOuter, -// double sunAngularRadius, -// double sunHaloSize, -// double sunHaloFallof, -// bool castShadows) { -// return viewer -// .addLight(LightType.values[type], colour, intensity, posX, posY, posZ, -// dirX, dirY, dirZ, -// falloffRadius: falloffRadius, -// spotLightConeInner: spotLightConeInner, -// spotLightConeOuter: spotLightConeOuter, -// sunAngularRadius: sunAngularRadius, -// sunHaloSize: sunHaloSize, -// sunHaloFallof: sunHaloFallof, -// castShadows: castShadows) -// .then((entity) => entity.toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise removeLight(ThermionEntity light) => viewer.removeLight(light).toJS; - -// @JSExport() -// JSPromise destroyLights() => viewer.destroyLights().toJS; - -// @JSExport() -// JSPromise loadGlb(String path, {int numInstances = 1}) { -// _logger.info("Loading GLB from path $path with numInstances $numInstances"); -// return viewer -// .loadGlb(path, numInstances: numInstances) -// .then((entity) => entity.toJS) -// .catchError((err) { -// _logger.info("Error: $err"); -// }).toJS; -// } - -// @JSExport() -// JSPromise createInstance(ThermionEntity entity) { -// return viewer.createInstance(entity).then((instance) => instance.toJS).toJS; -// } - -// @JSExport() -// JSPromise getInstanceCount(ThermionEntity entity) => -// viewer.getInstanceCount(entity).then((v) => v.toJS).toJS; - -// @JSExport() -// JSPromise> getInstances(ThermionEntity entity) { -// return viewer -// .getInstances(entity) -// .then((instances) => -// instances.map((instance) => instance.toJS).toList().toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise loadGltf(String path, String relativeResourcePath, -// {bool keepData = false}) { -// return viewer -// .loadGltf(path, relativeResourcePath, keepData: keepData) -// .then((entity) => entity.toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise panStart(double x, double y) => viewer.panStart(x, y).toJS; - -// @JSExport() -// JSPromise panUpdate(double x, double y) => viewer.panUpdate(x, y).toJS; - -// @JSExport() -// JSPromise panEnd() => viewer.panEnd().toJS; - -// @JSExport() -// JSPromise rotateStart(double x, double y) => viewer.rotateStart(x, y).toJS; - -// @JSExport() -// JSPromise rotateUpdate(double x, double y) => viewer.rotateUpdate(x, y).toJS; - -// @JSExport() -// JSPromise rotateEnd() => viewer.rotateEnd().toJS; - -// @JSExport() -// JSPromise setMorphTargetWeights( -// ThermionEntity entity, JSArray weights) { -// var dartWeights = weights.toDart.map((w) => w.toDartDouble).toList(); -// return viewer.setMorphTargetWeights(entity, dartWeights).toJS; -// } - -// @JSExport() -// JSPromise> getMorphTargetNames( -// ThermionEntity entity, ThermionEntity childEntity) { -// var morphTargetNames = viewer -// .getMorphTargetNames(entity, childEntity) -// .then((v) => v.map((s) => s.toJS).toList().toJS); -// return morphTargetNames.toJS; -// } - -// @JSExport() -// JSPromise> getBoneNames( -// ThermionEntity entity, int skinIndex) { -// return viewer -// .getBoneNames(entity, skinIndex: skinIndex) -// .then((v) => v.map((s) => s.toJS).toList().toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise> getAnimationNames(ThermionEntity entity) => -// viewer -// .getAnimationNames(entity) -// .then((v) => v.map((s) => s.toJS).toList().toJS) -// .toJS; - -// @JSExport() -// JSPromise getAnimationDuration( -// ThermionEntity entity, int animationIndex) => -// viewer -// .getAnimationDuration(entity, animationIndex) -// .then((v) => v.toJS) -// .toJS; - -// @JSExport() -// void clearMorphAnimationData(ThermionEntity entity) { -// viewer.clearMorphAnimationData(entity); -// } - -// @JSExport() -// JSPromise setMorphAnimationData( -// ThermionEntity entity, -// JSArray> animation, -// JSArray morphTargets, -// JSArray? targetMeshNames, -// double frameLengthInMs) { -// try { -// var morphTargetsDart = morphTargets.toDart.map((m) => m.toDart).toList(); -// var animationDataDart = animation.toDart -// .map((x) => x.toDart.map((y) => y.toDartDouble).toList()) -// .toList(); - -// var morphAnimationData = MorphAnimationData( -// animationDataDart, morphTargetsDart, -// frameLengthInMs: frameLengthInMs); -// var targetMeshNamesDart = -// targetMeshNames?.toDart.map((x) => x.toDart).toList(); -// if (animationDataDart.first.length != morphTargetsDart.length) { -// throw Exception( -// "Length mismatch between morph targets and animation data"); -// } -// var result = viewer -// .setMorphAnimationData( -// entity, -// morphAnimationData, -// targetMeshNames: targetMeshNamesDart, -// ) -// .onError((err, st) { -// _logger.severe("ERROR SETTING MORPH ANIMATION DATA : $err\n$st"); -// return null; -// }); -// return result.toJS; -// } catch (err, st) { -// _logger.severe(err); -// _logger.severe(st); -// rethrow; -// } -// } - -// @JSExport() -// JSPromise resetBones(ThermionEntity entity) => viewer.resetBones(entity).toJS; - -// @JSExport() -// JSPromise addBoneAnimation( -// ThermionEntity entity, -// JSArray bones, -// JSArray>> frameData, -// JSNumber frameLengthInMs, -// JSNumber spaceEnum, -// JSNumber skinIndex, -// JSNumber fadeInInSecs, -// JSNumber fadeOutInSecs, -// JSNumber maxDelta) { -// 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() -// .toList()) -// .toList(); - -// var data = BoneAnimationData( -// bones.toDart.map((n) => n.toDart).toList(), frameDataDart, -// frameLengthInMs: frameLengthInMs.toDartDouble, -// space: Space.values[spaceEnum.toDartInt]); - -// return viewer -// .addBoneAnimation(entity, data, -// skinIndex: skinIndex.toDartInt, -// fadeInInSecs: fadeInInSecs.toDartDouble, -// fadeOutInSecs: fadeOutInSecs.toDartDouble) -// .toJS; -// } - -// @JSExport() -// JSPromise destroyAsset(ThermionEntity entity) => -// viewer.destroyAsset(entity).toJS; - -// @JSExport() -// JSPromise destroyAssets() { -// return viewer.destroyAssets().toJS; -// } - -// @JSExport() -// JSPromise zoomBegin() => viewer.zoomBegin().toJS; - -// @JSExport() -// JSPromise zoomUpdate(double x, double y, double z) => -// viewer.zoomUpdate(x, y, z).toJS; - -// @JSExport() -// JSPromise zoomEnd() => viewer.zoomEnd().toJS; - -// @JSExport() -// JSPromise playAnimation(ThermionEntity entity, int index, -// {bool loop = false, -// bool reverse = false, -// bool replaceActive = true, -// double crossfade = 0.0, -// double startOffset = 0.0}) => -// viewer -// .playAnimation(entity, index, -// loop: loop, -// reverse: reverse, -// replaceActive: replaceActive, -// crossfade: crossfade, -// startOffset: startOffset) -// .toJS; - -// @JSExport() -// JSPromise playAnimationByName(ThermionEntity entity, String name, -// {bool loop = false, -// bool reverse = false, -// bool replaceActive = true, -// double crossfade = 0.0}) => -// viewer -// .playAnimationByName( -// entity, -// name, -// loop: loop, -// reverse: reverse, -// replaceActive: replaceActive, -// crossfade: crossfade, -// ) -// .toJS; - -// @JSExport() -// JSPromise setAnimationFrame( -// ThermionEntity entity, int index, int animationFrame) => -// viewer -// .setAnimationFrame( -// entity, -// index, -// animationFrame, -// ) -// .toJS; - -// @JSExport() -// JSPromise stopAnimation(ThermionEntity entity, int animationIndex) => -// viewer.stopAnimation(entity, animationIndex).toJS; - -// @JSExport() -// JSPromise stopAnimationByName(ThermionEntity entity, String name) => -// viewer.stopAnimationByName(entity, name).toJS; - -// @JSExport() -// JSPromise setCamera(ThermionEntity entity, String? name) => -// viewer.setCamera(entity, name).toJS; - -// @JSExport() -// JSPromise setMainCamera() => viewer.setMainCamera().toJS; - -// @JSExport() -// JSPromise getMainCamera() { -// throw UnimplementedError("TODO"); -// // return viewer.getMainCamera().then((camera) => camera.toJS).toJS; -// } - -// @JSExport() -// JSPromise setParent( -// ThermionEntity child, ThermionEntity parent, bool preserveScaling) { -// return viewer -// .setParent(child, parent, preserveScaling: preserveScaling) -// .toJS; -// } - -// @JSExport() -// JSPromise setCameraFov(double degrees, bool horizontal) => -// viewer.setCameraFov(degrees, horizontal: horizontal).toJS; - -// @JSExport() -// JSPromise setToneMapping(int mapper) => -// viewer.setToneMapping(ToneMapper.values[mapper]).toJS; - -// @JSExport() -// JSPromise setBloom(double bloom) => viewer.setBloom(bloom).toJS; - -// @JSExport() -// JSPromise setCameraFocalLength(double focalLength) => -// viewer.setCameraFocalLength(focalLength).toJS; - -// @JSExport() -// JSPromise setCameraCulling(double near, double far) => -// viewer.setCameraCulling(near, far).toJS; - -// @JSExport() -// JSPromise getCameraCullingNear() => -// viewer.getCameraCullingNear().then((v) => v.toJS).toJS; - -// @JSExport() -// JSPromise getCameraCullingFar() => -// viewer.getCameraCullingFar().then((v) => v.toJS).toJS; - -// @JSExport() -// JSPromise setCameraFocusDistance(double focusDistance) => -// viewer.setCameraFocusDistance(focusDistance).toJS; - -// @JSExport() -// JSPromise> getCameraPosition() { -// throw UnimplementedError(); -// // return viewer.getCameraPosition().then((position) => position.toJS).toJS; -// } - -// @JSExport() -// JSPromise> getCameraModelMatrix() { -// throw UnimplementedError(); -// // return viewer.getCameraModelMatrix().then((matrix) => matrix.toJSArray()).toJS; -// } - -// @JSExport() -// JSPromise> getCameraViewMatrix() { -// throw UnimplementedError(); -// // return viewer.getCameraViewMatrix().then((matrix) => matrix.toJSArray()).toJS; -// } - -// @JSExport() -// JSPromise> getCameraProjectionMatrix() { -// throw UnimplementedError(); -// // return viewer.getCameraProjectionMatrix().then((matrix) => matrix.toJSArray()).toJS; -// } - -// @JSExport() -// JSPromise> getCameraCullingProjectionMatrix() { -// throw UnimplementedError(); -// // return viewer.getCameraCullingProjectionMatrix().then((matrix) => matrix.toJSArray()).toJS; -// } - -// @JSExport() -// JSPromise getCameraFrustum() { -// throw UnimplementedError(); -// // return viewer.getCameraFrustum().then((frustum) => frustum.toJS).toJS; -// } - -// @JSExport() -// JSPromise setCameraPosition(double x, double y, double z) => -// viewer.setCameraPosition(x, y, z).toJS; -// @JSExport() -// JSPromise> getCameraRotation() { -// return viewer -// .getCameraRotation() -// .then((rotation) => rotation.storage.map((v) => v.toJS).toList().toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise moveCameraToAsset(ThermionEntity entity) => -// throw UnimplementedError(); -// // viewer.moveCameraToAsset(entity)).toJS; - -// @JSExport() -// JSPromise setViewFrustumCulling(JSBoolean enabled) => -// throw UnimplementedError(); -// // viewer.setViewFrustumCulling(enabled).toJS; - -// @JSExport() -// JSPromise setCameraExposure( -// double aperture, double shutterSpeed, double sensitivity) => -// viewer.setCameraExposure(aperture, shutterSpeed, sensitivity).toJS; - -// @JSExport() -// JSPromise setCameraRotation(JSArray quaternion) { -// var dartVals = quaternion.toDart; -// return viewer -// .setCameraRotation(v64.Quaternion( -// dartVals[0].toDartDouble, -// dartVals[1].toDartDouble, -// dartVals[2].toDartDouble, -// dartVals[3].toDartDouble)) -// .toJS; -// } - -// @JSExport() -// JSPromise setCameraModelMatrix(JSArray matrix) { -// throw UnimplementedError(); -// // viewer.setCameraModelMatrix(matrix).toJS; -// } - -// @JSExport() -// JSPromise setMaterialColor(ThermionEntity entity, String meshName, -// int materialIndex, double r, double g, double b, double a) => -// throw UnimplementedError(); -// // viewer.setMaterialColor( -// // entity), -// // meshName, -// // materialIndex, -// // r, -// // g, -// // b, -// // a, -// // ).toJS; - -// @JSExport() -// JSPromise transformToUnitCube(ThermionEntity entity) => -// viewer.transformToUnitCube(entity).toJS; - -// @JSExport() -// JSPromise setPosition(ThermionEntity entity, double x, double y, double z) => -// viewer.setPosition(entity, x, y, z).toJS; -// @JSExport() -// JSPromise setScale(ThermionEntity entity, double scale) => -// viewer.setScale(entity, scale).toJS; -// @JSExport() -// JSPromise setRotation( -// ThermionEntity entity, double rads, double x, double y, double z) => -// viewer.setRotation(entity, rads, x, y, z).toJS; -// @JSExport() -// JSPromise queuePositionUpdate( -// ThermionEntity entity, double x, double y, double z, bool relative) => -// viewer -// .queuePositionUpdate( -// entity, -// x, -// y, -// z, -// relative: relative, -// ) -// .toJS; -// @JSExport() -// JSPromise queueRotationUpdate(ThermionEntity entity, double rads, double x, -// double y, double z, bool relative) => -// viewer -// .queueRotationUpdate( -// entity, -// rads, -// x, -// y, -// z, -// relative: relative, -// ) -// .toJS; -// @JSExport() -// JSPromise queueRotationUpdateQuat( -// ThermionEntity entity, JSArray quat, JSBoolean relative) => -// throw UnimplementedError(); -// // viewer.queueRotationUpdateQuat( -// // entity, -// // quat.toDartQuaternion(), -// // relative: relative, -// // ).toJS; - -// @JSExport() -// JSPromise setPostProcessing(bool enabled) => -// viewer.setPostProcessing(enabled).toJS; - -// @JSExport() -// JSPromise setAntiAliasing(bool msaa, bool fxaa, bool taa) => -// viewer.setAntiAliasing(msaa, fxaa, taa).toJS; - -// @JSExport() -// JSPromise setRotationQuat( -// ThermionEntity entity, JSArray rotation) => -// throw UnimplementedError(); - -// @JSExport() -// JSPromise reveal(ThermionEntity entity, String? meshName) => -// viewer.reveal(entity, meshName).toJS; - -// @JSExport() -// JSPromise hide(ThermionEntity entity, String? meshName) => -// viewer.hide(entity, meshName).toJS; - -// @JSExport() -// void pick(int x, int y) => viewer.pick(x, y); - -// @JSExport() -// String? getNameForEntity(ThermionEntity entity) => -// viewer.getNameForEntity(entity); - -// @JSExport() -// JSPromise setCameraManipulatorOptions({ -// int mode = 0, -// double orbitSpeedX = 0.01, -// double orbitSpeedY = 0.01, -// double zoomSpeed = 0.01, -// }) => -// viewer -// .setCameraManipulatorOptions( -// mode: ManipulatorMode.values[mode], -// orbitSpeedX: orbitSpeedX, -// orbitSpeedY: orbitSpeedY, -// zoomSpeed: zoomSpeed, -// ) -// .toJS; - -// @JSExport() -// JSPromise> getChildEntities( -// ThermionEntity parent, bool renderableOnly) { -// return viewer -// .getChildEntities( -// parent, -// renderableOnly, -// ) -// .then((entities) => entities.map((entity) => entity.toJS).toList().toJS) -// .onError((e, st) async { -// _logger.severe("Error : $e\n$st"); -// return [].toJS; -// }).toJS; -// } - -// @JSExport() -// JSPromise getChildEntity(ThermionEntity parent, String childName) { -// return viewer -// .getChildEntity( -// parent, -// childName, -// ) -// .then((entity) => entity.toJS) -// .onError((e, st) async { -// _logger.severe("Error getChildEntity : $e\n$st"); -// return 0.toJS; -// }).toJS; -// } - -// @JSExport() -// JSPromise> getChildEntityNames( -// ThermionEntity entity, bool renderableOnly) => -// viewer -// .getChildEntityNames( -// entity, -// renderableOnly: renderableOnly, -// ) -// .then((v) => v.map((s) => s.toJS).toList().toJS) -// .toJS; - -// @JSExport() -// JSPromise setRecording(bool recording) => viewer.setRecording(recording).toJS; - -// @JSExport() -// JSPromise setRecordingOutputDirectory(String outputDirectory) => -// viewer.setRecordingOutputDirectory(outputDirectory).toJS; - -// @JSExport() -// JSPromise addAnimationComponent(ThermionEntity entity) => -// viewer.addAnimationComponent(entity).toJS; - -// @JSExport() -// JSPromise removeAnimationComponent(ThermionEntity entity) => -// viewer.removeAnimationComponent(entity).toJS; - -// @JSExport() -// JSPromise getParent(ThermionEntity entity) => -// viewer.removeAnimationComponent(entity).toJS; - -// @JSExport() -// JSPromise getBone(ThermionEntity entity, int boneIndex, int skinIndex) => -// viewer.getBone(entity, boneIndex, skinIndex: skinIndex).toJS; - -// @JSExport() -// JSPromise> getLocalTransform(ThermionEntity entity) { -// return viewer -// .getLocalTransform(entity) -// .then((t) => t.storage.map((v) => v.toJS).toList().toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise> getWorldTransform(ThermionEntity entity) { -// return viewer -// .getWorldTransform(entity) -// .then((t) => t.storage.map((v) => v.toJS).toList().toJS) -// .toJS; -// } - -// @JSExport() -// JSPromise setTransform(ThermionEntity entity, JSArray transform) { -// return viewer -// .setTransform( -// entity, -// Matrix4.fromList( -// transform.toDart.map((v) => v.toDartDouble).toList())) -// .toJS; -// } - -// @JSExport() -// JSPromise updateBoneMatrices(ThermionEntity entity) { -// return viewer.updateBoneMatrices(entity).toJS; -// } - -// @JSExport() -// JSPromise setBoneTransform(ThermionEntity entity, int boneIndex, -// JSArray transform, int skinIndex) { -// return viewer -// .setBoneTransform( -// entity, -// boneIndex, -// Matrix4.fromList( -// transform.toDart.map((v) => v.toDartDouble).toList()), -// skinIndex: skinIndex) -// .toJS; -// } - -// @JSExport() -// JSPromise addCollisionComponent(ThermionEntity entity, -// {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/src/viewer/src/web_js/src/thermion_viewer_js.dart b/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_js.dart deleted file mode 100644 index d53a67c8..00000000 --- a/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_js.dart +++ /dev/null @@ -1,1107 +0,0 @@ -// import 'dart:js_interop'; -// import 'dart:js_interop_unsafe'; -// import 'dart:math'; -// import 'dart:typed_data'; - -// import 'package:animation_tools_dart/animation_tools_dart.dart'; -// import 'package:logging/logging.dart'; -// import 'package:vector_math/vector_math_64.dart'; -// import '../../shared_types/internal/gizmo.dart'; -// import '../../../viewer.dart'; -// import '../../events.dart'; -// import '../../shared_types/camera.dart'; -// import 'thermion_viewer_js_shim.dart'; - -// /// -// /// An [ThermionViewer] implementation that forwards calls to -// /// a corresponding Javascript shim implementation (see [ThermionViewerJSShim]). -// /// -// class ThermionViewerJS implements ThermionViewer { -// final _logger = Logger("ThermionViewerJS"); -// late final ThermionViewerJSShim _shim; - -// ThermionViewerJS.fromGlobalProperty(String globalPropertyName) { -// this._shim = globalContext.getProperty(globalPropertyName.toJS) -// as ThermionViewerJSShim; -// } - -// ThermionViewerJS(this._shim); - -// @override -// Future get initialized async { -// var inited = _shim.initialized; -// final JSBoolean result = await inited.toDart; -// return result.toDart; -// } - -// @override -// Stream get pickResult { -// throw UnimplementedError(); -// } - -// @override -// bool get rendering => _shim.rendering; - -// @override -// Future setRendering(bool render) async { -// await _shim.setRendering(render).toDart; -// } - -// @override -// Future render() async { -// await _shim.render().toDart; -// } - -// @override -// Future setFrameRate(int framerate) async { -// await _shim.setFrameRate(framerate).toDart; -// } - -// @override -// Future dispose() async { -// await _shim.dispose().toDart; -// for (final callback in _onDispose) { -// callback.call(); -// } -// } - -// @override -// Future setBackgroundImage(String path, -// {bool fillHeight = false}) async { -// await _shim.setBackgroundImage(path, fillHeight).toDart; -// } - -// @override -// Future setBackgroundImagePosition(double x, double y, -// {bool clamp = false}) async { -// await _shim.setBackgroundImagePosition(x, y, clamp).toDart; -// } - -// @override -// Future clearBackgroundImage() async { -// await _shim.clearBackgroundImage().toDart; -// } - -// @override -// Future setBackgroundColor( -// double r, double g, double b, double alpha) async { -// await _shim.setBackgroundColor(r, g, b, alpha).toDart; -// } - -// @override -// Future loadSkybox(String skyboxPath) async { -// await _shim.loadSkybox(skyboxPath).toDart; -// } - -// @override -// Future removeSkybox() async { -// await _shim.removeSkybox().toDart; -// } - -// @override -// Future loadIbl(String lightingPath, {double intensity = 30000}) async { -// await _shim.loadIbl(lightingPath, intensity).toDart; -// } - -// @override -// Future rotateIbl(Matrix3 rotation) async { -// await _shim -// .rotateIbl(rotation.storage.map((v) => v.toJS).toList().toJS) -// .toDart; -// } - -// @override -// Future removeIbl() async { -// await _shim.removeIbl().toDart; -// } - -// @override -// Future addLight( -// LightType type, -// double colour, -// double intensity, -// double posX, -// double posY, -// double posZ, -// double dirX, -// double dirY, -// double dirZ, -// {double falloffRadius = 1.0, -// double spotLightConeInner = pi / 8, -// double spotLightConeOuter = pi / 4, -// double sunAngularRadius = 0.545, -// double sunHaloSize = 10.0, -// double sunHaloFallof = 80.0, -// bool castShadows = true}) async { -// return (await _shim -// .addLight( -// type.index, -// colour, -// intensity, -// posX, -// posY, -// posZ, -// dirX, -// dirY, -// dirZ, -// falloffRadius, -// spotLightConeInner, -// spotLightConeOuter, -// sunAngularRadius, -// sunHaloSize, -// sunHaloFallof, -// castShadows) -// .toDart) -// .toDartInt; -// } - -// @override -// Future removeLight(ThermionEntity light) async { -// await _shim.removeLight(light).toDart; -// } - -// @override -// Future destroyLights() async { -// await _shim.destroyLights().toDart; -// } - -// @override -// Future loadGlb(String path, {int numInstances = 1, bool keepData=false}) async { -// var entity = (await _shim.loadGlb(path, numInstances).toDart).toDartInt; -// return entity; -// } - -// @override -// Future createInstance(ThermionEntity entity) async { -// return (await _shim.createInstance(entity).toDart).toDartInt; -// } - -// @override -// Future getInstanceCount(ThermionEntity entity) async { -// return (await _shim.getInstanceCount(entity).toDart).toDartInt; -// } - -// @override -// Future> getInstances(ThermionEntity entity) async { -// throw UnimplementedError(); -// // final List jsInstances = -// // await _shim.getInstances(entity).toDart; -// // return jsInstances -// // .map((js) => ThermionEntity._fromJSObject(js)) -// // .toList() -// // .toDart; -// } - -// @override -// Future loadGltf(String path, String relativeResourcePath, -// {bool keepData = false}) async { -// throw UnimplementedError(); -// // final ThermionEntity jsEntity = await _shim -// // .loadGltf(path, relativeResourcePath, force: force) -// // .toDart; -// // return ThermionEntity._fromJSObject(jsEntity).toDart; -// } - -// @override -// Future panStart(double x, double y) async { -// await _shim.panStart(x, y).toDart; -// } - -// @override -// Future panUpdate(double x, double y) async { -// await _shim.panUpdate(x, y).toDart; -// } - -// @override -// Future panEnd() async { -// await _shim.panEnd().toDart; -// } - -// @override -// Future rotateStart(double x, double y) async { -// await _shim.rotateStart(x, y).toDart; -// } - -// @override -// Future rotateUpdate(double x, double y) async { -// await _shim.rotateUpdate(x, y).toDart; -// } - -// @override -// Future rotateEnd() async { -// await _shim.rotateEnd().toDart; -// } - -// @override -// Future setMorphTargetWeights( -// ThermionEntity entity, List weights) async { -// var jsWeights = weights.map((x) => x.toJS).cast().toList().toJS; -// var promise = _shim.setMorphTargetWeights(entity, jsWeights); -// await promise.toDart; -// } - -// @override -// Future> getMorphTargetNames( -// ThermionEntity entity, ThermionEntity childEntity) async { -// var result = await _shim.getMorphTargetNames(entity, childEntity).toDart; -// return result.toDart.map((r) => r.toDart).toList(); -// } - -// @override -// Future> getAnimationNames(ThermionEntity entity) async { -// var names = (await (_shim.getAnimationNames(entity).toDart)) -// .toDart -// .map((x) => x.toDart) -// .toList(); -// return names; -// } - -// @override -// Future getAnimationDuration( -// ThermionEntity entity, int animationIndex) async { -// return (await _shim.getAnimationDuration(entity, animationIndex).toDart) -// .toDartDouble; -// } - -// @override -// Future clearMorphAnimationData(ThermionEntity entity) async { -// _shim.clearMorphAnimationData(entity); -// } - -// @override -// Future setMorphAnimationData( -// ThermionEntity entity, MorphAnimationData animation, -// {List? targetMeshNames}) async { -// try { -// var animationDataJs = animation.data -// .map((x) => x.map((y) => y.toJS).toList().toJS) -// .toList() -// .toJS; -// var morphTargetsJs = animation.morphTargets -// .map((x) => x.toJS) -// .cast() -// .toList() -// .toJS; -// var targetMeshNamesJS = -// targetMeshNames?.map((x) => x.toJS).cast().toList().toJS; -// await _shim -// .setMorphAnimationData(entity, animationDataJs, morphTargetsJs, -// targetMeshNamesJS, animation.frameLengthInMs) -// .toDart; -// } catch (err, st) { -// _logger.severe(err); -// _logger.severe(st); -// rethrow; -// } -// } - -// @override -// Future resetBones(ThermionEntity entity) async { -// await _shim.resetBones(entity).toDart; -// } - -// @override -// Future addBoneAnimation( -// ThermionEntity entity, BoneAnimationData animation, -// {int skinIndex = 0, -// double fadeInInSecs = 0.0, -// double fadeOutInSecs = 0.0, -// double maxDelta = 1.0}) async { -// var boneNames = animation.bones.map((n) => n.toJS).toList().toJS; -// var frameData = animation.frameData -// .map((frame) => frame -// .map((q) => [ -// q.translation[0].toJS, -// q.translation[1].toJS, -// q.translation[2].toJS, -// q.rotation.x.toJS, -// q.rotation.y.toJS, -// q.rotation.z.toJS, -// q.rotation.w.toJS, -// ].toJS) -// .toList() -// .toJS) -// .toList() -// .toJS; - -// await _shim -// .addBoneAnimation( -// entity, -// boneNames, -// frameData, -// animation.frameLengthInMs.toJS, -// animation.space.index.toJS, -// skinIndex.toJS, -// fadeInInSecs.toJS, -// fadeOutInSecs.toJS, -// maxDelta.toJS) -// .toDart; -// } - -// @override -// Future destroyAsset(ThermionEntity entity) async { -// await _shim.destroyAsset(entity).toDart; -// } - -// @override -// Future destroyAssets() async { -// await _shim.destroyAssets().toDart; -// } - -// @override -// Future zoomBegin() async { -// await _shim.zoomBegin().toDart; -// } - -// @override -// Future zoomUpdate(double x, double y, double z) async { -// await _shim.zoomUpdate(x, y, z).toDart; -// } - -// @override -// Future zoomEnd() async { -// await _shim.zoomEnd().toDart; -// } - -// @override -// Future playAnimation(ThermionEntity entity, int index, -// {bool loop = false, -// bool reverse = false, -// bool replaceActive = true, -// double crossfade = 0.0, -// double startOffset = 0.0}) async { -// await _shim -// .playAnimation( -// entity, index, loop, reverse, replaceActive, crossfade, startOffset) -// .toDart; -// } - -// @override -// Future playAnimationByName(ThermionEntity entity, String name, -// {bool loop = false, -// bool reverse = false, -// bool replaceActive = true, -// double crossfade = 0.0}) async { -// await _shim -// .playAnimationByName( -// entity, name, loop, reverse, replaceActive, crossfade) -// .toDart; -// } - -// @override -// Future setAnimationFrame( -// ThermionEntity entity, int index, int animationFrame) async { -// await _shim.setAnimationFrame(entity, index, animationFrame).toDart; -// } - -// @override -// Future stopAnimation(ThermionEntity entity, int animationIndex) async { -// await _shim.stopAnimation(entity, animationIndex).toDart; -// } - -// @override -// Future stopAnimationByName(ThermionEntity entity, String name) async { -// await _shim.stopAnimationByName(entity, name).toDart; -// } - -// @override -// Future setCamera(ThermionEntity entity, String? name) async { -// await _shim.setCamera(entity, name).toDart; -// } - -// @override -// Future setMainCamera() async { -// await _shim.setMainCamera().toDart; -// } - -// @override -// Future getMainCamera() async { -// throw UnimplementedError(); -// // final ThermionEntity jsEntity = await _shim.getMainCamera().toDart; -// // return ThermionEntity._fromJSObject(jsEntity).toDart; -// } - -// @override -// Future setCameraFov(double degrees, {bool horizontal = true}) async { -// await _shim.setCameraFov(degrees, horizontal).toDart; -// } - -// @override -// Future setToneMapping(ToneMapper mapper) async { -// await _shim.setToneMapping(mapper.index).toDart; -// } - -// @override -// Future setBloom(double bloom) async { -// await _shim.setBloom(bloom).toDart; -// } - -// @override -// Future setCameraFocalLength(double focalLength) async { -// await _shim.setCameraFocalLength(focalLength).toDart; -// } - -// @override -// Future setCameraCulling(double near, double far) async { -// await _shim.setCameraCulling(near, far).toDart; -// } - -// @override -// Future getCameraCullingNear() async { -// return (await _shim.getCameraCullingNear().toDart).toDartDouble; -// } - -// @override -// Future getCameraCullingFar() async { -// return (await _shim.getCameraCullingFar().toDart).toDartDouble; -// } - -// @override -// Future setCameraFocusDistance(double focusDistance) async { -// await _shim.setCameraFocusDistance(focusDistance).toDart; -// } - -// @override -// Future getCameraPosition() async { -// final jsPosition = (await _shim.getCameraPosition().toDart).toDart; -// return Vector3(jsPosition[0].toDartDouble, jsPosition[1].toDartDouble, -// jsPosition[2].toDartDouble); -// } - -// @override -// Future getCameraModelMatrix() async { -// throw UnimplementedError(); -// // final JSMatrix4 jsMatrix = await _shim.getCameraModelMatrix().toDart; -// // return Matrix4.fromList(jsMatrix.storage).toDart; -// } - -// @override -// Future getCameraViewMatrix() async { -// throw UnimplementedError(); -// // final JSMatrix4 jsMatrix = await _shim.getCameraViewMatrix().toDart; -// // return Matrix4.fromList(jsMatrix.storage).toDart; -// } - -// @override -// Future getCameraProjectionMatrix() async { -// throw UnimplementedError(); -// // final JSMatrix4 jsMatrix = -// // await _shim.getCameraProjectionMatrix().toDart; -// // return Matrix4.fromList(jsMatrix.storage).toDart; -// } - -// @override -// Future getCameraCullingProjectionMatrix() async { -// throw UnimplementedError(); -// // final JSMatrix4 jsMatrix = -// // await _shim.getCameraCullingProjectionMatrix().toDart; -// // return Matrix4.fromList(jsMatrix.storage).toDart; -// } - -// @override -// Future getCameraFrustum() async { -// throw UnimplementedError(); -// // final JSObject jsFrustum = await _shim.getCameraFrustum().toDart; -// // // Assuming Frustum is a class that can be constructed from the JSObject -// // return Frustum._fromJSObject(jsFrustum).toDart; -// } - -// @override -// Future setCameraPosition(double x, double y, double z) async { -// await _shim.setCameraPosition(x, y, z).toDart; -// } - -// @override -// Future getCameraRotation() async { -// throw UnimplementedError(); -// // final JSMatrix3 jsRotation = await _shim.getCameraRotation().toDart; -// // return Matrix3.fromList(jsRotation.storage).toDart; -// } - -// @override -// Future moveCameraToAsset(ThermionEntity entity) async { -// await _shim.moveCameraToAsset(entity).toDart; -// } - -// @override -// Future setViewFrustumCulling(bool enabled) async { -// throw UnimplementedError(); -// // await _shim.setViewFrustumCulling(enabled.toJSBoolean()).toDart; -// } - -// @override -// Future setCameraExposure( -// double aperture, double shutterSpeed, double sensitivity) async { -// await _shim.setCameraExposure(aperture, shutterSpeed, sensitivity).toDart; -// } - -// @override -// Future setCameraRotation(Quaternion quaternion) async { -// final values = [ -// quaternion.x.toJS, -// quaternion.y.toJS, -// quaternion.z.toJS, -// quaternion.w.toJS -// ]; -// await _shim.setCameraRotation(values.toJS).toDart; -// } - -// @override -// Future setCameraModelMatrix(List matrix) async { -// throw UnimplementedError(); - -// // await _shim.setCameraModelMatrix(matrix.toJSBox).toDart; -// } - -// @override -// Future setMaterialColor(ThermionEntity entity, String meshName, -// int materialIndex, double r, double g, double b, double a) async { -// await _shim -// .setMaterialColor(entity, meshName, materialIndex, r, g, b, a) -// .toDart; -// } - -// @override -// Future transformToUnitCube(ThermionEntity entity) async { -// await _shim.transformToUnitCube(entity).toDart; -// } - -// @override -// Future setPosition( -// ThermionEntity entity, double x, double y, double z) async { -// await _shim.setPosition(entity, x, y, z).toDart; -// } - -// @override -// Future setScale(ThermionEntity entity, double scale) async { -// await _shim.setScale(entity, scale).toDart; -// } - -// @override -// Future setRotation( -// ThermionEntity entity, double rads, double x, double y, double z) async { -// await _shim.setRotation(entity, rads, x, y, z).toDart; -// } - -// @override -// Future queuePositionUpdate( -// ThermionEntity entity, double x, double y, double z, -// {bool relative = false}) async { -// await _shim.queuePositionUpdate(entity, x, y, z, relative).toDart; -// } - -// @override -// Future queueRotationUpdate( -// ThermionEntity entity, double rads, double x, double y, double z, -// {bool relative = false}) async { -// await _shim.queueRotationUpdate(entity, rads, x, y, z, relative).toDart; -// } - -// @override -// Future queueRotationUpdateQuat(ThermionEntity entity, Quaternion quat, -// {bool relative = false}) async { -// throw UnimplementedError(); - -// // final JSQuaternion jsQuat = quat.toJSQuaternion().toDart; -// // await _shim -// // .queueRotationUpdateQuat(entity, jsQuat, relative: relative) -// // .toDart; -// } - -// @override -// Future setPostProcessing(bool enabled) async { -// await _shim.setPostProcessing(enabled).toDart; -// } - -// @override -// Future setAntiAliasing(bool msaa, bool fxaa, bool taa) async { -// await _shim.setAntiAliasing(msaa, fxaa, taa).toDart; -// } - -// @override -// Future setRotationQuat( -// ThermionEntity entity, Quaternion rotation) async { -// throw UnimplementedError(); -// // final JSQuaternion jsRotation = rotation.toJSQuaternion().toDart; -// // await _shim.setRotationQuat(entity, jsRotation).toDart; -// } - -// @override -// Future reveal(ThermionEntity entity, String? meshName) async { -// throw UnimplementedError(); -// // await _shim.reveal(entity, meshName).toDart; -// } - -// @override -// Future hide(ThermionEntity entity, String? meshName) async { -// throw UnimplementedError(); -// // await _shim.hide(entity, meshName).toDart; -// } - -// @override -// void pick(int x, int y) { -// throw UnimplementedError(); -// // _shim.pick(x, y).toDart; -// } - -// @override -// String? getNameForEntity(ThermionEntity entity) { -// return _shim.getNameForEntity(entity); -// } - -// @override -// Future setCameraManipulatorOptions( -// {ManipulatorMode mode = ManipulatorMode.ORBIT, -// double orbitSpeedX = 0.01, -// double orbitSpeedY = 0.01, -// double zoomSpeed = 0.01}) async { -// await _shim -// .setCameraManipulatorOptions( -// mode.index, orbitSpeedX, orbitSpeedY, zoomSpeed) -// .toDart; -// } - -// @override -// Future> getChildEntities( -// ThermionEntity parent, bool renderableOnly) async { -// final children = -// await _shim.getChildEntities(parent, renderableOnly).toDart; -// return children.toDart -// .map((js) => js.toDartInt) -// .cast() -// .toList(); -// } - -// @override -// Future getChildEntity( -// ThermionEntity parent, String childName) async { -// return (await _shim.getChildEntity(parent, childName).toDart).toDartInt; -// } - -// @override -// Future> getChildEntityNames(ThermionEntity entity, -// {bool renderableOnly = true}) async { -// var names = await _shim.getChildEntityNames(entity, renderableOnly).toDart; -// return names.toDart.map((x) => x.toDart).toList(); -// } - -// @override -// Future setRecording(bool recording) async { -// throw UnimplementedError(); -// // await _shim.setRecording(recording.toJSBoolean()).toDart; -// } - -// @override -// Future setRecordingOutputDirectory(String outputDirectory) async { -// await _shim.setRecordingOutputDirectory(outputDirectory).toDart; -// } - -// @override -// Future addAnimationComponent(ThermionEntity entity) async { -// await _shim.addAnimationComponent(entity).toDart; -// } - -// @override -// Future addCollisionComponent(ThermionEntity entity, -// {void Function(int entityId1, int entityId2)? callback, -// bool affectsTransform = false}) async { -// throw UnimplementedError(); -// // final JSFunction? jsCallback = callback != null -// // ? allowInterop( -// // (int entityId1, int entityId2) => callback(entityId1, entityId2)) -// // : null; -// // await _shim -// // .addCollisionComponent(entity, -// // callback: jsCallback, -// // affectsTransform: affectsTransform.toJSBoolean()) -// // .toDart; -// } - -// @override -// Future removeCollisionComponent(ThermionEntity entity) async { -// await _shim.removeCollisionComponent(entity).toDart; -// } - -// @override -// Future createGeometry( -// Geometry geometry, -// { -// bool keepData=false, MaterialInstance? materialInstance, -// PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) async { -// throw UnimplementedError(); -// // final ThermionEntity jsEntity = await _shim -// // .createGeometry(vertices, indices, -// // materialPath: materialPath, primitiveType: primitiveType.index) -// // .toDart; -// // return ThermionEntity._fromJSObject(jsEntity).toDart; -// } - -// @override -// Future setParent(ThermionEntity child, ThermionEntity parent, -// {bool preserveScaling = false}) async { -// await _shim.setParent(child, parent, preserveScaling).toDart; -// } - -// @override -// Future testCollisions(ThermionEntity entity) async { -// await _shim.testCollisions(entity).toDart; -// } - -// @override -// Future setPriority(ThermionEntity entityId, int priority) async { -// await _shim.setPriority(entityId, priority).toDart; -// } - -// AbstractGizmo? get gizmo => null; - -// @override -// Future> getBoneNames(ThermionEntity entity, -// {int skinIndex = 0}) async { -// var result = await _shim.getBoneNames(entity, skinIndex).toDart; -// return result.toDart.map((n) => n.toDart).toList(); -// } - -// @override -// Future getBone(ThermionEntity entity, int boneIndex, -// {int skinIndex = 0}) async { -// var result = await _shim.getBone(entity, boneIndex, skinIndex).toDart; -// return result.toDartInt; -// } - -// @override -// Future getInverseBindMatrix(ThermionEntity parent, int boneIndex, -// {int skinIndex = 0}) { -// // TODO: implement getInverseBindMatrix -// throw UnimplementedError(); -// } - -// @override -// Future getLocalTransform(ThermionEntity entity) async { -// var result = await _shim.getLocalTransform(entity).toDart; -// return Matrix4.fromList(result.toDart.map((v) => v.toDartDouble).toList()); -// } - -// @override -// Future getParent(ThermionEntity child) async { -// var result = await _shim.getParent(child).toDart; -// return result.toDartInt; -// } - -// @override -// Future getWorldTransform(ThermionEntity entity) async { -// var result = await _shim.getLocalTransform(entity).toDart; -// return Matrix4.fromList(result.toDart.map((v) => v.toDartDouble).toList()); -// } - -// @override -// Future removeAnimationComponent(ThermionEntity entity) { -// return _shim.removeAnimationComponent(entity).toDart; -// } - -// @override -// Future setBoneTransform( -// ThermionEntity entity, int boneIndex, Matrix4 transform, -// {int skinIndex = 0}) { -// return _shim -// .setBoneTransform(entity, boneIndex, -// transform.storage.map((v) => v.toJS).toList().toJS, skinIndex) -// .toDart; -// } - -// @override -// Future setTransform(ThermionEntity entity, Matrix4 transform) { -// return _shim -// .setTransform( -// entity, transform.storage.map((v) => v.toJS).toList().toJS) -// .toDart; -// } - -// @override -// Future updateBoneMatrices(ThermionEntity entity) { -// return _shim.updateBoneMatrices(entity).toDart; -// } - -// final _onDispose = []; - -// /// -// /// -// /// -// void onDispose(Future Function() callback) { -// _onDispose.add(callback); -// } - -// @override -// Future setShadowType(ShadowType shadowType) { -// return _shim.setShadowType(shadowType.index).toDart; -// } - -// @override -// Future setShadowsEnabled(bool enabled) { -// return _shim.setShadowsEnabled(enabled).toDart; -// } - -// @override -// Future setSoftShadowOptions(double penumbraScale, double penumbraRatioScale) { -// return _shim.setSoftShadowOptions(penumbraScale, penumbraRatioScale).toDart; -// } - -// @override -// Future capture() async { -// final captured = await _shim.capture().toDart; -// return captured.toDart; -// } - -// @override -// late (double, double) viewportDimensions; - -// @override -// Future getBoundingBox(ThermionEntity entity) { -// // return _shim.getBoundingBox(entity); -// throw UnimplementedError(); -// } - -// @override -// Future getCameraFov(bool horizontal) { -// // TODO: implement getCameraFov -// throw UnimplementedError(); -// } - -// @override -// Future queueRelativePositionUpdateWorldAxis(ThermionEntity entity, -// double viewportX, double viewportY, double x, double y, double z) { -// // TODO: implement queueRelativePositionUpdateWorldAxis -// throw UnimplementedError(); -// } - -// @override -// double pixelRatio = 0.0; - -// @override -// Future createIbl(double r, double g, double b, double intensity) { -// // TODO: implement createIbl -// throw UnimplementedError(); -// } - -// @override -// // TODO: implement gizmoPickResult -// Stream get gizmoPickResult => throw UnimplementedError(); - -// @override -// void pickGizmo(int x, int y) { -// // TODO: implement pickGizmo -// } - -// @override -// Future setGizmoVisibility(bool visible) { -// // TODO: implement setGizmoVisibility -// throw UnimplementedError(); -// } - -// @override -// Future setLayerEnabled(int layer, bool enabled) { -// // TODO: implement setLayerEnabled -// throw UnimplementedError(); -// } - -// @override -// // TODO: implement entitiesAdded -// Stream get entitiesAdded => throw UnimplementedError(); - -// @override -// // TODO: implement entitiesRemoved -// Stream get entitiesRemoved => throw UnimplementedError(); - -// @override -// Future getAncestor(ThermionEntity entity) { -// // TODO: implement getAncestor -// throw UnimplementedError(); -// } - -// @override -// Future getCameraNear() { -// // TODO: implement getCameraNear -// throw UnimplementedError(); -// } - -// @override -// Future getViewportBoundingBox(ThermionEntity entity) { -// // TODO: implement getViewportBoundingBox -// throw UnimplementedError(); -// } - -// @override -// // TODO: implement lightsAdded -// Stream get lightsAdded => throw UnimplementedError(); - -// @override -// // TODO: implement lightsRemoved -// Stream get lightsRemoved => throw UnimplementedError(); - -// @override -// Future loadGlbFromBuffer(Uint8List data, {int numInstances = 1, bool keepData = false, int layer=4, int priority =4 }) { -// // TODO: implement loadGlbFromBuffer -// throw UnimplementedError(); -// } - -// @override -// Future queuePositionUpdateFromViewportCoords(ThermionEntity entity, double x, double y) { -// // TODO: implement queuePositionUpdateFromViewportCoords -// throw UnimplementedError(); -// } - -// @override -// Future removeStencilHighlight(ThermionEntity entity) { -// // TODO: implement removeStencilHighlight -// throw UnimplementedError(); -// } - - -// @override -// Future setCameraModelMatrix4(Matrix4 matrix) { -// // TODO: implement setCameraModelMatrix4 -// throw UnimplementedError(); -// } - -// @override -// Future setLightDirection(ThermionEntity lightEntity, Vector3 direction) { -// // TODO: implement setLightDirection -// throw UnimplementedError(); -// } - -// @override -// Future setLightPosition(ThermionEntity lightEntity, double x, double y, double z) { -// // TODO: implement setLightPosition -// throw UnimplementedError(); -// } - -// @override -// Future setMaterialPropertyFloat(ThermionEntity entity, String propertyName, int materialIndex, double value) { -// // TODO: implement setMaterialPropertyFloat -// throw UnimplementedError(); -// } - -// @override -// Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName, int materialIndex, double f1, double f2, double f3, double f4) { -// // TODO: implement setMaterialPropertyFloat4 -// throw UnimplementedError(); -// } - -// @override -// Future setStencilHighlight(ThermionEntity entity, {double r = 1.0, double g = 0.0, double b = 0.0}) { -// // TODO: implement setStencilHighlight -// throw UnimplementedError(); -// } - -// @override -// Future addDirectLight(DirectLight light) { -// // TODO: implement addDirectLight -// throw UnimplementedError(); -// } - -// @override -// Future applyTexture(covariant ThermionTexture texture, ThermionEntity entity, {int materialIndex = 0, String parameterName = "baseColorMap"}) { -// // TODO: implement applyTexture -// throw UnimplementedError(); -// } - -// @override -// Future createTexture(Uint8List data) { -// // TODO: implement createTexture -// throw UnimplementedError(); -// } - -// @override -// Future createUbershaderMaterialInstance({bool doubleSided = false, bool unlit = false, bool hasVertexColors = false, bool hasBaseColorTexture = false, bool hasNormalTexture = false, bool hasOcclusionTexture = false, bool hasEmissiveTexture = false, bool useSpecularGlossiness = false, AlphaMode alphaMode = AlphaMode.OPAQUE, bool enableDiagnostics = false, bool hasMetallicRoughnessTexture = false, int metallicRoughnessUV = 0, int baseColorUV = 0, bool hasClearCoatTexture = false, int clearCoatUV = 0, bool hasClearCoatRoughnessTexture = false, int clearCoatRoughnessUV = 0, bool hasClearCoatNormalTexture = false, int clearCoatNormalUV = 0, bool hasClearCoat = false, bool hasTransmission = false, bool hasTextureTransforms = false, int emissiveUV = 0, int aoUV = 0, int normalUV = 0, bool hasTransmissionTexture = false, int transmissionUV = 0, bool hasSheenColorTexture = false, int sheenColorUV = 0, bool hasSheenRoughnessTexture = false, int sheenRoughnessUV = 0, bool hasVolumeThicknessTexture = false, int volumeThicknessUV = 0, bool hasSheen = false, bool hasIOR = false, bool hasVolume = false}) { -// // TODO: implement createUbershaderMaterialInstance -// throw UnimplementedError(); -// } - -// @override -// Future createUnlitMaterialInstance() { -// // TODO: implement createUnlitMaterialInstance -// throw UnimplementedError(); -// } - -// @override -// Future destroyMaterialInstance(covariant MaterialInstance materialInstance) { -// // TODO: implement destroyMaterialInstance -// throw UnimplementedError(); -// } - -// @override -// Future destroyTexture(covariant ThermionTexture texture) { -// // TODO: implement destroyTexture -// throw UnimplementedError(); -// } - -// @override -// Future getMainCameraEntity() { -// // TODO: implement getMainCameraEntity -// throw UnimplementedError(); -// } - -// @override -// Future getMaterialInstanceAt(ThermionEntity entity, int index) { -// // TODO: implement getMaterialInstanceAt -// throw UnimplementedError(); -// } - - -// @override -// // TODO: implement sceneUpdated -// Stream get sceneUpdated => throw UnimplementedError(); - -// @override -// Future setLayerVisibility(int layer, bool visible) { -// // TODO: implement setLayerVisibility -// throw UnimplementedError(); -// } - -// @override -// Future setMaterialPropertyInt(ThermionEntity entity, String propertyName, int materialIndex, int value) { -// // TODO: implement setMaterialPropertyInt -// throw UnimplementedError(); -// } - -// @override -// Future setVisibilityLayer(ThermionEntity entity, int layer) { -// // TODO: implement setVisibilityLayer -// throw UnimplementedError(); -// } - -// @override -// Future setCameraLensProjection({double near = kNear, double far = kFar, double? aspect, double focalLength = kFocalLength}) { -// // TODO: implement setCameraLensProjection -// throw UnimplementedError(); -// } - -// @override -// Future createCamera() { -// // TODO: implement createCamera -// throw UnimplementedError(); -// } - -// @override -// Future registerRequestFrameHook(Future Function() hook) { -// // TODO: implement registerRequestFrameHook -// throw UnimplementedError(); -// } - -// @override -// Future requestFrame() { -// // TODO: implement requestFrame -// throw UnimplementedError(); -// } - -// @override -// Future setActiveCamera(covariant Camera camera) { -// // TODO: implement setActiveCamera -// throw UnimplementedError(); -// } - -// @override -// Future unregisterRequestFrameHook(Future Function() hook) { -// // TODO: implement unregisterRequestFrameHook -// throw UnimplementedError(); -// } -// } diff --git a/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_js_shim.dart b/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_js_shim.dart deleted file mode 100644 index 2d725281..00000000 --- a/thermion_dart/lib/src/viewer/src/web_js/src/thermion_viewer_js_shim.dart +++ /dev/null @@ -1,424 +0,0 @@ -@JS() -library thermion_flutter_js; - -import 'dart:js_interop'; - -import '../../../../filament/src/interface/shared_types.dart'; - -/// -/// An extension type on [JSObject] that represents a -/// Javascript shim implementation of the [ThermionViewer] interface. -/// -extension type ThermionViewerJSShim(JSObject _) implements JSObject { - @JS('initialized') - external JSPromise get initialized; - - @JS('rendering') - external bool get rendering; - - @JS('setRendering') - external JSPromise setRendering(bool render); - - @JS('render') - external JSPromise render(); - - @JS('capture') - external JSPromise capture(); - - @JS('setFrameRate') - external JSPromise setFrameRate(int framerate); - - @JS('dispose') - external JSPromise dispose(); - - @JS('setBackgroundImage') - external JSPromise setBackgroundImage(String path, bool fillHeight); - - @JS('setBackgroundImagePosition') - external JSPromise setBackgroundImagePosition(double x, double y, bool clamp); - - @JS('clearBackgroundImage') - external JSPromise clearBackgroundImage(); - - @JS('setBackgroundColor') - external JSPromise setBackgroundColor( - double r, double g, double b, double alpha); - - @JS('loadSkybox') - external JSPromise loadSkybox(String skyboxPath); - - @JS('removeSkybox') - external JSPromise removeSkybox(); - - @JS('loadIbl') - external JSPromise loadIbl(String lightingPath, double intensity); - - @JS('rotateIbl') - external JSPromise rotateIbl(JSArray rotationMatrix); - - @JS('removeIbl') - external JSPromise removeIbl(); - - @JS('addLight') - external JSPromise addLight( - int type, - double colour, - double intensity, - double posX, - double posY, - double posZ, - double dirX, - double dirY, - double dirZ, - double falloffRadius, - double spotLightConeInner, - double spotLightConeOuter, - double sunAngularRadius, - double sunHaloSize, - double sunHaloFallof, - bool castShadows); - - @JS('removeLight') - external JSPromise removeLight(ThermionEntity light); - - @JS('destroyLights') - external JSPromise destroyLights(); - - @JS('loadGlb') - external JSPromise loadGlb(String path, int numInstances); - - @JS('createInstance') - external JSPromise createInstance(ThermionEntity entity); - - @JS('getInstanceCount') - external JSPromise getInstanceCount(ThermionEntity entity); - - @JS('getInstances') - external JSPromise> getInstances(ThermionEntity entity); - - @JS('loadGltf') - external JSPromise loadGltf( - String path, String relativeResourcePath); - - @JS('panStart') - external JSPromise panStart(double x, double y); - - @JS('panUpdate') - external JSPromise panUpdate(double x, double y); - - @JS('panEnd') - external JSPromise panEnd(); - - @JS('rotateStart') - external JSPromise rotateStart(double x, double y); - - @JS('rotateUpdate') - external JSPromise rotateUpdate(double x, double y); - - @JS('rotateEnd') - external JSPromise rotateEnd(); - - @JS('setMorphTargetWeights') - external JSPromise setMorphTargetWeights( - ThermionEntity entity, JSArray weights); - - @JS('getMorphTargetNames') - external JSPromise> getMorphTargetNames( - ThermionEntity entity, ThermionEntity childEntity); - - @JS('getBoneNames') - external JSPromise> getBoneNames( - ThermionEntity entity, int skinIndex); - - @JS('getAnimationNames') - external JSPromise> getAnimationNames( - ThermionEntity entity); - - @JS('getAnimationDuration') - external JSPromise getAnimationDuration( - ThermionEntity entity, int animationIndex); - - @JS('clearMorphAnimationData') - external void clearMorphAnimationData(ThermionEntity entity); - - @JS('setMorphAnimationData') - external JSPromise setMorphAnimationData( - ThermionEntity entity, - JSArray> animation, - JSArray morphTargets, - JSArray? targetMeshNames, - double frameLengthInMs); - - @JS('resetBones') - external JSPromise resetBones(ThermionEntity entity); - - @JS('addBoneAnimation') - external JSPromise addBoneAnimation( - ThermionEntity entity, - JSArray bones, - JSArray>> frameData, - JSNumber frameLengthInMs, - JSNumber spaceEnum, - JSNumber skinIndex, - JSNumber fadeInInSecs, - JSNumber fadeOutInSecs, - JSNumber maxDelta); - - @JS('destroyAsset') - external JSPromise destroyAsset(ThermionEntity entity); - - @JS('destroyAssets') - external JSPromise destroyAssets(); - - @JS('zoomBegin') - external JSPromise zoomBegin(); - - @JS('zoomUpdate') - external JSPromise zoomUpdate(double x, double y, double z); - - @JS('zoomEnd') - external JSPromise zoomEnd(); - - @JS('playAnimation') - external JSPromise playAnimation( - ThermionEntity entity, - int index, - bool loop, - bool reverse, - bool replaceActive, - double crossfade, - double startOffset, - ); - - @JS('playAnimationByName') - external JSPromise playAnimationByName( - ThermionEntity entity, - String name, - bool loop, - bool reverse, - bool replaceActive, - double crossfade, - ); - - @JS('setAnimationFrame') - external JSPromise setAnimationFrame( - ThermionEntity entity, int index, int animationFrame); - - @JS('stopAnimation') - external JSPromise stopAnimation(ThermionEntity entity, int animationIndex); - - @JS('stopAnimationByName') - external JSPromise stopAnimationByName(ThermionEntity entity, String name); - - @JS('setCamera') - external JSPromise setCamera(ThermionEntity entity, String? name); - - @JS('setMainCamera') - external JSPromise setMainCamera(); - - @JS('getMainCamera') - external JSPromise getMainCamera(); - - @JS('setCameraFov') - external JSPromise setCameraFov(double degrees, bool horizontal); - - @JS('setToneMapping') - external JSPromise setToneMapping(int mapper); - - @JS('setBloom') - external JSPromise setBloom(double bloom); - - @JS('setCameraFocalLength') - external JSPromise setCameraFocalLength(double focalLength); - - @JS('setCameraCulling') - external JSPromise setCameraCulling(double near, double far); - - @JS('getCameraCullingNear') - external JSPromise getCameraCullingNear(); - - @JS('getCameraCullingFar') - external JSPromise getCameraCullingFar(); - - @JS('setCameraFocusDistance') - external JSPromise setCameraFocusDistance(double focusDistance); - - @JS('getCameraPosition') - external JSPromise> getCameraPosition(); - - @JS('getCameraModelMatrix') - external JSPromise> getCameraModelMatrix(); - - @JS('getCameraViewMatrix') - external JSPromise> getCameraViewMatrix(); - - @JS('getCameraProjectionMatrix') - external JSPromise> getCameraProjectionMatrix(); - - @JS('getCameraCullingProjectionMatrix') - external JSPromise> getCameraCullingProjectionMatrix(); - - @JS('getCameraFrustum') - external JSPromise getCameraFrustum(); - - @JS('setCameraPosition') - external JSPromise setCameraPosition(double x, double y, double z); - - @JS('getCameraRotation') - external JSPromise> getCameraRotation(); - - @JS('moveCameraToAsset') - external JSPromise moveCameraToAsset(ThermionEntity entity); - - @JS('setViewFrustumCulling') - external JSPromise setViewFrustumCulling(JSBoolean enabled); - - @JS('setCameraExposure') - external JSPromise setCameraExposure( - double aperture, double shutterSpeed, double sensitivity); - - @JS('setCameraRotation') - external JSPromise setCameraRotation(JSArray quaternion); - - @JS('setCameraModelMatrix') - external JSPromise setCameraModelMatrix(JSArray matrix); - - @JS('setMaterialColor') - external JSPromise setMaterialColor(ThermionEntity entity, String meshName, - int materialIndex, double r, double g, double b, double a); - - @JS('transformToUnitCube') - external JSPromise transformToUnitCube(ThermionEntity entity); - - @JS('setPosition') - external JSPromise setPosition( - ThermionEntity entity, double x, double y, double z); - - @JS('setScale') - external JSPromise setScale(ThermionEntity entity, double scale); - - @JS('setRotation') - external JSPromise setRotation( - ThermionEntity entity, double rads, double x, double y, double z); - - @JS('queuePositionUpdate') - external JSPromise queuePositionUpdate( - ThermionEntity entity, double x, double y, double z, bool relative); - - @JS('queueRotationUpdate') - external JSPromise queueRotationUpdate(ThermionEntity entity, double rads, - double x, double y, double z, bool relative); - - @JS('queueRotationUpdateQuat') - external JSPromise queueRotationUpdateQuat( - ThermionEntity entity, JSArray quat, bool relative); - - @JS('setPostProcessing') - external JSPromise setPostProcessing(bool enabled); - - @JS('setAntiAliasing') - external JSPromise setAntiAliasing(bool msaa, bool fxaa, bool taa); - - @JS('setRotationQuat') - external JSPromise setRotationQuat( - ThermionEntity entity, JSArray rotation); - - @JS('reveal') - external JSPromise reveal(ThermionEntity entity, String? meshName); - - @JS('hide') - external JSPromise hide(ThermionEntity entity, String? meshName); - - @JS('pick') - external void pick(int x, int y); - - @JS('getNameForEntity') - external String? getNameForEntity(ThermionEntity entity); - - @JS('setCameraManipulatorOptions') - external JSPromise setCameraManipulatorOptions( - int mode, - double orbitSpeedX, - double orbitSpeedY, - double zoomSpeed, - ); - - @JS('getChildEntities') - external JSPromise> getChildEntities( - ThermionEntity parent, bool renderableOnly); - - @JS('getChildEntity') - external JSPromise getChildEntity( - ThermionEntity parent, String childName); - - @JS('getChildEntityNames') - external JSPromise> getChildEntityNames( - ThermionEntity entity, bool renderableOnly); - - @JS('setRecording') - external JSPromise setRecording(JSBoolean recording); - - @JS('setRecordingOutputDirectory') - external JSPromise setRecordingOutputDirectory(String outputDirectory); - - @JS('addAnimationComponent') - external JSPromise addAnimationComponent(ThermionEntity entity); - - @JS('removeAnimationComponent') - external JSPromise removeAnimationComponent(ThermionEntity entity); - - @JS('addCollisionComponent') - external JSPromise addCollisionComponent(ThermionEntity entity); - - @JS('removeCollisionComponent') - external JSPromise removeCollisionComponent(ThermionEntity entity); - - @JS('createGeometry') - external JSPromise createGeometry(JSArray vertices, - JSArray indices, String? materialPath, int primitiveType); - - @JS('setParent') - external JSPromise setParent(ThermionEntity child, ThermionEntity parent, bool preserveScaling); - - @JS('getParent') - external JSPromise getParent(ThermionEntity child); - - @JS('getParent') - external JSPromise getBone( - ThermionEntity child, int boneIndex, int skinIndex); - - @JS('testCollisions') - external JSPromise testCollisions(ThermionEntity entity); - - @JS('setPriority') - external JSPromise setPriority(ThermionEntity entityId, int priority); - - @JS('getLocalTransform') - external JSPromise> getLocalTransform( - ThermionEntity entity); - - @JS('getWorldTransform') - external JSPromise> getWorldTransform( - ThermionEntity entity); - - @JS('updateBoneMatrices') - external JSPromise updateBoneMatrices(ThermionEntity entity); - - @JS('setTransform') - external JSPromise setTransform( - ThermionEntity entity, JSArray transform); - - @JS('setBoneTransform') - external JSPromise setBoneTransform(ThermionEntity entity, int boneIndex, - JSArray transform, int skinIndex); - - @JS('setShadowsEnabled') - external JSPromise setShadowsEnabled(bool enabled); - - @JS('setShadowType') - external JSPromise setShadowType(int shadowType); - - @JS('setSoftShadowOptions') - external JSPromise setSoftShadowOptions( - double penumbraScale, double penumbraRatioScale); -} diff --git a/thermion_dart/lib/src/viewer/src/web_js/thermion_viewer_js.dart b/thermion_dart/lib/src/viewer/src/web_js/thermion_viewer_js.dart deleted file mode 100644 index 10085033..00000000 --- a/thermion_dart/lib/src/viewer/src/web_js/thermion_viewer_js.dart +++ /dev/null @@ -1,5 +0,0 @@ -library; - -export 'src/thermion_viewer_dart_bridge.dart'; -export 'src/thermion_viewer_js_shim.dart'; -export 'src/thermion_viewer_js.dart';