Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Unreachable error when creating impulse joint #308

Open
fdb opened this issue Feb 19, 2025 · 0 comments
Open

Unreachable error when creating impulse joint #308

fdb opened this issue Feb 19, 2025 · 0 comments

Comments

@fdb
Copy link

fdb commented Feb 19, 2025

I have some very basic code for simulating two bodies connected with a (fixed) joint. However, this code fails in the latest release of rapier.js (0.14.0). It also fails in older releases.

<!DOCTYPE html>
<html>
  <head>
    <title>Testbed</title>
  </head>
  <body>
    <script type="module">
      import RAPIER from "https://esm.sh/@dimforge/rapier3d-compat@0.14.0";

      let rapier, world;

      RAPIER.init().then(() => {
        rapier = RAPIER;
        initSimulation();
      });

      function initSimulation() {
        world = new rapier.World({ x: 0.0, y: -9.81, z: 0.0 });

        const bodyDesc1 = rapier.RigidBodyDesc.dynamic()
          .setTranslation(0, 0, 0)
          .setRotation({ x: 0, y: 0, z: 0, w: 1.0 });
        const body1 = world.createRigidBody(bodyDesc1);
        const bodyDesc2 = rapier.RigidBodyDesc.dynamic()
          .setTranslation(1, 0, 0)
          .setRotation({ x: 0, y: 0, z: 0, w: 1.0 });
        const body2 = world.createRigidBody(bodyDesc2);

        const jointDesc = rapier.JointData.fixed(
          { x: 0, y: 0, z: 0 }, // parent anchor
          { x: 0.0, y: 0.0, z: 0.0, w: 1.0 }, // parent orientation
          { x: 0, y: 0, z: 0 }, // child anchor
          { x: 1.0, y: 0.0, z: 0.0, w: 1.0 } // child orientation
        );
        const joint = world.createImpulseJoint(jointDesc, body1.handle, body2.handle, true);

        animate();
      }

      function animate() {
        world.step();
        requestAnimationFrame(animate);
      }
    </script>
  </body>
</html>

Running this code in a browser (Chrome 133 on macOS 15.3.1) results in an "unreachable" exception deep in the WASM code:

0057e15e:0x1185c8 Uncaught (in promise) RuntimeError: unreachable
    at 0057e15e:0x1185c8
    at 0057e15e:0x148e24
    at 0057e15e:0x146ca9
    at 0057e15e:0x14abf1
    at 0057e15e:0x2f03e
    at 0057e15e:0xf96a9
    at Qg.step (rapier_wasm3d.js:3548:14)
    at eI.step (physics_pipeline.ts:69:22)
    at Q.step (world.ts:258:30)
    at animate (test.html:41:15)

This also fails with other types of joints, e.g. revolute joint:

const jointDesc = rapier.JointData.revolute(
  { x: 0, y: 0, z: 0 }, // parent anchor
  { x: 0, y: 0, z: 0 }, // child anchor
  { x: 1.0, y: 0.0, z: 0.0 } // axis
);
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant