File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 208208 clipShadows : true
209209 } ) ;
210210
211- object = new THREE . Group ( ) ;
212-
211+ const count = 5 * 5 * 5 ;
213212 const geometry = new THREE . BoxGeometry ( 0.18 , 0.18 , 0.18 ) ;
213+ object = new THREE . InstancedMesh ( geometry , clipMaterial , count ) ;
214+ object . castShadow = true ;
215+
216+ let i = 0 ;
217+ const matrix = new THREE . Matrix4 ( ) ;
214218
215219 for ( let z = - 2 ; z <= 2 ; ++ z )
216220 for ( let y = - 2 ; y <= 2 ; ++ y )
217221 for ( let x = - 2 ; x <= 2 ; ++ x ) {
218222
219- const mesh = new THREE . Mesh ( geometry , clipMaterial ) ;
220- mesh . position . set ( x / 5 , y / 5 , z / 5 ) ;
221- mesh . castShadow = true ;
222- object . add ( mesh ) ;
223+ matrix . setPosition ( x / 5 , y / 5 , z / 5 ) ;
224+ object . setMatrixAt ( i ++ , matrix ) ;
223225
224226 }
225227
You can’t perform that action at this time.
0 commit comments