Alexander Buzin 55049affc1 Fix basic/mouse and basic/embeded examples
- AutoresizeModule -> ResizeModule
- Build & assets

Former-commit-id: 9b667f864cc43747a22083bf1d0cad5d5fae8931
2017-01-23 19:21:14 +02:00

73 lines
1.3 KiB
JavaScript

import * as UTILS from '../../globals';
const world = new WHS.App([
new WHS.app.ElementModule(),
new WHS.app.SceneModule(),
new WHS.app.CameraModule({
position: new THREE.Vector3(0, 10, 50)
}),
new WHS.app.RenderingModule({
bgColor: 0x162129,
renderer: {
antialias: true,
shadowmap: {
type: THREE.PCFSoftShadowMap
}
}
}),
new PHYSICS.WorldModule({
ammo: process.ammoPath
}),
new WHS.OrbitControlsModule(),
new WHS.app.ResizeModule()
]);
const sphere = new WHS.Sphere({ // Create sphere component.
geometry: {
radius: 3,
widthSegments: 32,
heightSegments: 32
},
modules: [
new PHYSICS.SphereModule({
mass: 10
})
],
material: new THREE.MeshPhongMaterial({
color: UTILS.$colors.mesh
}),
position: [0, 100, 0]
});
sphere.addTo(world);
const mouse = new WHS.VirtualMouse(world);
mouse.track(sphere);
sphere.on('mouseover', () => {
sphere.material.color.set(0xffff00);
console.log('mouseover');
});
sphere.on('mousemove', () => {
console.log('mousemove');
});
sphere.on('mouseout', () => {
sphere.material.color.set(UTILS.$colors.mesh);
console.log('mouseout');
});
sphere.on('click', () => {
alert('click!');
});
UTILS.addPlane(world);
UTILS.addBasicLights(world);
world.start(); // Start animations and physics simulation.