Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple issues with scene extents computation #518

Closed
lexaknyazev opened this issue Dec 19, 2023 · 1 comment
Closed

Multiple issues with scene extents computation #518

lexaknyazev opened this issue Dec 19, 2023 · 1 comment
Assignees
Labels

Comments

@lexaknyazev
Copy link
Member

const boxMin = vec3.create();
let min = jsToGl(accessor.min);
if (accessor.normalized){
vec3.normalize(min, min);
}
vec3.transformMat4(boxMin, min, worldTransform);
const boxMax = vec3.create();
let max = jsToGl(accessor.max);
if (accessor.normalized){
vec3.normalize(max, max);
}
vec3.transformMat4(boxMax, max, worldTransform);

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants