Majeed Siddiqui Posted August 17, 2016 Share Posted August 17, 2016 I have few small boxes which I want to fit in big box. e.g I have 4x3, 4x4, 4x8 small boxes. And one big box of 4x(3 + 4 + 8 = 15) => 4x15. I want all these small boxes to be aligned in one line. Which are covered by big box. This big box is not visible at very close distance from camera only small boxes are. But it hides all the small and displays it self only at large distance from camera. How do I achieve this? Edit 1: I have drag and drop functionality thanks to @Wingnut, so doing drag and drop on big box should affect small boxes. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted August 17, 2016 Share Posted August 17, 2016 Hi @Majeed Siddiqui I made a simple PG with a custom create box function for you to start experimenting, you can create a new box by typing; var box1 = newBox(sizeX, sizeY, sizeZ, scene); check it out, and play around with it, if you need further help, don't hesitate to ask everything needed to know, should be commented in the code. http://www.babylonjs-playground.com/#1KH9RY#2 Majeed Siddiqui 1 Quote Link to comment Share on other sites More sharing options...
Majeed Siddiqui Posted August 17, 2016 Author Share Posted August 17, 2016 Thanks @aWeirdo! I know how to create basic boxes. How do I club all small boxes into big one? Solution I tried: Creating small boxes and setting their parent as big box. This fails miserably! The big box acts as pivot instead of covering these small boxes. I know I can achieve the view of mesh through LOD. I want a simpler mechanism. Like big box acting as container for small boxes. Quote Link to comment Share on other sites More sharing options...
aWeirdo Posted August 17, 2016 Share Posted August 17, 2016 Hi again @Majeed Siddiqui Take a look at what i did here: http://www.babylonjs-playground.com/#1KH9RY#3 depending on where i want the box, I offset the little box by half it's own scaling(size) either minus or plus, aswell as the bigBox position, and then half the bigbox's scaling(size), again, either plus or minus depending on where i want the box Note that using scaling as a mesh's size only works "out of the box" when the mesh is created with a size of 1 and then scaled to the wanted size. Majeed Siddiqui and Wingnut 2 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 17, 2016 Share Posted August 17, 2016 Hi guys. There's also a different kind of container... for boxes. Physics-active. http://www.babylonjs-playground.com/#14ADCQ#2 Probably not on-topic, but what the heck. jerome and Majeed Siddiqui 2 Quote Link to comment Share on other sites More sharing options...
JohnK Posted August 18, 2016 Share Posted August 18, 2016 (edited) Hi @Majeed Siddiqui et al. First of all if you want to create boxes of specific sizes use MeshBuilder, then there is no problem with scaling affecting children. Also 4 x 3 is the dimensions of a rectangle not a box, so what is the other dimension? This PG may not be exactly what you want but it shows how MeshBuilder can be used to align boxes in a box. http://www.babylonjs-playground.com/#1KH9RY#5 Edited August 19, 2016 by JohnK missing link added Majeed Siddiqui 1 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.