How to set values for BufferAttribute? Documentation examples produce TS errors

You now have to cast as THREE.BufferAttribute

E.g.,

// using array
const positions = (geometry.attributes.position as THREE.BufferAttribute).array

// using setXYZ
;(geometry.attributes.position as THREE.BufferAttribute).setXYZ(1, 2, 3, 4)

More Info : TS2339: Property 'array' does not exist on type 'BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute'. · Issue #389 · three-types/three-ts-types · GitHub

3 Likes