Game Development Reference
In-Depth Information
Objects'
visible
property is a Boolean controlling whether or not
they are rendered. In the WebGL renderer, setting this property
does not affect child objects, though it does affect child objects in
other renderers. This is important to know for multipart meshes,
which are often imported in a hierarchy. To set the visibility for
an object and all its children, you can use the
traverse
method,
which invokes a callback for each object in the hierarchy:
object.traverse(function(node) {
node.visible = false;
});
Particles and Sprites
CanvasRenderer
and
WebGLRenderer
use different objects to represent individual
particles. When using canvas, use
THREE.Particle
:
var material = new THREE.ParticleBasicMaterial({
color: 0x660000,
map: null, // or an image texture
});
var particle = new THREE.Particle(material);
As you can see, particles are basically just made up of a color or an image. Similarly,
when using WebGL, use
THREE.Sprite
:
var material = new THREE.SpriteMaterial({
color: 0x660000,
map: null, // or an image texture
opacity: 1.0,
blending: THREE.AdditiveBlending,
});
var sprite = new THREE.Sprite(material);