Graphics Reference
In-Depth Information
var geometry = new THREE.Geometry();
for (var i = 0 ; i < x ; i++) {
for (var j = 0 ; j < y ; j++) {
var v = new THREE.Vector3();
v.x = i / 10;
v.y = Math.sin(i/100 * Math.PI*2) +
Math.cos(j/100 * Math.PI) * 2;
v.z = j / 10;
geometry.vertices.push(v);
}
}
As you can see from this code snippet, you first need to instantiate
THREE.Geometry
and then create
THREE.Vector3
instances and push
them to the vertices property of geometry.
2. Now
that
we've
got
a
geometry,
we
just
need
THREE.PointCloudMaterial
:
var pcMat = new
THREE.PointCloudMaterial(geometry);
pcMat.map =
THREE.ImageUtils.loadTexture ("../assets/
textures/ps_smoke.png");
pcMat.color = new THREE.Color(0x55ff55);
pcMat.transparent = true;
pcMat.size = 0.2;
pcMat.blending = THREE.AdditiveBlending;
3. Use this material together with the geometry to create
THREE.PointCloud
and add it to the scene:
pc = new THREE.PointCloud(geometry,
pcMat);
pc.sizeAttenuation = true;
pc.sortPoints = true;
scene.add(pc);