这个问题通常是由于修改了BufferGeometry后,需要手动更新它的attributes。以下是一个示例,说明如何在手动更改属性后更新BufferGeometry:
// 创建一个BufferGeometry
const geometry = new THREE.BufferGeometry();
// 添加一个属性
const positions = new Float32Array( [ 0, 0, 0, 1, 1, 1 ] );
geometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );
// 修改属性
positions[0] = 1;
positions[1] = 1;
positions[2] = 1;
// 手动更新BufferGeometry的attributes
geometry.attributes.position.needsUpdate = true;
在这个例子中,当我们手动更改了positions属性时,需要将needsUpdate设置为true,以确保BufferGeometry更新。