Game Development Reference
In-Depth Information
Open the Stage.js file from the primitive folder in your favorite editor. The
following code is present in this file:
addTexture:function(index,name,img,clampToEdge){
...
if(clampToEdge){
this.gl.texParameteri(this.gl.TEXTURE_2D,
this.gl.TEXTURE_WRAP_S, this.gl.CLAMP_TO_EDGE);
this.gl.texParameteri(this.gl.TEXTURE_2D,
this.gl.TEXTURE_WRAP_T, this.gl.CLAMP_TO_EDGE);
}
...
}
We will now understand JavaScript physics engines and cover terrain physics in the
last section of the chapter.
Comparing JavaScript 3D physics
engines
Let's start by looking at the most popular JavaScript physics engines. Most of them
are still under development. The three most popular JavaScript physics libraries are
Box2dweb, Ammo.js, and JigLibJS. We will give you a quick introduction to each one
and then use JigLibJS in our code.
Ammo.js
Ammo.js is directly ported from the Bullet physics engine (a C++ physics library)
using Emscripten ( https://github.com/kripken/emscripten ). There is no human
rewriting involved in the translation of the source code. The full form of Ammo is
Avoided making my own . Ammo.js is a fully featured, rich physics library with a
wide range of options for physics shapes. It supports all features such as collision
detection, constraints, and vehicle systems.
The overview of Ammo.js is as follows:
Performance : As Ammo.js is a direct port, the JavaScript code has not
been optimized to run in the browser. It is powerful but performance can
be an issue.
Features : It is one of the most complete physics libraries available in any
programming language. The Bullet physics engine has been used in many
games such as Grand Theft Auto IV and Red Dead Redemption , and movies such
as 2012 and Sherlock Holmes .
 
Search WWH ::




Custom Search