|
@@ -117,44 +117,32 @@ async function RapierPhysics() {
|
|
|
|
|
|
function setMeshPosition( mesh, position, index = 0 ) {
|
|
|
|
|
|
- if ( mesh.isInstancedMesh ) {
|
|
|
-
|
|
|
- const bodies = meshMap.get( mesh );
|
|
|
- const body = bodies[ index ];
|
|
|
-
|
|
|
- body.setAngvel( ZERO );
|
|
|
- body.setLinvel( ZERO );
|
|
|
- body.setTranslation( position );
|
|
|
+ let body = meshMap.get( mesh );
|
|
|
|
|
|
- } else if ( mesh.isMesh ) {
|
|
|
-
|
|
|
- const body = meshMap.get( mesh );
|
|
|
+ if ( mesh.isInstancedMesh ) {
|
|
|
|
|
|
- body.setAngvel( ZERO );
|
|
|
- body.setLinvel( ZERO );
|
|
|
- body.setTranslation( position );
|
|
|
+ body = body[ index ];
|
|
|
|
|
|
}
|
|
|
|
|
|
+ body.setAngvel( ZERO );
|
|
|
+ body.setLinvel( ZERO );
|
|
|
+ body.setTranslation( position );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function setMeshVelocity( mesh, velocity, index = 0 ) {
|
|
|
|
|
|
- if ( mesh.isInstancedMesh ) {
|
|
|
-
|
|
|
- const bodies = meshMap.get( mesh );
|
|
|
- const body = bodies[ index ];
|
|
|
-
|
|
|
- body.setLinvel( velocity );
|
|
|
+ let body = meshMap.get( mesh );
|
|
|
|
|
|
- } else if ( mesh.isMesh ) {
|
|
|
-
|
|
|
- const body = meshMap.get( mesh );
|
|
|
+ if ( mesh.isInstancedMesh ) {
|
|
|
|
|
|
- body.setLinvel( velocity );
|
|
|
+ body = body[ index ];
|
|
|
|
|
|
}
|
|
|
|
|
|
+ body.setLinvel( velocity );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//
|