UNPKG

networked-aframe

Version:

A web framework for building multi-user virtual reality experiences.

288 lines • 200 kB
/*
 * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ "./node_modules/buffered-interpolation/dist/buffered-interpolation.js":
/*!****************************************************************************!*\
  !*** ./node_modules/buffered-interpolation/dist/buffered-interpolation.js ***!
  \****************************************************************************/
/***/ ((module) => {

"use strict";
eval("\n\nvar _createClass = function () {\n  function defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n  return function (Constructor, protoProps, staticProps) {\n    if (protoProps) defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) defineProperties(Constructor, staticProps);\n    return Constructor;\n  };\n}();\nfunction _classCallCheck(instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n}\n\n/* global THREE */\n\nvar INITIALIZING = 0;\nvar BUFFERING = 1;\nvar PLAYING = 2;\nvar MODE_LERP = 0;\nvar MODE_HERMITE = 1;\nvar vectorPool = [];\nvar quatPool = [];\nvar framePool = [];\nvar getPooledVector = function getPooledVector() {\n  return vectorPool.shift() || new THREE.Vector3();\n};\nvar getPooledQuaternion = function getPooledQuaternion() {\n  return quatPool.shift() || new THREE.Quaternion();\n};\nvar getPooledFrame = function getPooledFrame() {\n  var frame = framePool.pop();\n  if (!frame) {\n    frame = {\n      position: new THREE.Vector3(),\n      velocity: new THREE.Vector3(),\n      scale: new THREE.Vector3(),\n      quaternion: new THREE.Quaternion(),\n      time: 0\n    };\n  }\n  return frame;\n};\nvar freeFrame = function freeFrame(f) {\n  return framePool.push(f);\n};\nvar InterpolationBuffer = function () {\n  function InterpolationBuffer() {\n    var mode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : MODE_LERP;\n    var bufferTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.15;\n    _classCallCheck(this, InterpolationBuffer);\n    this.state = INITIALIZING;\n    this.buffer = [];\n    this.bufferTime = bufferTime * 1000;\n    this.time = 0;\n    this.mode = mode;\n    this.originFrame = getPooledFrame();\n    this.position = new THREE.Vector3();\n    this.quaternion = new THREE.Quaternion();\n    this.scale = new THREE.Vector3(1, 1, 1);\n  }\n  _createClass(InterpolationBuffer, [{\n    key: \"hermite\",\n    value: function hermite(target, t, p1, p2, v1, v2) {\n      var t2 = t * t;\n      var t3 = t * t * t;\n      var a = 2 * t3 - 3 * t2 + 1;\n      var b = -2 * t3 + 3 * t2;\n      var c = t3 - 2 * t2 + t;\n      var d = t3 - t2;\n      target.copy(p1.multiplyScalar(a));\n      target.add(p2.multiplyScalar(b));\n      target.add(v1.multiplyScalar(c));\n      target.add(v2.multiplyScalar(d));\n    }\n  }, {\n    key: \"lerp\",\n    value: function lerp(target, v1, v2, alpha) {\n      target.lerpVectors(v1, v2, alpha);\n    }\n  }, {\n    key: \"slerp\",\n    value: function slerp(target, r1, r2, alpha) {\n      target.slerpQuaternions(r1, r2, alpha);\n    }\n  }, {\n    key: \"updateOriginFrameToBufferTail\",\n    value: function updateOriginFrameToBufferTail() {\n      freeFrame(this.originFrame);\n      this.originFrame = this.buffer.shift();\n    }\n  }, {\n    key: \"appendBuffer\",\n    value: function appendBuffer(position, velocity, quaternion, scale) {\n      var tail = this.buffer.length > 0 ? this.buffer[this.buffer.length - 1] : null;\n      // update the last entry in the buffer if this is the same frame\n      if (tail && tail.time === this.time) {\n        if (position) {\n          tail.position.copy(position);\n        }\n        if (velocity) {\n          tail.velocity.copy(velocity);\n        }\n        if (quaternion) {\n          tail.quaternion.copy(quaternion);\n        }\n        if (scale) {\n          tail.scale.copy(scale);\n        }\n      } else {\n        var priorFrame = tail || this.originFrame;\n        var newFrame = getPooledFrame();\n        newFrame.position.copy(position || priorFrame.position);\n        newFrame.velocity.copy(velocity || priorFrame.velocity);\n        newFrame.quaternion.copy(quaternion || priorFrame.quaternion);\n        newFrame.scale.copy(scale || priorFrame.scale);\n        newFrame.time = this.time;\n        this.buffer.push(newFrame);\n      }\n    }\n  }, {\n    key: \"setTarget\",\n    value: function setTarget(position, velocity, quaternion, scale) {\n      this.appendBuffer(position, velocity, quaternion, scale);\n    }\n  }, {\n    key: \"setPosition\",\n    value: function setPosition(position, velocity) {\n      this.appendBuffer(position, velocity, null, null);\n    }\n  }, {\n    key: \"setQuaternion\",\n    value: function setQuaternion(quaternion) {\n      this.appendBuffer(null, null, quaternion, null);\n    }\n  }, {\n    key: \"setScale\",\n    value: function setScale(scale) {\n      this.appendBuffer(null, null, null, scale);\n    }\n  }, {\n    key: \"update\",\n    value: function update(delta) {\n      if (this.state === INITIALIZING) {\n        if (this.buffer.length > 0) {\n          this.updateOriginFrameToBufferTail();\n          this.position.copy(this.originFrame.position);\n          this.quaternion.copy(this.originFrame.quaternion);\n          this.scale.copy(this.originFrame.scale);\n          this.state = BUFFERING;\n        }\n      }\n      if (this.state === BUFFERING) {\n        if (this.buffer.length > 0 && this.time > this.bufferTime) {\n          this.state = PLAYING;\n        }\n      }\n      if (this.state === PLAYING) {\n        var mark = this.time - this.bufferTime;\n        //Purge this.buffer of expired frames\n        while (this.buffer.length > 0 && mark > this.buffer[0].time) {\n          //if this is the last frame in the buffer, just update the time and reuse it\n          if (this.buffer.length > 1) {\n            this.updateOriginFrameToBufferTail();\n          } else {\n            this.originFrame.position.copy(this.buffer[0].position);\n            this.originFrame.velocity.copy(this.buffer[0].velocity);\n            this.originFrame.quaternion.copy(this.buffer[0].quaternion);\n            this.originFrame.scale.copy(this.buffer[0].scale);\n            this.originFrame.time = this.buffer[0].time;\n            this.buffer[0].time = this.time + delta;\n          }\n        }\n        if (this.buffer.length > 0 && this.buffer[0].time > 0) {\n          var targetFrame = this.buffer[0];\n          var delta_time = targetFrame.time - this.originFrame.time;\n          var alpha = (mark - this.originFrame.time) / delta_time;\n          if (this.mode === MODE_LERP) {\n            this.lerp(this.position, this.originFrame.position, targetFrame.position, alpha);\n          } else if (this.mode === MODE_HERMITE) {\n            this.hermite(this.position, alpha, this.originFrame.position, targetFrame.position, this.originFrame.velocity.multiplyScalar(delta_time), targetFrame.velocity.multiplyScalar(delta_time));\n          }\n          this.slerp(this.quaternion, this.originFrame.quaternion, targetFrame.quaternion, alpha);\n          this.lerp(this.scale, this.originFrame.scale, targetFrame.scale, alpha);\n        }\n      }\n      if (this.state !== INITIALIZING) {\n        this.time += delta;\n      }\n    }\n  }, {\n    key: \"getPosition\",\n    value: function getPosition() {\n      return this.position;\n    }\n  }, {\n    key: \"getQuaternion\",\n    value: function getQuaternion() {\n      return this.quaternion;\n    }\n  }, {\n    key: \"getScale\",\n    value: function getScale() {\n      return this.scale;\n    }\n  }]);\n  return InterpolationBuffer;\n}();\nmodule.exports = InterpolationBuffer;\n\n//# sourceURL=webpack://networked-aframe/./node_modules/buffered-interpolation/dist/buffered-interpolation.js?");

/***/ }),

/***/ "./src/ChildEntityCache.js":
/*!*********************************!*\
  !*** ./src/ChildEntityCache.js ***!
  \*********************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar ChildEntityCache = /*#__PURE__*/function () {\n  function ChildEntityCache() {\n    _classCallCheck(this, ChildEntityCache);\n    this.dict = {};\n  }\n  return _createClass(ChildEntityCache, [{\n    key: \"addChild\",\n    value: function addChild(parentNetworkId, childData) {\n      if (!this.hasParent(parentNetworkId)) {\n        this.dict[parentNetworkId] = [];\n      }\n      this.dict[parentNetworkId].push(childData);\n    }\n  }, {\n    key: \"getChildren\",\n    value: function getChildren(parentNetworkId) {\n      if (!this.hasParent(parentNetworkId)) {\n        return [];\n      }\n      var children = this.dict[parentNetworkId];\n      delete this.dict[parentNetworkId];\n      return children;\n    }\n\n    /* Private */\n  }, {\n    key: \"hasParent\",\n    value: function hasParent(parentId) {\n      return !!this.dict[parentId];\n    }\n  }]);\n}();\nmodule.exports = ChildEntityCache;\n\n//# sourceURL=webpack://networked-aframe/./src/ChildEntityCache.js?");

/***/ }),

/***/ "./src/DeepEquals.js":
/*!***************************!*\
  !*** ./src/DeepEquals.js ***!
  \***************************/
/***/ ((module) => {

"use strict";
eval("// Patched version of fast-deep-equal which does not\n// allocate memory via calling Object.keys\n//\n// https://github.com/epoberezkin/fast-deep-equal/blob/master/index.js\n\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nvar isArray = Array.isArray;\nvar keyList = Object.keys;\nvar hasProp = Object.prototype.hasOwnProperty;\nmodule.exports = function equal(a, b) {\n  if (a === b) return true;\n  if (a && b && _typeof(a) == 'object' && _typeof(b) == 'object') {\n    var arrA = isArray(a),\n      arrB = isArray(b),\n      i,\n      length,\n      key;\n    if (arrA && arrB) {\n      length = a.length;\n      if (length != b.length) return false;\n      for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;\n      return true;\n    }\n    if (arrA != arrB) return false;\n    var dateA = a instanceof Date,\n      dateB = b instanceof Date;\n    if (dateA != dateB) return false;\n    if (dateA && dateB) return a.getTime() == b.getTime();\n    var regexpA = a instanceof RegExp,\n      regexpB = b instanceof RegExp;\n    if (regexpA != regexpB) return false;\n    if (regexpA && regexpB) return a.toString() == b.toString();\n    var keys = keyList(a);\n    length = keys.length;\n    if (length !== keyList(b).length) return false;\n    for (i = length; i-- !== 0;) if (!hasProp.call(b, keys[i])) return false;\n    for (i = length; i-- !== 0;) {\n      key = keys[i];\n      if (!equal(a[key], b[key])) return false;\n    }\n    return true;\n  }\n  return a !== a && b !== b;\n};\n\n//# sourceURL=webpack://networked-aframe/./src/DeepEquals.js?");

/***/ }),

/***/ "./src/NafIndex.js":
/*!*************************!*\
  !*** ./src/NafIndex.js ***!
  \*************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("var options = __webpack_require__(/*! ./options */ \"./src/options.js\");\nvar utils = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\nvar NafLogger = __webpack_require__(/*! ./NafLogger */ \"./src/NafLogger.js\");\nvar Schemas = __webpack_require__(/*! ./Schemas */ \"./src/Schemas.js\");\nvar NetworkEntities = __webpack_require__(/*! ./NetworkEntities */ \"./src/NetworkEntities.js\");\nvar NetworkConnection = __webpack_require__(/*! ./NetworkConnection */ \"./src/NetworkConnection.js\");\nvar AdapterFactory = __webpack_require__(/*! ./adapters/AdapterFactory */ \"./src/adapters/AdapterFactory.js\");\nvar naf = {};\nnaf.app = '';\nnaf.room = '';\nnaf.clientId = '';\nnaf.options = options;\nnaf.utils = utils;\nnaf.log = new NafLogger();\nnaf.schemas = new Schemas();\nnaf.version = \"0.14.0\";\nnaf.adapters = new AdapterFactory();\nvar entities = new NetworkEntities();\nvar connection = new NetworkConnection(entities);\nnaf.connection = connection;\nnaf.entities = entities;\nmodule.exports = window.NAF = naf;\n\n//# sourceURL=webpack://networked-aframe/./src/NafIndex.js?");

/***/ }),

