I lost couple days investigating an issue I had by updating my Babylon lib from v4.0.0.alpha32 to the last stable one. Which is v4.0.3 from now.
Long story short I have an editor which is using Babylon (of course).
This editor is used to make a map an eventually add 3D models in this map then when you save the map all data are exported in a file and in theses data I have model rotation (rotationQuaternion).
Then when I load the map I parse all theses data and somehow my rotationQuaternion data was parsed as string (so my bad) and not as number so I had some thing like that:
And this issue make my model not appear with no error. So I don’t know if it’s really a bug. But is it possible in future Babylon version to check, in the Quaternion constructor if the parameters are number and if not converting them to number or throw an error?
So far I fixed it by fixing my parsing part to ensure having number type.
Hope I can save some debug time for those who will get into this issue.
I do!
But somehow strings can be passed to Quaternion constructor this way
…
case “Quaternion”:
retval = new (Function.prototype.bind.apply(BABYLON.Quaternion, [null].concat(objectsParams)));
…
But the problem is, it was working this way in previous Babylon version this issue has appeared recently.
Hey, we cannot check at runtime because of performance reason. We want the math library to be as fast as it possible can so there is almost no check at all
This is not a bug, this is the way it should be. but if you want to keep your code without major changes, you can always add scalineInPlace after every quaternion creation. something like this:
sphere.rotationQuaternion = new BABYLON.Quaternion("-0.1", "0", "0", "-0.7").scaleInPlace(1);
As I said I don’t know if we can considering this issue as a bug. The bad thing about that is,
It was working before, I just updated babylon lib and my models have just disappeared with no error or warning.
I don’t know if something can be done in the Babylon lib without mess with the performance to at least emit an error.
But anyway now I’m fine. I fixed my parser to ensure sending number type to Quaternion constructor!
PS: I do use typescript but I can still pass string in Quaternion constructor