Object Disappearing when changing rotation quaternion

So I am trying to take a CSV of quaternion x, y, z, and w data and rotate an object over time. I have a function that updates the rotation as follows:

function spinTo(quaternion) {
            obj.rotationQuaternion = quaternion;
        }

When I create a test function like this it works perfectly fine:

test = []
test.push(new BABYLON.Quaternion(0.0473354718233223, -0.038995545096617186, 0.001849356963890785, 0.9981158652424583))
test.push(new BABYLON.Quaternion(-0.603939672922976, -0.7249621028033587, -0.2172722940812589, -0.24995913904734043))
test.push(new BABYLON.Quaternion(.4, .4, .4, .4))
test.push(new BABYLON.Quaternion(.3, .3, .1, .7))
for (let i = 0; i < test.length; i++) {
   console.log(test[i])                     
   setTimeout(()=>{spinTo(test[i])}, (i+1)*500); 
}

but when I parse the file and try the exact same thing the mesh disappears.
Although the obvious explanation would be that it is parsing the csv incorrectly, when I print to console it seems the take in the quaternions perfectly. Can anyone bring some insight into why this may be happening? Thanks.

Seems it is working here - Babylon.js Playground
(I added mesh to your function parameter).

1 Like