refactor: export ThermionViewerWasm for web and hide FFI/WASM version
This commit is contained in:
@@ -3,5 +3,4 @@ library thermion_flutter;
|
||||
export 'thermion/thermion_flutter_plugin.dart';
|
||||
export 'thermion/widgets/thermion_widget.dart';
|
||||
export 'thermion/widgets/camera/gestures/thermion_gesture_detector.dart';
|
||||
|
||||
export 'package:thermion_dart/thermion_dart.dart';
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/interop/thermion_viewer_wasm.dart';
|
||||
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
|
||||
import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart';
|
||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/interop/thermion_dart_js_extension_type.dart';
|
||||
import 'package:thermion_dart/thermion_dart/compatibility/web/interop/js_interop_filament_viewer.dart';
|
||||
import 'package:web/web.dart';
|
||||
|
||||
class ThermionFlutterWebPlugin extends ThermionFlutterPlatform {
|
||||
static void registerWith(Registrar registrar) {
|
||||
@@ -12,30 +12,31 @@ class ThermionFlutterWebPlugin extends ThermionFlutterPlatform {
|
||||
|
||||
@override
|
||||
Future<ThermionFlutterTexture?> createTexture(
|
||||
int width, int height, int offsetLeft, int offsetRight) async {}
|
||||
|
||||
@override
|
||||
Future destroyTexture(ThermionFlutterTexture texture) async {}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// TODO: implement dispose
|
||||
int width, int height, int offsetLeft, int offsetRight) async {
|
||||
return ThermionFlutterTexture(null, null, 0, 0, null);
|
||||
}
|
||||
|
||||
@override
|
||||
Future initialize({String? uberArchivePath}) async {
|
||||
print("Creating viewer in web plugin");
|
||||
viewer = JsInteropThermionViewerFFI("filamentViewer");
|
||||
print("Waiting for initialized");
|
||||
await viewer.initialized;
|
||||
print("int complete");
|
||||
Future destroyTexture(ThermionFlutterTexture texture) async {
|
||||
// noop
|
||||
}
|
||||
|
||||
@override
|
||||
Future<ThermionFlutterTexture?> resizeTexture(ThermionFlutterTexture texture,
|
||||
int width, int height, int offsetLeft, int offsetRight) async {}
|
||||
int width, int height, int offsetLeft, int offsetRight) async {
|
||||
return ThermionFlutterTexture(null, null, 0, 0, null);
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO: implement viewer
|
||||
late final ThermionViewer viewer;
|
||||
Future<ThermionViewer> createViewer({String? uberArchivePath}) async {
|
||||
final canvas = document.getElementById("canvas") as HTMLCanvasElement;
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
|
||||
var width = window.innerWidth;
|
||||
var height = window.innerHeight;
|
||||
|
||||
var viewer = ThermionViewerWasm();
|
||||
await viewer.initialize(width, height, uberArchivePath: uberArchivePath);
|
||||
return viewer;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user