better zoom management
This commit is contained in:
+15
-4
@@ -1,4 +1,5 @@
|
||||
import * as RAPIER from '@dimforge/rapier3d'
|
||||
import { Vector3 } from 'three';
|
||||
class Physics{
|
||||
constructor(engine){
|
||||
this.engine = engine
|
||||
@@ -51,10 +52,20 @@ class Physics{
|
||||
break
|
||||
|
||||
default:{
|
||||
colliderDesc = RAPIER.ColliderDesc.trimesh(
|
||||
mesh.geometry.attributes.position.array,
|
||||
mesh.geometry.index?.array
|
||||
)
|
||||
const vertices = [];
|
||||
const vertex = new Vector3();
|
||||
const position = mesh.geometry.getAttribute( 'position' );
|
||||
for ( let i = 0; i < position.count; i ++ ) {
|
||||
vertex.fromBufferAttribute( position, i );
|
||||
vertices.push( vertex.x, vertex.y, vertex.z );
|
||||
}
|
||||
|
||||
// if the buffer is non-indexed, generate an index buffer
|
||||
const indices = mesh.geometry.getIndex() === null
|
||||
? Uint32Array.from( Array( parseInt( vertices.length / 3 ) ).keys() )
|
||||
: mesh.geometry.getIndex().array;
|
||||
|
||||
colliderDesc = RAPIER.ColliderDesc.trimesh( vertices, indices );
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user