I'm trying to upgrade the release version of ThreeJS in my app. I'm showing some meshes on a 3D scene and allow the user to set their colour mappings. Meshes can be coloured in two ways, by vertices or by faces.
When creating the material of the mesh, I set up the vertexColors attribute to THREE.VertexColors or THREE.FaceColors, depending on the behaviour I want.
On rev71, I implemented the change of the colour like this :
var geometry = mesh.geometry;
/* For each face, change it's face colour or vertex colour */
for(var i = 0; i < geometry.faces.length; i++) {
if (colourFace) {
geometry.faces[i].color = myColorFace;
} else {
geometry.faces[i].vertexColors =
[myColorVert1, myColorVert2, myColorVert3];
}
}
Everytime I change the current mapping of the mesh, it is updated on the scene.
On rev73, ThreeJS seems to only update the first mapping change (just before the Mesh and it's Geometry have been pushed to the GPU). The only clue I got is these lines on WebGLGeometries :
/* ... */
} else if ( geometry instanceof THREE.Geometry ) {
if ( geometry._bufferGeometry === undefined ) {
geometry._bufferGeometry =
new THREE.BufferGeometry().setFromObject( object );
}
buffergeometry = geometry._bufferGeometry;
}
/* ... */
The buffergeometry attribute is then used by the WebGLRenderer to update WebGL array buffers (in my case, the color buffer). It seems that when updating the geometry from the mesh, it is never updated for the WebGLGeometry.
Does someone have a solution or should I post an issue or pull request to solve the problem?
=
usecopy()
orset()
. – WestLangleyneedsUpdate
flags? Otherwise, provide a simple working example of your issue by editing this fiddle. Code fragments are not sufficient. – WestLangley