/***/ "./src/NafInterface.js":
/*!*****************************!*\
  !*** ./src/NafInterface.js ***!
  \*****************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar NafInterface = /*#__PURE__*/function () {\n  function NafInterface() {\n    _classCallCheck(this, NafInterface);\n  }\n  return _createClass(NafInterface, [{\n    key: \"notImplemented\",\n    value: function notImplemented(name) {\n      NAF.log.error('Interface method not implemented:', name);\n    }\n  }]);\n}();\nmodule.exports = NafInterface;\n\n//# sourceURL=webpack://networked-aframe/./src/NafInterface.js?");

/***/ }),

/***/ "./src/NafLogger.js":
/*!**************************!*\
  !*** ./src/NafLogger.js ***!
  \**************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/*eslint no-console: \"off\" */\nvar NafLogger = /*#__PURE__*/function () {\n  function NafLogger() {\n    _classCallCheck(this, NafLogger);\n    this.debug = false;\n  }\n  return _createClass(NafLogger, [{\n    key: \"setDebug\",\n    value: function setDebug(debug) {\n      this.debug = debug;\n    }\n  }, {\n    key: \"write\",\n    value: function write() {\n      if (this.debug) {\n        console.log.apply(this, arguments);\n      }\n    }\n  }, {\n    key: \"warn\",\n    value: function warn() {\n      console.warn.apply(this, arguments);\n    }\n  }, {\n    key: \"error\",\n    value: function error() {\n      console.error.apply(this, arguments);\n    }\n  }]);\n}();\nmodule.exports = NafLogger;\n\n//# sourceURL=webpack://networked-aframe/./src/NafLogger.js?");

/***/ }),

/***/ "./src/NetworkConnection.js":
/*!**********************************!*\
  !*** ./src/NetworkConnection.js ***!
  \**********************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar ReservedDataType = {\n  Update: 'u',\n  UpdateMulti: 'um',\n  Remove: 'r'\n};\nvar NetworkConnection = /*#__PURE__*/function () {\n  function NetworkConnection(networkEntities) {\n    _classCallCheck(this, NetworkConnection);\n    this.entities = networkEntities;\n    this.setupDefaultDataSubscriptions();\n    this.connectedClients = {};\n    this.activeDataChannels = {};\n  }\n  return _createClass(NetworkConnection, [{\n    key: \"setNetworkAdapter\",\n    value: function setNetworkAdapter(adapter) {\n      this.adapter = adapter;\n    }\n  }, {\n    key: \"setupDefaultDataSubscriptions\",\n    value: function setupDefaultDataSubscriptions() {\n      this.dataChannelSubs = {};\n      this.dataChannelSubs[ReservedDataType.Update] = this.entities.updateEntity.bind(this.entities);\n      this.dataChannelSubs[ReservedDataType.UpdateMulti] = this.entities.updateEntityMulti.bind(this.entities);\n      this.dataChannelSubs[ReservedDataType.Remove] = this.entities.removeRemoteEntity.bind(this.entities);\n    }\n  }, {\n    key: \"connect\",\n    value: function connect(serverUrl, appName, roomName) {\n      var enableAudio = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n      var enableVideo = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;\n      NAF.app = appName;\n      NAF.room = roomName;\n      this.adapter.setServerUrl(serverUrl);\n      this.adapter.setApp(appName);\n      this.adapter.setRoom(roomName);\n      var webrtcOptions = {\n        audio: enableAudio,\n        video: enableVideo,\n        datachannel: true\n      };\n      this.adapter.setWebRtcOptions(webrtcOptions);\n      this.adapter.setServerConnectListeners(this.connectSuccess.bind(this), this.connectFailure.bind(this));\n      this.adapter.setDataChannelListeners(this.dataChannelOpen.bind(this), this.dataChannelClosed.bind(this), this.receivedData.bind(this));\n      this.adapter.setRoomOccupantListener(this.occupantsReceived.bind(this));\n      return this.adapter.connect();\n    }\n  }, {\n    key: \"onConnect\",\n    value: function onConnect(callback) {\n      this.onConnectCallback = callback;\n      if (this.isConnected()) {\n        callback();\n      } else {\n        document.body.addEventListener('connected', callback, false);\n      }\n    }\n  }, {\n    key: \"connectSuccess\",\n    value: function connectSuccess(clientId) {\n      NAF.log.write('Networked-Aframe Client ID:', clientId);\n      NAF.clientId = clientId;\n      var evt = new CustomEvent('connected', {\n        'detail': {\n          clientId: clientId\n        }\n      });\n      document.body.dispatchEvent(evt);\n    }\n  }, {\n    key: \"connectFailure\",\n    value: function connectFailure(errorCode, message) {\n      NAF.log.error(errorCode, \"failure to connect\");\n    }\n  }, {\n    key: \"occupantsReceived\",\n    value: function occupantsReceived(occupantList) {\n      var prevConnectedClients = Object.assign({}, this.connectedClients);\n      this.connectedClients = occupantList;\n      this.checkForDisconnectingClients(prevConnectedClients, occupantList);\n      this.checkForConnectingClients(occupantList);\n    }\n  }, {\n    key: \"checkForDisconnectingClients\",\n    value: function checkForDisconnectingClients(oldOccupantList, newOccupantList) {\n      for (var id in oldOccupantList) {\n        var clientFound = newOccupantList[id];\n        if (!clientFound) {\n          NAF.log.write('Closing stream to', id);\n          this.adapter.closeStreamConnection(id);\n        }\n      }\n    }\n\n    // Some adapters will handle this internally\n  }, {\n    key: \"checkForConnectingClients\",\n    value: function checkForConnectingClients(occupantList) {\n      for (var id in occupantList) {\n        var startConnection = this.isNewClient(id) && this.adapter.shouldStartConnectionTo(occupantList[id]);\n        if (startConnection) {\n          NAF.log.write('Opening datachannel to', id);\n          this.adapter.startStreamConnection(id);\n        }\n      }\n    }\n  }, {\n    key: \"getConnectedClients\",\n    value: function getConnectedClients() {\n      return this.connectedClients;\n    }\n  }, {\n    key: \"isConnected\",\n    value: function isConnected() {\n      return !!NAF.clientId;\n    }\n  }, {\n    key: \"isMineAndConnected\",\n    value: function isMineAndConnected(clientId) {\n      return this.isConnected() && NAF.clientId === clientId;\n    }\n  }, {\n    key: \"isNewClient\",\n    value: function isNewClient(clientId) {\n      return !this.isConnectedTo(clientId);\n    }\n  }, {\n    key: \"isConnectedTo\",\n    value: function isConnectedTo(clientId) {\n      return this.adapter.getConnectStatus(clientId) === NAF.adapters.IS_CONNECTED;\n    }\n  }, {\n    key: \"dataChannelOpen\",\n    value: function dataChannelOpen(clientId) {\n      NAF.log.write('Opened data channel from ' + clientId);\n      this.activeDataChannels[clientId] = true;\n      this.entities.completeSync(clientId, true);\n      var evt = new CustomEvent('clientConnected', {\n        detail: {\n          clientId: clientId\n        }\n      });\n      document.body.dispatchEvent(evt);\n    }\n  }, {\n    key: \"dataChannelClosed\",\n    value: function dataChannelClosed(clientId) {\n      NAF.log.write('Closed data channel from ' + clientId);\n      this.activeDataChannels[clientId] = false;\n      this.entities.removeEntitiesOfClient(clientId);\n      var evt = new CustomEvent('clientDisconnected', {\n        detail: {\n          clientId: clientId\n        }\n      });\n      document.body.dispatchEvent(evt);\n    }\n  }, {\n    key: \"hasActiveDataChannel\",\n    value: function hasActiveDataChannel(clientId) {\n      return !!this.activeDataChannels[clientId];\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(dataType, data) {\n      this.adapter.broadcastData(dataType, data);\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(dataType, data) {\n      this.adapter.broadcastDataGuaranteed(dataType, data);\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(toClientId, dataType, data, guaranteed) {\n      if (this.hasActiveDataChannel(toClientId)) {\n        if (guaranteed) {\n          this.adapter.sendDataGuaranteed(toClientId, dataType, data);\n        } else {\n          this.adapter.sendData(toClientId, dataType, data);\n        }\n      } else {\n        // console.error(\"NOT-CONNECTED\", \"not connected to \" + toClient);\n      }\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(toClientId, dataType, data) {\n      this.sendData(toClientId, dataType, data, true);\n    }\n  }, {\n    key: \"subscribeToDataChannel\",\n    value: function subscribeToDataChannel(dataType, callback) {\n      if (this.isReservedDataType(dataType)) {\n        NAF.log.error('NetworkConnection@subscribeToDataChannel: ' + dataType + ' is a reserved dataType. Choose another');\n        return;\n      }\n      this.dataChannelSubs[dataType] = callback;\n    }\n  }, {\n    key: \"unsubscribeToDataChannel\",\n    value: function unsubscribeToDataChannel(dataType) {\n      if (this.isReservedDataType(dataType)) {\n        NAF.log.error('NetworkConnection@unsubscribeToDataChannel: ' + dataType + ' is a reserved dataType. Choose another');\n        return;\n      }\n      delete this.dataChannelSubs[dataType];\n    }\n  }, {\n    key: \"isReservedDataType\",\n    value: function isReservedDataType(dataType) {\n      return dataType == ReservedDataType.Update || dataType == ReservedDataType.Remove;\n    }\n  }, {\n    key: \"receivedData\",\n    value: function receivedData(fromClientId, dataType, data, source) {\n      if (this.dataChannelSubs[dataType]) {\n        this.dataChannelSubs[dataType](fromClientId, dataType, data, source);\n      } else {\n        NAF.log.write('NetworkConnection@receivedData: ' + dataType + ' has not been subscribed to yet. Call subscribeToDataChannel()');\n      }\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return this.adapter.getServerTime();\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.entities.removeRemoteEntities();\n      if (this.adapter) {\n        this.adapter.disconnect();\n      }\n      NAF.app = '';\n      NAF.room = '';\n      NAF.clientId = '';\n      this.connectedClients = {};\n      this.activeDataChannels = {};\n      this.adapter = null;\n      this.setupDefaultDataSubscriptions();\n      document.body.removeEventListener('connected', this.onConnectCallback);\n    }\n  }]);\n}();\nmodule.exports = NetworkConnection;\n\n//# sourceURL=webpack://networked-aframe/./src/NetworkConnection.js?");

/***/ }),

/***/ "./src/NetworkEntities.js":
/*!********************************!*\
  !*** ./src/NetworkEntities.js ***!
  \********************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar ChildEntityCache = __webpack_require__(/*! ./ChildEntityCache */ \"./src/ChildEntityCache.js\");\nvar NetworkEntities = /*#__PURE__*/function () {\n  function NetworkEntities() {\n    _classCallCheck(this, NetworkEntities);\n    this.entities = {};\n    this.childCache = new ChildEntityCache();\n    this.onRemoteEntityCreatedEvent = new Event('remoteEntityCreated');\n    this._persistentFirstSyncs = {};\n  }\n  return _createClass(NetworkEntities, [{\n    key: \"registerEntity\",\n    value: function registerEntity(networkId, entity) {\n      this.entities[networkId] = entity;\n    }\n  }, {\n    key: \"createRemoteEntity\",\n    value: function createRemoteEntity(entityData) {\n      NAF.log.write('Creating remote entity', entityData);\n      var networkId = entityData.networkId;\n      var el = NAF.schemas.getCachedTemplate(entityData.template);\n      this.initPosition(el, entityData.components);\n      this.initRotation(el, entityData.components);\n      this.addNetworkComponent(el, entityData);\n      this.registerEntity(networkId, el);\n      return el;\n    }\n  }, {\n    key: \"initPosition\",\n    value: function initPosition(entity, componentData) {\n      var hasPosition = componentData['position'];\n      if (hasPosition) {\n        var position = componentData.position;\n        entity.setAttribute('position', position);\n      }\n    }\n  }, {\n    key: \"initRotation\",\n    value: function initRotation(entity, componentData) {\n      var hasRotation = componentData['rotation'];\n      if (hasRotation) {\n        var rotation = componentData.rotation;\n        entity.setAttribute('rotation', rotation);\n      }\n    }\n  }, {\n    key: \"addNetworkComponent\",\n    value: function addNetworkComponent(entity, entityData) {\n      var networkData = {\n        template: entityData.template,\n        creator: entityData.creator,\n        owner: entityData.owner,\n        networkId: entityData.networkId,\n        persistent: entityData.persistent\n      };\n      entity.setAttribute('networked', networkData);\n      entity.firstUpdateData = entityData;\n    }\n  }, {\n    key: \"updateEntityMulti\",\n    value: function updateEntityMulti(client, dataType, entityDatas, source) {\n      if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n      for (var i = 0, l = entityDatas.d.length; i < l; i++) {\n        this.updateEntity(client, 'u', entityDatas.d[i], source);\n      }\n    }\n  }, {\n    key: \"updateEntity\",\n    value: function updateEntity(client, dataType, entityData, source) {\n      if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n      var networkId = entityData.networkId;\n      if (this.hasEntity(networkId)) {\n        this.entities[networkId].components.networked.networkUpdate(entityData);\n      } else if (entityData.isFirstSync && NAF.connection.activeDataChannels[entityData.owner] !== false) {\n        if (NAF.options.firstSyncSource && source !== NAF.options.firstSyncSource) {\n          NAF.log.write('Ignoring first sync from disallowed source', source);\n        } else {\n          if (entityData.persistent) {\n            // If we receive a firstSync for a persistent entity that we don't have yet,\n            // we assume the scene will create it at some point, so stash the update for later use.\n            this._persistentFirstSyncs[networkId] = entityData;\n          } else {\n            this.receiveFirstUpdateFromEntity(entityData);\n          }\n        }\n      }\n    }\n  }, {\n    key: \"receiveFirstUpdateFromEntity\",\n    value: function receiveFirstUpdateFromEntity(entityData) {\n      var parent = entityData.parent;\n      var networkId = entityData.networkId;\n      var parentNotCreatedYet = parent && !this.hasEntity(parent);\n      if (parentNotCreatedYet) {\n        this.childCache.addChild(parent, entityData);\n      } else {\n        var remoteEntity = this.createRemoteEntity(entityData);\n        this.createAndAppendChildren(networkId, remoteEntity);\n        this.addEntityToPage(remoteEntity, parent);\n      }\n    }\n  }, {\n    key: \"createAndAppendChildren\",\n    value: function createAndAppendChildren(parentId, parentEntity) {\n      var children = this.childCache.getChildren(parentId);\n      for (var i = 0; i < children.length; i++) {\n        var childEntityData = children[i];\n        var childId = childEntityData.networkId;\n        if (this.hasEntity(childId)) {\n          NAF.log.warn('Tried to instantiate entity multiple times', childId, childEntityData, 'Existing entity:', this.getEntity(childId));\n          continue;\n        }\n        var childEntity = this.createRemoteEntity(childEntityData);\n        this.createAndAppendChildren(childId, childEntity);\n        parentEntity.appendChild(childEntity);\n      }\n    }\n  }, {\n    key: \"addEntityToPage\",\n    value: function addEntityToPage(entity, parentId) {\n      if (this.hasEntity(parentId)) {\n        this.addEntityToParent(entity, parentId);\n      } else {\n        this.addEntityToSceneRoot(entity);\n      }\n    }\n  }, {\n    key: \"addEntityToParent\",\n    value: function addEntityToParent(entity, parentId) {\n      this.entities[parentId].appendChild(entity);\n    }\n  }, {\n    key: \"addEntityToSceneRoot\",\n    value: function addEntityToSceneRoot(el) {\n      var scene = document.querySelector('a-scene');\n      scene.appendChild(el);\n    }\n  }, {\n    key: \"completeSync\",\n    value: function completeSync(targetClientId, isFirstSync) {\n      for (var id in this.entities) {\n        if (this.entities[id]) {\n          this.entities[id].components.networked.syncAll(targetClientId, isFirstSync);\n        }\n      }\n    }\n  }, {\n    key: \"removeRemoteEntity\",\n    value: function removeRemoteEntity(toClient, dataType, data, source) {\n      if (NAF.options.syncSource && source !== NAF.options.syncSource) return;\n      var id = data.networkId;\n      return this.removeEntity(id);\n    }\n  }, {\n    key: \"removeEntitiesOfClient\",\n    value: function removeEntitiesOfClient(clientId) {\n      var removedEntities = [];\n      for (var id in this.entities) {\n        var entity = this.entities[id];\n        var creator = NAF.utils.getCreator(entity);\n        var owner = NAF.utils.getNetworkOwner(entity);\n        if (creator === clientId || !creator && owner === clientId) {\n          var component = this.entities[id].getAttribute(\"networked\");\n          if (component && component.persistent) {\n            // everyone will attempt to take ownership, someone will win, it does not particularly matter who\n            NAF.utils.takeOwnership(entity);\n          } else {\n            removedEntities.push(this.removeEntity(id));\n          }\n        }\n      }\n      return removedEntities;\n    }\n  }, {\n    key: \"removeEntity\",\n    value: function removeEntity(id) {\n      this.forgetPersistentFirstSync(id);\n      if (this.hasEntity(id)) {\n        var entity = this.entities[id];\n        this.forgetEntity(id);\n        entity.parentNode.removeChild(entity);\n        return entity;\n      } else {\n        NAF.log.error(\"Tried to remove entity I don't have.\");\n        return null;\n      }\n    }\n  }, {\n    key: \"forgetEntity\",\n    value: function forgetEntity(id) {\n      delete this.entities[id];\n      this.forgetPersistentFirstSync(id);\n    }\n  }, {\n    key: \"getPersistentFirstSync\",\n    value: function getPersistentFirstSync(id) {\n      return this._persistentFirstSyncs[id];\n    }\n  }, {\n    key: \"forgetPersistentFirstSync\",\n    value: function forgetPersistentFirstSync(id) {\n      delete this._persistentFirstSyncs[id];\n    }\n  }, {\n    key: \"getEntity\",\n    value: function getEntity(id) {\n      if (this.entities[id]) {\n        return this.entities[id];\n      }\n      return null;\n    }\n  }, {\n    key: \"hasEntity\",\n    value: function hasEntity(id) {\n      return !!this.entities[id];\n    }\n  }, {\n    key: \"removeRemoteEntities\",\n    value: function removeRemoteEntities() {\n      this.childCache = new ChildEntityCache();\n      for (var id in this.entities) {\n        var owner = this.entities[id].getAttribute('networked').owner;\n        if (owner != NAF.clientId) {\n          this.removeEntity(id);\n        }\n      }\n    }\n  }]);\n}();\nmodule.exports = NetworkEntities;\n\n//# sourceURL=webpack://networked-aframe/./src/NetworkEntities.js?");

/***/ }),

/***/ "./src/Schemas.js":
/*!************************!*\
  !*** ./src/Schemas.js ***!
  \************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar Schemas = /*#__PURE__*/function () {\n  function Schemas() {\n    _classCallCheck(this, Schemas);\n    this.schemaDict = {};\n    this.templateCache = {};\n  }\n  return _createClass(Schemas, [{\n    key: \"createDefaultSchema\",\n    value: function createDefaultSchema(name) {\n      return {\n        template: name,\n        components: ['position', 'rotation']\n      };\n    }\n  }, {\n    key: \"add\",\n    value: function add(schema) {\n      if (this.validateSchema(schema)) {\n        this.schemaDict[schema.template] = schema;\n        var templateEl = document.querySelector(schema.template);\n        if (!templateEl) {\n          NAF.log.error(\"Template el not found for \".concat(schema.template, \", make sure NAF.schemas.add is called after <a-scene> is defined.\"));\n          return;\n        }\n        if (!this.validateTemplate(schema, templateEl)) {\n          return;\n        }\n        this.templateCache[schema.template] = document.importNode(templateEl.content, true);\n      } else {\n        NAF.log.error('Schema not valid: ', schema);\n        NAF.log.error('See https://github.com/networked-aframe/networked-aframe#syncing-custom-components');\n      }\n    }\n  }, {\n    key: \"getCachedTemplate\",\n    value: function getCachedTemplate(template) {\n      if (!this.templateIsCached(template)) {\n        if (this.templateExistsInScene(template)) {\n          this.add(this.createDefaultSchema(template));\n        } else {\n          NAF.log.error(\"Template el for \".concat(template, \" is not in the scene, add the template to <a-assets> and register with NAF.schemas.add.\"));\n        }\n      }\n      return this.templateCache[template].firstElementChild.cloneNode(true);\n    }\n  }, {\n    key: \"templateIsCached\",\n    value: function templateIsCached(template) {\n      return !!this.templateCache[template];\n    }\n  }, {\n    key: \"getComponents\",\n    value: function getComponents(template) {\n      var components = ['position', 'rotation'];\n      if (this.hasTemplate(template)) {\n        components = this.schemaDict[template].components;\n      }\n      return components;\n    }\n  }, {\n    key: \"hasTemplate\",\n    value: function hasTemplate(template) {\n      return !!this.schemaDict[template];\n    }\n  }, {\n    key: \"templateExistsInScene\",\n    value: function templateExistsInScene(templateSelector) {\n      var el = document.querySelector(templateSelector);\n      return el && this.isTemplateTag(el);\n    }\n  }, {\n    key: \"validateSchema\",\n    value: function validateSchema(schema) {\n      return !!(schema['template'] && schema['components']);\n    }\n  }, {\n    key: \"validateTemplate\",\n    value: function validateTemplate(schema, el) {\n      if (!this.isTemplateTag(el)) {\n        NAF.log.error(\"Template for \".concat(schema.template, \" is not a <template> tag. Instead found: \").concat(el.tagName));\n        return false;\n      } else if (!this.templateHasOneOrZeroChildren(el)) {\n        NAF.log.error(\"Template for \".concat(schema.template, \" has more than one child. Templates must have one direct child element, no more. Template found:\"), el);\n        return false;\n      } else {\n        return true;\n      }\n    }\n  }, {\n    key: \"isTemplateTag\",\n    value: function isTemplateTag(el) {\n      return el.tagName.toLowerCase() === 'template';\n    }\n  }, {\n    key: \"templateHasOneOrZeroChildren\",\n    value: function templateHasOneOrZeroChildren(el) {\n      return el.content.childElementCount < 2;\n    }\n  }, {\n    key: \"remove\",\n    value: function remove(template) {\n      delete this.schemaDict[template];\n    }\n  }, {\n    key: \"clear\",\n    value: function clear() {\n      this.schemaDict = {};\n    }\n  }]);\n}();\nmodule.exports = Schemas;\n\n//# sourceURL=webpack://networked-aframe/./src/Schemas.js?");

/***/ }),

/***/ "./src/adapters/AdapterFactory.js":
/*!****************************************!*\
  !*** ./src/adapters/AdapterFactory.js ***!
  \****************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nvar WsEasyRtcAdapter = __webpack_require__(/*! ./WsEasyRtcAdapter */ \"./src/adapters/WsEasyRtcAdapter.js\");\nvar EasyRtcAdapter = __webpack_require__(/*! ./EasyRtcAdapter */ \"./src/adapters/EasyRtcAdapter.js\");\nvar WebrtcAdapter = __webpack_require__(/*! ./naf-webrtc-adapter */ \"./src/adapters/naf-webrtc-adapter.js\");\nvar SocketioAdapter = __webpack_require__(/*! ./naf-socketio-adapter */ \"./src/adapters/naf-socketio-adapter.js\");\nvar UWSAdapter = __webpack_require__(/*! ./naf-uws-adapter */ \"./src/adapters/naf-uws-adapter.js\");\nvar AdapterFactory = /*#__PURE__*/function () {\n  function AdapterFactory() {\n    _classCallCheck(this, AdapterFactory);\n    this.adapters = {\n      \"wseasyrtc\": WsEasyRtcAdapter,\n      \"easyrtc\": EasyRtcAdapter,\n      \"socketio\": SocketioAdapter,\n      \"webrtc\": WebrtcAdapter,\n      \"uws\": UWSAdapter\n    };\n    this.IS_CONNECTED = AdapterFactory.IS_CONNECTED;\n    this.CONNECTING = AdapterFactory.CONNECTING;\n    this.NOT_CONNECTED = AdapterFactory.NOT_CONNECTED;\n  }\n  return _createClass(AdapterFactory, [{\n    key: \"register\",\n    value: function register(adapterName, AdapterClass) {\n      this.adapters[adapterName] = AdapterClass;\n    }\n  }, {\n    key: \"make\",\n    value: function make(adapterName) {\n      var name = adapterName.toLowerCase();\n      if (this.adapters[name]) {\n        var AdapterClass = this.adapters[name];\n        return new AdapterClass();\n      } else {\n        throw new Error(\"Adapter: \" + adapterName + \" not registered. Please use NAF.adapters.register() to register this adapter.\");\n      }\n    }\n  }]);\n}();\nAdapterFactory.IS_CONNECTED = \"IS_CONNECTED\";\nAdapterFactory.CONNECTING = \"CONNECTING\";\nAdapterFactory.NOT_CONNECTED = \"NOT_CONNECTED\";\nmodule.exports = AdapterFactory;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/AdapterFactory.js?");

/***/ }),

