# Trouble using Rapier Physics engine in Playground

**URL:** <https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322>\
**Category:** Questions\
**Tags:** playground, physics\
**Created:** [July 19, 2022, 11:28pm UTC](https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322 "2022-07-19T23:28:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tinman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tinman/32/2273_2.png) [@tinman](https://forum.babylonjs.com/u/tinman)\
**Post date:** [July 19, 2022, 11:28pm UTC](https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322/1 "2022-07-19T23:28:21Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#L5K58E%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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('https://cdn.skypack.dev/@dimforge/rapier3d-compat');`

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

```auto
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? [https://playground.babylonjs.com/#L5K58E#1](https://playground.babylonjs.com/#L5K58E#1)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [July 20, 2022, 12:08am UTC](https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322/2 "2022-07-20T00:08:04Z")

</div>

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 🙂  
Could you share your working non-PG example somewhere?

---

<div class="post-metadata">

**Author:** ![Blake](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/blake/32/21509_2.png) [@Blake](https://forum.babylonjs.com/u/Blake)\
**Post date:** [July 20, 2022, 12:47am UTC](https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322/3 "2022-07-20T00:47:46Z")

</div>

Here’s a way of loading it that you can play with (borrowed from the [Yuka thread](https://forum.babylonjs.com/t/yuka-game-ai-library-with-babylon-js/26902/13) 😉). 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. 🙂

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

> **[Babylon.js Playground](https://playground.babylonjs.com/#JL3MT8%231)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![tinman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tinman/32/2273_2.png) [@tinman](https://forum.babylonjs.com/u/tinman)\
**Post date:** [July 20, 2022, 1:49am UTC](https://forum.babylonjs.com/t/trouble-using-rapier-physics-engine-in-playground/32322/4 "2022-07-20T01:49:09Z")

</div>

> [@Blake](#):
>
> [Babylon.js Playground](https://playground.babylonjs.com/#JL3MT8)

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!
