My code is as follows:
var knot01 = BABYLON.SceneLoader.ImportMesh("", “model/glTF2.0/”, “jc.glb”, scene, function (newMeshes) { // Set the target of the camera to the first imported mesh
for (let i = 0; i < newMeshes.length; i++) {
newMeshes[i].scaling = new BABYLON.Vector3(10, 10, 10)
}
});
Off-hand, I’d hazard a guess that the GLB is using a right-handed coordinate and/or has inverted axis. Negative scale factors will cause image reversal like this, and since your scaling is positive, a likely explanation is that the model’s coordinate system isn’t aligned with BabylonJS
I cannot confirm this without playground repro to test it out. But gltf/glb files come with the root node, which is a parent node of all meshes in the scene, and this node is classified as a “mesh”. So when you call newMeshes[i].scaling the newMeshes[0] is most likely root node. Basically, when you export mesh from 3D software, its coordinate system usually does not match the webgl standards, so root node is added during export to “fix” that issue. My guess is that by default scaling of the root node contains negative values, so something like (-1,1,1), and when you iterate through meshes and scale them, you assign them new values (10, 10, 10), and that negative value basically flips.
So some thoughts that you can consider is:
Ignore root during scaling, and scale everything else.
Figure out the scaling of root and consider those values when you scaling.
Yup this is exactly as stated above, the -1 required to handled handedness needs to stay in the scale, so you might be better using the scaling functions instead of assigning a new value