mirror of
https://github.com/WhitestormJS/whs.js.git
synced 2025-12-08 20:26:23 +00:00
73 lines
1.4 KiB
JavaScript
73 lines
1.4 KiB
JavaScript
import * as UTILS from '../../globals';
|
|
|
|
const world = new WHS.App([
|
|
new WHS.modules.ElementModule(),
|
|
new WHS.modules.SceneModule(),
|
|
new WHS.modules.CameraModule({
|
|
position: new THREE.Vector3(0, 10, 50)
|
|
}),
|
|
new WHS.modules.RenderingModule({
|
|
bgColor: 0x162129,
|
|
|
|
renderer: {
|
|
antialias: true,
|
|
shadowmap: {
|
|
type: THREE.PCFSoftShadowMap
|
|
}
|
|
}
|
|
}),
|
|
new PHYSICS.WorldModule({
|
|
ammo: process.ammoPath
|
|
}),
|
|
new WHS.OrbitControlsModule(),
|
|
new WHS.modules.AutoresizeModule()
|
|
]);
|
|
|
|
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.manager);
|
|
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.
|