KhronosGroup / glTF-Sample-Viewer

Physically-Based Rendering in glTF 2.0 using WebGL
Apache License 2.0
1.21k stars 229 forks source link

Multiple issues with scene extents computation #518

Closed lexaknyazev closed 3 months ago

lexaknyazev commented 5 months ago

https://github.com/KhronosGroup/glTF-Sample-Viewer/blob/831cf2b03a64ad149f8f18f6d56e512a08ad0737/source/gltf/gltf_utils.js#L55-L67

Incorrect accessor normalization

To get effective min/max values of normalized accessors, their components need to be divided by a constant value determined from the accessor's component type (e.g., 65535 for unsigned short).

Incorrect bounding box transformation

To transform a bounding box, the transformation matrix should be applied to all its eight vertices and then all their components should be compared to determine the new bounding box.

UX3D-kanzler commented 4 months ago

Good catch. Most assets that have normalized and quantized accessors use the complete value range of the component type. For this reason, it is difficult to notice. I have prepared an asset that does not cover the complete range and hence demonstrates the issue: Avocado-normalized.zip