addToScene() accepts several entity types:
addToScene(
scene: SceneContext,
entity:
| Camera
| Mesh
| SceneNode
| LightBase
| ShadowGenerator
| AssetContainer,
): void;
But removeFromScene() does not appear to support the same set of types.
This makes the API asymmetric: if an app can add an entity/container with addToScene(), it should also be able to remove the same thing with removeFromScene().
Expected API
removeFromScene(
scene: SceneContext,
entity:
| Camera
| Mesh
| SceneNode
| LightBase
| ShadowGenerator
| AssetContainer,
): void;
Or, if some types should not be removable, the difference should be explicit and documented.
GLB use case
loadGltf() returns an AssetContainer:
const container: AssetContainer = await loadGltf(engine, url);
addToScene(scene, container);
// Later:
removeFromScene(scene, container);
Currently, there is no clear public way to fully remove/dispose everything added from the loaded container.
Expected behavior for AssetContainer
When removing an AssetContainer, removeFromScene() should undo what addToScene(scene, container) did:
- recursively remove
container.entities - dispose/free mesh GPU resources where applicable
- unregister container animation groups
- unregister related render/update callbacks
- remove container-owned lights/camera/shadow generators if they were added
- clean skeleton/material variant metadata if applicable
- be safe to call more than once
Request
Please make removeFromScene() symmetric with addToScene(), especially for AssetContainer, so loaded GLB/GLTF models can be safely unloaded.