sasha240100 6445e6cf23 Three.js example.
Former-commit-id: 01a8b1d8382c0de38849004008107728909f694f
2016-07-10 16:03:22 +03:00

71 lines
1.1 KiB
JavaScript

const GAME = new WHS.World({
stats: 'fps', // fps, ms, mb
autoresize: true,
gravity: {
x: 0,
y: -100,
z: 0
},
camera: {
far: 10000,
y: 10,
z: 30
},
init: {
scene: false
}
});
const scene = new THREE.Scene();
const obj1 = new THREE.Mesh(new THREE.SphereGeometry(3, 32, 32), new THREE.MeshBasicMaterial({color: 0xffffff}));
obj1.position.set(6, 6, 0);
scene.add(obj1);
const obj2 = new THREE.Mesh(new THREE.SphereGeometry(3, 32, 32), new THREE.MeshBasicMaterial({color: 0xffffff}));
obj2.position.set(12, 6, 0);
scene.add(obj2);
GAME.setScene(scene, true);
GAME._initCamera();
GAME._initRenderer();
GAME._initHelpers();
const sphere = new WHS.Shape(
new THREE.Mesh(new THREE.SphereGeometry(3, 32, 32), new THREE.MeshBasicMaterial({color: 0xffffff}))
);
sphere.addTo(GAME);
sphere.position.y = 3;
new WHS.Plane({
geometry: {
width: 250,
height: 250
},
mass: 0,
material: {
color: 0xff0000,
kind: 'basic'
},
pos: {
x: 0,
y: 0,
z: 0
},
rot: {
x: -Math.PI / 2
}
}).addTo(GAME);
GAME.start();