Created
December 8, 2015 23:38
-
-
Save KhanMaytok/d76f58c55704b7ce6140 to your computer and use it in GitHub Desktop.
Create a sphere made of particles with Three.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var distance = 100; | |
var geometry = new THREE.Geometry(); | |
for (var i = 0; i < 1000; i++) { | |
var vertex = new THREE.Vector3(); | |
var theta = THREE.Math.randFloatSpread(360); | |
var phi = THREE.Math.randFloatSpread(360); | |
vertex.x = distance * Math.sin(theta) * Math.cos(phi); | |
vertex.y = distance * Math.sin(theta) * Math.sin(phi); | |
vertex.z = distance * Math.cos(theta); | |
geometry.vertices.push(vertex); | |
} | |
var particles = new THREE.PointCloud(geometry, new THREE.PointCloudMaterial({ | |
color: 0xffffff | |
})); | |
particles.boundingSphere = 50; | |
scene.add(particles); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment