Alexander Buzin 4c0f831c0d Change StateModule example
Former-commit-id: 3f49442d994dc9d4bcc2c41aa93f4091ca55db88
2017-06-24 18:32:41 +03:00

43 lines
911 B
JavaScript

import * as UTILS from '../../globals';
const app = new WHS.App([
new WHS.ElementModule(),
new WHS.SceneModule(),
new WHS.DefineModule('camera', new WHS.PerspectiveCamera(UTILS.appDefaults.camera)),
new WHS.RenderingModule(UTILS.appDefaults.rendering, {
shadow: true
}),
new PHYSICS.WorldModule(UTILS.appDefaults.physics),
new WHS.OrbitControlsModule(),
new WHS.ResizeModule(),
new StatsModule()
]);
const sphere = new WHS.Sphere({ // Create sphere comonent.
geometry: {
radius: 5,
widthSegments: 32,
heightSegments: 32
},
modules: [
new PHYSICS.SphereModule({
mass: 10,
restitution: 1
})
],
material: new THREE.MeshPhongMaterial({
color: UTILS.$colors.mesh
}),
position: new THREE.Vector3(0, 20, 0)
});
sphere.addTo(app);
UTILS.addBoxPlane(app);
UTILS.addBasicLights(app);
app.start(); // Start animations and physics simulation.