model-viewer
model-viewer copied to clipboard
Node with transform doesn't scale properly
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:
When I modify the model (link) to use the matrix
property instead of scale
, the entire model is flipped along the vertical axis:
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).
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?
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