/***/ "./src/adapters/EasyRtcAdapter.js":
/*!****************************************!*\
  !*** ./src/adapters/EasyRtcAdapter.js ***!
  \****************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n/* global NAF */\nvar NoOpAdapter = __webpack_require__(/*! ./NoOpAdapter */ \"./src/adapters/NoOpAdapter.js\");\nvar EasyRtcAdapter = /*#__PURE__*/function (_NoOpAdapter) {\n  function EasyRtcAdapter(easyrtc) {\n    var _this;\n    _classCallCheck(this, EasyRtcAdapter);\n    _this = _callSuper(this, EasyRtcAdapter);\n    _this.easyrtc = easyrtc || window.easyrtc;\n    _this.app = \"default\";\n    _this.room = \"default\";\n    _this.destination = {\n      targetRoom: _this.room\n    };\n    _this.mediaStreams = {};\n    _this.remoteClients = {};\n    _this.pendingMediaRequests = new Map();\n    _this.serverTimeRequests = 0;\n    _this.timeOffsets = [];\n    _this.avgTimeOffset = 0;\n    _this.easyrtc.setPeerOpenListener(function (clientId) {\n      var clientConnection = _this.easyrtc.getPeerConnectionByUserId(clientId);\n      _this.remoteClients[clientId] = clientConnection;\n    });\n    _this.easyrtc.setPeerClosedListener(function (clientId) {\n      delete _this.remoteClients[clientId];\n      var pendingMediaRequests = _this.pendingMediaRequests.get(clientId);\n      if (pendingMediaRequests) {\n        var msg = \"The user disconnected before the media stream was resolved.\";\n        Object.keys(pendingMediaRequests).forEach(function (streamName) {\n          pendingMediaRequests[streamName].reject(msg);\n        });\n        _this.pendingMediaRequests[\"delete\"](clientId);\n      }\n    });\n    return _this;\n  }\n  _inherits(EasyRtcAdapter, _NoOpAdapter);\n  return _createClass(EasyRtcAdapter, [{\n    key: \"setServerUrl\",\n    value: function setServerUrl(url) {\n      this.easyrtc.setSocketUrl(url);\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(appName) {\n      this.app = appName;\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.room = roomName;\n      this.destination.targetRoom = this.room;\n      this.easyrtc.joinRoom(roomName, null);\n    }\n\n    // options: { datachannel: bool, audio: bool, video: bool }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      // this.easyrtc.enableDebug(true);\n      this.easyrtc.enableDataChannels(options.datachannel);\n      this.easyrtc.enableVideo(options.video);\n      this.easyrtc.enableAudio(options.audio);\n\n      // TODO receive(audio|video) options ?\n      this.easyrtc.enableVideoReceive(true);\n      this.easyrtc.enableAudioReceive(true);\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.connectSuccess = successListener;\n      this.connectFailure = failureListener;\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.easyrtc.setRoomOccupantListener(function (roomName, occupants, primary) {\n        occupantListener(occupants);\n      });\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.easyrtc.setDataChannelOpenListener(openListener);\n      this.easyrtc.setDataChannelCloseListener(closedListener);\n      this.easyrtc.setPeerListener(messageListener);\n    }\n  }, {\n    key: \"updateTimeOffset\",\n    value: function updateTimeOffset() {\n      var _this2 = this;\n      var clientSentTime = Date.now() + this.avgTimeOffset;\n      return fetch(document.location.href, {\n        method: \"HEAD\",\n        cache: \"no-cache\"\n      }).then(function (res) {\n        var precision = 1000;\n        var serverReceivedTime = new Date(res.headers.get(\"Date\")).getTime() + precision / 2;\n        var clientReceivedTime = Date.now();\n        var serverTime = serverReceivedTime + (clientReceivedTime - clientSentTime) / 2;\n        var timeOffset = serverTime - clientReceivedTime;\n        _this2.serverTimeRequests++;\n        if (_this2.serverTimeRequests <= 10) {\n          _this2.timeOffsets.push(timeOffset);\n        } else {\n          _this2.timeOffsets[_this2.serverTimeRequests % 10] = timeOffset;\n        }\n        _this2.avgTimeOffset = _this2.timeOffsets.reduce(function (acc, offset) {\n          return acc += offset;\n        }, 0) / _this2.timeOffsets.length;\n        if (_this2.serverTimeRequests > 10) {\n          setTimeout(function () {\n            return _this2.updateTimeOffset();\n          }, 5 * 60 * 1000); // Sync clock every 5 minutes.\n        } else {\n          _this2.updateTimeOffset();\n        }\n      });\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      var _this3 = this;\n      Promise.all([this.updateTimeOffset(), new Promise(function (resolve, reject) {\n        _this3._connect(resolve, reject);\n      })]).then(function (_ref) {\n        var _ref2 = _slicedToArray(_ref, 2),\n          _ = _ref2[0],\n          clientId = _ref2[1];\n        _this3._myRoomJoinTime = _this3._getRoomJoinTime(clientId);\n        _this3.connectSuccess(clientId);\n      })[\"catch\"](this.connectFailure);\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(client) {\n      return this._myRoomJoinTime <= client.roomJoinTime;\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(clientId) {\n      this.easyrtc.call(clientId, function (caller, media) {\n        if (media === \"datachannel\") {\n          NAF.log.write(\"Successfully started datachannel to \", caller);\n        }\n      }, function (errorCode, errorText) {\n        NAF.log.error(errorCode, errorText);\n      }, function (wasAccepted) {\n        // console.log(\"was accepted=\" + wasAccepted);\n      });\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      this.easyrtc.hangup(clientId);\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(clientId, dataType, data) {\n      // send via webrtc otherwise fallback to websockets\n      this.easyrtc.sendData(clientId, dataType, data);\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(clientId, dataType, data) {\n      this.easyrtc.sendDataWS(clientId, dataType, data);\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(dataType, data) {\n      var roomOccupants = this.easyrtc.getRoomOccupantsAsMap(this.room);\n\n      // Iterate over the keys of the easyrtc room occupants map.\n      // getRoomOccupantsAsArray uses Object.keys which allocates memory.\n      for (var roomOccupant in roomOccupants) {\n        if (roomOccupants[roomOccupant] && roomOccupant !== this.easyrtc.myEasyrtcid) {\n          // send via webrtc otherwise fallback to websockets\n          this.easyrtc.sendData(roomOccupant, dataType, data);\n        }\n      }\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(dataType, data) {\n      this.easyrtc.sendDataWS(this.destination, dataType, data);\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      var status = this.easyrtc.getConnectStatus(clientId);\n      if (status == this.easyrtc.IS_CONNECTED) {\n        return NAF.adapters.IS_CONNECTED;\n      } else if (status == this.easyrtc.NOT_CONNECTED) {\n        return NAF.adapters.NOT_CONNECTED;\n      } else {\n        return NAF.adapters.CONNECTING;\n      }\n    }\n  }, {\n    key: \"getMediaStream\",\n    value: function getMediaStream(clientId) {\n      var streamName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : \"audio\";\n      if (this.mediaStreams[clientId] && this.mediaStreams[clientId][streamName]) {\n        NAF.log.write(\"Already had \".concat(streamName, \" for \").concat(clientId));\n        return Promise.resolve(this.mediaStreams[clientId][streamName]);\n      } else {\n        NAF.log.write(\"Waiting on \".concat(streamName, \" for \").concat(clientId));\n\n        // Create initial pendingMediaRequests with audio|video alias\n        if (!this.pendingMediaRequests.has(clientId)) {\n          var _pendingMediaRequests = {};\n          var audioPromise = new Promise(function (resolve, reject) {\n            _pendingMediaRequests.audio = {\n              resolve: resolve,\n              reject: reject\n            };\n          })[\"catch\"](function (e) {\n            return NAF.log.warn(\"\".concat(clientId, \" getMediaStream Audio Error\"), e);\n          });\n          _pendingMediaRequests.audio.promise = audioPromise;\n          var videoPromise = new Promise(function (resolve, reject) {\n            _pendingMediaRequests.video = {\n              resolve: resolve,\n              reject: reject\n            };\n          })[\"catch\"](function (e) {\n            return NAF.log.warn(\"\".concat(clientId, \" getMediaStream Video Error\"), e);\n          });\n          _pendingMediaRequests.video.promise = videoPromise;\n          this.pendingMediaRequests.set(clientId, _pendingMediaRequests);\n        }\n        var pendingMediaRequests = this.pendingMediaRequests.get(clientId);\n\n        // Create initial pendingMediaRequests with streamName\n        if (!pendingMediaRequests[streamName]) {\n          var streamPromise = new Promise(function (resolve, reject) {\n            pendingMediaRequests[streamName] = {\n              resolve: resolve,\n              reject: reject\n            };\n          })[\"catch\"](function (e) {\n            return NAF.log.warn(\"\".concat(clientId, \" getMediaStream \\\"\").concat(streamName, \"\\\" Error\"), e);\n          });\n          pendingMediaRequests[streamName].promise = streamPromise;\n        }\n        return this.pendingMediaRequests.get(clientId)[streamName].promise;\n      }\n    }\n  }, {\n    key: \"setMediaStream\",\n    value: function setMediaStream(clientId, stream, streamName) {\n      var pendingMediaRequests = this.pendingMediaRequests.get(clientId); // return undefined if there is no entry in the Map\n      var clientMediaStreams = this.mediaStreams[clientId] = this.mediaStreams[clientId] || {};\n      if (streamName === \"default\") {\n        // Safari doesn't like it when you use a mixed media stream where one of the tracks is inactive, so we\n        // split the tracks into two streams.\n        // Add mediaStreams audio streamName alias\n        var audioTracks = stream.getAudioTracks();\n        if (audioTracks.length > 0) {\n          var audioStream = new MediaStream();\n          try {\n            audioTracks.forEach(function (track) {\n              return audioStream.addTrack(track);\n            });\n            clientMediaStreams.audio = audioStream;\n          } catch (e) {\n            NAF.log.warn(\"\".concat(clientId, \" setMediaStream \\\"audio\\\" alias Error\"), e);\n          }\n\n          // Resolve the promise for the user's media stream audio alias if it exists.\n          if (pendingMediaRequests) pendingMediaRequests.audio.resolve(audioStream);\n        }\n\n        // Add mediaStreams video streamName alias\n        var videoTracks = stream.getVideoTracks();\n        if (videoTracks.length > 0) {\n          var videoStream = new MediaStream();\n          try {\n            videoTracks.forEach(function (track) {\n              return videoStream.addTrack(track);\n            });\n            clientMediaStreams.video = videoStream;\n          } catch (e) {\n            NAF.log.warn(\"\".concat(clientId, \" setMediaStream \\\"video\\\" alias Error\"), e);\n          }\n\n          // Resolve the promise for the user's media stream video alias if it exists.\n          if (pendingMediaRequests) pendingMediaRequests.video.resolve(videoStream);\n        }\n      } else {\n        clientMediaStreams[streamName] = stream;\n\n        // Resolve the promise for the user's media stream by StreamName if it exists.\n        if (pendingMediaRequests && pendingMediaRequests[streamName]) {\n          pendingMediaRequests[streamName].resolve(stream);\n          delete pendingMediaRequests[streamName];\n        }\n      }\n    }\n  }, {\n    key: \"addLocalMediaStream\",\n    value: function addLocalMediaStream(stream, streamName) {\n      var easyrtc = this.easyrtc;\n      streamName = streamName || stream.id;\n      this.setMediaStream(\"local\", stream, streamName);\n      easyrtc.register3rdPartyLocalMediaStream(stream, streamName);\n\n      // Add local stream to existing connections\n      Object.keys(this.remoteClients).forEach(function (clientId) {\n        if (easyrtc.getConnectStatus(clientId) !== easyrtc.NOT_CONNECTED) {\n          easyrtc.addStreamToCall(clientId, streamName);\n        }\n      });\n    }\n  }, {\n    key: \"removeLocalMediaStream\",\n    value: function removeLocalMediaStream(streamName) {\n      this.easyrtc.closeLocalMediaStream(streamName);\n      delete this.mediaStreams[\"local\"][streamName];\n    }\n  }, {\n    key: \"enableMicrophone\",\n    value: function enableMicrophone(enabled) {\n      this.easyrtc.enableMicrophone(enabled);\n    }\n  }, {\n    key: \"enableCamera\",\n    value: function enableCamera(enabled) {\n      this.easyrtc.enableCamera(enabled);\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.easyrtc.disconnect();\n    }\n\n    /**\n     * Privates\n     */\n  }, {\n    key: \"_connect\",\n    value: function _connect(connectSuccess, connectFailure) {\n      var that = this;\n      this.easyrtc.setStreamAcceptor(this.setMediaStream.bind(this));\n      this.easyrtc.setOnStreamClosed(function (clientId, stream, streamName) {\n        if (streamName === \"default\") {\n          delete that.mediaStreams[clientId].audio;\n          delete that.mediaStreams[clientId].video;\n        } else {\n          delete that.mediaStreams[clientId][streamName];\n        }\n        if (Object.keys(that.mediaStreams[clientId]).length === 0) {\n          delete that.mediaStreams[clientId];\n        }\n      });\n      if (that.easyrtc.audioEnabled || that.easyrtc.videoEnabled) {\n        navigator.mediaDevices.getUserMedia({\n          video: that.easyrtc.videoEnabled,\n          audio: that.easyrtc.audioEnabled\n        }).then(function (stream) {\n          that.addLocalMediaStream(stream, \"default\");\n          that.easyrtc.connect(that.app, connectSuccess, connectFailure);\n        }, function (errorCode, errmesg) {\n          NAF.log.error(errorCode, errmesg);\n        });\n      } else {\n        that.easyrtc.connect(that.app, connectSuccess, connectFailure);\n      }\n    }\n  }, {\n    key: \"_getRoomJoinTime\",\n    value: function _getRoomJoinTime(clientId) {\n      var myRoomId = NAF.room;\n      var joinTime = this.easyrtc.getRoomOccupantsAsMap(myRoomId)[clientId].roomJoinTime;\n      return joinTime;\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return Date.now() + this.avgTimeOffset;\n    }\n  }]);\n}(NoOpAdapter);\nmodule.exports = EasyRtcAdapter;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/EasyRtcAdapter.js?");

/***/ }),

/***/ "./src/adapters/NoOpAdapter.js":
/*!*************************************!*\
  !*** ./src/adapters/NoOpAdapter.js ***!
  \*************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\nvar NafInterface = __webpack_require__(/*! ../NafInterface */ \"./src/NafInterface.js\");\nvar NoOpAdapter = /*#__PURE__*/function (_NafInterface) {\n  function NoOpAdapter() {\n    _classCallCheck(this, NoOpAdapter);\n    return _callSuper(this, NoOpAdapter, arguments);\n  }\n  _inherits(NoOpAdapter, _NafInterface);\n  return _createClass(NoOpAdapter, [{\n    key: \"setServerUrl\",\n    value: /* Pre-Connect setup methods - Call before `connect` */\n\n    function setServerUrl(url) {\n      this.notImplemented('setServerUrl');\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(app) {\n      this.notImplemented('setApp');\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.notImplemented('setRoom');\n    }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      this.notImplemented('setWebRtcOptions');\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.notImplemented('setServerConnectListeners');\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.notImplemented('setRoomOccupantListener');\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.notImplemented('setDataChannelListeners');\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      this.notImplemented('connect');\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(clientId) {\n      this.notImplemented('shouldStartConnectionTo');\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(clientId) {\n      this.notImplemented('startStreamConnection');\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      this.notImplemented('closeStreamConnection');\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      this.notImplemented('getConnectStatus');\n    }\n  }, {\n    key: \"getMediaStream\",\n    value: function getMediaStream(clientId) {\n      return Promise.reject(\"Interface method not implemented: getMediaStream\");\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      this.notImplemented('getServerTime');\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(clientId, dataType, data) {\n      this.notImplemented('sendData');\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(clientId, dataType, data) {\n      this.notImplemented('sendDataGuaranteed');\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(dataType, data) {\n      this.notImplemented('broadcastData');\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(dataType, data) {\n      this.notImplemented('broadcastDataGuaranteed');\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.notImplemented('disconnect');\n    }\n  }]);\n}(NafInterface);\nmodule.exports = NoOpAdapter;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/NoOpAdapter.js?");

/***/ }),

/***/ "./src/adapters/WsEasyRtcAdapter.js":
/*!******************************************!*\
  !*** ./src/adapters/WsEasyRtcAdapter.js ***!
  \******************************************/
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(r) { if (Array.isArray(r)) return r; }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nfunction _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }\nfunction _possibleConstructorReturn(t, e) { if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e; if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\"); return _assertThisInitialized(t); }\nfunction _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); return e; }\nfunction _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }\nfunction _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }\nfunction _inherits(t, e) { if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, \"prototype\", { writable: !1 }), e && _setPrototypeOf(t, e); }\nfunction _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }\n/* global NAF */\nvar NoOpAdapter = __webpack_require__(/*! ./NoOpAdapter */ \"./src/adapters/NoOpAdapter.js\");\nvar WsEasyRtcInterface = /*#__PURE__*/function (_NoOpAdapter) {\n  function WsEasyRtcInterface(easyrtc) {\n    var _this;\n    _classCallCheck(this, WsEasyRtcInterface);\n    _this = _callSuper(this, WsEasyRtcInterface);\n    _this.easyrtc = easyrtc || window.easyrtc;\n    _this.app = 'default';\n    _this.room = 'default';\n    _this.destination = {\n      targetRoom: _this.room\n    };\n    _this.connectedClients = [];\n    _this.serverTimeRequests = 0;\n    _this.timeOffsets = [];\n    _this.avgTimeOffset = 0;\n    return _this;\n  }\n  _inherits(WsEasyRtcInterface, _NoOpAdapter);\n  return _createClass(WsEasyRtcInterface, [{\n    key: \"setServerUrl\",\n    value: function setServerUrl(url) {\n      this.serverUrl = url;\n      this.easyrtc.setSocketUrl(url);\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(appName) {\n      this.app = appName;\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.room = roomName;\n      this.destination.targetRoom = this.room;\n      this.easyrtc.joinRoom(roomName, null);\n    }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      // No webrtc support\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.connectSuccess = successListener;\n      this.connectFailure = failureListener;\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.easyrtc.setRoomOccupantListener(function (roomName, occupants, primary) {\n        occupantListener(occupants);\n      });\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.openListener = openListener;\n      this.closedListener = closedListener;\n      this.easyrtc.setPeerListener(messageListener);\n    }\n  }, {\n    key: \"updateTimeOffset\",\n    value: function updateTimeOffset() {\n      var _this2 = this;\n      var clientSentTime = Date.now() + this.avgTimeOffset;\n      return fetch(document.location.href, {\n        method: \"HEAD\",\n        cache: \"no-cache\"\n      }).then(function (res) {\n        var precision = 1000;\n        var serverReceivedTime = new Date(res.headers.get(\"Date\")).getTime() + precision / 2;\n        var clientReceivedTime = Date.now();\n        var serverTime = serverReceivedTime + (clientReceivedTime - clientSentTime) / 2;\n        var timeOffset = serverTime - clientReceivedTime;\n        _this2.serverTimeRequests++;\n        if (_this2.serverTimeRequests <= 10) {\n          _this2.timeOffsets.push(timeOffset);\n        } else {\n          _this2.timeOffsets[_this2.serverTimeRequests % 10] = timeOffset;\n        }\n        _this2.avgTimeOffset = _this2.timeOffsets.reduce(function (acc, offset) {\n          return acc += offset;\n        }, 0) / _this2.timeOffsets.length;\n        if (_this2.serverTimeRequests > 10) {\n          setTimeout(function () {\n            return _this2.updateTimeOffset();\n          }, 5 * 60 * 1000); // Sync clock every 5 minutes.\n        } else {\n          _this2.updateTimeOffset();\n        }\n      });\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      var _this3 = this;\n      Promise.all([this.updateTimeOffset(), new Promise(function (resolve, reject) {\n        _this3.easyrtc.connect(_this3.app, resolve, reject);\n      })]).then(function (_ref) {\n        var _ref2 = _slicedToArray(_ref, 2),\n          _ = _ref2[0],\n          clientId = _ref2[1];\n        _this3.connectSuccess(clientId);\n      })[\"catch\"](this.connectFailure);\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(clientId) {\n      return true;\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(clientId) {\n      this.connectedClients.push(clientId);\n      this.openListener(clientId);\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      var index = this.connectedClients.indexOf(clientId);\n      if (index > -1) {\n        this.connectedClients.splice(index, 1);\n      }\n      this.closedListener(clientId);\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(clientId, dataType, data) {\n      this.easyrtc.sendDataWS(clientId, dataType, data);\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(clientId, dataType, data) {\n      this.sendData(clientId, dataType, data);\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(dataType, data) {\n      this.easyrtc.sendDataWS(this.destination, dataType, data);\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(dataType, data) {\n      this.broadcastData(dataType, data);\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      var connected = this.connectedClients.indexOf(clientId) != -1;\n      if (connected) {\n        return NAF.adapters.IS_CONNECTED;\n      } else {\n        return NAF.adapters.NOT_CONNECTED;\n      }\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return Date.now() + this.avgTimeOffset;\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.easyrtc.disconnect();\n    }\n  }]);\n}(NoOpAdapter);\nmodule.exports = WsEasyRtcInterface;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/WsEasyRtcAdapter.js?");

/***/ }),

