I have this code that generates some clouds in random position, rotation and random scale. Since they can be generated next to another, or next to another mesh, they can clip together. I want to set a minimum distance, like if(cloud position x and z is < 10 FROM ANOTHER CLOUD) then set distance how can I do? Here's the code:
for(let i = 0; i < 10; i+= 1){
loader.load('/clouds/clouds2/scene.gltf', function (clouds2) {
const cloud = clouds2.scene
const child1 = cloud.children[0].children[0].children[0].children[2].children[0]
const child2 = cloud.children[0].children[0].children[0].children[3].children[0]
const child3 = cloud.children[0].children[0].children[0].children[4].children[0]
child1.material = new THREE.MeshStandardMaterial({ emissive: 'white', emissiveIntensity: 0.3})
child2.material = new THREE.MeshStandardMaterial({ emissive: 'white', emissiveIntensity: 0.3})
child3.material = new THREE.MeshStandardMaterial({ emissive: 'white', emissiveIntensity: 0.3})
cloud.scale.x = (Math.random() * (0.06 - 0.04 ) + 0.04)
cloud.scale.y = (Math.random() * (0.06 - 0.04 ) + 0.04)
cloud.scale.z = (Math.random() * (0.06 - 0.04 ) + 0.04)
cloud.position.x = (Math.random() - 0.5) * 500
cloud.position.y = (Math.random() + 80)
cloud.position.z = (Math.random() - 1) * 500
cloud.rotation.x = Math.random()
cloud.rotation.y = Math.random()
cloud.rotation.z = Math.random()
scene.add(cloud)
})
}