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

86 lines
1.5 KiB
JavaScript

import * as UTILS from '../../globals';
const world = new WHS.World({
...UTILS.$world,
physics: {
ammo: process.ammoPath
},
camera: {
far: 10000,
position: [0, 2, 12]
},
modules: {
scene: false
}
});
const scene = new THREE.Scene();
const material = new THREE.MeshPhongMaterial({color: UTILS.$colors.mesh});
const materialNested = material.clone();
materialNested.color.set(0x0000ff);
const materialWHS = material.clone();
materialWHS.color.set(0xffffff);
materialWHS.map = new WHS.texture('{{ assets }}/textures/earth.jpg');
const mesh1 = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 32),
material
);
mesh1.position.set(2, 2, 0);
scene.add(mesh1);
const mesh2 = new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 32),
material
);
mesh2.position.set(4, 2, 0);
scene.add(mesh2);
const mesh3 = new THREE.Mesh(
new THREE.SphereGeometry(0.5, 32, 32),
materialNested
);
mesh3.position.set(0, 0, 1);
// Nested object.
mesh2.add(mesh3);
world.importScene(scene, true);
world.make$camera();
world.make$rendering();
world.make$helpers();
const sphere = new WHS.Element(
new THREE.Mesh(
new THREE.SphereGeometry(1, 32, 32),
materialWHS
),
[WHS.MeshComponent]
);
sphere.addTo(world);
sphere.position.y = 2;
const light = new WHS.Element(
new THREE.PointLight(),
[WHS.LightComponent]
);
light.wrap();
light.addTo(world);
UTILS.addPlane(world);
UTILS.addBasicLights(world);
world.setControls(new WHS.OrbitControls());
world.start();