New Physics Engine Progress

Recommended Posts


Few news about energyJS, It's still in dev. Here is a quick very alpha  preview with examples. This is not a bjs plugin version. @RaananW worked one year ago on the plugin. We need to talk about that, For the moment it reproduces more the c inteface of ODE c++ project(http:// It's quite usefull, ODE documentation is really good, and I kept all the method name.  Energyjs is port of Open dynamic engine to JS with EMSscripten ( . 













Vehicle   (maybe you need to refresh the html page - loading is async and I forgot to fix that,, same for v+trailers)

Vehicle+trailers (arrow key to control the vehicle, d to flip the vehicle)


It's only cpu dependent, maybe a little more faster than oimo and canon. Really well documented on ODE's part. You may have a TOTAL_MEMORY bug, search '167108864' in js/energy.js and increased this value.  This is just a start. I will publish this week the the typescript dev commented on github . 


Share this post

Link to post
Share on other sites

@Deltakosh , I'm going to work on a doc page this week. 

Another thing, I ported  energy.js to webAssembly, it works pretty well : file size is half than the asm.js version, performances are 5-10% better in FF or Chrome. Edge (40.15063.0.0) is far behind, (still alpha support of webAssembly ?).

Edit : about Edge, I test the new release in Preview build 16299 , performances are equivalent to ff and chrome.

Asm.js version runs almost equally in the 3 browsers.

Here is 2 perf tests, asm.js and webassembly. Launch the page clic on the scene and press S, You have to wait all red boxes become gray. Its about 21000ms on my i3 for asm.js and 19000ms for webAssembly.

asm.js test   

webAssembly test

Can someone test those demos and confirm webassembly is faster than asm in this particular test ?





Edited by Samuel Girardin

Share this post

Link to post
Share on other sites

On an i7 3770k:

  • Chrome 61:
    • 8783ms for asm
    • 8326ms for wasm
  • FF 57 (dev edition):
    • 7769ms for asm
    • 7611ms for wasm

The frame time (top right corner) sits at 12-13ms for wasm, but 16-17ms for asm after the test is finished.

Share this post

Link to post
Share on other sites

I only use emscripten to produce asm or wasm. The workflow ia exactly the same. I just have to add a specific flag to the compiler to emit asm or wasm. For the moment webassembly was just a test case. About your link, could be useful for heavy math calculation, but Javascript vm are more and more optimized.. Webaasembly is really useful to port existing c++ library to browsers. @Jerome


Share this post

Link to post
Share on other sites

actually wasm is more widely supported than asm :

As wasm is also standardized, I supposed it's the way to go now (although asm is easier to write by hand directly without any compilation)

[EDIT] and that's the reason why I wish the AssemblyScript project could get reliable and mature soon. It would allow us to translate some parts of the existing TS code (maths, matrix computations, for instance) at almost no cost (just by checking we specify the right types)  directly to WASM.


[EDIT 2] just found this site showing some live gain (or not) about image processing with WASM vs JS :


[EDIT 3] I just discovered that AssemblyScript (ASC) guys are already working on the next version of ASC, called NEXT :

They need to decouple ASC from the current TS compiler to be able to compile the ASC compiler itself directly in WASM instead of in TS. Complex, but makes sense.

Share this post

Link to post
Share on other sites

That said, ASM.js is still great, can be written by hand, is legal JS and brings immediate real gain.

Example (open your console) :

This PG just sets a big array with a float value (no maths or complex things here). The "normal" time is the JS classical array assignement, the "asm" time is the same done by the asm loop function.



mmmhh... having an idea to make an asm test with the SPS experiment, not sure this will work

Share this post

Link to post
Share on other sites
On 07/10/2017 at 12:58 AM, Deltakosh said:


We should work on a doc page to reference all your great samples!


I ve started that :

I m not sure where you want to put it ?



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.