From 1ce83b97f6e7954e5d38515ff0ee48fa9469ad09 Mon Sep 17 00:00:00 2001 From: Walter Perdan Date: Tue, 10 Dec 2024 20:51:46 +0100 Subject: [PATCH] removing not necessary main.js file --- aframe/dist/main.js | 636 -------------------------------------------- 1 file changed, 636 deletions(-) delete mode 100644 aframe/dist/main.js diff --git a/aframe/dist/main.js b/aframe/dist/main.js deleted file mode 100644 index d86fad73..00000000 --- a/aframe/dist/main.js +++ /dev/null @@ -1,636 +0,0 @@ -/* - * 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__ = { - /***/ "./src/component-anchor.js": - /*!*********************************!*\ - !*** ./src/component-anchor.js ***! - \*********************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _three_js_src_new_api_arjs_anchor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../three.js/src/new-api/arjs-anchor */ \"../three.js/src/new-api/arjs-anchor.js\");\n/* harmony import */ var _three_js_src_new_api_arjs_debugui__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../three.js/src/new-api/arjs-debugui */ \"../three.js/src/new-api/arjs-debugui.js\");\n/* harmony import */ var _three_js_src_threex_arjs_context__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../three.js/src/threex/arjs-context */ \"../three.js/src/threex/arjs-context.js\");\n\n\n\n\n\n// //////////////////////////////////////////////////////////////////////////////\n//\t\tarjs-anchor\n//////////////////////////////////////////////////////////////////////////////\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('arjs-anchor', {\n dependencies: ['arjs', 'artoolkit'],\n schema: {\n preset: {\n type: 'string',\n },\n markerhelpers: {\t// IIF preset === 'area'\n type: 'boolean',\n default: false,\n },\n\n // controls parameters\n size: {\n type: 'number',\n default: 1\n },\n type: {\n type: 'string',\n },\n patternUrl: {\n type: 'string',\n },\n barcodeValue: {\n type: 'number'\n },\n changeMatrixMode: {\n type: 'string',\n default: 'modelViewMatrix',\n },\n minConfidence: {\n type: 'number',\n default: 0.6,\n },\n smooth: {\n type: 'boolean',\n default: false,\n },\n smoothCount: {\n type: 'number',\n default: 5,\n },\n smoothTolerance: {\n type: 'number',\n default: 0.01,\n },\n smoothThreshold: {\n type: 'number',\n default: 2,\n },\n },\n init: function () {\n var _this = this\n\n // get arjsSystem\n var arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tCode Separator\n //////////////////////////////////////////////////////////////////////////////\n\n _this.isReady = false\n _this._arAnchor = null\n\n // honor object visibility\n if (_this.data.changeMatrixMode === 'modelViewMatrix') {\n _this.el.object3D.visible = false\n } else if (_this.data.changeMatrixMode === 'cameraTransformMatrix') {\n _this.el.sceneEl.object3D.visible = false\n } else console.assert(false)\n\n // trick to wait until arjsSystem is isReady\n var startedAt = Date.now()\n var timerId = setInterval(function () {\n // wait until the system is isReady\n if (arjsSystem.isReady === false) return\n\n clearInterval(timerId)\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tupdate arProfile\n //////////////////////////////////////////////////////////////////////////////\n var arProfile = arjsSystem._arProfile\n\n // arProfile.changeMatrixMode('modelViewMatrix')\n arProfile.changeMatrixMode(_this.data.changeMatrixMode)\n\n // honor this.data.preset\n var markerParameters = Object.assign({}, arProfile.defaultMarkerParameters)\n\n if (_this.data.preset === 'hiro') {\n markerParameters.type = 'pattern'\n markerParameters.patternUrl = _three_js_src_threex_arjs_context__WEBPACK_IMPORTED_MODULE_3__[\"default\"].baseURL + 'examples/marker-training/examples/pattern-files/pattern-hiro.patt'\n markerParameters.markersAreaEnabled = false\n } else if (_this.data.preset === 'kanji') {\n markerParameters.type = 'pattern'\n markerParameters.patternUrl = _three_js_src_threex_arjs_context__WEBPACK_IMPORTED_MODULE_3__[\"default\"].baseURL + 'examples/marker-training/examples/pattern-files/pattern-kanji.patt'\n markerParameters.markersAreaEnabled = false\n } else if (_this.data.preset === 'area') {\n markerParameters.type = 'barcode'\n markerParameters.barcodeValue = 1001\n markerParameters.markersAreaEnabled = true\n } else if (_this.data.type === 'barcode') {\n markerParameters = {\n type: _this.data.type,\n changeMatrixMode: 'modelViewMatrix',\n barcodeValue: _this.data.barcodeValue,\n markersAreaEnabled: false\n }\n } else if (_this.data.type === 'pattern') {\n markerParameters.type = _this.data.type\n markerParameters.patternUrl = _this.data.patternUrl;\n markerParameters.markersAreaEnabled = false\n }\n \n markerParameters.minConfidence = _this.data.minConfidence;\n markerParameters.smooth = _this.data.smooth;\n markerParameters.smoothCount = _this.data.smoothCount;\n markerParameters.smoothTolerance = _this.data.smoothTolerance;\n markerParameters.smoothThreshold = _this.data.smoothThreshold;\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tcreate arAnchor\n //////////////////////////////////////////////////////////////////////////////\n\n var arSession = arjsSystem._arSession\n var arAnchor = _this._arAnchor = new _three_js_src_new_api_arjs_anchor__WEBPACK_IMPORTED_MODULE_1__[\"default\"](arSession, markerParameters)\n\n // it is now considered isReady\n _this.isReady = true\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\thonor .debugUIEnabled\n //////////////////////////////////////////////////////////////////////////////\n if (arjsSystem.data.debugUIEnabled) {\n // get or create containerElement\n var containerElement = document.querySelector('#arjsDebugUIContainer')\n if (containerElement === null) {\n containerElement = document.createElement('div')\n containerElement.id = 'arjsDebugUIContainer'\n containerElement.setAttribute('style', 'position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1; color: grey;')\n document.body.appendChild(containerElement)\n }\n // create anchorDebugUI\n var anchorDebugUI = new _three_js_src_new_api_arjs_debugui__WEBPACK_IMPORTED_MODULE_2__.AnchorDebugUI(arAnchor)\n containerElement.appendChild(anchorDebugUI.domElement)\n }\n }, 1000 / 60)\n },\n remove: function () {\n },\n update: function () {\n },\n tick: function () {\n var _this = this\n // if not yet isReady, do nothing\n if (this.isReady === false) return\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tupdate arAnchor\n //////////////////////////////////////////////////////////////////////////////\n var arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit\n this._arAnchor.update()\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\thonor pose\n //////////////////////////////////////////////////////////////////////////////\n var arWorldRoot = this._arAnchor.object3d\n arWorldRoot.updateMatrixWorld(true)\n arWorldRoot.matrixWorld.decompose(this.el.object3D.position, this.el.object3D.quaternion, this.el.object3D.scale)\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\thonor visibility\n //////////////////////////////////////////////////////////////////////////////\n if (_this._arAnchor.parameters.changeMatrixMode === 'modelViewMatrix') {\n var wasVisible = _this.el.object3D.visible\n _this.el.object3D.visible = this._arAnchor.object3d.visible\n } else if (_this._arAnchor.parameters.changeMatrixMode === 'cameraTransformMatrix') {\n var wasVisible = _this.el.sceneEl.object3D.visible\n _this.el.sceneEl.object3D.visible = this._arAnchor.object3d.visible\n } else console.assert(false)\n\n // emit markerFound markerLost\n if (_this._arAnchor.object3d.visible === true && wasVisible === false) {\n _this.el.emit('markerFound')\n } else if (_this._arAnchor.object3d.visible === false && wasVisible === true) {\n _this.el.emit('markerLost')\n }\n }\n})\n\n//////////////////////////////////////////////////////////////////////////////\n// define some primitives shortcuts\n//////////////////////////////////////////////////////////////////////////////\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerPrimitive('a-anchor', aframe__WEBPACK_IMPORTED_MODULE_0__.utils.extendDeep({}, aframe__WEBPACK_IMPORTED_MODULE_0__.primitives.getMeshMixin(), {\n defaultComponents: {\n 'arjs-anchor': {},\n 'arjs-hit-testing': {},\n },\n mappings: {\n 'type': 'arjs-anchor.type',\n 'size': 'arjs-anchor.size',\n 'url': 'arjs-anchor.patternUrl',\n 'value': 'arjs-anchor.barcodeValue',\n 'preset': 'arjs-anchor.preset',\n 'min-confidence': 'arjs-anchor.minConfidence',\n 'marker-helpers': 'arjs-anchor.markerhelpers',\n 'smooth': 'arjs-anchor.smooth',\n 'smooth-count': 'arjs-anchor.smoothCount',\n 'smooth-tolerance': 'arjs-anchor.smoothTolerance',\n 'smooth-threshold': 'arjs-anchor.smoothThreshold',\n\n 'hit-testing-render-debug': 'arjs-hit-testing.renderDebug',\n 'hit-testing-enabled': 'arjs-hit-testing.enabled',\n }\n}))\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerPrimitive('a-camera-static', aframe__WEBPACK_IMPORTED_MODULE_0__.utils.extendDeep({}, aframe__WEBPACK_IMPORTED_MODULE_0__.primitives.getMeshMixin(), {\n defaultComponents: {\n 'camera': {},\n },\n mappings: {\n }\n}))\n\n//////////////////////////////////////////////////////////////////////////////\n//\t\tbackward compatibility\n//////////////////////////////////////////////////////////////////////////////\n// FIXME\naframe__WEBPACK_IMPORTED_MODULE_0__.registerPrimitive('a-marker', aframe__WEBPACK_IMPORTED_MODULE_0__.utils.extendDeep({}, aframe__WEBPACK_IMPORTED_MODULE_0__.primitives.getMeshMixin(), {\n defaultComponents: {\n 'arjs-anchor': {},\n 'arjs-hit-testing': {},\n },\n mappings: {\n 'type': 'arjs-anchor.type',\n 'size': 'arjs-anchor.size',\n 'url': 'arjs-anchor.patternUrl',\n 'value': 'arjs-anchor.barcodeValue',\n 'preset': 'arjs-anchor.preset',\n 'min-confidence': 'arjs-anchor.minConfidence',\n 'marker-helpers': 'arjs-anchor.markerhelpers',\n 'smooth': 'arjs-anchor.smooth',\n 'smooth-count': 'arjs-anchor.smoothCount',\n 'smooth-tolerance': 'arjs-anchor.smoothTolerance',\n 'smooth-threshold': 'arjs-anchor.smoothThreshold',\n\n 'hit-testing-render-debug': 'arjs-hit-testing.renderDebug',\n 'hit-testing-enabled': 'arjs-hit-testing.enabled',\n }\n}))\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerPrimitive('a-marker-camera', aframe__WEBPACK_IMPORTED_MODULE_0__.utils.extendDeep({}, aframe__WEBPACK_IMPORTED_MODULE_0__.primitives.getMeshMixin(), {\n defaultComponents: {\n 'arjs-anchor': {\n changeMatrixMode: 'cameraTransformMatrix'\n },\n 'camera': {},\n },\n mappings: {\n 'type': 'arjs-anchor.type',\n 'size': 'arjs-anchor.size',\n 'url': 'arjs-anchor.patternUrl',\n 'value': 'arjs-anchor.barcodeValue',\n 'preset': 'arjs-anchor.preset',\n 'min-confidence': 'arjs-anchor.minConfidence',\n 'marker-helpers': 'arjs-anchor.markerhelpers',\n }\n}))\n\n\n//# sourceURL=webpack:///./src/component-anchor.js?" - ); - - /***/ - }, - - /***/ "./src/component-hit-testing.js": - /*!**************************************!*\ - !*** ./src/component-hit-testing.js ***! - \**************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _three_js_src_new_api_arjs_hittesting__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../three.js/src/new-api/arjs-hittesting */ \"../three.js/src/new-api/arjs-hittesting.js\");\n\n\n\n// //////////////////////////////////////////////////////////////////////////////\n//\t\tarjs-hit-testing\n//////////////////////////////////////////////////////////////////////////////\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('arjs-hit-testing', {\n\tdependencies: ['arjs', 'artoolkit'],\n\tschema: {\n\t\tenabled : {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t\trenderDebug : {\n\t\t\ttype: 'boolean',\n\t\t\tdefault: false,\n\t\t},\n\t},\n\tinit: function () {\n\t\tvar _this = this\n\t\tvar arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit\n\n// TODO make it work on cameraTransformMatrix too\n//\n\t\t_this.isReady = false\n\t\t_this._arAnchor = null\n\t\t_this._arHitTesting = null\n\n\t\t// trick to wait until arjsSystem is isReady\n\t\tvar startedAt = Date.now()\n\t\tvar timerId = setInterval(function(){\n\t\t\tvar anchorEl = _this.el\n\t\t\tvar anchorComponent = anchorEl.components['arjs-anchor']\n\t\t\t// wait until anchorComponent is isReady\n\t\t\tif( anchorComponent === undefined || anchorComponent.isReady === false )\treturn\n\n\t\t\tclearInterval(timerId)\n\n\t\t\t//////////////////////////////////////////////////////////////////////////////\n\t\t\t//\t\tcreate arAnchor\n\t\t\t//////////////////////////////////////////////////////////////////////////////\n\t\t\tvar arAnchor = anchorComponent._arAnchor\n\t\t\tvar arSession = arjsSystem._arSession\n\t\t\tvar renderer = arSession.parameters.renderer\n\n\t\t\tvar hitTesting = _this._arHitTesting = new _three_js_src_new_api_arjs_hittesting__WEBPACK_IMPORTED_MODULE_1__[\"default\"](arSession)\n\t\t\thitTesting.enabled = _this.data.enabled\n\n\t\t\t_this.isReady = true\n\t\t}, 1000/60)\n\t},\n\tremove : function(){\n\t},\n\tupdate: function () {\n\t},\n\ttick: function(){\n\t\tvar _this = this\n\t\t// if not yet isReady, do nothing\n\t\tif( this.isReady === false )\treturn\n\n\t\tvar arjsSystem = this.el.sceneEl.systems.arjs || this.el.sceneEl.systems.artoolkit\n\t\tvar arSession = arjsSystem._arSession\n\n\t\tvar anchorEl = _this.el\n\t\tvar anchorComponent = anchorEl.components['arjs-anchor']\n\t\tvar arAnchor = anchorComponent._arAnchor\n\n\n\t\tvar hitTesting = this._arHitTesting\n\t\tvar camera = arSession.parameters.camera\n// console.log(camera.position)\n\t\thitTesting.update(camera, arAnchor.object3d, arAnchor.parameters.changeMatrixMode)\n\t}\n});\n\n\n//# sourceURL=webpack:///./src/component-hit-testing.js?" - ); - - /***/ - }, - - /***/ "./src/index.js": - /*!**********************!*\ - !*** ./src/index.js ***! - \**********************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - '__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _component_anchor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./component-anchor */ "./src/component-anchor.js");\n/* harmony import */ var _component_hit_testing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./component-hit-testing */ "./src/component-hit-testing.js");\n/* harmony import */ var _location_based_arjs_look_controls__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./location-based/arjs-look-controls */ "./src/location-based/arjs-look-controls.js");\n/* harmony import */ var _location_based_arjs_webcam_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./location-based/arjs-webcam-texture */ "./src/location-based/arjs-webcam-texture.js");\n/* harmony import */ var _location_based_ArjsDeviceOrientationControls__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./location-based/ArjsDeviceOrientationControls */ "./src/location-based/ArjsDeviceOrientationControls.js");\n/* harmony import */ var _location_based_gps_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./location-based/gps-camera */ "./src/location-based/gps-camera.js");\n/* harmony import */ var _location_based_gps_entity_place__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./location-based/gps-entity-place */ "./src/location-based/gps-entity-place.js");\n/* harmony import */ var _location_based_gps_projected_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./location-based/gps-projected-camera */ "./src/location-based/gps-projected-camera.js");\n/* harmony import */ var _location_based_gps_projected_entity_place__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./location-based/gps-projected-entity-place */ "./src/location-based/gps-projected-entity-place.js");\n/* harmony import */ var _new_location_based_gps_new_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./new-location-based/gps-new-camera */ "./src/new-location-based/gps-new-camera.js");\n/* harmony import */ var _new_location_based_gps_new_entity_place__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./new-location-based/gps-new-entity-place */ "./src/new-location-based/gps-new-entity-place.js");\n/* harmony import */ var _system_arjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./system-arjs */ "./src/system-arjs.js");\n// Components\n\n\n\n// Location-based components\n\n\n\n\n\n\n\n\n\n\n// System\n\n\n\n//# sourceURL=webpack:///./src/index.js?' - ); - - /***/ - }, - - /***/ "./src/location-based/ArjsDeviceOrientationControls.js": - /*!*************************************************************!*\ - !*** ./src/location-based/ArjsDeviceOrientationControls.js ***! - \*************************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ \"default\": () => (__WEBPACK_DEFAULT_EXPORT__)\n/* harmony export */ });\n/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! three */ \"../node_modules/three/build/three.module.js\");\n\n/**\n * @author richt / http://richt.me\n * @author WestLangley / http://github.com/WestLangley\n *\n * W3C Device Orientation control (http://w3c.github.io/deviceorientation/spec-source-orientation.html)\n */\n\n/* NOTE that this is a modified version of THREE.DeviceOrientationControls to \n * allow exponential smoothing, for use in AR.js.\n *\n * Modifications Nick Whitelegg (nickw1 github)\n */\n\n\n\nconst ArjsDeviceOrientationControls = function ( object ) {\n\n var scope = this;\n\n this.object = object;\n this.object.rotation.reorder( 'YXZ' );\n\n this.enabled = true;\n\n this.deviceOrientation = {};\n this.screenOrientation = 0;\n\n this.alphaOffset = 0; // radians\n\n this.smoothingFactor = 1;\n\n this.TWO_PI = 2 * Math.PI;\n this.HALF_PI = 0.5 * Math.PI;\n\n var onDeviceOrientationChangeEvent = function ( event ) {\n\n scope.deviceOrientation = event;\n\n };\n\n var onScreenOrientationChangeEvent = function () {\n\n scope.screenOrientation = window.orientation || 0;\n\n };\n\n // The angles alpha, beta and gamma form a set of intrinsic Tait-Bryan angles of type Z-X'-Y''\n\n var setObjectQuaternion = function () {\n\n var zee = new three__WEBPACK_IMPORTED_MODULE_0__.Vector3( 0, 0, 1 );\n\n var euler = new three__WEBPACK_IMPORTED_MODULE_0__.Euler();\n\n var q0 = new three__WEBPACK_IMPORTED_MODULE_0__.Quaternion();\n\n var q1 = new three__WEBPACK_IMPORTED_MODULE_0__.Quaternion( - Math.sqrt( 0.5 ), 0, 0, Math.sqrt( 0.5 ) ); // - PI/2 around the x-axis\n\n return function ( quaternion, alpha, beta, gamma, orient ) {\n\n euler.set( beta, alpha, - gamma, 'YXZ' ); // 'ZXY' for the device, but 'YXZ' for us\n\n quaternion.setFromEuler( euler ); // orient the device\n\n quaternion.multiply( q1 ); // camera looks out the back of the device, not the top\n\n quaternion.multiply( q0.setFromAxisAngle( zee, - orient ) ); // adjust for screen orientation\n\n };\n\n }();\n\n this.connect = function () {\n \n onScreenOrientationChangeEvent();\n\n window.addEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );\n window.addEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );\n\n scope.enabled = true;\n\n };\n\n this.disconnect = function () {\n\n window.removeEventListener( 'orientationchange', onScreenOrientationChangeEvent, false );\n window.removeEventListener( 'deviceorientation', onDeviceOrientationChangeEvent, false );\n\n scope.enabled = false;\n\n };\n\n this.update = function () {\n\n if ( scope.enabled === false ) return;\n\n var device = scope.deviceOrientation;\n\n if ( device ) {\n\n var alpha = device.alpha ? three__WEBPACK_IMPORTED_MODULE_0__.Math.degToRad( device.alpha ) + scope.alphaOffset : 0; // Z\n\n var beta = device.beta ? three__WEBPACK_IMPORTED_MODULE_0__.Math.degToRad( device.beta ) : 0; // X'\n\n var gamma = device.gamma ? three__WEBPACK_IMPORTED_MODULE_0__.Math.degToRad( device.gamma ) : 0; // Y''\n\n var orient = scope.screenOrientation ? three__WEBPACK_IMPORTED_MODULE_0__.Math.degToRad( scope.screenOrientation ) : 0; // O\n\n // NW Added smoothing code\n var k = this.smoothingFactor;\n\n if(this.lastOrientation) {\n alpha = this._getSmoothedAngle(alpha, this.lastOrientation.alpha, k);\n beta = this._getSmoothedAngle(beta + Math.PI, this.lastOrientation.beta, k);\n gamma = this._getSmoothedAngle(gamma + this.HALF_PI, this.lastOrientation.gamma, k, Math.PI);\n \n } else {\n beta += Math.PI;\n gamma += this.HALF_PI;\n }\n\n this.lastOrientation = {\n alpha: alpha,\n beta: beta,\n gamma: gamma\n };\n setObjectQuaternion( scope.object.quaternion, alpha, beta - Math.PI, gamma - this.HALF_PI, orient );\n\n }\n };\n\n \n // NW Added\n this._orderAngle = function(a, b, range = this.TWO_PI) {\n if ((b > a && Math.abs(b - a) < range / 2) || (a > b && Math.abs(b - a) > range / 2)) {\n return { left: a, right: b }\n } else { \n return { left: b, right: a }\n }\n };\n\n // NW Added\n this._getSmoothedAngle = function(a, b, k, range = this.TWO_PI) {\n const angles = this._orderAngle(a, b, range);\n const angleshift = angles.left;\n const origAnglesRight = angles.right;\n angles.left = 0;\n angles.right -= angleshift;\n if(angles.right < 0) angles.right += range;\n let newangle = origAnglesRight == b ? (1 - k)*angles.right + k * angles.left : k * angles.right + (1 - k) * angles.left;\n newangle += angleshift;\n if(newangle >= range) newangle -= range;\n return newangle;\n };\n\n this.dispose = function () {\n scope.disconnect();\n };\n\n this.connect();\n\n};\n\n/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (ArjsDeviceOrientationControls);\n\n\n//# sourceURL=webpack:///./src/location-based/ArjsDeviceOrientationControls.js?" - ); - - /***/ - }, - - /***/ "./src/location-based/arjs-look-controls.js": - /*!**************************************************!*\ - !*** ./src/location-based/arjs-look-controls.js ***! - \**************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _ArjsDeviceOrientationControls__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ArjsDeviceOrientationControls */ \"./src/location-based/ArjsDeviceOrientationControls.js\");\n// To avoid recalculation at every mouse movement tick\nvar PI_2 = Math.PI / 2;\n\n\n/**\n * look-controls. Update entity pose, factoring mouse, touch, and WebVR API data.\n */\n\n/* NOTE that this is a modified version of A-Frame's look-controls to \n * allow exponential smoothing, for use in AR.js.\n *\n * Modifications Nick Whitelegg (nickw1 github)\n */\n\n\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('arjs-look-controls', {\n dependencies: ['position', 'rotation'],\n\n schema: {\n enabled: {default: true},\n magicWindowTrackingEnabled: {default: true},\n pointerLockEnabled: {default: false},\n reverseMouseDrag: {default: false},\n reverseTouchDrag: {default: false},\n touchEnabled: {default: true},\n smoothingFactor: { type: 'number', default: 1 }\n },\n\n init: function () {\n this.deltaYaw = 0;\n this.previousHMDPosition = new THREE.Vector3();\n this.hmdQuaternion = new THREE.Quaternion();\n this.magicWindowAbsoluteEuler = new THREE.Euler();\n this.magicWindowDeltaEuler = new THREE.Euler();\n this.position = new THREE.Vector3();\n this.magicWindowObject = new THREE.Object3D();\n this.rotation = {};\n this.deltaRotation = {};\n this.savedPose = null;\n this.pointerLocked = false;\n this.setupMouseControls();\n this.bindMethods();\n this.previousMouseEvent = {};\n\n this.setupMagicWindowControls();\n\n // To save / restore camera pose\n this.savedPose = {\n position: new THREE.Vector3(),\n rotation: new THREE.Euler()\n };\n\n // Call enter VR handler if the scene has entered VR before the event listeners attached.\n if (this.el.sceneEl.is('vr-mode')) { this.onEnterVR(); }\n },\n\n setupMagicWindowControls: function () {\n var magicWindowControls;\n var data = this.data;\n\n // Only on mobile devices and only enabled if DeviceOrientation permission has been granted.\n if (aframe__WEBPACK_IMPORTED_MODULE_0__.utils.device.isMobile()) {\n magicWindowControls = this.magicWindowControls = new _ArjsDeviceOrientationControls__WEBPACK_IMPORTED_MODULE_1__[\"default\"](this.magicWindowObject);\n if (typeof DeviceOrientationEvent !== 'undefined' && DeviceOrientationEvent.requestPermission) {\n magicWindowControls.enabled = false;\n if (this.el.sceneEl.components['device-orientation-permission-ui'].permissionGranted) {\n magicWindowControls.enabled = data.magicWindowTrackingEnabled;\n } else {\n this.el.sceneEl.addEventListener('deviceorientationpermissiongranted', function () {\n magicWindowControls.enabled = data.magicWindowTrackingEnabled;\n });\n }\n }\n }\n },\n\n update: function (oldData) {\n var data = this.data;\n\n // Disable grab cursor classes if no longer enabled.\n if (data.enabled !== oldData.enabled) {\n this.updateGrabCursor(data.enabled);\n }\n\n // Reset magic window eulers if tracking is disabled.\n if (oldData && !data.magicWindowTrackingEnabled && oldData.magicWindowTrackingEnabled) {\n this.magicWindowAbsoluteEuler.set(0, 0, 0);\n this.magicWindowDeltaEuler.set(0, 0, 0);\n }\n\n // Pass on magic window tracking setting to magicWindowControls.\n if (this.magicWindowControls) {\n this.magicWindowControls.enabled = data.magicWindowTrackingEnabled;\n this.magicWindowControls.smoothingFactor = data.smoothingFactor;\n }\n\n if (oldData && !data.pointerLockEnabled !== oldData.pointerLockEnabled) {\n this.removeEventListeners();\n this.addEventListeners();\n if (this.pointerLocked) { this.exitPointerLock(); }\n }\n },\n\n tick: function (t) {\n var data = this.data;\n if (!data.enabled) { return; }\n this.updateOrientation();\n },\n\n play: function () {\n this.addEventListeners();\n },\n\n pause: function () {\n this.removeEventListeners();\n if (this.pointerLocked) { this.exitPointerLock(); }\n },\n\n remove: function () {\n this.removeEventListeners();\n if (this.pointerLocked) { this.exitPointerLock(); }\n },\n\n bindMethods: function () {\n this.onMouseDown = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onMouseDown, this);\n this.onMouseMove = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onMouseMove, this);\n this.onMouseUp = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onMouseUp, this);\n this.onTouchStart = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onTouchStart, this);\n this.onTouchMove = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onTouchMove, this);\n this.onTouchEnd = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onTouchEnd, this);\n this.onEnterVR = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onEnterVR, this);\n this.onExitVR = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onExitVR, this);\n this.onPointerLockChange = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onPointerLockChange, this);\n this.onPointerLockError = aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.onPointerLockError, this);\n },\n\n /**\n * Set up states and Object3Ds needed to store rotation data.\n */\n setupMouseControls: function () {\n this.mouseDown = false;\n this.pitchObject = new THREE.Object3D();\n this.yawObject = new THREE.Object3D();\n this.yawObject.position.y = 10;\n this.yawObject.add(this.pitchObject);\n },\n\n /**\n * Add mouse and touch event listeners to canvas.\n */\n addEventListeners: function () {\n var sceneEl = this.el.sceneEl;\n var canvasEl = sceneEl.canvas;\n\n // Wait for canvas to load.\n if (!canvasEl) {\n sceneEl.addEventListener('render-target-loaded', aframe__WEBPACK_IMPORTED_MODULE_0__.utils.bind(this.addEventListeners, this));\n return;\n }\n\n // Mouse events.\n canvasEl.addEventListener('mousedown', this.onMouseDown, false);\n window.addEventListener('mousemove', this.onMouseMove, false);\n window.addEventListener('mouseup', this.onMouseUp, false);\n\n // Touch events.\n canvasEl.addEventListener('touchstart', this.onTouchStart);\n window.addEventListener('touchmove', this.onTouchMove);\n window.addEventListener('touchend', this.onTouchEnd);\n\n // sceneEl events.\n sceneEl.addEventListener('enter-vr', this.onEnterVR);\n sceneEl.addEventListener('exit-vr', this.onExitVR);\n\n // Pointer Lock events.\n if (this.data.pointerLockEnabled) {\n document.addEventListener('pointerlockchange', this.onPointerLockChange, false);\n document.addEventListener('mozpointerlockchange', this.onPointerLockChange, false);\n document.addEventListener('pointerlockerror', this.onPointerLockError, false);\n }\n },\n\n /**\n * Remove mouse and touch event listeners from canvas.\n */\n removeEventListeners: function () {\n var sceneEl = this.el.sceneEl;\n var canvasEl = sceneEl && sceneEl.canvas;\n\n if (!canvasEl) { return; }\n\n // Mouse events.\n canvasEl.removeEventListener('mousedown', this.onMouseDown);\n window.removeEventListener('mousemove', this.onMouseMove);\n window.removeEventListener('mouseup', this.onMouseUp);\n\n // Touch events.\n canvasEl.removeEventListener('touchstart', this.onTouchStart);\n window.removeEventListener('touchmove', this.onTouchMove);\n window.removeEventListener('touchend', this.onTouchEnd);\n\n // sceneEl events.\n sceneEl.removeEventListener('enter-vr', this.onEnterVR);\n sceneEl.removeEventListener('exit-vr', this.onExitVR);\n\n // Pointer Lock events.\n document.removeEventListener('pointerlockchange', this.onPointerLockChange, false);\n document.removeEventListener('mozpointerlockchange', this.onPointerLockChange, false);\n document.removeEventListener('pointerlockerror', this.onPointerLockError, false);\n },\n\n /**\n * Update orientation for mobile, mouse drag, and headset.\n * Mouse-drag only enabled if HMD is not active.\n */\n updateOrientation: (function () {\n var poseMatrix = new THREE.Matrix4();\n\n return function () {\n var object3D = this.el.object3D;\n var pitchObject = this.pitchObject;\n var yawObject = this.yawObject;\n var pose;\n var sceneEl = this.el.sceneEl;\n\n // In VR mode, THREE is in charge of updating the camera pose.\n if (sceneEl.is('vr-mode') && sceneEl.checkHeadsetConnected()) {\n // With WebXR THREE applies headset pose to the object3D matrixWorld internally.\n // Reflect values back on position, rotation, scale for getAttribute to return the expected values.\n if (sceneEl.hasWebXR) {\n pose = sceneEl.renderer.xr.getCameraPose();\n if (pose) {\n poseMatrix.elements = pose.transform.matrix;\n poseMatrix.decompose(object3D.position, object3D.rotation, object3D.scale);\n }\n }\n return;\n }\n\n this.updateMagicWindowOrientation();\n\n // On mobile, do camera rotation with touch events and sensors.\n object3D.rotation.x = this.magicWindowDeltaEuler.x + pitchObject.rotation.x;\n object3D.rotation.y = this.magicWindowDeltaEuler.y + yawObject.rotation.y;\n object3D.rotation.z = this.magicWindowDeltaEuler.z;\n };\n })(),\n\n updateMagicWindowOrientation: function () {\n var magicWindowAbsoluteEuler = this.magicWindowAbsoluteEuler;\n var magicWindowDeltaEuler = this.magicWindowDeltaEuler;\n // Calculate magic window HMD quaternion.\n if (this.magicWindowControls && this.magicWindowControls.enabled) {\n this.magicWindowControls.update();\n magicWindowAbsoluteEuler.setFromQuaternion(this.magicWindowObject.quaternion, 'YXZ');\n if (!this.previousMagicWindowYaw && magicWindowAbsoluteEuler.y !== 0) {\n this.previousMagicWindowYaw = magicWindowAbsoluteEuler.y;\n }\n if (this.previousMagicWindowYaw) {\n magicWindowDeltaEuler.x = magicWindowAbsoluteEuler.x;\n magicWindowDeltaEuler.y += magicWindowAbsoluteEuler.y - this.previousMagicWindowYaw;\n magicWindowDeltaEuler.z = magicWindowAbsoluteEuler.z;\n this.previousMagicWindowYaw = magicWindowAbsoluteEuler.y;\n }\n }\n },\n\n /**\n * Translate mouse drag into rotation.\n *\n * Dragging up and down rotates the camera around the X-axis (yaw).\n * Dragging left and right rotates the camera around the Y-axis (pitch).\n */\n onMouseMove: function (evt) {\n var direction;\n var movementX;\n var movementY;\n var pitchObject = this.pitchObject;\n var previousMouseEvent = this.previousMouseEvent;\n var yawObject = this.yawObject;\n\n // Not dragging or not enabled.\n if (!this.data.enabled || (!this.mouseDown && !this.pointerLocked)) { return; }\n\n // Calculate delta.\n if (this.pointerLocked) {\n movementX = evt.movementX || evt.mozMovementX || 0;\n movementY = evt.movementY || evt.mozMovementY || 0;\n } else {\n movementX = evt.screenX - previousMouseEvent.screenX;\n movementY = evt.screenY - previousMouseEvent.screenY;\n }\n this.previousMouseEvent.screenX = evt.screenX;\n this.previousMouseEvent.screenY = evt.screenY;\n\n // Calculate rotation.\n direction = this.data.reverseMouseDrag ? 1 : -1;\n yawObject.rotation.y += movementX * 0.002 * direction;\n pitchObject.rotation.x += movementY * 0.002 * direction;\n pitchObject.rotation.x = Math.max(-PI_2, Math.min(PI_2, pitchObject.rotation.x));\n },\n\n /**\n * Register mouse down to detect mouse drag.\n */\n onMouseDown: function (evt) {\n var sceneEl = this.el.sceneEl;\n if (!this.data.enabled || (sceneEl.is('vr-mode') && sceneEl.checkHeadsetConnected())) { return; }\n // Handle only primary button.\n if (evt.button !== 0) { return; }\n\n var canvasEl = sceneEl && sceneEl.canvas;\n\n this.mouseDown = true;\n this.previousMouseEvent.screenX = evt.screenX;\n this.previousMouseEvent.screenY = evt.screenY;\n this.showGrabbingCursor();\n\n if (this.data.pointerLockEnabled && !this.pointerLocked) {\n if (canvasEl.requestPointerLock) {\n canvasEl.requestPointerLock();\n } else if (canvasEl.mozRequestPointerLock) {\n canvasEl.mozRequestPointerLock();\n }\n }\n },\n\n /**\n * Shows grabbing cursor on scene\n */\n showGrabbingCursor: function () {\n this.el.sceneEl.canvas.style.cursor = 'grabbing';\n },\n\n /**\n * Hides grabbing cursor on scene\n */\n hideGrabbingCursor: function () {\n this.el.sceneEl.canvas.style.cursor = '';\n },\n\n /**\n * Register mouse up to detect release of mouse drag.\n */\n onMouseUp: function () {\n this.mouseDown = false;\n this.hideGrabbingCursor();\n },\n\n /**\n * Register touch down to detect touch drag.\n */\n onTouchStart: function (evt) {\n if (evt.touches.length !== 1 ||\n !this.data.touchEnabled ||\n this.el.sceneEl.is('vr-mode')) { return; }\n this.touchStart = {\n x: evt.touches[0].pageX,\n y: evt.touches[0].pageY\n };\n this.touchStarted = true;\n },\n\n /**\n * Translate touch move to Y-axis rotation.\n */\n onTouchMove: function (evt) {\n var direction;\n var canvas = this.el.sceneEl.canvas;\n var deltaY;\n var yawObject = this.yawObject;\n\n if (!this.touchStarted || !this.data.touchEnabled) { return; }\n\n deltaY = 2 * Math.PI * (evt.touches[0].pageX - this.touchStart.x) / canvas.clientWidth;\n\n direction = this.data.reverseTouchDrag ? 1 : -1;\n // Limit touch orientaion to to yaw (y axis).\n yawObject.rotation.y -= deltaY * 0.5 * direction;\n this.touchStart = {\n x: evt.touches[0].pageX,\n y: evt.touches[0].pageY\n };\n },\n\n /**\n * Register touch end to detect release of touch drag.\n */\n onTouchEnd: function () {\n this.touchStarted = false;\n },\n\n /**\n * Save pose.\n */\n onEnterVR: function () {\n var sceneEl = this.el.sceneEl;\n if (!sceneEl.checkHeadsetConnected()) { return; }\n this.saveCameraPose();\n this.el.object3D.position.set(0, 0, 0);\n this.el.object3D.rotation.set(0, 0, 0);\n if (sceneEl.hasWebXR) {\n this.el.object3D.matrixAutoUpdate = false;\n this.el.object3D.updateMatrix();\n }\n },\n\n /**\n * Restore the pose.\n */\n onExitVR: function () {\n if (!this.el.sceneEl.checkHeadsetConnected()) { return; }\n this.restoreCameraPose();\n this.previousHMDPosition.set(0, 0, 0);\n this.el.object3D.matrixAutoUpdate = true;\n },\n\n /**\n * Update Pointer Lock state.\n */\n onPointerLockChange: function () {\n this.pointerLocked = !!(document.pointerLockElement || document.mozPointerLockElement);\n },\n\n /**\n * Recover from Pointer Lock error.\n */\n onPointerLockError: function () {\n this.pointerLocked = false;\n },\n\n // Exits pointer-locked mode.\n exitPointerLock: function () {\n document.exitPointerLock();\n this.pointerLocked = false;\n },\n\n /**\n * Toggle the feature of showing/hiding the grab cursor.\n */\n updateGrabCursor: function (enabled) {\n var sceneEl = this.el.sceneEl;\n\n function enableGrabCursor () { sceneEl.canvas.classList.add('a-grab-cursor'); }\n function disableGrabCursor () { sceneEl.canvas.classList.remove('a-grab-cursor'); }\n\n if (!sceneEl.canvas) {\n if (enabled) {\n sceneEl.addEventListener('render-target-loaded', enableGrabCursor);\n } else {\n sceneEl.addEventListener('render-target-loaded', disableGrabCursor);\n }\n return;\n }\n\n if (enabled) {\n enableGrabCursor();\n return;\n }\n disableGrabCursor();\n },\n\n /**\n * Save camera pose before entering VR to restore later if exiting.\n */\n saveCameraPose: function () {\n var el = this.el;\n\n this.savedPose.position.copy(el.object3D.position);\n this.savedPose.rotation.copy(el.object3D.rotation);\n this.hasSavedPose = true;\n },\n\n /**\n * Reset camera pose to before entering VR.\n */\n restoreCameraPose: function () {\n var el = this.el;\n var savedPose = this.savedPose;\n\n if (!this.hasSavedPose) { return; }\n\n // Reset camera orientation.\n el.object3D.position.copy(savedPose.position);\n el.object3D.rotation.copy(savedPose.rotation);\n this.hasSavedPose = false;\n }\n});\n\n\n//# sourceURL=webpack:///./src/location-based/arjs-look-controls.js?" - ); - - /***/ - }, - - /***/ "./src/location-based/arjs-webcam-texture.js": - /*!***************************************************!*\ - !*** ./src/location-based/arjs-webcam-texture.js ***! - \***************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - '__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ "../node_modules/aframe/dist/aframe-master.js");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ "../node_modules/three/build/three.module.js");\n\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent(\'arjs-webcam-texture\', {\n\n init: function() {\n this.scene = this.el.sceneEl;\n this.texCamera = new three__WEBPACK_IMPORTED_MODULE_1__.OrthographicCamera(-0.5, 0.5, 0.5, -0.5, 0, 10);\n this.texScene = new three__WEBPACK_IMPORTED_MODULE_1__.Scene();\n\n this.scene.renderer.autoClear = false;\n this.video = document.createElement("video");\n this.video.setAttribute("autoplay", true);\n this.video.setAttribute("playsinline", true);\n this.video.setAttribute("display", "none");\n document.body.appendChild(this.video);\n this.geom = new three__WEBPACK_IMPORTED_MODULE_1__.PlaneBufferGeometry(); //0.5, 0.5);\n this.texture = new three__WEBPACK_IMPORTED_MODULE_1__.VideoTexture(this.video);\n this.material = new three__WEBPACK_IMPORTED_MODULE_1__.MeshBasicMaterial( { map: this.texture } );\n const mesh = new three__WEBPACK_IMPORTED_MODULE_1__.Mesh(this.geom, this.material);\n this.texScene.add(mesh);\n },\n\n play: function() {\n if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n const constraints = { video: {\n facingMode: \'environment\' }\n };\n navigator.mediaDevices.getUserMedia(constraints).then( stream=> {\n this.video.srcObject = stream; \n this.video.play();\n })\n .catch(e => { \n this.el.sceneEl.systems[\'arjs\']._displayErrorPopup(`Webcam error: ${e}`);\n });\n } else {\n this.el.sceneEl.systems[\'arjs\']._displayErrorPopup(\'sorry - media devices API not supported\');\n }\n },\n\n tick: function() {\n this.scene.renderer.clear();\n this.scene.renderer.render(this.texScene, this.texCamera);\n this.scene.renderer.clearDepth();\n },\n\n pause: function() {\n this.video.srcObject.getTracks().forEach ( track => {\n track.stop();\n });\n },\n\n remove: function() {\n this.material.dispose();\n this.texture.dispose();\n this.geom.dispose();\n }\n});\n\n\n//# sourceURL=webpack:///./src/location-based/arjs-webcam-texture.js?' - ); - - /***/ - }, - - /***/ "./src/location-based/gps-camera.js": - /*!******************************************!*\ - !*** ./src/location-based/gps-camera.js ***! - \******************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var three__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! three */ \"../node_modules/three/build/three.module.js\");\n/*\n * UPDATES 28/08/20:\n *\n * - add gpsMinDistance and gpsTimeInterval properties to control how\n * frequently GPS updates are processed. Aim is to prevent 'stuttering'\n * effects when close to AR content due to continuous small changes in\n * location.\n */\n\n\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-camera', {\n _watchPositionId: null,\n originCoords: null,\n currentCoords: null,\n lookControls: null,\n heading: null,\n schema: {\n simulateLatitude: {\n type: 'number',\n default: 0,\n },\n simulateLongitude: {\n type: 'number',\n default: 0,\n },\n simulateAltitude: {\n type: 'number',\n default: 0,\n },\n positionMinAccuracy: {\n type: 'int',\n default: 100,\n },\n alert: {\n type: 'boolean',\n default: false,\n },\n minDistance: {\n type: 'int',\n default: 0,\n },\n maxDistance: {\n type: 'int',\n default: 0,\n },\n gpsMinDistance: {\n type: 'number',\n default: 5,\n },\n gpsTimeInterval: {\n type: 'number',\n default: 0,\n },\n },\n update: function() {\n if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {\n var localPosition = Object.assign({}, this.currentCoords || {});\n localPosition.longitude = this.data.simulateLongitude;\n localPosition.latitude = this.data.simulateLatitude;\n localPosition.altitude = this.data.simulateAltitude;\n this.currentCoords = localPosition;\n\n // re-trigger initialization for new origin\n this.originCoords = null;\n this._updatePosition();\n }\n },\n init: function () { \n if (!this.el.components['arjs-look-controls'] && !this.el.components['look-controls']) {\n return;\n }\n\n this.lastPosition = {\n latitude: 0,\n longitude: 0\n };\n\n this.loader = document.createElement('DIV');\n this.loader.classList.add('arjs-loader');\n document.body.appendChild(this.loader);\n\n this.onGpsEntityPlaceAdded = this._onGpsEntityPlaceAdded.bind(this);\n window.addEventListener('gps-entity-place-added', this.onGpsEntityPlaceAdded);\n\n this.lookControls = this.el.components['arjs-look-controls'] || this.el.components['look-controls'];\n\n // listen to deviceorientation event\n var eventName = this._getDeviceOrientationEventName();\n this._onDeviceOrientation = this._onDeviceOrientation.bind(this);\n\n // if Safari\n if (!!navigator.userAgent.match(/Version\\/[\\d.]+.*Safari/)) {\n // iOS 13+\n if (typeof DeviceOrientationEvent.requestPermission === 'function') {\n var handler = function () {\n console.log('Requesting device orientation permissions...')\n DeviceOrientationEvent.requestPermission();\n document.removeEventListener('touchend', handler);\n };\n\n document.addEventListener('touchend', function () { handler() }, false);\n\n this.el.sceneEl.systems['arjs']._displayErrorPopup( 'After camera permission prompt, please tap the screen to activate geolocation.');\n } else {\n var timeout = setTimeout(function () {\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Please enable device orientation in Settings > Safari > Motion & Orientation Access.');\n }, 750);\n window.addEventListener(eventName, function () {\n clearTimeout(timeout);\n });\n }\n }\n\n window.addEventListener(eventName, this._onDeviceOrientation, false);\n\n },\n\n play: function() {\n if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {\n var localPosition = Object.assign({}, this.currentCoords || {});\n localPosition.latitude = this.data.simulateLatitude;\n localPosition.longitude = this.data.simulateLongitude;\n if (this.data.simulateAltitude !== 0) {\n localPosition.altitude = this.data.simulateAltitude;\n }\n this.currentCoords = localPosition;\n this._updatePosition();\n } else {\n this._watchPositionId = this._initWatchGPS(function (position) {\n var localPosition = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n };\n \n if (this.data.simulateAltitude !== 0) {\n localPosition.altitude = this.data.simulateAltitude;\n }\n \n this.currentCoords = localPosition;\n var distMoved = this._haversineDist(\n this.lastPosition,\n this.currentCoords\n );\n\n if(distMoved >= this.data.gpsMinDistance || !this.originCoords) {\n this._updatePosition();\n this.lastPosition = {\n longitude: this.currentCoords.longitude,\n latitude: this.currentCoords.latitude\n };\n }\n }.bind(this));\n }\n },\n\n tick: function () {\n if (this.heading === null) {\n return;\n }\n this._updateRotation();\n },\n\n pause: function() {\n if (this._watchPositionId) {\n navigator.geolocation.clearWatch(this._watchPositionId);\n }\n this._watchPositionId = null;\n },\n\n remove: function () {\n\n var eventName = this._getDeviceOrientationEventName();\n window.removeEventListener(eventName, this._onDeviceOrientation, false);\n\n window.removeEventListener('gps-entity-place-added', this.onGpsEntityPlaceAdded);\n },\n\n /**\n * Get device orientation event name, depends on browser implementation.\n * @returns {string} event name\n */\n _getDeviceOrientationEventName: function () {\n if ('ondeviceorientationabsolute' in window) {\n var eventName = 'deviceorientationabsolute'\n } else if ('ondeviceorientation' in window) {\n var eventName = 'deviceorientation'\n } else {\n var eventName = ''\n console.error('Compass not supported')\n }\n\n return eventName\n },\n\n /**\n * Get current user position.\n *\n * @param {function} onSuccess\n * @param {function} onError\n * @returns {Promise}\n */\n _initWatchGPS: function (onSuccess, onError) {\n if (!onError) {\n onError = function (err) {\n console.warn('ERROR(' + err.code + '): ' + err.message)\n\n if (err.code === 1) {\n // User denied GeoLocation, let their know that\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Please activate Geolocation and refresh the page. If it is already active, please check permissions for this website.');\n return;\n }\n\n if (err.code === 3) {\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Cannot retrieve GPS position. Signal is absent.');\n return;\n }\n };\n }\n\n if ('geolocation' in navigator === false) {\n onError({ code: 0, message: 'Geolocation is not supported by your browser' });\n return Promise.resolve();\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition\n return navigator.geolocation.watchPosition(onSuccess, onError, {\n enableHighAccuracy: true,\n maximumAge: this.data.gpsTimeInterval,\n timeout: 27000,\n });\n },\n\n /**\n * Update user position.\n *\n * @returns {void}\n */\n _updatePosition: function () {\n // don't update if accuracy is not good enough\n if (this.currentCoords.accuracy > this.data.positionMinAccuracy) {\n if (this.data.alert && !document.getElementById('alert-popup')) {\n var popup = document.createElement('div');\n popup.innerHTML = 'GPS signal is very poor. Try move outdoor or to an area with a better signal.'\n popup.setAttribute('id', 'alert-popup');\n document.body.appendChild(popup);\n }\n return;\n }\n\n var alertPopup = document.getElementById('alert-popup');\n if (this.currentCoords.accuracy <= this.data.positionMinAccuracy && alertPopup) {\n document.body.removeChild(alertPopup);\n }\n\n if (!this.originCoords) {\n // first camera initialization\n this.originCoords = this.currentCoords;\n this._setPosition();\n\n var loader = document.querySelector('.arjs-loader');\n if (loader) {\n loader.remove();\n }\n window.dispatchEvent(new CustomEvent('gps-camera-origin-coord-set'));\n } else {\n this._setPosition();\n }\n },\n _setPosition: function () {\n var position = this.el.getAttribute('position');\n\n // compute position.x\n var dstCoords = {\n longitude: this.currentCoords.longitude,\n latitude: this.originCoords.latitude,\n };\n\n position.x = this.computeDistanceMeters(this.originCoords, dstCoords);\n position.x *= this.currentCoords.longitude > this.originCoords.longitude ? 1 : -1;\n\n // compute position.z\n var dstCoords = {\n longitude: this.originCoords.longitude,\n latitude: this.currentCoords.latitude,\n }\n\n position.z = this.computeDistanceMeters(this.originCoords, dstCoords);\n position.z *= this.currentCoords.latitude > this.originCoords.latitude ? -1 : 1;\n\n // update position\n this.el.setAttribute('position', position);\n\n window.dispatchEvent(new CustomEvent('gps-camera-update-position', { detail: { position: this.currentCoords, origin: this.originCoords } }));\n },\n /**\n * Returns distance in meters between source and destination inputs.\n *\n * Calculate distance, bearing and more between Latitude/Longitude points\n * Details: https://www.movable-type.co.uk/scripts/latlong.html\n *\n * @param {Position} src\n * @param {Position} dest\n * @param {Boolean} isPlace\n *\n * @returns {number} distance | Number.MAX_SAFE_INTEGER\n */\n computeDistanceMeters: function (src, dest, isPlace) {\n var distance = this._haversineDist (src, dest);\n\n // if function has been called for a place, and if it's too near and a min distance has been set,\n // return max distance possible - to be handled by the caller\n if (isPlace && this.data.minDistance && this.data.minDistance > 0 && distance < this.data.minDistance) {\n return Number.MAX_SAFE_INTEGER;\n }\n\n // if function has been called for a place, and if it's too far and a max distance has been set,\n // return max distance possible - to be handled by the caller\n if (isPlace && this.data.maxDistance && this.data.maxDistance > 0 && distance > this.data.maxDistance) {\n return Number.MAX_SAFE_INTEGER;\n }\n \n return distance;\n },\n\n _haversineDist: function (src, dest) {\n var dlongitude = three__WEBPACK_IMPORTED_MODULE_1__.Math.degToRad(dest.longitude - src.longitude);\n var dlatitude = three__WEBPACK_IMPORTED_MODULE_1__.Math.degToRad(dest.latitude - src.latitude);\n\n var a = (Math.sin(dlatitude / 2) * Math.sin(dlatitude / 2)) + Math.cos(three__WEBPACK_IMPORTED_MODULE_1__.Math.degToRad(src.latitude)) * Math.cos(three__WEBPACK_IMPORTED_MODULE_1__.Math.degToRad(dest.latitude)) * (Math.sin(dlongitude / 2) * Math.sin(dlongitude / 2));\n var angle = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return angle * 6371000;\n },\n\n /**\n * Compute compass heading.\n *\n * @param {number} alpha\n * @param {number} beta\n * @param {number} gamma\n *\n * @returns {number} compass heading\n */\n _computeCompassHeading: function (alpha, beta, gamma) {\n\n // Convert degrees to radians\n var alphaRad = alpha * (Math.PI / 180);\n var betaRad = beta * (Math.PI / 180);\n var gammaRad = gamma * (Math.PI / 180);\n\n // Calculate equation components\n var cA = Math.cos(alphaRad);\n var sA = Math.sin(alphaRad);\n var sB = Math.sin(betaRad);\n var cG = Math.cos(gammaRad);\n var sG = Math.sin(gammaRad);\n\n // Calculate A, B, C rotation components\n var rA = - cA * sG - sA * sB * cG;\n var rB = - sA * sG + cA * sB * cG;\n\n // Calculate compass heading\n var compassHeading = Math.atan(rA / rB);\n\n // Convert from half unit circle to whole unit circle\n if (rB < 0) {\n compassHeading += Math.PI;\n } else if (rA < 0) {\n compassHeading += 2 * Math.PI;\n }\n\n // Convert radians to degrees\n compassHeading *= 180 / Math.PI;\n\n return compassHeading;\n },\n\n /**\n * Handler for device orientation event.\n *\n * @param {Event} event\n * @returns {void}\n */\n _onDeviceOrientation: function (event) {\n if (event.webkitCompassHeading !== undefined) {\n if (event.webkitCompassAccuracy < 50) {\n this.heading = event.webkitCompassHeading;\n } else {\n console.warn('webkitCompassAccuracy is event.webkitCompassAccuracy');\n }\n } else if (event.alpha !== null) {\n if (event.absolute === true || event.absolute === undefined) {\n this.heading = this._computeCompassHeading(event.alpha, event.beta, event.gamma);\n } else {\n console.warn('event.absolute === false');\n }\n } else {\n console.warn('event.alpha === null');\n }\n },\n\n /**\n * Update user rotation data.\n *\n * @returns {void}\n */\n _updateRotation: function () {\n var heading = 360 - this.heading;\n var cameraRotation = this.el.getAttribute('rotation').y;\n var yawRotation = three__WEBPACK_IMPORTED_MODULE_1__.Math.radToDeg(this.lookControls.yawObject.rotation.y);\n var offset = (heading - (cameraRotation - yawRotation)) % 360;\n this.lookControls.yawObject.rotation.y = three__WEBPACK_IMPORTED_MODULE_1__.Math.degToRad(offset);\n },\n \n _onGpsEntityPlaceAdded: function() {\n // if places are added after camera initialization is finished\n if (this.originCoords) {\n window.dispatchEvent(new CustomEvent('gps-camera-origin-coord-set'));\n }\n if (this.loader && this.loader.parentElement) {\n document.body.removeChild(this.loader)\n }\n }\n});\n\n\n//# sourceURL=webpack:///./src/location-based/gps-camera.js?" - ); - - /***/ - }, - - /***/ "./src/location-based/gps-entity-place.js": - /*!************************************************!*\ - !*** ./src/location-based/gps-entity-place.js ***! - \************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-entity-place', {\n _cameraGps: null,\n schema: {\n longitude: {\n type: 'number',\n default: 0,\n },\n latitude: {\n type: 'number',\n default: 0,\n }\n },\n remove: function() {\n // cleaning listeners when the entity is removed from the DOM\n window.removeEventListener('gps-camera-origin-coord-set', this.coordSetListener);\n window.removeEventListener('gps-camera-update-position', this.updatePositionListener);\n },\n init: function() {\n this.coordSetListener = () => {\n if (!this._cameraGps) {\n var camera = document.querySelector('[gps-camera]');\n if (!camera.components['gps-camera']) {\n console.error('gps-camera not initialized')\n return;\n }\n this._cameraGps = camera.components['gps-camera'];\n }\n this._updatePosition();\n };\n\n this.updatePositionListener = (ev) => {\n if (!this.data || !this._cameraGps) {\n return;\n }\n\n var dstCoords = {\n longitude: this.data.longitude,\n latitude: this.data.latitude,\n };\n\n // it's actually a 'distance place', but we don't call it with last param, because we want to retrieve distance even if it's < minDistance property\n var distanceForMsg = this._cameraGps.computeDistanceMeters(ev.detail.position, dstCoords);\n\n this.el.setAttribute('distance', distanceForMsg);\n this.el.setAttribute('distanceMsg', this._formatDistance(distanceForMsg));\n this.el.dispatchEvent(new CustomEvent('gps-entity-place-update-position', { detail: { distance: distanceForMsg } }));\n\n var actualDistance = this._cameraGps.computeDistanceMeters(ev.detail.position, dstCoords, true);\n\n if (actualDistance === Number.MAX_SAFE_INTEGER) {\n this.hideForMinDistance(this.el, true);\n } else {\n this.hideForMinDistance(this.el, false);\n }\n };\n\n window.addEventListener('gps-camera-origin-coord-set', this.coordSetListener);\n window.addEventListener('gps-camera-update-position', this.updatePositionListener);\n\n this._positionXDebug = 0;\n\n window.dispatchEvent(new CustomEvent('gps-entity-place-added', { detail: { component: this.el } }));\n },\n /**\n * Hide entity according to minDistance property\n * @returns {void}\n */\n hideForMinDistance: function(el, hideEntity) {\n if (hideEntity) {\n el.setAttribute('visible', 'false');\n } else {\n el.setAttribute('visible', 'true');\n }\n },\n /**\n * Update place position\n * @returns {void}\n */\n _updatePosition: function() {\n var position = { x: 0, y: this.el.getAttribute('position').y || 0, z: 0 }\n\n // update position.x\n var dstCoords = {\n longitude: this.data.longitude,\n latitude: this._cameraGps.originCoords.latitude,\n };\n\n position.x = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords);\n\n this._positionXDebug = position.x;\n\n position.x *= this.data.longitude > this._cameraGps.originCoords.longitude ? 1 : -1;\n\n // update position.z\n var dstCoords = {\n longitude: this._cameraGps.originCoords.longitude,\n latitude: this.data.latitude,\n };\n\n position.z = this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords, dstCoords);\n\n position.z *= this.data.latitude > this._cameraGps.originCoords.latitude ? -1 : 1;\n\n if (position.y !== 0) {\n var altitude = this._cameraGps.originCoords.altitude !== undefined ? this._cameraGps.originCoords.altitude : 0;\n position.y = position.y - altitude;\n }\n\n // update element's position in 3D world\n this.el.setAttribute('position', position);\n },\n\n /**\n * Format distances string\n *\n * @param {String} distance\n */\n\n _formatDistance: function(distance) {\n distance = distance.toFixed(0);\n\n if (distance >= 1000) {\n return (distance / 1000) + ' kilometers';\n }\n\n return distance + ' meters';\n }\n});\n\n\n//# sourceURL=webpack:///./src/location-based/gps-entity-place.js?" - ); - - /***/ - }, - - /***/ "./src/location-based/gps-projected-camera.js": - /*!****************************************************!*\ - !*** ./src/location-based/gps-projected-camera.js ***! - \****************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/** gps-projected-camera\n *\n * based on the original gps-camera, modified by nickw 02/04/20\n *\n * Rather than keeping track of position by calculating the distance of\n * entities or the current location to the original location, this version\n * makes use of the \"Google\" Spherical Mercactor projection, aka epsg:3857.\n *\n * The original position (lat/lon) is projected into Spherical Mercator and\n * stored.\n *\n * Then, when we receive a new position (lat/lon), this new position is\n * projected into Spherical Mercator and then its world position calculated\n * by comparing against the original position.\n *\n * The same is also the case for 'entity-places'; when these are added, their\n * Spherical Mercator coords are calculated (see gps-projected-entity-place).\n *\n * Spherical Mercator units are close to, but not exactly, metres, and are\n * heavily distorted near the poles. Nonetheless they are a good approximation\n * for many areas of the world and appear not to cause unacceptable distortions\n * when used as the units for AR apps.\n *\n * UPDATES 28/08/20:\n *\n * - add gpsMinDistance and gpsTimeInterval properties to control how\n * frequently GPS updates are processed. Aim is to prevent 'stuttering'\n * effects when close to AR content due to continuous small changes in\n * location.\n */\n\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-projected-camera', {\n _watchPositionId: null,\n originCoords: null, // original coords now in Spherical Mercator\n currentCoords: null,\n lookControls: null,\n heading: null,\n schema: {\n simulateLatitude: {\n type: 'number',\n default: 0,\n },\n simulateLongitude: {\n type: 'number',\n default: 0,\n },\n simulateAltitude: {\n type: 'number',\n default: 0,\n },\n positionMinAccuracy: {\n type: 'int',\n default: 100,\n },\n alert: {\n type: 'boolean',\n default: false,\n },\n minDistance: {\n type: 'int',\n default: 0,\n },\n gpsMinDistance: {\n type: 'number',\n default: 0\n },\n gpsTimeInterval: {\n type: 'number',\n default: 0\n },\n },\n update: function() {\n if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {\n var localPosition = Object.assign({}, this.currentCoords || {});\n localPosition.longitude = this.data.simulateLongitude;\n localPosition.latitude = this.data.simulateLatitude;\n localPosition.altitude = this.data.simulateAltitude;\n this.currentCoords = localPosition;\n\n // re-trigger initialization for new origin\n this.originCoords = null;\n this._updatePosition();\n }\n },\n init: function() {\n if (!this.el.components['arjs-look-controls'] && !this.el.components['look-controls']) {\n return;\n }\n\n this.lastPosition = {\n latitude: 0,\n longitude: 0\n };\n\n this.loader = document.createElement('DIV');\n this.loader.classList.add('arjs-loader');\n document.body.appendChild(this.loader);\n\n this.onGpsEntityPlaceAdded = this._onGpsEntityPlaceAdded.bind(this);\n window.addEventListener('gps-entity-place-added', this.onGpsEntityPlaceAdded);\n\n this.lookControls = this.el.components['arjs-look-controls'] || this.el.components['look-controls'];\n\n // listen to deviceorientation event\n var eventName = this._getDeviceOrientationEventName();\n this._onDeviceOrientation = this._onDeviceOrientation.bind(this);\n\n // if Safari\n if (!!navigator.userAgent.match(/Version\\/[\\d.]+.*Safari/)) {\n // iOS 13+\n if (typeof DeviceOrientationEvent.requestPermission === 'function') {\n var handler = function() {\n console.log('Requesting device orientation permissions...')\n DeviceOrientationEvent.requestPermission();\n document.removeEventListener('touchend', handler);\n };\n\n document.addEventListener('touchend', function() { handler() }, false);\n\n this.el.sceneEl.systems['arjs']._displayErrorPopup('After camera permission prompt, please tap the screen to activate geolocation.');\n } else {\n var timeout = setTimeout(function() {\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Please enable device orientation in Settings > Safari > Motion & Orientation Access.');\n }, 750);\n window.addEventListener(eventName, function() {\n clearTimeout(timeout);\n });\n }\n }\n\n window.addEventListener(eventName, this._onDeviceOrientation, false);\n },\n\n play: function() {\n if (this.data.simulateLatitude !== 0 && this.data.simulateLongitude !== 0) {\n var localPosition = Object.assign({}, this.currentCoords || {});\n localPosition.latitude = this.data.simulateLatitude;\n localPosition.longitude = this.data.simulateLongitude;\n if (this.data.simulateAltitude !== 0) {\n localPosition.altitude = this.data.simulateAltitude;\n }\n this.currentCoords = localPosition;\n this._updatePosition();\n } else {\n this._watchPositionId = this._initWatchGPS(function (position) {\n var localPosition = {\n latitude: position.coords.latitude,\n longitude: position.coords.longitude,\n altitude: position.coords.altitude,\n accuracy: position.coords.accuracy,\n altitudeAccuracy: position.coords.altitudeAccuracy,\n };\n \n if (this.data.simulateAltitude !== 0) {\n localPosition.altitude = this.data.simulateAltitude;\n }\n \n this.currentCoords = localPosition;\n var distMoved = this._haversineDist(\n this.lastPosition,\n this.currentCoords\n );\n\n if(distMoved >= this.data.gpsMinDistance || !this.originCoords) {\n this._updatePosition();\n this.lastPosition = {\n longitude: this.currentCoords.longitude,\n latitude: this.currentCoords.latitude\n };\n }\n }.bind(this));\n }\n },\n\n tick: function() {\n if (this.heading === null) {\n return;\n }\n this._updateRotation();\n },\n\n pause: function() {\n if (this._watchPositionId) {\n navigator.geolocation.clearWatch(this._watchPositionId);\n }\n this._watchPositionId = null;\n },\n\n remove: function() {\n var eventName = this._getDeviceOrientationEventName();\n window.removeEventListener(eventName, this._onDeviceOrientation, false);\n window.removeEventListener('gps-entity-place-added', this.onGpsEntityPlaceAdded);\n },\n\n /**\n * Get device orientation event name, depends on browser implementation.\n * @returns {string} event name\n */\n _getDeviceOrientationEventName: function() {\n if ('ondeviceorientationabsolute' in window) {\n var eventName = 'deviceorientationabsolute'\n } else if ('ondeviceorientation' in window) {\n var eventName = 'deviceorientation'\n } else {\n var eventName = ''\n console.error('Compass not supported')\n }\n\n return eventName\n },\n\n /**\n * Get current user position.\n *\n * @param {function} onSuccess\n * @param {function} onError\n * @returns {Promise}\n */\n _initWatchGPS: function(onSuccess, onError) {\n if (!onError) {\n onError = function(err) {\n console.warn('ERROR(' + err.code + '): ' + err.message)\n\n if (err.code === 1) {\n // User denied GeoLocation, let their know that\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Please activate Geolocation and refresh the page. If it is already active, please check permissions for this website.'); \n return;\n }\n\n if (err.code === 3) {\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Cannot retrieve GPS position. Signal is absent.');\n return;\n }\n };\n }\n\n if ('geolocation' in navigator === false) {\n onError({ code: 0, message: 'Geolocation is not supported by your browser' });\n return Promise.resolve();\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/watchPosition\n return navigator.geolocation.watchPosition(onSuccess, onError, {\n enableHighAccuracy: true,\n maximumAge: this.data.gpsTimeInterval,\n timeout: 27000,\n });\n },\n\n /**\n * Update user position.\n *\n * @returns {void}\n */\n _updatePosition: function() {\n // don't update if accuracy is not good enough\n if (this.currentCoords.accuracy > this.data.positionMinAccuracy) {\n if (this.data.alert && !document.getElementById('alert-popup')) {\n var popup = document.createElement('div');\n popup.innerHTML = 'GPS signal is very poor. Try move outdoor or to an area with a better signal.'\n popup.setAttribute('id', 'alert-popup');\n document.body.appendChild(popup);\n }\n return;\n }\n\n var alertPopup = document.getElementById('alert-popup');\n if (this.currentCoords.accuracy <= this.data.positionMinAccuracy && alertPopup) {\n document.body.removeChild(alertPopup);\n }\n\n if (!this.originCoords) {\n // first camera initialization\n // Now store originCoords as PROJECTED original lat/lon, so that\n // we can set the world origin to the original position in \"metres\"\n this.originCoords = this._project(this.currentCoords.latitude, this.currentCoords.longitude);\n this._setPosition();\n\n var loader = document.querySelector('.arjs-loader');\n if (loader) {\n loader.remove();\n }\n window.dispatchEvent(new CustomEvent('gps-camera-origin-coord-set'));\n } else {\n this._setPosition();\n }\n },\n /**\n * Set the current position (in world coords, based on Spherical Mercator)\n *\n * @returns {void}\n */\n _setPosition: function() {\n var position = this.el.getAttribute('position');\n\n var worldCoords = this.latLonToWorld(this.currentCoords.latitude, this.currentCoords.longitude);\n\n position.x = worldCoords[0];\n position.z = worldCoords[1];\n\n // update position\n this.el.setAttribute('position', position);\n\n // add the sphmerc position to the event (for testing only)\n window.dispatchEvent(new CustomEvent('gps-camera-update-position', { detail: { position: this.currentCoords, origin: this.originCoords } }));\n },\n /**\n * Returns distance in meters between camera and destination input.\n *\n * Assume we are using a metre-based projection. Not all 'metre-based'\n * projections give exact metres, e.g. Spherical Mercator, but it appears\n * close enough to be used for AR at least in middle temperate\n * latitudes (40 - 55). It is heavily distorted near the poles, however.\n *\n * @param {Position} dest\n * @param {Boolean} isPlace\n *\n * @returns {number} distance | Number.MAX_SAFE_INTEGER\n */\n computeDistanceMeters: function(dest, isPlace) {\n var src = this.el.getAttribute(\"position\");\n var dx = dest.x - src.x;\n var dz = dest.z - src.z;\n var distance = Math.sqrt(dx * dx + dz * dz);\n\n // if function has been called for a place, and if it's too near and a min distance has been set,\n // return max distance possible - to be handled by the method caller\n if (isPlace && this.data.minDistance && this.data.minDistance > 0 && distance < this.data.minDistance) {\n return Number.MAX_SAFE_INTEGER;\n }\n\n return distance;\n },\n /**\n * Converts latitude/longitude to OpenGL world coordinates.\n *\n * First projects lat/lon to absolute Spherical Mercator and then\n * calculates the world coordinates by comparing the Spherical Mercator\n * coordinates with the Spherical Mercator coordinates of the origin point.\n *\n * @param {Number} lat\n * @param {Number} lon\n *\n * @returns {array} world coordinates\n */\n latLonToWorld: function(lat, lon) {\n var projected = this._project(lat, lon);\n // Sign of z needs to be reversed compared to projected coordinates\n return [projected[0] - this.originCoords[0], -(projected[1] - this.originCoords[1])];\n },\n /**\n * Converts latitude/longitude to Spherical Mercator coordinates.\n * Algorithm is used in several OpenStreetMap-related applications.\n *\n * @param {Number} lat\n * @param {Number} lon\n *\n * @returns {array} Spherical Mercator coordinates\n */\n _project: function(lat, lon) {\n const HALF_EARTH = 20037508.34;\n\n // Convert the supplied coords to Spherical Mercator (EPSG:3857), also\n // known as 'Google Projection', using the algorithm used extensively\n // in various OpenStreetMap software.\n var y = Math.log(Math.tan((90 + lat) * Math.PI / 360.0)) / (Math.PI / 180.0);\n return [(lon / 180.0) * HALF_EARTH, y * HALF_EARTH / 180.0];\n },\n /**\n * Converts Spherical Mercator coordinates to latitude/longitude.\n * Algorithm is used in several OpenStreetMap-related applications.\n *\n * @param {Number} spherical mercator easting\n * @param {Number} spherical mercator northing\n *\n * @returns {object} lon/lat\n */\n _unproject: function(e, n) {\n const HALF_EARTH = 20037508.34;\n var yp = (n / HALF_EARTH) * 180.0;\n return {\n longitude: (e / HALF_EARTH) * 180.0,\n latitude: 180.0 / Math.PI * (2 * Math.atan(Math.exp(yp * Math.PI / 180.0)) - Math.PI / 2)\n };\n },\n /**\n * Compute compass heading.\n *\n * @param {number} alpha\n * @param {number} beta\n * @param {number} gamma\n *\n * @returns {number} compass heading\n */\n _computeCompassHeading: function(alpha, beta, gamma) {\n\n // Convert degrees to radians\n var alphaRad = alpha * (Math.PI / 180);\n var betaRad = beta * (Math.PI / 180);\n var gammaRad = gamma * (Math.PI / 180);\n\n // Calculate equation components\n var cA = Math.cos(alphaRad);\n var sA = Math.sin(alphaRad);\n var sB = Math.sin(betaRad);\n var cG = Math.cos(gammaRad);\n var sG = Math.sin(gammaRad);\n\n // Calculate A, B, C rotation components\n var rA = - cA * sG - sA * sB * cG;\n var rB = - sA * sG + cA * sB * cG;\n\n // Calculate compass heading\n var compassHeading = Math.atan(rA / rB);\n\n // Convert from half unit circle to whole unit circle\n if (rB < 0) {\n compassHeading += Math.PI;\n } else if (rA < 0) {\n compassHeading += 2 * Math.PI;\n }\n\n // Convert radians to degrees\n compassHeading *= 180 / Math.PI;\n\n return compassHeading;\n },\n\n /**\n * Handler for device orientation event.\n *\n * @param {Event} event\n * @returns {void}\n */\n _onDeviceOrientation: function(event) {\n if (event.webkitCompassHeading !== undefined) {\n if (event.webkitCompassAccuracy < 50) {\n this.heading = event.webkitCompassHeading;\n } else {\n console.warn('webkitCompassAccuracy is event.webkitCompassAccuracy');\n }\n } else if (event.alpha !== null) {\n if (event.absolute === true || event.absolute === undefined) {\n this.heading = this._computeCompassHeading(event.alpha, event.beta, event.gamma);\n } else {\n console.warn('event.absolute === false');\n }\n } else {\n console.warn('event.alpha === null');\n }\n },\n\n /**\n * Update user rotation data.\n *\n * @returns {void}\n */\n _updateRotation: function() {\n var heading = 360 - this.heading;\n var cameraRotation = this.el.getAttribute('rotation').y;\n var yawRotation = THREE.MathUtils.radToDeg(this.lookControls.yawObject.rotation.y);\n var offset = (heading - (cameraRotation - yawRotation)) % 360;\n this.lookControls.yawObject.rotation.y = THREE.MathUtils.degToRad(offset);\n },\n\n /**\n * Calculate haversine distance between two lat/lon pairs.\n *\n * Taken from gps-camera\n */\n _haversineDist: function(src, dest) {\n var dlongitude = THREE.MathUtils.degToRad(dest.longitude - src.longitude);\n var dlatitude = THREE.MathUtils.degToRad(dest.latitude - src.latitude);\n\n var a = (Math.sin(dlatitude / 2) * Math.sin(dlatitude / 2)) + Math.cos(THREE.MathUtils.degToRad(src.latitude)) * Math.cos(THREE.MathUtils.degToRad(dest.latitude)) * (Math.sin(dlongitude / 2) * Math.sin(dlongitude / 2));\n var angle = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n return angle * 6371000;\n },\n\n _onGpsEntityPlaceAdded: function() {\n // if places are added after camera initialization is finished\n if (this.originCoords) {\n window.dispatchEvent(new CustomEvent('gps-camera-origin-coord-set'));\n }\n if (this.loader && this.loader.parentElement) {\n document.body.removeChild(this.loader)\n }\n }\n});\n\n\n\n//# sourceURL=webpack:///./src/location-based/gps-projected-camera.js?" - ); - - /***/ - }, - - /***/ "./src/location-based/gps-projected-entity-place.js": - /*!**********************************************************!*\ - !*** ./src/location-based/gps-projected-entity-place.js ***! - \**********************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/** gps-projected-entity-place\n *\n * based on the original gps-entity-place, modified by nickw 02/04/20\n *\n * Rather than keeping track of position by calculating the distance of\n * entities or the current location to the original location, this version\n * makes use of the \"Google\" Spherical Mercactor projection, aka epsg:3857.\n *\n * The original location on startup (lat/lon) is projected into Spherical \n * Mercator and stored.\n *\n * When 'entity-places' are added, their Spherical Mercator coords are \n * calculated and converted into world coordinates, relative to the original\n * position, using the Spherical Mercator projection calculation in\n * gps-projected-camera.\n *\n * Spherical Mercator units are close to, but not exactly, metres, and are\n * heavily distorted near the poles. Nonetheless they are a good approximation\n * for many areas of the world and appear not to cause unacceptable distortions\n * when used as the units for AR apps.\n */\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-projected-entity-place', {\n _cameraGps: null,\n schema: {\n longitude: {\n type: 'number',\n default: 0,\n },\n latitude: {\n type: 'number',\n default: 0,\n }\n },\n remove: function() {\n // cleaning listeners when the entity is removed from the DOM\n window.removeEventListener('gps-camera-update-position', this.updatePositionListener);\n },\n init: function() {\n // Used now to get the GPS camera when it's been setup\n this.coordSetListener = () => {\n if (!this._cameraGps) {\n var camera = document.querySelector('[gps-projected-camera]');\n if (!camera.components['gps-projected-camera']) {\n console.error('gps-projected-camera not initialized')\n return;\n }\n this._cameraGps = camera.components['gps-projected-camera'];\n this._updatePosition();\n }\n };\n \n\n\n // update position needs to worry about distance but nothing else?\n this.updatePositionListener = (ev) => {\n if (!this.data || !this._cameraGps) {\n return;\n }\n\n var dstCoords = this.el.getAttribute('position');\n\n // it's actually a 'distance place', but we don't call it with last param, because we want to retrieve distance even if it's < minDistance property\n // _computeDistanceMeters is now going to use the projected\n var distanceForMsg = this._cameraGps.computeDistanceMeters(dstCoords);\n\n this.el.setAttribute('distance', distanceForMsg);\n this.el.setAttribute('distanceMsg', this._formatDistance(distanceForMsg));\n\n this.el.dispatchEvent(new CustomEvent('gps-entity-place-update-position', { detail: { distance: distanceForMsg } }));\n\n var actualDistance = this._cameraGps.computeDistanceMeters(dstCoords, true);\n\n if (actualDistance === Number.MAX_SAFE_INTEGER) {\n this.hideForMinDistance(this.el, true);\n } else {\n this.hideForMinDistance(this.el, false);\n }\n };\n\n // Retain as this event is fired when the GPS camera is set up\n window.addEventListener('gps-camera-origin-coord-set', this.coordSetListener);\n window.addEventListener('gps-camera-update-position', this.updatePositionListener);\n\n this._positionXDebug = 0;\n\n window.dispatchEvent(new CustomEvent('gps-entity-place-added', { detail: { component: this.el } }));\n },\n /**\n * Hide entity according to minDistance property\n * @returns {void}\n */\n hideForMinDistance: function(el, hideEntity) {\n if (hideEntity) {\n el.setAttribute('visible', 'false');\n } else {\n el.setAttribute('visible', 'true');\n }\n },\n /**\n * Update place position\n * @returns {void}\n */\n\n // set position to world coords using the lat/lon \n _updatePosition: function() {\n var worldPos = this._cameraGps.latLonToWorld(this.data.latitude, this.data.longitude);\n var position = this.el.getAttribute('position');\n\n // update element's position in 3D world\n //this.el.setAttribute('position', position);\n this.el.setAttribute('position', {\n x: worldPos[0],\n y: position.y, \n z: worldPos[1]\n }); \n },\n\n /**\n * Format distances string\n *\n * @param {String} distance\n */\n\n _formatDistance: function(distance) {\n distance = distance.toFixed(0);\n\n if (distance >= 1000) {\n return (distance / 1000) + ' kilometers';\n }\n\n return distance + ' meters';\n }\n});\n\n\n\n//# sourceURL=webpack:///./src/location-based/gps-projected-entity-place.js?" - ); - - /***/ - }, - - /***/ "./src/new-location-based/gps-new-camera.js": - /*!**************************************************!*\ - !*** ./src/new-location-based/gps-new-camera.js ***! - \**************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-new-camera', {\n schema: {\n simulateLatitude: {\n type: 'number',\n default: 0\n },\n simulateLongitude: {\n type: 'number',\n default: 0\n },\n simulateAltitude: {\n type: 'number',\n default: -Number.MAX_VALUE\n },\n gpsMinDistance: {\n type: 'number',\n default: 0\n },\n positionMinAccuracy: {\n type: 'number',\n default: 100\n }\n },\n\n\n init: function() {\n this._testForOrientationControls();\n\n this.threeLoc = new THREEx.LocationBased(\n this.el.sceneEl.object3D, \n this.el.object3D\n );\n\n this.threeLoc.on(\"gpsupdate\", gpspos => { \n this._sendGpsUpdateEvent(gpspos.coords.longitude, gpspos.coords.latitude);\n });\n\n // from original gps-camera component\n // if Safari\n if (!!navigator.userAgent.match(/Version\\/[\\d.]+.*Safari/)) {\n this._setupSafariOrientationPermissions();\n }\n },\n\n update: function(oldData) {\n this.threeLoc.setGpsOptions({\n gpsMinAccuracy: this.data.positionMinAccuracy,\n gpsMinDistance: this.data.gpsMinDistance,\n });\n if((this.data.simulateLatitude !== 0 || this.data.simulateLongitude !== 0) && (this.data.simulateLatitude != oldData.simulateLatitude || this.data.simulateLongitude != oldData.simulateLongitude)) {\n\n this.threeLoc.fakeGps(\n this.data.simulateLongitude,\n this.data.simulateLatitude\n );\n this.data.simulateLatitude = 0;\n this.data.simulateLongitude = 0;\n }\n if(this.data.simulateAltitude > -Number.MAX_VALUE) {\n this.threeLoc.setElevation(this.data.simulateAltitude + 1.6);\n }\n },\n\n play: function() {\n if(this.data.simulateLatitude === 0 && this.data.simulateLongitude === 0) {\n this.threeLoc.startGps();\n }\n },\n\n pause: function() {\n this.threeLoc.stopGps();\n },\n\n _sendGpsUpdateEvent: function(lon, lat) {\n this.el.emit('gps-camera-update-position', {\n position: { \n longitude: lon,\n latitude: lat\n }\n });\n },\n\n _testForOrientationControls: function() {\n const arjs = this.el.sceneEl.systems['arjs'];\n const msg = 'WARNING - No look-controls component, app will not respond to device rotation.';\n if(!this.el.components['arjs-look-controls'] && !this.el.components['look-controls']) {\n if(arjs) {\n arjs._displayErrorPopup(msg);\n } else {\n alert(msg);\n }\n }\n },\n\n // from original gps-camera component\n _setupSafariOrientationPermissions: function() {\n // iOS 13+\n if (typeof DeviceOrientationEvent.requestPermission === 'function') {\n var handler = function() {\n console.log('Requesting device orientation permissions...')\n DeviceOrientationEvent.requestPermission();\n document.removeEventListener('touchend', handler);\n };\n\n document.addEventListener('touchend', function() { handler() }, false);\n\n this.el.sceneEl.systems['arjs']._displayErrorPopup('After camera permission prompt, please tap the screen to activate geolocation.');\n } else {\n var timeout = setTimeout(function() {\n this.el.sceneEl.systems['arjs']._displayErrorPopup('Please enable device orientation in Settings > Safari > Motion & Orientation Access.');\n }, 750);\n window.addEventListener(eventName, function() {\n clearTimeout(timeout);\n });\n }\n }\n});\n\n\n//# sourceURL=webpack:///./src/new-location-based/gps-new-camera.js?" - ); - - /***/ - }, - - /***/ "./src/new-location-based/gps-new-entity-place.js": - /*!********************************************************!*\ - !*** ./src/new-location-based/gps-new-entity-place.js ***! - \********************************************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerComponent('gps-new-entity-place', {\n schema: {\n longitude: {\n type: 'number',\n default: 0\n },\n latitude: {\n type: 'number',\n default: 0\n }\n },\n\n init: function() {\n const camera = document.querySelector(\"[gps-new-camera]\");\n if(!camera.components['gps-new-camera']) {\n console.error('gps-new-camera not initialised');\n return;\n }\n this._cameraGps = camera.components['gps-new-camera'];\n },\n\n update: function() {\n const projCoords = this._cameraGps.threeLoc.lonLatToWorldCoords(this.data.longitude, this.data.latitude);\n this.el.object3D.position.set(\n projCoords[0],\n this.el.object3D.position.y, \n projCoords[1]\n );\n }\n});\n\n\n//# sourceURL=webpack:///./src/new-location-based/gps-new-entity-place.js?" - ); - - /***/ - }, - - /***/ "./src/system-arjs.js": - /*!****************************!*\ - !*** ./src/system-arjs.js ***! - \****************************/ - /***/ ( - __unused_webpack_module, - __webpack_exports__, - __webpack_require__ - ) => { - "use strict"; - eval( - "__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! aframe */ \"../node_modules/aframe/dist/aframe-master.js\");\n/* harmony import */ var aframe__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(aframe__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _three_js_src_threex_arjs_profile__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../three.js/src/threex/arjs-profile */ \"../three.js/src/threex/arjs-profile.js\");\n/* harmony import */ var _three_js_src_new_api_arjs_session__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../three.js/src/new-api/arjs-session */ \"../three.js/src/new-api/arjs-session.js\");\n/* harmony import */ var _three_js_src_new_api_arjs_debugui__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../three.js/src/new-api/arjs-debugui */ \"../three.js/src/new-api/arjs-debugui.js\");\n\n\n\n\n\naframe__WEBPACK_IMPORTED_MODULE_0__.registerSystem('arjs', {\n schema: {\n trackingMethod: {\n type: 'string',\n default: 'best',\n },\n debugUIEnabled: {\n type: 'boolean',\n default: false,\n },\n areaLearningButton: {\n type: 'boolean',\n default: true,\n },\n performanceProfile: {\n type: 'string',\n default: 'default',\n },\n labelingMode: {\n type: 'string',\n default: '',\n },\n // new video texture mode (location based only)\n videoTexture: {\n type: 'boolean',\n default: false\n },\n // old parameters\n debug: {\n type: 'boolean',\n default: false\n },\n detectionMode: {\n type: 'string',\n default: '',\n },\n matrixCodeType: {\n type: 'string',\n default: '',\n },\n patternRatio: {\n type: 'number',\n default: -1,\n },\n cameraParametersUrl: {\n type: 'string',\n default: '',\n },\n maxDetectionRate: {\n type: 'number',\n default: -1\n },\n sourceType: {\n type: 'string',\n default: '',\n },\n sourceUrl: {\n type: 'string',\n default: '',\n },\n sourceWidth: {\n type: 'number',\n default: -1\n },\n sourceHeight: {\n type: 'number',\n default: -1\n },\n deviceId: {\n type: 'string',\n default: ''\n },\n displayWidth: {\n type: 'number',\n default: -1\n },\n displayHeight: {\n type: 'number',\n default: -1\n },\n canvasWidth: {\n type: 'number',\n default: -1\n },\n canvasHeight: {\n type: 'number',\n default: -1\n },\n errorPopup: {\n type: 'string',\n default: ''\n }\n },\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tCode Separator\n //////////////////////////////////////////////////////////////////////////////\n\n init: function () {\n var _this = this\n\n // If videoTexture is set, skip the remainder of the setup entirely and just use the arjs-webcam-texture component\n if(this.data.videoTexture === true && this.data.sourceType === 'webcam') {\n var webcamEntity = document.createElement(\"a-entity\");\n webcamEntity.setAttribute(\"arjs-webcam-texture\", true);\n this.el.sceneEl.appendChild(webcamEntity);\n return;\n }\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tsetup arProfile\n //////////////////////////////////////////////////////////////////////////////\n\n var arProfile = this._arProfile = new _three_js_src_threex_arjs_profile__WEBPACK_IMPORTED_MODULE_1__[\"default\"]()\n .trackingMethod(this.data.trackingMethod)\n .performance(this.data.performanceProfile)\n .defaultMarker()\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\thonor this.data and setup arProfile with it\n //////////////////////////////////////////////////////////////////////////////\n\n // honor this.data and push what has been modified into arProfile\n if (this.data.debug !== false) arProfile.contextParameters.debug = this.data.debug\n if (this.data.detectionMode !== '') arProfile.contextParameters.detectionMode = this.data.detectionMode\n if (this.data.matrixCodeType !== '') arProfile.contextParameters.matrixCodeType = this.data.matrixCodeType\n if (this.data.patternRatio !== -1) arProfile.contextParameters.patternRatio = this.data.patternRatio\n if (this.data.labelingMode !== '') arProfile.contextParameters.labelingMode = this.data.labelingMode\n if (this.data.cameraParametersUrl !== '') arProfile.contextParameters.cameraParametersUrl = this.data.cameraParametersUrl\n if (this.data.maxDetectionRate !== -1) arProfile.contextParameters.maxDetectionRate = this.data.maxDetectionRate\n if (this.data.canvasWidth !== -1) arProfile.contextParameters.canvasWidth = this.data.canvasWidth\n if (this.data.canvasHeight !== -1) arProfile.contextParameters.canvasHeight = this.data.canvasHeight\n\n if (this.data.sourceType !== '') arProfile.sourceParameters.sourceType = this.data.sourceType\n if (this.data.sourceUrl !== '') arProfile.sourceParameters.sourceUrl = this.data.sourceUrl\n if (this.data.sourceWidth !== -1) arProfile.sourceParameters.sourceWidth = this.data.sourceWidth\n if (this.data.sourceHeight !== -1) arProfile.sourceParameters.sourceHeight = this.data.sourceHeight\n if (this.data.deviceId !== '') arProfile.sourceParameters.deviceId = this.data.deviceId\n if (this.data.displayWidth !== -1) arProfile.sourceParameters.displayWidth = this.data.displayWidth\n if (this.data.displayHeight !== -1) arProfile.sourceParameters.displayHeight = this.data.displayHeight\n\n arProfile.checkIfValid()\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tCode Separator\n //////////////////////////////////////////////////////////////////////////////\n\n this._arSession = null\n\n _this.isReady = false\n _this.needsOverride = true\n\n // wait until the renderer is isReady\n this.el.sceneEl.addEventListener('renderstart', function () {\n var scene = _this.el.sceneEl.object3D\n var camera = _this.el.sceneEl.camera\n var renderer = _this.el.sceneEl.renderer\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tbuild ARjs.Session\n //////////////////////////////////////////////////////////////////////////////\n var arSession = _this._arSession = new _three_js_src_new_api_arjs_session__WEBPACK_IMPORTED_MODULE_2__[\"default\"]({\n scene: scene,\n renderer: renderer,\n camera: camera,\n sourceParameters: arProfile.sourceParameters,\n contextParameters: arProfile.contextParameters\n })\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tCode Separator\n //////////////////////////////////////////////////////////////////////////////\n\n _this.isReady = true\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tawful resize trick\n //////////////////////////////////////////////////////////////////////////////\n // KLUDGE\n window.addEventListener('resize', onResize)\n function onResize() {\n var arSource = _this._arSession.arSource\n\n // ugly kludge to get resize on aframe... not even sure it works\n if (arProfile.contextParameters.trackingBackend !== 'tango') {\n arSource.copyElementSizeTo(document.body)\n }\n\n // fixing a-frame css\n var buttonElement = document.querySelector('.a-enter-vr')\n if (buttonElement) {\n buttonElement.style.position = 'fixed'\n }\n }\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\thonor .debugUIEnabled\n //////////////////////////////////////////////////////////////////////////////\n if (_this.data.debugUIEnabled) initDebugUI()\n function initDebugUI() {\n // get or create containerElement\n var containerElement = document.querySelector('#arjsDebugUIContainer')\n if (containerElement === null) {\n containerElement = document.createElement('div')\n containerElement.id = 'arjsDebugUIContainer'\n containerElement.setAttribute('style', 'position: fixed; bottom: 10px; width:100%; text-align: center; z-index: 1;color: grey;')\n document.body.appendChild(containerElement)\n }\n\n // create sessionDebugUI\n var sessionDebugUI = new _three_js_src_new_api_arjs_debugui__WEBPACK_IMPORTED_MODULE_3__.SessionDebugUI(arSession)\n containerElement.appendChild(sessionDebugUI.domElement)\n }\n })\n\n //////////////////////////////////////////////////////////////////////////////\n //\t\tCode Separator\n //////////////////////////////////////////////////////////////////////////////\n // TODO this is crappy - code an exponential backoff - max 1 seconds\n // KLUDGE: kludge to write a 'resize' event\n // var startedAt = Date.now()\n // var timerId = setInterval(function () {\n // if (Date.now() - startedAt > 10000 * 1000) {\n // clearInterval(timerId)\n // return\n // }\n // // onResize()\n // window.dispatchEvent(new Event('resize'));\n // }, 1000 / 30)\n\n function setBackoff(func, millisDuration = Infinity, limit = 1000) {\n if(func == null || !(Object.prototype.toString.call(func) == '[object Function]')) {\n return;\n } \n let backoff = 33.3\n let start = Date.now()\n let repeat = function() {\n return (millisDuration == Infinity || (Date.now() - start) < millisDuration)\n }\n let next = function() {\n backoff = (backoff * 2) < limit ? (backoff * 2) : limit\n setTimeout(function() {\n func()\n if(repeat()) {\n next()\n }\n }, backoff)\n };\n next()\n }\n\n setBackoff(() => {\n window.dispatchEvent(new Event('resize'))\n })\n },\n\n tick: function () {\n // skip it if not yet isInitialised\n if (this.isReady === false || this.data.videoTexture === true) return\n\n // update arSession\n this._arSession.update()\n\n // copy projection matrix to camera\n this._arSession.onResize()\n },\n\n _displayErrorPopup: function(msg) {\n if (this.data.errorPopup !== '') {\n let errorPopup = document.getElementById(this.data.errorPopup);\n if (!errorPopup) {\n errorPopup = document.createElement('div');\n errorPopup.setAttribute('id', this.data.errorPopup);\n document.body.appendChild(errorPopup);\n }\n errorPopup.innerHTML = msg;\n } else {\n alert(msg);\n }\n }\n})\n\n\n//# sourceURL=webpack:///./src/system-arjs.js?" - ); - - /***/ - }, - - /***/ "../node_modules/aframe/dist/aframe-master.js": - /*!****************************************************!*\ - !*** ../node_modules/aframe/dist/aframe-master.js ***! - \****************************************************/ - /***/ (module, __unused_webpack_exports, __webpack_require__) => { - eval( - "(function(f){if(true){module.exports=f()}else { var g; }})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c=undefined;if(!f&&c)return require(i,!0);if(u)return u(i,!0);var a=new Error(\"Cannot find module '\"+i+\"'\");throw a.code=\"MODULE_NOT_FOUND\",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u=undefined,i=0;i 0) {\n throw new Error('Invalid string. Length must be a multiple of 4')\n }\n\n // Trim off extra bytes after placeholder bytes are found\n // See: https://github.com/beatgammit/base64-js/issues/42\n var validLen = b64.indexOf('=')\n if (validLen === -1) validLen = len\n\n var placeHoldersLen = validLen === len\n ? 0\n : 4 - (validLen % 4)\n\n return [validLen, placeHoldersLen]\n}\n\n// base64 is 4/3 + up to two characters of the original data\nfunction byteLength (b64) {\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction _byteLength (b64, validLen, placeHoldersLen) {\n return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen\n}\n\nfunction toByteArray (b64) {\n var tmp\n var lens = getLens(b64)\n var validLen = lens[0]\n var placeHoldersLen = lens[1]\n\n var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))\n\n var curByte = 0\n\n // if there are placeholders, only get up to the last complete 4 chars\n var len = placeHoldersLen > 0\n ? validLen - 4\n : validLen\n\n for (var i = 0; i < len; i += 4) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 18) |\n (revLookup[b64.charCodeAt(i + 1)] << 12) |\n (revLookup[b64.charCodeAt(i + 2)] << 6) |\n revLookup[b64.charCodeAt(i + 3)]\n arr[curByte++] = (tmp >> 16) & 0xFF\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 2) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 2) |\n (revLookup[b64.charCodeAt(i + 1)] >> 4)\n arr[curByte++] = tmp & 0xFF\n }\n\n if (placeHoldersLen === 1) {\n tmp =\n (revLookup[b64.charCodeAt(i)] << 10) |\n (revLookup[b64.charCodeAt(i + 1)] << 4) |\n (revLookup[b64.charCodeAt(i + 2)] >> 2)\n arr[curByte++] = (tmp >> 8) & 0xFF\n arr[curByte++] = tmp & 0xFF\n }\n\n return arr\n}\n\nfunction tripletToBase64 (num) {\n return lookup[num >> 18 & 0x3F] +\n lookup[num >> 12 & 0x3F] +\n lookup[num >> 6 & 0x3F] +\n lookup[num & 0x3F]\n}\n\nfunction encodeChunk (uint8, start, end) {\n var tmp\n var output = []\n for (var i = start; i < end; i += 3) {\n tmp =\n ((uint8[i] << 16) & 0xFF0000) +\n ((uint8[i + 1] << 8) & 0xFF00) +\n (uint8[i + 2] & 0xFF)\n output.push(tripletToBase64(tmp))\n }\n return output.join('')\n}\n\nfunction fromByteArray (uint8) {\n var tmp\n var len = uint8.length\n var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes\n var parts = []\n var maxChunkLength = 16383 // must be multiple of 3\n\n // go through the array every three bytes, we'll deal with trailing stuff later\n for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {\n parts.push(encodeChunk(\n uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)\n ))\n }\n\n // pad the end with zeros, but make sure to not forget the extra bytes\n if (extraBytes === 1) {\n tmp = uint8[len - 1]\n parts.push(\n lookup[tmp >> 2] +\n lookup[(tmp << 4) & 0x3F] +\n '=='\n )\n } else if (extraBytes === 2) {\n tmp = (uint8[len - 2] << 8) + uint8[len - 1]\n parts.push(\n lookup[tmp >> 10] +\n lookup[(tmp >> 4) & 0x3F] +\n lookup[(tmp << 2) & 0x3F] +\n '='\n )\n }\n\n return parts.join('')\n}\n\n},{}],4:[function(require,module,exports){\n'use strict';\n// For more information about browser field, check out the browser field at https://github.com/substack/browserify-handbook#browser-field.\n\nmodule.exports = {\n // Create a tag with optional data attributes\n createLink: function(href, attributes) {\n var head = document.head || document.getElementsByTagName('head')[0];\n var link = document.createElement('link');\n\n link.href = href;\n link.rel = 'stylesheet';\n\n for (var key in attributes) {\n if ( ! attributes.hasOwnProperty(key)) {\n continue;\n }\n var value = attributes[key];\n link.setAttribute('data-' + key, value);\n }\n\n head.appendChild(link);\n },\n // Create a