dimforge / rapier.js

Official JavaScript bindings for the Rapier physics engine.
https://rapier.rs
Apache License 2.0
397 stars 55 forks source link

ColliderDesc.convexMesh does not work #234

Open coolvision opened 1 year ago

coolvision commented 1 year ago

Creating a collirer with RAPIER.ColliderDesc.convexMesh does not work. Here is a simple test case:

    let geometry = new THREE.BoxGeometry(size, size, size);
    let mesh = new THREE.Mesh(geometry, new THREE.MeshLambertMaterial({color: color}));
    let collider_desc = RAPIER.ColliderDesc.convexMesh(mesh.geometry.attributes.position.array, mesh.geometry.index.array);

inputs should be correct, THREE.BoxGeometry is convex. But, this causes an error:

rapier3d-compat.js:38 Uncaught Error: expected instance of IA
    at a (rapier3d-compat.js:38:11)
    at l.createCollider (rapier3d-compat.js:467:7)
    at sI.createCollider (rapier3d-compat.js:3807:236)
    at eI.createCollider (rapier3d-compat.js:4099:27)
    at init (main.js:70:26)
    at async main.js:20:1

can be reproduced in sandbox: https://codesandbox.io/p/github/coolvision/rapier_js_examples/master?workspaceId=e7df68ff-e684-4891-81ac-cef3e7594869

frankieali commented 1 year ago

I ran into this problem as well. My data would work as a convexHull but not as a convexMesh. I was able to get convexMesh to work by excluding the indices argument and only providing the vertices

Update: I'm wondering if the underlying issue is with the indices ArrayBuffer data type.