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.

Revisions

  1. BABAK0T0 created this gist Mar 2, 2021.
    22 changes: 22 additions & 0 deletions Around.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    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)