refactor!: rename removeAsset to destroyAsset
use render thread methods for lights
This commit is contained in:
@@ -22,7 +22,7 @@ class _Gizmo {
|
||||
|
||||
Future dispose() async {
|
||||
await transformUpdates.close();
|
||||
await viewer.removeAsset(_gizmo);
|
||||
await viewer.destroyAsset(_gizmo);
|
||||
}
|
||||
|
||||
Future hide() async {
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// }
|
||||
|
||||
// Future dispose() async {
|
||||
// await viewer.removeAsset(_translationGizmo);
|
||||
// await viewer.destroyAsset(_translationGizmo);
|
||||
// }
|
||||
|
||||
// @override
|
||||
|
||||
@@ -246,6 +246,28 @@ void MaterialInstance_setTransparencyMode(
|
||||
transparencyMode.value,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TLightManager>, EntityId, ffi.Double,
|
||||
ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void LightManager_setPosition(
|
||||
ffi.Pointer<TLightManager> tLightManager,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TLightManager>, EntityId, ffi.Double,
|
||||
ffi.Double, ffi.Double)>(isLeaf: true)
|
||||
external void LightManager_setDirection(
|
||||
ffi.Pointer<TLightManager> tLightManager,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TViewer> Function(ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>,
|
||||
ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Char>)>(isLeaf: true)
|
||||
@@ -406,6 +428,12 @@ external ffi.Pointer<TRenderableManager> Engine_getRenderableManager(
|
||||
ffi.Pointer<TEngine> engine,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Pointer<TLightManager> Function(ffi.Pointer<TEngine>)>(
|
||||
isLeaf: true)
|
||||
external ffi.Pointer<TLightManager> Engine_getLightManager(
|
||||
ffi.Pointer<TEngine> engine,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Pointer<TEntityManager> Function(ffi.Pointer<TEngine>)>(
|
||||
isLeaf: true)
|
||||
external ffi.Pointer<TEntityManager> Engine_getEntityManager(
|
||||
@@ -465,11 +493,16 @@ external void set_background_color(
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>, ffi.Pointer<ffi.Char>)>(
|
||||
isLeaf: true)
|
||||
external void load_skybox(
|
||||
external void Viewer_loadSkybox(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<ffi.Char> skyboxPath,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void Viewer_removeSkybox(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TViewer>, ffi.Pointer<ffi.Char>, ffi.Float)>(isLeaf: true)
|
||||
@@ -479,6 +512,11 @@ external void Viewer_loadIbl(
|
||||
double intensity,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void Viewer_removeIbl(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, ffi.Float, ffi.Float, ffi.Float,
|
||||
ffi.Float)>(isLeaf: true)
|
||||
@@ -497,88 +535,6 @@ external void rotate_ibl(
|
||||
ffi.Pointer<ffi.Float> rotationMatrix,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void remove_skybox(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void remove_ibl(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
EntityId Function(
|
||||
ffi.Pointer<TViewer>,
|
||||
ffi.Uint8,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Bool)>(isLeaf: true)
|
||||
external int add_light(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
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 shadows,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>, EntityId)>(isLeaf: true)
|
||||
external void remove_light(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
int entityId,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void clear_lights(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, EntityId, ffi.Float, ffi.Float,
|
||||
ffi.Float)>(isLeaf: true)
|
||||
external void set_light_position(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, EntityId, ffi.Float, ffi.Float,
|
||||
ffi.Float)>(isLeaf: true)
|
||||
external void set_light_direction(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
int light,
|
||||
double x,
|
||||
double y,
|
||||
double z,
|
||||
);
|
||||
|
||||
@ffi.Native<EntityId Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external int get_main_camera(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
@@ -1314,6 +1270,14 @@ external void Viewer_loadIblRenderThread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void Viewer_removeIblRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TViewer>,
|
||||
@@ -1341,6 +1305,23 @@ external void Viewer_destroyRenderTargetRenderThread(
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void Viewer_loadSkyboxRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<ffi.Char> skyboxPath,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void Viewer_removeSkyboxRenderThread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TEngine>,
|
||||
@@ -1462,20 +1443,6 @@ external void set_background_image_position_render_thread(
|
||||
bool clamp,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TViewer>, ffi.Pointer<ffi.Char>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void load_skybox_render_thread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
ffi.Pointer<ffi.Char> skyboxPath,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> onComplete,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TViewer>)>(isLeaf: true)
|
||||
external void remove_skybox_render_thread(
|
||||
ffi.Pointer<TViewer> viewer,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
@@ -1656,24 +1623,89 @@ external void SceneManager_loadGltfRenderThread(
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<ffi.Void> Function(ffi.Pointer<TSceneManager>,
|
||||
ffi.Void Function(ffi.Pointer<TSceneManager>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external ffi.Pointer<ffi.Void> SceneManager_destroyAllRenderThread(
|
||||
external void SceneManager_destroyAllRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<ffi.Void> Function(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
ffi.Pointer<TSceneAsset>,
|
||||
ffi.Void Function(ffi.Pointer<TSceneManager>, ffi.Pointer<TSceneAsset>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external ffi.Pointer<ffi.Void> SceneManager_destroyAssetRenderThread(
|
||||
external void SceneManager_destroyAssetRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<TSceneAsset> sceneAsset,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TSceneManager>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void SceneManager_destroyAssetsRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TSceneManager>,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void SceneManager_destroyLightsRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
EntityId Function(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
ffi.Uint8,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Bool,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(EntityId)>>)>(
|
||||
isLeaf: true)
|
||||
external int SceneManager_addLightRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
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 shadows,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function(EntityId)>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(ffi.Pointer<TSceneManager>, EntityId,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>>)>(isLeaf: true)
|
||||
external void SceneManager_removeLightRenderThread(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
int entityId,
|
||||
ffi.Pointer<ffi.NativeFunction<ffi.Void Function()>> callback,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
@@ -2012,6 +2044,7 @@ external void SceneManager_transformToUnitCube(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
ffi.Pointer<ffi.Uint8>,
|
||||
ffi.Size,
|
||||
ffi.Int,
|
||||
ffi.Bool,
|
||||
ffi.Int,
|
||||
ffi.Int,
|
||||
@@ -2020,6 +2053,7 @@ external ffi.Pointer<TSceneAsset> SceneManager_loadGlbFromBuffer(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<ffi.Uint8> arg1,
|
||||
int length,
|
||||
int numInstances,
|
||||
bool keepData,
|
||||
int priority,
|
||||
int layer,
|
||||
@@ -2047,26 +2081,81 @@ external ffi.Pointer<TSceneAsset> SceneManager_loadGltf(
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TAnimationManager> Function(
|
||||
ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external ffi.Pointer<TAnimationManager> SceneManager_getAnimationManager(
|
||||
EntityId Function(
|
||||
ffi.Pointer<TSceneManager>,
|
||||
ffi.Uint8,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Float,
|
||||
ffi.Bool)>(isLeaf: true)
|
||||
external int SceneManager_addLight(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
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 shadows,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Pointer<ffi.Void> Function(ffi.Pointer<TSceneManager>)>(
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TSceneManager>, EntityId)>(
|
||||
isLeaf: true)
|
||||
external ffi.Pointer<ffi.Void> SceneManager_destroyAll(
|
||||
external void SceneManager_removeLight(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
int entityId,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external void SceneManager_destroyLights(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<ffi.Void> Function(
|
||||
ffi.Void Function(
|
||||
ffi.Pointer<TSceneManager>, ffi.Pointer<TSceneAsset>)>(isLeaf: true)
|
||||
external ffi.Pointer<ffi.Void> SceneManager_destroyAsset(
|
||||
external void SceneManager_destroyAsset(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
ffi.Pointer<TSceneAsset> sceneAsset,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external void SceneManager_destroyAssets(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external void SceneManager_destroyAll(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TAnimationManager> Function(
|
||||
ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
external ffi.Pointer<TAnimationManager> SceneManager_getAnimationManager(
|
||||
ffi.Pointer<TSceneManager> tSceneManager,
|
||||
);
|
||||
|
||||
@ffi.Native<
|
||||
ffi.Pointer<TNameComponentManager> Function(
|
||||
ffi.Pointer<TSceneManager>)>(isLeaf: true)
|
||||
@@ -2118,6 +2207,13 @@ external ffi.Pointer<TMaterialInstance> RenderableManager_getMaterialInstanceAt(
|
||||
int primitiveIndex,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Bool Function(ffi.Pointer<TRenderableManager>, EntityId)>(
|
||||
isLeaf: true)
|
||||
external bool RenderableManager_isRenderable(
|
||||
ffi.Pointer<TRenderableManager> tRenderableManager,
|
||||
int entityId,
|
||||
);
|
||||
|
||||
@ffi.Native<ffi.Void Function(ffi.Pointer<TSceneAsset>, ffi.Pointer<TScene>)>(
|
||||
isLeaf: true)
|
||||
external void SceneAsset_addToScene(
|
||||
@@ -2425,6 +2521,8 @@ final class TViewer extends ffi.Opaque {}
|
||||
|
||||
final class TSceneManager extends ffi.Opaque {}
|
||||
|
||||
final class TLightManager extends ffi.Opaque {}
|
||||
|
||||
final class TRenderTarget extends ffi.Opaque {}
|
||||
|
||||
final class TSwapChain extends ffi.Opaque {}
|
||||
|
||||
@@ -356,7 +356,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
final pathPtr = skyboxPath.toNativeUtf8(allocator: allocator).cast<Char>();
|
||||
|
||||
await withVoidCallback((cb) {
|
||||
load_skybox_render_thread(_viewer!, pathPtr, cb);
|
||||
Viewer_loadSkyboxRenderThread(_viewer!, pathPtr, cb);
|
||||
});
|
||||
|
||||
allocator.free(pathPtr);
|
||||
@@ -401,7 +401,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
@override
|
||||
Future removeSkybox() async {
|
||||
remove_skybox_render_thread(_viewer!);
|
||||
await withVoidCallback((cb) {
|
||||
Viewer_removeSkyboxRenderThread(_viewer!, cb);
|
||||
});
|
||||
}
|
||||
|
||||
///
|
||||
@@ -454,25 +456,27 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
@override
|
||||
Future<ThermionEntity> addDirectLight(DirectLight directLight) async {
|
||||
var entity = SceneManager_addLight(
|
||||
_sceneManager!,
|
||||
directLight.type.index,
|
||||
directLight.color,
|
||||
directLight.intensity,
|
||||
directLight.position.x,
|
||||
directLight.position.y,
|
||||
directLight.position.z,
|
||||
directLight.direction.x,
|
||||
directLight.direction.y,
|
||||
directLight.direction.z,
|
||||
directLight.falloffRadius,
|
||||
directLight.spotLightConeInner,
|
||||
directLight.spotLightConeOuter,
|
||||
directLight.sunAngularRadius,
|
||||
directLight.sunHaloSize,
|
||||
directLight.sunHaloFallof,
|
||||
directLight.castShadows,
|
||||
);
|
||||
var entity = await withIntCallback((cb) {
|
||||
SceneManager_addLightRenderThread(
|
||||
_sceneManager!,
|
||||
directLight.type.index,
|
||||
directLight.color,
|
||||
directLight.intensity,
|
||||
directLight.position.x,
|
||||
directLight.position.y,
|
||||
directLight.position.z,
|
||||
directLight.direction.x,
|
||||
directLight.direction.y,
|
||||
directLight.direction.z,
|
||||
directLight.falloffRadius,
|
||||
directLight.spotLightConeInner,
|
||||
directLight.spotLightConeOuter,
|
||||
directLight.sunAngularRadius,
|
||||
directLight.sunHaloSize,
|
||||
directLight.sunHaloFallof,
|
||||
directLight.castShadows,
|
||||
cb);
|
||||
});
|
||||
if (entity == FILAMENT_ASSET_ERROR) {
|
||||
throw Exception("Failed to add light to scene");
|
||||
}
|
||||
@@ -484,7 +488,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
@override
|
||||
Future removeLight(ThermionEntity entity) async {
|
||||
SceneManager_removeLight(_sceneManager!, entity);
|
||||
await withVoidCallback((cb) {
|
||||
SceneManager_removeLightRenderThread(_sceneManager!, entity, cb);
|
||||
});
|
||||
}
|
||||
|
||||
///
|
||||
@@ -492,7 +498,9 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
@override
|
||||
Future destroyLights() async {
|
||||
SceneManager_destroyLights(_sceneManager!);
|
||||
await withVoidCallback((cb) {
|
||||
SceneManager_destroyLightsRenderThread(_sceneManager!, cb);
|
||||
});
|
||||
}
|
||||
|
||||
///
|
||||
@@ -976,7 +984,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
///
|
||||
///
|
||||
@override
|
||||
Future removeAsset(covariant FFIAsset asset) async {
|
||||
Future destroyAsset(covariant FFIAsset asset) async {
|
||||
if (asset.boundingBoxAsset != null) {
|
||||
await asset.setBoundingBoxVisibility(false);
|
||||
await withVoidCallback((callback) =>
|
||||
@@ -993,7 +1001,7 @@ class ThermionViewerFFI extends ThermionViewer {
|
||||
@override
|
||||
Future destroyAssets() async {
|
||||
await withVoidCallback((callback) {
|
||||
SceneManager_destroyAllRenderThread(_sceneManager!, callback);
|
||||
SceneManager_destroyAssetsRenderThread(_sceneManager!, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -377,10 +377,10 @@ abstract class ThermionViewer {
|
||||
{int skinIndex = 0});
|
||||
|
||||
///
|
||||
/// Removes/destroys the specified entity from the scene.
|
||||
/// [entity] will no longer be a valid handle after this method is called; ensure you immediately discard all references once this method is complete.
|
||||
/// Destroys [asset] and all underlying resources
|
||||
/// (including instances, but excluding any manually created material instances).
|
||||
///
|
||||
Future removeAsset(ThermionAsset asset);
|
||||
Future destroyAsset(ThermionAsset asset);
|
||||
|
||||
///
|
||||
/// Removes/destroys all renderable entities from the scene (including cameras).
|
||||
|
||||
@@ -410,13 +410,6 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future setParent(ThermionEntity child, ThermionEntity parent, { bool preserveScaling = false}) {
|
||||
// TODO: implement setParent
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setPosition(ThermionEntity entity, double x, double y, double z) {
|
||||
// TODO: implement setPosition
|
||||
@@ -1008,7 +1001,7 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
}
|
||||
|
||||
@override
|
||||
Future removeAsset(ThermionAsset asset) {
|
||||
Future destroyAsset(ThermionAsset asset) {
|
||||
// TODO: implement removeAsset
|
||||
throw UnimplementedError();
|
||||
}
|
||||
@@ -1102,6 +1095,12 @@ class ThermionViewerStub extends ThermionViewer {
|
||||
// TODO: implement showGridOverlay
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future setParent(ThermionEntity child, ThermionEntity? parent, {bool preserveScaling=false}) {
|
||||
// TODO: implement setParent
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -319,8 +319,8 @@
|
||||
// }
|
||||
|
||||
// @JSExport()
|
||||
// JSPromise removeAsset(ThermionEntity entity) =>
|
||||
// viewer.removeAsset(entity).toJS;
|
||||
// JSPromise destroyAsset(ThermionEntity entity) =>
|
||||
// viewer.destroyAsset(entity).toJS;
|
||||
|
||||
// @JSExport()
|
||||
// JSPromise destroyAssets() {
|
||||
|
||||
@@ -339,8 +339,8 @@
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future<void> removeAsset(ThermionEntity entity) async {
|
||||
// await _shim.removeAsset(entity).toDart;
|
||||
// Future<void> destroyAsset(ThermionEntity entity) async {
|
||||
// await _shim.destroyAsset(entity).toDart;
|
||||
// }
|
||||
|
||||
// @override
|
||||
|
||||
@@ -164,8 +164,8 @@ extension type ThermionViewerJSShim(JSObject _) implements JSObject {
|
||||
JSNumber fadeOutInSecs,
|
||||
JSNumber maxDelta);
|
||||
|
||||
@JS('removeAsset')
|
||||
external JSPromise removeAsset(ThermionEntity entity);
|
||||
@JS('destroyAsset')
|
||||
external JSPromise destroyAsset(ThermionEntity entity);
|
||||
|
||||
@JS('destroyAssets')
|
||||
external JSPromise destroyAssets();
|
||||
|
||||
@@ -225,8 +225,8 @@
|
||||
// return;
|
||||
// }
|
||||
// await setRendering(false);
|
||||
// await clearEntities();
|
||||
// await clearLights();
|
||||
// await destroyAssets();
|
||||
// await destroyLights();
|
||||
// _destroyViewer();
|
||||
|
||||
// _sceneManager = null;
|
||||
@@ -1130,13 +1130,13 @@
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future clearEntities() async {
|
||||
// Future destroyAssets() async {
|
||||
// _module!.ccall(
|
||||
// "clear_entities", "void", ["void*".toJS].toJS, [_viewer!].toJS, null);
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future clearLights() async {
|
||||
// Future destroyLights() async {
|
||||
// _module!.ccall(
|
||||
// "clear_lights", "void", ["void*".toJS].toJS, [_viewer!].toJS, null);
|
||||
// }
|
||||
@@ -1585,7 +1585,7 @@
|
||||
// }
|
||||
|
||||
// @override
|
||||
// Future removeEntity(ThermionEntity entity) async {
|
||||
// Future destroyAsset(ThermionEntity entity) async {
|
||||
// _module!.ccall("remove_entity", "void", ["void*".toJS, "int".toJS].toJS,
|
||||
// [_viewer!, entity.toJS].toJS, null);
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user