I have a massive buffer geometry consisting of approximately 4 million vertices that requires a small area of shading to be updated. Currently, I randomly update the vertex normals causing lag. I attempted using updateRange.offset on the geometry but it seems this does not affect the vertexNormals() function (How to quickly update a large BufferGeometry?).
Here is my loop 1,000 times:
GRID.geometry.attributes.position.array[ (array_position + 2) ] = _position[2] - WEBGLzTranslate;
GRID.geometry.attributes.color.array[ (array_position) + 0 ] = color.r;
GRID.geometry.attributes.color.array[ (array_position) + 1 ] = color.g;
GRID.geometry.attributes.color.array[ (array_position) + 2 ] = color.b;
Then set update:
if(minArrayPosition < Infinity){
GRID.geometry.attributes.position.updateRange = {};
GRID.geometry.attributes.position.offset = minArrayPosition;
GRID.geometry.attributes.position.count = maxArrayPosition - minArrayPosition;
GRID.geometry.attributes.position.needsUpdate = true;
GRID.geometry.verticesNeedUpdate = true;
}
GRID.geometry.attributes.color.needsUpdate = true;
GRID.material.needsUpdate = true;
if(Math.random() > .99)
{
GRID.geometry.computeFaceNormals();
GRID.geometry.computeVertexNormals();
console.log('Updating Shading');
}
My preference would be for the range to work with the vertexNormals, potentially somewhere in the code snippet below (BufferGeometry.js:657):
Implementation details...
Should I consider exploring morphing materials as an alternative solution? Thank you.