Hey, everyone!
I’ve been working on a way of automatically processing specific meshes in the scene to their proper collision types like the guide on the wiki, but I’m running into a strange problem here.
The monkey head on the right is the GLB model that is being imported, and the white box on the left with a reversed position and rotation is the visible collision box that is being generated by my code.
For some reason when reading the position and rotation values of the GLB file, it’s mirrored across the world X-axis. I can fix the position by typing in -X in my function, but the rotation is no easy fix unfortunately, at least in terms of quaternions. Does anyone know what would cause the input values of a GLB to be scaled over the X-axis like this?
Here is my code for processing the monkey GLB file:
BABYLON.SceneLoader.ImportMesh("", “./textures/monkey.glb”, “”, scene, function(newMeshes)
{
processCollisions(newMeshes);
});
function processCollisions(newMeshes)
{
newMeshes.forEach((m)=>{
if(m.name.indexOf(“box”) != -1){
m.scaling.x = Math.abs(m.scaling.x)
m.scaling.y = Math.abs(m.scaling.y)
m.scaling.z = Math.abs(m.scaling.z)
let tempPhys = BABYLON.MeshBuilder.CreateBox("", { width: m.scaling.x * 2, height: m.scaling.y * 2, depth: m.scaling.z * 2 }, scene);
tempPhys.rotationQuaternion = m.rotationQuaternion;
tempPhys.position = new BABYLON.Vector3(m.position.x, m.position.y, m.position.z);
tempPhys.physicsImpostor = new BABYLON.PhysicsImpostor(tempPhys, BABYLON.PhysicsImpostor.BoxImpostor, { mass: 0 }, scene);
tempPhys.visibility = true;
m.dispose();
}
});
}



