On scaling gltf scenes
Because some gltf scenes are in milimeters and therefore super big our loaders have an option to normalize assets size to 1x1x1. It's is problematic with ECS as scene bounds are not known until first transformSystem pass. Therefore various versions of the code below are present in ECS based projects:
renderEngine.transformSystem.update(world.entities);
rescaleScene(sceneEntities[0]);
Which is not pretty. Alternative solution:
- don't scale scenes -> fix your asset! current attitude after posting this issue
- expose transformSystem and update manually like above (will cause issues in Nodes)
- add some
normalizeOnFirstFrameflag -> seems messy
Unless better solution is found i'll stick with the first option for now but wanted to document that the issue exists.
don't scale scenes -> fix your asset! current attitude after posting this issue
Unfortunately gltf sample models are all over the place in term of scaling.
Sounds like a good use case to have a "center and normalize scene system".
Could be quite good example on how to make your own system.
if (enitity.normaliseScale && !aabb.empty(entity.transform.worldBounds) {
rescaleEntity(enitity)
delete enitity.normaliseScale
}
Just instantiate temp transformSystem, update your scene graph worldBounds in loader (always) so the user can center and normalizeScale as it wishes.
Done, feels a bit dirty but will close for now. Reopen if we think normalizing Scene should also be an option in the gltf loader or somewhere else.
Note on alternatives:
// Update transform system
renderEngine.systems
.find((system) => system.type === "transform-system")
.update(scene.entities);
// Update all systems
renderEngine.update(scene.entities);