Skip to content

Commit

Permalink
update docs: RigidBody -> Body, and copy() direction fix. schteppe#263
Browse files Browse the repository at this point in the history
  • Loading branch information
schteppe committed Mar 9, 2016
1 parent 748afef commit 4cc2eb1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions examples/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

You've learnt how to render really cool 3D in the browser, and now you want your mesh to move. You add your favorite physics engine (cannon.js) to your project, and then... what?

These examples demonstrates how to render a Cannon.js physics scene using commonly used 3D libraries. The main problem is to make a mesh move according to a ```CANNON.RigidBody``` by synchronizing coordinates (position and orientation).
These examples demonstrates how to render a Cannon.js physics scene using commonly used 3D libraries. The main problem is to make a mesh move according to a ```CANNON.Body``` by synchronizing coordinates (position and orientation).

If you are looking for more in-depth examples on how to use Cannon.js, go to the [demos](https://github.com/schteppe/cannon.js/tree/master/demos) instead.

Expand All @@ -18,8 +18,13 @@ mesh.useQuaternion = true;

Then it gets really simple to copy over position+orientation data to the Three.js mesh:
```javascript
rigidbody.position.copy(mesh.position);
rigidbody.quaternion.copy(mesh.quaternion);
mesh.position.x = body.position.x;
mesh.position.y = body.position.y;
mesh.position.z = body.position.z;
mesh.quaternion.x = body.quaternion.x;
mesh.quaternion.y = body.quaternion.y;
mesh.quaternion.z = body.quaternion.z;
mesh.quaternion.w = body.quaternion.w;
```

See [threejs.html](https://github.com/schteppe/cannon.js/blob/master/examples/threejs.html) for a full example.
Expand All @@ -34,13 +39,13 @@ See [threejs.html](https://github.com/schteppe/cannon.js/blob/master/examples/th
type: "translate",
id: "my-translate",
x : 0.0, y : 0.0, z : 0.0,
nodes: [
{
type: "quaternion",
id: "my-quaternion",
x : 1.0, y : 0.0, z : 0.0, angle : 0.0,
nodes: [
...
```
Expand All @@ -56,8 +61,8 @@ The full example, and how to get the axis/angle representation of the ```CANNON.
You can easily update your KickJS game objects by copying the position and rotation vectors from cannon.js like this:

```javascript
pos = rigidbody.position
quat = rigidbody.quaternion
pos = body.position
quat = body.quaternion
gameObject.transform.position = [pos.x, pos.y, pos.z]
gameObject.transform.rotation = [quat.x, quat.y, quat.z, quat.w]
```
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/Plane.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var Shape = require('./Shape');
var Vec3 = require('../math/Vec3');

/**
* A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a RigidBody and rotate that body. See the demos.
* A plane, facing in the Z direction. The plane has its surface at z=0 and everything below z=0 is assumed to be solid plane. To make the plane face in some other direction than z, you must put it inside a Body and rotate that body. See the demos.
* @class Plane
* @constructor
* @extends Shape
Expand Down

0 comments on commit 4cc2eb1

Please sign in to comment.