@ma2yama/ar.js 3.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 AR.js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+
2
+ # AR.js - Augmented Reality on the Web
3
+
4
+
5
+ [![CI](https://github.com/AR-js-org/AR.js/actions/workflows/CI.yml/badge.svg)](https://github.com/AR-js-org/AR.js/actions/workflows/CI.yml)
6
+ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
7
+ [![Gitter chat](https://badges.gitter.im/AR-js/Lobby.png)](https://gitter.im/AR-js/Lobby)
8
+ [![Twitter Follow](https://img.shields.io/twitter/follow/nicolocarp.svg?style=plastic&label=nicolocarpignoli-𝕏(Twitter)&style=plastic)](https://twitter.com/nicolocarp)
9
+ [![Twitter Follow](https://img.shields.io/twitter/follow/jerome_etienne.svg?style=plastic&label=jeromeetienne-𝕏(Twitter)&style=plastic)](https://twitter.com/jerome_etienne)
10
+
11
+ You can now own the first commit of AR.js! 👉[OpenSea](https://opensea.io/assets/matic/0xe7ea2e2be12c257d376400cb231d8ee51e972bd6/3962549295964122998537137060348053157629730105441540397501924171148500367064/)
12
+
13
+ AR.js is a lightweight library for Augmented Reality on the Web, coming with features like Image Tracking, Location-based AR and Marker tracking.
14
+
15
+ <i><b>30/12/21 Update:</b> There is now also a brand new OSS Web AR JS library around, called [MindAR](https://github.com/hiukim/mind-ar-js).
16
+ If you need a great Image tracking feature (also multiple image tracking) and Face tracking, [go check it out](https://github.com/hiukim/mind-ar-js)!
17
+ As for now, AR.js is still the only library providing Marker based and Location based AR features.</i>
18
+
19
+ This project has been created by [@jeromeetienne](https://github.com/jeromeetienne), previously managed by Nicolò Carpignoli and it is now maintained by the AR.js org.
20
+
21
+ 🚀For frequent updates on AR.js you can follow [@the official 𝕏(Twitter) account](https://twitter.com/ARjs_Library) and Watch this repo!
22
+
23
+ Logo is courtesy of <a href="https://twitter.com/viralinfo"> Simon Poulter </a>.
24
+
25
+ ------
26
+
27
+
28
+ ### ⚡️AR.js has now an official Documentation!⚡️
29
+ ### Check it out: [AR.js Official Documentation](https://ar-js-org.github.io/AR.js-Docs/).
30
+
31
+ If you want to give a first look at AR.js potential, you can continue with this Readme.
32
+
33
+ -----
34
+
35
+
36
+ ⚡️ AR.js is coming in different builds. They are both maintained. They are exclusive.
37
+
38
+ Please import the one you need for your project, not both:
39
+
40
+ - **AR.js with Image Tracking + Location Based AR (AFRAME):**
41
+
42
+ - https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js
43
+
44
+ - **AR.js with Marker Tracking + Location Based AR (AFRAME):**
45
+
46
+ - https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js
47
+
48
+
49
+ - **AR.js with Image Tracking + Marker Tracking (Threejs):**
50
+
51
+ - https://raw.githack.com/AR-js-org/AR.js/master/three.js/build/ar-threex.js
52
+
53
+ if you need the ARjs namespace import ar.js:
54
+
55
+ - https://raw.githack.com/AR-js-org/AR.js/master/three.js/build/ar.js
56
+
57
+ - **AR.js with Location Based AR (Threejs):**
58
+
59
+ - https://raw.githack.com/AR-js-org/AR.js/master/three.js/build/ar-threex-location-only.js
60
+
61
+
62
+ You can also import a specific version replacing `master` keyword with version tag:
63
+
64
+ ```html
65
+ <script src="https://raw.githack.com/AR-js-org/AR.js/3.4.7/aframe/build/aframe-ar-nft.js">
66
+ ```
67
+
68
+ ## Get started
69
+
70
+ ### 🖼 **Image Tracking**
71
+
72
+ Please follow these simple steps:
73
+
74
+ - Create a new project with the code below (or [open this live example](https://ar-js-org.github.io/.github/profile/aframe/examples/image-tracking/nft/) and go directly to the last step)
75
+ - Run it on a server
76
+ - Open the website on your phone
77
+ - Scan [this picture](https://raw.githubusercontent.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex-image-big.jpeg) to see content through the camera.
78
+
79
+ ```html
80
+ <script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@1.6.0/dist/aframe-master.min.js"></script>
81
+ <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>
82
+
83
+ <style>
84
+ .arjs-loader {
85
+ height: 100%;
86
+ width: 100%;
87
+ position: absolute;
88
+ top: 0;
89
+ left: 0;
90
+ background-color: rgba(0, 0, 0, 0.8);
91
+ z-index: 9999;
92
+ display: flex;
93
+ justify-content: center;
94
+ align-items: center;
95
+ }
96
+
97
+ .arjs-loader div {
98
+ text-align: center;
99
+ font-size: 1.25em;
100
+ color: white;
101
+ }
102
+ </style>
103
+
104
+ <body style="margin : 0px; overflow: hidden;">
105
+ <!-- minimal loader shown until image descriptors are loaded -->
106
+ <div class="arjs-loader">
107
+ <div>Loading, please wait...</div>
108
+ </div>
109
+ <a-scene
110
+ vr-mode-ui="enabled: false;"
111
+ renderer="logarithmicDepthBuffer: true; precision: medium;"
112
+ embedded
113
+ arjs="trackingMethod: best; sourceType: webcam;debugUIEnabled: false;"
114
+ >
115
+ <!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server -->
116
+ <a-nft
117
+ type="nft"
118
+ url="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/trex-image/trex"
119
+ smooth="true"
120
+ smoothCount="10"
121
+ smoothTolerance=".01"
122
+ smoothThreshold="5"
123
+ >
124
+ <a-entity
125
+ gltf-model="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
126
+ scale="5 5 5"
127
+ position="150 300 -100"
128
+ >
129
+ </a-entity>
130
+ </a-nft>
131
+ <a-entity camera></a-entity>
132
+ </a-scene>
133
+ </body>
134
+ ```
135
+
136
+ ### 🌍Location Based Example
137
+
138
+ Please follow these simple steps:
139
+
140
+ - Create a new project with the following snippet, and change `add-your-latitude` and `add-your-longitude` with your latitude and longitude, without the `<>`.
141
+ - Run it on a server
142
+ - Activate GPS on your phone and navigate to the example URL
143
+ - Look around. You should see the text looking at you, appearing in the requested position, even if you look around and move.
144
+
145
+ ```html
146
+ <!DOCTYPE html>
147
+ <html>
148
+ <head>
149
+ <meta charset="utf-8" />
150
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
151
+ <title>GeoAR.js demo</title>
152
+ <script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
153
+ <script src="https://unpkg.com/aframe-look-at-component@1.0.0/dist/aframe-look-at-component.min.js"></script>
154
+ <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar-nft.js"></script>
155
+ </head>
156
+
157
+ <body>
158
+ <a-scene
159
+ vr-mode-ui="enabled: false"
160
+ arjs="sourceType: webcam; videoTexture: true; debugUIEnabled: false;"
161
+ >
162
+ <a-text
163
+ value="This content will always face you."
164
+ look-at="[gps-camera]"
165
+ scale="120 120 120"
166
+ gps-entity-place="latitude: <add-your-latitude>; longitude: <add-your-longitude>;"
167
+ ></a-text>
168
+ <a-camera gps-camera rotation-reader> </a-camera>
169
+ </a-scene>
170
+ </body>
171
+ </html>
172
+ ```
173
+
174
+ ### 🔲 Marker Based Example
175
+
176
+ Please follow this simple steps:
177
+
178
+ - Create a new project with the code below (or [open this live example](https://ar-js-org.github.io/.github/profile/aframe/examples/marker-based/basic.html) and go directly to the last step)
179
+ - Run it on a server
180
+ - Open the website on your phone
181
+ - Scan [this picture](https://raw.githubusercontent.com/AR-js-org/AR.js/master/data/images/hiro.png) to see content through the camera.
182
+
183
+ ```html
184
+ <!DOCTYPE html>
185
+ <html>
186
+ <script src="https://aframe.io/releases/1.6.0/aframe.min.js"></script>
187
+ <!-- we import arjs version without NFT but with marker + location based support -->
188
+ <script src="https://raw.githack.com/AR-js-org/AR.js/master/aframe/build/aframe-ar.js"></script>
189
+ <body style="margin : 0px; overflow: hidden;">
190
+ <a-scene embedded arjs>
191
+ <a-marker preset="hiro">
192
+ <!-- we use cors proxy to avoid cross-origin problems ATTENTION! you need to set up your server -->
193
+ <a-entity
194
+ position="0 0 0"
195
+ scale="0.05 0.05 0.05"
196
+ gltf-model="your-server/https://raw.githack.com/AR-js-org/AR.js/master/aframe/examples/image-tracking/nft/trex/scene.gltf"
197
+ ></a-entity>
198
+ </a-marker>
199
+ <a-entity camera></a-entity>
200
+ </a-scene>
201
+ </body>
202
+ </html>
203
+ ```
204
+ Important! Be aware that if you are referring to external resources, in any app, especially those using NFT, you will encounter CORS problems if those resources are not in the same server of the code. If you can’t see the tracking, please open your Browser Dev Tools and check if you have CORS errors in the console. If so, you have to fix those errors in order to see your content. The correct fix is to place your resources on the same server of your code.
205
+
206
+ If you cannot do that, you can host a proxy anywhere server to solve that (https://github.com/Rob--W/cors-anywhere).
207
+ Please note that several hosting services have policies that does not permit to use such server. Always check hosting services policies before using them to avoid account suspensions
208
+
209
+ Learn more on the [AR.js Official Documentation](https://ar-js-org.github.io/AR.js-Docs/).
210
+
211
+ ## ES6 npm package
212
+
213
+ You can install **AR.js** with **npm** and use in any compatible project that support npm modules (React.js, Vue.js, Next.js or whatelse), to install it run:
214
+
215
+ ```
216
+ // Install with npm
217
+ npm install @ar-js-org/ar.js
218
+ ```
219
+ ```
220
+ // Install with yarn
221
+ yarn add @ar-js-org/ar.js
222
+ ```
223
+ For some examples read this [issue](https://github.com/AR-js-org/AR.js/issues/234).
224
+ ### New Import Syntax for `ar-threex.mjs` and `ar.mjs`
225
+
226
+ With the updates 3.4.6, `three.js` can now be imported using the ES module syntax.
227
+ To align with this standard, `ar-threex.mjs`,`ar.mjs` and `ar-threex-location-only.mjs` should also be imported in the same way using an import map. Here is an example of how to import these modules in your project:
228
+
229
+ ```html
230
+ // Example importing ar-threex.mjs
231
+ <script type="importmap">
232
+ {
233
+ "imports": {
234
+ "three": "https://cdn.jsdelivr.net/npm/three@0.164.0/build/three.module.js",
235
+ "threex": "./path/to/ar-threex.mjs",
236
+ }
237
+ }
238
+ </script>
239
+
240
+ <script type="module">
241
+ import * as THREE from 'three';
242
+ import { ArToolkitSource, ArToolkitContext, ArMarkerControls } from 'threex'
243
+
244
+ // Your AR.js code here
245
+ </script>
246
+ ```
247
+ Read the examples included in this repository for more information, but basically the only change is the import syntax.
248
+
249
+ ## Troubleshooting, feature requests, community
250
+
251
+ **You can find a lot of help on the old [AR.js repositories issues](https://github.com/jeromeetienne/AR.js/issues). Please search on open/closed issues, you may find interesting stuff.**
252
+
253
+ ### Contributing
254
+
255
+ From opening a bug report to creating a pull request: every contribution is
256
+ appreciated and welcome. If you're planning to implement a new feature or change
257
+ the api please create an issue first. This way we can ensure that your precious
258
+ work is not in vain.
259
+
260
+ ### Issues
261
+
262
+ If you are having configuration or setup problems, please post
263
+ a question to [StackOverflow](https://stackoverflow.com/search?q=ar.js).
264
+ You can also address the question to us in our [Gitter chatroom](https://gitter.im/AR-js/Lobby)
265
+
266
+ **If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.**
267
+
268
+ ### Submitting Changes
269
+
270
+ After getting some feedback, push to your fork and submit a pull request. We
271
+ may suggest some changes or improvements or alternatives, but for small changes
272
+ your pull request should be accepted quickly.
273
+
274
+ Some things that will increase the chance that your pull request is accepted:
275
+
276
+ * Follow the existing coding style
277
+ * Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
278
+
279
+ ## Licenses
280
+
281
+ It is **all open-source**! artoolkit5-js is under LGPLv3 license and additional permission.
282
+ And all my code in the AR.js repository is under MIT license. :)
283
+
284
+ For legal details, be sure to check [artoolkit5-js license](https://github.com/AR-js-org/artoolkit5-js/blob/master/LICENSE)
285
+ and [AR.js license](https://github.com/AR-js-org/AR.js/blob/master/LICENSE).
286
+
287
+ Full Changelog: [AR.js changelog](https://github.com/AR-js-org/AR.js/blob/master/CHANGELOG.md)
@@ -0,0 +1 @@
1
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("aframe"),require("three")):"function"==typeof define&&define.amd?define(["aframe","three"],e):"object"==typeof exports?exports.ARjs=e(require("aframe"),require("three")):t.ARjs=e(t.AFRAME,t.THREE)}(this,((t,e)=>(()=>{"use strict";var i={14:e=>{e.exports=t},818:t=>{t.exports=e}},o={};function n(t){var e=o[t];if(void 0!==e)return e.exports;var s=o[t]={exports:{}};return i[t](s,s.exports,n),s.exports}var s=n(14),a=n(818);const r=function(t){var e=this;this.object=t,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0,this.alphaOffset=0,this.smoothingFactor=1,this.TWO_PI=2*Math.PI,this.HALF_PI=.5*Math.PI;var i,o,n,s,r=function(t){e.deviceOrientation=t},d=function(){e.screenOrientation=window.orientation||0},c=(i=new a.Vector3(0,0,1),o=new a.Euler,n=new a.Quaternion,s=new a.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),function(t,e,a,r,d){o.set(a,e,-r,"YXZ"),t.setFromEuler(o),t.multiply(s),t.multiply(n.setFromAxisAngle(i,-d))});this.connect=function(){d(),window.addEventListener("orientationchange",d,!1),window.addEventListener("deviceorientation",r,!1),e.enabled=!0},this.disconnect=function(){window.removeEventListener("orientationchange",d,!1),window.removeEventListener("deviceorientation",r,!1),e.enabled=!1},this.update=function(){if(!1!==e.enabled){var t=e.deviceOrientation;if(t){var i=t.alpha?a.MathUtils.degToRad(t.alpha)+e.alphaOffset:0,o=t.beta?a.MathUtils.degToRad(t.beta):0,n=t.gamma?a.MathUtils.degToRad(t.gamma):0,s=e.screenOrientation?a.MathUtils.degToRad(e.screenOrientation):0,r=this.smoothingFactor;this.lastOrientation?(i=this._getSmoothedAngle(i,this.lastOrientation.alpha,r),o=this._getSmoothedAngle(o+Math.PI,this.lastOrientation.beta,r),n=this._getSmoothedAngle(n+this.HALF_PI,this.lastOrientation.gamma,r,Math.PI)):(o+=Math.PI,n+=this.HALF_PI),this.lastOrientation={alpha:i,beta:o,gamma:n},c(e.object.quaternion,i,o-Math.PI,n-this.HALF_PI,s)}}},this._orderAngle=function(t,e,i=this.TWO_PI){return e>t&&Math.abs(e-t)<i/2||t>e&&Math.abs(e-t)>i/2?{left:t,right:e}:{left:e,right:t}},this._getSmoothedAngle=function(t,e,i,o=this.TWO_PI){const n=this._orderAngle(t,e,o),s=n.left,a=n.right;n.left=0,n.right-=s,n.right<0&&(n.right+=o);let r=a==e?(1-i)*n.right+i*n.left:i*n.right+(1-i)*n.left;return r+=s,r>=o&&(r-=o),r},this.dispose=function(){e.disconnect()},this.connect()};var d,c=Math.PI/2;return s.registerComponent("arjs-look-controls",{dependencies:["position","rotation"],schema:{enabled:{default:!0},magicWindowTrackingEnabled:{default:!0},pointerLockEnabled:{default:!1},reverseMouseDrag:{default:!1},reverseTouchDrag:{default:!1},touchEnabled:{default:!0},smoothingFactor:{type:"number",default:1}},init:function(){this.deltaYaw=0,this.previousHMDPosition=new THREE.Vector3,this.hmdQuaternion=new THREE.Quaternion,this.magicWindowAbsoluteEuler=new THREE.Euler,this.magicWindowDeltaEuler=new THREE.Euler,this.position=new THREE.Vector3,this.magicWindowObject=new THREE.Object3D,this.rotation={},this.deltaRotation={},this.savedPose=null,this.pointerLocked=!1,this.setupMouseControls(),this.bindMethods(),this.previousMouseEvent={},this.setupMagicWindowControls(),this.savedPose={position:new THREE.Vector3,rotation:new THREE.Euler},this.el.sceneEl.is("vr-mode")&&this.onEnterVR()},setupMagicWindowControls:function(){var t,e=this.data;s.utils.device.isMobile()&&(t=this.magicWindowControls=new r(this.magicWindowObject),"undefined"!=typeof DeviceOrientationEvent&&DeviceOrientationEvent.requestPermission&&(t.enabled=!1,this.el.sceneEl.components["device-orientation-permission-ui"].permissionGranted?t.enabled=e.magicWindowTrackingEnabled:this.el.sceneEl.addEventListener("deviceorientationpermissiongranted",(function(){t.enabled=e.magicWindowTrackingEnabled}))))},update:function(t){var e=this.data;e.enabled!==t.enabled&&this.updateGrabCursor(e.enabled),t&&!e.magicWindowTrackingEnabled&&t.magicWindowTrackingEnabled&&(this.magicWindowAbsoluteEuler.set(0,0,0),this.magicWindowDeltaEuler.set(0,0,0)),this.magicWindowControls&&(this.magicWindowControls.enabled=e.magicWindowTrackingEnabled,this.magicWindowControls.smoothingFactor=e.smoothingFactor),t&&!e.pointerLockEnabled!==t.pointerLockEnabled&&(this.removeEventListeners(),this.addEventListeners(),this.pointerLocked&&this.exitPointerLock())},tick:function(t){this.data.enabled&&this.updateOrientation()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.pointerLocked&&this.exitPointerLock()},remove:function(){this.removeEventListeners(),this.pointerLocked&&this.exitPointerLock()},bindMethods:function(){this.onMouseDown=s.utils.bind(this.onMouseDown,this),this.onMouseMove=s.utils.bind(this.onMouseMove,this),this.onMouseUp=s.utils.bind(this.onMouseUp,this),this.onTouchStart=s.utils.bind(this.onTouchStart,this),this.onTouchMove=s.utils.bind(this.onTouchMove,this),this.onTouchEnd=s.utils.bind(this.onTouchEnd,this),this.onEnterVR=s.utils.bind(this.onEnterVR,this),this.onExitVR=s.utils.bind(this.onExitVR,this),this.onPointerLockChange=s.utils.bind(this.onPointerLockChange,this),this.onPointerLockError=s.utils.bind(this.onPointerLockError,this)},setupMouseControls:function(){this.mouseDown=!1,this.pitchObject=new THREE.Object3D,this.yawObject=new THREE.Object3D,this.yawObject.position.y=10,this.yawObject.add(this.pitchObject)},addEventListeners:function(){var t=this.el.sceneEl,e=t.canvas;e?(e.addEventListener("mousedown",this.onMouseDown,!1),window.addEventListener("mousemove",this.onMouseMove,!1),window.addEventListener("mouseup",this.onMouseUp,!1),e.addEventListener("touchstart",this.onTouchStart),window.addEventListener("touchmove",this.onTouchMove),window.addEventListener("touchend",this.onTouchEnd),t.addEventListener("enter-vr",this.onEnterVR),t.addEventListener("exit-vr",this.onExitVR),this.data.pointerLockEnabled&&(document.addEventListener("pointerlockchange",this.onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.addEventListener("pointerlockerror",this.onPointerLockError,!1))):t.addEventListener("render-target-loaded",s.utils.bind(this.addEventListeners,this))},removeEventListeners:function(){var t=this.el.sceneEl,e=t&&t.canvas;e&&(e.removeEventListener("mousedown",this.onMouseDown),window.removeEventListener("mousemove",this.onMouseMove),window.removeEventListener("mouseup",this.onMouseUp),e.removeEventListener("touchstart",this.onTouchStart),window.removeEventListener("touchmove",this.onTouchMove),window.removeEventListener("touchend",this.onTouchEnd),t.removeEventListener("enter-vr",this.onEnterVR),t.removeEventListener("exit-vr",this.onExitVR),document.removeEventListener("pointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("mozpointerlockchange",this.onPointerLockChange,!1),document.removeEventListener("pointerlockerror",this.onPointerLockError,!1))},updateOrientation:(d=new THREE.Matrix4,function(){var t,e=this.el.object3D,i=this.pitchObject,o=this.yawObject,n=this.el.sceneEl;n.is("vr-mode")&&n.checkHeadsetConnected()?n.hasWebXR&&(t=n.renderer.xr.getCameraPose())&&(d.elements=t.transform.matrix,d.decompose(e.position,e.rotation,e.scale)):(this.updateMagicWindowOrientation(),e.rotation.x=this.magicWindowDeltaEuler.x+i.rotation.x,e.rotation.y=this.magicWindowDeltaEuler.y+o.rotation.y,e.rotation.z=this.magicWindowDeltaEuler.z)}),updateMagicWindowOrientation:function(){var t=this.magicWindowAbsoluteEuler,e=this.magicWindowDeltaEuler;this.magicWindowControls&&this.magicWindowControls.enabled&&(this.magicWindowControls.update(),t.setFromQuaternion(this.magicWindowObject.quaternion,"YXZ"),this.previousMagicWindowYaw||0===t.y||(this.previousMagicWindowYaw=t.y),this.previousMagicWindowYaw&&(e.x=t.x,e.y+=t.y-this.previousMagicWindowYaw,e.z=t.z,this.previousMagicWindowYaw=t.y))},onMouseMove:function(t){var e,i,o,n=this.pitchObject,s=this.previousMouseEvent,a=this.yawObject;this.data.enabled&&(this.mouseDown||this.pointerLocked)&&(this.pointerLocked?(i=t.movementX||t.mozMovementX||0,o=t.movementY||t.mozMovementY||0):(i=t.screenX-s.screenX,o=t.screenY-s.screenY),this.previousMouseEvent.screenX=t.screenX,this.previousMouseEvent.screenY=t.screenY,e=this.data.reverseMouseDrag?1:-1,a.rotation.y+=.002*i*e,n.rotation.x+=.002*o*e,n.rotation.x=Math.max(-c,Math.min(c,n.rotation.x)))},onMouseDown:function(t){var e=this.el.sceneEl;if(!(!this.data.enabled||e.is("vr-mode")&&e.checkHeadsetConnected())&&0===t.button){var i=e&&e.canvas;this.mouseDown=!0,this.previousMouseEvent.screenX=t.screenX,this.previousMouseEvent.screenY=t.screenY,this.showGrabbingCursor(),this.data.pointerLockEnabled&&!this.pointerLocked&&(i.requestPointerLock?i.requestPointerLock():i.mozRequestPointerLock&&i.mozRequestPointerLock())}},showGrabbingCursor:function(){this.el.sceneEl.canvas.style.cursor="grabbing"},hideGrabbingCursor:function(){this.el.sceneEl.canvas.style.cursor=""},onMouseUp:function(){this.mouseDown=!1,this.hideGrabbingCursor()},onTouchStart:function(t){1===t.touches.length&&this.data.touchEnabled&&!this.el.sceneEl.is("vr-mode")&&(this.touchStart={x:t.touches[0].pageX,y:t.touches[0].pageY},this.touchStarted=!0)},onTouchMove:function(t){var e,i,o=this.el.sceneEl.canvas,n=this.yawObject;this.touchStarted&&this.data.touchEnabled&&(i=2*Math.PI*(t.touches[0].pageX-this.touchStart.x)/o.clientWidth,e=this.data.reverseTouchDrag?1:-1,n.rotation.y-=.5*i*e,this.touchStart={x:t.touches[0].pageX,y:t.touches[0].pageY})},onTouchEnd:function(){this.touchStarted=!1},onEnterVR:function(){var t=this.el.sceneEl;t.checkHeadsetConnected()&&(this.saveCameraPose(),this.el.object3D.position.set(0,0,0),this.el.object3D.rotation.set(0,0,0),t.hasWebXR&&(this.el.object3D.matrixAutoUpdate=!1,this.el.object3D.updateMatrix()))},onExitVR:function(){this.el.sceneEl.checkHeadsetConnected()&&(this.restoreCameraPose(),this.previousHMDPosition.set(0,0,0),this.el.object3D.matrixAutoUpdate=!0)},onPointerLockChange:function(){this.pointerLocked=!(!document.pointerLockElement&&!document.mozPointerLockElement)},onPointerLockError:function(){this.pointerLocked=!1},exitPointerLock:function(){document.exitPointerLock(),this.pointerLocked=!1},updateGrabCursor:function(t){var e=this.el.sceneEl;function i(){e.canvas.classList.add("a-grab-cursor")}function o(){e.canvas.classList.remove("a-grab-cursor")}e.canvas?t?i():o():t?e.addEventListener("render-target-loaded",i):e.addEventListener("render-target-loaded",o)},saveCameraPose:function(){var t=this.el;this.savedPose.position.copy(t.object3D.position),this.savedPose.rotation.copy(t.object3D.rotation),this.hasSavedPose=!0},restoreCameraPose:function(){var t=this.el,e=this.savedPose;this.hasSavedPose&&(t.object3D.position.copy(e.position),t.object3D.rotation.copy(e.rotation),this.hasSavedPose=!1)}}),s.registerComponent("arjs-webcam-texture",{init:function(){this.scene=this.el.sceneEl,this.texCamera=new a.OrthographicCamera(-.5,.5,.5,-.5,0,10),this.texScene=new a.Scene,this.scene.renderer.autoClear=!1,this.video=document.createElement("video"),this.video.setAttribute("autoplay",!0),this.video.setAttribute("playsinline",!0),this.video.setAttribute("display","none"),document.body.appendChild(this.video),this.geom=new a.PlaneGeometry,this.texture=new a.VideoTexture(this.video),this.material=new a.MeshBasicMaterial({map:this.texture});const t=new a.Mesh(this.geom,this.material);this.texScene.add(t)},play:function(){if(navigator.mediaDevices&&navigator.mediaDevices.getUserMedia){const t={video:{facingMode:"environment"}};navigator.mediaDevices.getUserMedia(t).then((t=>{this.video.srcObject=t,this.video.play()})).catch((t=>{this.el.sceneEl.systems.arjs._displayErrorPopup(`Webcam error: ${t}`)}))}else this.el.sceneEl.systems.arjs._displayErrorPopup("sorry - media devices API not supported")},tick:function(){this.scene.renderer.clear(),this.scene.renderer.render(this.texScene,this.texCamera),this.scene.renderer.clearDepth()},pause:function(){this.video.srcObject.getTracks().forEach((t=>{t.stop()}))},remove:function(){this.material.dispose(),this.texture.dispose(),this.geom.dispose()}}),s.registerComponent("gps-camera",{_watchPositionId:null,originCoords:null,currentCoords:null,lookControls:null,heading:null,schema:{simulateLatitude:{type:"number",default:0},simulateLongitude:{type:"number",default:0},simulateAltitude:{type:"number",default:0},positionMinAccuracy:{type:"int",default:100},alert:{type:"boolean",default:!1},minDistance:{type:"int",default:0},maxDistance:{type:"int",default:0},gpsMinDistance:{type:"number",default:5},gpsTimeInterval:{type:"number",default:0}},update:function(){if(0!==this.data.simulateLatitude&&0!==this.data.simulateLongitude){var t=Object.assign({},this.currentCoords||{});t.longitude=this.data.simulateLongitude,t.latitude=this.data.simulateLatitude,t.altitude=this.data.simulateAltitude,this.currentCoords=t,this.originCoords=null,this._updatePosition()}},init:function(){if(this.el.components["arjs-look-controls"]||this.el.components["look-controls"]){this.lastPosition={latitude:0,longitude:0},this.loader=document.createElement("DIV"),this.loader.classList.add("arjs-loader"),document.body.appendChild(this.loader),this.onGpsEntityPlaceAdded=this._onGpsEntityPlaceAdded.bind(this),window.addEventListener("gps-entity-place-added",this.onGpsEntityPlaceAdded),this.lookControls=this.el.components["arjs-look-controls"]||this.el.components["look-controls"];var t=this._getDeviceOrientationEventName();if(this._onDeviceOrientation=this._onDeviceOrientation.bind(this),navigator.userAgent.match(/Version\/[\d.]+.*Safari/))if("function"==typeof DeviceOrientationEvent.requestPermission){var e=function(){console.log("Requesting device orientation permissions..."),DeviceOrientationEvent.requestPermission(),document.removeEventListener("touchend",e)};document.addEventListener("touchend",(function(){e()}),!1),this.el.sceneEl.systems.arjs._displayErrorPopup("After camera permission prompt, please tap the screen to activate geolocation.")}else{var i=setTimeout((function(){this.el.sceneEl.systems.arjs._displayErrorPopup("Please enable device orientation in Settings > Safari > Motion & Orientation Access.")}),750);window.addEventListener(t,(function(){clearTimeout(i)}))}window.addEventListener(t,this._onDeviceOrientation,!1)}},play:function(){if(0!==this.data.simulateLatitude&&0!==this.data.simulateLongitude){var t=Object.assign({},this.currentCoords||{});t.latitude=this.data.simulateLatitude,t.longitude=this.data.simulateLongitude,0!==this.data.simulateAltitude&&(t.altitude=this.data.simulateAltitude),this.currentCoords=t,this._updatePosition()}else this._watchPositionId=this._initWatchGPS(function(t){var e={latitude:t.coords.latitude,longitude:t.coords.longitude,altitude:t.coords.altitude,accuracy:t.coords.accuracy,altitudeAccuracy:t.coords.altitudeAccuracy};0!==this.data.simulateAltitude&&(e.altitude=this.data.simulateAltitude),this.currentCoords=e,(this._haversineDist(this.lastPosition,this.currentCoords)>=this.data.gpsMinDistance||!this.originCoords)&&(this._updatePosition(),this.lastPosition={longitude:this.currentCoords.longitude,latitude:this.currentCoords.latitude})}.bind(this))},tick:function(){null!==this.heading&&this._updateRotation()},pause:function(){this._watchPositionId&&navigator.geolocation.clearWatch(this._watchPositionId),this._watchPositionId=null},remove:function(){var t=this._getDeviceOrientationEventName();window.removeEventListener(t,this._onDeviceOrientation,!1),window.removeEventListener("gps-entity-place-added",this.onGpsEntityPlaceAdded)},_getDeviceOrientationEventName:function(){if("ondeviceorientationabsolute"in window)var t="deviceorientationabsolute";else"ondeviceorientation"in window?t="deviceorientation":(t="",console.error("Compass not supported"));return t},_initWatchGPS:function(t,e){return e||(e=function(t){console.warn("ERROR("+t.code+"): "+t.message),1!==t.code?3!==t.code||this.el.sceneEl.systems.arjs._displayErrorPopup("Cannot retrieve GPS position. Signal is absent."):this.el.sceneEl.systems.arjs._displayErrorPopup("Please activate Geolocation and refresh the page. If it is already active, please check permissions for this website.")}),"geolocation"in navigator==0?(e({code:0,message:"Geolocation is not supported by your browser"}),Promise.resolve()):navigator.geolocation.watchPosition(t,e,{enableHighAccuracy:!0,maximumAge:this.data.gpsTimeInterval,timeout:27e3})},_updatePosition:function(){if(this.currentCoords.accuracy>this.data.positionMinAccuracy){if(this.data.alert&&!document.getElementById("alert-popup")){var t=document.createElement("div");t.innerHTML="GPS signal is very poor. Try move outdoor or to an area with a better signal.",t.setAttribute("id","alert-popup"),document.body.appendChild(t)}}else{var e=document.getElementById("alert-popup");if(this.currentCoords.accuracy<=this.data.positionMinAccuracy&&e&&document.body.removeChild(e),this.originCoords)this._setPosition();else{this.originCoords=this.currentCoords,this._setPosition();var i=document.querySelector(".arjs-loader");i&&i.remove(),window.dispatchEvent(new CustomEvent("gps-camera-origin-coord-set"))}}},_setPosition:function(){var t=this.el.getAttribute("position"),e={longitude:this.currentCoords.longitude,latitude:this.originCoords.latitude};t.x=this.computeDistanceMeters(this.originCoords,e),t.x*=this.currentCoords.longitude>this.originCoords.longitude?1:-1,e={longitude:this.originCoords.longitude,latitude:this.currentCoords.latitude},t.z=this.computeDistanceMeters(this.originCoords,e),t.z*=this.currentCoords.latitude>this.originCoords.latitude?-1:1,this.el.setAttribute("position",t),window.dispatchEvent(new CustomEvent("gps-camera-update-position",{detail:{position:this.currentCoords,origin:this.originCoords}}))},computeDistanceMeters:function(t,e,i){var o=this._haversineDist(t,e);return i&&this.data.minDistance&&this.data.minDistance>0&&o<this.data.minDistance||i&&this.data.maxDistance&&this.data.maxDistance>0&&o>this.data.maxDistance?Number.MAX_SAFE_INTEGER:o},_haversineDist:function(t,e){var i=a.MathUtils.degToRad(e.longitude-t.longitude),o=a.MathUtils.degToRad(e.latitude-t.latitude),n=Math.sin(o/2)*Math.sin(o/2)+Math.cos(a.MathUtils.degToRad(t.latitude))*Math.cos(a.MathUtils.degToRad(e.latitude))*(Math.sin(i/2)*Math.sin(i/2));return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371e3},_computeCompassHeading:function(t,e,i){var o=t*(Math.PI/180),n=e*(Math.PI/180),s=i*(Math.PI/180),a=Math.cos(o),r=Math.sin(o),d=Math.sin(n),c=Math.cos(s),h=Math.sin(s),u=-a*h-r*d*c,l=-r*h+a*d*c,p=Math.atan(u/l);return l<0?p+=Math.PI:u<0&&(p+=2*Math.PI),p*(180/Math.PI)},_onDeviceOrientation:function(t){void 0!==t.webkitCompassHeading?t.webkitCompassAccuracy<50?this.heading=t.webkitCompassHeading:console.warn("webkitCompassAccuracy is event.webkitCompassAccuracy"):null!==t.alpha?!0===t.absolute||void 0===t.absolute?this.heading=this._computeCompassHeading(t.alpha,t.beta,t.gamma):console.warn("event.absolute === false"):console.warn("event.alpha === null")},_updateRotation:function(){var t=(360-this.heading-(this.el.getAttribute("rotation").y-a.MathUtils.radToDeg(this.lookControls.yawObject.rotation.y)))%360;this.lookControls.yawObject.rotation.y=a.MathUtils.degToRad(t)},_onGpsEntityPlaceAdded:function(){this.originCoords&&window.dispatchEvent(new CustomEvent("gps-camera-origin-coord-set")),this.loader&&this.loader.parentElement&&document.body.removeChild(this.loader)}}),s.registerComponent("gps-entity-place",{_cameraGps:null,schema:{longitude:{type:"number",default:0},latitude:{type:"number",default:0}},remove:function(){window.removeEventListener("gps-camera-origin-coord-set",this.coordSetListener),window.removeEventListener("gps-camera-update-position",this.updatePositionListener)},init:function(){this.coordSetListener=()=>{if(!this._cameraGps){var t=document.querySelector("[gps-camera]");if(!t.components["gps-camera"])return void console.error("gps-camera not initialized");this._cameraGps=t.components["gps-camera"]}this._updatePosition()},this.updatePositionListener=t=>{if(this.data&&this._cameraGps){var e={longitude:this.data.longitude,latitude:this.data.latitude},i=this._cameraGps.computeDistanceMeters(t.detail.position,e);this.el.setAttribute("distance",i),this.el.setAttribute("distanceMsg",this._formatDistance(i)),this.el.dispatchEvent(new CustomEvent("gps-entity-place-update-position",{detail:{distance:i}})),this._cameraGps.computeDistanceMeters(t.detail.position,e,!0)===Number.MAX_SAFE_INTEGER?this.hideForMinDistance(this.el,!0):this.hideForMinDistance(this.el,!1)}},window.addEventListener("gps-camera-origin-coord-set",this.coordSetListener),window.addEventListener("gps-camera-update-position",this.updatePositionListener),this._positionXDebug=0,window.dispatchEvent(new CustomEvent("gps-entity-place-added",{detail:{component:this.el}}))},hideForMinDistance:function(t,e){e?t.setAttribute("visible","false"):t.setAttribute("visible","true")},_updatePosition:function(){var t={x:0,y:this.el.getAttribute("position").y||0,z:0},e={longitude:this.data.longitude,latitude:this._cameraGps.originCoords.latitude};if(t.x=this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords,e),this._positionXDebug=t.x,t.x*=this.data.longitude>this._cameraGps.originCoords.longitude?1:-1,e={longitude:this._cameraGps.originCoords.longitude,latitude:this.data.latitude},t.z=this._cameraGps.computeDistanceMeters(this._cameraGps.originCoords,e),t.z*=this.data.latitude>this._cameraGps.originCoords.latitude?-1:1,0!==t.y){var i=void 0!==this._cameraGps.originCoords.altitude?this._cameraGps.originCoords.altitude:0;t.y=t.y-i}this.el.setAttribute("position",t)},_formatDistance:function(t){return(t=t.toFixed(0))>=1e3?t/1e3+" kilometers":t+" meters"}}),s.registerComponent("gps-projected-camera",{_watchPositionId:null,originCoords:null,currentCoords:null,lookControls:null,heading:null,schema:{simulateLatitude:{type:"number",default:0},simulateLongitude:{type:"number",default:0},simulateAltitude:{type:"number",default:0},positionMinAccuracy:{type:"int",default:100},alert:{type:"boolean",default:!1},minDistance:{type:"int",default:0},gpsMinDistance:{type:"number",default:0},gpsTimeInterval:{type:"number",default:0}},update:function(){if(0!==this.data.simulateLatitude&&0!==this.data.simulateLongitude){var t=Object.assign({},this.currentCoords||{});t.longitude=this.data.simulateLongitude,t.latitude=this.data.simulateLatitude,t.altitude=this.data.simulateAltitude,this.currentCoords=t,this.originCoords=null,this._updatePosition()}},init:function(){if(this.el.components["arjs-look-controls"]||this.el.components["look-controls"]){this.lastPosition={latitude:0,longitude:0},this.loader=document.createElement("DIV"),this.loader.classList.add("arjs-loader"),document.body.appendChild(this.loader),this.onGpsEntityPlaceAdded=this._onGpsEntityPlaceAdded.bind(this),window.addEventListener("gps-entity-place-added",this.onGpsEntityPlaceAdded),this.lookControls=this.el.components["arjs-look-controls"]||this.el.components["look-controls"];var t=this._getDeviceOrientationEventName();if(this._onDeviceOrientation=this._onDeviceOrientation.bind(this),navigator.userAgent.match(/Version\/[\d.]+.*Safari/))if("function"==typeof DeviceOrientationEvent.requestPermission){var e=function(){console.log("Requesting device orientation permissions..."),DeviceOrientationEvent.requestPermission(),document.removeEventListener("touchend",e)};document.addEventListener("touchend",(function(){e()}),!1),this.el.sceneEl.systems.arjs._displayErrorPopup("After camera permission prompt, please tap the screen to activate geolocation.")}else{var i=setTimeout((function(){this.el.sceneEl.systems.arjs._displayErrorPopup("Please enable device orientation in Settings > Safari > Motion & Orientation Access.")}),750);window.addEventListener(t,(function(){clearTimeout(i)}))}window.addEventListener(t,this._onDeviceOrientation,!1)}},play:function(){if(0!==this.data.simulateLatitude&&0!==this.data.simulateLongitude){var t=Object.assign({},this.currentCoords||{});t.latitude=this.data.simulateLatitude,t.longitude=this.data.simulateLongitude,0!==this.data.simulateAltitude&&(t.altitude=this.data.simulateAltitude),this.currentCoords=t,this._updatePosition()}else this._watchPositionId=this._initWatchGPS(function(t){var e={latitude:t.coords.latitude,longitude:t.coords.longitude,altitude:t.coords.altitude,accuracy:t.coords.accuracy,altitudeAccuracy:t.coords.altitudeAccuracy};0!==this.data.simulateAltitude&&(e.altitude=this.data.simulateAltitude),this.currentCoords=e,(this._haversineDist(this.lastPosition,this.currentCoords)>=this.data.gpsMinDistance||!this.originCoords)&&(this._updatePosition(),this.lastPosition={longitude:this.currentCoords.longitude,latitude:this.currentCoords.latitude})}.bind(this))},tick:function(){null!==this.heading&&this._updateRotation()},pause:function(){this._watchPositionId&&navigator.geolocation.clearWatch(this._watchPositionId),this._watchPositionId=null},remove:function(){var t=this._getDeviceOrientationEventName();window.removeEventListener(t,this._onDeviceOrientation,!1),window.removeEventListener("gps-entity-place-added",this.onGpsEntityPlaceAdded)},_getDeviceOrientationEventName:function(){if("ondeviceorientationabsolute"in window)var t="deviceorientationabsolute";else"ondeviceorientation"in window?t="deviceorientation":(t="",console.error("Compass not supported"));return t},_initWatchGPS:function(t,e){return e||(e=function(t){console.warn("ERROR("+t.code+"): "+t.message),1!==t.code?3!==t.code||this.el.sceneEl.systems.arjs._displayErrorPopup("Cannot retrieve GPS position. Signal is absent."):this.el.sceneEl.systems.arjs._displayErrorPopup("Please activate Geolocation and refresh the page. If it is already active, please check permissions for this website.")}),"geolocation"in navigator==0?(e({code:0,message:"Geolocation is not supported by your browser"}),Promise.resolve()):navigator.geolocation.watchPosition(t,e,{enableHighAccuracy:!0,maximumAge:this.data.gpsTimeInterval,timeout:27e3})},_updatePosition:function(){if(this.currentCoords.accuracy>this.data.positionMinAccuracy){if(this.data.alert&&!document.getElementById("alert-popup")){var t=document.createElement("div");t.innerHTML="GPS signal is very poor. Try move outdoor or to an area with a better signal.",t.setAttribute("id","alert-popup"),document.body.appendChild(t)}}else{var e=document.getElementById("alert-popup");if(this.currentCoords.accuracy<=this.data.positionMinAccuracy&&e&&document.body.removeChild(e),this.originCoords)this._setPosition();else{this.originCoords=this._project(this.currentCoords.latitude,this.currentCoords.longitude),this._setPosition();var i=document.querySelector(".arjs-loader");i&&i.remove(),window.dispatchEvent(new CustomEvent("gps-camera-origin-coord-set"))}}},_setPosition:function(){var t=this.el.getAttribute("position"),e=this.latLonToWorld(this.currentCoords.latitude,this.currentCoords.longitude);t.x=e[0],t.z=e[1],this.el.setAttribute("position",t),window.dispatchEvent(new CustomEvent("gps-camera-update-position",{detail:{position:this.currentCoords,origin:this.originCoords}}))},computeDistanceMeters:function(t,e){var i=this.el.getAttribute("position"),o=t.x-i.x,n=t.z-i.z,s=Math.sqrt(o*o+n*n);return e&&this.data.minDistance&&this.data.minDistance>0&&s<this.data.minDistance?Number.MAX_SAFE_INTEGER:s},latLonToWorld:function(t,e){var i=this._project(t,e);return[i[0]-this.originCoords[0],-(i[1]-this.originCoords[1])]},_project:function(t,e){const i=20037508.34;return[e/180*i,Math.log(Math.tan((90+t)*Math.PI/360))/(Math.PI/180)*i/180]},_unproject:function(t,e){const i=20037508.34;var o=e/i*180;return{longitude:t/i*180,latitude:180/Math.PI*(2*Math.atan(Math.exp(o*Math.PI/180))-Math.PI/2)}},_computeCompassHeading:function(t,e,i){var o=t*(Math.PI/180),n=e*(Math.PI/180),s=i*(Math.PI/180),a=Math.cos(o),r=Math.sin(o),d=Math.sin(n),c=Math.cos(s),h=Math.sin(s),u=-a*h-r*d*c,l=-r*h+a*d*c,p=Math.atan(u/l);return l<0?p+=Math.PI:u<0&&(p+=2*Math.PI),p*(180/Math.PI)},_onDeviceOrientation:function(t){void 0!==t.webkitCompassHeading?t.webkitCompassAccuracy<50?this.heading=t.webkitCompassHeading:console.warn("webkitCompassAccuracy is event.webkitCompassAccuracy"):null!==t.alpha?!0===t.absolute||void 0===t.absolute?this.heading=this._computeCompassHeading(t.alpha,t.beta,t.gamma):console.warn("event.absolute === false"):console.warn("event.alpha === null")},_updateRotation:function(){var t=(360-this.heading-(this.el.getAttribute("rotation").y-THREE.MathUtils.radToDeg(this.lookControls.yawObject.rotation.y)))%360;this.lookControls.yawObject.rotation.y=THREE.MathUtils.degToRad(t)},_haversineDist:function(t,e){var i=THREE.MathUtils.degToRad(e.longitude-t.longitude),o=THREE.MathUtils.degToRad(e.latitude-t.latitude),n=Math.sin(o/2)*Math.sin(o/2)+Math.cos(THREE.MathUtils.degToRad(t.latitude))*Math.cos(THREE.MathUtils.degToRad(e.latitude))*(Math.sin(i/2)*Math.sin(i/2));return 2*Math.atan2(Math.sqrt(n),Math.sqrt(1-n))*6371e3},_onGpsEntityPlaceAdded:function(){this.originCoords&&window.dispatchEvent(new CustomEvent("gps-camera-origin-coord-set")),this.loader&&this.loader.parentElement&&document.body.removeChild(this.loader)}}),s.registerComponent("gps-projected-entity-place",{_cameraGps:null,schema:{longitude:{type:"number",default:0},latitude:{type:"number",default:0}},remove:function(){window.removeEventListener("gps-camera-update-position",this.updatePositionListener)},init:function(){this.coordSetListener=()=>{if(!this._cameraGps){var t=document.querySelector("[gps-projected-camera]");if(!t.components["gps-projected-camera"])return void console.error("gps-projected-camera not initialized");this._cameraGps=t.components["gps-projected-camera"],this._updatePosition()}},this.updatePositionListener=t=>{if(this.data&&this._cameraGps){var e=this.el.getAttribute("position"),i=this._cameraGps.computeDistanceMeters(e);this.el.setAttribute("distance",i),this.el.setAttribute("distanceMsg",this._formatDistance(i)),this.el.dispatchEvent(new CustomEvent("gps-entity-place-update-position",{detail:{distance:i}})),this._cameraGps.computeDistanceMeters(e,!0)===Number.MAX_SAFE_INTEGER?this.hideForMinDistance(this.el,!0):this.hideForMinDistance(this.el,!1)}},window.addEventListener("gps-camera-origin-coord-set",this.coordSetListener),window.addEventListener("gps-camera-update-position",this.updatePositionListener),this._positionXDebug=0,window.dispatchEvent(new CustomEvent("gps-entity-place-added",{detail:{component:this.el}}))},hideForMinDistance:function(t,e){e?t.setAttribute("visible","false"):t.setAttribute("visible","true")},_updatePosition:function(){var t=this._cameraGps.latLonToWorld(this.data.latitude,this.data.longitude),e=this.el.getAttribute("position");this.el.setAttribute("position",{x:t[0],y:e.y,z:t[1]})},_formatDistance:function(t){return(t=t.toFixed(0))>=1e3?t/1e3+" kilometers":t+" meters"}}),{}})()));