model-viewer icon indicating copy to clipboard operation
model-viewer copied to clipboard

Node with transform doesn't scale properly

Open Jochem-W opened this issue 3 years ago • 2 comments

When I open a model (link) in the PlayCanvas Viewer that scales the root node along the X-axis by using the scale property it's displayed correctly: image

When I modify the model (link) to use the matrix property instead of scale, the entire model is flipped along the vertical axis: image

Both models validate without errors and are displayed correctly in almost every other viewer I tested (only Cesium had trouble with the normals, but this is a known issue).

Jochem-W avatar Jan 07 '22 22:01 Jochem-W

That model has a negative scale on the X axis.

So this is because the engine extracts scale from the matrix property using the Mat4#getScale function which only returns positive scales.

https://github.com/playcanvas/engine/blob/dev/src/resources/parser/glb-parser.js#L1457

Got any thoughts on this @mvaligursky or @slimbuck?

willeastcott avatar Jan 10 '22 13:01 willeastcott

We might need to do what's suggested here: https://pixel.engineer/posts/matrix-decomposition-unity/

an additional negativity check on the rotation matrix and flip both scale and rotation in some cases

mvaligursky avatar Jan 10 '22 13:01 mvaligursky