Physics module for Whitestorm.js [Beta]
Modules list
new PHYSICS.WorldModule()
const app = // ... gravity: 0 -10 0 ammo: 'path/to/ammo.js' ; appstart;
new PHYSICS.BoxModule()
const box = geometry: width: 2 height: 2 depth: 4 modules: mass: 10 material: color: 0xff0000; box;
new PHYSICS.SphereModule()
const sphere = geometry: radius: 3 modules: mass: 10 material: color: 0xff0000; sphere;
new PHYSICS.PlaneModule()
const plane = geometry: width: 100 height: 100 modules: mass: 5 material: color: 0xff0000; plane;
new PHYSICS.CapsuleModule()
No example yet.
new PHYSICS.ConeModule()
const sphere = geometry: radiusTop: 0 radiusBottom: 3 height: 4 modules: mass: 2 material: color: 0xff0000; box;
new PHYSICS.ConvexModule()
const teapot = geometry: path: 'path/to/teapot.json' modules: mass: 2 path: 'path/to/simplified/teapot.json' material: color: 0xff0000; teapot;
new PHYSICS.CylinderModule()
const sphere = geometry: radiusTop: 3 radiusBottom: 3 height: 4 modules: mass: 2 material: color: 0xff0000; box;
new PHYSICS.HeightfieldModule()
const terrain = geometry: func: myFunction modules: mass: 5 size: 100 100 autoAlign: true // center physics object automatically. material: color: 0xff0000; terrain;
new PHYSICS.CompoundModule()
This module should be used only if you want to create a copmound physics object without shape and then add needed objects. CompoundModule
is selected by default if you add object to another object.
new PHYSICS.ConcaveModule()
const teapot = geometry: path: 'path/to/teapot.json' modules: mass: 2 path: 'path/to/simplified/teapot.json' material: color: 0xff0000; teapot;
new PHYSICS.SoftbodyModule()
const sphere = geometry: radius: 3 detial: 2 modules: mass: 5 pressure: 500 material: color: 0xff0000; sphere;
new PHYSICS.ClothModule()
Used only with
WHS.Plane
const cloth = geometry: width: 100 height: 50 modules: mass: 5 material: color: 0xff0000; cloth;
new PHYSICS.RopeModule()
const rope = geometry: curve: 0 10 0 0 20 0 modules: mass: 5 material: color: 0xff0000; rope;
Additional available physics parameters
RigidBody
restitution: 03 friction: 08 damping: 0 margin: 0
SoftModule
, ClothModule
, RopeModule
)
SodtBody ( friction: 08 damping: 0 margin: 0 klst: 09 kvst: 09 kast: 09 piterations: 1 viterations: 0 diterations: 0 citerations: 4 anchorHardness: 07 rigidHardness: 1
Events
collision
player;
FAQ
Q: My ClothModule
doesn't work properly, what to do?
A: In 90% cases it is because you have set pressure
parameter. You shouldn't set it for ClothModule
.