formatting
This commit is contained in:
@@ -63,7 +63,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
focalLength = kFocalLength;
|
focalLength = kFocalLength;
|
||||||
}
|
}
|
||||||
await camera.setLensProjection(
|
await camera.setLensProjection(
|
||||||
near: near, far: far, aspect: aspect, focalLength: focalLength);
|
near: near,
|
||||||
|
far: far,
|
||||||
|
aspect: aspect,
|
||||||
|
focalLength: focalLength,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +87,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
|
|
||||||
await view.setCamera(camera);
|
await view.setCamera(camera);
|
||||||
|
|
||||||
animationManager = await withPointerCallback<TAnimationManager>((cb) =>
|
animationManager = await withPointerCallback<TAnimationManager>(
|
||||||
AnimationManager_createRenderThread(app.engine, scene.scene, cb));
|
(cb) => AnimationManager_createRenderThread(app.engine, scene.scene, cb),
|
||||||
|
);
|
||||||
|
|
||||||
RenderTicker_addAnimationManager(app.renderTicker, animationManager);
|
RenderTicker_addAnimationManager(app.renderTicker, animationManager);
|
||||||
|
|
||||||
@@ -113,8 +118,14 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future render() async {
|
Future render() async {
|
||||||
await withVoidCallback((requestId, cb) => RenderTicker_renderRenderThread(
|
await withVoidCallback(
|
||||||
app.renderTicker, 0.toBigInt, requestId, cb));
|
(requestId, cb) => RenderTicker_renderRenderThread(
|
||||||
|
app.renderTicker,
|
||||||
|
0.toBigInt,
|
||||||
|
requestId,
|
||||||
|
cb,
|
||||||
|
),
|
||||||
|
);
|
||||||
await FilamentApp.instance!.flush();
|
await FilamentApp.instance!.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,8 +224,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future setBackgroundImagePosition(double x, double y,
|
Future setBackgroundImagePosition(
|
||||||
{bool clamp = false}) async {
|
double x,
|
||||||
|
double y, {
|
||||||
|
bool clamp = false,
|
||||||
|
}) async {
|
||||||
throw UnimplementedError();
|
throw UnimplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +241,12 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
|
|
||||||
skybox = await withPointerCallback<TSkybox>((cb) {
|
skybox = await withPointerCallback<TSkybox>((cb) {
|
||||||
Engine_buildSkyboxRenderThread(
|
Engine_buildSkyboxRenderThread(
|
||||||
app.engine, data.address, data.length, cb, nullptr);
|
app.engine,
|
||||||
|
data.address,
|
||||||
|
data.length,
|
||||||
|
cb,
|
||||||
|
nullptr,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
Scene_setSkybox(scene.scene, skybox!);
|
Scene_setSkybox(scene.scene, skybox!);
|
||||||
}
|
}
|
||||||
@@ -249,7 +268,13 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
|
|
||||||
indirectLight = await withPointerCallback<TIndirectLight>((cb) {
|
indirectLight = await withPointerCallback<TIndirectLight>((cb) {
|
||||||
Engine_buildIndirectLightRenderThread(
|
Engine_buildIndirectLightRenderThread(
|
||||||
app.engine, data.address, data.length, intensity, cb, nullptr);
|
app.engine,
|
||||||
|
data.address,
|
||||||
|
data.length,
|
||||||
|
intensity,
|
||||||
|
cb,
|
||||||
|
nullptr,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
if (FILAMENT_WASM) {
|
if (FILAMENT_WASM) {
|
||||||
//stackRestore(stackPtr);
|
//stackRestore(stackPtr);
|
||||||
@@ -291,8 +316,14 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (skybox != null) {
|
if (skybox != null) {
|
||||||
await withVoidCallback((requestId, cb) =>
|
await withVoidCallback(
|
||||||
Engine_destroySkyboxRenderThread(app.engine, skybox!, requestId, cb));
|
(requestId, cb) => Engine_destroySkyboxRenderThread(
|
||||||
|
app.engine,
|
||||||
|
skybox!,
|
||||||
|
requestId,
|
||||||
|
cb,
|
||||||
|
),
|
||||||
|
);
|
||||||
skybox = null;
|
skybox = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,9 +335,14 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
Future removeIbl() async {
|
Future removeIbl() async {
|
||||||
if (indirectLight != null) {
|
if (indirectLight != null) {
|
||||||
Scene_setIndirectLight(scene.scene, nullptr);
|
Scene_setIndirectLight(scene.scene, nullptr);
|
||||||
await withVoidCallback((requestId, cb) =>
|
await withVoidCallback(
|
||||||
Engine_destroyIndirectLightRenderThread(
|
(requestId, cb) => Engine_destroyIndirectLightRenderThread(
|
||||||
app.engine, indirectLight!, requestId, cb));
|
app.engine,
|
||||||
|
indirectLight!,
|
||||||
|
requestId,
|
||||||
|
cb,
|
||||||
|
),
|
||||||
|
);
|
||||||
indirectLight = null;
|
indirectLight = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,12 +390,14 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future<ThermionAsset> loadGltf(String path,
|
Future<ThermionAsset> loadGltf(
|
||||||
{bool addToScene = true,
|
String path, {
|
||||||
int numInstances = 1,
|
bool addToScene = true,
|
||||||
bool keepData = false,
|
int numInstances = 1,
|
||||||
String? resourceUri,
|
bool keepData = false,
|
||||||
bool loadAsync = false}) async {
|
String? resourceUri,
|
||||||
|
bool loadAsync = false,
|
||||||
|
}) async {
|
||||||
final data = await FilamentApp.instance!.loadResource(path);
|
final data = await FilamentApp.instance!.loadResource(path);
|
||||||
if (resourceUri == null) {
|
if (resourceUri == null) {
|
||||||
var split = path.split("/");
|
var split = path.split("/");
|
||||||
@@ -370,34 +408,42 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
resourceUri = "${resourceUri}/";
|
resourceUri = "${resourceUri}/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadGltfFromBuffer(data,
|
return loadGltfFromBuffer(
|
||||||
addToScene: addToScene,
|
data,
|
||||||
numInstances: numInstances,
|
addToScene: addToScene,
|
||||||
keepData: keepData,
|
numInstances: numInstances,
|
||||||
resourceUri: resourceUri,
|
keepData: keepData,
|
||||||
loadResourcesAsync: loadAsync);
|
resourceUri: resourceUri,
|
||||||
|
loadResourcesAsync: loadAsync,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future<ThermionAsset> loadGltfFromBuffer(Uint8List data,
|
Future<ThermionAsset> loadGltfFromBuffer(
|
||||||
{bool addToScene = true,
|
Uint8List data, {
|
||||||
int numInstances = 1,
|
bool addToScene = true,
|
||||||
bool keepData = false,
|
int numInstances = 1,
|
||||||
int priority = 4,
|
bool keepData = false,
|
||||||
int layer = 0,
|
int priority = 4,
|
||||||
bool loadResourcesAsync = false,
|
int layer = 0,
|
||||||
String? resourceUri}) async {
|
bool loadResourcesAsync = false,
|
||||||
var asset = await FilamentApp.instance!.loadGltfFromBuffer(
|
String? resourceUri,
|
||||||
data, animationManager,
|
}) async {
|
||||||
numInstances: numInstances,
|
var asset =
|
||||||
keepData: keepData,
|
await FilamentApp.instance!.loadGltfFromBuffer(
|
||||||
priority: priority,
|
data,
|
||||||
layer: layer,
|
animationManager,
|
||||||
loadResourcesAsync: loadResourcesAsync,
|
numInstances: numInstances,
|
||||||
resourceUri: resourceUri) as FFIAsset;
|
keepData: keepData,
|
||||||
|
priority: priority,
|
||||||
|
layer: layer,
|
||||||
|
loadResourcesAsync: loadResourcesAsync,
|
||||||
|
resourceUri: resourceUri,
|
||||||
|
)
|
||||||
|
as FFIAsset;
|
||||||
|
|
||||||
_assets.add(asset);
|
_assets.add(asset);
|
||||||
if (addToScene) {
|
if (addToScene) {
|
||||||
@@ -413,7 +459,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
@override
|
@override
|
||||||
Future destroyAsset(covariant FFIAsset asset) async {
|
Future destroyAsset(covariant FFIAsset asset) async {
|
||||||
_assets.remove(asset);
|
_assets.remove(asset);
|
||||||
await asset.removeAnimationComponent();
|
await asset.removeAnimationComponent();
|
||||||
await scene.remove(asset);
|
await scene.remove(asset);
|
||||||
|
|
||||||
if (asset.boundingBoxAsset != null) {
|
if (asset.boundingBoxAsset != null) {
|
||||||
@@ -421,7 +467,6 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
await FilamentApp.instance!.destroyAsset(asset.boundingBoxAsset!);
|
await FilamentApp.instance!.destroyAsset(asset.boundingBoxAsset!);
|
||||||
}
|
}
|
||||||
await FilamentApp.instance!.destroyAsset(asset);
|
await FilamentApp.instance!.destroyAsset(asset);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -476,7 +521,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
///
|
///
|
||||||
Future setSoftShadowOptions(
|
Future setSoftShadowOptions(
|
||||||
double penumbraScale, double penumbraRatioScale) async {
|
double penumbraScale,
|
||||||
|
double penumbraRatioScale,
|
||||||
|
) async {
|
||||||
View_setSoftShadowOptions(view.view, penumbraScale, penumbraRatioScale);
|
View_setSoftShadowOptions(view.view, penumbraScale, penumbraRatioScale);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,7 +559,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future setLightPosition(
|
Future setLightPosition(
|
||||||
ThermionEntity lightEntity, double x, double y, double z) async {
|
ThermionEntity lightEntity,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double z,
|
||||||
|
) async {
|
||||||
LightManager_setPosition(app.lightManager, lightEntity, x, y, z);
|
LightManager_setPosition(app.lightManager, lightEntity, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -521,10 +572,17 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
///
|
///
|
||||||
@override
|
@override
|
||||||
Future setLightDirection(
|
Future setLightDirection(
|
||||||
ThermionEntity lightEntity, Vector3 direction) async {
|
ThermionEntity lightEntity,
|
||||||
|
Vector3 direction,
|
||||||
|
) async {
|
||||||
direction.normalize();
|
direction.normalize();
|
||||||
LightManager_setPosition(
|
LightManager_setPosition(
|
||||||
app.lightManager, lightEntity, direction.x, direction.y, direction.z);
|
app.lightManager,
|
||||||
|
lightEntity,
|
||||||
|
direction.x,
|
||||||
|
direction.y,
|
||||||
|
direction.z,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -542,8 +600,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
Future<v64.Aabb3> getRenderableBoundingBox(ThermionEntity entityId) async {
|
Future<v64.Aabb3> getRenderableBoundingBox(ThermionEntity entityId) async {
|
||||||
final result = RenderableManager_getAabb(app.renderableManager, entityId);
|
final result = RenderableManager_getAabb(app.renderableManager, entityId);
|
||||||
return v64.Aabb3.centerAndHalfExtents(
|
return v64.Aabb3.centerAndHalfExtents(
|
||||||
Vector3(result.centerX, result.centerY, result.centerZ),
|
Vector3(result.centerX, result.centerY, result.centerZ),
|
||||||
Vector3(result.halfExtentX, result.halfExtentY, result.halfExtentZ));
|
Vector3(result.halfExtentX, result.halfExtentY, result.halfExtentZ),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@@ -676,8 +735,11 @@ class ThermionViewerFFI extends ThermionViewer {
|
|||||||
@override
|
@override
|
||||||
Future<GizmoAsset> getGizmo(GizmoType gizmoType) async {
|
Future<GizmoAsset> getGizmo(GizmoType gizmoType) async {
|
||||||
if (_gizmos[gizmoType] == null) {
|
if (_gizmos[gizmoType] == null) {
|
||||||
_gizmos[gizmoType] = await FilamentApp.instance!
|
_gizmos[gizmoType] = await FilamentApp.instance!.createGizmo(
|
||||||
.createGizmo(view, animationManager, gizmoType);
|
view,
|
||||||
|
animationManager,
|
||||||
|
gizmoType,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return _gizmos[gizmoType]!;
|
return _gizmos[gizmoType]!;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user