Jump to content

Why Button3D Lacks Rotation?


mkadirtan
 Share

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...