Jump to content

Position a 3D object in relation to another with Babylon.js


DellaFree
 Share

Recommended Posts

Hi, I am a newbie, that recently I started studying Babylon.js . I would ask , though it may sound trite and silly , how to position an object in relation to another ? Let me explain: I created a cube and a pyramid , separated , and I view them in a canvas ; now I would like , through a function that will be called by a button , position the pyramid above the cube . I would understand, how to implement this function in order to position the pyramid above the cube , no matter where I place the cube ( the cube could move) . I repeat I'm a newbie and I have not even a starting point to show you an example . Any advice is welcome . Thank you again for your attention .

Link to comment
Share on other sites

Hello and welcome.. :)

 

I think you can do this:

pyramid.parent = cubepyramid.position = new BABYLON.Vector3(0, 1, 0);// AboveORpyramid.position = cube.position.add(new BABYLON.Vector3(0, 1, 0));// Above

Great :D it's what I'm looking for. Is there another way to get the cube's height, instead using the value 1 ? Thanks a lot.

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...