-
Notifications
You must be signed in to change notification settings - Fork 1
Physics
Josh Stovall edited this page Dec 22, 2020
·
4 revisions
XR.js uses Physijs for physics simulation.
Physics can be configured when creating a Reality()
.
new XR.Reality({
physics: true, // default is true
gravity: [0, -10, 0], // downward gravity
});
Add a new object
new XR.Box({
physics: true,
gravity: -10,
bounce: 1,
friction: 1,
mass: 100
});
an object's physics can be configured with these parameters
Name | Type | Options | Default | Description |
---|---|---|---|---|
physics |
bool | true |
physics on or off | |
bounce |
float | 0.5 |
amount of bounce | |
friction |
float | 0.5 |
amount of friction | |
mass |
int | > 0 (0 is off ) |
1 |
mass of object |
We can turn physics on/off per object.
new XR.Box({
physics: false
});
if a single number, gravity will exist along the y axis
if an array, there can me multi-dimensional gravity [x_force
,y_force
,z_force
]
if 0
, object will be fixed in space (but other objects will still bounce off it)
see Physijs wiki