I am attempting to separate all the meshes that make up the loaded obj file from each other in order for the user to easily view each mesh individually.
I am striving to replicate a similar functionality as shown in this example:
Demo
To achieve this effect, please visit the link and click on the explode icon in the UI tray, then adjust the slider accordingly.
Progress So Far: I have successfully accessed all the meshes within the model and can apply functions to them. Currently, I have looped through the meshes and assigned them random position vectors.
This method works well in separating the model into distinct mesh components.
The Issue:
While assigning random position vectors does separate the meshes, they are placed in arbitrary locations. I am looking to mimic the behavior seen in the shared link. Any assistance or guidance would be greatly appreciated. As a newcomer to threejs, I am eager to expand my knowledge. Thank you in advance.
Edit: Sample Code
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
for(var i = 0; i < mainStand.children.length; i++)
{
pos1 = getRandomArbitrary(1 , 2);
pos2 = getRandomArbitrary(1 , 2);
pos3 = getRandomArbitrary(1 , 2);
mainStand.children[i].position.set(pos1 , pos2 , pos3);
}
Here, mainStand
represents the loaded obj Model