Cool 3D Physics

278 views
Skip to first unread message

Gregg Tavares (社用)

unread,
Oct 23, 2012, 1:21:43 PM10/23/12
to webgl-d...@googlegroups.com
I just felt like sharing but I am really impressed by the 3D physics samples on this page for JS and WebGL. They seem 1-3 orders of magnitude faster than any other WebGL 3D physics demo I've seen
http://biz.turbulenz.com/samples#!

Anyone know of any others with similar perf?

Brandon Jones

unread,
Oct 23, 2012, 2:07:27 PM10/23/12
to webgl-d...@googlegroups.com
Wow, that's very impressive!

Most of the WebGL+Physics demos I've seen run on Emscripten builds of C++ engines (like Ammo.js) which can perform well but often are very janky at first while the browser figures out how to optimize the code, and then stutter as the garbage collector works overtime to keep up. This one is incredibly smooth for the entire duration. Respect++ for the Turbulenz devs!

Tony Parisi

unread,
Oct 23, 2012, 2:40:57 PM10/23/12
to webgl-d...@googlegroups.com
Hey Brandon,

Are there preload techniques to avoid the initial um jankiness? Been wondering about that...
--
Tony Parisi                             tpa...@gmail.com
CTO at Large                         415.902.8002
Skype                                     auradeluxe
Follow me on Twitter!             http://twitter.com/auradeluxe
Read my blog at                     http://www.tonyparisi.com/

Read my book! WebGL, Up and Running
http://shop.oreilly.com/product/0636920024729.do
http://www.amazon.com/dp/144932357X


Brandon Jones

unread,
Oct 23, 2012, 2:48:01 PM10/23/12
to webgl-d...@googlegroups.com
I haven't experimented with it much, but it should be possible to spin through a few hundred frames of dummy simulation with various shape types during your apps loading screen to "prime" the JS engine for the physics code paths. I'm not sure if the Turbulenz demo is doing that, though. Would be interesting to hear how they avoid startup stutters.

Kenneth Russell

unread,
Oct 23, 2012, 2:59:36 PM10/23/12
to webgl-d...@googlegroups.com
Wow, that's incredible 3D physics performance in a browser! Huge kudos
to the Turbulenz team, and Gregg, thanks for pointing it out.

Brandon, good advice on warming up the code paths before starting the
level. Let me point out that some bugs have been fixed recently in the
V8 JavaScript engine which significantly reduced jank at startup for
large JavaScript code:

http://code.google.com/p/chromium/issues/detail?id=123822
http://code.google.com/p/chromium/issues/detail?id=128252
https://code.google.com/p/v8/issues/detail?id=2139

-Ken

David Galeano

unread,
Oct 24, 2012, 5:04:40 AM10/24/12
to webgl-d...@googlegroups.com
Glad you guys like it.

We also suffer startup stutters, slightly more noticeable with Firefox than with Chrome. Our physics simulation can be configured to clamp the time spent on simulation to some degree, which helps with initial frames, but the "physics_benchmark" example in particular adds objects to the world one by one to avoid as much as possible the startup stutters. On other demos we do run a hidden full simulation step to smooth out the first rendering frames.

We wrote our 2D and 3D physics solutions directly in JavaScript, using typed arrays everywhere and with aggressive objects reuse to reduce pressure on the memory manager. The 2D solution is fully featured, for the 3D version we still need to implement some of the more complex constraints and we still need to write specific shape-to-shape collision functions to optimize the more common cases.

David Galeano
Turbulenz Limited

Tony Parisi

unread,
Oct 24, 2012, 11:21:41 AM10/24/12
to webgl-d...@googlegroups.com
Very impressive David! I look forward to seeing more and more of this.
Tony
Reply all
Reply to author
Forward
0 new messages