/***/ "./src/adapters/naf-socketio-adapter.js":
/*!**********************************************!*\
  !*** ./src/adapters/naf-socketio-adapter.js ***!
  \**********************************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF, io */\n/**\n * SocketIO Adapter (socketio)\n * networked-scene: serverURL needs to be ws://localhost:8080 when running locally\n */\nvar SocketioAdapter = /*#__PURE__*/function () {\n  function SocketioAdapter() {\n    _classCallCheck(this, SocketioAdapter);\n    if (io === undefined) console.warn('It looks like socket.io has not been loaded before SocketioAdapter. Please do that.');\n    this.app = 'default';\n    this.room = 'default';\n    this.occupantListener = null;\n    this.myRoomJoinTime = null;\n    this.myId = null;\n    this.packet = {\n      from: undefined,\n      to: undefined,\n      type: undefined,\n      data: undefined\n    };\n    this.occupants = {}; // id -> joinTimestamp\n    this.connectedClients = [];\n    this.serverTimeRequests = 0;\n    this.timeOffsets = [];\n    this.avgTimeOffset = 0;\n  }\n  return _createClass(SocketioAdapter, [{\n    key: \"setServerUrl\",\n    value: function setServerUrl(wsUrl) {\n      this.wsUrl = wsUrl;\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(appName) {\n      this.app = appName;\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.room = roomName;\n    }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      // No WebRTC support\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.connectSuccess = successListener;\n      this.connectFailure = failureListener;\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.occupantListener = occupantListener;\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.openListener = openListener;\n      this.closedListener = closedListener;\n      this.messageListener = messageListener;\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      var _this = this;\n      var self = this;\n      this.updateTimeOffset().then(function () {\n        if (!self.wsUrl || self.wsUrl === '/') {\n          if (location.protocol === 'https:') {\n            self.wsUrl = 'wss://' + location.host;\n          } else {\n            self.wsUrl = 'ws://' + location.host;\n          }\n        }\n        NAF.log.write('Attempting to connect to socket.io');\n        var socket = self.socket = io(self.wsUrl);\n        socket.on('connect', function () {\n          if (NAF.clientId) {\n            // The server restarted quickly and we got a new socket without\n            // getting in the error handler.\n            self.onDisconnect();\n          }\n          NAF.log.write('User connected', socket.id);\n          self.myId = socket.id;\n          self.joinRoom();\n        });\n        socket.on('connectSuccess', function (data) {\n          var joinedTime = data.joinedTime;\n          self.myRoomJoinTime = joinedTime;\n          NAF.log.write('Successfully joined room', self.room, 'at server time', joinedTime);\n          self.connectSuccess(self.myId);\n        });\n        socket.io.on('error', function (err) {\n          console.error('Socket connection failure', err);\n          _this.onDisconnect();\n        });\n        socket.on('occupantsChanged', function (data) {\n          var occupants = data.occupants;\n          NAF.log.write('occupants changed', data);\n          self.receivedOccupants(occupants);\n        });\n        function receiveData(packet) {\n          var from = packet.from;\n          var type = packet.type;\n          var data = packet.data;\n          self.messageListener(from, type, data);\n        }\n        socket.on('send', receiveData);\n        socket.on('broadcast', receiveData);\n      });\n    }\n  }, {\n    key: \"joinRoom\",\n    value: function joinRoom() {\n      NAF.log.write('Joining room', this.room);\n      this.socket.emit('joinRoom', {\n        room: this.room\n      });\n    }\n  }, {\n    key: \"receivedOccupants\",\n    value: function receivedOccupants(occupants) {\n      delete occupants[this.myId];\n      this.occupants = occupants;\n      this.occupantListener(occupants);\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(client) {\n      return true;\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(remoteId) {\n      this.connectedClients.push(remoteId);\n      this.openListener(remoteId);\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      this.connectedClients = this.connectedClients.filter(function (c) {\n        return c !== clientId;\n      });\n      this.closedListener(clientId);\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      var connected = this.connectedClients.indexOf(clientId) !== -1;\n      if (connected) {\n        return NAF.adapters.IS_CONNECTED;\n      } else {\n        return NAF.adapters.NOT_CONNECTED;\n      }\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(to, type, data) {\n      this.sendDataGuaranteed(to, type, data);\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(to, type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = to;\n      this.packet.type = type;\n      this.packet.data = data;\n      if (this.socket) {\n        this.socket.emit('send', this.packet);\n      } else {\n        NAF.log.warn('SocketIO socket not created yet');\n      }\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(type, data) {\n      this.broadcastDataGuaranteed(type, data);\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = undefined;\n      this.packet.type = type;\n      this.packet.data = data;\n      if (this.socket) {\n        this.socket.emit('broadcast', this.packet);\n      } else {\n        NAF.log.warn('SocketIO socket not created yet');\n      }\n    }\n  }, {\n    key: \"getMediaStream\",\n    value: function getMediaStream(clientId) {\n      return Promise.reject('Interface method not implemented: getMediaStream');\n    }\n  }, {\n    key: \"updateTimeOffset\",\n    value: function updateTimeOffset() {\n      var _this2 = this;\n      var clientSentTime = Date.now() + this.avgTimeOffset;\n      return fetch(document.location.href, {\n        method: 'HEAD',\n        cache: 'no-cache'\n      }).then(function (res) {\n        var precision = 1000;\n        var serverReceivedTime = new Date(res.headers.get('Date')).getTime() + precision / 2;\n        var clientReceivedTime = Date.now();\n        var serverTime = serverReceivedTime + (clientReceivedTime - clientSentTime) / 2;\n        var timeOffset = serverTime - clientReceivedTime;\n        _this2.serverTimeRequests++;\n        if (_this2.serverTimeRequests <= 10) {\n          _this2.timeOffsets.push(timeOffset);\n        } else {\n          _this2.timeOffsets[_this2.serverTimeRequests % 10] = timeOffset;\n        }\n        _this2.avgTimeOffset = _this2.timeOffsets.reduce(function (acc, offset) {\n          return acc += offset;\n        }, 0) / _this2.timeOffsets.length;\n        if (_this2.serverTimeRequests > 10) {\n          setTimeout(function () {\n            return _this2.updateTimeOffset();\n          }, 5 * 60 * 1000); // Sync clock every 5 minutes.\n        } else {\n          _this2.updateTimeOffset();\n        }\n      });\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return Date.now() + this.avgTimeOffset;\n    }\n  }, {\n    key: \"onDisconnect\",\n    value: function onDisconnect() {\n      if (NAF.clientId === '') return;\n      // Properly remove connected clients and remote entities\n      this.receivedOccupants({});\n      // For entities I'm the creator, reset to empty owner and register\n      // again the onConnected callback to send my entities to all\n      // the participants upon reconnect.\n      for (var _i = 0, _Object$values = Object.values(NAF.entities.entities); _i < _Object$values.length; _i++) {\n        var entity = _Object$values[_i];\n        if (entity.components.networked.data.creator === NAF.clientId) {\n          // The creator and owner will be set to the new NAF.clientId upon reconnect\n          entity.setAttribute('networked', {\n            owner: '',\n            creator: ''\n          });\n          document.body.addEventListener('connected', entity.components.networked.onConnected, false);\n        }\n      }\n      NAF.clientId = '';\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.socket.disconnect();\n      this.onDisconnect();\n    }\n  }]);\n}();\nmodule.exports = SocketioAdapter;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/naf-socketio-adapter.js?");

/***/ }),

/***/ "./src/adapters/naf-uws-adapter.js":
/*!*****************************************!*\
  !*** ./src/adapters/naf-uws-adapter.js ***!
  \*****************************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF */\nvar UWSAdapter = /*#__PURE__*/function () {\n  function UWSAdapter() {\n    var _this = this;\n    _classCallCheck(this, UWSAdapter);\n    this.app = 'default';\n    this.room = 'default';\n    this.occupantListener = null;\n    this.myRoomJoinTime = null;\n    this.myId = null;\n    this.packet = {\n      from: undefined,\n      to: undefined,\n      type: undefined,\n      data: undefined\n    };\n    this.occupants = {}; // id -> joinTimestamp\n    this.connectedClients = [];\n    this.serverTimeRequests = 0;\n    this.timeOffsets = [];\n    this.avgTimeOffset = 0;\n    this.ws = null;\n    this.onWebsocketOpen = this.onWebsocketOpen.bind(this);\n    this.onWebsocketClose = this.onWebsocketClose.bind(this);\n    this.onWebsocketMessage = this.onWebsocketMessage.bind(this);\n\n    // In the event the server restarts and all clients lose connection, reconnect with\n    // some random jitter added to prevent simultaneous reconnection requests.\n    this.initialReconnectionDelay = 1000 * Math.random();\n    this.reconnectionDelay = this.initialReconnectionDelay;\n    this.reconnectionTimeout = null;\n    this.maxReconnectionAttempts = 10;\n    this.reconnectionAttempts = 0;\n    this.isReconnecting = false;\n    window.addEventListener('offline', function () {\n      console.log('Browser went offline - closing WebSocket');\n      _this.reconnect();\n    });\n  }\n  return _createClass(UWSAdapter, [{\n    key: \"setServerUrl\",\n    value: function setServerUrl(wsUrl) {\n      this.wsUrl = wsUrl;\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(appName) {\n      this.app = appName;\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.room = roomName;\n    }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      // No WebRTC support\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.connectSuccess = successListener;\n      this.connectFailure = failureListener;\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.occupantListener = occupantListener;\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.openListener = openListener;\n      this.closedListener = closedListener;\n      this.messageListener = messageListener;\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      return Promise.all([this.connectToServer(), this.updateTimeOffset()]);\n    }\n  }, {\n    key: \"connectToServer\",\n    value: function connectToServer() {\n      var _this2 = this;\n      if (!this.wsUrl || this.wsUrl === '/') {\n        if (location.protocol === 'https:') {\n          this.wsUrl = 'wss://' + location.host;\n        } else {\n          this.wsUrl = 'ws://' + location.host;\n        }\n      }\n      NAF.log.write('Connecting to WebSocket', this.wsUrl);\n      var websocketConnection = new Promise(function (resolve, reject) {\n        _this2.ws = new WebSocket(_this2.wsUrl);\n        _this2.websocketConnectionPromise = {};\n        _this2.websocketConnectionPromise.resolve = resolve;\n        _this2.websocketConnectionPromise.reject = reject;\n        _this2.ws.addEventListener('open', _this2.onWebsocketOpen);\n        _this2.ws.addEventListener('close', _this2.onWebsocketClose);\n        _this2.ws.addEventListener('message', _this2.onWebsocketMessage);\n      });\n      return websocketConnection;\n    }\n  }, {\n    key: \"onWebsocketOpen\",\n    value: function onWebsocketOpen() {\n      console.log('WebSocket connected');\n      this.joinRoom();\n    }\n  }, {\n    key: \"onWebsocketClose\",\n    value: function onWebsocketClose(event) {\n      var _this3 = this;\n      // The connection was closed successfully. Don't try to reconnect.\n      if (event.code === 1000 || event.code === 1005) {\n        return;\n      }\n      this.websocketConnectionPromise.reject(event);\n      if (!this.isReconnecting) {\n        this.isReconnecting = true;\n        console.warn('WebSocket closed unexpectedly.');\n        if (this.onReconnecting) {\n          this.onReconnecting(this.reconnectionDelay);\n        }\n        this.reconnectionTimeout = setTimeout(function () {\n          return _this3.reconnect();\n        }, this.reconnectionDelay);\n      }\n    }\n  }, {\n    key: \"reconnect\",\n    value: function reconnect() {\n      var _this4 = this;\n      // Dispose of all networked entities and other resources tied to the session.\n      this.disconnect();\n      this.connectToServer().then(function () {\n        _this4.reconnectionDelay = _this4.initialReconnectionDelay;\n        _this4.reconnectionAttempts = 0;\n        _this4.isReconnecting = false;\n        if (_this4.onReconnected) {\n          _this4.onReconnected();\n        }\n      })[\"catch\"](function (error) {\n        _this4.reconnectionDelay += 1000;\n        _this4.reconnectionAttempts++;\n        if (_this4.reconnectionAttempts > _this4.maxReconnectionAttempts) {\n          var _error = new Error('Connection could not be reestablished, exceeded maximum number of reconnection attempts.');\n          if (_this4.onReconnectionError) {\n            return _this4.onReconnectionError(_error);\n          } else {\n            console.warn(_error);\n            return;\n          }\n        }\n        console.warn('Error during reconnect, retrying.');\n        console.warn(error);\n        if (_this4.onReconnecting) {\n          _this4.onReconnecting(_this4.reconnectionDelay);\n        }\n        _this4.reconnectionTimeout = setTimeout(function () {\n          return _this4.reconnect();\n        }, _this4.reconnectionDelay);\n      });\n    }\n  }, {\n    key: \"onWebsocketMessage\",\n    value: function onWebsocketMessage(event) {\n      var message = JSON.parse(event.data);\n      var eventName = message.event,\n        data = message.data;\n      switch (eventName) {\n        case 'connectSuccess':\n          {\n            var joinedTime = data.joinedTime,\n              socketId = data.socketId;\n            this.myRoomJoinTime = joinedTime;\n            this.myId = socketId;\n            this.websocketConnectionPromise.resolve();\n            this.connectSuccess(this.myId);\n            break;\n          }\n        case 'occupantsChanged':\n          {\n            var occupants = data.occupants;\n            this.receivedOccupants(occupants);\n            break;\n          }\n        case 'send':\n        case 'broadcast':\n          {\n            var from = data.from,\n              type = data.type,\n              messageData = data.data;\n            this.messageListener(from, type, messageData);\n            break;\n          }\n      }\n    }\n  }, {\n    key: \"joinRoom\",\n    value: function joinRoom() {\n      NAF.log.write('Joining room', this.room);\n      this.send('joinRoom', {\n        room: this.room\n      });\n    }\n  }, {\n    key: \"receivedOccupants\",\n    value: function receivedOccupants(occupants) {\n      delete occupants[this.myId];\n      this.occupants = occupants;\n      this.occupantListener(occupants);\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(client) {\n      return true;\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(remoteId) {\n      this.connectedClients.push(remoteId);\n      this.openListener(remoteId);\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      this.connectedClients = this.connectedClients.filter(function (c) {\n        return c !== clientId;\n      });\n      this.closedListener(clientId);\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      var connected = this.connectedClients.indexOf(clientId) !== -1;\n      if (connected) {\n        return NAF.adapters.IS_CONNECTED;\n      } else {\n        return NAF.adapters.NOT_CONNECTED;\n      }\n    }\n  }, {\n    key: \"send\",\n    value: function send(event, data) {\n      if (this.ws && this.ws.readyState === WebSocket.OPEN) {\n        this.ws.send(JSON.stringify({\n          event: event,\n          data: data\n        }));\n      }\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(to, type, data) {\n      this.sendDataGuaranteed(to, type, data);\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(to, type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = to;\n      this.packet.type = type;\n      this.packet.data = data;\n      this.send('send', this.packet);\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(type, data) {\n      this.broadcastDataGuaranteed(type, data);\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = undefined;\n      this.packet.type = type;\n      this.packet.data = data;\n      this.send('broadcast', this.packet);\n    }\n  }, {\n    key: \"getMediaStream\",\n    value: function getMediaStream(clientId) {\n      return Promise.reject('Interface method not implemented: getMediaStream');\n    }\n  }, {\n    key: \"updateTimeOffset\",\n    value: function updateTimeOffset() {\n      var _this5 = this;\n      var clientSentTime = Date.now() + this.avgTimeOffset;\n      return fetch(document.location.href, {\n        method: 'HEAD',\n        cache: 'no-cache'\n      }).then(function (res) {\n        var precision = 1000;\n        var serverReceivedTime = new Date(res.headers.get('Date')).getTime() + precision / 2;\n        var clientReceivedTime = Date.now();\n        var serverTime = serverReceivedTime + (clientReceivedTime - clientSentTime) / 2;\n        var timeOffset = serverTime - clientReceivedTime;\n        _this5.serverTimeRequests++;\n        if (_this5.serverTimeRequests <= 10) {\n          _this5.timeOffsets.push(timeOffset);\n        } else {\n          _this5.timeOffsets[_this5.serverTimeRequests % 10] = timeOffset;\n        }\n        _this5.avgTimeOffset = _this5.timeOffsets.reduce(function (acc, offset) {\n          return acc += offset;\n        }, 0) / _this5.timeOffsets.length;\n        if (_this5.serverTimeRequests > 10) {\n          setTimeout(function () {\n            return _this5.updateTimeOffset();\n          }, 5 * 60 * 1000); // Sync clock every 5 minutes.\n        } else {\n          _this5.updateTimeOffset();\n        }\n      });\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return Date.now() + this.avgTimeOffset;\n    }\n  }, {\n    key: \"onDisconnect\",\n    value: function onDisconnect() {\n      if (NAF.clientId === '') return;\n      // Properly remove connected clients and remote entities\n      this.receivedOccupants({});\n      // For entities I'm the creator, reset to empty owner and register\n      // again the onConnected callback to send my entities to all\n      // the participants upon reconnect.\n      for (var _i = 0, _Object$values = Object.values(NAF.entities.entities); _i < _Object$values.length; _i++) {\n        var entity = _Object$values[_i];\n        if (entity.components.networked.data.creator === NAF.clientId) {\n          // The creator and owner will be set to the new NAF.clientId upon reconnect\n          entity.setAttribute('networked', {\n            owner: '',\n            creator: ''\n          });\n          document.body.addEventListener('connected', entity.components.networked.onConnected, false);\n        }\n      }\n      NAF.clientId = '';\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      clearTimeout(this.reconnectionTimeout);\n      this.onDisconnect();\n      if (this.ws) {\n        this.ws.removeEventListener('open', this.onWebsocketOpen);\n        this.ws.removeEventListener('close', this.onWebsocketClose);\n        this.ws.removeEventListener('message', this.onWebsocketMessage);\n        this.ws.close();\n        this.ws = null;\n      }\n    }\n  }]);\n}();\nmodule.exports = UWSAdapter;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/naf-uws-adapter.js?");

/***/ }),

/***/ "./src/adapters/naf-webrtc-adapter.js":
/*!********************************************!*\
  !*** ./src/adapters/naf-webrtc-adapter.js ***!
  \********************************************/
