Hi all,
This is probably a simple question, but here goes.
There are 2 example codes shown below. In the first example, the material successfully renders on my viewport if I use THREE.BoxGeometry. However, in the second example, the material does not render at all if I use THREE.BufferGeometry. Why is this so, and how should I resolve this?
Example Code 1:
let geom = new THREE.BoxGeometry(1, 1, 1);
let im = new THREE.InstancedMesh(
geom,
new THREE.MeshLambertMaterial(),
length
)
Example Code 2:
let geom = new THREE.BufferGeometry();
let vertices = new Float32Array( [
-0.5, -0.5, -0.5,
0.5, -0.5, -0.5,
0.5, 0.5, -0.5,
-0.5, 0.5, -0.5,
-0.5, -0.5, 0.5,
0.5, -0.5, 0.5,
0.5, 0.5, 0.5,
-0.5, 0.5, 0.5,
] );;
let indices = [0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4, 0, 4, 3, 3, 4, 7, 3, 7, 2, 2, 7, 6, 2, 1, 6, 6, 1, 5, 0, 1, 5, 0, 5, 4]
geom.setIndex( indices );
geom.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
let im = new THREE.InstancedMesh(
geom,
new THREE.MeshLambertMaterial(),
length
)
Thanks in advance.