chore!: restructure viewer folders as libraries to only export the public interface
This commit is contained in:
@@ -2,7 +2,7 @@ import 'dart:ffi';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:ffi/ffi.dart';
|
import 'package:ffi/ffi.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
|
|
||||||
class DartResourceLoader {
|
class DartResourceLoader {
|
||||||
static final _assets = <int, Pointer>{};
|
static final _assets = <int, Pointer>{};
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Helper function to convert double4x4 to Matrix4
|
// Helper function to convert double4x4 to Matrix4
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'dart:ffi';
|
import 'dart:ffi';
|
||||||
|
|
||||||
import 'package:thermion_dart/thermion_dart/utils/matrix.dart';
|
import 'package:thermion_dart/thermion_dart/utils/matrix.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ library thermion_flutter_js;
|
|||||||
|
|
||||||
import 'dart:js_interop';
|
import 'dart:js_interop';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/web/thermion_viewer_js_shim.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/web_js/src/thermion_viewer_js_shim.dart';
|
||||||
|
|
||||||
import 'package:vector_math/vector_math_64.dart' as v64;
|
import 'package:vector_math/vector_math_64.dart' as v64;
|
||||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
@@ -400,7 +400,8 @@ class ThermionViewerJSDartBridge {
|
|||||||
|
|
||||||
@JSExport()
|
@JSExport()
|
||||||
JSPromise<JSNumber> getMainCamera() {
|
JSPromise<JSNumber> getMainCamera() {
|
||||||
return viewer.getMainCamera().then((camera) => camera.toJS).toJS;
|
throw UnimplementedError("TODO");
|
||||||
|
// return viewer.getMainCamera().then((camera) => camera.toJS).toJS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JSExport()
|
@JSExport()
|
||||||
@@ -8,6 +8,8 @@ import 'package:logging/logging.dart';
|
|||||||
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
|
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/scene.dart';
|
import 'package:thermion_dart/thermion_dart/scene.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||||
|
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
|
||||||
|
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
|
||||||
|
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
import 'thermion_viewer_js_shim.dart';
|
import 'thermion_viewer_js_shim.dart';
|
||||||
@@ -166,9 +168,8 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> loadGlb(String path, {int numInstances = 1}) async {
|
Future<ThermionEntity> loadGlb(String path, {int numInstances = 1, bool keepData=false}) async {
|
||||||
var entity = (await _shim.loadGlb(path, numInstances).toDart).toDartInt;
|
var entity = (await _shim.loadGlb(path, numInstances).toDart).toDartInt;
|
||||||
scene.registerEntity(entity);
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath,
|
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath,
|
||||||
{bool force = false}) async {
|
{bool keepData = false}) async {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
// final ThermionEntity jsEntity = await _shim
|
// final ThermionEntity jsEntity = await _shim
|
||||||
// .loadGltf(path, relativeResourcePath, force: force)
|
// .loadGltf(path, relativeResourcePath, force: force)
|
||||||
@@ -416,7 +417,7 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> getMainCamera() async {
|
Future<Camera> getMainCamera() async {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
// final ThermionEntity jsEntity = await _shim.getMainCamera().toDart;
|
// final ThermionEntity jsEntity = await _shim.getMainCamera().toDart;
|
||||||
// return ThermionEntity._fromJSObject(jsEntity).toDart;
|
// return ThermionEntity._fromJSObject(jsEntity).toDart;
|
||||||
@@ -725,8 +726,9 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> createGeometry(
|
Future<ThermionEntity> createGeometry(
|
||||||
List<double> vertices, List<int> indices,
|
Geometry geometry,
|
||||||
{String? materialPath,
|
{
|
||||||
|
bool keepData=false, MaterialInstance? materialInstance,
|
||||||
PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) async {
|
PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) async {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
// final ThermionEntity jsEntity = await _shim
|
// final ThermionEntity jsEntity = await _shim
|
||||||
@@ -752,14 +754,6 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
await _shim.setPriority(entityId, priority).toDart;
|
await _shim.setPriority(entityId, priority).toDart;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene? _scene;
|
|
||||||
|
|
||||||
// @override
|
|
||||||
Scene get scene {
|
|
||||||
_scene ??= SceneImpl(this);
|
|
||||||
return _scene!;
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractGizmo? get gizmo => null;
|
AbstractGizmo? get gizmo => null;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -882,7 +876,7 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
double pixelRatio;
|
double pixelRatio = 0.0;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future createIbl(double r, double g, double b, double intensity) {
|
Future createIbl(double r, double g, double b, double intensity) {
|
||||||
@@ -946,7 +940,7 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
Stream<ThermionEntity> get lightsRemoved => throw UnimplementedError();
|
Stream<ThermionEntity> get lightsRemoved => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data, {int numInstances = 1, bool keepData = false}) {
|
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data, {int numInstances = 1, bool keepData = false, int layer=4, int priority =4 }) {
|
||||||
// TODO: implement loadGlbFromBuffer
|
// TODO: implement loadGlbFromBuffer
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
@@ -963,11 +957,6 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future setCameraLensProjection(double near, double far, double aspect, double focalLength) {
|
|
||||||
// TODO: implement setCameraLensProjection
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setCameraModelMatrix4(Matrix4 matrix) {
|
Future setCameraModelMatrix4(Matrix4 matrix) {
|
||||||
@@ -1004,4 +993,91 @@ class ThermionViewerJS implements ThermionViewer {
|
|||||||
// TODO: implement setStencilHighlight
|
// TODO: implement setStencilHighlight
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ThermionEntity> 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<ThermionTexture> createTexture(Uint8List data) {
|
||||||
|
// TODO: implement createTexture
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MaterialInstance> 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<MaterialInstance> 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<ThermionEntity> getMainCameraEntity() {
|
||||||
|
// TODO: implement getMainCameraEntity
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MaterialInstance?> getMaterialInstanceAt(ThermionEntity entity, int index) {
|
||||||
|
// TODO: implement getMaterialInstanceAt
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void requestFrame() {
|
||||||
|
// TODO: implement requestFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement sceneUpdated
|
||||||
|
Stream<SceneUpdateEvent> 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
library;
|
||||||
|
|
||||||
|
export 'src/thermion_viewer_dart_bridge.dart';
|
||||||
|
export 'src/thermion_viewer_js_shim.dart';
|
||||||
|
export 'src/thermion_viewer_js.dart';
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
|
||||||
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
|
class ThermionWasmCamera extends Camera {
|
||||||
|
|
||||||
|
final int pointer;
|
||||||
|
|
||||||
|
ThermionWasmCamera(this.pointer);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future setProjectionMatrixWithCulling(
|
||||||
|
Matrix4 projectionMatrix, double near, double far) {
|
||||||
|
// TODO: implement setProjectionMatrixWithCulling
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:thermion_dart/thermion_dart/viewer/shared_types/material.dart';
|
||||||
|
|
||||||
|
class ThermionWasmMaterialInstance extends MaterialInstance {
|
||||||
|
final int pointer;
|
||||||
|
|
||||||
|
ThermionWasmMaterialInstance(this.pointer);
|
||||||
|
@override
|
||||||
|
Future setDepthCullingEnabled(bool enabled) {
|
||||||
|
// TODO: implement setDepthCullingEnabled
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future setDepthWriteEnabled(bool enabled) {
|
||||||
|
// TODO: implement setDepthWriteEnabled
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,15 +7,16 @@ import 'dart:typed_data';
|
|||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
|
import 'package:thermion_dart/thermion_dart/entities/abstract_gizmo.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/entities/gizmo.dart';
|
import 'package:thermion_dart/thermion_dart/entities/gizmo.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/scene.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
|
||||||
|
import 'package:thermion_dart/thermion_dart/viewer/shared_types/camera.dart';
|
||||||
import 'package:web/web.dart';
|
import 'package:web/web.dart';
|
||||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'camera.dart';
|
||||||
export 'thermion_viewer_dart_bridge.dart';
|
import 'material_instance.dart';
|
||||||
|
|
||||||
extension type _EmscriptenModule(JSObject _) implements JSObject {
|
extension type _EmscriptenModule(JSObject _) implements JSObject {
|
||||||
external JSAny? ccall(String name, String returnType,
|
external JSAny? ccall(String name, String returnType,
|
||||||
@@ -588,14 +589,9 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> getMainCamera() async {
|
Future<Camera> getMainCamera() async {
|
||||||
final entityId = _module!.ccall(
|
var mainCameraEntity = await getMainCameraEntity();
|
||||||
"get_main_camera", "int", ["void*".toJS].toJS, [_viewer].toJS, null)
|
return ThermionWasmCamera(mainCameraEntity);
|
||||||
as JSNumber;
|
|
||||||
if (entityId.toDartInt == -1) {
|
|
||||||
throw Exception("Failed to get main camera");
|
|
||||||
}
|
|
||||||
return entityId.toDartInt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -695,7 +691,7 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data,
|
Future<ThermionEntity> loadGlbFromBuffer(Uint8List data,
|
||||||
{int numInstances = 1}) async {
|
{int numInstances = 1, bool keepData= false, int layer=0, int priority=4}) async {
|
||||||
if (numInstances != 1) {
|
if (numInstances != 1) {
|
||||||
throw Exception("TODO");
|
throw Exception("TODO");
|
||||||
}
|
}
|
||||||
@@ -717,7 +713,8 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> loadGlb(String path, {int numInstances = 1, bool keepData = false}) async {
|
Future<ThermionEntity> loadGlb(String path,
|
||||||
|
{int numInstances = 1, bool keepData = false}) async {
|
||||||
final promise = _module!.ccall(
|
final promise = _module!.ccall(
|
||||||
"load_glb",
|
"load_glb",
|
||||||
"int",
|
"int",
|
||||||
@@ -732,7 +729,8 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath, { bool keepData = false}) async {
|
Future<ThermionEntity> loadGltf(String path, String relativeResourcePath,
|
||||||
|
{bool keepData = false}) async {
|
||||||
final promise = _module!.ccall(
|
final promise = _module!.ccall(
|
||||||
"load_gltf",
|
"load_gltf",
|
||||||
"int",
|
"int",
|
||||||
@@ -871,9 +869,6 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Scene get scene => throw UnimplementedError();
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setAntiAliasing(bool msaa, bool fxaa, bool taa) async {
|
Future setAntiAliasing(bool msaa, bool fxaa, bool taa) async {
|
||||||
_module!.ccall(
|
_module!.ccall(
|
||||||
@@ -1146,11 +1141,12 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future createGeometry(List<double> vertices, List<int> indices,
|
Future createGeometry(Geometry geometry,
|
||||||
{String? materialPath,
|
{MaterialInstance? materialInstance,
|
||||||
|
bool keepData = false,
|
||||||
PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) async {
|
PrimitiveType primitiveType = PrimitiveType.TRIANGLES}) async {
|
||||||
final verticesData = td.Float32List.fromList(vertices);
|
final verticesData = td.Float32List.fromList(geometry.vertices);
|
||||||
final indicesData = Uint16List.fromList(indices);
|
final indicesData = Uint16List.fromList(geometry.indices);
|
||||||
final verticesPtr = _module!._malloc(verticesData.lengthInBytes);
|
final verticesPtr = _module!._malloc(verticesData.lengthInBytes);
|
||||||
final indicesPtr = _module!._malloc(indicesData.lengthInBytes);
|
final indicesPtr = _module!._malloc(indicesData.lengthInBytes);
|
||||||
_module!.writeArrayToMemory(
|
_module!.writeArrayToMemory(
|
||||||
@@ -1173,11 +1169,11 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
[
|
[
|
||||||
_viewer!,
|
_viewer!,
|
||||||
verticesPtr,
|
verticesPtr,
|
||||||
vertices.length.toJS,
|
verticesData.length.toJS,
|
||||||
indicesPtr,
|
indicesPtr,
|
||||||
indices.length.toJS,
|
indicesData.length.toJS,
|
||||||
primitiveType.index.toJS,
|
primitiveType.index.toJS,
|
||||||
materialPath?.toJS ?? "".toJS,
|
(materialInstance as ThermionWasmMaterialInstance?)?.pointer.toJS ?? "".toJS,
|
||||||
].toJS,
|
].toJS,
|
||||||
null) as JSNumber;
|
null) as JSNumber;
|
||||||
|
|
||||||
@@ -2256,14 +2252,14 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setLightDirection(ThermionEntity lightEntity, Vector3 direction) async {
|
Future setLightDirection(
|
||||||
|
ThermionEntity lightEntity, Vector3 direction) async {
|
||||||
direction.normalize();
|
direction.normalize();
|
||||||
_module!.ccall(
|
_module!.ccall(
|
||||||
"set_light_direction",
|
"set_light_direction",
|
||||||
"void",
|
"void",
|
||||||
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
||||||
[_viewer!, direction.x.toJS, direction.y.toJS, direction.z.toJS]
|
[_viewer!, direction.x.toJS, direction.y.toJS, direction.z.toJS].toJS,
|
||||||
.toJS,
|
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2274,84 +2270,212 @@ class ThermionViewerWasm implements ThermionViewer {
|
|||||||
"set_light_position",
|
"set_light_position",
|
||||||
"void",
|
"void",
|
||||||
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
["void*".toJS, "double".toJS, "double".toJS, "double".toJS].toJS,
|
||||||
[_viewer!, x.toJS,y.toJS,z.toJS]
|
[_viewer!, x.toJS, y.toJS, z.toJS].toJS,
|
||||||
.toJS,
|
|
||||||
null);
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<ThermionEntity?> getAncestor(ThermionEntity entity) {
|
Future<ThermionEntity?> getAncestor(ThermionEntity entity) {
|
||||||
// TODO: implement getAncestor
|
// TODO: implement getAncestor
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future queuePositionUpdateFromViewportCoords(ThermionEntity entity, double x, double y) {
|
Future queuePositionUpdateFromViewportCoords(
|
||||||
|
ThermionEntity entity, double x, double y) {
|
||||||
// TODO: implement queuePositionUpdateFromViewportCoords
|
// TODO: implement queuePositionUpdateFromViewportCoords
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future removeStencilHighlight(ThermionEntity entity) {
|
Future removeStencilHighlight(ThermionEntity entity) {
|
||||||
// TODO: implement removeStencilHighlight
|
// TODO: implement removeStencilHighlight
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setStencilHighlight(ThermionEntity entity, {double r = 1.0, double g = 0.0, double b = 0.0}) {
|
Future setStencilHighlight(ThermionEntity entity,
|
||||||
|
{double r = 1.0, double g = 0.0, double b = 0.0}) {
|
||||||
// TODO: implement setStencilHighlight
|
// TODO: implement setStencilHighlight
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement entitiesAdded
|
// TODO: implement entitiesAdded
|
||||||
Stream<ThermionEntity> get entitiesAdded => throw UnimplementedError();
|
Stream<ThermionEntity> get entitiesAdded => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement entitiesRemoved
|
// TODO: implement entitiesRemoved
|
||||||
Stream<ThermionEntity> get entitiesRemoved => throw UnimplementedError();
|
Stream<ThermionEntity> get entitiesRemoved => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<double> getCameraNear() {
|
Future<double> getCameraNear() {
|
||||||
// TODO: implement getCameraNear
|
// TODO: implement getCameraNear
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<Aabb2> getViewportBoundingBox(ThermionEntity entity) {
|
Future<Aabb2> getViewportBoundingBox(ThermionEntity entity) {
|
||||||
// TODO: implement getViewportBoundingBox
|
// TODO: implement getViewportBoundingBox
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement lightsAdded
|
// TODO: implement lightsAdded
|
||||||
Stream<ThermionEntity> get lightsAdded => throw UnimplementedError();
|
Stream<ThermionEntity> get lightsAdded => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
// TODO: implement lightsRemoved
|
// TODO: implement lightsRemoved
|
||||||
Stream<ThermionEntity> get lightsRemoved => throw UnimplementedError();
|
Stream<ThermionEntity> get lightsRemoved => throw UnimplementedError();
|
||||||
|
|
||||||
@override
|
|
||||||
Future setCameraLensProjection(double near, double far, double aspect, double focalLength) {
|
|
||||||
// TODO: implement setCameraLensProjection
|
|
||||||
throw UnimplementedError();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setCameraModelMatrix4(Matrix4 matrix) {
|
Future setCameraModelMatrix4(Matrix4 matrix) {
|
||||||
// TODO: implement setCameraModelMatrix4
|
// TODO: implement setCameraModelMatrix4
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setMaterialPropertyFloat(ThermionEntity entity, String propertyName, int materialIndex, double value) {
|
Future setMaterialPropertyFloat(ThermionEntity entity, String propertyName,
|
||||||
|
int materialIndex, double value) {
|
||||||
// TODO: implement setMaterialPropertyFloat
|
// TODO: implement setMaterialPropertyFloat
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName, int materialIndex, double f1, double f2, double f3, double f4) {
|
Future setMaterialPropertyFloat4(ThermionEntity entity, String propertyName,
|
||||||
|
int materialIndex, double f1, double f2, double f3, double f4) {
|
||||||
// TODO: implement setMaterialPropertyFloat4
|
// TODO: implement setMaterialPropertyFloat4
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ThermionEntity> 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<ThermionTexture> createTexture(td.Uint8List data) {
|
||||||
|
// TODO: implement createTexture
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MaterialInstance> 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<MaterialInstance> 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<ThermionEntity> getMainCameraEntity() async {
|
||||||
|
final entityId = _module!.ccall(
|
||||||
|
"get_main_camera", "int", ["void*".toJS].toJS, [_viewer].toJS, null)
|
||||||
|
as JSNumber;
|
||||||
|
if (entityId.toDartInt == -1) {
|
||||||
|
throw Exception("Failed to get main camera");
|
||||||
|
}
|
||||||
|
return entityId.toDartInt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<MaterialInstance?> getMaterialInstanceAt(
|
||||||
|
ThermionEntity entity, int index) {
|
||||||
|
// TODO: implement getMaterialInstanceAt
|
||||||
|
throw UnimplementedError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void requestFrame() {
|
||||||
|
// TODO: implement requestFrame
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
// TODO: implement sceneUpdated
|
||||||
|
Stream<SceneUpdateEvent> 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
library;
|
||||||
|
|
||||||
|
export 'src/thermion_viewer_wasm.dart' show ThermionViewerWasm;
|
||||||
@@ -8,8 +8,8 @@ import 'package:thermion_dart/thermion_dart.dart';
|
|||||||
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart';
|
import 'package:thermion_dart/thermion_dart/swift/swift_bindings.g.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
|
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_viewer_ffi.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
/// Test files are run in a variety of ways, find this package root in all.
|
/// Test files are run in a variety of ways, find this package root in all.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import 'package:animation_tools_dart/animation_tools_dart.dart';
|
|||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:thermion_dart/thermion_dart/utils/geometry.dart';
|
import 'package:thermion_dart/thermion_dart/utils/geometry.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/events.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_viewer_ffi.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
import 'helpers.dart';
|
import 'helpers.dart';
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
|
|||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/utils/geometry.dart';
|
import 'package:thermion_dart/thermion_dart/utils/geometry.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_viewer_ffi.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
/// Test files are run in a variety of ways, find this package root in all.
|
/// Test files are run in a variety of ways, find this package root in all.
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
|||||||
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
|
import 'package:thermion_dart/thermion_dart/utils/dart_resources.dart';
|
||||||
|
|
||||||
import 'package:test/test.dart';
|
import 'package:test/test.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_dart.g.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_dart.g.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/ffi/thermion_viewer_ffi.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/ffi/src/thermion_viewer_ffi.dart';
|
||||||
|
|
||||||
import 'package:vector_math/vector_math_64.dart';
|
import 'package:vector_math/vector_math_64.dart';
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
import 'package:thermion_dart/thermion_dart/thermion_viewer.dart';
|
||||||
import 'package:thermion_dart/thermion_dart/viewer/web/thermion_viewer_wasm.dart';
|
import 'package:thermion_dart/thermion_dart/viewer/web_wasm/src/thermion_viewer_wasm.dart';
|
||||||
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
|
import 'package:thermion_flutter_platform_interface/thermion_flutter_platform_interface.dart';
|
||||||
import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart';
|
import 'package:thermion_flutter_platform_interface/thermion_flutter_texture.dart';
|
||||||
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
||||||
|
|||||||
Reference in New Issue
Block a user