# Adding Collisions to Imported GLB File

**URL:** <https://forum.babylonjs.com/t/adding-collisions-to-imported-glb-file/24198>\
**Category:** Questions\
**Tags:** coding\
**Created:** [September 30, 2021, 1:59am UTC](https://forum.babylonjs.com/t/adding-collisions-to-imported-glb-file/24198 "2021-09-30T01:59:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yungtechboy1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yungtechboy1/32/18769_2.png) [@yungtechboy1](https://forum.babylonjs.com/u/yungtechboy1)\
**Post date:** [September 30, 2021, 1:59am UTC](https://forum.babylonjs.com/t/adding-collisions-to-imported-glb-file/24198/1 "2021-09-30T01:59:17Z")

</div>

Hi all,

I have been looking all over the forums for a week now looking for a good way to add collisions to wall that my camera and player object can collide against… If the camera clips, I can live with it…

I found this demo which is way bigger than the GLB room I am trying to import, but is a perfect example of what I need. I see this demo is using a XRHelper? is that it?  
[https://www.babylonjs.com/demos/glowingespilit/](https://www.babylonjs.com/demos/glowingespilit/)

Currently I am able to move the camera or player with WASD/Arrow keys, but currently they player just clips through the wall. Which I can not have… I have enabled collisions on my Wall mesh objects but they work more as a trap than a wall or barrier. I can keep going forward to the point where the player mesh’s center is now in the middle of the wall. Ive tried loading a Physics engine but Im currently using Angular and typescript definitions and compatibilities are a nightmare… I’ve seen a few posts explaining it but I still rather not add the physics engine right now.

Ive tried flipping the overrideMaterialSideOrientation from Front to Back and even both… I even cloned all my wall meshes and then had 1/2 with Front and the other 1/2 Backwards.

Is there any way to have collision meshes pre-baked into a GLB file? Or any suggestions on how to make the walls work? Also is that demo code public? I found a JS file using inspect element but it didnt have any guts (real code) :L

I will try and create a playground example to show my issues and progress… I feel like I’m so close… I figured out importing animations and I though collisons was gonna be easy ☹

Thanks,  
YungTech

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [September 30, 2021, 10:09am UTC](https://forum.babylonjs.com/t/adding-collisions-to-imported-glb-file/24198/2 "2021-09-30T10:09:39Z")

</div>

There is no automatic way to create phyics from gltf. there is no info in the gltf for this.  
There are some threads like this:

> [@glTF & Basic Physics](https://forum.babylonjs.com/t/gltf-basic-physics/20849):
>
> I’ve created a very basic model in Blender 2.92. It contains the basic types of meshes (Cone, Cube, Cylinder, Icosphere, Plane, Sphere & Torus). Each mesh also has its own ‘Collider’ mesh, which is either a Cube, Cylinder or Sphere. Having exported & loaded ‘test.gltf’ into a Babylon.js scene, I’m using the Ammo.js plugin to drop spheres onto each mesh in the model. ‘ballOnCone’ is dropped onto the Cone mesh & so on. I’m trying to follow the steps describ…

as well as a playground:

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

---

<div class="post-metadata">

**Author:** ![yungtechboy1](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/yungtechboy1/32/18769_2.png) [@yungtechboy1](https://forum.babylonjs.com/u/yungtechboy1)\
**Post date:** [October 2, 2021, 3:06am UTC](https://forum.babylonjs.com/t/adding-collisions-to-imported-glb-file/24198/3 "2021-10-02T03:06:16Z")

</div>

After some playing around… I was able to import Ammo.JS without getting a Webpack error… I will release a template of a Babylon NG project with AmmoJS Physics

I install Webpack 5.56.0 and then ran npm i --package-lock-only.

5.50.0 also works
