Graphics Reference
In-Depth Information
6. Next, you can define individual colors on the vertices or the faces. You do this
by setting these color properties: geometry.faces[i].color and geo-
metry.vertices[i].color . Once you've made changes to these prop-
erties, you have to set geometry.colorsNeedUpdate to true .
7. As a final step, you can choose to change textures and materials during
runtime. When you want to change one of these properties of a material,
you need to set material.needsUpdate to true : texture, fog, vertex col-
ors, skinning, morphing, shadow map, alpha test, uniforms, and lights. If
you want to update the data behind a texture, you need to set the tex-
ture.needsUpdate flag to true .
How it works...
As a summary, steps 1 to 7 apply to geometries and any resulting Three.js objects
that are based on geometries.
To get the most performance out of your 3D scene, Three.js caches certain proper-
ties and values that usually don't change. Especially when working with the WebGL
renderer, a lot of performance is gained by caching all these values. When you set
one of these flags to true, Three.js knows, very specifically, which part it needs to
update.
See also
• There are recipes within this topic that are similar to this. If you look at the
source code for the Applying matrix transformations recipe, you can see that
we've used the verticesNeedUpdate property after we applied some mat-
rix transformations to the geometry.
Search WWH ::




Custom Search