I am attempting to generate a point cloud using threejs with the following code:
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 );
However, I encounter an error (at the line noted above):
TypeError: THREE.BufferAttribute: array should be a Typed Array.
Since 'vertices' is initialized, I assumed it was typed, right?