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

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

##### 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`

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

##### Share on other sites

You can use mesh.getBoundingInfo().boundingBox.

Here are the properties of the bounding box:

http://doc.babylonjs.com/page.php?p=24939

##### Share on other sites

You can use mesh.getBoundingInfo().boundingBox.

Here are the properties of the bounding box:

http://doc.babylonjs.com/page.php?p=24939

Yes! That's it. Again, thank you so much.

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

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.