UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

47 lines (46 loc) 1.37 kB
"use strict"; export class DispatchController { constructor(scene) { this.scene = scene; } setListener(eventsListener) { if (!this._eventsListener) { this._eventsListener = eventsListener; this._runOnAddListenerCallbacks(); } else { console.warn("scene already has a listener"); } } onAddListener(callback) { if (this._eventsListener) { callback(); } else { this._onAddListenerCallbacks = this._onAddListenerCallbacks || []; this._onAddListenerCallbacks.push(callback); } } _runOnAddListenerCallbacks() { if (this._onAddListenerCallbacks) { let callback; while (callback = this._onAddListenerCallbacks.pop()) { callback(); } this._onAddListenerCallbacks = void 0; } } dispatch(emitter, event, data) { var _a; (_a = this._eventsListener) == null ? void 0 : _a.processEvents(emitter, event, data); } emitAllowed() { return this._eventsListener != null && this.scene.loadingController.loaded() && this.scene.loadingController.autoUpdating(); } processActorEvaluator(evaluator) { var _a; return (_a = this._eventsListener) == null ? void 0 : _a.processActorEvaluator(evaluator); } actorEvaluatorDebug(options) { var _a; return (_a = this._eventsListener) == null ? void 0 : _a.actorEvaluatorDebug(options); } }