Center of model changing
Closed this issue · 6 comments
Describe the bug
Loading a model with GLTFLoader.load directly vs loading a model through gltf-transform then GLTFLoader.parse generates a different center for the model (according to Box3().setFromObject(model).getCenter())
To Reproduce
- Load this model through gltf-transform then GLTFLoader.parse https://we.tl/t-BgNDHZ1xrZ
- Compare center to when loading with GLTFLoader.load
Expected behavior
Center should remain consistent
Versions:
- Version: 4.0.0-alpha.8
- Environment: Browser
@dennis-modelsend could you expand on what you mean by "load this model through gltf-transform"? Do you mean simply read/write without changes? Testing that on the CLI:
gltf-transform cp input.glb output.glb
The scene has the same bounds before and after:
# | name | rootName | bboxMin | bboxMax |
---|---|---|---|---|
0 | Sketchfab_Scene | Sketchfab_model | -47.82007, -47.82007, -79.41164 | 47.82007, 47.82007, -1.26045 |
# | name | rootName | bboxMin | bboxMax |
---|---|---|---|---|
0 | Sketchfab_Scene | Sketchfab_model | -47.82007, -47.82007, -79.41164 | 47.82007, 47.82007, -1.26045 |
To investigate this I'll need to be able to reproduce it, and knowing the version of glTF Transform used, and complete steps to reproduce, would be helpful.
@donmccurdy I use threejs FileLoader then use @gltf-transform/core WebIO.readBinary and writeBinary without any transforms
Using 4.0.0-alpha.8
@dennis-modelsend I've had a quick go at this, and I'm not immediately able to reproduce any issue. If you can share full reproduction steps — a demo, or complete code — I can investigate further. I'm happy to spend time investigating the bug, but would prefer not to spend time guessing what your code looks like. Occasionally, the cause of a bug can be something as non-obvious as the bundler configuration.
Found the issue while writing the demo, I was only calling updateMatrixWorld on only one of the objects ... thank you for the help Don
@dennis-modelsend ah sorry, that's the least fun kind of bug! Note that THREE.GLTFLoader in r163 will start doing updateMatrixWorld automatically before returning the scene: