Cannon.js: Difference between revisions

Content deleted Content added
Octogonz (talk | contribs)
m Add release version
Remove dead link
 
(6 intermediate revisions by 4 users not shown)
Line 1:
{{Short description|3D JavaScript physics engine}}
{{Infobox software
| title = Cannon.js
Line 16 ⟶ 17:
|access-date = 11 May 2021
}}</ref>
| website = {{URL|httphttps://wwwgithub.cannonjs.orgcom/schteppe/cannon.js}}
| AsOf =
}}
{{Portal|Free and open-source software}}
 
'''Cannon.js''' is an [[Open-source software|open source]] [[JavaScript]] [[3D computer graphics|3D]] [[physics engine]] created by Stefan "schteppe" Hedman.<ref>{{cite web |title=Stefan Hedman |url=https://github.com/schteppe |website=GitHub |accessdate=27 April 2017}}</ref> Unlike physics engine libraries ported from C++ to JavaScript, cannon.js is written in JavaScript from the start and can take advantage of its features.<ref name=Prall2012>{{cite web |last=Prall |first=Chandler |title=JavaScript Physics Engines Comparison |url=http://buildnewgames.com/physics-engines-comparison/ |website=Build New Games |date=10 April 2012 |accessdate=27 April 2017}}</ref> In a 2013 comparison with Ammo.js, cannon.js was found to be "more compact, more comprehensible, more powerful with regard to its performance and also easier to understand", but did not have as many features.<ref name=Huber2013>{{cite book |last=Huber |first=Linda |chapter=Initial Steps for the Coupling of JavaScript Physics Engines with X3DOM |editor1=Jan Bender |editor2=Jeremie Dequidt |editor3=Christian Duriez |editor4=Gabriel Zachmann |title=Workshop on Virtual Reality Interaction and Physical Simulation (VRIPHYS 2013) |journal=Workshop on Virtual Reality Interaction and Physical Simulation |publisher=The Eurographics Association |date=2013 |pages=81–90 |isbn=978-3-905674-57-6 |doi=10.2312/PE.vriphys.vriphys13.081-090}}</ref>
 
== Features ==
Line 28 ⟶ 29:
The physics engine implements rigid-body dynamics, discrete [[collision detection]], and a [[Gauss–Seidel method|Gauss-Seidel]] constraint solver.<ref>{{cite web |title= Branch: master. cannon.js/README.markdown |url=https://github.com/schteppe/cannon.js/blob/master/README.markdown |publisher=GitHub |date=22 April 2015 |accessdate=27 April 2017}}</ref> It can perform [[cloth simulation]]<ref>{{cite web | url=https://blog.raananweber.com/2016/04/03/cloth-physics-simulation-for-babylon-js/ | title = Cloth physics simulation}}</ref>
 
Cannon.js can be used with Three.js and Babylon.js<ref>{{cite web|title=Create wonderful interactive games for the web: Using webgl and a physics engine (babylon.js & cannon.js)|url=https://www.eternalcoding.com/?p=153|accessdate=21 February 2017}}</ref><ref name="msdn_phy_tutorial">{{cite web|title=MSDN Game Development with Babylon.js|url=https://msdn.microsoft.com/en-us/magazine/mt614269.aspx|accessdate=21 February 2017}}</ref> WebGL renderers to generate physics-based 3D scenes. It can also be used to provide networked-physics synchronization for [[multiplayer online game]]s using Lance.gg<ref>{{cite web | url = https://github.com/lance-gg/lance | title = Lance source repository| website = [[GitHub]]}}</ref>
 
== Example ==
Line 58 ⟶ 59:
// Start the simulation loop
var lastTime;
(function simloop(time) {
requestAnimationFrame(simloop);
if (lastTime !== undefined) {
var dt = (time - lastTime) / 1000;
world.step(fixedTimeStep, dt, maxSubSteps);
Line 73 ⟶ 74:
 
== External links ==
* {{GitHub|schteppe/cannon.js}}
* {{Official website|http://www.cannonjs.org/}}
* [https://github.com/schteppe/cannon.js Source Code Repository]
 
{{Physics engines}}