/***/ ((module) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\"); }\nfunction _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }\nfunction _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", { writable: !1 }), e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global NAF, io */\nvar WebRtcPeer = /*#__PURE__*/function () {\n  function WebRtcPeer(localId, remoteId, sendSignalFunc) {\n    _classCallCheck(this, WebRtcPeer);\n    this.localId = localId;\n    this.remoteId = remoteId;\n    this.sendSignalFunc = sendSignalFunc;\n    this.open = false;\n    this.channelLabel = 'networked-aframe-channel';\n    this.pc = this.createPeerConnection();\n    this.channel = null;\n  }\n  return _createClass(WebRtcPeer, [{\n    key: \"setDatachannelListeners\",\n    value: function setDatachannelListeners(openListener, closedListener, messageListener, trackListener) {\n      this.openListener = openListener;\n      this.closedListener = closedListener;\n      this.messageListener = messageListener;\n      this.trackListener = trackListener;\n    }\n  }, {\n    key: \"offer\",\n    value: function offer(options) {\n      var self = this;\n      // reliable: false - UDP\n      this.setupChannel(this.pc.createDataChannel(this.channelLabel, {\n        reliable: false\n      }));\n\n      // If there are errors with Safari implement this:\n      // https://github.com/OpenVidu/openvidu/blob/master/openvidu-browser/src/OpenViduInternal/WebRtcPeer/WebRtcPeer.ts#L154\n\n      if (options.sendAudio) {\n        options.localAudioStream.getTracks().forEach(function (track) {\n          return self.pc.addTrack(track, options.localAudioStream);\n        });\n      }\n      this.pc.createOffer(function (sdp) {\n        self.handleSessionDescription(sdp);\n      }, function (error) {\n        NAF.log.error('WebRtcPeer.offer: ' + error);\n      }, {\n        offerToReceiveAudio: true,\n        offerToReceiveVideo: false\n      });\n    }\n  }, {\n    key: \"handleSignal\",\n    value: function handleSignal(signal) {\n      // ignores signal if it isn't for me\n      if (this.localId !== signal.to || this.remoteId !== signal.from) return;\n      switch (signal.type) {\n        case 'offer':\n          this.handleOffer(signal);\n          break;\n        case 'answer':\n          this.handleAnswer(signal);\n          break;\n        case 'candidate':\n          this.handleCandidate(signal);\n          break;\n        default:\n          NAF.log.error('WebRtcPeer.handleSignal: Unknown signal type ' + signal.type);\n          break;\n      }\n    }\n  }, {\n    key: \"send\",\n    value: function send(type, data) {\n      if (this.channel === null || this.channel.readyState !== 'open') {\n        return;\n      }\n      this.channel.send(JSON.stringify({\n        type: type,\n        data: data\n      }));\n    }\n  }, {\n    key: \"getStatus\",\n    value: function getStatus() {\n      if (this.channel === null) return WebRtcPeer.NOT_CONNECTED;\n      switch (this.channel.readyState) {\n        case 'open':\n          return WebRtcPeer.IS_CONNECTED;\n        case 'connecting':\n          return WebRtcPeer.CONNECTING;\n        case 'closing':\n        case 'closed':\n        default:\n          return WebRtcPeer.NOT_CONNECTED;\n      }\n    }\n\n    /*\n     * Privates\n     */\n  }, {\n    key: \"createPeerConnection\",\n    value: function createPeerConnection() {\n      var self = this;\n      var RTCPeerConnection = window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection || window.msRTCPeerConnection;\n      if (RTCPeerConnection === undefined) {\n        throw new Error('WebRtcPeer.createPeerConnection: This browser does not seem to support WebRTC.');\n      }\n      var pc = new RTCPeerConnection({\n        iceServers: WebRtcPeer.ICE_SERVERS\n      });\n      pc.onicecandidate = function (event) {\n        if (event.candidate) {\n          self.sendSignalFunc({\n            from: self.localId,\n            to: self.remoteId,\n            type: 'candidate',\n            sdpMLineIndex: event.candidate.sdpMLineIndex,\n            candidate: event.candidate.candidate\n          });\n        }\n      };\n\n      // Note: seems like channel.onclose hander is unreliable on some platforms,\n      //       so also tries to detect disconnection here.\n      pc.oniceconnectionstatechange = function () {\n        if (self.open && pc.iceConnectionState === 'disconnected') {\n          self.open = false;\n          self.closedListener(self.remoteId);\n        }\n      };\n      pc.ontrack = function (e) {\n        self.trackListener(self.remoteId, e.streams[0]);\n      };\n      return pc;\n    }\n  }, {\n    key: \"setupChannel\",\n    value: function setupChannel(channel) {\n      var self = this;\n      this.channel = channel;\n\n      // received data from a remote peer\n      this.channel.onmessage = function (event) {\n        var data = JSON.parse(event.data);\n        self.messageListener(self.remoteId, data.type, data.data);\n      };\n\n      // connected with a remote peer\n      this.channel.onopen = function (_event) {\n        self.open = true;\n        self.openListener(self.remoteId);\n      };\n\n      // disconnected with a remote peer\n      this.channel.onclose = function (_event) {\n        if (!self.open) return;\n        self.open = false;\n        self.closedListener(self.remoteId);\n      };\n\n      // error occurred with a remote peer\n      this.channel.onerror = function (error) {\n        NAF.log.error('WebRtcPeer.channel.onerror: ' + error);\n      };\n    }\n  }, {\n    key: \"handleOffer\",\n    value: function handleOffer(message) {\n      var self = this;\n      this.pc.ondatachannel = function (event) {\n        self.setupChannel(event.channel);\n      };\n      this.setRemoteDescription(message);\n      this.pc.createAnswer(function (sdp) {\n        self.handleSessionDescription(sdp);\n      }, function (error) {\n        NAF.log.error('WebRtcPeer.handleOffer: ' + error);\n      });\n    }\n  }, {\n    key: \"handleAnswer\",\n    value: function handleAnswer(message) {\n      this.setRemoteDescription(message);\n    }\n  }, {\n    key: \"handleCandidate\",\n    value: function handleCandidate(message) {\n      var RTCIceCandidate = window.RTCIceCandidate || window.webkitRTCIceCandidate || window.mozRTCIceCandidate;\n      this.pc.addIceCandidate(new RTCIceCandidate(message), function () {}, function (error) {\n        NAF.log.error('WebRtcPeer.handleCandidate: ' + error);\n      });\n    }\n  }, {\n    key: \"handleSessionDescription\",\n    value: function handleSessionDescription(sdp) {\n      this.pc.setLocalDescription(sdp, function () {}, function (error) {\n        NAF.log.error('WebRtcPeer.handleSessionDescription: ' + error);\n      });\n      this.sendSignalFunc({\n        from: this.localId,\n        to: this.remoteId,\n        type: sdp.type,\n        sdp: sdp.sdp\n      });\n    }\n  }, {\n    key: \"setRemoteDescription\",\n    value: function setRemoteDescription(message) {\n      var RTCSessionDescription = window.RTCSessionDescription || window.webkitRTCSessionDescription || window.mozRTCSessionDescription || window.msRTCSessionDescription;\n      this.pc.setRemoteDescription(new RTCSessionDescription(message), function () {}, function (error) {\n        NAF.log.error('WebRtcPeer.setRemoteDescription: ' + error);\n      });\n    }\n  }, {\n    key: \"close\",\n    value: function close() {\n      if (this.pc) {\n        this.pc.close();\n      }\n    }\n  }]);\n}();\nWebRtcPeer.IS_CONNECTED = 'IS_CONNECTED';\nWebRtcPeer.CONNECTING = 'CONNECTING';\nWebRtcPeer.NOT_CONNECTED = 'NOT_CONNECTED';\nWebRtcPeer.ICE_SERVERS = [{\n  urls: 'stun:stun1.l.google.com:19302'\n}, {\n  urls: 'stun:stun2.l.google.com:19302'\n}, {\n  urls: 'stun:stun3.l.google.com:19302'\n}, {\n  urls: 'stun:stun4.l.google.com:19302'\n}];\n\n/**\n * Native WebRTC Adapter (native-webrtc)\n * For use with uws-server.js\n * networked-scene: serverURL needs to be ws://localhost:8080 when running locally\n */\nvar WebrtcAdapter = /*#__PURE__*/function () {\n  function WebrtcAdapter() {\n    _classCallCheck(this, WebrtcAdapter);\n    if (io === undefined) console.warn('It looks like socket.io has not been loaded before WebrtcAdapter. Please do that.');\n    this.app = 'default';\n    this.room = 'default';\n    this.occupantListener = null;\n    this.myRoomJoinTime = null;\n    this.myId = null;\n    this.packet = {\n      from: undefined,\n      to: undefined,\n      type: undefined,\n      data: undefined\n    };\n    this.peers = {}; // id -> WebRtcPeer\n    this.occupants = {}; // id -> joinTimestamp\n\n    this.audioStreams = {};\n    this.pendingAudioRequest = {};\n    this.serverTimeRequests = 0;\n    this.timeOffsets = [];\n    this.avgTimeOffset = 0;\n  }\n  return _createClass(WebrtcAdapter, [{\n    key: \"setServerUrl\",\n    value: function setServerUrl(wsUrl) {\n      this.wsUrl = wsUrl;\n    }\n  }, {\n    key: \"setApp\",\n    value: function setApp(appName) {\n      this.app = appName;\n    }\n  }, {\n    key: \"setRoom\",\n    value: function setRoom(roomName) {\n      this.room = roomName;\n    }\n  }, {\n    key: \"setWebRtcOptions\",\n    value: function setWebRtcOptions(options) {\n      if (options.datachannel === false) {\n        NAF.log.error('WebrtcAdapter.setWebRtcOptions: datachannel must be true.');\n      }\n      if (options.audio === true) {\n        this.sendAudio = true;\n      }\n      if (options.video === true) {\n        NAF.log.warn('WebrtcAdapter does not support video yet.');\n      }\n    }\n  }, {\n    key: \"setServerConnectListeners\",\n    value: function setServerConnectListeners(successListener, failureListener) {\n      this.connectSuccess = successListener;\n      this.connectFailure = failureListener;\n    }\n  }, {\n    key: \"setRoomOccupantListener\",\n    value: function setRoomOccupantListener(occupantListener) {\n      this.occupantListener = occupantListener;\n    }\n  }, {\n    key: \"setDataChannelListeners\",\n    value: function setDataChannelListeners(openListener, closedListener, messageListener) {\n      this.openListener = openListener;\n      this.closedListener = closedListener;\n      this.messageListener = messageListener;\n    }\n  }, {\n    key: \"connect\",\n    value: function connect() {\n      var _this = this;\n      var self = this;\n      this.updateTimeOffset().then(function () {\n        if (!self.wsUrl || self.wsUrl === '/') {\n          if (location.protocol === 'https:') {\n            self.wsUrl = 'wss://' + location.host;\n          } else {\n            self.wsUrl = 'ws://' + location.host;\n          }\n        }\n        NAF.log.write('Attempting to connect to socket.io');\n        var socket = self.socket = io(self.wsUrl);\n        socket.on('connect', function () {\n          if (NAF.clientId) {\n            // The server restarted quickly and we got a new socket without\n            // getting in the error handler.\n            self.onDisconnect();\n          }\n          NAF.log.write('User connected', socket.id);\n          self.myId = socket.id;\n          self.joinRoom();\n        });\n        socket.on('connectSuccess', function (data) {\n          var joinedTime = data.joinedTime;\n          self.myRoomJoinTime = joinedTime;\n          NAF.log.write('Successfully joined room', self.room, 'at server time', joinedTime);\n          if (self.sendAudio) {\n            var mediaConstraints = {\n              audio: true,\n              video: false\n            };\n            navigator.mediaDevices.getUserMedia(mediaConstraints).then(function (localStream) {\n              self.storeAudioStream(self.myId, localStream);\n              self.connectSuccess(self.myId);\n              localStream.getTracks().forEach(function (track) {\n                Object.keys(self.peers).forEach(function (peerId) {\n                  self.peers[peerId].pc.addTrack(track, localStream);\n                });\n              });\n            })[\"catch\"](function (e) {\n              NAF.log.error(e);\n              console.error('Microphone is disabled due to lack of permissions');\n              self.sendAudio = false;\n              self.connectSuccess(self.myId);\n            });\n          } else {\n            self.connectSuccess(self.myId);\n          }\n        });\n        socket.io.on('error', function (err) {\n          console.error('Socket connection failure', err);\n          _this.onDisconnect();\n        });\n        socket.on('occupantsChanged', function (data) {\n          var occupants = data.occupants;\n          NAF.log.write('occupants changed', data);\n          self.receivedOccupants(occupants);\n        });\n        function receiveData(packet) {\n          var from = packet.from;\n          var type = packet.type;\n          var data = packet.data;\n          if (type === 'ice-candidate') {\n            self.peers[from].handleSignal(data);\n            return;\n          }\n          self.messageListener(from, type, data);\n        }\n        socket.on('send', receiveData);\n        socket.on('broadcast', receiveData);\n      });\n    }\n  }, {\n    key: \"joinRoom\",\n    value: function joinRoom() {\n      NAF.log.write('Joining room', this.room);\n      this.socket.emit('joinRoom', {\n        room: this.room\n      });\n    }\n  }, {\n    key: \"receivedOccupants\",\n    value: function receivedOccupants(occupants) {\n      var _this2 = this;\n      delete occupants[this.myId];\n      this.occupants = occupants;\n      var self = this;\n      var localId = this.myId;\n      var _loop = function _loop() {\n        var remoteId = key;\n        if (_this2.peers[remoteId]) return 1; // continue\n        var peer = new WebRtcPeer(localId, remoteId, function (data) {\n          self.socket.emit('send', {\n            from: localId,\n            to: remoteId,\n            type: 'ice-candidate',\n            data: data\n          });\n        });\n        peer.setDatachannelListeners(self.openListener, self.closedListener, self.messageListener, self.trackListener.bind(self));\n        self.peers[remoteId] = peer;\n      };\n      for (var key in occupants) {\n        if (_loop()) continue;\n      }\n      this.occupantListener(occupants);\n    }\n  }, {\n    key: \"shouldStartConnectionTo\",\n    value: function shouldStartConnectionTo(client) {\n      return (this.myRoomJoinTime || 0) <= (client || 0);\n    }\n  }, {\n    key: \"startStreamConnection\",\n    value: function startStreamConnection(remoteId) {\n      var _this3 = this;\n      NAF.log.write('starting offer process');\n      if (this.sendAudio) {\n        this.getMediaStream(this.myId).then(function (stream) {\n          var options = {\n            sendAudio: true,\n            localAudioStream: stream\n          };\n          _this3.peers[remoteId].offer(options);\n        });\n      } else {\n        this.peers[remoteId].offer({});\n      }\n    }\n  }, {\n    key: \"closeStreamConnection\",\n    value: function closeStreamConnection(clientId) {\n      NAF.log.write('closeStreamConnection', clientId, this.peers);\n      this.peers[clientId].close();\n      delete this.peers[clientId];\n      delete this.occupants[clientId];\n      this.closedListener(clientId);\n    }\n  }, {\n    key: \"getConnectStatus\",\n    value: function getConnectStatus(clientId) {\n      var peer = this.peers[clientId];\n      if (peer === undefined) return NAF.adapters.NOT_CONNECTED;\n      switch (peer.getStatus()) {\n        case WebRtcPeer.IS_CONNECTED:\n          return NAF.adapters.IS_CONNECTED;\n        case WebRtcPeer.CONNECTING:\n          return NAF.adapters.CONNECTING;\n        case WebRtcPeer.NOT_CONNECTED:\n        default:\n          return NAF.adapters.NOT_CONNECTED;\n      }\n    }\n  }, {\n    key: \"sendData\",\n    value: function sendData(to, type, data) {\n      this.peers[to].send(type, data);\n    }\n  }, {\n    key: \"sendDataGuaranteed\",\n    value: function sendDataGuaranteed(to, type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = to;\n      this.packet.type = type;\n      this.packet.data = data;\n      if (this.socket) {\n        this.socket.emit('send', this.packet);\n      } else {\n        NAF.log.warn('SocketIO socket not created yet');\n      }\n    }\n  }, {\n    key: \"broadcastData\",\n    value: function broadcastData(type, data) {\n      for (var clientId in this.peers) {\n        this.sendData(clientId, type, data);\n      }\n    }\n  }, {\n    key: \"broadcastDataGuaranteed\",\n    value: function broadcastDataGuaranteed(type, data) {\n      this.packet.from = this.myId;\n      this.packet.to = undefined;\n      this.packet.type = type;\n      this.packet.data = data;\n      if (this.socket) {\n        this.socket.emit('broadcast', this.packet);\n      } else {\n        NAF.log.warn('SocketIO socket not created yet');\n      }\n    }\n  }, {\n    key: \"storeAudioStream\",\n    value: function storeAudioStream(clientId, stream) {\n      this.audioStreams[clientId] = stream;\n      if (this.pendingAudioRequest[clientId]) {\n        NAF.log.write('Received pending audio for ' + clientId);\n        this.pendingAudioRequest[clientId](stream);\n        delete this.pendingAudioRequest[clientId](stream);\n      }\n    }\n  }, {\n    key: \"trackListener\",\n    value: function trackListener(clientId, stream) {\n      this.storeAudioStream(clientId, stream);\n    }\n  }, {\n    key: \"getMediaStream\",\n    value: function getMediaStream(clientId) {\n      var self = this;\n      if (this.audioStreams[clientId]) {\n        NAF.log.write('Already had audio for ' + clientId);\n        return Promise.resolve(this.audioStreams[clientId]);\n      } else {\n        NAF.log.write('Waiting on audio for ' + clientId);\n        return new Promise(function (resolve) {\n          self.pendingAudioRequest[clientId] = resolve;\n        });\n      }\n    }\n  }, {\n    key: \"updateTimeOffset\",\n    value: function updateTimeOffset() {\n      var _this4 = this;\n      var clientSentTime = Date.now() + this.avgTimeOffset;\n      return fetch(document.location.href, {\n        method: 'HEAD',\n        cache: 'no-cache'\n      }).then(function (res) {\n        var precision = 1000;\n        var serverReceivedTime = new Date(res.headers.get('Date')).getTime() + precision / 2;\n        var clientReceivedTime = Date.now();\n        var serverTime = serverReceivedTime + (clientReceivedTime - clientSentTime) / 2;\n        var timeOffset = serverTime - clientReceivedTime;\n        _this4.serverTimeRequests++;\n        if (_this4.serverTimeRequests <= 10) {\n          _this4.timeOffsets.push(timeOffset);\n        } else {\n          _this4.timeOffsets[_this4.serverTimeRequests % 10] = timeOffset;\n        }\n        _this4.avgTimeOffset = _this4.timeOffsets.reduce(function (acc, offset) {\n          return acc += offset;\n        }, 0) / _this4.timeOffsets.length;\n        if (_this4.serverTimeRequests > 10) {\n          setTimeout(function () {\n            return _this4.updateTimeOffset();\n          }, 5 * 60 * 1000); // Sync clock every 5 minutes.\n        } else {\n          _this4.updateTimeOffset();\n        }\n      });\n    }\n  }, {\n    key: \"getServerTime\",\n    value: function getServerTime() {\n      return Date.now() + this.avgTimeOffset;\n    }\n  }, {\n    key: \"onDisconnect\",\n    value: function onDisconnect() {\n      if (NAF.clientId === '') return;\n      // Properly remove connected clients and remote entities\n      this.receivedOccupants({});\n      // For entities I'm the creator, reset to empty owner and register\n      // again the onConnected callback to send my entities to all\n      // the participants upon reconnect.\n      for (var _i = 0, _Object$values = Object.values(NAF.entities.entities); _i < _Object$values.length; _i++) {\n        var entity = _Object$values[_i];\n        if (entity.components.networked.data.creator === NAF.clientId) {\n          // The creator and owner will be set to the new NAF.clientId upon reconnect\n          entity.setAttribute('networked', {\n            owner: '',\n            creator: ''\n          });\n          document.body.addEventListener('connected', entity.components.networked.onConnected, false);\n        }\n      }\n      NAF.clientId = '';\n    }\n  }, {\n    key: \"disconnect\",\n    value: function disconnect() {\n      this.socket.disconnect();\n      this.onDisconnect();\n    }\n  }]);\n}();\nmodule.exports = WebrtcAdapter;\n\n//# sourceURL=webpack://networked-aframe/./src/adapters/naf-webrtc-adapter.js?");

/***/ }),

/***/ "./src/components/networked-audio-source.js":
/*!**************************************************!*\
  !*** ./src/components/networked-audio-source.js ***!
  \**************************************************/
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {

eval("/* global AFRAME, NAF, THREE */\nvar naf = __webpack_require__(/*! ../NafIndex */ \"./src/NafIndex.js\");\nAFRAME.registerComponent('networked-audio-source', {\n  schema: {\n    streamName: {\n      \"default\": 'audio'\n    },\n    positional: {\n      \"default\": true\n    },\n    distanceModel: {\n      \"default\": \"inverse\",\n      oneOf: [\"linear\", \"inverse\", \"exponential\"]\n    },\n    maxDistance: {\n      \"default\": 10000\n    },\n    refDistance: {\n      \"default\": 1\n    },\n    rolloffFactor: {\n      \"default\": 1\n    },\n    createSoundOnInit: {\n      \"default\": true\n    }\n  },\n  init: function init() {\n    this.stream = null;\n    this.sound = null;\n    this.audioEl = null;\n    this._setupSound = this._setupSound.bind(this);\n    if (this.data.createSoundOnInit) {\n      this.createSound();\n    }\n  },\n  update: function update(oldData) {\n    if (!this.sound) {\n      return;\n    }\n    if (oldData.positional !== this.data.positional) {\n      this.destroySound();\n      this._setupSound(this.stream);\n    } else if (this.data.positional) {\n      this._setPannerProperties();\n    }\n  },\n  _setPannerProperties: function _setPannerProperties() {\n    this.sound.setDistanceModel(this.data.distanceModel);\n    this.sound.setMaxDistance(this.data.maxDistance);\n    this.sound.setRefDistance(this.data.refDistance);\n    this.sound.setRolloffFactor(this.data.rolloffFactor);\n  },\n  remove: function remove() {\n    this.destroySound();\n  },\n  destroySound: function destroySound() {\n    if (this.sound) {\n      this.el.emit('sound-source-removed', {\n        soundSource: this.soundSource\n      });\n      this.sound.disconnect();\n      this.el.removeObject3D(this.attrName);\n      this.sound = null;\n    }\n    if (this.audioEl) {\n      this.audioEl.pause();\n      this.audioEl.srcObject = null;\n      this.audioEl.load();\n      this.audioEl = null;\n    }\n  },\n  createSound: function createSound() {\n    var _this = this;\n    NAF.utils.getNetworkedEntity(this.el).then(function (networkedEl) {\n      var ownerId = networkedEl.components.networked.data.owner;\n      if (ownerId) {\n        NAF.connection.adapter.getMediaStream(ownerId, _this.data.streamName).then(_this._setupSound)[\"catch\"](function (e) {\n          return naf.log.error(\"Error getting media stream for \".concat(ownerId), e);\n        });\n      } else {\n        // Correctly configured local entity, perhaps do something here for enabling debug audio loopback\n      }\n    });\n  },\n  _setupSound: function _setupSound(newStream) {\n    if (!newStream) return;\n    var isRemoved = !this.el.parentNode;\n    if (isRemoved) return;\n    var el = this.el;\n    var sceneEl = el.sceneEl;\n    if (!sceneEl.audioListener) {\n      sceneEl.audioListener = new THREE.AudioListener();\n      sceneEl.camera && sceneEl.camera.add(sceneEl.audioListener);\n      sceneEl.addEventListener('camera-set-active', function (evt) {\n        evt.detail.cameraEl.getObject3D('camera').add(sceneEl.audioListener);\n      });\n    }\n    this.sound = this.data.positional ? new THREE.PositionalAudio(sceneEl.audioListener) : new THREE.Audio(sceneEl.audioListener);\n    el.setObject3D(this.attrName, this.sound);\n    if (this.data.positional) {\n      this._setPannerProperties();\n    }\n\n    // Chrome seems to require a MediaStream be attached to an AudioElement before AudioNodes work correctly\n    // We don't want to do this in other browsers, particularly in Safari, which actually plays the audio despite\n    // setting the volume to 0.\n    if (/chrome/i.test(navigator.userAgent)) {\n      this.audioEl = new Audio();\n      this.audioEl.setAttribute(\"autoplay\", \"autoplay\");\n      this.audioEl.setAttribute(\"playsinline\", \"playsinline\");\n      this.audioEl.srcObject = newStream;\n      this.audioEl.volume = 0; // we don't actually want to hear audio from this element\n    }\n    this.soundSource = this.sound.context.createMediaStreamSource(newStream);\n    this.sound.setNodeSource(this.soundSource);\n    this.el.emit('sound-source-set', {\n      soundSource: this.soundSource\n    });\n    this.stream = newStream;\n  }\n});\n\n//# sourceURL=webpack://networked-aframe/./src/components/networked-audio-source.js?");

/***/ }),

