Graphics Reference
In-Depth Information
cube = new
THREE.CubeGeometry(4,6,4,20,20,20);
cube.vertices.forEach(function(v) {
v.velocity = Math.random();
});
createPointSystemFromGeometry(cube);
As you can see, we don't just create the geometry; we also add a velocity
parameter to each of the vertices, which we set to a random value. We do
this to make sure not all the points explode at the same speed (which would
have the same effect as just scaling the geometry).
2. Now, we can create the point cloud:
var psMat = new
THREE.PointCloudMaterial();
psMat.map =
THREE.ImageUtils.loadTexture("../assets/
textures/ps_ball.png");
psMat.blending = THREE.AdditiveBlending;
psMat.transparent = true;
psMat.opacity = 0.6;
var ps = new THREE.PointCloud(cube,
psMat);
ps.sortPoints = true;
scene.add(ps);
This is just a standard point cloud based on the geometry we created in step
1.
3. In the introduction to the recipe, we mentioned that we wanted to explode the
points based on their normal vector. So, before we start rendering the scene
and updating the position of the individual points, we first need to calculate
the normal of each vector:
var avgVertexNormals = [];
var avgVertexCount = [];
for (var i = 0 ; i <
Search WWH ::




Custom Search