Added orbit controls

master
Robin Hawkes 2016-02-12 10:41:41 +00:00
rodzic 7684a0061b
commit 1fccf5358c
10 zmienionych plików z 1441 dodań i 28 usunięć

1329
dist/vizicities.js vendored

Plik diff jest za duży Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -5,3 +5,6 @@ var world = VIZI.World('world');
// Makes sense to allow others to customise their environment so perhaps this
// could be left public but a default is set up within World to simplify things
var environment = VIZI.EnvironmentLayer().addTo(world);
// Add controls
VIZI.Controls.Orbit().addTo(world);

Wyświetl plik

@ -80,6 +80,7 @@
},
"dependencies": {
"eventemitter3": "^1.1.1",
"three": "^0.73.2"
"three": "^0.73.2",
"three-orbit-controls": "^72.0.0"
}
}

Wyświetl plik

@ -10,15 +10,15 @@ class Engine extends EventEmitter {
super();
this.scene = Scene;
this.renderer = Renderer(container);
this.camera = Camera(container);
this._scene = Scene;
this._renderer = Renderer(container);
this._camera = Camera(container);
this.clock = new THREE.Clock();
}
_update(delta) {
this.emit('preRender');
this.renderer.render(this.scene, this.camera);
this._renderer.render(this._scene, this._camera);
this.emit('postRender');
}
}

Wyświetl plik

@ -9,6 +9,7 @@ class World extends EventEmitter {
super();
this._layers = [];
this._controls = [];
this._initContainer(domId);
this._initEngine();
@ -48,13 +49,25 @@ class World extends EventEmitter {
this._layers.push(layer);
// Could move this into Layer but it'll do here for now
this._engine.scene.add(layer._layer);
this._engine._scene.add(layer._layer);
this.emit('layerAdded', layer);
return this;
}
// Remove layer and perform clean up operations
removeLayer(layer) {}
addControls(controls) {
controls._addToWorld(this);
this._controls.push(controls);
this.emit('controlsAdded', controls);
return this;
}
removeControls(controls) {}
}
// Initialise without requiring new keyword

Wyświetl plik

@ -0,0 +1,73 @@
import EventEmitter from 'eventemitter3';
import THREE from 'three';
import OrbitControls from 'three-orbit-controls';
var _OrbitControls = OrbitControls(THREE);
class Orbit extends EventEmitter {
constructor() {
super();
}
// Moving the camera along the [x,y,z] axis based on a target position
_panTo(point, animate) {}
_panBy(pointDelta, animate) {}
// Zooming the camera in and out
_zoomTo(metres, animate) {}
_zoomBy(metresDelta, animate) {}
// Force camera to look at something other than the target
_lookAt(point, animate) {}
// Make camera look at the target
_lookAtTarget() {}
// Tilt (up and down)
_tiltTo(angle, animate) {}
_tiltBy(angleDelta, animate) {}
// Rotate (left and right)
_rotateTo(angle, animate) {}
_rotateBy(angleDelta, animate) {}
// Fly to the given point, animating pan and tilt/rotation to final position
// with nice zoom out and in
//
// Calling flyTo a second time before the previous animation has completed
// will immediately start the new animation from wherever the previous one
// has got to
_flyTo(point, noZoom) {}
// Internal methods called when before, during and after control updates
_onStart() {}
_onChange() {}
_onEnd() {}
// Add controls to world instance and store world reference
addTo(world) {
world.addControls(this);
return this;
}
// Internal method called by World.addControls to actually add the controls
_addToWorld(world) {
this._world = world;
// TODO: Override panLeft and panUp methods to prevent panning on Y axis
// See: http://stackoverflow.com/a/26188674/997339
this._orbitControls = new _OrbitControls(world._engine._camera, world._container);
this.emit('added');
}
// Proxy to OrbitControls.update()
update() {
this._orbitControls.update();
}
}
// Initialise without requiring new keyword
export default function() {
return new Orbit();
};

Wyświetl plik

@ -0,0 +1,7 @@
import Orbit from './Controls.Orbit';
const Controls = {
Orbit: Orbit
};
export default Controls;

Wyświetl plik

@ -1,4 +1,5 @@
import World from './World';
import Controls from './controls/Controls';
import EnvironmentLayer from './layer/environment/EnvironmentLayer';
const VIZI = {
@ -6,6 +7,7 @@ const VIZI = {
// Public API
World: World,
Controls: Controls,
EnvironmentLayer: EnvironmentLayer
};