File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,26 @@ function getShape( geometry ) {
2828 const radius = parameters . radius !== undefined ? parameters . radius : 1 ;
2929 return RAPIER . ColliderDesc . ball ( radius ) ;
3030
31+ } else if ( geometry . type === 'BufferGeometry' ) {
32+
33+ const vertices = [ ] ;
34+ const vertex = new Vector3 ( ) ;
35+ const position = geometry . getAttribute ( 'position' ) ;
36+
37+ for ( let i = 0 ; i < position . count ; i ++ ) {
38+
39+ vertex . fromBufferAttribute ( position , i ) ;
40+ vertices . push ( vertex . x , vertex . y , vertex . z ) ;
41+
42+ }
43+
44+ // if the buffer is non-indexed, generate an index buffer
45+ const indices = geometry . getIndex ( ) === null
46+ ? Uint32Array . from ( Array ( parseInt ( vertices . length / 3 ) ) . keys ( ) )
47+ : geometry . getIndex ( ) . array ;
48+
49+ return RAPIER . ColliderDesc . trimesh ( vertices , indices ) ;
50+
3151 }
3252
3353 return null ;
You can’t perform that action at this time.
0 commit comments