better zoom management

This commit is contained in:
2025-11-10 08:01:56 +02:00
parent 22c27a7a9e
commit 03edeaef2d
4 changed files with 35 additions and 16 deletions
+15 -4
View File
@@ -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
}