/***/ "./src/components/networked-hand-controls.js":
/*!***************************************************!*\
  !*** ./src/components/networked-hand-controls.js ***!
  \***************************************************/
/***/ (() => {

eval("function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _unsupportedIterableToArray(r, a) { if (r) { if (\"string\" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }\nfunction _iterableToArray(r) { if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r); }\nfunction _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }\nfunction _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }\n/* global THREE, AFRAME, NAF */\n\n/**\n * Represent any 6dof controller as a hand with live tracked animated gestures and normalized events.\n *\n * Updated and modified adaption of https://github.com/aframevr/aframe/blob/master/src/components/hand-controls.js\n * Designed for use with NAF, but can also be used without NAF.\n *\n * Auto-detects appropriate controller.\n * Handles common events coming from the detected vendor-specific controls.\n * Loads hand model with gestures that are applied based on the button pressed.\n * Translate button events to semantic hand-related event names:\n * (fist, thumbUp, point, hold, open, pistol) + (start, end)\n * note that the events were incomplete/broken in prior implementation, and therefore a breaking change\n */\n\n// this is a way to bypass adding the template in to the HTML, as well as the already awkward NAF.schemas.add \n// workaround. this makes the use of this component for the end user much simpler.\nfunction addHandTemplate(hand) {\n  var templateOuter = document.createElement('template');\n  var templateInner = document.createElement('a-entity');\n  templateOuter.id = \"\".concat(hand, \"-hand-default-template\");\n  templateInner.setAttribute('rotation', '0 0 0'); // to set the YXZ order\n  templateInner.setAttribute('networked-hand-controls', \"hand: \".concat(hand));\n  templateOuter.appendChild(templateInner);\n  var refTemplateId = \"#\".concat(templateOuter.id);\n  NAF.schemas.schemaDict[refTemplateId] = {\n    template: refTemplateId,\n    components: [{\n      component: 'position',\n      requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.001)\n    }, {\n      component: 'rotation',\n      requiresNetworkUpdate: NAF.utils.vectorRequiresUpdate(0.5)\n    }, 'networked-hand-controls']\n  };\n  NAF.schemas.templateCache[refTemplateId] = templateOuter;\n}\n[\"left\", \"right\"].forEach(addHandTemplate);\nAFRAME.registerComponent('networked-hand-controls', {\n  schema: {\n    color: {\n      \"default\": 'white',\n      type: 'color'\n    },\n    hand: {\n      type: \"string\",\n      \"default\": 'left',\n      oneOf: ['right', 'left']\n    },\n    handModelStyle: {\n      type: \"string\",\n      \"default\": 'highPoly',\n      oneOf: ['lowPoly', 'highPoly', 'toon', 'controller']\n    },\n    // these are set internally if we use type 'controller' for handModelStyle\n    controllerComponent: {\n      type: \"string\",\n      \"default\": ''\n    },\n    webxrControllerProfiles: {\n      type: \"string\",\n      \"default\": ''\n    },\n    controllerEvent: {\n      \"default\": JSON.stringify({}),\n      type: \"string\"\n    },\n    controllerModelUpdate: {\n      \"default\": [],\n      type: \"array\"\n    },\n    // these are for specifying a custom hand model URL; only allowed at init, not via update\n    // (must correspond to existing models and have matching animations to work properly)\n    customHandModelURL: {\n      type: \"string\",\n      \"default\": ''\n    },\n    // this is set internally when using a hand model\n    gesture: {\n      type: \"string\",\n      \"default\": 'open'\n    },\n    // this is set internally, hands are invisible until webxr controller is connected\n    visible: {\n      type: \"bool\",\n      \"default\": false\n    }\n  },\n  init: function init() {\n    var _this = this;\n    this.setup();\n    this.rendererSystem = this.el.sceneEl.systems.renderer;\n    if (this.data.handModelStyle !== \"controller\") {\n      this.addHandModel();\n    }\n    NAF.utils.getNetworkedEntity(this.el).then(function (networkedEl) {\n      // Here networkedEl may be different than this.el if we don't use nested\n      // networked components for hands.\n      _this.local = networkedEl.components.networked.createdByMe();\n    })[\"catch\"](function () {\n      _this.local = true;\n    }).then(function () {\n      if (_this.local) {\n        _this.addControllerComponents(_this.data.handModelStyle === \"controller\");\n        // Bind all functions, the listeners are only registered later for local avatar.\n        for (var evtName in _this.buttonEventMap) {\n          var _this$handleButton;\n          _this.eventFunctionMap[_this.data.hand][evtName] = (_this$handleButton = _this.handleButton).bind.apply(_this$handleButton, [_this].concat(_toConsumableArray(_this.buttonEventMap[evtName])));\n        }\n        for (var _evtName in _this.visibleListeners) {\n          _this.eventFunctionMap[_this.data.hand][_evtName] = _this.visibleListeners[_evtName].bind(_this);\n        }\n      } else {\n        // Adding a class to easily see what the entity is in the aframe\n        // inspector. This is shown in the class field in the panel after you\n        // click the entity.\n        _this.el.classList.add('naf-remote-hand');\n      }\n    });\n  },\n  play: function play() {\n    if (this.local) {\n      this.addEventListeners();\n    }\n  },\n  pause: function pause() {\n    if (this.local) {\n      this.removeEventListeners();\n    }\n  },\n  tick: function tick(time, delta) {\n    var _this$getMesh;\n    if ((_this$getMesh = this.getMesh()) !== null && _this$getMesh !== void 0 && _this$getMesh.mixer) this.getMesh().mixer.update(delta / 1000);\n  },\n  update: function update(oldData) {\n    var _this2 = this;\n    if (oldData.visible != this.data.visible) {\n      this.el.object3D.visible = this.data.visible;\n    }\n\n    // this block is for handling updates() from hand model to controller model, or vice versa.\n    if (oldData.handModelStyle && oldData.handModelStyle !== this.data.handModelStyle) {\n      // first, remove old model\n      if (this.getMesh()) this.el.removeObject3D(this.str.mesh);\n      ['gltf-model', 'obj-model'].forEach(function (modelComponent) {\n        if (_this2.el.components[modelComponent]) {\n          _this2.el.removeAttribute(modelComponent);\n        }\n      });\n      // then, add correct model\n      if (this.data.handModelStyle !== \"controller\") {\n        this.addHandModel();\n      } else {\n        // it would be nice if this worked, but those components don't handle this option in their update() methods:\n        // this.el.setAttribute(this.data.controllerComponent, 'model', true)\n\n        // so we first remove the controller component\n        if (this.data.controllerComponent && this.el.components[this.data.controllerComponent]) {\n          this.el.removeAttribute(this.data.controllerComponent);\n        }\n        if (!this.local) {\n          if (!this.injectedController && this.data.controllerComponent && this.data.webxrControllerProfiles[0]) {\n            this.injectRemoteControllerModel();\n          }\n        } else {\n          this.addControllerComponents(true);\n          // controllerconnected event won't fire again, so we have to call this manually:\n          this.el.components[this.data.controllerComponent].injectTrackedControls({\n            profiles: JSON.parse(this.data.webxrControllerProfiles)\n          });\n        }\n      }\n    }\n    if (oldData.color && this.data.handModelStyle !== this.str.controller && oldData.color !== this.data.color) {\n      this.updateHandMeshColor();\n    }\n\n    // this block is for receiving+handling networked hand gestures and button events for controller model updates\n    // and for initial injection of remote controller model\n    if (!this.local) {\n      if (this.data.handModelStyle !== this.str.controller && this.data.gesture !== oldData.gesture) {\n        this.handleGesture(this.data.gesture, oldData.gesture);\n      } else if (this.data.handModelStyle === this.str.controller) {\n        if (!this.injectedController && this.data.controllerComponent && this.data.webxrControllerProfiles[0]) {\n          this.injectRemoteControllerModel();\n        }\n        if (oldData.controllerEvent && oldData.controllerEvent !== this.data.controllerEvent) {\n          var controllerEvent = JSON.parse(this.data.controllerEvent);\n          this.el.components[this.data.controllerComponent][controllerEvent.type === 'thumbstickmoved' ? 'onThumbstickMoved' : 'onButtonChanged'](controllerEvent);\n        }\n        if (oldData.controllerModelUpdate && (oldData.controllerModelUpdate[0] !== this.data.controllerModelUpdate[0] || oldData.controllerModelUpdate[1] !== this.data.controllerModelUpdate[1])) {\n          var _this$el$components$t;\n          (_this$el$components$t = this.el.components[this.data.controllerComponent]).updateModel.apply(_this$el$components$t, _toConsumableArray(this.data.controllerModelUpdate));\n        }\n      }\n    }\n  },\n  remove: function remove() {\n    this.el.removeObject3D(this.str.mesh);\n  },\n  addHandModel: function addHandModel() {\n    var _this3 = this;\n    this.loader = new THREE.GLTFLoader();\n    this.loader.setCrossOrigin('anonymous');\n    var handmodelUrl = this.MODEL_BASE + this.MODEL_NAMES[this.data.handModelStyle + this.data.hand.charAt(0).toUpperCase() + this.data.hand.slice(1)];\n    this.loader.load(this.data.customHandModelURL || handmodelUrl, function (gltf) {\n      var newMesh = gltf.scene.children[0];\n      var handModelOrientation = _this3.data.hand === 'left' ? Math.PI / 2 : -Math.PI / 2;\n      newMesh.mixer = new THREE.AnimationMixer(newMesh);\n      _this3.clips = gltf.animations;\n      _this3.clips.forEach(function (clip) {\n        _this3.clipNameToClip[clip.name] = clip;\n      });\n      _this3.el.setObject3D(_this3.str.mesh, newMesh);\n      var handColor = _this3.data.color;\n      newMesh.traverse(function (object) {\n        if (!object.isMesh) {\n          return;\n        }\n        object.material.color = new THREE.Color(handColor);\n      });\n      newMesh.position.set(0, 0, 0);\n      newMesh.rotation.set(0, 0, handModelOrientation);\n    });\n  },\n  updateHandMeshColor: function updateHandMeshColor() {\n    var mesh = this.getMesh();\n    if (!mesh) return;\n    var handColor = this.data.color;\n    mesh.traverse(function (object) {\n      if (!object.isMesh) {\n        return;\n      }\n      object.material.color.set(handColor);\n    });\n  },\n  controllerComponents: ['magicleap-controls', 'vive-controls', 'oculus-touch-controls', 'windows-motion-controls', 'hp-mixed-reality-controls',\n  // these were missing from the original hand-controls component:\n  'valve-index-controls',\n  // some older models that it doesn't hurt to include:\n  'oculus-go-controls', 'vive-focus-controls'],\n  addControllerComponents: function addControllerComponents(useControllerModel) {\n    var _this4 = this;\n    // this adds all controller components, with wrappers set up to capture and broadcast model found and relevant button presses\n    this.controllerComponents.forEach(function (controllerComponentName) {\n      if (_this4.data.controllerComponent && _this4.data.controllerComponent !== controllerComponentName) {\n        return;\n      }\n      _this4.el.setAttribute(controllerComponentName, {\n        hand: _this4.data.hand,\n        model: useControllerModel\n      });\n\n      // (note: this could possibly be rewritten to rely on the controllerconnected event)\n      _this4.el.components[controllerComponentName].injectTrackedControls = _this4.injectControlsWrapper.bind(_this4, _this4.el.components[controllerComponentName].injectTrackedControls.bind(_this4.el.components[controllerComponentName]), controllerComponentName);\n    });\n    this.isViveController();\n  },\n  injectControlsWrapper: function injectControlsWrapper(originalFn, controllerComponentName, webxrControllerSymbol) {\n    // captures and rebroadcasts the model found by AFRAME.utils.trackedControls.findMatchingControllerWebXR\n    this.el.setAttribute('networked-hand-controls', {\n      controllerComponent: controllerComponentName,\n      webxrControllerProfiles: JSON.stringify(webxrControllerSymbol.profiles)\n    });\n    originalFn(webxrControllerSymbol);\n\n    // this function handles mesh color updates\n    this.el.components[controllerComponentName].updateModel = this.updateModelWrapper.bind(this, this.el.components[controllerComponentName].updateModel.bind(this.el.components[controllerComponentName]));\n    this.el.components[controllerComponentName].onButtonChanged = this.onButtonChangedWrapper.bind(this, this.el.components[controllerComponentName].onButtonChanged);\n    this.el.components[controllerComponentName].onThumbstickMoved = this.onThumbstickMovedWrapper.bind(this, this.el.components[controllerComponentName].onThumbstickMoved);\n\n    // we want to strip the listeners pointing to the original functions, and then re-add them with our wrapped functions\n    this.el.components[controllerComponentName].removeEventListeners();\n    this.el.components[controllerComponentName].addEventListeners();\n  },\n  onButtonChangedWrapper: function onButtonChangedWrapper(originalFn, evt) {\n    this.el.setAttribute('networked-hand-controls', this.str.controllerEvent, JSON.stringify({\n      detail: evt.detail,\n      type: evt.type\n    }));\n    originalFn(evt);\n  },\n  onThumbstickMovedWrapper: function onThumbstickMovedWrapper(originalFn, evt) {\n    this.el.setAttribute('networked-hand-controls', this.str.controllerEvent, JSON.stringify({\n      detail: evt.detail,\n      type: evt.type\n    }));\n    originalFn(evt);\n  },\n  updateModelWrapper: function updateModelWrapper(originalFn, buttonName, evtName) {\n    // capture and rebroadcast controller events (only used if using controller model instead of hand)\n    if (!this.btnEvtMap[buttonName]) {\n      this.btnEvtMap[buttonName] = {};\n    }\n    if (!this.btnEvtMap[buttonName][evtName]) {\n      this.btnEvtMap[buttonName][evtName] = \"\".concat(buttonName, \",\").concat(evtName);\n    }\n    this.el.setAttribute('networked-hand-controls', \"controllerModelUpdate\", this.btnEvtMap[buttonName][evtName]);\n    originalFn(buttonName, evtName);\n  },\n  catchPoseTrackingInitialization: function catchPoseTrackingInitialization() {\n    this.catchAndRemoveWebXRTracking = function catchAndRemoveWebXRTracking(evt) {\n      if (evt.detail.name !== 'tracked-controls-webxr') {\n        return;\n      }\n      this.el.removeEventListener('componentinitialized', this.catchAndRemoveWebXRTracking);\n      this.el.removeAttribute('tracked-controls-webxr');\n    }.bind(this);\n    this.el.addEventListener('componentinitialized', this.catchAndRemoveWebXRTracking);\n  },\n  injectRemoteControllerModel: function injectRemoteControllerModel() {\n    // this is for a networked controller entity, where we want to show a non-hand controller model\n    // we add the relevant controller component, and then hack it just a bit to:\n    // A) convince it the model show without relation to whether one is actually locally connected, and \n    // B) to not track _local_ pose data (so, no prevent/remove tracked-controller component)\n\n    // we pause the element so we can prevent pose tracking from being added.\n    this.el.pause();\n\n    // we add the actual component, to get the model generated and button meshes and event handling\n    this.el.setAttribute(this.data.controllerComponent, {\n      hand: this.data.hand,\n      model: true\n      // could also optionally support custom buttonColor, buttonTouchColor, buttonHighlightColor \n    });\n\n    // in new design, we leave this, as the controller needs to emit some of these events to itself\n    // in order to get mesh color updates\n    // this.el.components[this.data.controllerComponent].removeEventListeners();\n\n    // we don't want the remote model to listen to local button/trigger/thumbstick events, though \n    this.el.components[this.data.controllerComponent].removeControllersUpdateListener();\n\n    // some older controller components aren't as well written, and so we have to allow pose tracking to be added and then remove it\n    if (!this.el.components[this.data.controllerComponent].checkIfControllerPresent || !this.el.components[this.data.controllerComponent].loadModel) {\n      console.warn(\"fallback path: will add and then disable pose tracking\", this.data.controllerComponent, this.el, this.el.components);\n\n      // however, we do still want _one_ event listener, so we add the button meshes\n      this.el.addEventListener('model-loaded', this.el.components[this.data.controllerComponent].onModelLoaded);\n      this.catchPoseTrackingInitialization();\n      // here we have no loadModel() to use directly, so we fully inject (bypassing controller detection)\n      // and catch and remove pose tracking once it is added.\n      this.el.components[this.data.controllerComponent].injectTrackedControls({\n        profiles: JSON.parse(this.data.webxrControllerProfiles)\n      });\n    } else {\n      // ideal, default path, for controller components (like oculus-touch-controls), that have separate loadModel() function\n\n      // this prevents injectTrackedControllers from running, which prevents the \n      // tracked-controls-webxr component from being added, which is responsible for pose tracking\n      // (which we are disabling, since we want this controller to follow this NAF entity instead)\n      this.el.components[this.data.controllerComponent].checkIfControllerPresent = function (x) {\n        return x;\n      };\n      this.el.components[this.data.controllerComponent].injectTrackedControls = function (x) {\n        return x;\n      };\n\n      // we need to fire this listener to load the button meshes\n      this.el.addEventListener('model-loaded', this.el.components[this.data.controllerComponent].onModelLoaded);\n      // we load the model indicated by the remote user's headset\n      this.el.components[this.data.controllerComponent].loadModel({\n        profiles: JSON.parse(this.data.webxrControllerProfiles)\n      });\n    }\n    this.el.play();\n    this.injectedController = true;\n  },\n  getMesh: function getMesh() {\n    return this.el.getObject3D(this.str.mesh);\n  },\n  // local hands are controlled by one's controllers, non-local hands are controlled by updates via NAF\n  local: false,\n  eventFunctionMap: {\n    left: {},\n    right: {}\n  },\n  buttonEventMap: {\n    gripdown: ['grip', 'down'],\n    gripup: ['grip', 'up'],\n    trackpaddown: ['trackpad', 'down'],\n    trackpadup: ['trackpad', 'up'],\n    trackpadtouchstart: ['trackpad', 'touchstart'],\n    trackpadtouchend: ['trackpad', 'touchend'],\n    triggerdown: ['trigger', 'down'],\n    triggerup: ['trigger', 'up'],\n    triggertouchstart: ['trigger', 'touchstart'],\n    triggertouchend: ['trigger', 'touchend'],\n    griptouchstart: ['grip', 'touchstart'],\n    griptouchend: ['grip', 'touchend'],\n    abuttontouchstart: ['AorX', 'touchstart'],\n    abuttontouchend: ['AorX', 'touchend'],\n    bbuttontouchstart: ['BorY', 'touchstart'],\n    bbuttontouchend: ['BorY', 'touchend'],\n    xbuttontouchstart: ['AorX', 'touchstart'],\n    xbuttontouchend: ['AorX', 'touchend'],\n    ybuttontouchstart: ['BorY', 'touchstart'],\n    ybuttontouchend: ['BorY', 'touchend'],\n    surfacetouchstart: ['surface', 'touchstart'],\n    surfacetouchend: ['surface', 'touchend']\n\n    // these are not used for any existing gestures\n    // thumbstickdown: ['thumbstick', 'down'],\n    // thumbstickup: ['thumbstick', 'up'],  \n  },\n  visibleListeners: {\n    // (note: while `this.el` looks wrong here, we use .bind() on it within init())\n    controllerconnected: function controllerconnected() {\n      this.el.setAttribute('networked-hand-controls', 'visible', true);\n    },\n    controllerdisconnected: function controllerdisconnected() {\n      this.el.setAttribute('networked-hand-controls', 'visible', false);\n    }\n  },\n  addEventListeners: function addEventListeners() {\n    for (var evtName in this.buttonEventMap) {\n      this.el.addEventListener(evtName, this.eventFunctionMap[this.data.hand][evtName]);\n    }\n    for (var _evtName2 in this.visibleListeners) {\n      this.el.addEventListener(_evtName2, this.eventFunctionMap[this.data.hand][_evtName2]);\n    }\n  },\n  removeEventListeners: function removeEventListeners() {\n    for (var evtName in this.buttonEventMap) {\n      this.el.removeEventListener(evtName, this.eventFunctionMap[this.data.hand][evtName]);\n    }\n    for (var _evtName3 in this.visibleListeners) {\n      this.el.removeEventListener(_evtName3, this.eventFunctionMap[this.data.hand][_evtName3]);\n    }\n  },\n  // to minimize garbage collection, prevents generating huge numbers of one-time-use strings\n  str: {\n    nafHandControls: \"networked-hand-controls\",\n    mesh: \"mesh\",\n    gesture: \"gesture\",\n    down: 'down',\n    touchstart: 'touchstart',\n    fist: \"fist\",\n    point: \"point\",\n    thumbUp: \"thumbUp\",\n    pistol: \"pistol\",\n    hold: \"hold\",\n    open: \"open\",\n    controller: \"controller\",\n    controllerEvent: \"controllerEvent\"\n  },\n  handleButton: function handleButton(button, evt) {\n    // this function is only for generating networked gestures with hand model\n    if (this.data.handModelStyle === 'controller') {\n      return;\n    }\n    this.isContact = evt === this.str.down || evt === this.str.touchstart;\n    if (this.isContact === this.contact[button]) {\n      return;\n    }\n    this.contact[button] = this.isContact;\n    this.lastGesture = this.data.gesture;\n    this.determineGesture();\n    if (this.gesture === this.lastGesture) {\n      return;\n    }\n\n    // set new gesture into schema to propagate via NAF\n    this.el.setAttribute(this.str.nafHandControls, this.str.gesture, this.gesture);\n    this.handleGesture();\n  },\n  handleGesture: function handleGesture() {\n    if (this.data.gesture === this.lastGesture) {\n      return;\n    }\n    this.playAnimation();\n    this.emitGestureEvents();\n  },\n  determineGesture: function determineGesture() {\n    this.gripIsActive = this.contact.grip;\n    this.triggerIsActive = this.contact.trigger;\n    this.thumbIsActive = this.contact.trackpad || this.contact.surface;\n    this.contact.AorX || this.contact.BorY;\n    if (!this.isVive) {\n      this.gesture = this.gripIsActive && this.thumbIsActive && this.triggerIsActive ? this.str.fist : this.gripIsActive && this.thumbIsActive && !this.triggerIsActive ? this.str.point : this.gripIsActive && !this.thumbIsActive && this.triggerIsActive ? this.str.thumbUp : this.gripIsActive && !this.thumbIsActive && !this.triggerIsActive ? this.str.pistol : this.triggerIsActive ? this.str.hold : this.str.open;\n    } else {\n      // Vive handling was supposedly left incomplete\n      this.gesture = this.gripIsActive || this.triggerIsActive ? this.str.fist : this.contact.trackpad ? this.str.point : this.str.open;\n    }\n  },\n  emitGestureEvents: function emitGestureEvents() {\n    var _this$eventNames$this, _this$eventNames$this2;\n    this.el.emit((_this$eventNames$this = this.eventNames[this.lastGesture]) === null || _this$eventNames$this === void 0 ? void 0 : _this$eventNames$this.inactive);\n    this.el.emit((_this$eventNames$this2 = this.eventNames[this.data.gesture]) === null || _this$eventNames$this2 === void 0 ? void 0 : _this$eventNames$this2.active);\n  },\n  // mapping rather than function to reduce garbage collection\n  eventNames: {\n    fist: {\n      active: \"fiststart\",\n      inactive: \"fistend\"\n    },\n    thumbUp: {\n      active: \"thumbupstart\",\n      inactive: \"thumbupend\"\n    },\n    point: {\n      active: \"pointstart\",\n      inactive: \"pointend\"\n    },\n    hold: {\n      active: \"holdstart\",\n      inactive: \"holdend\"\n    },\n    open: {\n      active: \"openstart\",\n      inactive: \"openend\"\n    },\n    pistol: {\n      active: \"pistolstart\",\n      inactive: \"pistolend\"\n    }\n  },\n  playAnimation: function playAnimation() {\n    // this function seems like it could be improved\n    // implementation is from the original hand-controls component\n\n    if (!this.getMesh()) {\n      return;\n    }\n\n    // Stop all current animations\n    this.getMesh().mixer.stopAllAction();\n\n    // Grab clip action\n    this.clip = this.clipNameToClip[this.ANIMATIONS[this.data.gesture]];\n    this.toAction = this.getMesh().mixer.clipAction(this.clip);\n    this.toAction.clampWhenFinished = true;\n    this.toAction.loop = THREE.LoopRepeat;\n    this.toAction.repetitions = 0;\n    this.toAction.timeScale = this.reverse ? -1 : 1;\n    this.toAction.time = this.reverse ? this.clip.duration : 0;\n    this.toAction.weight = 1;\n    if (!this.lastGesture || this.data.gesture === this.lastGesture) {\n      this.getMesh().mixer.stopAllAction();\n      this.toAction.play();\n      return;\n    }\n\n    // Animate or crossfade from gesture to gesture\n    this.clip = this.clipNameToClip[this.ANIMATIONS[this.lastGesture]];\n    this.fromAction = this.getMesh().mixer.clipAction(this.clip);\n    this.fromAction.weight = 0.15;\n    this.fromAction.play();\n    this.toAction.play();\n    this.fromAction.crossFadeTo(this.toAction, 0.15, true);\n  },\n  // see https://github.com/aframevr/assets\n  MODEL_BASE: 'https://cdn.aframe.io/controllers/hands/',\n  MODEL_NAMES: {\n    toonLeft: 'leftHand.glb',\n    toonRight: 'rightHand.glb',\n    lowPolyLeft: 'leftHandLow.glb',\n    lowPolyRight: 'rightHandLow.glb',\n    highPolyLeft: 'leftHandHigh.glb',\n    highPolyRight: 'rightHandHigh.glb'\n  },\n  clipNameToClip: {},\n  // map from internal state names to the names of the clips as specified within the models\n  ANIMATIONS: {\n    open: 'Open',\n    point: 'Point',\n    pistol: 'Point + Thumb',\n    fist: 'Fist',\n    hold: 'Hold',\n    thumbUp: 'Thumb Up'\n  },\n  isVive: false,\n  isViveController: function isViveController() {\n    var controller = this.el.components['tracked-controls'] && this.el.components['tracked-controls'].controller;\n    this.isVive = controller && (controller.id && controller.id.indexOf('OpenVR ') === 0 || controller.profiles && controller.profiles[0] && controller.profiles[0] === 'htc-vive');\n  },\n  btnEvtMap: {},\n  // dynamically populated, but actually helpful if prototype is modified\n  setup: function setup() {\n    // preventing garbage collection by making sure these don't end up as part of the prototype\n    this.contact = {\n      grip: false,\n      trigger: false,\n      surface: false,\n      trackpad: false,\n      AorX: false,\n      BorY: false\n    };\n    this.reverse = false;\n    this.isContact = false;\n    this.injectedController = false;\n    this.lastGesture = \"\";\n    this.gesture = \"\";\n    this.gripIsActive = false;\n    this.triggerIsActive = false;\n    this.thumbIsActive = false;\n    this.clip = null;\n    this.toAction = null;\n    this.fromAction = null;\n  }\n});\n\n//# sourceURL=webpack://networked-aframe/./src/components/networked-hand-controls.js?");

/***/ }),

