DellaFree Posted May 28, 2015 Share Posted May 28, 2015 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 . Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 28, 2015 Share Posted May 28, 2015 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 DellaFree 1 Quote Link to comment Share on other sites More sharing options...
DellaFree Posted May 28, 2015 Author Share Posted May 28, 2015 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));// AboveGreat 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted May 29, 2015 Share Posted May 29, 2015 You can use mesh.getBoundingInfo().boundingBox. Here are the properties of the bounding box:http://doc.babylonjs.com/page.php?p=24939 Quote Link to comment Share on other sites More sharing options...
DellaFree Posted May 31, 2015 Author Share Posted May 31, 2015 You can use mesh.getBoundingInfo().boundingBox. Here are the properties of the bounding box:http://doc.babylonjs.com/page.php?p=24939Yes! That's it. Again, thank you so much. 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.