Graphics Reference
In-Depth Information
Informing Three.js about updates
If you've worked a bit longer with Three.js, you'll probably have noticed that some-
times, it seems that changes you make to a certain geometry doesn't always result in
a change onscreen. This is because for performance reasons, Three.js caches some
objects (such as the vertices and faces of a geometry) and doesn't automatically de-
tect updates. For these kinds of changes, you'll have to explicitly inform Three.js that
something has changed. In this recipe, we'll show you what properties of a geometry
are cached and require explicit notification to Three.js to be updated. These proper-
ties are:
•
geometry.vertices
•
geometry.faces
•
geometry.morphTargets
•
geometry.faceVertexUvs
•
geometry.faces[i].normal
and
geometry.vertices[i].normal
•
geometry.faces[i].color
and
geometry.vertices[i].color
•
geometry.vertices[i].tangent
•
geometry.lineDistances
Getting ready
An example is available that allows you to change two properties that require an ex-
plicit update: face colors and vertex positions. If you open up the
02.04-update-
stuff.html
example in your browser, you'll see something similar to the following
screenshot: