From 4a895b104de959b64a15d407c9d54679d84b3507 Mon Sep 17 00:00:00 2001 From: Greg Fodor <gfodor@gmail.com> Date: Mon, 12 Nov 2018 05:59:06 +0000 Subject: [PATCH] Missing file --- src/systems/cameras.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/systems/cameras.js diff --git a/src/systems/cameras.js b/src/systems/cameras.js new file mode 100644 index 000000000..2aa2e4081 --- /dev/null +++ b/src/systems/cameras.js @@ -0,0 +1,28 @@ +// Used for tracking and managing camera tools in the scene +AFRAME.registerSystem("cameras", { + init() { + this.cameraEls = []; + }, + + register(el) { + this.cameraEls.push(el); + el.addEventListener("ownership-changed", this._onOwnershipChange); + this.currentCamera = null; + }, + + deregister(el) { + this.cameraEls = this.cameraEls.filter(c => c !== el); + el.removeEventListener("ownership-changed", this._onOwnershipChange); + this.currentCamera = null; + }, + + getCurrent() { + if (this.currentCamera) return this.currentCamera; + this.currentCamera = this.cameraEls.find(NAF.utils.isMine); + return this.currentCamera; + }, + + _onOwnershipChange() { + this.currentCamera = null; + } +}); -- GitLab