refactor: rearrange some stubs/imports for easier web WASM deployment
This commit is contained in:
@@ -1,3 +1 @@
|
||||
export 'web/compatibility.dart' if (dart.library.io) 'native/compatibility.dart';
|
||||
|
||||
|
||||
export 'native/compatibility.dart';
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'dart:convert';
|
||||
import 'dart:ffi' as ffi hide Uint8Pointer, FloatPointer;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/thermion_dart.g.dart';
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/ffi/thermion_dart.g.dart';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
export 'package:ffi/ffi.dart' hide StringUtf8Pointer, Utf8Pointer;
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:js_interop';
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/interop.dart';
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/ffi/interop.dart';
|
||||
|
||||
import "allocator.dart";
|
||||
|
||||
@@ -33,8 +33,11 @@ extension type _EmscriptenModule(JSObject _) implements JSObject {
|
||||
external JSAny get HEAP32;
|
||||
}
|
||||
|
||||
typedef ThermionViewerImpl = ThermionViewerWasm;
|
||||
|
||||
|
||||
///
|
||||
/// An [ThermionViewer] implementation that forwards calls to
|
||||
/// A [ThermionViewer] implementation that forwards calls to
|
||||
/// the (Emscripten-generated) ThermionDart JS module.
|
||||
///
|
||||
class ThermionViewerWasm implements ThermionViewer {
|
||||
@@ -43,8 +46,8 @@ class ThermionViewerWasm implements ThermionViewer {
|
||||
bool _initialized = false;
|
||||
bool _rendering = false;
|
||||
|
||||
ThermionViewerWasm({String moduleName = "thermion_dart"}) {
|
||||
_module = window.getProperty<_EmscriptenModule>(moduleName.toJS);
|
||||
ThermionViewerWasm({JSObject? module, String moduleName = "thermion_dart"}) {
|
||||
_module = module as _EmscriptenModule? ?? window.getProperty<_EmscriptenModule>(moduleName.toJS);
|
||||
}
|
||||
|
||||
JSNumber? _viewer;
|
||||
@@ -1687,7 +1690,7 @@ class ThermionViewerWasm implements ThermionViewer {
|
||||
Future setMorphTargetWeights(
|
||||
ThermionEntity entity, List<double> weights) async {
|
||||
final numWeights = weights.length;
|
||||
final ptr = _module._malloc(numWeights * 4) as JSNumber;
|
||||
final ptr = _module._malloc(numWeights * 4);
|
||||
for (int i = 0; i < numWeights; i++) {
|
||||
_module.setValue(
|
||||
(ptr.toDartInt + (i * 4)).toJS, weights[i].toJS, "float");
|
||||
|
||||
Reference in New Issue
Block a user