How can I arrange objects in order in the scene?

I have to import boxes with differents size and arrange them in a quadrant so that the larger ones are on one corner and the smaller ones on the opposite corner.

to make myself more understandable, here is a picture of where I have arrived until now

what i need to do is to sort the boxes by angles and not by lines or rows

Any reference picture of the result?

So this question is not about three.js specifically, but about sorting in general.

well actually it could be, do you have an idea anyway?

Will it always have 3 β€œ0”, 3 β€œ1”, 4 β€œ2”, 5 β€œ3”, 4 β€œ4”, 3 β€œ5” and 3 β€œ6” ?

thanks for the answers, by the way,

it was just an example the boxes are created randomly, for example with a height value from 0 to 20. I should find a way to always allocate them in the right position. From the largest to the smallest, or vice versa, in order not by lines or rows on the dial, but more by radians.

So, basically, you want it in this order?
ΠΈΠ·ΠΎΠ±Ρ€Π°ΠΆΠ΅Π½ΠΈΠ΅

1 Like

YES! exactly like this

/cc

First, put bars in an array and sort it by heights of bars.
Second, find an algorithm that puts elements of an array in the desired order.

Well, with help of .sort() of array and this SO answer: https://stackoverflow.com/q/35373936/4045502
I’ve turned this

into this

Link: https://jsfiddle.net/prisoner849/vpdkL0zt/

3 Likes

Wow! that’s exactly what I meant.

thanks a lot

You’re welcome :beers:
I’ve added a link in my previous post :wink:

1 Like