kopia lustrzana https://github.com/robhawkes/vizicities
Externalised three.js dependency
rodzic
1fccf5358c
commit
8548809a07
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,9 @@
|
|||
<body>
|
||||
<div id="world"></div>
|
||||
|
||||
<script src="../vendor/three.min.js"></script>
|
||||
<script src="../../dist/vizicities.min.js"></script>
|
||||
|
||||
<script src="main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -10,6 +10,10 @@ import { Instrumenter } from 'isparta';
|
|||
|
||||
import manifest from './package.json';
|
||||
|
||||
// TODO: Re-implement build process to utilise proper caching
|
||||
// TODO: Consider bundling three.js within the final build, or at least having
|
||||
// a different build step for an all-in-one file
|
||||
|
||||
// Load all of our Gulp plugins
|
||||
const $ = loadPlugins();
|
||||
|
||||
|
@ -69,6 +73,10 @@ function build() {
|
|||
libraryTarget: 'umd',
|
||||
library: config.mainVarName
|
||||
},
|
||||
externals: {
|
||||
// Proxy the global THREE variable to require('three')
|
||||
'three': 'THREE'
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"eventemitter3": "^1.1.1",
|
||||
"three": "^0.73.2",
|
||||
"three-orbit-controls": "^72.0.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,11 @@ class World extends EventEmitter {
|
|||
// Once _update is called it will run forever, for now
|
||||
window.requestAnimationFrame(this._update.bind(this));
|
||||
|
||||
// Update controls
|
||||
this._controls.forEach(controls => {
|
||||
controls.update();
|
||||
});
|
||||
|
||||
this.emit('preUpdate');
|
||||
this._engine._update(delta);
|
||||
this.emit('postUpdate');
|
||||
|
|
|
@ -9,6 +9,21 @@ class Orbit extends EventEmitter {
|
|||
super();
|
||||
}
|
||||
|
||||
// Proxy control events
|
||||
_initEvents() {
|
||||
this._controls.addEventListener('start', (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
this._controls.addEventListener('change', (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
|
||||
this._controls.addEventListener('end', (event) => {
|
||||
console.log(event);
|
||||
});
|
||||
}
|
||||
|
||||
// Moving the camera along the [x,y,z] axis based on a target position
|
||||
_panTo(point, animate) {}
|
||||
_panBy(pointDelta, animate) {}
|
||||
|
@ -44,6 +59,11 @@ class Orbit extends EventEmitter {
|
|||
_onChange() {}
|
||||
_onEnd() {}
|
||||
|
||||
// Proxy to OrbitControls.update()
|
||||
update() {
|
||||
this._controls.update();
|
||||
}
|
||||
|
||||
// Add controls to world instance and store world reference
|
||||
addTo(world) {
|
||||
world.addControls(this);
|
||||
|
@ -56,15 +76,12 @@ class Orbit extends EventEmitter {
|
|||
|
||||
// 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._controls = new _OrbitControls(world._engine._camera, world._container);
|
||||
|
||||
this._initEvents();
|
||||
|
||||
this.emit('added');
|
||||
}
|
||||
|
||||
// Proxy to OrbitControls.update()
|
||||
update() {
|
||||
this._orbitControls.update();
|
||||
}
|
||||
}
|
||||
|
||||
// Initialise without requiring new keyword
|
||||
|
|
Ładowanie…
Reference in New Issue