I am trying to create a point cloud in threejs as:
const pcGeom = new THREE.BufferGeometry();
const rows = 100;
const columns = 3;
const vertices = [...Array(rows)].map(() => [...Array(columns)].fill(0));
for(let i = 0; i < rows; i++) {
for (let j = 0; j < columns; j++) {
vertices[i][j] = Math.random() * (2 - 0) + 0;
}
}
pcGeom.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) ); // error at this line
const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
const pointCloud = new THREE.Mesh( geometry, material );
But this gives error(at line annotated above):
TypeError: THREE.BufferAttribute: array should be a Typed Array.
‘vertices’ is initialized, so I guess it’s typed, isn’t?