sasha240100 a0471c9e8c Replace swig rendering engine with pug
Former-commit-id: 1180e65c0209b26897944c7f4e920f8dbfe7db2a
2017-01-09 03:54:10 +02:00

86 lines
1.8 KiB
JavaScript

import * as UTILS from '../../globals';
const world = new (PHYSICS.$world(WHS.World))({
...UTILS.$world,
physics: {
ammo: process.ammoPath
},
helpers: {
grid: {
size: 100,
step: 100,
color1: 0xff0000
},
axis: {
size: 100
}
},
camera: {
far: 10000,
position: [0, 10, 30]
}
});
const sphere = new (PHYSICS.$rigidBody(WHS.Sphere, PHYSICS.SPHERE))({
geometry: {
radius: 2,
widthSegments: 16,
heightSegments: 16
},
mass: 0,
material: {
color: UTILS.$colors.mesh,
kind: 'phong'
},
position: [0, 10, 0]
});
console.log(sphere.copy);
sphere.wait().then(() => {
const boxHelper = sphere.clone();
boxHelper.addTo(world);
boxHelper.addHelper('box');
const faceNormalsHelper = sphere.clone();
faceNormalsHelper.position.x = 10;
faceNormalsHelper.addTo(world);
faceNormalsHelper.addHelper('faceNormals', {color: 0x0000ff, size: 0.5});
const vertexNormalsHelper = sphere.clone();
vertexNormalsHelper.position.set(10, 10, 10);
vertexNormalsHelper.addTo(world);
vertexNormalsHelper.addHelper('vertexNormals', {color: 0x00ff00, size: 0.5});
window.boundingBoxHelper = sphere.clone();
boundingBoxHelper.wrap();
boundingBoxHelper.build().then(() => {
console.log(boundingBoxHelper.native);
});
boundingBoxHelper.position.y = 10;
boundingBoxHelper.position.z = 10;
boundingBoxHelper.native.mass = 10;
boundingBoxHelper.addTo(world);
boundingBoxHelper.addHelper('boundingBox', {color: 0x00ffff});
// new WHS.Loop(() =>
// // boundingBoxHelper.updateHelper('boundingBox')
// ).start(world);
});
UTILS.addPlane(world, 250);
UTILS.addBasicLights(world, 0.5, [0, 50, 50], 200).then(o => {
o.addHelper('default', {size: 1});
});
world.setControls(new WHS.OrbitControls());
world.start();