Trouble using Rapier Physics engine in Playground

Hi, I’m toying around with adding Rapier and wanted to get a basic concept working in the playground first. I think I have a lot of my sizing and rotation code, etc, wrong but want to see it in action. Locally I had something working along these lines but in the playground I get errors in the console.

Rapier JS uses WASM so the import is kind of funky for playground use. I tried:
const RAPIER = await import('');

It seems to bring it in as a library but then I get:

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'rawintegrationparameters_new')

when I actually try to use the features. Anybody else get Rapier working in a playground I didn’t see? Or any ideas how to fix this one?

Generally the promise fulfilling takes some time during that time the value is undefined. Add a return condition for the undefined part and this error may go away.

Rapier is tricky even without Playground :slight_smile:
Could you share your working non-PG example somewhere?

1 Like

Here’s a way of loading it that you can play with (borrowed from the Yuka thread :wink:). I didn’t look at the physics simulation to try to see why the ball is hitting the ground early but it seems to be running without errors now at least. :slight_smile:

EDIT: Oops I was importing it in an overcomplicated way before, here’s the simpler way. :blush:


Ah Blake, you’re my hero, that’s very cool. Now I can figure out why the geometry didn’t translate correctly separately with a proper playground - but getting that far is a huge step forward! Thank you!

1 Like