Hiya D! Cool project!
I am HIGHLY un-qualified for this, but… terms “orthogonal” and “perpendicular” might be good playground/forums search fodder, for this.
Ok, now for the two playgrounds I have bookmarked under my “orthogonals” category…
Click on box to place cylinders that are always oriented orthogonal to box. Notice the Dot and Cross directives in lines 50/51. That might be something worth investigating. The .rotate() in line 53… is a .rotationQuaternion-based thing… and likely doesn’t affect Euler .rotation. I THINK… using a .rotate() method like that… tells BJS system to automatically install a .rotationQuaternion on that mesh, and use IT instead of .rotation property. Read-on for more about that.
After model-load, mouse-around on the canvas. The monkey’s head always stays “upright”, no matter what mesh surface-angle… the pointer crosses. “thoggin’”… staying orTHOGonal.
See the ‘crossToRef’ in lines 111/112 of #16 PG?
BABYLON.Vector3.CrossToRef(axis2, axis1, axis3); The ‘toRef’ part… is talking about the third parameter. The above directive means… calculate the Cross-product of axis2 and axis1, and store result in axis3. (in case you have low-experience in ‘toRef’ things).
There’s other goodies in that same PG series, too. #17 rocks, #18 rocks, #19 rocks, #20 is a failure by Wingnut to make the rabbit model… do the same as the monkey does in #16. Way to fail, Wingy!
Lots of .rotate() (pg#1) and mesh.rotationQuaternion (pg#16) stuff… which means that standard Euler-type mesh.rotation is not really used anymore. As you might know, if user wishes, or if BJS system NEEDS to use a Quaternion for mesh rotation, system or user installs a mesh.rotationQuaternion (esp needed for ‘p-mesh’… physics-active mesh). After installing it on a mesh, Euler .rotation property is essentially un-used, and system uses .rotationQuaternion instead (for THAT mesh’s rotation transforms).
Anyway… that’s something. A little intro to Dot and Cross and Quats… all in one gulp. And, that’s all the intelligence that I have… in this topic. I hope I was on-topic and understood the issue correctly. Stay tuned for more/wiser comments, as wanted.