/***/ "./src/components/networked-scene.js":
/*!*******************************************!*\
  !*** ./src/components/networked-scene.js ***!
  \*******************************************/
/***/ (() => {

eval("/* global AFRAME, NAF */\n\nAFRAME.registerComponent('networked-scene', {\n  schema: {\n    serverURL: {\n      \"default\": '/'\n    },\n    app: {\n      \"default\": 'default'\n    },\n    room: {\n      \"default\": 'default'\n    },\n    connectOnLoad: {\n      \"default\": true\n    },\n    onConnect: {\n      \"default\": 'onConnect'\n    },\n    adapter: {\n      \"default\": 'wseasyrtc'\n    },\n    // See https://github.com/networked-aframe/networked-aframe#adapters for list of adapters\n    audio: {\n      \"default\": false\n    },\n    // Only if adapter supports audio\n    video: {\n      \"default\": false\n    },\n    // Only if adapter supports video\n    debug: {\n      \"default\": false\n    }\n  },\n  init: function init() {\n    var el = this.el;\n    this.connect = this.connect.bind(this);\n    el.addEventListener('connect', this.connect);\n    if (this.data.connectOnLoad) {\n      el.emit('connect', null, false);\n    }\n  },\n  /**\n   * Connect to signalling server and begin connecting to other clients\n   */\n  connect: function connect() {\n    NAF.log.setDebug(this.data.debug);\n    NAF.log.write('Networked-Aframe Connecting...');\n    this.checkDeprecatedProperties();\n    this.setupNetworkAdapter();\n    if (this.hasOnConnectFunction()) {\n      this.callOnConnect();\n    }\n    return NAF.connection.connect(this.data.serverURL, this.data.app, this.data.room, this.data.audio, this.data.video);\n  },\n  checkDeprecatedProperties: function checkDeprecatedProperties() {\n    // No current\n  },\n  setupNetworkAdapter: function setupNetworkAdapter() {\n    var adapterName = this.data.adapter;\n    var adapter = NAF.adapters.make(adapterName);\n    NAF.connection.setNetworkAdapter(adapter);\n    this.el.emit('adapter-ready', adapter, false);\n  },\n  hasOnConnectFunction: function hasOnConnectFunction() {\n    return this.data.onConnect != '' && window[this.data.onConnect];\n  },\n  callOnConnect: function callOnConnect() {\n    NAF.connection.onConnect(window[this.data.onConnect]);\n  },\n  remove: function remove() {\n    NAF.log.write('networked-scene disconnected');\n    this.el.removeEventListener('connect', this.connect);\n    NAF.connection.disconnect();\n  }\n});\n\n//# sourceURL=webpack://networked-aframe/./src/components/networked-scene.js?");

/***/ }),

/***/ "./src/components/networked-video-source.js":
/*!**************************************************!*\
  !*** ./src/components/networked-video-source.js ***!
  \**************************************************/
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {

eval("/* global AFRAME, NAF, THREE */\nvar naf = __webpack_require__(/*! ../NafIndex */ \"./src/NafIndex.js\");\nAFRAME.registerComponent('networked-video-source', {\n  schema: {\n    streamName: {\n      \"default\": 'video'\n    }\n  },\n  dependencies: ['material'],\n  init: function init() {\n    this.videoTexture = null;\n    this.video = null;\n    this.stream = null;\n    this._setMediaStream = this._setMediaStream.bind(this);\n    this._waitForMediaStream = this._waitForMediaStream.bind(this);\n    this._waitForMediaStream();\n  },\n  _waitForMediaStream: function _waitForMediaStream() {\n    var _this = this;\n    NAF.utils.getNetworkedEntity(this.el).then(function (networkedEl) {\n      var ownerId = networkedEl.components.networked.data.owner;\n      if (ownerId) {\n        NAF.connection.adapter.getMediaStream(ownerId, _this.data.streamName).then(_this._setMediaStream)[\"catch\"](function (e) {\n          return naf.log.error(\"Error getting media stream for \".concat(ownerId), e);\n        });\n      } else {\n        // Correctly configured local entity, perhaps do something here for enabling debug audio loopback\n      }\n    });\n  },\n  _setMediaStream: function _setMediaStream(newStream) {\n    var _this2 = this;\n    if (!this.video) {\n      this.setupVideo();\n    }\n    if (newStream !== this.stream) {\n      if (this.stream) {\n        this._clearMediaStream();\n      }\n      if (newStream) {\n        this.video.srcObject = newStream;\n        var playResult = this.video.play();\n        if (playResult instanceof Promise) {\n          playResult[\"catch\"](function (e) {\n            return naf.log.error(\"Error play video stream\", e);\n          });\n        }\n        if (this.videoTexture) {\n          this.videoTexture.dispose();\n        }\n        this.videoTexture = new THREE.VideoTexture(this.video);\n        var mesh = this.el.getObject3D('mesh');\n        mesh.material.map = this.videoTexture;\n        mesh.material.map.colorSpace = THREE.SRGBColorSpace;\n        mesh.material.needsUpdate = true;\n\n        // Listen for the 'removetrack' event on the MediaStream\n        // that is emitted when the remote screen sharing stops.\n        newStream.addEventListener('removetrack', function () {\n          _this2._clearMediaStream();\n          _this2._waitForMediaStream();\n        });\n      }\n      this.stream = newStream;\n    }\n  },\n  _clearMediaStream: function _clearMediaStream() {\n    this.stream = null;\n    if (this.videoTexture) {\n      if (this.videoTexture.image instanceof HTMLVideoElement) {\n        // Note: this.videoTexture.image === this.video\n        var video = this.videoTexture.image;\n        video.pause();\n        video.srcObject = null;\n        video.load();\n      }\n      this.videoTexture.dispose();\n      this.videoTexture = null;\n      var mesh = this.el.getObject3D('mesh');\n      mesh.material.map = null;\n      mesh.material.needsUpdate = true;\n    }\n  },\n  remove: function remove() {\n    this._clearMediaStream();\n  },\n  setupVideo: function setupVideo() {\n    if (!this.video) {\n      var video = document.createElement('video');\n      video.setAttribute('autoplay', true);\n      video.setAttribute('playsinline', true);\n      video.setAttribute('muted', true);\n      this.video = video;\n    }\n  }\n});\n\n//# sourceURL=webpack://networked-aframe/./src/components/networked-video-source.js?");

/***/ }),

