Is it possible to instance a prebuilt object (e.g. BoxBufferGeometry) with RawShaderMaterial
? The instancing examples in Three.js work with MeshBasicMaterial though. I am assuming that setMatrixAt()
needs to be applied differently. Is that right?
const geometry = new THREE.SphereBufferGeometry(4, 32, 32)
const materialBasic = new THREE.MeshBasicMaterial({ color: 'red' })
const material = new THREE.RawShaderMaterial({
uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader,
})
const mesh1 = new THREE.InstancedMesh(geometry, materialBasic, size);
const mesh2 = new THREE.InstancedMesh(geometry, material, size);
for (let i = 0; i < 10; i++) {
const matrix = new THREE.Matrix4();
matrix.setPosition(i * 10, 0, 0);
mesh1.setMatrixAt(i, matrix);
//I don't see instances of mesh2 except for original one
mesh2.setMatrixAt(i, matrix);
}