Graphics Reference
In-Depth Information
4 * Math.random() + 2,
4 * Math.random() + 2);
var cubeMaterial = new
THREE.MeshLambertMaterial(
{
color: 0xffffff * Math.random()
}
);
There is nothing special to do in this step for Physijs .
3. The next step is to create a mesh object. For objects to work with Physijs ,
we need to create a Physijs library specific mesh and a Physijs library
specific material:
var box_material =
Physijs.createMaterial(
cubeMaterial,
control.friction,
control.restitution);
var cube = new Physijs.BoxMesh(
cubeGeometry,
box_material,
10
);
scene.add(cube);
For the material, we use the Physijs.createMaterial function. This
wraps our material created in step 2 and allows us to define the friction
and restitution properties. The friction defines the roughness of the object
and affects how far it can slide over another object. The restitution ob-
ject is used for the bounciness of an object. To create a mesh, we use the
Physijs.BoxMesh object, provide the geometry and the material we just
created, and also add the weight of the object. Physijs provides differently
shaped meshes; for more information on them, refer to the There's moreā€¦
section of this recipe.
Search WWH ::




Custom Search