Nodragem Posted November 11, 2018 Share Posted November 11, 2018 Hello, I attached my player and the camera to the same TransformNode to move and rotate them around together. Because of that, the rotation of the camera is always zeros (or whatever I made it) in local coordinates. I was a bit surprise to find out that I could not get the rotation in world coordinates as I would with globalPosition. I thought I may have missed something but @Deltakosh confirmed that globalRotation or globalRotationQuaternion don't exit, he suggested me to use https://doc.babylonjs.com/api/classes/babylon.matrix#decompose instead for the time being. I believe that this is not user friendly and should only be a temporary/hacky solution for my project. Hence my feature is to add a globalRotation and globalRotationQuaternion to meshes and compatible Nodes. Feature Request add globalRotation and globalRotationQuaternion properties to meshes and compatible Nodes. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 12, 2018 Share Posted November 12, 2018 Thank you for this thread:) So here is why I think we should not do it: whereas globalPosition is easy to compute (last line of the worldMatrix), globalRotation and globalScaling would require a really expensive operation (matrix.decompose). I think that the engine should be a guide to make sure games and applications built with it perform well in every situation. Here, if we expose these two properties there is no way we can let people know that they could be expensive and they should be used cautiously. This is why I recommend not adding them and instead add a word about how to compute them in the doc. Quote Link to comment Share on other sites More sharing options...
Nodragem Posted November 15, 2018 Author Share Posted November 15, 2018 sounds reasonable... but I am not sure why globalRotation has to be an expensive computation, it looks to me that the global Rotation is just something like that: // start with a null rotation: globalRotationQuaternion = BABYLON.Quaternion.Identity() // applying the rotation of all the parents of the mesh: for parent in mesh.parents: globalRotationQuaternion *= parent.rotationQuaternion // then apply the local rotation of the mesh: globalRotationQuaternion *= mesh.rotationQuaternion I mean I am not sure how Quaternions work, so I might be wrong to start with the identity. The idea is that global Rotation is simply the application of all the rotations of the parents + your own rotation. I guess that might be what's decompose() is doing? On 11/12/2018 at 12:11 AM, Deltakosh said: I think that the engine should be a guide to make sure games and applications built with it perform well in every situation. Here, if we expose these two properties there is no way we can let people know that they could be expensive and they should be used cautiously. In the API doc, which pop-ups in VS code when you call a function, you can add a warning: this is an expensive operation; use it with moderation. Quote Link to comment Share on other sites More sharing options...
bghgary Posted November 15, 2018 Share Posted November 15, 2018 If scaling and position of each level of the hierarchy are identity, then this solution would work, but if not, then this solution will compute the wrong result since scaling affects position and position affects the rotation. Quote Link to comment Share on other sites More sharing options...
Guest Posted November 15, 2018 Share Posted November 15, 2018 also you must have scaling AND translation set to identity because each rotation is done around parent pivot point. So this is not applicable unfortunately Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.