mkadirtan Posted November 24, 2018 Share Posted November 24, 2018 Hey everyone! In my project I need to create a Button3D and then rotate it around. However, there is no rotation property or rotate method for Button3D and some other GUI3D elements, too. I didn't provide pg for this but I think my point is clear. If this is the way it needs to be, I should better use MeshButton3D or ActionManager on a mesh I think? Much thanks in advance! Quote Link to comment Share on other sites More sharing options...
ssaket Posted November 24, 2018 Share Posted November 24, 2018 Hi, You can use TransformNode to achieve this, posting one of my previous threads - Quote Link to comment Share on other sites More sharing options...
brianzinn Posted November 24, 2018 Share Posted November 24, 2018 4 hours ago, mkadirtan said: However, there is no rotation property or rotate method for Button3D and some other GUI3D elements, too. You may not be interested in the implementation details, but I'm going to show you why they don't have a rotation property and how to get around that. That's because the 3D controls only have position, which delegates to the 'node' member variable: https://github.com/BabylonJS/Babylon.js/blob/master/gui/src/3D/controls/control3D.ts#L32 You can use linkToTransformNode() as ssaket explains. Here is the code for linking, as you can see it just adds a parent (which is best for positioning multiple controls in 3D together): https://github.com/BabylonJS/Babylon.js/blob/master/gui/src/3D/controls/control3D.ts#L239 You can directly rotate 3D controls by accessing their 'node' property!! 'node' is only available after they are added to manager. Here I am rotating the button 45 degrees. https://www.babylonjs-playground.com/#2YZFA0#11 Quote Link to comment Share on other sites More sharing options...
mkadirtan Posted November 24, 2018 Author Share Posted November 24, 2018 Ahh, thanks a lot! I've tried linking to a node but didn't see anything happening because I was adding my button to manager in a later point. Have a nice day! 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.