UNPKG

convex-pixel

Version:

The library for creating pseudo 3d interactive scenes based on webgl

42 lines 1.54 kB
import * as PIXI from "pixi.js"; import { CameraControllerEventTypes } from "./events/event-types"; export class CameraControllerManager extends PIXI.utils.EventEmitter { constructor(_camera) { super(); this._camera = _camera; this._controllers = []; this._handlerControllerMove = (target) => { this.emit(CameraControllerEventTypes.MOVE, target); }; this._handlerControllerPOV = (target) => { this.emit(CameraControllerEventTypes.POV, target); }; this._handlerControllerZoom = (zoom) => { this.emit(CameraControllerEventTypes.ZOOM, zoom); }; this._handlerControllerRotate = (rotation) => { this.emit(CameraControllerEventTypes.ROTATE, rotation); }; } add(controller) { this._controllers.push(controller); controller.camera = this._camera; controller.onMove = this._handlerControllerMove; controller.onPOV = this._handlerControllerPOV; controller.onZoom = this._handlerControllerZoom; controller.onRotate = this._handlerControllerRotate; } removeAll() { while (this._controllers.length > 0) { const controller = this._controllers.pop(); if (controller) { controller.destroy(); } } } destroy() { this.removeAll(); super.removeAllListeners(); } } //# sourceMappingURL=camera-controller-manager.js.map