<p>PhysX is a C++ API and can thus not directly be integrated with the JavaScript-based WebGL.</p>

<p>Depending on your needs, you have the following options:</p>

<ul>
<li>Use a JavaScript-based physics engine, mostly suitable for 2D use cases.</li>
<li>Use a Game Engine that can export for the web (e.g. Unity 3D) and build your application in there, using full 3D physics capability. Keep in mind that this will probably require your users to install some additional Web Player and is not native WebGL.</li>
</ul>

<p>Keep in mind that Game Engines may be a viable way for 2D applications too and can make your life a whole lot easier.</p>

CC BY-SA 3.0
2016-08-26T14:34:29.973Z
Unity can export to WebGL.
SurvivalMachine
CC BY-SA 3.0
2016-08-28T00:53:17.450Z
Why are JavaScript-based physics engines "mostly suitable for 2D use cases"? Also you said "Keep in mind that Game Engines may be a viable way for 2D applications too and can make your life a whole lot easier", which is why I'm making http://github.com/infamous/infamous (renaming it soon and adding docs/demos). It's a 3D API that currently renders to DOM (CSS3D with my DOMMatrix polyfill), and I'd like to add WebGL soon. Here's a couple small demos: http://trusktr.io (hover on the left edge for the 3D menu) and http://mightydevs.com (letters moving into formation, needs word wrapping).
trusktr
CC BY-SA 3.0
2016-08-28T15:47:28.807Z
@trusktr Because, or at least that's what I thought, there is no JS 3D physics engine that comes close to PhysX in terms of features. Then again I just found out that someone [ported Bullet to JS](https://github.com/kripken/ammo.js). YMMV.
David Kuri
CC BY-SA 3.0
2016-08-26T08:28:27.930Z
2016-08-26T08:28:27.930Z
David Kuri
<p>I'm new to GL stuff (coming in via WebGL, with no direct OpenGL experience). Can we use PhysX with WebGL?</p>

<webgl><physics><javascript>
Can we use PhysX in WebGL?
trusktr
# Can we use PhysX in WebGL?

(Asked by: username_0 on 2016-08-26)

I'm new to GL stuff (coming in via WebGL, with no direct OpenGL experience). Can we use PhysX with WebGL?

**Tags:** webgl, physics, javascript


---

## 1 answers

### Answer by username_1 on 2016-08-26. Score: 5 | Accepted answer

PhysX is a C++ API and can thus not directly be integrated with the JavaScript-based WebGL.

Depending on your needs, you have the following options:

* Use a JavaScript-based physics engine, mostly suitable for 2D use cases.
* Use a Game Engine that can export for the web (e.g. Unity 3D) and build your application in there, using full 3D physics capability. Keep in mind that this will probably require your users to install some additional Web Player and is not native WebGL.

Keep in mind that Game Engines may be a viable way for 2D applications too and can make your life a whole lot easier.

> **Comments:**
> **username_2**: Unity can export to WebGL.  
> **username_0**: Why are JavaScript-based physics engines "mostly suitable for 2D use cases"? Also you said "Keep in mind that Game Engines may be a viable way for 2D applications too and can make your life a whole lot easier", which is why I'm making http://github.com/infamous/infamous (renaming it soon and adding docs/demos). It's a 3D API that currently renders to DOM (CSS3D with my DOMMatrix polyfill), and I'd like to add WebGL soon. Here's a couple small demos: http://username_0.io (hover on the left edge for the 3D menu) and http://mightydevs.com (letters moving into formation, needs word wrapping).  
> **username_1**: @username_0 Because, or at least that's what I thought, there is no JS 3D physics engine that comes close to PhysX in terms of features. Then again I just found out that someone [ported Bullet to JS](https://github.com/kripken/ammo.js). YMMV.  

---