/***/ "./src/components/networked.js":
/*!*************************************!*\
  !*** ./src/components/networked.js ***!
  \*************************************/
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {

eval("function _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nfunction _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == _typeof(i) ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != _typeof(i)) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\n/* global AFRAME, NAF, THREE */\nvar deepEqual = __webpack_require__(/*! ../DeepEquals */ \"./src/DeepEquals.js\");\nvar InterpolationBuffer = __webpack_require__(/*! buffered-interpolation */ \"./node_modules/buffered-interpolation/dist/buffered-interpolation.js\");\n// InterpolationBuffer.MODE_LERP is not exported, it's undefined\nvar MODE_LERP = 0;\nvar DEG2RAD = THREE.MathUtils.DEG2RAD;\nvar OBJECT3D_COMPONENTS = ['position', 'rotation', 'scale'];\n\n// Expose InterpolationBuffer on NAF global\nNAF.InterpolationBuffer = InterpolationBuffer;\nfunction defaultRequiresUpdate() {\n  var cachedData = null;\n  return function (newData) {\n    if (cachedData === null || !deepEqual(cachedData, newData)) {\n      cachedData = AFRAME.utils.clone(newData);\n      return true;\n    }\n    return false;\n  };\n}\nfunction isValidVector3(v) {\n  return !!(v.isVector3 && !isNaN(v.x) && !isNaN(v.y) && !isNaN(v.z) && v.x !== null && v.y !== null && v.z !== null);\n}\nfunction isValidQuaternion(q) {\n  return !!(q.isQuaternion && !isNaN(q.x) && !isNaN(q.y) && !isNaN(q.z) && !isNaN(q.w) && q.x !== null && q.y !== null && q.z !== null && q.w !== null);\n}\nvar throttle = function () {\n  var previousLogTime = 0;\n  return function throttle(f, milliseconds) {\n    var now = Date.now();\n    if (now - previousLogTime > milliseconds) {\n      previousLogTime = now;\n      f();\n    }\n  };\n}();\nfunction warnOnInvalidNetworkUpdate() {\n  NAF.log.warn(\"Received invalid network update.\");\n}\nfunction clearObject(obj) {\n  for (var key in obj) {\n    delete obj[key];\n  }\n  return obj;\n}\nAFRAME.registerSystem(\"networked\", {\n  init: function init() {\n    // An array of \"networked\" component instances.\n    this.components = [];\n    this.nextSyncTime = 0;\n  },\n  register: function register(component) {\n    this.components.push(component);\n  },\n  deregister: function deregister(component) {\n    var idx = this.components.indexOf(component);\n    if (idx > -1) {\n      this.components.splice(idx, 1);\n    }\n  },\n  tick: function () {\n    // \"d\" is an array of entity datas per entity in this.components.\n    var data = {\n      d: []\n    };\n    return function () {\n      if (!NAF.connection.adapter) return;\n      if (this.el.clock.elapsedTime < this.nextSyncTime) return;\n\n      // Reset the \"d\" array\n      data.d.length = 0;\n      for (var i = 0, l = this.components.length; i < l; i++) {\n        var c = this.components[i];\n        if (!c.isMine()) continue;\n        if (!c.el.parentElement) {\n          NAF.log.error(\"entity registered with system despite being removed\");\n          //TODO: Find out why tick is still being called\n          return;\n        }\n        var syncData = this.components[i].syncDirty();\n        if (!syncData) continue;\n        data.d.push(syncData);\n      }\n      if (data.d.length > 0) {\n        NAF.connection.broadcastData('um', data);\n      }\n      this.updateNextSyncTime();\n    };\n  }(),\n  updateNextSyncTime: function updateNextSyncTime() {\n    this.nextSyncTime = this.el.clock.elapsedTime + 1 / NAF.options.updateRate;\n  }\n});\nAFRAME.registerComponent('networked', {\n  schema: {\n    template: {\n      \"default\": ''\n    },\n    attachTemplateToLocal: {\n      \"default\": true\n    },\n    persistent: {\n      \"default\": false\n    },\n    networkId: {\n      \"default\": ''\n    },\n    owner: {\n      \"default\": ''\n    },\n    creator: {\n      \"default\": ''\n    }\n  },\n  init: function init() {\n    this.OWNERSHIP_GAINED = 'ownership-gained';\n    this.OWNERSHIP_CHANGED = 'ownership-changed';\n    this.OWNERSHIP_LOST = 'ownership-lost';\n    this.onOwnershipGainedEvent = {\n      el: this.el\n    };\n    this.onOwnershipChangedEvent = {\n      el: this.el\n    };\n    this.onOwnershipLostEvent = {\n      el: this.el\n    };\n    this.conversionEuler = new THREE.Euler();\n    this.conversionEuler.order = \"YXZ\";\n    this.bufferInfos = [];\n    this.bufferPosition = new THREE.Vector3();\n    this.bufferQuaternion = new THREE.Quaternion();\n    this.bufferScale = new THREE.Vector3();\n    var wasCreatedByNetwork = !!this.el.firstUpdateData;\n    this.onConnected = this.onConnected.bind(this);\n    this.syncData = {};\n    this.componentsData = {};\n    this.componentSchemas = NAF.schemas.getComponents(this.data.template);\n    this.cachedElements = new Array(this.componentSchemas.length);\n    this.networkUpdatePredicates = this.componentSchemas.map(function (x) {\n      return x.requiresNetworkUpdate && x.requiresNetworkUpdate() || defaultRequiresUpdate();\n    });\n\n    // Fill cachedElements array with null elements\n    this.invalidateCachedElements();\n    this.initNetworkParent();\n    var networkId;\n    if (this.data.networkId === '') {\n      networkId = NAF.utils.createNetworkId();\n      this.el.setAttribute(this.name, {\n        networkId: networkId\n      });\n    } else {\n      networkId = this.data.networkId;\n    }\n    if (!this.el.id) {\n      this.el.setAttribute('id', 'naf-' + networkId);\n    }\n    if (wasCreatedByNetwork) {\n      this.firstUpdate();\n    } else {\n      if (this.data.attachTemplateToLocal) {\n        this.attachTemplateToLocal();\n      }\n      this.registerEntity(this.data.networkId);\n    }\n    this.lastOwnerTime = -1;\n    if (NAF.clientId) {\n      this.onConnected();\n    } else {\n      document.body.addEventListener('connected', this.onConnected, false);\n    }\n    document.body.dispatchEvent(this.entityCreatedEvent());\n    this.el.dispatchEvent(new CustomEvent('instantiated', {\n      detail: {\n        el: this.el\n      }\n    }));\n    this.el.sceneEl.systems.networked.register(this);\n  },\n  attachTemplateToLocal: function attachTemplateToLocal() {\n    var template = NAF.schemas.getCachedTemplate(this.data.template);\n    var elAttrs = template.attributes;\n\n    // Merge root element attributes with this entity\n    for (var attrIdx = 0; attrIdx < elAttrs.length; attrIdx++) {\n      this.el.setAttribute(elAttrs[attrIdx].name, elAttrs[attrIdx].value);\n    }\n\n    // Append all child elements\n    while (template.firstElementChild) {\n      this.el.appendChild(template.firstElementChild);\n    }\n  },\n  takeOwnership: function takeOwnership() {\n    var owner = this.data.owner;\n    var lastOwnerTime = this.lastOwnerTime;\n    var now = NAF.connection.getServerTime();\n    if (owner && !this.isMine() && lastOwnerTime < now) {\n      this.lastOwnerTime = now;\n      this.removeLerp();\n      this.el.setAttribute('networked', {\n        owner: NAF.clientId\n      });\n      this.syncAll();\n      this.onOwnershipGainedEvent.oldOwner = owner;\n      this.el.emit(this.OWNERSHIP_GAINED, this.onOwnershipGainedEvent);\n      this.onOwnershipChangedEvent.oldOwner = owner;\n      this.onOwnershipChangedEvent.newOwner = NAF.clientId;\n      this.el.emit(this.OWNERSHIP_CHANGED, this.onOwnershipChangedEvent);\n      return true;\n    }\n    return false;\n  },\n  initNetworkParent: function initNetworkParent() {\n    var parentEl = this.el.parentElement;\n    if (parentEl['components'] && parentEl.components['networked']) {\n      this.parent = parentEl;\n    } else {\n      this.parent = null;\n    }\n  },\n  registerEntity: function registerEntity(networkId) {\n    NAF.entities.registerEntity(networkId, this.el);\n  },\n  applyPersistentFirstSync: function applyPersistentFirstSync() {\n    var networkId = this.data.networkId;\n    var persistentFirstSync = NAF.entities.getPersistentFirstSync(networkId);\n    if (persistentFirstSync) {\n      this.networkUpdate(persistentFirstSync);\n      NAF.entities.forgetPersistentFirstSync(networkId);\n    }\n  },\n  firstUpdate: function firstUpdate() {\n    var entityData = this.el.firstUpdateData;\n    this.networkUpdate(entityData);\n    this.el.firstUpdateData = undefined;\n  },\n  onConnected: function onConnected() {\n    var _this = this;\n    if (this.data.owner === '') {\n      this.lastOwnerTime = NAF.connection.getServerTime();\n      this.el.setAttribute(this.name, {\n        owner: NAF.clientId,\n        creator: NAF.clientId\n      });\n      setTimeout(function () {\n        //a-primitives attach their components on the next frame; wait for components to be attached before calling syncAll\n        if (!_this.el.parentNode) {\n          NAF.log.warn(\"Networked element was removed before ever getting the chance to syncAll\");\n          return;\n        }\n        _this.syncAll(undefined, true);\n      }, 0);\n    }\n    document.body.removeEventListener('connected', this.onConnected, false);\n  },\n  isMine: function isMine() {\n    return this.data.owner === NAF.clientId;\n  },\n  createdByMe: function createdByMe() {\n    return this.data.creator === NAF.clientId;\n  },\n  tick: function tick(time, dt) {\n    if (!this.isMine() && NAF.options.useLerp) {\n      for (var i = 0; i < this.bufferInfos.length; i++) {\n        var bufferInfo = this.bufferInfos[i];\n        var buffer = bufferInfo.buffer;\n        var object3D = bufferInfo.object3D;\n        var componentNames = bufferInfo.componentNames;\n        buffer.update(dt);\n        if (componentNames.includes(\"position\")) {\n          var position = buffer.getPosition();\n          if (isValidVector3(position)) {\n            object3D.position.copy(position);\n          } else {\n            throttle(warnOnInvalidNetworkUpdate, 5000);\n          }\n        }\n        if (componentNames.includes(\"rotation\")) {\n          var quaternion = buffer.getQuaternion();\n          if (isValidQuaternion(quaternion)) {\n            object3D.quaternion.copy(quaternion);\n          } else {\n            throttle(warnOnInvalidNetworkUpdate, 5000);\n          }\n        }\n        if (componentNames.includes(\"scale\")) {\n          var scale = buffer.getScale();\n          if (isValidVector3(scale)) {\n            object3D.scale.copy(scale);\n          } else {\n            throttle(warnOnInvalidNetworkUpdate, 5000);\n          }\n        }\n      }\n    }\n  },\n  /* Sending updates */\n\n  syncAll: function syncAll(targetClientId, isFirstSync) {\n    if (!this.canSync()) {\n      return;\n    }\n    var components = this.gatherComponentsData(true);\n    var syncData = this.createSyncData(components, isFirstSync);\n    if (targetClientId) {\n      NAF.connection.sendDataGuaranteed(targetClientId, 'u', syncData);\n    } else {\n      NAF.connection.broadcastDataGuaranteed('u', syncData);\n    }\n  },\n  syncDirty: function syncDirty() {\n    if (!this.canSync()) {\n      return;\n    }\n    var components = this.gatherComponentsData(false);\n    if (components === null) {\n      return;\n    }\n    return this.createSyncData(components);\n  },\n  getCachedElement: function getCachedElement(componentSchemaIndex) {\n    var cachedElement = this.cachedElements[componentSchemaIndex];\n    if (cachedElement) {\n      return cachedElement;\n    }\n    var componentSchema = this.componentSchemas[componentSchemaIndex];\n    if (componentSchema.selector) {\n      return this.cachedElements[componentSchemaIndex] = this.el.querySelector(componentSchema.selector);\n    } else {\n      return this.cachedElements[componentSchemaIndex] = this.el;\n    }\n  },\n  invalidateCachedElements: function invalidateCachedElements() {\n    for (var i = 0; i < this.cachedElements.length; i++) {\n      this.cachedElements[i] = null;\n    }\n  },\n  gatherComponentsData: function gatherComponentsData(fullSync) {\n    var componentsData = null;\n    for (var i = 0; i < this.componentSchemas.length; i++) {\n      var componentSchema = this.componentSchemas[i];\n      var componentElement = this.getCachedElement(i);\n      if (!componentElement) {\n        if (fullSync) {\n          componentsData = componentsData || clearObject(this.componentsData);\n          componentsData[i] = null;\n        }\n        continue;\n      }\n      var componentName = componentSchema.component ? componentSchema.component : componentSchema;\n      var componentData = componentElement.getAttribute(componentName);\n      if (componentData === null) {\n        if (fullSync) {\n          componentsData = componentsData || clearObject(this.componentsData);\n          componentsData[i] = null;\n        }\n        continue;\n      }\n      var syncedComponentData = componentSchema.property ? componentData[componentSchema.property] : componentData;\n\n      // Use networkUpdatePredicate to check if the component needs to be updated.\n      // Call networkUpdatePredicate first so that it can update any cached values in the event of a fullSync.\n      if (this.networkUpdatePredicates[i](syncedComponentData) || fullSync) {\n        componentsData = componentsData || clearObject(this.componentsData);\n        componentsData[i] = syncedComponentData;\n      }\n    }\n    return componentsData;\n  },\n  createSyncData: function createSyncData(components, isFirstSync) {\n    var syncData = this.syncData,\n      data = this.data;\n    syncData.networkId = data.networkId;\n    syncData.owner = data.owner;\n    syncData.creator = data.creator;\n    syncData.lastOwnerTime = this.lastOwnerTime;\n    syncData.template = data.template;\n    syncData.persistent = data.persistent;\n    syncData.parent = this.getParentId();\n    syncData.components = components;\n    syncData.isFirstSync = !!isFirstSync;\n    return syncData;\n  },\n  canSync: function canSync() {\n    // This client will send a sync if:\n    //\n    // - The client is the owner\n    // - The client is the creator, and the owner is not in the room.\n    //\n    // The reason for the latter case is so the object will still be\n    // properly instantiated if the owner leaves. (Since the object lifetime\n    // is tied to the creator.)\n    if (this.data.owner && this.isMine()) return true;\n    if (!this.createdByMe()) return false;\n    var clients = NAF.connection.getConnectedClients();\n    for (var clientId in clients) {\n      if (clientId === this.data.owner) return false;\n    }\n    return true;\n  },\n  getParentId: function getParentId() {\n    this.initNetworkParent(); // TODO fix calling this each network tick\n    if (!this.parent) {\n      return null;\n    }\n    var netComp = this.parent.getAttribute('networked');\n    return netComp.networkId;\n  },\n  /* Receiving updates */\n\n  networkUpdate: function networkUpdate(entityData) {\n    // We received a network update but the component is not initialized yet,\n    // merge this.el.firstUpdateData with latest received entityData and return.\n    // The component initialization will call this.firstUpdate() that will call networkUpdate(this.el.firstUpdateData)\n    // https://github.com/networked-aframe/networked-aframe/issues/476\n    if (this.componentSchemas === undefined) {\n      if (this.el.firstUpdateData && this.el.firstUpdateData !== entityData) {\n        this.el.firstUpdateData.components = _objectSpread(_objectSpread({}, this.el.firstUpdateData.components), entityData.components);\n      }\n      return;\n    }\n\n    // Avoid updating components if the entity data received did not come from the current owner.\n    if (entityData.lastOwnerTime < this.lastOwnerTime || this.lastOwnerTime === entityData.lastOwnerTime && this.data.owner > entityData.owner) {\n      return;\n    }\n    if (this.data.owner !== entityData.owner) {\n      var wasMine = this.isMine();\n      this.lastOwnerTime = entityData.lastOwnerTime;\n      var oldOwner = this.data.owner;\n      var newOwner = entityData.owner;\n      this.el.setAttribute('networked', {\n        owner: entityData.owner\n      });\n      if (wasMine) {\n        this.onOwnershipLostEvent.newOwner = newOwner;\n        this.el.emit(this.OWNERSHIP_LOST, this.onOwnershipLostEvent);\n      }\n      this.onOwnershipChangedEvent.oldOwner = oldOwner;\n      this.onOwnershipChangedEvent.newOwner = newOwner;\n      this.el.emit(this.OWNERSHIP_CHANGED, this.onOwnershipChangedEvent);\n    }\n    if (this.data.persistent !== entityData.persistent) {\n      this.el.setAttribute('networked', {\n        persistent: entityData.persistent\n      });\n    }\n    this.updateNetworkedComponents(entityData.components);\n  },\n  updateNetworkedComponents: function updateNetworkedComponents(components) {\n    for (var componentIndex = 0, l = this.componentSchemas.length; componentIndex < l; componentIndex++) {\n      var componentData = components[componentIndex];\n      var componentSchema = this.componentSchemas[componentIndex];\n      var componentElement = this.getCachedElement(componentIndex);\n      if (componentElement === null || componentData === null || componentData === undefined) {\n        continue;\n      }\n      if (componentSchema.component) {\n        if (componentSchema.property) {\n          this.updateNetworkedComponent(componentElement, componentSchema.component, componentSchema.property, componentData);\n        } else {\n          this.updateNetworkedComponent(componentElement, componentSchema.component, componentData);\n        }\n      } else {\n        this.updateNetworkedComponent(componentElement, componentSchema, componentData);\n      }\n    }\n  },\n  updateNetworkedComponent: function updateNetworkedComponent(el, componentName, data, value) {\n    if (!NAF.options.useLerp || !OBJECT3D_COMPONENTS.includes(componentName)) {\n      if (value === undefined) {\n        el.setAttribute(componentName, data);\n      } else {\n        el.setAttribute(componentName, data, value);\n      }\n      return;\n    }\n    var bufferInfo;\n    for (var i = 0, l = this.bufferInfos.length; i < l; i++) {\n      var info = this.bufferInfos[i];\n      if (info.object3D === el.object3D) {\n        bufferInfo = info;\n        break;\n      }\n    }\n    if (!bufferInfo) {\n      bufferInfo = {\n        buffer: new InterpolationBuffer(MODE_LERP, 0.1),\n        object3D: el.object3D,\n        componentNames: [componentName]\n      };\n      this.bufferInfos.push(bufferInfo);\n    } else {\n      var componentNames = bufferInfo.componentNames;\n      if (!componentNames.includes(componentName)) {\n        componentNames.push(componentName);\n      }\n    }\n    var buffer = bufferInfo.buffer;\n    switch (componentName) {\n      case 'position':\n        buffer.setPosition(this.bufferPosition.set(data.x, data.y, data.z));\n        return;\n      case 'rotation':\n        this.conversionEuler.set(DEG2RAD * data.x, DEG2RAD * data.y, DEG2RAD * data.z);\n        buffer.setQuaternion(this.bufferQuaternion.setFromEuler(this.conversionEuler));\n        return;\n      case 'scale':\n        buffer.setScale(this.bufferScale.set(data.x, data.y, data.z));\n        return;\n    }\n    NAF.log.error('Could not set value in interpolation buffer.', el, componentName, data, bufferInfo);\n  },\n  removeLerp: function removeLerp() {\n    this.bufferInfos = [];\n  },\n  remove: function remove() {\n    document.body.removeEventListener('connected', this.onConnected, false);\n    if (this.isMine() && NAF.connection.isConnected()) {\n      var syncData = {\n        networkId: this.data.networkId\n      };\n      if (NAF.entities.hasEntity(this.data.networkId)) {\n        NAF.connection.broadcastDataGuaranteed('r', syncData);\n      } else {\n        // The entity may already have been removed if the creator (different of the current owner) left the room.\n        // Don't log an error in this case.\n        if (!(this.data.creator && NAF.connection.activeDataChannels[this.data.creator] === false)) {\n          NAF.log.error(\"Removing networked entity that is not in entities array.\");\n        }\n      }\n    }\n    NAF.entities.forgetEntity(this.data.networkId);\n    document.body.dispatchEvent(this.entityRemovedEvent(this.data.networkId));\n    this.el.sceneEl.systems.networked.deregister(this);\n  },\n  entityCreatedEvent: function entityCreatedEvent() {\n    return new CustomEvent('entityCreated', {\n      detail: {\n        el: this.el\n      }\n    });\n  },\n  entityRemovedEvent: function entityRemovedEvent(networkId) {\n    return new CustomEvent('entityRemoved', {\n      detail: {\n        networkId: networkId\n      }\n    });\n  }\n});\n\n//# sourceURL=webpack://networked-aframe/./src/components/networked.js?");

/***/ }),

/***/ "./src/index.js":
/*!**********************!*\
  !*** ./src/index.js ***!
  \**********************/
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {

eval("// Global vars and functions\n__webpack_require__(/*! ./NafIndex.js */ \"./src/NafIndex.js\");\n\n// Network components\n__webpack_require__(/*! ./components/networked-scene */ \"./src/components/networked-scene.js\");\n__webpack_require__(/*! ./components/networked */ \"./src/components/networked.js\");\n__webpack_require__(/*! ./components/networked-audio-source */ \"./src/components/networked-audio-source.js\");\n__webpack_require__(/*! ./components/networked-video-source */ \"./src/components/networked-video-source.js\");\n__webpack_require__(/*! ./components/networked-hand-controls */ \"./src/components/networked-hand-controls.js\");\n\n//# sourceURL=webpack://networked-aframe/./src/index.js?");

/***/ }),

/***/ "./src/options.js":
/*!************************!*\
  !*** ./src/options.js ***!
  \************************/
/***/ ((module) => {

eval("var options = {\n  debug: false,\n  updateRate: 15,\n  // How often network components call `sync`\n  useLerp: true,\n  // lerp position, rotation, and scale components on networked entities.\n  firstSyncSource: null,\n  // If specified, only allow first syncs from this source.\n  syncSource: null // If specified, only allow syncs from this source.\n};\nmodule.exports = options;\n\n//# sourceURL=webpack://networked-aframe/./src/options.js?");

/***/ }),

/***/ "./src/utils.js":
/*!**********************!*\
  !*** ./src/utils.js ***!
  \**********************/
/***/ ((module) => {

eval("/* global NAF, THREE */\n\nmodule.exports.whenEntityLoaded = function (entity, callback) {\n  if (entity.hasLoaded) {\n    callback();\n  }\n  entity.addEventListener('loaded', function () {\n    callback();\n  });\n};\nmodule.exports.createHtmlNodeFromString = function (str) {\n  var div = document.createElement('div');\n  div.innerHTML = str;\n  var child = div.firstChild;\n  return child;\n};\nmodule.exports.getCreator = function (el) {\n  var components = el.components;\n  if (components['networked']) {\n    return components['networked'].data.creator;\n  }\n  return null;\n};\nmodule.exports.getNetworkOwner = function (el) {\n  var components = el.components;\n  if (components['networked']) {\n    return components['networked'].data.owner;\n  }\n  return null;\n};\nmodule.exports.getNetworkId = function (el) {\n  var components = el.components;\n  if (components['networked']) {\n    return components['networked'].data.networkId;\n  }\n  return null;\n};\nmodule.exports.now = function () {\n  return Date.now();\n};\nmodule.exports.createNetworkId = function () {\n  return Math.random().toString(36).substring(2, 9);\n};\n\n/**\n * Find the closest ancestor (including the passed in entity) that has a `networked` component\n * @param {ANode} entity - Entity to begin the search on\n * @returns {Promise<ANode>} An promise that resolves to an entity with a `networked` component\n */\nfunction getNetworkedEntity(entity) {\n  return new Promise(function (resolve, reject) {\n    var curEntity = entity;\n    while (curEntity && curEntity.components && !curEntity.components.networked) {\n      curEntity = curEntity.parentNode;\n    }\n    if (!curEntity || !curEntity.components || !curEntity.components.networked) {\n      return reject(\"Entity does not have and is not a child of an entity with the [networked] component \");\n    }\n    if (curEntity.hasLoaded) {\n      resolve(curEntity);\n    } else {\n      curEntity.addEventListener(\"instantiated\", function () {\n        resolve(curEntity);\n      }, {\n        once: true\n      });\n    }\n  });\n}\nmodule.exports.getNetworkedEntity = getNetworkedEntity;\nmodule.exports.takeOwnership = function (entity) {\n  var curEntity = entity;\n  while (curEntity && curEntity.components && !curEntity.components.networked) {\n    curEntity = curEntity.parentNode;\n  }\n  if (!curEntity || !curEntity.components || !curEntity.components.networked) {\n    throw new Error(\"Entity does not have and is not a child of an entity with the [networked] component \");\n  }\n  return curEntity.components.networked.takeOwnership();\n};\nmodule.exports.isMine = function (entity) {\n  var curEntity = entity;\n  while (curEntity && curEntity.components && !curEntity.components.networked) {\n    curEntity = curEntity.parentNode;\n  }\n  if (!curEntity || !curEntity.components || !curEntity.components.networked) {\n    throw new Error(\"Entity does not have and is not a child of an entity with the [networked] component \");\n  }\n\n  // When remote networked entities are initially created, there's a frame delay before they are completely instantiated.\n  // On that frame, data is undefined in aframe lower than 1.6.0 so we can't check the owner. In this instance we assume that the user is not the owner of the entity.\n  // That's not an issue anymore with aframe 1.6.0, this.data can't be undefined and is initialized to an empty object for a multi properties component.\n  if (!curEntity.components.networked.data) {\n    return false;\n  }\n  return curEntity.components.networked.data.owner === NAF.clientId;\n};\nmodule.exports.almostEqualVec3 = function (u, v, epsilon) {\n  return Math.abs(u.x - v.x) < epsilon && Math.abs(u.y - v.y) < epsilon && Math.abs(u.z - v.z) < epsilon;\n};\nmodule.exports.vectorRequiresUpdate = function (epsilon) {\n  return function () {\n    var prev = null;\n    return function (curr) {\n      if (prev === null) {\n        prev = new THREE.Vector3(curr.x, curr.y, curr.z);\n        return true;\n      } else if (!NAF.utils.almostEqualVec3(prev, curr, epsilon)) {\n        prev.copy(curr);\n        return true;\n      }\n      return false;\n    };\n  };\n};\n\n//# sourceURL=webpack://networked-aframe/./src/utils.js?");

/***/ })

/******/ 	});
/************************************************************************/
/******/ 	// The module cache
/******/ 	var __webpack_module_cache__ = {};
/******/ 	
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/ 		// Check if module is in cache
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
/******/ 		if (cachedModule !== undefined) {
/******/ 			return cachedModule.exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = __webpack_module_cache__[moduleId] = {
/******/ 			// no module.id needed
/******/ 			// no module.loaded needed
/******/ 			exports: {}
/******/ 		};
/******/ 	
/******/ 		// Execute the module function
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/ 	
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/ 	
/************************************************************************/
/******/ 	
/******/ 	// startup
/******/ 	// Load entry module and return exports
/******/ 	// This entry module can't be inlined because the eval devtool is used.
/******/ 	var __webpack_exports__ = __webpack_require__("./src/index.js");
/******/ 	
/******/ })()
;