vizicities/src/layer/Layer.js

33 wiersze
672 B
JavaScript
Czysty Zwykły widok Historia

import EventEmitter from 'eventemitter3';
import THREE from 'three';
import Scene from '../engine/Scene';
class Layer extends EventEmitter {
constructor() {
super();
this._layer = new THREE.Object3D();
}
// Add layer to world instance and store world reference
addTo(world) {
world.addLayer(this);
return this;
}
// Internal method called by World.addLayer to actually add the layer
_addToWorld(world) {
this._world = world;
2016-02-14 19:10:28 +00:00
this._onAdd(world);
this.emit('added');
}
2016-02-18 19:33:12 +00:00
// Destroys the layer and removes it from the scene and memory
destroy() {
this._world = null;
this._layer = null;
}
}
export default Layer;