Skip to content

Instantly share code, notes, and snippets.

@BABAK0T0
Created March 2, 2021 12:26
Show Gist options
  • Save BABAK0T0/0a073bad5746ca3f081cf0aa8f5d1d43 to your computer and use it in GitHub Desktop.
Save BABAK0T0/0a073bad5746ca3f081cf0aa8f5d1d43 to your computer and use it in GitHub Desktop.
const objs = new THREE.Group();
const minRadius = 3;
const maxRadius = 6;
for(let i = 0; i < 50; i++)
{
const angle = Math.random() * Math.PI * 2; // Random angle
const radius = minRadius + Math.random() * maxRadius; // Random radius between [3,9]
const x = Math.cos(angle) * radius; // Get the x position using cosinus
const z = Math.sin(angle) * radius; // Get the z position using sinus
// Create the mesh
const mesh = new THREE.Mesh(objGeometry, objMaterial);
// Position
mesh.position.set(x, 0, z);
// Add to the graves container
objs.add(mesh)
}
scene.add(objs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment