How to quickly update a large BufferGeometry?

后端 未结 2 959
-上瘾入骨i
-上瘾入骨i 2020-12-05 05:55

I\'m using a BufferGeometry to draw thousands of cubes which makes up the terrain, but having a hard time finding out how to update the geometry if I need to change the posi

2条回答
  •  有刺的猬
    2020-12-05 06:48

    As of r71 threejs supports bufferSubData.

    Use a DynamicBufferAttribute, (or just set updateRange correctly)

    var positionAttr = geometry.attributes.position 
    // if not using DynamicBufferAttribute initialize updateRange:
    // positionAttr.updateRange = {};
    positionAttr.updateRange.offset = 0; // where to start updating
    positionAttr.updateRange.count = 1; // how many vertices to update
    positionAttr.needsUpdate = true;
    

提交回复
热议问题