@realsee/five 6.8.0 → 6.8.1

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.
Files changed (216) hide show
  1. package/ai_guides/features/flowing-light-2d-pass.md +64 -10
  2. package/ai_guides/features/flowing-light-3d-pass.md +64 -10
  3. package/docs/assets/hierarchy.js +1 -1
  4. package/docs/assets/navigation.js +1 -1
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/five.AdaptiveLuminancePass.html +1 -1
  7. package/docs/classes/five.BoundingMesh.html +1 -1
  8. package/docs/classes/five.Camera.html +1 -1
  9. package/docs/classes/five.EyeDomeLightingPass.html +1 -1
  10. package/docs/classes/five.Five.html +1 -1
  11. package/docs/classes/five.FivePass.html +1 -1
  12. package/docs/classes/five.InternalWebGLRenderer.html +1 -1
  13. package/docs/classes/five.Model.html +1 -1
  14. package/docs/classes/five.ModelScene.html +1 -1
  15. package/docs/classes/five.NetworkSubscribe.html +1 -1
  16. package/docs/classes/five.PBMContainer.html +1 -1
  17. package/docs/classes/five.PBMCustomShader.html +1 -1
  18. package/docs/classes/five.PBMGSObject.html +1 -1
  19. package/docs/classes/five.PBMGroup.html +1 -1
  20. package/docs/classes/five.PBMMesh.html +1 -1
  21. package/docs/classes/five.PBMMeshMaterial.html +1 -1
  22. package/docs/classes/five.PBMPanoFilter.html +1 -1
  23. package/docs/classes/five.PBMPointCloud.html +1 -1
  24. package/docs/classes/five.PBMPointCloudMaterial.html +1 -1
  25. package/docs/classes/five.PBMSkinnedMesh.html +1 -1
  26. package/docs/classes/five.PBMUpdateable.html +1 -1
  27. package/docs/classes/five.PanoCircleMesh.html +1 -1
  28. package/docs/classes/five.PanoCircleMeshCustom.html +1 -1
  29. package/docs/classes/five.PanoCircleMeshSolid.html +1 -1
  30. package/docs/classes/five.Parameter.html +1 -1
  31. package/docs/classes/five.Scene.html +1 -1
  32. package/docs/classes/five.Subscribe.html +1 -1
  33. package/docs/classes/five.Tile3D.html +1 -1
  34. package/docs/classes/five.TileNode.html +1 -1
  35. package/docs/classes/five.TrajectoryNode.html +1 -1
  36. package/docs/classes/five.WorkResolvedObserver.html +1 -1
  37. package/docs/classes/gltf-loader.DDSLoader.html +1 -1
  38. package/docs/classes/gltf-loader.DRACOLoader.html +1 -1
  39. package/docs/classes/gltf-loader.GLTFLoader.html +1 -1
  40. package/docs/classes/gltf-loader.GLTFObject.html +1 -1
  41. package/docs/classes/gltf-loader.THREEGLTFLoader.html +1 -1
  42. package/docs/classes/line.Line.html +1 -1
  43. package/docs/classes/line.LineGeometry.html +1 -1
  44. package/docs/classes/line.LineMaterial.html +1 -1
  45. package/docs/classes/line.LineSegmentsGeometry.html +1 -1
  46. package/docs/classes/line.THREE_Line2.html +1 -1
  47. package/docs/classes/line.THREE_LineSegments2.html +1 -1
  48. package/docs/classes/plugins.BasePlugin.Controller.html +1 -1
  49. package/docs/classes/plugins.CSS2DObject.html +10 -0
  50. package/docs/classes/plugins.CSS2DRenderer.html +7 -0
  51. package/docs/classes/plugins.CSS3DObject.html +1 -1
  52. package/docs/classes/plugins.CSS3DSprite.html +1 -1
  53. package/docs/classes/plugins.Object3DHelperController.html +1 -1
  54. package/docs/classes/plugins.RoundedBoxGeometry.html +1 -1
  55. package/docs/classes/sticker.Sticker.html +1 -1
  56. package/docs/classes/vfx.Airflow.html +1 -1
  57. package/docs/classes/vfx.Flame.html +1 -1
  58. package/docs/classes/vfx.Particle.html +1 -1
  59. package/docs/classes/vfx.ParticleGPU.html +1 -1
  60. package/docs/classes/vfx.SpotLight.html +1 -1
  61. package/docs/documents/features_flowing-light-2d-pass.html +28 -15
  62. package/docs/documents/features_flowing-light-3d-pass.html +27 -14
  63. package/docs/functions/plugins.CSS2DPlugin.html +1 -0
  64. package/docs/functions/react.getPlugin.html +2 -0
  65. package/docs/functions/react.setPlugin.html +2 -0
  66. package/docs/functions/react.useFivePlugin.html +8 -0
  67. package/docs/functions/react.withFive.html +1 -1
  68. package/docs/hierarchy.html +1 -1
  69. package/docs/interfaces/five.AddableObject.html +1 -1
  70. package/docs/interfaces/five.AjaxOptions.html +1 -1
  71. package/docs/interfaces/five.BaseEvent.html +1 -1
  72. package/docs/interfaces/five.BaseExtendableEvent.html +1 -1
  73. package/docs/interfaces/five.EventCallback.html +1 -1
  74. package/docs/interfaces/five.GestureEvent.html +1 -1
  75. package/docs/interfaces/five.ImageOptions.html +1 -1
  76. package/docs/interfaces/five.IntersectEvent.html +1 -1
  77. package/docs/interfaces/five.IntersectMesh.html +1 -1
  78. package/docs/interfaces/five.IntersectMeshInterface.html +1 -1
  79. package/docs/interfaces/five.Intersection.html +1 -1
  80. package/docs/interfaces/five.LooseWorkWithExtrinsics.html +1 -1
  81. package/docs/interfaces/five.ModeChangeEvent.html +1 -1
  82. package/docs/interfaces/five.ModelControllerCustomInitArgs.html +1 -1
  83. package/docs/interfaces/five.ModelEvent.html +1 -1
  84. package/docs/interfaces/five.ModelSceneEvent.html +1 -1
  85. package/docs/interfaces/five.ModelTileEvent.html +1 -1
  86. package/docs/interfaces/five.MovePanoOptions.html +1 -1
  87. package/docs/interfaces/five.NetworkAbortError.html +1 -1
  88. package/docs/interfaces/five.NetworkFirbiddenError.html +1 -1
  89. package/docs/interfaces/five.NetworkOptions.html +1 -1
  90. package/docs/interfaces/five.NetworkProxyError.html +1 -1
  91. package/docs/interfaces/five.NetworkResourceEvent.html +1 -1
  92. package/docs/interfaces/five.NetworkResponseError.html +1 -1
  93. package/docs/interfaces/five.NetworkTimeoutError.html +1 -1
  94. package/docs/interfaces/five.ObjectEvent.html +1 -1
  95. package/docs/interfaces/five.PBMMaterial.html +1 -1
  96. package/docs/interfaces/five.PBMMeshMaterialParameters.html +1 -1
  97. package/docs/interfaces/five.PBMPointCloudMaterialParameters.html +1 -1
  98. package/docs/interfaces/five.PanoCircleMeshInterface.html +1 -1
  99. package/docs/interfaces/five.PanoEvent.html +1 -1
  100. package/docs/interfaces/five.PanoPrepareEvent.html +1 -1
  101. package/docs/interfaces/five.PanoTextureEvent.html +1 -1
  102. package/docs/interfaces/five.PanoramaControllerCustomInitArgs.html +1 -1
  103. package/docs/interfaces/five.PanoramaLikeControllerCustomInitArgs.html +1 -1
  104. package/docs/interfaces/five.ParameterMaterialValue.html +1 -1
  105. package/docs/interfaces/five.ParameterTilesetValue.html +1 -1
  106. package/docs/interfaces/five.ParameterValue.html +1 -1
  107. package/docs/interfaces/five.Pose.html +1 -1
  108. package/docs/interfaces/five.RenderEvent.html +1 -1
  109. package/docs/interfaces/five.ResolvedParameterValue.html +1 -1
  110. package/docs/interfaces/five.State.html +1 -1
  111. package/docs/interfaces/five.StateEvent.html +1 -1
  112. package/docs/interfaces/five.TextureOptions.html +1 -1
  113. package/docs/interfaces/five.TopviewControllerCustomInitArgs.html +1 -1
  114. package/docs/interfaces/five.VRPanoramaControllerCustomInitArgs.html +1 -1
  115. package/docs/interfaces/five.ViewLayer.html +1 -1
  116. package/docs/interfaces/five.WorkCubeImage.html +1 -1
  117. package/docs/interfaces/five.WorkImage.html +1 -1
  118. package/docs/interfaces/five.WorkObserver.html +1 -1
  119. package/docs/interfaces/five.WorkObserverProto.html +1 -1
  120. package/docs/interfaces/five.WorkTile.html +1 -1
  121. package/docs/interfaces/five.WorksEvent.html +1 -1
  122. package/docs/interfaces/five.XRControllerEvent.html +1 -1
  123. package/docs/interfaces/five.XRGestureEvent.html +1 -1
  124. package/docs/interfaces/five.XRPanoramaControllerCustomInitArgs.html +1 -1
  125. package/docs/interfaces/five.XRSessionEvent.html +1 -1
  126. package/docs/interfaces/plugins.BackgroundPluginController.html +1 -1
  127. package/docs/interfaces/plugins.BackgroundPluginType.EventMap.html +1 -1
  128. package/docs/interfaces/plugins.BasePlugin.State.html +1 -1
  129. package/docs/interfaces/plugins.CSS2DPluginController.html +49 -0
  130. package/docs/interfaces/plugins.CSS2DPluginType.Config.html +2 -0
  131. package/docs/interfaces/plugins.CSS2DPluginType.CreateCSS2DObjectType.html +8 -0
  132. package/docs/interfaces/plugins.CSS2DPluginType.EventMap.html +10 -0
  133. package/docs/interfaces/plugins.CSS2DPluginType.Params.html +4 -0
  134. package/docs/interfaces/plugins.CSS2DPluginType.State.html +8 -0
  135. package/docs/interfaces/plugins.CSS2DRendererParameters.html +2 -0
  136. package/docs/interfaces/plugins.CSS3DPluginController.html +12 -12
  137. package/docs/interfaces/plugins.CSS3DPluginType.EventMap.html +1 -1
  138. package/docs/interfaces/plugins.CSS3DPluginType.State.html +1 -1
  139. package/docs/interfaces/plugins.DynamicPathLinePluginController.html +1 -1
  140. package/docs/interfaces/plugins.DynamicPathLinePluginType.EventMap.html +1 -1
  141. package/docs/interfaces/plugins.DynamicPathLinePluginType.State.html +1 -1
  142. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationController.html +1 -1
  143. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.EventMap.html +1 -1
  144. package/docs/interfaces/plugins.GaussianSplattingEntranceAnimationPluginType.State.html +1 -1
  145. package/docs/interfaces/plugins.ItemMaskController.html +1 -1
  146. package/docs/interfaces/plugins.ItemMaskPluginType.EventMap.html +1 -1
  147. package/docs/interfaces/plugins.ItemMaskPluginType.State.html +1 -1
  148. package/docs/interfaces/plugins.Object3DHelperPluginType.BaseController.html +1 -1
  149. package/docs/interfaces/plugins.Object3DHelperPluginType.BaseHelper.html +1 -1
  150. package/docs/interfaces/plugins.Object3DHelperPluginType.BoundingBoxController.html +1 -1
  151. package/docs/interfaces/plugins.Object3DHelperPluginType.MoveController.html +1 -1
  152. package/docs/interfaces/plugins.Object3DHelperPluginType.MoveHelperAbstract.html +1 -1
  153. package/docs/interfaces/plugins.Object3DHelperPluginType.RotateController.html +1 -1
  154. package/docs/interfaces/plugins.Object3DHelperPluginType.RotateHelperAbstract.html +1 -1
  155. package/docs/interfaces/plugins.OrientationPluginController.html +1 -1
  156. package/docs/interfaces/plugins.OrientationPluginType.EventMap.html +1 -1
  157. package/docs/interfaces/plugins.OrientationPluginType.State.html +1 -1
  158. package/docs/interfaces/plugins.PanoAnimeController.html +1 -1
  159. package/docs/interfaces/plugins.PanoAnimePluginType.EventMap.html +1 -1
  160. package/docs/interfaces/plugins.PanoAnimePluginType.State.html +1 -1
  161. package/docs/interfaces/plugins.PluginTemplateType.EventMap.html +1 -1
  162. package/docs/interfaces/plugins.PluginTemplateType.State.html +1 -1
  163. package/docs/interfaces/plugins.TrajectoryController.html +1 -1
  164. package/docs/interfaces/react.FiveAppProps.html +11 -0
  165. package/docs/interfaces/react.FiveInjectionTypes.html +1 -1
  166. package/docs/modules/plugins.CSS2DPluginType.html +1 -0
  167. package/docs/modules/plugins.html +1 -1
  168. package/docs/modules/react.html +1 -1
  169. package/docs/types/five.ParseOptions.html +1 -1
  170. package/docs/types/plugins.BasePlugin.EventMap.html +1 -1
  171. package/docs/types/plugins.CSS2DPluginType.PluginData.html +1 -0
  172. package/docs/types/plugins.CSS2DPluginType.ServerData.html +1 -0
  173. package/docs/variables/react.FiveApp.html +3 -0
  174. package/docs/variables/react.FiveAutoCanvas.html +3 -0
  175. package/five/index.js +5 -5
  176. package/five/index.mjs +65 -65
  177. package/five/renderer/postprocessing/passes/flowing-light-2d-pass.d.ts +6 -1
  178. package/five/renderer/postprocessing/passes/flowing-light-3d-pass.d.ts +3 -1
  179. package/gltf-loader/index.js +3 -3
  180. package/gltf-loader/index.mjs +3 -3
  181. package/line/index.js +3 -3
  182. package/line/index.mjs +3 -3
  183. package/package.json +1 -1
  184. package/plugins/CSS2DPlugin/Controller.d.ts +59 -0
  185. package/plugins/CSS2DPlugin/index.d.ts +5 -0
  186. package/plugins/CSS2DPlugin/typing.d.ts +30 -0
  187. package/plugins/index.d.ts +2 -0
  188. package/plugins/index.js +24 -4
  189. package/plugins/index.mjs +557 -393
  190. package/plugins/thirdParty/CSS2DRenderer.d.ts +37 -0
  191. package/react/autoCanvas.d.ts +9 -0
  192. package/react/fiveApp.d.ts +22 -0
  193. package/react/hooks/useFivePlugin.d.ts +26 -0
  194. package/react/index.d.ts +4 -0
  195. package/react/index.js +3 -3
  196. package/react/index.mjs +291 -175
  197. package/react/withFive.d.ts +1 -1
  198. package/shader-lib/index.js +2 -2
  199. package/shader-lib/index.mjs +2 -2
  200. package/sticker/index.js +3 -3
  201. package/sticker/index.mjs +3 -3
  202. package/umd/five-gltf-loader.js +3 -3
  203. package/umd/five-line.js +3 -3
  204. package/umd/five-plugins.js +24 -4
  205. package/umd/five-react.js +3 -3
  206. package/umd/five-shader-lib.js +2 -2
  207. package/umd/five-sticker.js +3 -3
  208. package/umd/five-vfx.js +2 -2
  209. package/umd/five-vue.js +2 -2
  210. package/umd/five.js +5 -5
  211. package/vfx/index.js +2 -2
  212. package/vfx/index.mjs +2 -2
  213. package/vue/index.js +2 -2
  214. package/vue/index.mjs +2 -2
  215. package/work-downloader/index.js +2 -2
  216. package/work-downloader/index.mjs +2 -2
package/umd/five.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five
4
- * Generated: 4/17/2026
5
- * Version: 6.8.0
4
+ * Generated: 2026/4/28
5
+ * Version: 6.8.1
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -935,7 +935,7 @@ void main() {
935
935
  #include <fog_fragment>
936
936
  #include <premultiplied_alpha_fragment>
937
937
  }
938
- `,uniforms:{diffuse:{value:new three.Color},opacity:{value:1},displacementScalar:{value:0}}};function createPipeBufferGeometry(e,t,n,r){let o=new Float32Array((n+1)*(r+1)*3),s=new Float32Array((n+1)*(r+1)*3),c=new Float32Array((n+1)*(r+1)*2),l=new Uint32Array(n*r*6),u=e.computeFrenetFrames(n),d=new three.Vector3,f=new three.Vector3,p=new three.Vector2,m=new three.Vector3;for(let l=0;l<=n;l++){m=e.getPointAt(l/n,m);let h=u.normals[l],g=u.binormals[l];for(let e=0;e<=r;e++){let u=l*(r+1)+e,_=e/r*Math.PI*2,v=Math.sin(_),y=-Math.cos(_);f.x=y*h.x+v*g.x,f.y=y*h.y+v*g.y,f.z=y*h.z+v*g.z,f.normalize(),f.toArray(s,u*3),d.x=m.x+t*f.x,d.y=m.y+t*f.y,d.z=m.z+t*f.z,d.toArray(o,u*3),p.x=l/n,p.y=e/r,p.toArray(c,u*2)}}for(let e=0;e<n;e++)for(let t=0;t<r;t++){let n=(e*r+t)*6,o=(r+1)*e+t,s=(r+1)*(e+1)+t,c=(r+1)*(e+1)+(t+1),u=(r+1)*e+(t+1);l[n]=o,l[n+1]=s,l[n+2]=u,l[n+3]=s,l[n+4]=c,l[n+5]=u}let h=new three.BufferGeometry;return h.setIndex(new three.BufferAttribute(l,1)),h.setAttribute(`position`,new three.BufferAttribute(o,3)),h.setAttribute(`normal`,new three.BufferAttribute(s,3)),h.setAttribute(`uv`,new three.BufferAttribute(c,2)),h}function parseTrajectoryObject(e,t){let n=new three.Color(0).convertSRGBToLinear(),r=new three.Color(52949).convertSRGBToLinear(),o=new three.Color(3370495).convertSRGBToLinear(),s=new three.Color(16777215).convertSRGBToLinear(),c=0,l=new three.CurvePath,u=e.length;for(let t=3;t<u;t+=3){let n=new three.Vector3().fromArray(e,t-3),r=new three.Vector3().fromArray(e,t);c+=n.distanceTo(r);let o=new three.LineCurve3(n,r);l.add(o)}let d=createPipeBufferGeometry(l,.03,Math.ceil(c*100),6);d.clearGroups(),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,0),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,1),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,2);let f=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.BackSide});f.uniforms.totalLength.value=c,f.uniforms.diffuse.value=n,f.uniforms.diffuse2.value=n,f.uniforms.opacity.value=.5,f.transparent=!0;let p=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.BackSide});p.uniforms.totalLength.value=c,p.uniforms.displacementScalar.value=-.01,p.uniforms.diffuse.value=r,p.uniforms.diffuse2.value=o;let m=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.DoubleSide});m.uniforms.totalLength.value=c,m.uniforms.displacementScalar.value=-.026,m.uniforms.dashSize.value=new three.Vector2(.06,.09),m.uniforms.diffuse.value=s,m.uniforms.diffuse2.value=s;let h=new three.Mesh(d,[f,p,m]),g=.08,_=24,v=new three.SphereBufferGeometry(.08,24,24);v.clearGroups(),v.addGroup(0,d.index?d.index.count:d.attributes.position.count,0),v.addGroup(0,d.index?d.index.count:d.attributes.position.count,1);let y=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.BackSide});y.uniforms.diffuse.value=n,y.uniforms.opacity.value=.5,y.transparent=!0;let b=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.FrontSide});b.uniforms.displacementScalar.value=-.01,b.uniforms.diffuse.value=r;let S=new three.Mesh(v,[y,b]);S.position.fromArray(e,0),h.add(S);let C=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.FrontSide});C.uniforms.displacementScalar.value=-.01,C.uniforms.diffuse.value=o;let w=new three.Mesh(v,[y,C]);return w.position.fromArray(e,e.length-3),h.add(w),{scene:h,dispose:()=>{d.dispose(),f.dispose(),p.dispose(),m.dispose(),v.dispose(),y.dispose(),b.dispose(),C.dispose()}}}function loadTrajectory(e,t){let n=e.name,r=imageURL(appendSearch(e.content.uri,t.search),{key:`model.0`});return e.content.loadState=`LOADING`,e.content.loadStateUpdateTime=now(),loadPly(r,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:t.fetcher}).then(t=>{var o,s,c,l;let u=(s=(o=t.scene.attributes)==null?void 0:o.time.array)==null?[]:s,d=(l=(c=t.scene.attributes)==null?void 0:c.position.array)==null?[]:l,f=t.byteLength,p=t.memoryUsage,m=parseTrajectoryObject(d,u);m.scene.applyMatrix4(e.transform),m.scene.updateWorldMatrix(!1,!0),m.scene.matrixAutoUpdate=!1;let h=new TrajectoryNode(n,m.scene);return e.content.data={uri:r,byteLength:f,memoryUsage:p,positionArray:d,timeArray:u,object:h},e.content.byteLength=f,e.content.memoryUsage=p,e.content.loadState=`READY`,e.content.loadStateUpdateTime=now(),e}).catch(t=>(e.content.data=void 0,e.content.loadState=`FAILED`,e.content.loadStateUpdateTime=now(),t instanceof NetworkResponseError&&t.httpStatus===0||t instanceof NetworkTimeoutError||t instanceof NetworkProxyError?e.content.loadfailRetryDelay=clamp$1(e.content.loadfailRetryDelay+RETRY_DELAY_STEP,RETRY_DELAY_STEP,MAX_RETRY_DELAY):e.content.loadfailRetryDelay=1/0,Promise.reject(t)))}function unloadTrajectory(e){e.content&&(e.content.data&&e.content.data.object.dispose(),e.content.data=void 0,e.content.loadState=`UNLOADED`,e.content.loadProgress=0,e.content.loadStateUpdateTime=now(),e.content.byteLength=0,e.content.memoryUsage=0)}var scratchVector3$7=new three.Vector3,scratchMatrix3=new three.Matrix3,scratchMatrix4$3=new three.Matrix4,a=6378137,invF=298.257223563;function ecefToLla(e){let t=a-a/invF,n=(a*a-t*t)/(a*a),r=Math.sqrt(e.x*e.x+e.y*e.y),o=1e-12,s=1e3,c=0,l=Math.atan2(e.z,r),u=0;for(;c++<1e3;){let t=Math.sin(l),o=a/Math.sqrt(1-n*t*t);u=r/Math.cos(l)-o;let s=Math.atan2(e.z/(o*(1-n)+u),r/(o+u));if(isNaN(s)||Math.abs(s-l)<1e-12)break;l=s}return e.set(l,Math.atan2(e.y,e.x),u)}function llaToEcef(e){let{x:t,y:n,z:r}=e,o=a-a/invF,s=(a*a-o*o)/(a*a),c=Math.sin(t),l=Math.cos(t),u=Math.sin(n),d=Math.cos(n),f=a/Math.sqrt(1-s*c*c),p=(f+r)*l*d,m=(f+r)*l*u,h=(o*o/(a*a)*f+r)*c;return e.set(p,m,h)}function getEcefToEnuMatrix(e,t){let{x:n,y:r,z:o}=ecefToLla(scratchVector3$7.copy(e)),s=Math.sin(n),c=Math.sin(r),l=Math.cos(n),u=Math.cos(r);t.fromArray([-c,-s*u,l*u,0,+u,-s*c,l*c,0,0,l,s,0,0,0,0,1]);let d=scratchMatrix3.setFromMatrix4(t),f=scratchVector3$7.copy(e).applyMatrix3(d).multiplyScalar(-1);t.setPosition(f);let p=scratchMatrix4$3.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,o,1]);return t.premultiply(p),t}var ROTATE_X_90_MATRIX=new three.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),ROTATE_X_90_MATRIX_INVERSE=new three.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),enuToLocalMatrix=new three.Matrix4().copy(ROTATE_X_90_MATRIX),localToEnuMatrix=new three.Matrix4().copy(ROTATE_X_90_MATRIX_INVERSE);function getRecommendTile3dProps(e,t={}){var n,r,o;let s,c,l;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){l=4,t.powerPreference===`high`&&(l=2),s=l/1.6;let u=0;if(((n=e.tileset.rootMeta.taskParameters)==null?void 0:n.point_homogenization)===`1`&&(r=e.tileset.rootMeta.taskParameters)!=null&&r.homo_point_density){let t=Number((o=e.tileset.rootMeta.taskParameters)==null?void 0:o.homo_point_density);isFinite(t)&&!isNaN(t)&&(u=t)}u<=0&&(u=.02),c=u*1.4}else l=5,t.powerPreference===`high`&&(l=4),s=0,c=.03;else l=6,s=0,c=.03,e.name===`aerophoto`?(l=12,t.powerPreference===`high`&&(l=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(l=5,t.powerPreference===`high`&&(l=4));return{pointScale:c,pointMinPixel:s,maxScreenSpaceError:l}}var scratchVector3$6=new three.Vector3,scratchSphereBoundingVolume=new SphereBoundingVolume,scratchBoxBoundingVolume=new BoxBoundingVolume,parameterVersionMap=new WeakMap,tileVersionMap=new WeakMap,trajectoryVersionMap=new WeakMap,STENCIL_CONSTANT={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},SKIP_BACKFACE_MATERIAL=(()=>{let e=new three.MeshBasicMaterial;return e.side=three.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=STENCIL_CONSTANT.TILE_MASK,e.stencilFunc=three.AlwaysStencilFunc,e.stencilFuncMask=STENCIL_CONSTANT.TILE_MASK,e.stencilZPass=three.ReplaceStencilOp,e.stencilWriteMask=STENCIL_CONSTANT.TILE_MASK,e})(),SKIP_BACKFACE_TRANSPARENT_MATERIAL=(()=>{let e=new three.MeshBasicMaterial;return e.visible=!1,e})(),CLEAR_STENCIL_GEOMETRY=new three.BufferGeometry,CLEAR_STENCIL_MATERIAL=new three.MeshBasicMaterial;function cloneSkipBackfaceObject(e){let t;t=e instanceof three.Mesh?new three.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?SKIP_BACKFACE_TRANSPARENT_MATERIAL:SKIP_BACKFACE_MATERIAL):e.material&&e.material.transparent?SKIP_BACKFACE_TRANSPARENT_MATERIAL:SKIP_BACKFACE_MATERIAL):e instanceof three.Group?new three.Group:new three.Object3D,t.position.copy(e.position),t.quaternion.copy(e.quaternion),t.scale.copy(e.scale),t.matrix.compose(e.position,e.quaternion,e.scale),t.matrixAutoUpdate=!1,t.frustumCulled=e.frustumCulled,t.visible=e.visible;for(let n of e.children)t.add(cloneSkipBackfaceObject(n));return t}var Tile3D=class extends three.Object3D{constructor(e,t){var n,r;super(),this.parameter=new Parameter,this.renderObjects=[],this.backfaceObjects=[],this.tileObjects=[],this.frameNumber=0,this.error=(n=t.error)==null?null:n,this.name=t.name,this.type=t.type,this.upAxis=t.upAxis,this.light=t.light,this.fetcher=t.fetcher,this.search=(r=t.search)==null?``:r,this.groundHeight=t.groundHeight,this.coordinateSystem=t.coordinateSystem,this.boundingBox=new three.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new three.Mesh(CLEAR_STENCIL_GEOMETRY,CLEAR_STENCIL_MATERIAL),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new Tileset(e,{tileLoader:e=>this.loadContent(e),tileUnloader:e=>this.unloadContent(e),onTileLoad:e=>{this.onTileLoad&&this.onTileLoad(e)},onTileUnload:e=>{this.onTileUnload&&this.onTileUnload(e)},onTileError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{tile:e})),console.error(`Tile error`,e.id,t)},trajectoryLoader:e=>this.loadTrajectory(e),trajectoryUnloader:e=>this.unloadTrajectory(e),onTrajectoryLoad:()=>{},onTrajectoryUnload:e=>{},onTrajectoryError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{error:t})),console.error(`Trajectory error`,e,t)}}),this.tileset.root.boundingVolume&&this.tileset.root.boundingVolume.getBoundingBox(this.boundingBox),this.currentResolvedParameterValue=Parameter.resolveValueTo({},this.parameter)}get viewerRequestVolume(){return this.tileset.root.viewerRequestVolume}set viewerRequestVolume(e){this.tileset.root.viewerRequestVolume=e}get tiles(){return this.tileset.selectedTiles}get trajectories(){return this.tileset.trajectories}getRecommendProps(e={}){return getRecommendTile3dProps(this,e)}loadContent(e){return loadTileContent(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)unloadTileContent(e);else if(e.content.data)if(e.content.data.type===`spz`){let t=e.content.data.object.children[0].boundingBox;this.boundingBox.union(t)}else this.boundingBox.expandByObject(e.content.data.object)}})}unloadContent(e){return unloadTileContent(e),Promise.resolve()}loadAllTilesets(){let e=t=>{let n=[];return this.tileset.root.traverse(e=>{var t;e.type===`TILESET`&&((t=e.content)==null?void 0:t.loadState)!==`READY`&&n.push(e)}),Promise.all(n.map(t=>this.loadContent(t).then(()=>e(t)))).then(()=>{})};return e(this.tileset.root)}loadTrajectory(e){return loadTrajectory(e,{fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(e=>{this.disposed&&unloadTrajectory(e)})}unloadTrajectory(e){return unloadTrajectory(e),Promise.resolve()}intersectRaycaster(e,t){var n,r;let o=t==null?[]:t,s=[this.tileset.root],c=this.tileset.transform,l=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,u=e.sortByDistance;e.sortByDistance=!1;let d,f=1/0;for(;d=s.pop();){let t;if(d.boundingVolume){let n;n=d.boundingVolume instanceof BoxBoundingVolume?scratchBoxBoundingVolume.copy(d.boundingVolume):d.boundingVolume instanceof SphereBoundingVolume?scratchSphereBoundingVolume.copy(d.boundingVolume):d.boundingVolume.clone(),n.applyMatrix4(c),t=n.intersectRay(e.ray,l,f)}else t=!0;if(t){for(let e=0,t=d.children.length;e<t;e++)s.push(d.children[e]);if(d.selected&&d.content&&d.content.data&&d.content.data.object.visible){let t=e.hitFilter;if(e.hitFilter=n=>{var r;return Object.assign(n,{model:(r=this.parent)==null?void 0:r,viewLayer:this,tile:d}),t?t.call(e,n):!0},d.content.data.object.intersectRaycaster(e,o),e.hitFilter=t,e.firstHitOnly){let e=o[0];e&&f>e.distance&&(f=e.distance)}}}}return e.sortByDistance=u,sortIntersects(o,e.sortByDistance,e.firstHitOnly),o}update(e,t,n,r){var o,s,c,l,u,d,f;this.renderer=e,this.frameNumber++;let p=!1,m=Parameter.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);parameterVersionMap.get(this)!==m.versionNumber&&(parameterVersionMap.set(this,m.versionNumber),p=!0);let h=(l=this.visible&&((o=this.parent)==null?void 0:o.visible)&&((c=(s=this.parent)==null?void 0:s.parent)==null?void 0:c.visible))==null?!1:l,g=m.maxLevelOfDetail;g=Math.max(g,0);let _=Math.min(m.minLevelOfDetail,g);(!h||!this.loaded||!n.loaded)&&(g=Math.max(_,0));let v=m.maxMemoryUsage;h||(v=Math.min(0,v));let y=m.minGeometricError,b=m.maxRequests,S=m.memoryAdjustedScreenSpaceError;h||(S=!1);let C=t.controllerMode;(C===`Panorama`||C===`VRPanorama`||C===`XRPanorama`)&&(m.modelAlpha<.1&&(y=m.panoramaMinGeometricError,S=!1),m.progress>=.01&&m.progress<=.99&&(b=0));let w=m.maxGeometricError;w=Math.max(y,w);let T={time:t.time,camera:{type:t.type,position:new three.Vector3().copy(t.position),direction:t.getDirection(new three.Vector3),up:new three.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:h&&t.visible,refine:t.refineModel},height:t.resolution.height,pixelRatio:t.pixelRatio,frameNumber:this.frameNumber,sseDenominator:2*Math.tan(.5*t.fov/180*Math.PI),cullingVolume:new CullingVolume().setFromCamera(t),minLevelOfDetail:_,maxLevelOfDetail:g,minGeometricError:y,maxGeometricError:w,skipLevelOfDetail:m.skipLevelOfDetail,mostDetail:m.mostDetail,loadSiblings:m.loadSiblings,cameraCulling:m.cameraCulling,maxMemoryUsage:v,maxRequests:b,requestOrder:m.requestOrder,maxScreenSpaceError:m.maxScreenSpaceError,memoryAdjustedScreenSpaceError:S},E=m.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},T),{camera:{type:t.type,position:new three.Vector3().copy(e.position),direction:e.getWorldDirection(new three.Vector3),up:new three.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new CullingVolume().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),p=!0);let D=!this.autoRefine;if(D===!1&&m.progress>=.01&&m.progress<=.99){let e=new three.Vector3;m.pano0&&e.setFromMatrixPosition(m.pano0.matrix);let t=e.clone();m.pano1&&t.setFromMatrixPosition(m.pano1.matrix),e.distanceTo(t)<10&&(D=!0)}if(D||this.tileset.update(T,E),this.refined=!0,this.refineProgress[0]=0,this.refineProgress[1]=0,this.tileset.needsRefinedTiles.forEach(e=>{if(this.refineProgress[1]++,e.content){let t=e.content.loadState;if(t===`UNLOADED`||t===`LOADING`){this.refined=!1;return}}this.refineProgress[0]++}),this.loaded===!1&&this.autoRefine){this.loaded=!0;let e=!1;this.tileset.needsRefinedTiles.forEach(t=>{if(this.loaded!==!1&&t.content&&(t.state.visible&&(e=!0),m.minLevelOfDetail>=0)){if(T.skipLevelOfDetail){if(t.state.finalResolution){let e=t.state.ancestorWithContentAvailable,n=(e&&e.content?e.content:t.content).loadState;(n===`UNLOADED`||n===`LOADING`)&&(this.loaded=!1)}}else if(t.state.visible&&t.levelOfContent<=0){let e=t.content.loadState;(e===`UNLOADED`||e===`LOADING`)&&(this.loaded=!1)}}}),e&&this.tileset.selectedTiles.length===0&&this.tileset.frameNumber<500&&(this.loaded=!1),this.loaded===!0&&(this.refined=!1,this.refineProgress[1]++)}this.renderObjects.length=0,this.backfaceObjects.length=0,this.tileObjects.length=0;for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);T.skipLevelOfDetail||this.tileset.selectedTiles.sort((e,t)=>e.floor===t.floor?e.levelOfContent===t.levelOfContent?e.state.distanceToCamera===t.state.distanceToCamera?e.state.centerZDepth-t.state.centerZDepth:e.state.distanceToCamera-t.state.distanceToCamera:t.levelOfContent-e.levelOfContent:e.floor-t.floor);let O=[];for(let r of this.tileset.selectedTiles){let o=(d=(u=r.content)==null?void 0:u.data)==null?void 0:d.object;if(!o)continue;let s=o.update(e,t,n,this,r,m);if(O.push(r.id),s&&(p=!0),this.tileset.hasMixedContent&&T.skipLevelOfDetail){if(!r.state.finalResolution){let e=cloneSkipBackfaceObject(o);e.name=`skipBackface:`+o.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=STENCIL_CONSTANT.TILE_MASK|e<<STENCIL_CONSTANT.SKIP_LOD_BIT_SHIFT,n=three.GreaterEqualStencilFunc,s=STENCIL_CONSTANT.SKIP_LOD_MASK,c=three.ReplaceStencilOp,l=STENCIL_CONSTANT.TILE_MASK|STENCIL_CONSTANT.SKIP_LOD_MASK;for(let e of o.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=s,e.stencilZPass=c,e.stencilWriteMask=l}else for(let e of o.materials)e.stencilWrite=!1,e.stencilRef=STENCIL_CONSTANT.TILE_MASK,e.stencilFunc=three.AlwaysStencilFunc,e.stencilFuncMask=STENCIL_CONSTANT.TILE_MASK,e.stencilZPass=three.ReplaceStencilOp,e.stencilWriteMask=STENCIL_CONSTANT.TILE_MASK;this.tileObjects.push(o)}let k=O.toString();if(tileVersionMap.get(this)!==k&&(tileVersionMap.set(this,k),p=!0),T.skipLevelOfDetail&&this.backfaceObjects.length)for(let e=0;e<this.backfaceObjects.length;e++)this.renderObjects.push(this.backfaceObjects[e]);if(this.tileObjects.length)for(let e=0;e<this.tileObjects.length;e++)this.renderObjects.push(this.tileObjects[e]);T.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let A=[];for(let r of this.tileset.selectedTrajectories){let o=(f=r.content.data)==null?void 0:f.object;if(!o)continue;let s=o.update(e,t,n,this,r,m);A.push(r.id),s&&(p=!0),this.renderObjects.push(o)}let j=A.toString();if(trajectoryVersionMap.get(this)!==j&&(trajectoryVersionMap.set(this,j),p=!0),this.parent){let e=this.parent.children.length+1,t=(Math.min(0,this.parent.children.indexOf(this))-e)*1e4+1;for(let e=0;e<this.renderObjects.length;e++){let n=this.renderObjects[e],r=e+t;n.traverse(e=>{(e instanceof three.Mesh||e instanceof three.Line||e instanceof three.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return p}dispose(){this.disposed=!0,this.tileset.reset(),this.tileset.root.children.length=0,/^blob\:/.test(this.tileset.id)&&URL.revokeObjectURL(this.tileset.id);for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);this.refined=!1,this.loaded=!1,this.refineProgress[0]=this.refineProgress[1]=0,this.error=null,this.onError=void 0,this.renderer=void 0}get model(){return this.parent}get scene(){return this}get viewLayer(){return this}localToEnu(e){return e.applyMatrix4(localToEnuMatrix)}enuToLocal(e){return e.applyMatrix4(enuToLocalMatrix)}enuToEcef(e){return e.applyMatrix4(this.coordinateSystem.enuToEcefMatrix)}ecefToEnu(e){return e.applyMatrix4(this.coordinateSystem.ecefToEnuMatrix)}localToEcef(e){return this.enuToEcef(this.localToEnu(e))}ecefToLocal(e){return this.enuToLocal(this.ecefToEnu(e))}localToLla(e){return ecefToLla(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(llaToEcef(e)))}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}worldToEcef(e){return this.localToEcef(this.worldToLocal(e))}ecefToWorld(e){return this.localToWorld(this.ecefToLocal(e))}worldToLla(e){return this.localToLla(this.worldToLocal(e))}llaToWorld(e){return this.localToWorld(this.llaToLocal(e))}get coordinates(){scratchVector3$6.setScalar(0);let{x:e,y:t}=this.localToLla(scratchVector3$6);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new three.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(enuToLocalMatrix),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new three.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return scratchVector3$6.copy(e),this.worldToLla(scratchVector3$6),{latitude:scratchVector3$6.x,longitude:scratchVector3$6.y,altitude:scratchVector3$6.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minLevelOfDetail`,...e)}set minLevelOfDetail(e){this.parameter.set(`minLevelOfDetail`,e)}get maxLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxLevelOfDetail`,...e)}set maxLevelOfDetail(e){this.parameter.set(`maxLevelOfDetail`,e)}get minGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minGeometricError`,...e)}set minGeometricError(e){this.parameter.set(`minGeometricError`,e)}get maxGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxGeometricError`,...e)}set maxGeometricError(e){this.parameter.set(`maxGeometricError`,e)}get panoramaMinGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`panoramaMinGeometricError`,...e)}set panoramaMinGeometricError(e){this.parameter.set(`panoramaMinGeometricError`,e)}get skipLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`skipLevelOfDetail`,...e)}set skipLevelOfDetail(e){this.parameter.set(`skipLevelOfDetail`,e)}get mostDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`mostDetail`,...e)}set mostDetail(e){this.parameter.set(`mostDetail`,e)}get loadSiblings(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`loadSiblings`,...e)}set loadSiblings(e){this.parameter.set(`loadSiblings`,e)}get maxMemoryUsage(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxMemoryUsage`,...e)}set maxMemoryUsage(e){this.parameter.set(`maxMemoryUsage`,e)}get maxRequests(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxRequests`,...e)}set maxRequests(e){this.parameter.set(`maxRequests`,e)}get requestOrder(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`requestOrder`,...e)}set requestOrder(e){this.parameter.set(`requestOrder`,e)}get maxScreenSpaceError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},fetchers={};function getFetcher(e,t){let n=fetchers[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function registerFetcher(e,t,n){let r=fetchers[e];r||(r=fetchers[e]=new WeakMap),r.has(t)||r.set(t,n)}var identityMatrix4=new three.Matrix4,scratchVector3$5=new three.Vector3,scratchMatrix4$2=new three.Matrix4;function getEcefToEnuMatrixFromUpAxis(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:getEcefToEnuMatrix(t,n);break;default:n.identity();break}return n}function loadViewLayer(e){var t;let[n,r]=e.tilesetUrl.split(`#`),o=(t=(r||n).split(`?`)[1])==null?``:t;return e.fetcher.ajax(e.tilesetUrl,{responseType:`text`}).catch(e=>({error:e,body:JSON.stringify({asset:{version:`0.0`},geometricError:0,root:{geometricError:0}})})).then(t=>{var n;let r=`error`in t?t.error:null,s=normalizeTilesetHeader(JSON.parse(t.body),e.tilesetUrl),{root:c,rootMeta:l={}}=s,u=e.upAxis;l.upAxis&&l.upAxis!==u&&(u=l.upAxis),`lodVersion`in s&&(u=`-Y`,`floorInfo`in s&&(s.properties=s.properties||{},s.properties.floorInfo=s.floorInfo.map(e=>({ground:-e.ground,height:e.height})),s.floorInfo=void 0),s.asset.tilesetVersion=String(s.lodVersion),s.lodVersion=void 0);let d=u,f=new three.Matrix4;d===`Y`?(d=`Z`,f.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):d===`-Y`&&(d=`Z`,f.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let p=c.boundingVolume?makeBoundingVolume(c.boundingVolume):void 0;p&&c.transform&&p.applyMatrix4(scratchMatrix4$2.fromArray(c.transform));let m=null,h=new three.Matrix4,g=new three.Matrix4;return l.coordinate?(m=l.coordinate.ground_height,h.fromArray(l.coordinate.pose_ecef_to_enu),g.fromArray(l.coordinate.pose_enu_to_ecef)):(p?p.getCenter(scratchVector3$5):scratchVector3$5.setScalar(0),scratchVector3$5.applyMatrix4(f),getEcefToEnuMatrixFromUpAxis(d,scratchVector3$5,h),g.getInverse(h)),s.root={refine:(n=c.refine)==null?`REPLACE`:n,geometricError:c.geometricError,transform:scratchMatrix4$2.copy(f).premultiply(d===`Z`?identityMatrix4:h).premultiply(enuToLocalMatrix).toArray(),boundingVolume:p?p.toJson():void 0,children:[c]},new Tile3D(s,{name:e.name,type:e.type,upAxis:u,light:e.light,fetcher:e.fetcher,search:o,groundHeight:m,coordinateSystem:{enuToEcefMatrix:g,ecefToEnuMatrix:h},error:r})})}function loadViewLayers(e,t){var n;let r=e.layers.map(e=>({tilesetUrl:e.work.getURL(e.tileset),name:e.name,type:e.type,upAxis:e.upAxis,light:t.light,fetcher:t.fetcher}));if(e.file){let o=!1;for(let e of r)if(e.type===`mesh`){o=!0;break}if(o===!1){let o=getExtname(e.file)||`.at3d`,s=JSON.stringify({tilesetUrl:``,asset:{version:`0.0`},geometricError:0,root:{refine:`REPLACE`,geometricError:0,transform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],content:{uri:e.work.getURL(e.file)},extras:{[o.slice(1)]:{upAxis:e.upAxis,textureBaseUri:typeof e.textureBase==`string`?e.work.getURL(e.textureBase):void 0,textureArray:e.textures,textureOptions:(n=t.textureOptions)==null?{}:n}}},rootMeta:{coordinate:e.coordinate}});r.push({name:`fallback`,type:`mesh`,upAxis:`Z`,tilesetUrl:URL.createObjectURL(new Blob([s],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let o=r.map(e=>loadViewLayer(e).then(e=>e));return Promise.all(o)}function createSimpleBoxBufferGeometry(e=1,t=1,n=1){let r=e/2,o=t/2,s=n/2,c=new Float32Array([-r,+o,+s,+r,+o,+s,+r,+o,-s,-r,+o,-s,-r,-o,+s,+r,-o,+s,+r,-o,-s,-r,-o,-s]),l=new Uint32Array([0,4,1,1,4,5,1,5,2,2,5,6,2,6,3,3,6,7,3,7,0,0,7,4,3,0,2,2,0,1,4,7,5,5,7,6]),u=new three.BufferGeometry;return u.setAttribute(`position`,new three.BufferAttribute(c,3)),u.setIndex(new three.BufferAttribute(l,1)),u.addGroup(0,u.index.count,0),u.computeBoundingBox(),u.computeBoundingSphere(),u}function mergeBufferGeometries(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),o=new Set(Object.keys(e[0].morphAttributes)),s={},c={},l=new three.BufferGeometry,u=0,d=0;d<e.length;++d){var f=e[d];if(n!==(f.index!==null))return null;for(var p in f.attributes){if(!r.has(p))return null;s[p]===void 0&&(s[p]=[]),s[p].push(f.attributes[p])}for(var p in f.morphAttributes){if(!o.has(p))return null;c[p]===void 0&&(c[p]=[]),c[p].push(f.morphAttributes[p])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(f.userData),t){var m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return null;l.addGroup(u,m,d),u+=m}}if(n){for(var h=0,g=[],d=0;d<e.length;++d){for(var _=e[d].index,v=0;v<_.count;++v)g.push(_.getX(v)+h);h+=e[d].attributes.position.count}l.setIndex(g)}for(var p in s){var y=mergeBufferAttributes(s[p]);if(!y)return null;l.setAttribute(p,y)}for(var p in c){var b=c[p][0].length;if(b===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[p]=[];for(var d=0;d<b;++d){for(var S=[],v=0;v<c[p].length;++v)S.push(c[p][v][d]);var C=mergeBufferAttributes(S);if(!C)return null;l.morphAttributes[p].push(C)}}return l}function mergeBufferAttributes(e){for(var t,n,r,o=0,s=0;s<e.length;++s){var c=e[s];if(c.isInterleavedBufferAttribute||(t===void 0&&(t=c.array.constructor),t!==c.array.constructor)||(n===void 0&&(n=c.itemSize),n!==c.itemSize)||(r===void 0&&(r=c.normalized),r!==c.normalized))return null;o+=c.array.length}for(var l=new t(o),u=0,s=0;s<e.length;++s)l.set(e[s].array,u),u+=e[s].array.length;return new three.BufferAttribute(l,n,r)}function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),o=e.getAttribute(`position`),s=r?r.count:o.count,c=0,l=Object.keys(e.attributes),u={},d={},f=[],p=[`getX`,`getY`,`getZ`,`getW`],m=0,h=l.length;m<h;m++){var g=l[m];u[g]=[];var _=e.morphAttributes[g];_&&(d[g]=Array(_.length).fill().map(()=>[]))}for(var v=Math.log10(1/t),y=Math.pow(10,v),m=0;m<s;m++){for(var b=r?r.getX(m):m,S=``,C=0,h=l.length;C<h;C++)for(var g=l[C],w=e.getAttribute(g),T=w.itemSize,E=0;E<T;E++)S+=`${~~(w[p[E]](b)*y)},`;if(S in n)f.push(n[S]);else{for(var C=0,h=l.length;C<h;C++)for(var g=l[C],w=e.getAttribute(g),_=e.morphAttributes[g],T=w.itemSize,D=u[g],O=d[g],E=0;E<T;E++){var k=p[E];if(D.push(w[k](b)),_)for(var A=0,j=_.length;A<j;A++)O[A].push(_[A][k](b))}n[S]=c,f.push(c),c++}}let M=e.clone();for(var m=0,h=l.length;m<h;m++){var g=l[m],N=e.getAttribute(g),P=new N.array.constructor(u[g]),w=new three.BufferAttribute(P,N.itemSize,N.normalized);if(M.setAttribute(g,w),g in d)for(var C=0;C<d[g].length;C++){var F=e.morphAttributes[g][C],P=new F.array.constructor(d[g][C]),I=new three.BufferAttribute(P,F.itemSize,F.normalized);M.morphAttributes[g][C]=I}}return M.setIndex(f),M}var scratchSphere$1=new three.Sphere,scratchMatrix4$1=new three.Matrix4,scratchMatrix4Inverse=new three.Matrix4;function getEdgesBySphere(e,t,n=30/180*Math.PI){let r=Math.cos(n),o=[];for(let n of e.children)n instanceof Tile3D&&n.tileset.selectedTiles.forEach(e=>{var n,s,c;let l=(s=(n=e.content)==null?void 0:n.data)==null?void 0:s.object;if(l&&l.visible){let e=[];if(l.traverseVisible(n=>{if(n instanceof three.Mesh){let r=getBvhTreeForMesh(n);if(r){scratchMatrix4$1.copy(n.matrixWorld),scratchMatrix4Inverse.getInverse(scratchMatrix4$1),scratchSphere$1.copy(t).applyMatrix4(scratchMatrix4Inverse);let o=r.trianglesInSphere(scratchSphere$1.center,scratchSphere$1.radius),s=new three.BufferGeometry;s.setAttribute(`position`,new three.BufferAttribute(o,3)),s.applyMatrix4(n.matrixWorld),s=mergeVertices(s,.01),e.push(s)}}}),e.length===0)return;let n=[`a`,`b`,`c`],s=mergeBufferGeometries(e,!1),u=s.getAttribute(`position`).array,d=((c=s.getIndex())==null?void 0:c.array)||[],f=[],p=[];for(let e=0,t=u.length;e<t;e+=3){let t=new three.Vector3(u[e],u[e+1],u[e+2]);f.push(t)}for(let e=0,t=d.length;e<t;e+=3){let t=d[e],n=d[e+1],r=d[e+2],o=new three.Vector3().crossVectors(f[n].clone().sub(f[t]),f[r].clone().sub(f[t])).normalize();p.push({a:t,b:n,c:r,normal:o})}let m={};for(let e=0,t=p.length;e<t;e++){let t=p[e];for(let r=0;r<3;r++){let o=t[n[r]],s=t[n[(r+1)%3]],c=[Math.min(o,s),Math.max(o,s)],l=c[0]+`-`+c[1];m[l]===void 0?m[l]={index1:c[0],index2:c[1],face1:e}:m[l].face2=e}}for(let e in m){let t=m[e];if(t.face2===void 0||p[t.face1].normal.dot(p[t.face2].normal)<=r){let e=f[t.index1],n=f[t.index2];o.push(new three.Line3(e,n))}}f.length=0,p.length=0}});return o}var scratchBoundingBox$1=new three.Box3,scratchViewLayerBox=new three.Box3,scratchObserverBox$3=new three.Box3,Model=class extends three.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new Parameter,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new three.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let o=0;for(let e of t.observers)o=Math.max(o,e.floorIndex);if(this.floorLength=o+1,t.model){this.metaPending=!0;let e=loadViewLayers(t.model,{fetcher:getFetcher(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),o=e=>this.dispatchEvent({type:`error`,error:e}),s=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),c=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,l=null;for(let t of e){if(t.visible=!1,t.onError=o,t.onTileLoad=s,t.onTileUnload=c,t.error){o(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):l===null&&(l=t)}let u=(t=n==null?r:n)==null?l:t;if(u&&(u.visible=!0),e.length)if(this.disposed)for(let t of e)t.dispose();else this.add(...e);return this}),this.loadedReady=new Promise(e=>{let t=()=>{e(this),this.removeEventListener(`load`,t),this.removeEventListener(`dispose`,t)};this.addEventListener(`load`,t),this.addEventListener(`dispose`,t)})}else this.refined=!0,this.loaded=!0,this.initReady=Promise.resolve(this),this.loadedReady=Promise.resolve(this);this.parameter.set(`boundingBox`,this.boundingBox.clone())}dispose(){this.disposed=!0;let e;for(;e=this.children[0];)typeof e.dispose==`function`&&e.dispose(),e.onError=void 0,e.onTileLoad=void 0,e.onTileUnload=void 0,this.remove(e);this.dispatchEvent({type:`dispose`})}get empty(){return this.children.length===0}get viewLayers(){return this.children}getEdgesBySphere(e,t=30/180*Math.PI){return getEdgesBySphere(this,e,t)}intersectRaycaster(e,t){let n=t==null?[]:t,r=e.sortByDistance;e.sortByDistance=!1;for(let t=0,r=this.children.length;t<r;t++){let r=this.children[t];r.visible&&typeof r.intersectRaycaster==`function`&&r.intersectRaycaster(e,n)}return e.sortByDistance=r,sortIntersects(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let o=this.loaded;this.refined=!this.metaPending,this.loaded=!this.metaPending,this.refineProgress[0]=this.refineProgress[1]=0,this.work.transform.equals(this.matrix)||(this.matrix.copy(this.work.transform),this.matrix.decompose(this.position,this.quaternion,this.scale),this.matrixAutoUpdate=!1,r=!0);for(let o of this.children)o.autoRefine=this.autoRefine,o.update(e,t,n,this)&&(r=!0),o.refined===!1&&(this.refined=!1),o.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=o.refineProgress[0],this.refineProgress[1]+=o.refineProgress[1];scratchBoundingBox$1.makeEmpty(),scratchObserverBox$3.copy(this.work.observerBox),scratchObserverBox$3.isEmpty()||(scratchObserverBox$3.max.x+=1,scratchObserverBox$3.max.z+=1,scratchObserverBox$3.max.y+=1,--scratchObserverBox$3.min.x,--scratchObserverBox$3.min.z,scratchBoundingBox$1.union(scratchObserverBox$3));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(scratchViewLayerBox.copy(e.boundingBox),scratchBoundingBox$1.union(scratchViewLayerBox));return scratchBoundingBox$1.applyMatrix4(this.matrix),scratchBoundingBox$1.equals(this.boundingBox)||(this.boundingBox.copy(scratchBoundingBox$1),this.parameter.set(`boundingBox`,scratchBoundingBox$1.clone())),o===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(localToEnuMatrix)}enuToLocal(e){return e.applyMatrix4(enuToLocalMatrix)}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}get shownFloor(){return this.shownFloorIndex===-1?null:this.shownFloorIndex}set shownFloor(e){this.shownFloorIndex=e===null?-1:e}show(e){this.shownFloor=e==null?null:e,this.dispatchEvent({type:`changeShownFloor`,floorIndex:e==null?null:e})}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`shownFloorIndex`,...e)}set shownFloorIndex(e){this.parameter.set(`shownFloorIndex`,e)}get brightness(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`brightness`,...e)}set brightness(e){this.parameter.set(`brightness`,e)}get clippers(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`clippers`,...e)}set clippers(e){this.parameter.set(`clippers`,e)}get customShaders(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`customShaders`,...e)}set customShaders(e){this.parameter.set(`customShaders`,e)}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.viewLayers)e.resetBrightness()}},scratchGeometry=createSimpleBoxBufferGeometry(1,1,1);scratchGeometry.applyMatrix4(new three.Matrix4().makeScale(-1,1,1));var parameterValueVersionMap=new WeakMap,cameraBoxSize=new three.Vector3(1,1,1),scratchBoundingBox=new three.Box3,scratchBoundingBoxSize=new three.Vector3,scratchCameraBox=new three.Box3,scratchPosition=new three.Vector3,scratchScale=new three.Vector3,BoundingMesh=class extends PBMMesh{constructor(e={}){var t;let n=new PBMMeshMaterial(`none`);n.flatShading=!0,n.depthWrite=!1,n.transparent=!1,n.blending=three.CustomBlending,n.blendSrc=three.SrcAlphaFactor,n.blendDst=three.OneMinusSrcAlphaFactor,n.blendSrcAlpha=three.OneFactor,n.blendDstAlpha=three.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(scratchGeometry,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999,this.currentResolvedParameterValue=Parameter.resolveValueTo({})}update(e,t,n){var r,o;let s=!1,c=Parameter.resolveValueTo(this.currentResolvedParameterValue,n.parameter);scratchBoundingBox.copy(c.boundingBox),scratchBoundingBox.getSize(scratchBoundingBoxSize);let l=Math.min(scratchBoundingBoxSize.x/2,500);scratchBoundingBox.min.x-=l,scratchBoundingBox.max.x+=l;let u=Math.min(scratchBoundingBoxSize.y/2,500);scratchBoundingBox.min.z-=u,scratchBoundingBox.max.z+=u;let d=scratchBoundingBoxSize.length()/2;if(scratchBoundingBox.max.y=Math.max(scratchBoundingBox.max.y,d),scratchBoundingBox.union(scratchCameraBox.setFromCenterAndSize(t.position,cameraBoxSize)),scratchBoundingBox.expandByScalar(1),scratchBoundingBox.getCenter(scratchPosition),scratchBoundingBox.getSize(scratchScale),scratchPosition.equals(this.position)||(this.position.copy(scratchPosition),s=!0),scratchScale.equals(this.scale)||(this.scale.copy(scratchScale),s=!0),parameterValueVersionMap.get(this)!==c.versionNumber){parameterValueVersionMap.set(this,c.versionNumber),s=!0;let e=this.material;for(let t of e)t.customShaders=c.customShaders,t.pano0=c.pano0,t.pano1=c.pano1,t.panoFilter=(o=(r=c.panoFilter)==null?void 0:r.toValue())==null?null:o,t.refinedScreen=c.refinedScreen,t.modelAlpha=c.modelAlpha,t.progress=c.progress,t.transition=c.transition,t.opacity=c.opacity,t.floorStyle=c.floorStyle,t.constantColor=c.constantColor,t.shownFloorIndex=c.shownFloorIndex,t.clippers=c.clippers,t.brightness=c.brightness,t.useHQWeight=c.useHQWeight,t.useHQDepth=c.useHQDepth,t.colorSaturation=c.colorSaturation,t.colorBrightness=c.colorBrightness,t.gradientTexture=c.gradientTexture,t.transparent=!1,t.modelBoundingMax.copy(c.boundingBox.max),t.modelBoundingMin.copy(c.boundingBox.min),c.useAddBlend&&(t.opacity=0),t.opacity===0&&(t.visible=!1)}return s}dispose(){for(let e of this.material)e.dispose(),e.pano0=null,e.pano1=null}},scratchBoundingBox3=new three.Box3,ModelScene=class extends three.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new three.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new Parameter,this.fiveId=e.fiveId,this.boundingMesh=new BoundingMesh({name:`bounding`}),this.add(this.boundingMesh);let t=this.models=[];this.shownModels=[],this.updateModelMap=new Map,this.parameter.set(`boundingBox`,this.boundingBox.clone());let n=this;defineProperty(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),defineProperty(t,`bounding`,{get(){return n.boundingBox}}),defineProperty(t,`loaded`,{get(){return n.loaded}}),defineProperty(t,`refined`,{get(){return n.refined}}),defineProperty(t,`refineProgress`,{get(){return n.refineProgress}}),defineProperty(t,`cacheCameras`,{get(){return n.parameter.resolveValue(`cacheCameras`)},set(e){n.parameter.set(`cacheCameras`,e)}}),defineProperty(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),defineProperty(t,`setMaterial`,{value:e=>n.setMaterial(e)}),defineProperty(t,`getMaterial`,{value:()=>n.getMaterial()}),defineProperty(t,`resetBrightness`,{value:()=>n.resetBrightness()})}setModels(e,t){let n=e.map(e=>{let n=this.shownModels.filter(t=>t.work.workCode===e.workCode)[0];if(n||(n=this.models.filter(t=>t.work.workCode===e.workCode)[0],n))return n.work=e,n;n=new Model(this.fiveId,e,{light:t.light,textureOptions:t.textureOptions});let r=t[`3d-tiles`];return n.initReady.then(()=>{if(r)if(typeof r==`function`)for(let e of n.viewLayers){let t=r(e,n);t&&(t.viewerRequestVolume&&(e.viewerRequestVolume=makeBoundingVolume(t.viewerRequestVolume)),e.parameter.set(omit(t,[`showLayers`])),t.showLayers===!1?e.visible=!1:Array.isArray(t.showLayers)&&(e.visible=t.showLayers.includes(e.name)))}else for(let e of n.viewLayers)r.viewerRequestVolume&&(e.viewerRequestVolume=makeBoundingVolume(r.viewerRequestVolume)),e.parameter.set(omit(r,[`showLayers`])),r.showLayers===!1?e.visible=!1:Array.isArray(r.showLayers)&&(e.visible=r.showLayers.includes(e.name))}),this.dispatchEvent({type:`model.create`,model:n}),n});for(let e=0;e<this.models.length;e++){let t=this.models[e];n.indexOf(t)===-1&&this.shownModels.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.models.length=0;for(let e=0;e<n.length;e++){let t=n[e];this.models.push(t)}if(t.forceReplaceImmediately&&!arrayEqual(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e])}return this.loaded=!1,this.refined=!1,this.models}get empty(){return this.boundingBox.isEmpty()}intersectRaycaster(e,t){let n=t==null?[]:t,r=this.shownModels.filter(e=>e.visible);if(r.length===1)r[0].intersectRaycaster(e,n);else{let t=e.sortByDistance;e.sortByDistance=!1;for(let t of r)t.intersectRaycaster(e,n);e.sortByDistance=t,sortIntersects(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;scratchBoundingBox3.makeEmpty(),this.loaded=this.models.length>0,this.refined=this.models.length>0,this.refineProgress[0]=this.refineProgress[1]=0,this.updateModelMap.clear();for(let n=0;n<this.models.length;n++){let r=this.models[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;this.autoRefine===!1&&(r.autoRefine=!1);let o=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,o)}r.loaded===!1&&(this.loaded=!1),r.refined===!1&&(this.refined=!1),this.refineProgress[0]+=r.refineProgress[0],this.refineProgress[1]+=r.refineProgress[1]}if((this.loaded===!0||this.models.length===0)&&!arrayEqual(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e]);n=!0}for(let n=0;n<this.shownModels.length;n++){let r=this.shownModels[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;(this.autoRefine===!1||this.models.indexOf(r)<0)&&(r.autoRefine=!1);let o=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,o)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Model&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),scratchBoundingBox3.union(t.boundingBox),this.add(t)}for(let e=0;e<this.models.length;e++){let t=this.models[e];this.shownModels.indexOf(t)===-1&&scratchBoundingBox3.union(t.boundingBox)}return scratchBoundingBox3.equals(this.boundingBox)||(this.boundingBox.copy(scratchBoundingBox3),this.parameter.set(`boundingBox`,this.boundingBox.clone()),n=!0),this.boundingMesh.update(e,t,this)&&(n=!0),this.updateModelMap.clear(),this.needsRender=n,n}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){return this.parameter.resolveValue()}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.models)e.resetBrightness()}dispose(){this.remove(this.boundingMesh),this.boundingMesh.dispose();for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Model&&this.remove(t)}let e=arrayUnique(this.models.concat(this.shownModels));for(let t=0;t<this.shownModels.length;t++)e[t].dispose();this.models.length=0,this.shownModels.length=0,super.dispose()}};function workInitialToJson(e){let t={};return e.mode!==void 0&&(t.mode=e.mode),e.panoIndex!==void 0&&(t.pano_index=e.panoIndex),e.longitude!==void 0&&(t.longitude=e.longitude),e.latitude!==void 0&&(t.latitude=e.latitude),e.fov!==void 0&&(t.fov=e.fov),e.distance!==void 0&&(t.distance=e.distance),e.offset!==void 0&&(t.offset=e.offset.toArray()),t}function workModelToJson(e){var t;if(e)return{file_url:e.file,material_base_url:e.textureBase,material_textures:(t=e.textures)==null?void 0:t.slice(),up_axis:e.upAxis,layers:e.layers.map(e=>({tileset_url:e.tileset,up_axis:e.upAxis,name:e.name,type:e.type}))}}function workObserverToObserverJson(e){return{index:e.index,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,floor_index:e.floorIndex,position:e.position.toArray(),standing_position:e.standingPosition.toArray(),quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w},visible_nodes:e.accessibleNodes.slice(),accessible_nodes:e.accessibleNodes.slice()}}function workObserverToPanoramaJson(e){return{index:e.index,active:e.active,loadable:e.loadable,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,size_list:e.images.sizeList.slice(),up:e.images.up,down:e.images.down,right:e.images.right,left:e.images.left,front:e.images.front,back:e.images.back,video:e.images.video?{matrix:e.images.video.matrix.toArray(),size:e.images.video.size.toArray(),source:e.images.video.source}:void 0}}function workToJson(e){return{allow_hosts:e.allowHosts.slice(),expire_at:e.expire.getTime().toString(),project_id:e.projectId,code:e.workCode,name:e.name,base_url:e.baseURL,initial:workInitialToJson(e.initial),model:workModelToJson(e.model),observers:e.observers.map(e=>workObserverToObserverJson(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>workObserverToPanoramaJson(e))}}}function equirectangularUvToCubemap(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),o=Math.cos(n),s=Math.sin(t),c=Math.cos(t),l=o*s,u=r,d=o*c,f=Math.abs(l),p=Math.abs(u),m=Math.abs(d),h,g;if(f>=p&&f>=m){let e=1/f;l>0?(h=`right`,g=new three.Vector2(-d*e,u*e)):(h=`left`,g=new three.Vector2(d*e,u*e))}else if(p>=f&&p>=m){let e=1/p;u>0?(h=`up`,g=new three.Vector2(l*e,-d*e)):(h=`down`,g=new three.Vector2(l*e,d*e))}else{let e=1/m;d>0?(h=`front`,g=new three.Vector2(l*e,u*e)):(h=`back`,g=new three.Vector2(-l*e,u*e))}return g.x=(g.x+1)/2,g.y=1-(g.y+1)/2,[h,g]}function cubemapUvToEquirectangular(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,o=0,s=0,c=0;switch(e){case`right`:o=1,s=r,c=-n;break;case`left`:o=-1,s=r,c=n;break;case`up`:o=n,s=1,c=-r;break;case`down`:o=n,s=-1,c=r;break;case`front`:o=n,s=r,c=1;break;case`back`:o=-n,s=r,c=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let l=Math.sqrt(o*o+s*s+c*c);if(l===0)return new three.Vector2(.5,.5);o/=l,s/=l,c/=l;let u=Math.atan2(o,c),d=Math.asin(Math.max(-1,Math.min(1,s))),f=(u+Math.PI)/(2*Math.PI),p=(Math.PI/2-d)/Math.PI;return f%=1,f=f<0?f+1:f,p=Math.max(0,Math.min(1,p)),new three.Vector2(f,p)}var workObserverProto={vectorToEquirectangularUv(e,t=`top-left`){let n=new three.Quaternion().setFromRotationMatrix(this.work.transform).inverse(),r=new three.Quaternion().copy(this.quaternion).inverse(),o=new three.Quaternion(0,1,0,0).inverse(),s=new three.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(o),c=Math.atan2(s.x,-s.z),l=Math.asin(-s.y);if(t===`top-left`)return new three.Vector2(c/(Math.PI*2)+.5,l/Math.PI+.5);if(t===`bottom-left`)return new three.Vector2(c/(Math.PI*2)+.5,.5-l/Math.PI);throw Error(`Invalid uvOrigin ${t}`)},vectorToCubemapUv(e,t=`top-left`){let n=equirectangularUvToCubemap(this.vectorToEquirectangularUv(e,`top-left`));if(t===`top-left`)return n;if(t===`bottom-left`){let[e,t]=n;return t.y=1-t.y,n}else throw Error(`Invalid uvOrigin ${t}`)},equirectangularUvToVector(e,t=`top-left`){let n=0;if(t===`top-left`)n=1;else if(t===`bottom-left`)n=-1;else throw Error(`Invalid uvOrigin ${t}`);let r=new three.Quaternion().setFromRotationMatrix(this.work.transform),o=new three.Quaternion().copy(this.quaternion),s=new three.Quaternion(0,1,0,0),c=Math.PI*2*(e.x+.5),l=Math.PI*(e.y-.5),u=Math.abs(Math.cos(l)),d=Math.sin(c)*u,f=-Math.sin(l)*n,p=-Math.cos(c)*u;return new three.Vector3(d,f,p).applyQuaternion(s).applyQuaternion(o).applyQuaternion(r)},cubemapUvToVector(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new three.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let o=cubemapUvToEquirectangular(e,r);return this.equirectangularUvToVector(o)},getWorldPosition(){return new three.Vector3().copy(this.position).applyMatrix4(this.work.transform)},getWorldStandingPosition(){return new three.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}};function isNumber(e){return typeof e==`number`}function jsonClone(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:jsonClone(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:jsonClone(r)}return t}}function getType(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function jsonMerge(e,t){let n=getType(e),r=getType(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return jsonClone(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=jsonMerge(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=jsonMerge(e[n],t[n]);return e}function jsonStableStrinfiy_(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=jsonStableStrinfiy_(e[r],!1)+`,`;return n>-1&&(t+=jsonStableStrinfiy_(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return jsonStableStrinfiy_(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,o=``,s=0;for(;s<r;){let t=n[s],r=jsonStableStrinfiy_(e[t],!0);r!==void 0&&(s&&o!==``&&(o+=`,`),o+=JSON.stringify(t)+`:`+r),s++}return`{`+o+`}`}switch(n){case`function`:return JSON.stringify(e.toString());case`undefined`:return t?void 0:null;case`number`:return e;default:return isFinite(e)?e:null}}function jsonStableStrinfiy(e){return jsonStableStrinfiy_(e,!1)}function jsonHash(e){return`hash::${sha256(jsonStableStrinfiy(e))}`}var PANO_ID_REG=/^(.*)\[(\d+)\]$/;function panoStringify(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function panoParse(e){let t=e.match(PANO_ID_REG);if(t){let[e,n,r]=t,o=Math.floor(Number(r));if(!isNaN(o)&&isFinite(o))return{workCode:n,panoIndex:o}}throw Error(`Invalid PanoId`)}function panoEqual(e,t){return panoStringify(e)===panoStringify(t)}function isPanoId(e){return typeof e==`string`&&PANO_ID_REG.test(e)}var REG_STR=`\\{([^\\}]+)\\}`;function escapeRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function createRegExp(e){return RegExp(`^`+e.map(e=>escapeRegexp(e)).join(`(.+)`)+`$`)}var StringPattern=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(REG_STR,`g`),n,r=0;for(;(n=t.exec(e))!==null;)this.strings.push(e.slice(r,n.index)),this.keys.push(n[1]),r=n.index+n[0].length;this.strings.push(e.slice(r))}stringify(e){let t=[this.strings[0]];for(let n=0;n<this.keys.length;n++){let r=e[this.keys[n]];t.push(String(r),this.strings[n+1])}return t.join(``)}match(e){var t;this.matchRegexp=(t=this.matchRegexp)==null?createRegExp(this.strings):t;let n=e.match(this.matchRegexp);if(!n)return null;let r={};for(let e=0;e<this.keys.length;e++){let t=this.keys[e],o=n[e+1];if(r[t]!==o){if(r[t]!==void 0)return null;r[t]=o}}return r}};function deepFreeze(e){Object.freeze(e);let t=typeof e==`function`,n=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach(function(r){n.call(e,r)&&(!t||r!==`caller`&&r!==`callee`&&r!==`arguments`)&&e[r]!==null&&(typeof e[r]==`object`||typeof e[r]==`function`)&&!Object.isFrozen(e[r])&&deepFreeze(e[r])}),e}var URL_REGEXP=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,BUILDIN_ALLOW_HOST=deepFreeze(JSON.parse(function(...e){let t=113,n=126,r=0,o=``;return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/rnyrr;p{/9/rnyrr;p|z/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/rnyrr;nv/9/;p{/9/pq{;p{/9/pnyp{|qr;vr/j`))),domainRegex=/^([^.]+)(\.([^.]+))*$/,currentHostname=typeof location<`u`?location.hostname:`localhost`;function isIPDomain(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function matchDomain(e,t){if(!domainRegex.test(e)||!domainRegex.test(t))return!1;if(e===`*`)return!0;let n=e.split(`.`).reverse(),r=t.split(`.`).reverse();if(n.length<=1)return e===t;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function hostnameFromURL(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return currentHostname;let t=e.match(URL_REGEXP);return t?t[2]:currentHostname}var error_invalid_input=()=>Error(`Invalid input.`),error_invalid_certificate=()=>Error(`Invalid certificate.`),error_invalid_signature=()=>Error(`Invalid signature.`),error_date_expired=e=>Error(`Date(${e.toString()}) expired.`),error_host_not_allowed=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function ObjectOmit(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function jsonStableNoneNumberStrinfiy_(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=jsonStableNoneNumberStrinfiy_(e[r],!1)+`,`;return n>-1&&(t+=jsonStableNoneNumberStrinfiy_(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return jsonStableNoneNumberStrinfiy_(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,o=``,s=0;for(;s<r;){let t=n[s],r=jsonStableNoneNumberStrinfiy_(e[t],!0);r!==void 0&&(s&&o!==``&&(o+=`,`),o+=JSON.stringify(t)+`:`+r),s++}return`{`+o+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function jsonStableNoneNumberStrinfiy(e){return String(jsonStableNoneNumberStrinfiy_(e,!1))}function verify(e){var t,n,r;let o={};try{o=typeof e==`string`?JSON.parse(e):e}catch(e){return error_invalid_input()}if(typeof o!=`object`)return error_invalid_input();let s=currentHostname,c=Date.now(),l=new Date(typeof o.expire_at==`string`&&/^\d+$/.test(o.expire_at)?Number(o.expire_at):o.expire_at),u=Array.isArray(o.allow_hosts)?o.allow_hosts:[];if(s.length===0||isIPDomain(s)||BUILDIN_ALLOW_HOST.filter(e=>matchDomain(e,s)).length>0){let e=String((t=o.certificate)==null?``:t);if(e)try{let t=new X509;return t.readCertPEM(e),deepFreeze({issuer:t.getSubjectString(),expire:l,allowHosts:u})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return deepFreeze({issuer:`none`,expire:l,allowHosts:u})}let d=String((n=o.certificate)==null?``:n);if(!d)return error_invalid_certificate();let f=new X509;f.readCertPEM(d);let p=String((r=o._signature)==null?``:r);return!p||verifyMessage(jsonStableNoneNumberStrinfiy(ObjectOmit(o,[`_signature`])),p,f)===!1?error_invalid_signature():c<l.getTime()?BUILDIN_ALLOW_HOST.concat(u).filter(e=>matchDomain(e,s)).length===0?error_host_not_allowed(s):deepFreeze({issuer:f.getSubjectString(),expire:l,allowHosts:u}):error_date_expired(l)}function verifyURL(e,t){let n=hostnameFromURL(e);return currentHostname.length!==0&&!isIPDomain(currentHostname)&&BUILDIN_ALLOW_HOST.filter(e=>matchDomain(e,currentHostname)).length===0&&!isIPDomain(n)&&BUILDIN_ALLOW_HOST.concat(t).filter(e=>matchDomain(e,n)).length===0?error_host_not_allowed(n):e}var accessibleNodesSet=new Set,PANO_TEXTURE_SCALE=new three.Vector3(1,1,1),FACE_ORDER$1=[`right`,`left`,`up`,`down`,`front`,`back`];function relativeURL(e,t){if(!isAbsoluteURL(e))return e;if(e.indexOf(t)===0)return e.slice(t.length);let n=t.replace(/^https\:/,`http:`);if(e.indexOf(n)===0)return e.slice(n.length);let r=t.replace(/^http\:/,`https:`);return e.indexOf(r)===0?e.slice(r.length):(console.warn(`${e} is not start with base_url(${t}).`),e)}function panoURL(e,t,n){return!isAbsoluteURL(e)&&typeof t==`string`&&t.length>0&&(e=pathJoin(t,String(n),e)),e}function getTileLevel(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function sortTile(e){e=e.slice().sort((e,t)=>e.level-t.level);let t=[];for(let n of e){if(t.length===0){t.push(n);continue}let e=t[t.length-1];if(n.level>e.level){t.push(n);continue}if(n.size>e.size){t[t.length-1]=n;continue}}return t}function parse(e,t){var n,r,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,S,C;let w=[],T=null;for(let t of[].concat(e))if(`getURL`in t)T={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},w.push(workToJson(t));else{let e=typeof t==`string`?JSON.parse(t):jsonClone(t),n=verify(e);if(n instanceof Error)return n;T===null&&(T=n),w.push(e)}if(T===null)return Error(`Empty`);defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:T.issuer}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(T.expire)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(T.allowHosts)});let E=w.reduce((e,t)=>jsonMerge(e,t));defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=E.name)==null?`Unknown`:n)}),defineProperty(t,`workCode`,{enumerable:!0,writable:!0,value:String(E.resource_code||E.basic_code||E.vr_code||E.code||E.project_id||E.work_code||E.workCode||createUuid())}),defineProperty(t,`projectId`,{enumerable:!0,writable:!0,value:E.project_id}),defineProperty(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=E.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let D;typeof E.model==`object`&&(D={},defineProperty(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(D,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=E.model.file_url;if(e)return relativeURL(e,t.baseURL)})()}),defineProperty(D,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=E.model.material_base_url;return e&&(e=relativeURL(e,t.baseURL)),e})()}),defineProperty(D,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(E.model.material_textures)&&(e=E.model.material_textures.slice(),Object.freeze(e)),e})()}),defineProperty(D,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:E.model.up_axis}),defineProperty(D,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:jsonClone(E.model.coordinate)}),defineProperty(D,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let o=[];if(Array.isArray(E.model.layers)){for(let s of E.model.layers)if(s&&s.tileset_url){let c={};defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=s.name)==null?``:e}),defineProperty(c,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=s.type)==null?`mesh`:n}),defineProperty(c,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=s.up_axis)==null?`Z`:r}),defineProperty(c,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:relativeURL(s.tileset_url,t.baseURL)}),o.push(c)}}if(typeof E.model.tiles==`object`){let e=E.model.tiles;if(e&&e.tileset_url){let n={};defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),defineProperty(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),defineProperty(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),defineProperty(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:relativeURL(e.tileset_url,t.baseURL)}),o.push(n)}}return Object.freeze(o)})()})),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:D});let O=[];if(Array.isArray(E.observers)&&E.panorama&&Array.isArray(E.panorama.list||E.panorama.info)){let e=E.observers,n=(r=E.panorama.list||E.panorama.info)==null?[]:r,w=(d=(l=(s=(o=E.panorama)==null?void 0:o.pano_high_cube_base_url)==null?(c=E.panorama)==null?void 0:c.pano_cube_base_url:s)==null?(u=E.panorama)==null?void 0:u.base_url:l)==null?``:d,T=Math.min(e.length,n.length),D={};for(let e of Object.keys((f=E.panorama.pattern)==null?{}:f)){let t=e,n=E.panorama.pattern[t];if(typeof n==`string`){let e=new StringPattern(n);D[t]=t=>e.stringify(t)}else D[t]=()=>n}let k=(e,t)=>{var n;let r=D[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<T;r++){let o=e[r],s=n[r],c=Object.create(workObserverProto);defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),defineProperty(c,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),defineProperty(c,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:panoStringify({workCode:t.workCode,panoIndex:r})}),defineProperty(c,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(p=o.floor_index)==null?o.floor:p}),defineProperty(c,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(h=(m=o.derived_id)==null?k(s,`derived_id`):m)==null?0:h}),defineProperty(c,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(_=(g=o.derived_id_str)==null?k(s,`derived_id_str`):g)==null?String(c.derivedId):_}),defineProperty(c,`active`,{enumerable:!0,configurable:!1,writable:!1,value:o.active!==!1&&k(s,`active`)!==!1}),defineProperty(c,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(y=(v=o.loadable)==null?k(s,`loadable`):v)==null?!1:y}),defineProperty(c,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Vector3().fromArray((b=o.position)==null?[0,0,0]:b))}),defineProperty(c,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Vector3().fromArray((C=(S=o.standing_position)==null?o.standingPosition:S)==null?[0,0,0]:C))}),defineProperty(c,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Quaternion().fromArray(o.quaternion?[o.quaternion.x,o.quaternion.y,o.quaternion.z,o.quaternion.w]:[0,0,0,1]))}),defineProperty(c,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Matrix4().compose(c.position,c.quaternion,PANO_TEXTURE_SCALE))}),defineProperty(c,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(accessibleNodesSet.clear(),o.accessible_nodes&&Array.isArray(o.accessible_nodes))for(let e of o.accessible_nodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.accessibleNodes&&Array.isArray(o.accessibleNodes))for(let e of o.accessibleNodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.visible_nodes&&Array.isArray(o.visible_nodes))for(let e of o.visible_nodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.visibleNodes&&Array.isArray(o.visibleNodes))for(let e of o.visibleNodes)e>=T||e===r||accessibleNodesSet.add(e);if(accessibleNodesSet.size===0)for(let e=0;e<T;e++)e!==r&&accessibleNodesSet.add(e);let e=Array.from(accessibleNodesSet);return accessibleNodesSet.clear(),Object.freeze(e)})()}),defineProperty(c,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:c.accessibleNodes}),defineProperty(c,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of FACE_ORDER$1)defineProperty(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return relativeURL(panoURL((e=k(s,n))==null?``:e,w,r),t.baseURL)})()});return defineProperty(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=getImageSizeFromURL(e[FACE_ORDER$1[0]]),n=k(s,`size_list`),r=k(s,`tiles`);if(t){if(n){let e=n.slice().sort((e,t)=>e-t);return Object.freeze(e)}else if(r){let e=[t],n=r.slice().sort((e,t)=>e-t);for(let r of n){let n=512*Math.pow(2,r);n>t&&e.push(n)}return Object.freeze(e)}return Object.freeze([t])}return Object.freeze([])})()}),defineProperty(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=getImageSizeFromURL(e.front);if(!n)return;let r=e.sizeList.slice();if(r[0]){let e=getTileLevel(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let o=[];for(let s of r){let r=getTileLevel(s);if(typeof r!=`number`)continue;let c={};if(defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),s>n){defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of FACE_ORDER$1)defineProperty(c,t,{enumerable:!0,configurable:!1,writable:!1,value:replaceImageSize(e[t],s)})}else{defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/n});for(let t of FACE_ORDER$1)defineProperty(c,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]})}o.push(c)}return o=sortTile(o),Object.freeze(o)})()}),defineProperty(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=k(s,`video`),n;return e&&(n={},defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),defineProperty(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Matrix4().fromArray(e.matrix)}),defineProperty(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector2().fromArray(e.size)})),n})()}),e})()}),O.push(c)}}defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(O)});let k={};if(defineProperty(k,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),E.initial){if(t.observers.length>0){let e;isNumber(E.initial.panoIndex)?e=E.initial.panoIndex:isNumber(E.initial.pano_index)?e=E.initial.pano_index:isNumber(E.initial.pano)&&(e=E.initial.pano),typeof e==`number`&&(e=clamp$1(e,0,t.observers.length-1),defineProperty(k,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(E.initial.mode===`Panorama`&&t.observers.length===0||E.initial.mode===`Floorplan`||E.initial.mode===`Topview`||E.initial.mode===`Model`||E.initial.mode===`Mapview`?defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:E.initial.mode}):typeof k.panoIndex==`number`?defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),isNumber(E.initial.latitude)&&defineProperty(k,`latitude`,{enumerable:!0,writable:!0,value:E.initial.latitude}),isNumber(E.initial.longitude)?defineProperty(k,`longitude`,{enumerable:!0,writable:!0,value:E.initial.longitude}):isNumber(E.initial.heading)&&defineProperty(k,`longitude`,{enumerable:!0,writable:!0,value:headingToLongitude(E.initial.heading)}),isNumber(E.initial.fov)&&defineProperty(k,`fov`,{enumerable:!0,writable:!0,value:E.initial.fov}),isNumber(E.initial.distance)&&defineProperty(k,`distance`,{enumerable:!0,writable:!0,value:E.initial.distance}),Array.isArray(E.initial.offset)){let e=E.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});defineProperty(k,`offset`,{enumerable:!0,writable:!0,value:new three.Vector3().fromArray(t)})}else typeof E.initial.offset==`object`&&typeof E.initial.offset.x==`number`&&typeof E.initial.offset.y==`number`&&typeof E.initial.offset.z==`number`&&defineProperty(k,`offset`,{enumerable:!0,writable:!0,value:new three.Vector3().fromArray([E.initial.offset.x,E.initial.offset.y,E.initial.offset.z])})}return defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:k}),t}function parseNull(e,t){return defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),defineProperty(t,`workCode`,{enumerable:!0,value:`null-`+createUuid()}),defineProperty(t,`baseURL`,{enumerable:!0,value:`/`}),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function parsePano(e,t){var n,r;return defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),defineProperty(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?createUuid():r}),defineProperty(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:panoStringify({workCode:t.workCode,panoIndex:0})}),defineProperty(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),defineProperty(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),defineProperty(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector3(0,1.5,0)}),defineProperty(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector3(0,0,0)}),defineProperty(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Quaternion(0,1,0,0)}),defineProperty(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Matrix4().compose(n.position,n.quaternion,PANO_TEXTURE_SCALE)}),defineProperty(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),defineProperty(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),defineProperty(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of FACE_ORDER$1)defineProperty(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return defineProperty(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),defineProperty(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=getImageSizeFromURL(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=getTileLevel(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let o=[];for(let s of r){let r=getTileLevel(s);if(typeof r!=`number`)continue;let c={};if(defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),s>e){defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of FACE_ORDER$1)defineProperty(c,e,{enumerable:!0,configurable:!1,writable:!1,value:replaceImageSize(n[e],s)})}else{defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/e});for(let e of FACE_ORDER$1)defineProperty(c,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}o.push(c)}return o=sortTile(o),Object.freeze(o)})()}),defineProperty(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),defineProperty(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var workVerifySet=new WeakSet,Work=class{constructor(e,t){this.observerBox=new three.Box3,this.observerBox=new three.Box3,this.transform=new three.Matrix4,this.shortPath=!1,this.jsonp=!1;let n;if(n=e===null?parseNull(e,this):typeof e==`object`&&typeof e.size==`number`&&typeof e.up==`string`&&typeof e.down==`string`&&typeof e.right==`string`&&typeof e.left==`string`&&typeof e.front==`string`&&typeof e.back==`string`?parsePano(e,this):parse(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
938
+ `,uniforms:{diffuse:{value:new three.Color},opacity:{value:1},displacementScalar:{value:0}}};function createPipeBufferGeometry(e,t,n,r){let o=new Float32Array((n+1)*(r+1)*3),s=new Float32Array((n+1)*(r+1)*3),c=new Float32Array((n+1)*(r+1)*2),l=new Uint32Array(n*r*6),u=e.computeFrenetFrames(n),d=new three.Vector3,f=new three.Vector3,p=new three.Vector2,m=new three.Vector3;for(let l=0;l<=n;l++){m=e.getPointAt(l/n,m);let h=u.normals[l],g=u.binormals[l];for(let e=0;e<=r;e++){let u=l*(r+1)+e,_=e/r*Math.PI*2,v=Math.sin(_),y=-Math.cos(_);f.x=y*h.x+v*g.x,f.y=y*h.y+v*g.y,f.z=y*h.z+v*g.z,f.normalize(),f.toArray(s,u*3),d.x=m.x+t*f.x,d.y=m.y+t*f.y,d.z=m.z+t*f.z,d.toArray(o,u*3),p.x=l/n,p.y=e/r,p.toArray(c,u*2)}}for(let e=0;e<n;e++)for(let t=0;t<r;t++){let n=(e*r+t)*6,o=(r+1)*e+t,s=(r+1)*(e+1)+t,c=(r+1)*(e+1)+(t+1),u=(r+1)*e+(t+1);l[n]=o,l[n+1]=s,l[n+2]=u,l[n+3]=s,l[n+4]=c,l[n+5]=u}let h=new three.BufferGeometry;return h.setIndex(new three.BufferAttribute(l,1)),h.setAttribute(`position`,new three.BufferAttribute(o,3)),h.setAttribute(`normal`,new three.BufferAttribute(s,3)),h.setAttribute(`uv`,new three.BufferAttribute(c,2)),h}function parseTrajectoryObject(e,t){let n=new three.Color(0).convertSRGBToLinear(),r=new three.Color(52949).convertSRGBToLinear(),o=new three.Color(3370495).convertSRGBToLinear(),s=new three.Color(16777215).convertSRGBToLinear(),c=0,l=new three.CurvePath,u=e.length;for(let t=3;t<u;t+=3){let n=new three.Vector3().fromArray(e,t-3),r=new three.Vector3().fromArray(e,t);c+=n.distanceTo(r);let o=new three.LineCurve3(n,r);l.add(o)}let d=createPipeBufferGeometry(l,.03,Math.ceil(c*100),6);d.clearGroups(),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,0),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,1),d.addGroup(0,d.index?d.index.count:d.attributes.position.count,2);let f=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.BackSide});f.uniforms.totalLength.value=c,f.uniforms.diffuse.value=n,f.uniforms.diffuse2.value=n,f.uniforms.opacity.value=.5,f.transparent=!0;let p=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.BackSide});p.uniforms.totalLength.value=c,p.uniforms.displacementScalar.value=-.01,p.uniforms.diffuse.value=r,p.uniforms.diffuse2.value=o;let m=new three.ShaderMaterial({vertexShader:TRAJECTOR_PIPE_SHADER.vertexShader,fragmentShader:TRAJECTOR_PIPE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_PIPE_SHADER.uniforms),side:three.DoubleSide});m.uniforms.totalLength.value=c,m.uniforms.displacementScalar.value=-.026,m.uniforms.dashSize.value=new three.Vector2(.06,.09),m.uniforms.diffuse.value=s,m.uniforms.diffuse2.value=s;let h=new three.Mesh(d,[f,p,m]),g=.08,_=24,v=new three.SphereBufferGeometry(.08,24,24);v.clearGroups(),v.addGroup(0,d.index?d.index.count:d.attributes.position.count,0),v.addGroup(0,d.index?d.index.count:d.attributes.position.count,1);let y=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.BackSide});y.uniforms.diffuse.value=n,y.uniforms.opacity.value=.5,y.transparent=!0;let b=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.FrontSide});b.uniforms.displacementScalar.value=-.01,b.uniforms.diffuse.value=r;let S=new three.Mesh(v,[y,b]);S.position.fromArray(e,0),h.add(S);let C=new three.ShaderMaterial({vertexShader:TRAJECTOR_SPHERE_SHADER.vertexShader,fragmentShader:TRAJECTOR_SPHERE_SHADER.fragmentShader,uniforms:three.UniformsUtils.clone(TRAJECTOR_SPHERE_SHADER.uniforms),side:three.FrontSide});C.uniforms.displacementScalar.value=-.01,C.uniforms.diffuse.value=o;let w=new three.Mesh(v,[y,C]);return w.position.fromArray(e,e.length-3),h.add(w),{scene:h,dispose:()=>{d.dispose(),f.dispose(),p.dispose(),m.dispose(),v.dispose(),y.dispose(),b.dispose(),C.dispose()}}}function loadTrajectory(e,t){let n=e.name,r=imageURL(appendSearch(e.content.uri,t.search),{key:`model.0`});return e.content.loadState=`LOADING`,e.content.loadStateUpdateTime=now(),loadPly(r,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:t.fetcher}).then(t=>{var o,s,c,l;let u=(s=(o=t.scene.attributes)==null?void 0:o.time.array)==null?[]:s,d=(l=(c=t.scene.attributes)==null?void 0:c.position.array)==null?[]:l,f=t.byteLength,p=t.memoryUsage,m=parseTrajectoryObject(d,u);m.scene.applyMatrix4(e.transform),m.scene.updateWorldMatrix(!1,!0),m.scene.matrixAutoUpdate=!1;let h=new TrajectoryNode(n,m.scene);return e.content.data={uri:r,byteLength:f,memoryUsage:p,positionArray:d,timeArray:u,object:h},e.content.byteLength=f,e.content.memoryUsage=p,e.content.loadState=`READY`,e.content.loadStateUpdateTime=now(),e}).catch(t=>(e.content.data=void 0,e.content.loadState=`FAILED`,e.content.loadStateUpdateTime=now(),t instanceof NetworkResponseError&&t.httpStatus===0||t instanceof NetworkTimeoutError||t instanceof NetworkProxyError?e.content.loadfailRetryDelay=clamp$1(e.content.loadfailRetryDelay+RETRY_DELAY_STEP,RETRY_DELAY_STEP,MAX_RETRY_DELAY):e.content.loadfailRetryDelay=1/0,Promise.reject(t)))}function unloadTrajectory(e){e.content&&(e.content.data&&e.content.data.object.dispose(),e.content.data=void 0,e.content.loadState=`UNLOADED`,e.content.loadProgress=0,e.content.loadStateUpdateTime=now(),e.content.byteLength=0,e.content.memoryUsage=0)}var scratchVector3$7=new three.Vector3,scratchMatrix3=new three.Matrix3,scratchMatrix4$3=new three.Matrix4,a=6378137,invF=298.257223563;function ecefToLla(e){let t=a-a/invF,n=(a*a-t*t)/(a*a),r=Math.sqrt(e.x*e.x+e.y*e.y),o=1e-12,s=1e3,c=0,l=Math.atan2(e.z,r),u=0;for(;c++<1e3;){let t=Math.sin(l),o=a/Math.sqrt(1-n*t*t);u=r/Math.cos(l)-o;let s=Math.atan2(e.z/(o*(1-n)+u),r/(o+u));if(isNaN(s)||Math.abs(s-l)<1e-12)break;l=s}return e.set(l,Math.atan2(e.y,e.x),u)}function llaToEcef(e){let{x:t,y:n,z:r}=e,o=a-a/invF,s=(a*a-o*o)/(a*a),c=Math.sin(t),l=Math.cos(t),u=Math.sin(n),d=Math.cos(n),f=a/Math.sqrt(1-s*c*c),p=(f+r)*l*d,m=(f+r)*l*u,h=(o*o/(a*a)*f+r)*c;return e.set(p,m,h)}function getEcefToEnuMatrix(e,t){let{x:n,y:r,z:o}=ecefToLla(scratchVector3$7.copy(e)),s=Math.sin(n),c=Math.sin(r),l=Math.cos(n),u=Math.cos(r);t.fromArray([-c,-s*u,l*u,0,+u,-s*c,l*c,0,0,l,s,0,0,0,0,1]);let d=scratchMatrix3.setFromMatrix4(t),f=scratchVector3$7.copy(e).applyMatrix3(d).multiplyScalar(-1);t.setPosition(f);let p=scratchMatrix4$3.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,o,1]);return t.premultiply(p),t}var ROTATE_X_90_MATRIX=new three.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),ROTATE_X_90_MATRIX_INVERSE=new three.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),enuToLocalMatrix=new three.Matrix4().copy(ROTATE_X_90_MATRIX),localToEnuMatrix=new three.Matrix4().copy(ROTATE_X_90_MATRIX_INVERSE);function getRecommendTile3dProps(e,t={}){var n,r,o;let s,c,l;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){l=4,t.powerPreference===`high`&&(l=2),s=l/1.6;let u=0;if(((n=e.tileset.rootMeta.taskParameters)==null?void 0:n.point_homogenization)===`1`&&(r=e.tileset.rootMeta.taskParameters)!=null&&r.homo_point_density){let t=Number((o=e.tileset.rootMeta.taskParameters)==null?void 0:o.homo_point_density);isFinite(t)&&!isNaN(t)&&(u=t)}u<=0&&(u=.02),c=u*1.4}else l=5,t.powerPreference===`high`&&(l=4),s=0,c=.03;else l=6,s=0,c=.03,e.name===`aerophoto`?(l=12,t.powerPreference===`high`&&(l=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(l=5,t.powerPreference===`high`&&(l=4));return{pointScale:c,pointMinPixel:s,maxScreenSpaceError:l}}var scratchVector3$6=new three.Vector3,scratchSphereBoundingVolume=new SphereBoundingVolume,scratchBoxBoundingVolume=new BoxBoundingVolume,parameterVersionMap=new WeakMap,tileVersionMap=new WeakMap,trajectoryVersionMap=new WeakMap,STENCIL_CONSTANT={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},SKIP_BACKFACE_MATERIAL=(()=>{let e=new three.MeshBasicMaterial;return e.side=three.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=STENCIL_CONSTANT.TILE_MASK,e.stencilFunc=three.AlwaysStencilFunc,e.stencilFuncMask=STENCIL_CONSTANT.TILE_MASK,e.stencilZPass=three.ReplaceStencilOp,e.stencilWriteMask=STENCIL_CONSTANT.TILE_MASK,e})(),SKIP_BACKFACE_TRANSPARENT_MATERIAL=(()=>{let e=new three.MeshBasicMaterial;return e.visible=!1,e})(),CLEAR_STENCIL_GEOMETRY=new three.BufferGeometry,CLEAR_STENCIL_MATERIAL=new three.MeshBasicMaterial;function cloneSkipBackfaceObject(e){let t;t=e instanceof three.Mesh?new three.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?SKIP_BACKFACE_TRANSPARENT_MATERIAL:SKIP_BACKFACE_MATERIAL):e.material&&e.material.transparent?SKIP_BACKFACE_TRANSPARENT_MATERIAL:SKIP_BACKFACE_MATERIAL):e instanceof three.Group?new three.Group:new three.Object3D,t.position.copy(e.position),t.quaternion.copy(e.quaternion),t.scale.copy(e.scale),t.matrix.compose(e.position,e.quaternion,e.scale),t.matrixAutoUpdate=!1,t.frustumCulled=e.frustumCulled,t.visible=e.visible;for(let n of e.children)t.add(cloneSkipBackfaceObject(n));return t}var Tile3D=class extends three.Object3D{constructor(e,t){var n,r;super(),this.parameter=new Parameter,this.renderObjects=[],this.backfaceObjects=[],this.tileObjects=[],this.frameNumber=0,this.error=(n=t.error)==null?null:n,this.name=t.name,this.type=t.type,this.upAxis=t.upAxis,this.light=t.light,this.fetcher=t.fetcher,this.search=(r=t.search)==null?``:r,this.groundHeight=t.groundHeight,this.coordinateSystem=t.coordinateSystem,this.boundingBox=new three.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new three.Mesh(CLEAR_STENCIL_GEOMETRY,CLEAR_STENCIL_MATERIAL),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new Tileset(e,{tileLoader:e=>this.loadContent(e),tileUnloader:e=>this.unloadContent(e),onTileLoad:e=>{this.onTileLoad&&this.onTileLoad(e)},onTileUnload:e=>{this.onTileUnload&&this.onTileUnload(e)},onTileError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{tile:e})),console.error(`Tile error`,e.id,t)},trajectoryLoader:e=>this.loadTrajectory(e),trajectoryUnloader:e=>this.unloadTrajectory(e),onTrajectoryLoad:()=>{},onTrajectoryUnload:e=>{},onTrajectoryError:(e,t)=>{this.onError&&this.onError(Object.assign(t,{error:t})),console.error(`Trajectory error`,e,t)}}),this.tileset.root.boundingVolume&&this.tileset.root.boundingVolume.getBoundingBox(this.boundingBox),this.currentResolvedParameterValue=Parameter.resolveValueTo({},this.parameter)}get viewerRequestVolume(){return this.tileset.root.viewerRequestVolume}set viewerRequestVolume(e){this.tileset.root.viewerRequestVolume=e}get tiles(){return this.tileset.selectedTiles}get trajectories(){return this.tileset.trajectories}getRecommendProps(e={}){return getRecommendTile3dProps(this,e)}loadContent(e){return loadTileContent(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)unloadTileContent(e);else if(e.content.data)if(e.content.data.type===`spz`){let t=e.content.data.object.children[0].boundingBox;this.boundingBox.union(t)}else this.boundingBox.expandByObject(e.content.data.object)}})}unloadContent(e){return unloadTileContent(e),Promise.resolve()}loadAllTilesets(){let e=t=>{let n=[];return this.tileset.root.traverse(e=>{var t;e.type===`TILESET`&&((t=e.content)==null?void 0:t.loadState)!==`READY`&&n.push(e)}),Promise.all(n.map(t=>this.loadContent(t).then(()=>e(t)))).then(()=>{})};return e(this.tileset.root)}loadTrajectory(e){return loadTrajectory(e,{fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(e=>{this.disposed&&unloadTrajectory(e)})}unloadTrajectory(e){return unloadTrajectory(e),Promise.resolve()}intersectRaycaster(e,t){var n,r;let o=t==null?[]:t,s=[this.tileset.root],c=this.tileset.transform,l=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,u=e.sortByDistance;e.sortByDistance=!1;let d,f=1/0;for(;d=s.pop();){let t;if(d.boundingVolume){let n;n=d.boundingVolume instanceof BoxBoundingVolume?scratchBoxBoundingVolume.copy(d.boundingVolume):d.boundingVolume instanceof SphereBoundingVolume?scratchSphereBoundingVolume.copy(d.boundingVolume):d.boundingVolume.clone(),n.applyMatrix4(c),t=n.intersectRay(e.ray,l,f)}else t=!0;if(t){for(let e=0,t=d.children.length;e<t;e++)s.push(d.children[e]);if(d.selected&&d.content&&d.content.data&&d.content.data.object.visible){let t=e.hitFilter;if(e.hitFilter=n=>{var r;return Object.assign(n,{model:(r=this.parent)==null?void 0:r,viewLayer:this,tile:d}),t?t.call(e,n):!0},d.content.data.object.intersectRaycaster(e,o),e.hitFilter=t,e.firstHitOnly){let e=o[0];e&&f>e.distance&&(f=e.distance)}}}}return e.sortByDistance=u,sortIntersects(o,e.sortByDistance,e.firstHitOnly),o}update(e,t,n,r){var o,s,c;this.renderer=e,this.frameNumber++;let l=!1,u=Parameter.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);parameterVersionMap.get(this)!==u.versionNumber&&(parameterVersionMap.set(this,u.versionNumber),l=!0);let d=this.visible&&r.visible&&n.visible,f=u.maxLevelOfDetail;f=Math.max(f,0);let p=Math.min(u.minLevelOfDetail,f);(!d||!this.loaded||!n.loaded)&&(f=Math.max(p,0));let m=u.maxMemoryUsage;d||(m=Math.min(0,m));let h=u.minGeometricError,g=u.maxRequests,_=u.memoryAdjustedScreenSpaceError;d||(_=!1);let v=t.controllerMode;(v===`Panorama`||v===`VRPanorama`||v===`XRPanorama`)&&(u.modelAlpha<.1&&(h=u.panoramaMinGeometricError,_=!1),u.progress>=.01&&u.progress<=.99&&(g=0));let y=u.maxGeometricError;y=Math.max(h,y);let b={time:t.time,camera:{type:t.type,position:new three.Vector3().copy(t.position),direction:t.getDirection(new three.Vector3),up:new three.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:d&&t.visible,refine:t.refineModel},height:t.resolution.height,pixelRatio:t.pixelRatio,frameNumber:this.frameNumber,sseDenominator:2*Math.tan(.5*t.fov/180*Math.PI),cullingVolume:new CullingVolume().setFromCamera(t),minLevelOfDetail:p,maxLevelOfDetail:f,minGeometricError:h,maxGeometricError:y,skipLevelOfDetail:u.skipLevelOfDetail,mostDetail:u.mostDetail,loadSiblings:u.loadSiblings,cameraCulling:u.cameraCulling,maxMemoryUsage:m,maxRequests:g,requestOrder:u.requestOrder,maxScreenSpaceError:u.maxScreenSpaceError,memoryAdjustedScreenSpaceError:_},S=u.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},b),{camera:{type:t.type,position:new three.Vector3().copy(e.position),direction:e.getWorldDirection(new three.Vector3),up:new three.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new CullingVolume().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),l=!0);let C=!this.autoRefine;if(C===!1&&u.progress>=.01&&u.progress<=.99){let e=new three.Vector3;u.pano0&&e.setFromMatrixPosition(u.pano0.matrix);let t=e.clone();u.pano1&&t.setFromMatrixPosition(u.pano1.matrix),e.distanceTo(t)<10&&(C=!0)}if(C||this.tileset.update(b,S),this.refined=!0,this.refineProgress[0]=0,this.refineProgress[1]=0,this.tileset.needsRefinedTiles.forEach(e=>{if(this.refineProgress[1]++,e.content){let t=e.content.loadState;if(t===`UNLOADED`||t===`LOADING`){this.refined=!1;return}}this.refineProgress[0]++}),this.loaded===!1&&this.autoRefine){this.loaded=!0;let e=!1;this.tileset.needsRefinedTiles.forEach(t=>{if(this.loaded!==!1&&t.content&&(t.state.visible&&(e=!0),u.minLevelOfDetail>=0)){if(b.skipLevelOfDetail){if(t.state.finalResolution){let e=t.state.ancestorWithContentAvailable,n=(e&&e.content?e.content:t.content).loadState;(n===`UNLOADED`||n===`LOADING`)&&(this.loaded=!1)}}else if(t.state.visible&&t.levelOfContent<=0){let e=t.content.loadState;(e===`UNLOADED`||e===`LOADING`)&&(this.loaded=!1)}}}),e&&this.tileset.selectedTiles.length===0&&this.tileset.frameNumber<500&&(this.loaded=!1),this.loaded===!0&&(this.refined=!1,this.refineProgress[1]++)}this.renderObjects.length=0,this.backfaceObjects.length=0,this.tileObjects.length=0;for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);b.skipLevelOfDetail||this.tileset.selectedTiles.sort((e,t)=>e.floor===t.floor?e.levelOfContent===t.levelOfContent?e.state.distanceToCamera===t.state.distanceToCamera?e.state.centerZDepth-t.state.centerZDepth:e.state.distanceToCamera-t.state.distanceToCamera:t.levelOfContent-e.levelOfContent:e.floor-t.floor);let w=[];for(let r of this.tileset.selectedTiles){let c=(s=(o=r.content)==null?void 0:o.data)==null?void 0:s.object;if(!c)continue;let d=c.update(e,t,n,this,r,u);if(w.push(r.id),d&&(l=!0),this.tileset.hasMixedContent&&b.skipLevelOfDetail){if(!r.state.finalResolution){let e=cloneSkipBackfaceObject(c);e.name=`skipBackface:`+c.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=STENCIL_CONSTANT.TILE_MASK|e<<STENCIL_CONSTANT.SKIP_LOD_BIT_SHIFT,n=three.GreaterEqualStencilFunc,o=STENCIL_CONSTANT.SKIP_LOD_MASK,s=three.ReplaceStencilOp,l=STENCIL_CONSTANT.TILE_MASK|STENCIL_CONSTANT.SKIP_LOD_MASK;for(let e of c.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=o,e.stencilZPass=s,e.stencilWriteMask=l}else for(let e of c.materials)e.stencilWrite=!1,e.stencilRef=STENCIL_CONSTANT.TILE_MASK,e.stencilFunc=three.AlwaysStencilFunc,e.stencilFuncMask=STENCIL_CONSTANT.TILE_MASK,e.stencilZPass=three.ReplaceStencilOp,e.stencilWriteMask=STENCIL_CONSTANT.TILE_MASK;this.tileObjects.push(c)}let T=w.toString();if(tileVersionMap.get(this)!==T&&(tileVersionMap.set(this,T),l=!0),b.skipLevelOfDetail&&this.backfaceObjects.length)for(let e=0;e<this.backfaceObjects.length;e++)this.renderObjects.push(this.backfaceObjects[e]);if(this.tileObjects.length)for(let e=0;e<this.tileObjects.length;e++)this.renderObjects.push(this.tileObjects[e]);b.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let E=[];for(let r of this.tileset.selectedTrajectories){let o=(c=r.content.data)==null?void 0:c.object;if(!o)continue;let s=o.update(e,t,n,this,r,u);E.push(r.id),s&&(l=!0),this.renderObjects.push(o)}let D=E.toString();if(trajectoryVersionMap.get(this)!==D&&(trajectoryVersionMap.set(this,D),l=!0),this.parent){let e=this.parent.children.length+1,t=(Math.min(0,this.parent.children.indexOf(this))-e)*1e4+1;for(let e=0;e<this.renderObjects.length;e++){let n=this.renderObjects[e],r=e+t;n.traverse(e=>{(e instanceof three.Mesh||e instanceof three.Line||e instanceof three.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return l}dispose(){this.disposed=!0,this.tileset.reset(),this.tileset.root.children.length=0,/^blob\:/.test(this.tileset.id)&&URL.revokeObjectURL(this.tileset.id);for(let e=this.children.length-1;e>=0;e--)this.remove(this.children[e]);this.refined=!1,this.loaded=!1,this.refineProgress[0]=this.refineProgress[1]=0,this.error=null,this.onError=void 0,this.renderer=void 0}get model(){return this.parent}get scene(){return this}get viewLayer(){return this}localToEnu(e){return e.applyMatrix4(localToEnuMatrix)}enuToLocal(e){return e.applyMatrix4(enuToLocalMatrix)}enuToEcef(e){return e.applyMatrix4(this.coordinateSystem.enuToEcefMatrix)}ecefToEnu(e){return e.applyMatrix4(this.coordinateSystem.ecefToEnuMatrix)}localToEcef(e){return this.enuToEcef(this.localToEnu(e))}ecefToLocal(e){return this.enuToLocal(this.ecefToEnu(e))}localToLla(e){return ecefToLla(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(llaToEcef(e)))}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}worldToEcef(e){return this.localToEcef(this.worldToLocal(e))}ecefToWorld(e){return this.localToWorld(this.ecefToLocal(e))}worldToLla(e){return this.localToLla(this.worldToLocal(e))}llaToWorld(e){return this.localToWorld(this.llaToLocal(e))}get coordinates(){scratchVector3$6.setScalar(0);let{x:e,y:t}=this.localToLla(scratchVector3$6);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new three.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(enuToLocalMatrix),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new three.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return scratchVector3$6.copy(e),this.worldToLla(scratchVector3$6),{latitude:scratchVector3$6.x,longitude:scratchVector3$6.y,altitude:scratchVector3$6.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minLevelOfDetail`,...e)}set minLevelOfDetail(e){this.parameter.set(`minLevelOfDetail`,e)}get maxLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxLevelOfDetail`,...e)}set maxLevelOfDetail(e){this.parameter.set(`maxLevelOfDetail`,e)}get minGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`minGeometricError`,...e)}set minGeometricError(e){this.parameter.set(`minGeometricError`,e)}get maxGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxGeometricError`,...e)}set maxGeometricError(e){this.parameter.set(`maxGeometricError`,e)}get panoramaMinGeometricError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`panoramaMinGeometricError`,...e)}set panoramaMinGeometricError(e){this.parameter.set(`panoramaMinGeometricError`,e)}get skipLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`skipLevelOfDetail`,...e)}set skipLevelOfDetail(e){this.parameter.set(`skipLevelOfDetail`,e)}get mostDetail(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`mostDetail`,...e)}set mostDetail(e){this.parameter.set(`mostDetail`,e)}get loadSiblings(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`loadSiblings`,...e)}set loadSiblings(e){this.parameter.set(`loadSiblings`,e)}get maxMemoryUsage(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxMemoryUsage`,...e)}set maxMemoryUsage(e){this.parameter.set(`maxMemoryUsage`,e)}get maxRequests(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxRequests`,...e)}set maxRequests(e){this.parameter.set(`maxRequests`,e)}get requestOrder(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`requestOrder`,...e)}set requestOrder(e){this.parameter.set(`requestOrder`,e)}get maxScreenSpaceError(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof Parameter&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},fetchers={};function getFetcher(e,t){let n=fetchers[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function registerFetcher(e,t,n){let r=fetchers[e];r||(r=fetchers[e]=new WeakMap),r.has(t)||r.set(t,n)}var identityMatrix4=new three.Matrix4,scratchVector3$5=new three.Vector3,scratchMatrix4$2=new three.Matrix4;function getEcefToEnuMatrixFromUpAxis(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:getEcefToEnuMatrix(t,n);break;default:n.identity();break}return n}function loadViewLayer(e){var t;let[n,r]=e.tilesetUrl.split(`#`),o=(t=(r||n).split(`?`)[1])==null?``:t;return e.fetcher.ajax(e.tilesetUrl,{responseType:`text`}).catch(e=>({error:e,body:JSON.stringify({asset:{version:`0.0`},geometricError:0,root:{geometricError:0}})})).then(t=>{var n;let r=`error`in t?t.error:null,s=normalizeTilesetHeader(JSON.parse(t.body),e.tilesetUrl),{root:c,rootMeta:l={}}=s,u=e.upAxis;l.upAxis&&l.upAxis!==u&&(u=l.upAxis),`lodVersion`in s&&(u=`-Y`,`floorInfo`in s&&(s.properties=s.properties||{},s.properties.floorInfo=s.floorInfo.map(e=>({ground:-e.ground,height:e.height})),s.floorInfo=void 0),s.asset.tilesetVersion=String(s.lodVersion),s.lodVersion=void 0);let d=u,f=new three.Matrix4;d===`Y`?(d=`Z`,f.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):d===`-Y`&&(d=`Z`,f.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let p=c.boundingVolume?makeBoundingVolume(c.boundingVolume):void 0;p&&c.transform&&p.applyMatrix4(scratchMatrix4$2.fromArray(c.transform));let m=null,h=new three.Matrix4,g=new three.Matrix4;return l.coordinate?(m=l.coordinate.ground_height,h.fromArray(l.coordinate.pose_ecef_to_enu),g.fromArray(l.coordinate.pose_enu_to_ecef)):(p?p.getCenter(scratchVector3$5):scratchVector3$5.setScalar(0),scratchVector3$5.applyMatrix4(f),getEcefToEnuMatrixFromUpAxis(d,scratchVector3$5,h),g.getInverse(h)),s.root={refine:(n=c.refine)==null?`REPLACE`:n,geometricError:c.geometricError,transform:scratchMatrix4$2.copy(f).premultiply(d===`Z`?identityMatrix4:h).premultiply(enuToLocalMatrix).toArray(),boundingVolume:p?p.toJson():void 0,children:[c]},new Tile3D(s,{name:e.name,type:e.type,upAxis:u,light:e.light,fetcher:e.fetcher,search:o,groundHeight:m,coordinateSystem:{enuToEcefMatrix:g,ecefToEnuMatrix:h},error:r})})}function loadViewLayers(e,t){var n;let r=e.layers.map(e=>({tilesetUrl:e.work.getURL(e.tileset),name:e.name,type:e.type,upAxis:e.upAxis,light:t.light,fetcher:t.fetcher}));if(e.file){let o=!1;for(let e of r)if(e.type===`mesh`){o=!0;break}if(o===!1){let o=getExtname(e.file)||`.at3d`,s=JSON.stringify({tilesetUrl:``,asset:{version:`0.0`},geometricError:0,root:{refine:`REPLACE`,geometricError:0,transform:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],content:{uri:e.work.getURL(e.file)},extras:{[o.slice(1)]:{upAxis:e.upAxis,textureBaseUri:typeof e.textureBase==`string`?e.work.getURL(e.textureBase):void 0,textureArray:e.textures,textureOptions:(n=t.textureOptions)==null?{}:n}}},rootMeta:{coordinate:e.coordinate}});r.push({name:`fallback`,type:`mesh`,upAxis:`Z`,tilesetUrl:URL.createObjectURL(new Blob([s],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let o=r.map(e=>loadViewLayer(e).then(e=>e));return Promise.all(o)}function createSimpleBoxBufferGeometry(e=1,t=1,n=1){let r=e/2,o=t/2,s=n/2,c=new Float32Array([-r,+o,+s,+r,+o,+s,+r,+o,-s,-r,+o,-s,-r,-o,+s,+r,-o,+s,+r,-o,-s,-r,-o,-s]),l=new Uint32Array([0,4,1,1,4,5,1,5,2,2,5,6,2,6,3,3,6,7,3,7,0,0,7,4,3,0,2,2,0,1,4,7,5,5,7,6]),u=new three.BufferGeometry;return u.setAttribute(`position`,new three.BufferAttribute(c,3)),u.setIndex(new three.BufferAttribute(l,1)),u.addGroup(0,u.index.count,0),u.computeBoundingBox(),u.computeBoundingSphere(),u}function mergeBufferGeometries(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),o=new Set(Object.keys(e[0].morphAttributes)),s={},c={},l=new three.BufferGeometry,u=0,d=0;d<e.length;++d){var f=e[d];if(n!==(f.index!==null))return null;for(var p in f.attributes){if(!r.has(p))return null;s[p]===void 0&&(s[p]=[]),s[p].push(f.attributes[p])}for(var p in f.morphAttributes){if(!o.has(p))return null;c[p]===void 0&&(c[p]=[]),c[p].push(f.morphAttributes[p])}if(l.userData.mergedUserData=l.userData.mergedUserData||[],l.userData.mergedUserData.push(f.userData),t){var m;if(n)m=f.index.count;else if(f.attributes.position!==void 0)m=f.attributes.position.count;else return null;l.addGroup(u,m,d),u+=m}}if(n){for(var h=0,g=[],d=0;d<e.length;++d){for(var _=e[d].index,v=0;v<_.count;++v)g.push(_.getX(v)+h);h+=e[d].attributes.position.count}l.setIndex(g)}for(var p in s){var y=mergeBufferAttributes(s[p]);if(!y)return null;l.setAttribute(p,y)}for(var p in c){var b=c[p][0].length;if(b===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[p]=[];for(var d=0;d<b;++d){for(var S=[],v=0;v<c[p].length;++v)S.push(c[p][v][d]);var C=mergeBufferAttributes(S);if(!C)return null;l.morphAttributes[p].push(C)}}return l}function mergeBufferAttributes(e){for(var t,n,r,o=0,s=0;s<e.length;++s){var c=e[s];if(c.isInterleavedBufferAttribute||(t===void 0&&(t=c.array.constructor),t!==c.array.constructor)||(n===void 0&&(n=c.itemSize),n!==c.itemSize)||(r===void 0&&(r=c.normalized),r!==c.normalized))return null;o+=c.array.length}for(var l=new t(o),u=0,s=0;s<e.length;++s)l.set(e[s].array,u),u+=e[s].array.length;return new three.BufferAttribute(l,n,r)}function mergeVertices(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),o=e.getAttribute(`position`),s=r?r.count:o.count,c=0,l=Object.keys(e.attributes),u={},d={},f=[],p=[`getX`,`getY`,`getZ`,`getW`],m=0,h=l.length;m<h;m++){var g=l[m];u[g]=[];var _=e.morphAttributes[g];_&&(d[g]=Array(_.length).fill().map(()=>[]))}for(var v=Math.log10(1/t),y=Math.pow(10,v),m=0;m<s;m++){for(var b=r?r.getX(m):m,S=``,C=0,h=l.length;C<h;C++)for(var g=l[C],w=e.getAttribute(g),T=w.itemSize,E=0;E<T;E++)S+=`${~~(w[p[E]](b)*y)},`;if(S in n)f.push(n[S]);else{for(var C=0,h=l.length;C<h;C++)for(var g=l[C],w=e.getAttribute(g),_=e.morphAttributes[g],T=w.itemSize,D=u[g],O=d[g],E=0;E<T;E++){var k=p[E];if(D.push(w[k](b)),_)for(var A=0,j=_.length;A<j;A++)O[A].push(_[A][k](b))}n[S]=c,f.push(c),c++}}let M=e.clone();for(var m=0,h=l.length;m<h;m++){var g=l[m],N=e.getAttribute(g),P=new N.array.constructor(u[g]),w=new three.BufferAttribute(P,N.itemSize,N.normalized);if(M.setAttribute(g,w),g in d)for(var C=0;C<d[g].length;C++){var F=e.morphAttributes[g][C],P=new F.array.constructor(d[g][C]),I=new three.BufferAttribute(P,F.itemSize,F.normalized);M.morphAttributes[g][C]=I}}return M.setIndex(f),M}var scratchSphere$1=new three.Sphere,scratchMatrix4$1=new three.Matrix4,scratchMatrix4Inverse=new three.Matrix4;function getEdgesBySphere(e,t,n=30/180*Math.PI){let r=Math.cos(n),o=[];for(let n of e.children)n instanceof Tile3D&&n.tileset.selectedTiles.forEach(e=>{var n,s,c;let l=(s=(n=e.content)==null?void 0:n.data)==null?void 0:s.object;if(l&&l.visible){let e=[];if(l.traverseVisible(n=>{if(n instanceof three.Mesh){let r=getBvhTreeForMesh(n);if(r){scratchMatrix4$1.copy(n.matrixWorld),scratchMatrix4Inverse.getInverse(scratchMatrix4$1),scratchSphere$1.copy(t).applyMatrix4(scratchMatrix4Inverse);let o=r.trianglesInSphere(scratchSphere$1.center,scratchSphere$1.radius),s=new three.BufferGeometry;s.setAttribute(`position`,new three.BufferAttribute(o,3)),s.applyMatrix4(n.matrixWorld),s=mergeVertices(s,.01),e.push(s)}}}),e.length===0)return;let n=[`a`,`b`,`c`],s=mergeBufferGeometries(e,!1),u=s.getAttribute(`position`).array,d=((c=s.getIndex())==null?void 0:c.array)||[],f=[],p=[];for(let e=0,t=u.length;e<t;e+=3){let t=new three.Vector3(u[e],u[e+1],u[e+2]);f.push(t)}for(let e=0,t=d.length;e<t;e+=3){let t=d[e],n=d[e+1],r=d[e+2],o=new three.Vector3().crossVectors(f[n].clone().sub(f[t]),f[r].clone().sub(f[t])).normalize();p.push({a:t,b:n,c:r,normal:o})}let m={};for(let e=0,t=p.length;e<t;e++){let t=p[e];for(let r=0;r<3;r++){let o=t[n[r]],s=t[n[(r+1)%3]],c=[Math.min(o,s),Math.max(o,s)],l=c[0]+`-`+c[1];m[l]===void 0?m[l]={index1:c[0],index2:c[1],face1:e}:m[l].face2=e}}for(let e in m){let t=m[e];if(t.face2===void 0||p[t.face1].normal.dot(p[t.face2].normal)<=r){let e=f[t.index1],n=f[t.index2];o.push(new three.Line3(e,n))}}f.length=0,p.length=0}});return o}var scratchBoundingBox$1=new three.Box3,scratchViewLayerBox=new three.Box3,scratchObserverBox$3=new three.Box3,Model=class extends three.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new Parameter,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new three.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let o=0;for(let e of t.observers)o=Math.max(o,e.floorIndex);if(this.floorLength=o+1,t.model){this.metaPending=!0;let e=loadViewLayers(t.model,{fetcher:getFetcher(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),o=e=>this.dispatchEvent({type:`error`,error:e}),s=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),c=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,l=null;for(let t of e){if(t.visible=!1,t.onError=o,t.onTileLoad=s,t.onTileUnload=c,t.error){o(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):l===null&&(l=t)}let u=(t=n==null?r:n)==null?l:t;if(u&&(u.visible=!0),e.length)if(this.disposed)for(let t of e)t.dispose();else this.add(...e);return this}),this.loadedReady=new Promise(e=>{let t=()=>{e(this),this.removeEventListener(`load`,t),this.removeEventListener(`dispose`,t)};this.addEventListener(`load`,t),this.addEventListener(`dispose`,t)})}else this.refined=!0,this.loaded=!0,this.initReady=Promise.resolve(this),this.loadedReady=Promise.resolve(this);this.parameter.set(`boundingBox`,this.boundingBox.clone())}dispose(){this.disposed=!0;let e;for(;e=this.children[0];)typeof e.dispose==`function`&&e.dispose(),e.onError=void 0,e.onTileLoad=void 0,e.onTileUnload=void 0,this.remove(e);this.dispatchEvent({type:`dispose`})}get empty(){return this.children.length===0}get viewLayers(){return this.children}getEdgesBySphere(e,t=30/180*Math.PI){return getEdgesBySphere(this,e,t)}intersectRaycaster(e,t){let n=t==null?[]:t,r=e.sortByDistance;e.sortByDistance=!1;for(let t=0,r=this.children.length;t<r;t++){let r=this.children[t];r.visible&&typeof r.intersectRaycaster==`function`&&r.intersectRaycaster(e,n)}return e.sortByDistance=r,sortIntersects(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let o=this.loaded;this.refined=!this.metaPending,this.loaded=!this.metaPending,this.refineProgress[0]=this.refineProgress[1]=0,this.work.transform.equals(this.matrix)||(this.matrix.copy(this.work.transform),this.matrix.decompose(this.position,this.quaternion,this.scale),this.matrixAutoUpdate=!1,r=!0);for(let o of this.children)o.autoRefine=this.autoRefine,o.update(e,t,n,this)&&(r=!0),o.refined===!1&&(this.refined=!1),o.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=o.refineProgress[0],this.refineProgress[1]+=o.refineProgress[1];scratchBoundingBox$1.makeEmpty(),scratchObserverBox$3.copy(this.work.observerBox),scratchObserverBox$3.isEmpty()||(scratchObserverBox$3.max.x+=1,scratchObserverBox$3.max.z+=1,scratchObserverBox$3.max.y+=1,--scratchObserverBox$3.min.x,--scratchObserverBox$3.min.z,scratchBoundingBox$1.union(scratchObserverBox$3));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(scratchViewLayerBox.copy(e.boundingBox),scratchBoundingBox$1.union(scratchViewLayerBox));return scratchBoundingBox$1.applyMatrix4(this.matrix),scratchBoundingBox$1.equals(this.boundingBox)||(this.boundingBox.copy(scratchBoundingBox$1),this.parameter.set(`boundingBox`,scratchBoundingBox$1.clone())),o===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(localToEnuMatrix)}enuToLocal(e){return e.applyMatrix4(enuToLocalMatrix)}worldToEnu(e){return this.localToEnu(this.worldToLocal(e))}enuToWorld(e){return this.localToWorld(this.enuToLocal(e))}get shownFloor(){return this.shownFloorIndex===-1?null:this.shownFloorIndex}set shownFloor(e){this.shownFloorIndex=e===null?-1:e}show(e){this.shownFloor=e==null?null:e,this.dispatchEvent({type:`changeShownFloor`,floorIndex:e==null?null:e})}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`shownFloorIndex`,...e)}set shownFloorIndex(e){this.parameter.set(`shownFloorIndex`,e)}get brightness(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`brightness`,...e)}set brightness(e){this.parameter.set(`brightness`,e)}get clippers(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`clippers`,...e)}set clippers(e){this.parameter.set(`clippers`,e)}get customShaders(){let e=[];return this.parent&&this.parent.parameter instanceof Parameter&&e.unshift(this.parent.parameter),this.parameter.resolveValue(`customShaders`,...e)}set customShaders(e){this.parameter.set(`customShaders`,e)}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.viewLayers)e.resetBrightness()}},scratchGeometry=createSimpleBoxBufferGeometry(1,1,1);scratchGeometry.applyMatrix4(new three.Matrix4().makeScale(-1,1,1));var parameterValueVersionMap=new WeakMap,cameraBoxSize=new three.Vector3(1,1,1),scratchBoundingBox=new three.Box3,scratchBoundingBoxSize=new three.Vector3,scratchCameraBox=new three.Box3,scratchPosition=new three.Vector3,scratchScale=new three.Vector3,BoundingMesh=class extends PBMMesh{constructor(e={}){var t;let n=new PBMMeshMaterial(`none`);n.flatShading=!0,n.depthWrite=!1,n.transparent=!1,n.blending=three.CustomBlending,n.blendSrc=three.SrcAlphaFactor,n.blendDst=three.OneMinusSrcAlphaFactor,n.blendSrcAlpha=three.OneFactor,n.blendDstAlpha=three.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(scratchGeometry,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999,this.currentResolvedParameterValue=Parameter.resolveValueTo({})}update(e,t,n){var r,o;let s=!1,c=Parameter.resolveValueTo(this.currentResolvedParameterValue,n.parameter);scratchBoundingBox.copy(c.boundingBox),scratchBoundingBox.getSize(scratchBoundingBoxSize);let l=Math.min(scratchBoundingBoxSize.x/2,500);scratchBoundingBox.min.x-=l,scratchBoundingBox.max.x+=l;let u=Math.min(scratchBoundingBoxSize.y/2,500);scratchBoundingBox.min.z-=u,scratchBoundingBox.max.z+=u;let d=scratchBoundingBoxSize.length()/2;if(scratchBoundingBox.max.y=Math.max(scratchBoundingBox.max.y,d),scratchBoundingBox.union(scratchCameraBox.setFromCenterAndSize(t.position,cameraBoxSize)),scratchBoundingBox.expandByScalar(1),scratchBoundingBox.getCenter(scratchPosition),scratchBoundingBox.getSize(scratchScale),scratchPosition.equals(this.position)||(this.position.copy(scratchPosition),s=!0),scratchScale.equals(this.scale)||(this.scale.copy(scratchScale),s=!0),parameterValueVersionMap.get(this)!==c.versionNumber){parameterValueVersionMap.set(this,c.versionNumber),s=!0;let e=this.material;for(let t of e)t.customShaders=c.customShaders,t.pano0=c.pano0,t.pano1=c.pano1,t.panoFilter=(o=(r=c.panoFilter)==null?void 0:r.toValue())==null?null:o,t.refinedScreen=c.refinedScreen,t.modelAlpha=c.modelAlpha,t.progress=c.progress,t.transition=c.transition,t.opacity=c.opacity,t.floorStyle=c.floorStyle,t.constantColor=c.constantColor,t.shownFloorIndex=c.shownFloorIndex,t.clippers=c.clippers,t.brightness=c.brightness,t.useHQWeight=c.useHQWeight,t.useHQDepth=c.useHQDepth,t.colorSaturation=c.colorSaturation,t.colorBrightness=c.colorBrightness,t.gradientTexture=c.gradientTexture,t.transparent=!1,t.modelBoundingMax.copy(c.boundingBox.max),t.modelBoundingMin.copy(c.boundingBox.min),c.useAddBlend&&(t.opacity=0),t.opacity===0&&(t.visible=!1)}return s}dispose(){for(let e of this.material)e.dispose(),e.pano0=null,e.pano1=null}},scratchBoundingBox3=new three.Box3,ModelScene=class extends three.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new three.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new Parameter,this.fiveId=e.fiveId,this.boundingMesh=new BoundingMesh({name:`bounding`}),this.add(this.boundingMesh);let t=this.models=[];this.shownModels=[],this.updateModelMap=new Map,this.parameter.set(`boundingBox`,this.boundingBox.clone());let n=this;defineProperty(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),defineProperty(t,`bounding`,{get(){return n.boundingBox}}),defineProperty(t,`loaded`,{get(){return n.loaded}}),defineProperty(t,`refined`,{get(){return n.refined}}),defineProperty(t,`refineProgress`,{get(){return n.refineProgress}}),defineProperty(t,`cacheCameras`,{get(){return n.parameter.resolveValue(`cacheCameras`)},set(e){n.parameter.set(`cacheCameras`,e)}}),defineProperty(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),defineProperty(t,`setMaterial`,{value:e=>n.setMaterial(e)}),defineProperty(t,`getMaterial`,{value:()=>n.getMaterial()}),defineProperty(t,`resetBrightness`,{value:()=>n.resetBrightness()})}setModels(e,t){let n=e.map(e=>{let n=this.shownModels.filter(t=>t.work.workCode===e.workCode)[0];if(n||(n=this.models.filter(t=>t.work.workCode===e.workCode)[0],n))return n.work=e,n;n=new Model(this.fiveId,e,{light:t.light,textureOptions:t.textureOptions});let r=t[`3d-tiles`];return n.initReady.then(()=>{if(r)if(typeof r==`function`)for(let e of n.viewLayers){let t=r(e,n);t&&(t.viewerRequestVolume&&(e.viewerRequestVolume=makeBoundingVolume(t.viewerRequestVolume)),e.parameter.set(omit(t,[`showLayers`])),t.showLayers===!1?e.visible=!1:Array.isArray(t.showLayers)&&(e.visible=t.showLayers.includes(e.name)))}else for(let e of n.viewLayers)r.viewerRequestVolume&&(e.viewerRequestVolume=makeBoundingVolume(r.viewerRequestVolume)),e.parameter.set(omit(r,[`showLayers`])),r.showLayers===!1?e.visible=!1:Array.isArray(r.showLayers)&&(e.visible=r.showLayers.includes(e.name))}),this.dispatchEvent({type:`model.create`,model:n}),n});for(let e=0;e<this.models.length;e++){let t=this.models[e];n.indexOf(t)===-1&&this.shownModels.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.models.length=0;for(let e=0;e<n.length;e++){let t=n[e];this.models.push(t)}if(t.forceReplaceImmediately&&!arrayEqual(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e])}return this.loaded=!1,this.refined=!1,this.models}get empty(){return this.boundingBox.isEmpty()}intersectRaycaster(e,t){let n=t==null?[]:t,r=this.shownModels.filter(e=>e.visible);if(r.length===1)r[0].intersectRaycaster(e,n);else{let t=e.sortByDistance;e.sortByDistance=!1;for(let t of r)t.intersectRaycaster(e,n);e.sortByDistance=t,sortIntersects(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;scratchBoundingBox3.makeEmpty(),this.loaded=this.models.length>0,this.refined=this.models.length>0,this.refineProgress[0]=this.refineProgress[1]=0,this.updateModelMap.clear();for(let n=0;n<this.models.length;n++){let r=this.models[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;this.autoRefine===!1&&(r.autoRefine=!1);let o=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,o)}r.loaded===!1&&(this.loaded=!1),r.refined===!1&&(this.refined=!1),this.refineProgress[0]+=r.refineProgress[0],this.refineProgress[1]+=r.refineProgress[1]}if((this.loaded===!0||this.models.length===0)&&!arrayEqual(this.models,this.shownModels)){for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.models.indexOf(t)===-1&&(t.dispose(),this.dispatchEvent({type:`model.dispose`,model:t}))}this.shownModels.length=0;for(let e=0;e<this.models.length;e++)this.shownModels.push(this.models[e]);n=!0}for(let n=0;n<this.shownModels.length;n++){let r=this.shownModels[n];if(!this.updateModelMap.has(r)){let n=r.autoRefine;(this.autoRefine===!1||this.models.indexOf(r)<0)&&(r.autoRefine=!1);let o=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,o)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Model&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),scratchBoundingBox3.union(t.boundingBox),this.add(t)}for(let e=0;e<this.models.length;e++){let t=this.models[e];this.shownModels.indexOf(t)===-1&&scratchBoundingBox3.union(t.boundingBox)}return scratchBoundingBox3.equals(this.boundingBox)||(this.boundingBox.copy(scratchBoundingBox3),this.parameter.set(`boundingBox`,this.boundingBox.clone()),n=!0),this.boundingMesh.update(e,t,this)&&(n=!0),this.updateModelMap.clear(),this.needsRender=n,n}get bounding(){return this.boundingBox}setMaterial(e){this.parameter.set(e)}getMaterial(){return this.parameter.resolveValue()}resetBrightness(){this.parameter.reset(`brightness`);for(let e of this.models)e.resetBrightness()}dispose(){this.remove(this.boundingMesh),this.boundingMesh.dispose();for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Model&&this.remove(t)}let e=arrayUnique(this.models.concat(this.shownModels));for(let t=0;t<this.shownModels.length;t++)e[t].dispose();this.models.length=0,this.shownModels.length=0,super.dispose()}};function workInitialToJson(e){let t={};return e.mode!==void 0&&(t.mode=e.mode),e.panoIndex!==void 0&&(t.pano_index=e.panoIndex),e.longitude!==void 0&&(t.longitude=e.longitude),e.latitude!==void 0&&(t.latitude=e.latitude),e.fov!==void 0&&(t.fov=e.fov),e.distance!==void 0&&(t.distance=e.distance),e.offset!==void 0&&(t.offset=e.offset.toArray()),t}function workModelToJson(e){var t;if(e)return{file_url:e.file,material_base_url:e.textureBase,material_textures:(t=e.textures)==null?void 0:t.slice(),up_axis:e.upAxis,layers:e.layers.map(e=>({tileset_url:e.tileset,up_axis:e.upAxis,name:e.name,type:e.type}))}}function workObserverToObserverJson(e){return{index:e.index,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,floor_index:e.floorIndex,position:e.position.toArray(),standing_position:e.standingPosition.toArray(),quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w},visible_nodes:e.accessibleNodes.slice(),accessible_nodes:e.accessibleNodes.slice()}}function workObserverToPanoramaJson(e){return{index:e.index,active:e.active,loadable:e.loadable,derived_id:e.derivedId,derived_id_str:e.derivedIdStr,size_list:e.images.sizeList.slice(),up:e.images.up,down:e.images.down,right:e.images.right,left:e.images.left,front:e.images.front,back:e.images.back,video:e.images.video?{matrix:e.images.video.matrix.toArray(),size:e.images.video.size.toArray(),source:e.images.video.source}:void 0}}function workToJson(e){return{allow_hosts:e.allowHosts.slice(),expire_at:e.expire.getTime().toString(),project_id:e.projectId,code:e.workCode,name:e.name,base_url:e.baseURL,initial:workInitialToJson(e.initial),model:workModelToJson(e.model),observers:e.observers.map(e=>workObserverToObserverJson(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>workObserverToPanoramaJson(e))}}}function equirectangularUvToCubemap(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),o=Math.cos(n),s=Math.sin(t),c=Math.cos(t),l=o*s,u=r,d=o*c,f=Math.abs(l),p=Math.abs(u),m=Math.abs(d),h,g;if(f>=p&&f>=m){let e=1/f;l>0?(h=`right`,g=new three.Vector2(-d*e,u*e)):(h=`left`,g=new three.Vector2(d*e,u*e))}else if(p>=f&&p>=m){let e=1/p;u>0?(h=`up`,g=new three.Vector2(l*e,-d*e)):(h=`down`,g=new three.Vector2(l*e,d*e))}else{let e=1/m;d>0?(h=`front`,g=new three.Vector2(l*e,u*e)):(h=`back`,g=new three.Vector2(-l*e,u*e))}return g.x=(g.x+1)/2,g.y=1-(g.y+1)/2,[h,g]}function cubemapUvToEquirectangular(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,o=0,s=0,c=0;switch(e){case`right`:o=1,s=r,c=-n;break;case`left`:o=-1,s=r,c=n;break;case`up`:o=n,s=1,c=-r;break;case`down`:o=n,s=-1,c=r;break;case`front`:o=n,s=r,c=1;break;case`back`:o=-n,s=r,c=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let l=Math.sqrt(o*o+s*s+c*c);if(l===0)return new three.Vector2(.5,.5);o/=l,s/=l,c/=l;let u=Math.atan2(o,c),d=Math.asin(Math.max(-1,Math.min(1,s))),f=(u+Math.PI)/(2*Math.PI),p=(Math.PI/2-d)/Math.PI;return f%=1,f=f<0?f+1:f,p=Math.max(0,Math.min(1,p)),new three.Vector2(f,p)}var workObserverProto={vectorToEquirectangularUv(e,t=`top-left`){let n=new three.Quaternion().setFromRotationMatrix(this.work.transform).inverse(),r=new three.Quaternion().copy(this.quaternion).inverse(),o=new three.Quaternion(0,1,0,0).inverse(),s=new three.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(o),c=Math.atan2(s.x,-s.z),l=Math.asin(-s.y);if(t===`top-left`)return new three.Vector2(c/(Math.PI*2)+.5,l/Math.PI+.5);if(t===`bottom-left`)return new three.Vector2(c/(Math.PI*2)+.5,.5-l/Math.PI);throw Error(`Invalid uvOrigin ${t}`)},vectorToCubemapUv(e,t=`top-left`){let n=equirectangularUvToCubemap(this.vectorToEquirectangularUv(e,`top-left`));if(t===`top-left`)return n;if(t===`bottom-left`){let[e,t]=n;return t.y=1-t.y,n}else throw Error(`Invalid uvOrigin ${t}`)},equirectangularUvToVector(e,t=`top-left`){let n=0;if(t===`top-left`)n=1;else if(t===`bottom-left`)n=-1;else throw Error(`Invalid uvOrigin ${t}`);let r=new three.Quaternion().setFromRotationMatrix(this.work.transform),o=new three.Quaternion().copy(this.quaternion),s=new three.Quaternion(0,1,0,0),c=Math.PI*2*(e.x+.5),l=Math.PI*(e.y-.5),u=Math.abs(Math.cos(l)),d=Math.sin(c)*u,f=-Math.sin(l)*n,p=-Math.cos(c)*u;return new three.Vector3(d,f,p).applyQuaternion(s).applyQuaternion(o).applyQuaternion(r)},cubemapUvToVector(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new three.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let o=cubemapUvToEquirectangular(e,r);return this.equirectangularUvToVector(o)},getWorldPosition(){return new three.Vector3().copy(this.position).applyMatrix4(this.work.transform)},getWorldStandingPosition(){return new three.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}};function isNumber(e){return typeof e==`number`}function jsonClone(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:jsonClone(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:jsonClone(r)}return t}}function getType(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function jsonMerge(e,t){let n=getType(e),r=getType(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return jsonClone(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=jsonMerge(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=jsonMerge(e[n],t[n]);return e}function jsonStableStrinfiy_(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=jsonStableStrinfiy_(e[r],!1)+`,`;return n>-1&&(t+=jsonStableStrinfiy_(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return jsonStableStrinfiy_(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,o=``,s=0;for(;s<r;){let t=n[s],r=jsonStableStrinfiy_(e[t],!0);r!==void 0&&(s&&o!==``&&(o+=`,`),o+=JSON.stringify(t)+`:`+r),s++}return`{`+o+`}`}switch(n){case`function`:return JSON.stringify(e.toString());case`undefined`:return t?void 0:null;case`number`:return e;default:return isFinite(e)?e:null}}function jsonStableStrinfiy(e){return jsonStableStrinfiy_(e,!1)}function jsonHash(e){return`hash::${sha256(jsonStableStrinfiy(e))}`}var PANO_ID_REG=/^(.*)\[(\d+)\]$/;function panoStringify(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function panoParse(e){let t=e.match(PANO_ID_REG);if(t){let[e,n,r]=t,o=Math.floor(Number(r));if(!isNaN(o)&&isFinite(o))return{workCode:n,panoIndex:o}}throw Error(`Invalid PanoId`)}function panoEqual(e,t){return panoStringify(e)===panoStringify(t)}function isPanoId(e){return typeof e==`string`&&PANO_ID_REG.test(e)}var REG_STR=`\\{([^\\}]+)\\}`;function escapeRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function createRegExp(e){return RegExp(`^`+e.map(e=>escapeRegexp(e)).join(`(.+)`)+`$`)}var StringPattern=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(REG_STR,`g`),n,r=0;for(;(n=t.exec(e))!==null;)this.strings.push(e.slice(r,n.index)),this.keys.push(n[1]),r=n.index+n[0].length;this.strings.push(e.slice(r))}stringify(e){let t=[this.strings[0]];for(let n=0;n<this.keys.length;n++){let r=e[this.keys[n]];t.push(String(r),this.strings[n+1])}return t.join(``)}match(e){var t;this.matchRegexp=(t=this.matchRegexp)==null?createRegExp(this.strings):t;let n=e.match(this.matchRegexp);if(!n)return null;let r={};for(let e=0;e<this.keys.length;e++){let t=this.keys[e],o=n[e+1];if(r[t]!==o){if(r[t]!==void 0)return null;r[t]=o}}return r}};function deepFreeze(e){Object.freeze(e);let t=typeof e==`function`,n=Object.prototype.hasOwnProperty;return Object.getOwnPropertyNames(e).forEach(function(r){n.call(e,r)&&(!t||r!==`caller`&&r!==`callee`&&r!==`arguments`)&&e[r]!==null&&(typeof e[r]==`object`||typeof e[r]==`function`)&&!Object.isFrozen(e[r])&&deepFreeze(e[r])}),e}var URL_REGEXP=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,BUILDIN_ALLOW_HOST=deepFreeze(JSON.parse(function(...e){let t=113,n=126,r=0,o=``;return arguments[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`h/y|pnyu|/9/xr;p|z/9/yvn{wvn;p|z/9/rnyrr;p|z/9/rnyrr;p{/9/rnyrr;w}/9/uv;p|z/9/uv;p{/9/rnyrr;p{/9/rnyrr;p|z/9/ywpq{;p|z/9/rnyrr:pq{;p|z/9/rnyrr:pq{;p{/9/rnyrr;nv/9/;p{/9/pq{;p{/9/pnyp{|qr;vr/j`))),domainRegex=/^([^.]+)(\.([^.]+))*$/,currentHostname=typeof location<`u`?location.hostname:`localhost`;function isIPDomain(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function matchDomain(e,t){if(!domainRegex.test(e)||!domainRegex.test(t))return!1;if(e===`*`)return!0;let n=e.split(`.`).reverse(),r=t.split(`.`).reverse();if(n.length<=1)return e===t;for(let e=0;e<n.length;e++)if(n[e]!==r[e])return!1;return!0}function hostnameFromURL(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return currentHostname;let t=e.match(URL_REGEXP);return t?t[2]:currentHostname}var error_invalid_input=()=>Error(`Invalid input.`),error_invalid_certificate=()=>Error(`Invalid certificate.`),error_invalid_signature=()=>Error(`Invalid signature.`),error_date_expired=e=>Error(`Date(${e.toString()}) expired.`),error_host_not_allowed=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function ObjectOmit(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function jsonStableNoneNumberStrinfiy_(e,t=!1){let n=typeof e;if(n===`string`)return JSON.stringify(e);if(e===!0)return`true`;if(e===!1)return`false`;if(e===null)return`null`;if(e instanceof Array){let t=`[`,n=e.length-1,r=0;for(;r<n;r++)t+=jsonStableNoneNumberStrinfiy_(e[r],!1)+`,`;return n>-1&&(t+=jsonStableNoneNumberStrinfiy_(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return jsonStableNoneNumberStrinfiy_(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,o=``,s=0;for(;s<r;){let t=n[s],r=jsonStableNoneNumberStrinfiy_(e[t],!0);r!==void 0&&(s&&o!==``&&(o+=`,`),o+=JSON.stringify(t)+`:`+r),s++}return`{`+o+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function jsonStableNoneNumberStrinfiy(e){return String(jsonStableNoneNumberStrinfiy_(e,!1))}function verify(e){var t,n,r;let o={};try{o=typeof e==`string`?JSON.parse(e):e}catch(e){return error_invalid_input()}if(typeof o!=`object`)return error_invalid_input();let s=currentHostname,c=Date.now(),l=new Date(typeof o.expire_at==`string`&&/^\d+$/.test(o.expire_at)?Number(o.expire_at):o.expire_at),u=Array.isArray(o.allow_hosts)?o.allow_hosts:[];if(s.length===0||isIPDomain(s)||BUILDIN_ALLOW_HOST.filter(e=>matchDomain(e,s)).length>0){let e=String((t=o.certificate)==null?``:t);if(e)try{let t=new X509;return t.readCertPEM(e),deepFreeze({issuer:t.getSubjectString(),expire:l,allowHosts:u})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return deepFreeze({issuer:`none`,expire:l,allowHosts:u})}let d=String((n=o.certificate)==null?``:n);if(!d)return error_invalid_certificate();let f=new X509;f.readCertPEM(d);let p=String((r=o._signature)==null?``:r);return!p||verifyMessage(jsonStableNoneNumberStrinfiy(ObjectOmit(o,[`_signature`])),p,f)===!1?error_invalid_signature():c<l.getTime()?BUILDIN_ALLOW_HOST.concat(u).filter(e=>matchDomain(e,s)).length===0?error_host_not_allowed(s):deepFreeze({issuer:f.getSubjectString(),expire:l,allowHosts:u}):error_date_expired(l)}function verifyURL(e,t){let n=hostnameFromURL(e);return currentHostname.length!==0&&!isIPDomain(currentHostname)&&BUILDIN_ALLOW_HOST.filter(e=>matchDomain(e,currentHostname)).length===0&&!isIPDomain(n)&&BUILDIN_ALLOW_HOST.concat(t).filter(e=>matchDomain(e,n)).length===0?error_host_not_allowed(n):e}var accessibleNodesSet=new Set,PANO_TEXTURE_SCALE=new three.Vector3(1,1,1),FACE_ORDER$1=[`right`,`left`,`up`,`down`,`front`,`back`];function relativeURL(e,t){if(!isAbsoluteURL(e))return e;if(e.indexOf(t)===0)return e.slice(t.length);let n=t.replace(/^https\:/,`http:`);if(e.indexOf(n)===0)return e.slice(n.length);let r=t.replace(/^http\:/,`https:`);return e.indexOf(r)===0?e.slice(r.length):(console.warn(`${e} is not start with base_url(${t}).`),e)}function panoURL(e,t,n){return!isAbsoluteURL(e)&&typeof t==`string`&&t.length>0&&(e=pathJoin(t,String(n),e)),e}function getTileLevel(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function sortTile(e){e=e.slice().sort((e,t)=>e.level-t.level);let t=[];for(let n of e){if(t.length===0){t.push(n);continue}let e=t[t.length-1];if(n.level>e.level){t.push(n);continue}if(n.size>e.size){t[t.length-1]=n;continue}}return t}function parse(e,t){var n,r,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,S,C;let w=[],T=null;for(let t of[].concat(e))if(`getURL`in t)T={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},w.push(workToJson(t));else{let e=typeof t==`string`?JSON.parse(t):jsonClone(t),n=verify(e);if(n instanceof Error)return n;T===null&&(T=n),w.push(e)}if(T===null)return Error(`Empty`);defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:T.issuer}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(T.expire)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(T.allowHosts)});let E=w.reduce((e,t)=>jsonMerge(e,t));defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=E.name)==null?`Unknown`:n)}),defineProperty(t,`workCode`,{enumerable:!0,writable:!0,value:String(E.resource_code||E.basic_code||E.vr_code||E.code||E.project_id||E.work_code||E.workCode||createUuid())}),defineProperty(t,`projectId`,{enumerable:!0,writable:!0,value:E.project_id}),defineProperty(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=E.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let D;typeof E.model==`object`&&(D={},defineProperty(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(D,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=E.model.file_url;if(e)return relativeURL(e,t.baseURL)})()}),defineProperty(D,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=E.model.material_base_url;return e&&(e=relativeURL(e,t.baseURL)),e})()}),defineProperty(D,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(E.model.material_textures)&&(e=E.model.material_textures.slice(),Object.freeze(e)),e})()}),defineProperty(D,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:E.model.up_axis}),defineProperty(D,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:jsonClone(E.model.coordinate)}),defineProperty(D,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let o=[];if(Array.isArray(E.model.layers)){for(let s of E.model.layers)if(s&&s.tileset_url){let c={};defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=s.name)==null?``:e}),defineProperty(c,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=s.type)==null?`mesh`:n}),defineProperty(c,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=s.up_axis)==null?`Z`:r}),defineProperty(c,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:relativeURL(s.tileset_url,t.baseURL)}),o.push(c)}}if(typeof E.model.tiles==`object`){let e=E.model.tiles;if(e&&e.tileset_url){let n={};defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),defineProperty(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),defineProperty(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),defineProperty(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:relativeURL(e.tileset_url,t.baseURL)}),o.push(n)}}return Object.freeze(o)})()})),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:D});let O=[];if(Array.isArray(E.observers)&&E.panorama&&Array.isArray(E.panorama.list||E.panorama.info)){let e=E.observers,n=(r=E.panorama.list||E.panorama.info)==null?[]:r,w=(d=(l=(s=(o=E.panorama)==null?void 0:o.pano_high_cube_base_url)==null?(c=E.panorama)==null?void 0:c.pano_cube_base_url:s)==null?(u=E.panorama)==null?void 0:u.base_url:l)==null?``:d,T=Math.min(e.length,n.length),D={};for(let e of Object.keys((f=E.panorama.pattern)==null?{}:f)){let t=e,n=E.panorama.pattern[t];if(typeof n==`string`){let e=new StringPattern(n);D[t]=t=>e.stringify(t)}else D[t]=()=>n}let k=(e,t)=>{var n;let r=D[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<T;r++){let o=e[r],s=n[r],c=Object.create(workObserverProto);defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),defineProperty(c,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),defineProperty(c,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:panoStringify({workCode:t.workCode,panoIndex:r})}),defineProperty(c,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(p=o.floor_index)==null?o.floor:p}),defineProperty(c,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(h=(m=o.derived_id)==null?k(s,`derived_id`):m)==null?0:h}),defineProperty(c,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(_=(g=o.derived_id_str)==null?k(s,`derived_id_str`):g)==null?String(c.derivedId):_}),defineProperty(c,`active`,{enumerable:!0,configurable:!1,writable:!1,value:o.active!==!1&&k(s,`active`)!==!1}),defineProperty(c,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(y=(v=o.loadable)==null?k(s,`loadable`):v)==null?!1:y}),defineProperty(c,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Vector3().fromArray((b=o.position)==null?[0,0,0]:b))}),defineProperty(c,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Vector3().fromArray((C=(S=o.standing_position)==null?o.standingPosition:S)==null?[0,0,0]:C))}),defineProperty(c,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Quaternion().fromArray(o.quaternion?[o.quaternion.x,o.quaternion.y,o.quaternion.z,o.quaternion.w]:[0,0,0,1]))}),defineProperty(c,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new three.Matrix4().compose(c.position,c.quaternion,PANO_TEXTURE_SCALE))}),defineProperty(c,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(accessibleNodesSet.clear(),o.accessible_nodes&&Array.isArray(o.accessible_nodes))for(let e of o.accessible_nodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.accessibleNodes&&Array.isArray(o.accessibleNodes))for(let e of o.accessibleNodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.visible_nodes&&Array.isArray(o.visible_nodes))for(let e of o.visible_nodes)e>=T||e===r||accessibleNodesSet.add(e);else if(o.visibleNodes&&Array.isArray(o.visibleNodes))for(let e of o.visibleNodes)e>=T||e===r||accessibleNodesSet.add(e);if(accessibleNodesSet.size===0)for(let e=0;e<T;e++)e!==r&&accessibleNodesSet.add(e);let e=Array.from(accessibleNodesSet);return accessibleNodesSet.clear(),Object.freeze(e)})()}),defineProperty(c,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:c.accessibleNodes}),defineProperty(c,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of FACE_ORDER$1)defineProperty(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return relativeURL(panoURL((e=k(s,n))==null?``:e,w,r),t.baseURL)})()});return defineProperty(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=getImageSizeFromURL(e[FACE_ORDER$1[0]]),n=k(s,`size_list`),r=k(s,`tiles`);if(t){if(n){let e=n.slice().sort((e,t)=>e-t);return Object.freeze(e)}else if(r){let e=[t],n=r.slice().sort((e,t)=>e-t);for(let r of n){let n=512*Math.pow(2,r);n>t&&e.push(n)}return Object.freeze(e)}return Object.freeze([t])}return Object.freeze([])})()}),defineProperty(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=getImageSizeFromURL(e.front);if(!n)return;let r=e.sizeList.slice();if(r[0]){let e=getTileLevel(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let o=[];for(let s of r){let r=getTileLevel(s);if(typeof r!=`number`)continue;let c={};if(defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),s>n){defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of FACE_ORDER$1)defineProperty(c,t,{enumerable:!0,configurable:!1,writable:!1,value:replaceImageSize(e[t],s)})}else{defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/n});for(let t of FACE_ORDER$1)defineProperty(c,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]})}o.push(c)}return o=sortTile(o),Object.freeze(o)})()}),defineProperty(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=k(s,`video`),n;return e&&(n={},defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),defineProperty(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Matrix4().fromArray(e.matrix)}),defineProperty(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector2().fromArray(e.size)})),n})()}),e})()}),O.push(c)}}defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(O)});let k={};if(defineProperty(k,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),E.initial){if(t.observers.length>0){let e;isNumber(E.initial.panoIndex)?e=E.initial.panoIndex:isNumber(E.initial.pano_index)?e=E.initial.pano_index:isNumber(E.initial.pano)&&(e=E.initial.pano),typeof e==`number`&&(e=clamp$1(e,0,t.observers.length-1),defineProperty(k,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(E.initial.mode===`Panorama`&&t.observers.length===0||E.initial.mode===`Floorplan`||E.initial.mode===`Topview`||E.initial.mode===`Model`||E.initial.mode===`Mapview`?defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:E.initial.mode}):typeof k.panoIndex==`number`?defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):defineProperty(k,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),isNumber(E.initial.latitude)&&defineProperty(k,`latitude`,{enumerable:!0,writable:!0,value:E.initial.latitude}),isNumber(E.initial.longitude)?defineProperty(k,`longitude`,{enumerable:!0,writable:!0,value:E.initial.longitude}):isNumber(E.initial.heading)&&defineProperty(k,`longitude`,{enumerable:!0,writable:!0,value:headingToLongitude(E.initial.heading)}),isNumber(E.initial.fov)&&defineProperty(k,`fov`,{enumerable:!0,writable:!0,value:E.initial.fov}),isNumber(E.initial.distance)&&defineProperty(k,`distance`,{enumerable:!0,writable:!0,value:E.initial.distance}),Array.isArray(E.initial.offset)){let e=E.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});defineProperty(k,`offset`,{enumerable:!0,writable:!0,value:new three.Vector3().fromArray(t)})}else typeof E.initial.offset==`object`&&typeof E.initial.offset.x==`number`&&typeof E.initial.offset.y==`number`&&typeof E.initial.offset.z==`number`&&defineProperty(k,`offset`,{enumerable:!0,writable:!0,value:new three.Vector3().fromArray([E.initial.offset.x,E.initial.offset.y,E.initial.offset.z])})}return defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:k}),t}function parseNull(e,t){return defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),defineProperty(t,`workCode`,{enumerable:!0,value:`null-`+createUuid()}),defineProperty(t,`baseURL`,{enumerable:!0,value:`/`}),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function parsePano(e,t){var n,r;return defineProperty(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),defineProperty(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),defineProperty(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),defineProperty(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),defineProperty(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?createUuid():r}),defineProperty(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),defineProperty(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:panoStringify({workCode:t.workCode,panoIndex:0})}),defineProperty(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),defineProperty(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),defineProperty(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),defineProperty(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),defineProperty(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector3(0,1.5,0)}),defineProperty(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Vector3(0,0,0)}),defineProperty(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Quaternion(0,1,0,0)}),defineProperty(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new three.Matrix4().compose(n.position,n.quaternion,PANO_TEXTURE_SCALE)}),defineProperty(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),defineProperty(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),defineProperty(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};defineProperty(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of FACE_ORDER$1)defineProperty(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return defineProperty(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),defineProperty(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=getImageSizeFromURL(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=getTileLevel(r[0]);if(e)for(let t=e-1;t>=0;t--)r.unshift(512*Math.pow(2,t))}if(r.length<=0)return;let o=[];for(let s of r){let r=getTileLevel(s);if(typeof r!=`number`)continue;let c={};if(defineProperty(c,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(c,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),s>e){defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:s}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of FACE_ORDER$1)defineProperty(c,e,{enumerable:!0,configurable:!1,writable:!1,value:replaceImageSize(n[e],s)})}else{defineProperty(c,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),defineProperty(c,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:s/e});for(let e of FACE_ORDER$1)defineProperty(c,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}o.push(c)}return o=sortTile(o),Object.freeze(o)})()}),defineProperty(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),defineProperty(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return defineProperty(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),defineProperty(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),defineProperty(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var workVerifySet=new WeakSet,Work=class{constructor(e,t){this.observerBox=new three.Box3,this.observerBox=new three.Box3,this.transform=new three.Matrix4,this.shortPath=!1,this.jsonp=!1;let n;if(n=e===null?parseNull(e,this):typeof e==`object`&&typeof e.size==`number`&&typeof e.up==`string`&&typeof e.down==`string`&&typeof e.right==`string`&&typeof e.left==`string`&&typeof e.front==`string`&&typeof e.back==`string`?parsePano(e,this):parse(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
939
939
  Error work input:
940
940
  `+JSON.stringify(e));workVerifySet.add(this);for(let e of this.observers)this.observerBox.expandByPoint(e.position),this.observerBox.expandByPoint(e.standingPosition);t.baseURL&&(this.baseURL=t.baseURL),t.transform&&(Array.isArray(t.transform)?this.transform.fromArray(t.transform):this.transform.copy(t.transform)),typeof t.jsonp==`boolean`&&(this.jsonp=t.jsonp),typeof t.shortPath==`boolean`&&(this.shortPath=t.shortPath),t.workCode&&(typeof t.workCode==`string`?this.workCode=t.workCode:typeof t.workCode==`function`&&(this.workCode=t.workCode(e)));{let e=this;this.options={get transform(){return e.transform}},this.raw={get works(){return[JSON.stringify(workToJson(e))]}}}}getURL(e){var t;if(!isAbsoluteURL(e)){if(this.jsonp===!0){e=e.replace(/([\?\#].*)?$/i,``);let t=sha256(`${e}`).slice(0,7);e=`${e}.${t}.jsonp`}if(this.shortPath===!0){let n=e.replace(e,``).split(`.`),r=(t=n.shift())==null?``:t,o=n.join(`.`);e=sha256(r)+(o?`.`+o:``)}e=pathJoin(this.baseURL,e)}return e=getFullURL(e),e}verifyURL(e){return typeof verifyURL(this.getURL(e),this.allowHosts)==`string`}toJSON(){return workToJson(this)}};Work.parse=parseWork;function parseWork(e,t){typeof e==`string`&&e.trim()[0]===`{`&&(e=JSON.parse(e));try{return new Work(e,t==null?{}:t)}catch(t){console.log(t);let n=t instanceof Error?t.message:String(t);throw Error(`[PARSE Error]: `+n+`
941
941
  Error work input:
@@ -2236,7 +2236,7 @@ void main() {
2236
2236
  #include <premultiplied_alpha_fragment>
2237
2237
 
2238
2238
  }
2239
- `},LineMaterial=class extends three.ShaderMaterial{constructor(e){super({uniforms:three.UniformsUtils.clone(lineShader.uniforms),vertexShader:lineShader.vertexShader,fragmentShader:lineShader.fragmentShader,clipping:!0}),this.type=`LineMaterial`,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)}};Object.assign(LineMaterial.prototype,{isLineMaterial:!0});var LineSegments2=class extends three.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new LineSegmentsGeometry:e,this.material=t===void 0?new LineMaterial({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count),o=new three.Vector3,s=new three.Vector3;for(var c=0,l=0,u=t.count;c<u;c++,l+=2)o.fromBufferAttribute(t,c),s.fromBufferAttribute(n,c),r[l]=l===0?0:r[l-1],r[l+1]=r[l]+o.distanceTo(s);let d=new three.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new three.InterleavedBufferAttribute(d,1,0)),e.setAttribute(`instanceDistanceEnd`,new three.InterleavedBufferAttribute(d,1,1)),this}raycast(e,t){e.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let n=e.ray,r=e.camera,o=r.projectionMatrix,s=this.geometry,c=this.material,l=c.resolution,u=c.linewidth,d=s.attributes.instanceStart,f=s.attributes.instanceEnd,p=new three.Vector4,m=new three.Vector4,h=new three.Vector4,g=new three.Vector3,_=new three.Matrix4,v=new three.Line3,y=new three.Vector3;n.at(1,h),h.w=1,h.applyMatrix4(r.matrixWorldInverse),h.applyMatrix4(o),h.multiplyScalar(1/h.w),h.x*=l.x/2,h.y*=l.y/2,h.z=0,g.copy(h);let b=this.matrixWorld;_.multiplyMatrices(r.matrixWorldInverse,b);for(var S=0,C=d.count;S<C;S++){p.fromBufferAttribute(d,S),m.fromBufferAttribute(f,S),p.w=1,m.w=1,p.applyMatrix4(_),m.applyMatrix4(_),p.applyMatrix4(o),m.applyMatrix4(o),p.multiplyScalar(1/p.w),m.multiplyScalar(1/m.w);var w=p.z<-1&&m.z<-1,T=p.z>1&&m.z>1;if(w||T)continue;p.x*=l.x/2,p.y*=l.y/2,m.x*=l.x/2,m.y*=l.y/2,v.start.copy(p),v.start.z=0,v.end.copy(m),v.end.z=0;let e=v.closestPointToPointParameter(g,!0);v.at(e,y);let r=three.MathUtils.lerp(p.z,m.z,e),s=r>=-1&&r<=1;var E=g.distanceTo(y)<u*.5;if(s&&E){v.start.fromBufferAttribute(d,S),v.end.fromBufferAttribute(f,S),v.start.applyMatrix4(b),v.end.applyMatrix4(b);var D=new three.Vector3,O=new three.Vector3;n.distanceSqToSegment(v.start,v.end,O,D),t.push({point:O,pointOnLine:D,distance:n.origin.distanceTo(O),object:this,faceIndex:S})}}}};Object.assign(LineSegments2.prototype,{isLineSegments2:!0});var Line2=class extends LineSegments2{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(Line2.prototype,{isLine2:!0});var LineGeometry=class extends LineSegmentsGeometry{constructor(){super(),this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){let t=e.geometry;if(t instanceof three.Geometry){let e=new three.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof three.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}copy(){return this}};Object.assign(LineGeometry.prototype,{isLineGeometry:!0});var circleImageURL=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,DEFAULT_COLOR=14467195,POINT_SIZE=8,DEFAULT_LINEWIDTH=2,DEFAULT_DASHSCALE=20,sharedCircleTexture=null,FiveLine=class extends three.Object3D{static get version(){return`6.8.0`}constructor(e=new three.Vector3,t=new three.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0,this.line=new Line2(new LineGeometry,new LineMaterial({color:DEFAULT_COLOR,linewidth:DEFAULT_LINEWIDTH,dashScale:DEFAULT_DASHSCALE,dashed:!1}));let n=new three.BufferGeometry,r=new three.PointsMaterial({color:DEFAULT_COLOR,size:POINT_SIZE,map:sharedCircleTexture||(sharedCircleTexture=new three.TextureLoader().load(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`)),sizeAttenuation:!1,transparent:!0});this.points=new three.Points(n,r),this.points.renderOrder=11,this.points.frustumCulled=!1,this.setPoints(e,t),this.add(this.line,this.points)}setPoints(e,t){let n=[].concat(e.toArray(),t.toArray());this.points.geometry.setAttribute(`position`,new three.BufferAttribute(new Float32Array(n),3)),this.line.geometry.setPositions(n),this.line.computeLineDistances(),this.needsRender=!0}getPoints(){let e=this.points.geometry.attributes.position.array;return[new three.Vector3(e[0],e[1],e[2]),new three.Vector3(e[3],e[4],e[5])]}setMaterial(e){let t=this.line.material;for(let n in e){if(!e.hasOwnProperty(n))continue;let r=e[n];n===`dashed`?(t.dashed=r,r?t.defines.USE_DASH=``:delete t.defines.USE_DASH,t.needsUpdate=!0):t[n]=e[n]}this.needsRender=!0}setResolution(e,t){let n=this.line.material.resolution;(n.x!==e||n.y!==t)&&(n.set(e,t),this.needsRender=!0)}};Object.assign(FiveLine.prototype,{isFiveLine:!0});var Constants={Handedness:Object.freeze({NONE:`none`,LEFT:`left`,RIGHT:`right`}),ComponentState:Object.freeze({DEFAULT:`default`,TOUCHED:`touched`,PRESSED:`pressed`}),ComponentProperty:Object.freeze({BUTTON:`button`,X_AXIS:`xAxis`,Y_AXIS:`yAxis`,STATE:`state`}),ComponentType:Object.freeze({TRIGGER:`trigger`,SQUEEZE:`squeeze`,TOUCHPAD:`touchpad`,THUMBSTICK:`thumbstick`,BUTTON:`button`}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:`transform`,VISIBILITY:`visibility`})};function fetchJsonFile(e){return __awaiter(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function fetchProfilesList(e){return __awaiter(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield fetchJsonFile(`${e}/profilesList.json`)})}function fetchProfile(e,t){return __awaiter(this,arguments,void 0,function*(e,t,n=null,r=!0){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No basePath supplied`);let o=yield fetchProfilesList(t),s;if(e.profiles.some(e=>{let n=o[e];return n&&(s={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!s}),!s){if(!n)throw Error(`No matching profile name found`);let e=o[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);s={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let c=yield fetchJsonFile(s.profilePath),l;if(r){let t;if(t=c.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${s.profileId}`);t.assetPath&&(l=s.profilePath.replace(`profile.json`,t.assetPath))}return{profile:c,assetPath:l}})}var defaultComponentValues={xAxis:0,yAxis:0,button:0,state:Constants.ComponentState.DEFAULT};function normalizeAxes(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let o=Math.atan2(t,e);n=Math.cos(o),r=Math.sin(o)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var VisualResponse=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Constants.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(defaultComponentValues)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:o,normalizedYAxis:s}=normalizeAxes(e,t);switch(this.componentProperty){case Constants.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?o:.5;break;case Constants.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?s:.5;break;case Constants.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case Constants.ComponentProperty.STATE:this.valueNodeProperty===Constants.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},Component=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw Error(`Invalid arguments supplied`);this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(e=>{let n=new VisualResponse(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Constants.ComponentState.DEFAULT,button:this.gamepadIndices.button===void 0?void 0:0,xAxis:this.gamepadIndices.xAxis===void 0?void 0:0,yAxis:this.gamepadIndices.yAxis===void 0?void 0:0}}get data(){return Object.assign({id:this.id},this.values)}updateFromGamepad(e){if(this.values.state=Constants.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){let t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Constants.ComponentState.PRESSED:(t.touched||this.values.button>Constants.ButtonTouchThreshold)&&(this.values.state=Constants.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},MotionController=class{constructor(e,t,n){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No profile supplied`);this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(e=>{let t=this.layoutDescription.components[e];this.components[e]=new Component(e,t)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){let e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}},DEFAULT_PROFILES_PATH=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,DEFAULT_PROFILE=`generic-trigger`,XRControllerModel=class extends three.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof three.Mesh&&e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(e=>{Object.values(e.visualResponses).forEach(e=>{let{valueNode:t,minNode:n,maxNode:r,value:o,valueNodeProperty:s}=e;t&&(s===Constants.VisualResponseProperty.VISIBILITY?t.visible=o:s===Constants.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,o),t.position.lerpVectors(n.position,r.position,o)))})}))}};function findNodes(e,t){Object.values(e.components).forEach(e=>{let{type:n,touchPointNodeName:r,visualResponses:o}=e;if(n===Constants.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){let t=new three.Mesh(new three.SphereGeometry(.001),new three.MeshBasicMaterial({color:255}));e.touchPointNode.add(t)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(o).forEach(e=>{let{valueNodeName:n,minNodeName:r,maxNodeName:o,valueNodeProperty:s}=e;if(s===Constants.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(r),e.maxNode=t.getObjectByName(o),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${o} in the model`);return}}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)})})}function addAssetSceneToControllerModel(e,t){findNodes(e.motionController,t),e.envMap&&t.traverse(t=>{t instanceof three.Mesh&&t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)}),e.add(t)}var XRControllerModelFactory=class{constructor(e=null){this.gltfLoader=e,this.path=DEFAULT_PROFILES_PATH,this._assetCache={}}createControllerModel(e){let t=new XRControllerModel,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||fetchProfile(r,this.path,DEFAULT_PROFILE).then(({profile:e,assetPath:o})=>{t.motionController=new MotionController(r,e,o);let s=this._assetCache[t.motionController.assetUrl];if(s)n=s.scene.clone(),addAssetSceneToControllerModel(t,n);else{if(!this.gltfLoader)throw Error(`GLTFLoader not set.`);this.gltfLoader.load(t.motionController.assetUrl,e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),addAssetSceneToControllerModel(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},defaultXRPanoramaControllerInitArgs=Object.assign({},omit(defaultPanoramaControllerCustomInitArgs,[`maxLatitude`,`minLatitude`]));function mapPanoResource(e,t){if(!t)return e;let n=e.match(/\d+_[a-z].png/);return e.substring(0,n.index)+t+`/`+e.substring(n.index)}var CONTROLLER_EVNET_DELTA_TIME=300,scratchRaycaster=new three.Raycaster,scratchVector3=new three.Vector3,XRPanoramaController=class e extends PanoramaController{static parseArgs(t){if(t instanceof e)return t;let n=Object.assign(Object.assign({},t),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return super.parseArgs(n)}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`XRPanorama`})}constructor(e){super(e),this.xrManager=new XRManager(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,createEvent(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,createEvent(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new three.Raycaster,right:new three.Raycaster},this.xrControllerRay.left.params.Points={threshold:.1},this.xrControllerRay.left.firstHitOnly=!0,this.xrControllerRay.left.floorIndex=-1,this.xrControllerRay.right.params.Points={threshold:.1},this.xrControllerRay.right.firstHitOnly=!0,this.xrControllerRay.right.floorIndex=-1,this.gazeRay=null,this.pointerLines={left:new FiveLine,right:new FiveLine},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new three.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new three.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new three.Group,new three.Group];let t=this.xrManager.getController(0);this.controllerWrappers[0].add(t);let n=this.xrManager.getController(1);this.controllerWrappers[1].add(n);let r=new XRControllerModelFactory;r.gltfLoader={load(e,t){internalFetcher.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return parseGltf(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:internalFetcher})}).then(e=>t(e))}},(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`)&&this.scene.add(this.pointerLines.left,this.pointerLines.right,this.controllerWrappers[0],this.controllerWrappers[1]),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=createUuid()]={panoId:panoStringify(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:`fade`,effectEasing:defaultEffectEase,fixCameraTransform:new three.Matrix4},this.parallaxCameraMatrixs=[];let o=AnimationFrameLoop.shared.getContext();if(!o){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(o),this.on(`xr.session.start`,()=>{let e=this.xrManager.getControllerGrip(0);e.add(r.createControllerModel(e)),this.controllerWrappers[0].add(e);let t=this.xrManager.getControllerGrip(1);t.add(r.createControllerModel(t)),this.controllerWrappers[1].add(t)}),this.xrHandleState={LeftAxesUp:{touchStartTime:0,touchStart:!1},LeftAxesDown:{touchStartTime:0,touchStart:!1},LeftAxesLeft:{touchStartTime:0,touchStart:!1},LeftAxesRight:{touchStartTime:0,touchStart:!1},LeftTrigger:{touchStartTime:0,touchStart:!1},LeftPinch:{touchStartTime:0,touchStart:!1},RightAxesUp:{touchStartTime:0,touchStart:!1},RightAxesDown:{touchStartTime:0,touchStart:!1},RightAxesLeft:{touchStartTime:0,touchStart:!1},RightAxesRight:{touchStartTime:0,touchStart:!1},RightTrigger:{touchStartTime:0,touchStart:!1},RightPinch:{touchStartTime:0,touchStart:!1},Y:{touchStartTime:0,touchStart:!1},X:{touchStartTime:0,touchStart:!1},A:{touchStartTime:0,touchStart:!1},B:{touchStartTime:0,touchStart:!1}},this.xrManager.machineType===`VP`&&this.initHandEvent()}updateConfiguration(e){return super.updateConfiguration(Object.assign(Object.assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2}))}moveToPano(e,t,n){var r,o,s;let c=(r=t.effect)==null?`fade`:r;this.userAction=n,this.stopMomentumMovement();let l=panoStringify(e),u=this.works.getObserver(e);if(!u)throw Error(`Invalid PanoIndex`);let d=getImageSizeFromURL(u.images.up),f=this.imageOptions.size;f===void 0&&u&&d&&(f=Number(d)),f===void 0&&(f=2048);let p=this.imageOptions.transform,m=(e,t)=>mapPanoResource(applyImageURLOptions(e,p,t)),h=Object.assign({key:`pano.${l}`},pick(this.imageOptions,[`format`,`size`,`quality`])),g={right:u.images.work.getURL(u.images.right),left:u.images.work.getURL(u.images.left),up:u.images.work.getURL(u.images.up),down:u.images.work.getURL(u.images.down),front:u.images.work.getURL(u.images.front),back:u.images.work.getURL(u.images.back)},_=`pano:`+jsonHash([g,h,p]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===_)return;{let t=this.pendingPanoTask.panoId;(o=this.panoMeshes.get(t))==null||o.setProgress(0),this.emit(`pano.texture.abort`,createEvent(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let v=`move-to-pano-`+l;this.pending.add(v);let y=createExtendableEvent(`pano.prepare`,{prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,y),y.defaultPrevented){this.pending.delete(v);return}let b=this.modelScene.parameter,S;if(b.pano0&&b.pano0.map.name===_?S=b.pano0:b.pano1&&b.pano1.map.name===_&&(S=b.pano1),S){let n={panoId:l,effect:c,effectEasing:(s=t.effectEasing)==null?defaultEffectEase:s,leftPanoPicture:{panoId:S.panoId,map:S.map,mapHistogram:S.mapHistogram,mapSize:S.mapSize,matrix:u.matrix.clone().premultiply(u.work.transform),zoom:1},position:u.position.clone().applyMatrix4(u.work.transform),fixCameraTransform:new three.Matrix4};n.leftPanoPicture&&this.panoPictureObserverMap.set(n.leftPanoPicture,u),this.pendingPanoTask=void 0,Promise.resolve().then(()=>waitForExtendableEvent(y)).catch(e=>{let t=toError(e);return this.emit(`error`,t),t}).then(r=>{var o,s;if(!(r instanceof Error))this.pending.delete(v),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(l))==null||o.setProgress(0),this.doMoveToPano(e,n,t);else{let e=null;r instanceof Error&&(e||(e=r));let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.error`,createEvent(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(v),this.pendingPanoTask=void 0,(s=this.panoMeshes.get(l))==null||s.setProgress(0)}});return}let C=this.panoMeshes.get(l);C&&C.tap&&C.tap(),this.pendingPanoTask={panoId:l,hash:_,onLoad:n=>{var r,o;let s=n.body;if(this.destroyed)s.dispose();else{s.name=_;let n=Array.isArray(s.image)?s.image[0]:s.image,d=(r=n==null?void 0:n.width)==null?2048:r,f=new Histogram().formPixels(getRgbaDataFromCubeTexture(this.renderer,s,!0,sharedHistogramRgbaData).data),p={panoId:l,effect:c,effectEasing:(o=t.effectEasing)==null?defaultEffectEase:o,leftPanoPicture:{panoId:l,map:s,mapSize:d,mapHistogram:new three.Vector4().fromArray(f.toArray()),matrix:u.matrix.clone(),zoom:1},position:u.position.clone(),fixCameraTransform:new three.Matrix4};p.leftPanoPicture&&this.panoPictureObserverMap.set(p.leftPanoPicture,u),this.doMoveToPano(e,p,t)}},onError:e=>{let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),this.emit(`pano.error`,createEvent(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),t.moveCancelCallback&&t.moveCancelCallback()}},Promise.all([Promise.resolve().then(()=>{this.emit(`pano.texture.load`,createEvent(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(g,{imageURL:{transform:m,options:h},format:three.RGBFormat,viaAjax:!0,fetcher:getFetcher(this.fiveId,u.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,createEvent(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===_&&((r=this.panoMeshes.get(l))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=toError(t);return this.emit(`pano.texture.error`,createEvent(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>waitForExtendableEvent(y)).catch(e=>toError(e))]).then(([t,n])=>{var r,o,s,c;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(v),((r=this.pendingPanoTask)==null?void 0:r.hash)===_?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(l))==null||o.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,createEvent(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}));else{let e=null;t instanceof Error?e||(e=t):t.body.dispose(),n instanceof Error&&(e||(e=n)),this.pending.delete(v),((s=this.pendingPanoTask)==null?void 0:s.hash)===_&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(c=this.panoMeshes.get(l))==null||c.setProgress(0))}})}doMoveToPano(e,t,n={}){var r,o,s,c,l,u,d,f,p,m;let h=now(),g=createUuid();this.panoResources[g]=t;let _=1,v,y,b;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,o=this.panoResourceFromLocationMotionKeyframe(n).position,s=t.position;v=Math.max(o.distanceTo(s),1),y=[{key:n.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],b=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,o=this.panoResourceFromLocationMotionKeyframe(e).position,s=this.panoResourceFromLocationMotionKeyframe(n).position,c=t.position,l=n.value.count-r.count,u=Math.max(o.distanceTo(s),1)*l;v=u+Math.max(s.distanceTo(c),1),y=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:u/v,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let d=this.locationMotionKeyframesLength(this.locationMotion.keyframes),f=this.locationMotionKeyframesLength(y);b=this.locationMotion.getProgressVelocity(h)*d/f}let S=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?v:0),C={longitude:n.longitude,latitude:n.latitude,fov:n.fov},w=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(r=C.longitude)==null?this.camera.pose.longitude:r,latitude:(o=C.latitude)==null?this.camera.pose.latitude:o,fov:(s=C.fov)==null?this.camera.pose.fov:s,offset:t.position.clone(),distance:0}),T=this.currentPano;if(this.emit(`pano.moveTo`,createEvent(`pano.moveTo`,{options:n,prevPano:T,pano:{panoIndex:w.panoIndex,workCode:w.workCode},progress:0,state:w,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(w),this.perspToOrthoMotion.set({perspToOrtho:0},S).catch(noop),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],S).catch(noop),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=noop,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(C,S).catch(noop);else{let e=coordinatesToVector({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=coordinatesToVector({longitude:(c=C.longitude)==null?this.cameraMotion.value.longitude:c,latitude:(l=C.latitude)==null?this.cameraMotion.value.latitude:l}),r=new three.Object3D;r.lookAt(e);let o=new three.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let s=new three.Matrix4().makeRotationFromQuaternion(r.quaternion),h=new three.Matrix4().getInverse(o).premultiply(s),g=this.cameraMotion.value.fov,_=(u=C.fov)==null?this.cameraMotion.value.fov:u,v=1;t.effect===`zoomin`?v=1.5:t.effect===`zoomout`&&(v=.4);let b=_*v;for(let e=0;e<y.length-1;e++){let t=y[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(h),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(b/2/180*Math.PI)/Math.tan(g/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=C.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=C.latitude)==null?this.cameraMotion.value.latitude:f,fov:b}},{progress:1,value:{longitude:(p=C.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=C.latitude)==null?this.cameraMotion.value.latitude:m,fov:_}}],S).catch(noop)}this.locationMotion.setKeyframes(y,S,b).then(()=>{for(let e of this.modelScene.children)e instanceof Model&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:0});this.emit(`pano.arrived`,createEvent(`pano.arrived`,{options:n,prevPano:T,pano:{panoIndex:t.panoIndex,workCode:t.workCode},progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(this.currentPano);if(r&&r.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:r.images.video.size.clone(),matrix:r.images.video.matrix.clone(),panoMatrix:r.matrix.clone().premultiply(r.work.transform),alpha:1},t=createUuid(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),canplayVideo().then(o=>{o&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=noop,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=noop,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}},()=>{let e=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{options:n,prevPano:T,pano:{panoIndex:e.panoIndex,workCode:e.workCode},progress:0,state:e,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}checkSelectedPano(e){var t;this.stopMomentumMovement(),this.camera.getDirection(new three.Vector3).setY(0);let n=null,r=this.works.getObserver(this.currentPano);if(!r)return null;let o=r.work.observers,s=r.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&r.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||scratchVector3.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(e);if(c){let[e,r]=arrayMin(s,e=>{let t=o[e];return t?scratchVector3.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&r<this.panoTapTriggerRadius&&(n=(t=o[e])==null?null:t)}if(isNil(n)){let t=this.getForwardObserverOrNot(this.xrManager.cameraVR,e);t&&(n=t)}for(let e of this.locationMotion.keyframes){let t=this.panoResourceFromLocationMotionKeyframe(e);if(!(e.progress<this.locationMotion.progress)&&n){let e=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode});if(t.panoId===e){n=null;break}}}if(isNil(n))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!n.active){let e=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let l={workCode:n.work.workCode,panoIndex:n.panoIndex,mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,distance:0,offset:n?n.position.clone():new three.Vector3};return this.emit(`pano.select`,createEvent(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.workCode},state:l,userAction:!0,options:{},progress:0,error:null})),n&&n.active?(this.emit(`pano.request`,createEvent(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.workCode},progress:0,state:l,options:{},error:null})),{workCode:n.work.workCode,panoIndex:n.panoIndex}):null}destroy(){super.destroy()}isReady(){return!1}updateCamera(e,t,n){return Promise.resolve()}updateCameraWithKeyframes(e,t,n){return Promise.resolve()}updateTime(e,t,...n){var r,o,s,c,l,u,d,f,p;this.userAction=!0;let m={},h={},g=this.camera.getDirection(new three.Vector3),_=this.locationMotion.keyframes[0],v=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[y,b]=this.locationMotion.getKeyFrameSegment(e),S=this.panoResourceFromLocationMotionKeyframe(y),C=this.panoResourceFromLocationMotionKeyframe(b),w=this.panoResourceFromLocationMotionKeyframe(_),T=this.panoResourceFromLocationMotionKeyframe(v),E=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),h.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),m.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-b.value.count+1,n=new three.Vector3().copy(S.position),s=new three.Vector3().copy(C.position);if(m.progress=t,t>=.01&&t<=.99&&(m.progress=clamp$1(C.effectEasing(t),.01,.99)),C.leftPanoPicture&&(t<1?S.leftPanoPicture&&(m.pano0=S.leftPanoPicture):m.pano0=C.leftPanoPicture,m.pano1=C.leftPanoPicture),C.effect===`montage`?m.transition=`BLACK`:C.effect===`spread`?m.transition=`SPREAD`:m.transition=`FADE`,C.effect===`zoomin`||C.effect===`zoomout`?m.progress=Math.pow(t,3):C.effect===`model`&&this.camera.pose.distance<.01&&(m.modelAlpha=1-Math.pow(clamp$1(Math.abs(t-.5)*2,0,1),4)),t<1&&C.effect!==`fly`){if(m.pano0&&S.leftPanoPicture){let e={panoId:m.pano0.panoId,map:m.pano0.map,mapHistogram:m.pano0.mapHistogram,mapSize:m.pano0.mapSize,zoom:m.pano0.zoom,matrix:S.leftPanoPicture.matrix.clone().setPosition(C.position)},t=this.panoPictureObserverMap.get(m.pano0);t&&this.panoPictureObserverMap.set(e,t),m.pano0=e}n.copy(s),E=!0}h.distance=this.locationMotion.value.distance,h.offset=new three.Vector3(n.x+(s.x-n.x)*t,n.y+(s.y-n.y)*t,n.z+(s.z-n.z)*t);let c=[],l=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(c.push(t),n>this.locationMotion.progress&&l.push(t))}for(let e of Object.keys(this.panoResources)){if(l.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((r=m.pano0)==null?void 0:r.map)||e===((o=m.pano1)==null?void 0:o.map))continue;e.dispose(),t.leftPanoPicture=null}}c.indexOf(e)>=0||delete this.panoResources[e]}let u=panoParse(C.panoId);u!==this.currentPano&&(this.currentPano=u,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,createEvent(`pano.moving`,{userAction:this.userAction,prevPano:panoParse(w.panoId),pano:panoParse(T.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},panoParse(T.panoId)),{mode:this.mode}),clonePose(this.camera.pose)),h),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(h),this.xrManager.cameraVR.projectionMatrix.copy(this.camera.projectionMatrix),this.xrManager.cameraVR.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.xrManager.cameraVR.matrix.copy(this.camera.matrix),this.xrManager.cameraVR.position.copy(this.camera.position),this.xrManager.cameraVR.quaternion.copy(this.camera.quaternion),this.xrManager.cameraVR.scale.copy(this.camera.scale),this.xrManager.cameraVR.matrixAutoUpdate=!1,this.xrManager.cameraVR.matrixWorld.copy(this.camera.matrixWorld);let[D,O]=n,k=new three.Vector3(0,0,0),A=new three.Vector2().copy(this.camera.resolution);if(O&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let n=this.xrManager.cameraVR,r=this.xrManager.referenceSpace,o=this.xrManager.session.renderState.baseLayer,u=O.getViewerPose(r),d=(s=u==null?void 0:u.views)==null?[]:s;for(let e=0;e<d.length;e++){let t=d[e],r=n.cameras[e],s=o.getViewport(t);s&&(r.projectionMatrix.fromArray(t.projectionMatrix),r.projectionMatrixInverse.getInverse(r.projectionMatrix),r.matrix.fromArray(t.transform.matrix),r.matrix.setPosition(this.camera.position),r.matrix.decompose(r.position,r.quaternion,r.scale),r.matrixWorld.copy(r.matrix),r.matrixWorldInverse.getInverse(r.matrixWorld),r.matrixAutoUpdate=!1,k.copy(r.position),r.viewport.set(s.x,s.y,s.width,s.height),A.set(s.width,s.height))}if(this.xrManager.setProjectionFromUnion(this.xrManager.cameraVR,this.xrManager.cameraL,this.xrManager.cameraR),this.camera.quaternion.copy(this.xrManager.cameraVR.quaternion),this.camera.scale.copy(this.xrManager.cameraVR.scale),this.camera.matrix.compose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.computePose((c=h.distance)==null?this.camera.pose.distance:c),this.xrManager.session.inputSources){for(let e=0;e<this.xrManager.session.inputSources.length;e++)if(this.xrManager.session.inputSources[e]&&this.xrManager.session.inputSources[e].targetRayMode===`transient-pointer`){let t=O.getPose(this.xrManager.session.inputSources[e].targetRaySpace,r);if(t){let e=t.transform.orientation,n=new three.Quaternion(e.x,e.y,e.z,e.w),r=new three.Vector3(0,0,-1).applyQuaternion(n);this.gazeRay=new three.Raycaster(this.camera.position,r)}}}if(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`){let n=this.xrManager.session.inputSources;for(let e=0;e<n.length;e++){let t=this.xrManager.controllers[e],o=n[e];if(!o)continue;t&&t.update(o,O,r);let s=this.xrManager.getController(e),c=new three.Vector3(0,1.2,0),u=s.position.clone().add(k).sub(c);o.handedness===`left`?this.xrControllerRay.left.set(u,new three.Vector3(0,0,-1).applyEuler(s.rotation)):o.handedness===`right`&&this.xrControllerRay.right.set(u,new three.Vector3(0,0,-1).applyEuler(s.rotation)),this.controllerWrappers[e].position.copy(new three.Vector3(0,0,0).add(k).sub(c));let d=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(d.length===0){let e=this.works.getResolvedObserver(this.currentPano);d=this.xrControllerRay.right.intersectObject(this.modelScene.boundingMesh,!0).map(t=>{var n;let r=(n=e==null?void 0:e.floorIndex)==null?0:n;return Object.assign({floorIndex:r,floor:r},t)})}if(d.length>=1&&d[0].face)if(o.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=d[0].face.normal,n=t.clone(),r=d[0].point.clone();this.intersectMesh.position.copy(r);let o=r.clone().add(n);if(this.intersectMesh.lookAt(o),Math.abs(t.y)>.99){let e=this.camera.position.clone().sub(r);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0,e.length>0?(this.pointerLines.right.setPoints(u,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(u,d[0].point));let s=d[0],c=createEvent(`intersect.update`,{raycaster:(l=this.xrControllerRay.right)==null?null:l,intersection:s==null?null:s,object:this.intersectMesh});if(this.emit(`intersect.update`,c),c.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(u,d[0].point)}this.updateControllerHelper(n,e,t)}}else O||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);isEmptyObject(m)===!1&&this.modelScene.parameter.set(m),this.emit(`camera.update`,createEvent(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose))}));let j=this.works.getResolvedObserver(this.currentPano),M=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,N=this.works.getObserver(S.panoId),P=this.works.getObserver(C.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&j){let e=[],t=j.work.observers;for(let n of j.accessibleNodes){let r=t[n];r&&e.push(r)}let n=new Map;if(e.sort((e,t)=>{let r=n.get(e);r===void 0&&(r=e.standingPosition.distanceTo(j.standingPosition),n.set(e,r));let o=n.get(e);return o===void 0&&(o=t.standingPosition.distanceTo(j.standingPosition),n.set(t,o)),r-o}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let t=e[this.accessibleObserverFloorCheckCount],n=this.modelScene.models.find(e=>e.work===(t==null?void 0:t.work));if(t&&n&&n.visible){let e=.3,r=.05,o=.005,s=t.standingPosition.clone().applyMatrix4(t.work.transform),c=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode}),l=adjustPanoCircleMeshVectors.map(t=>{scratchRaycaster.ray.origin.copy(s),scratchRaycaster.ray.origin.add(scratchVector3.copy(t).setY(e)),scratchRaycaster.ray.direction.set(0,-1,0),scratchRaycaster.firstHitOnly=!0,scratchRaycaster.floorIndex=-1;let[r]=n.intersectRaycaster(scratchRaycaster);return r&&r.distance-o<=e?new three.Vector3().copy(s).setY(r.point.y+o):s});l.sort((e,t)=>t.y-e.y);let u=l[Math.floor(l.length/2)],[d]=l.filter(e=>e.distanceTo(u)<=.05);if(d){let e=new three.Vector4(s.x,s.y,s.z,d.y-s.y),t=this.adjustPanoCircleMeshPositionFix.get(c);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(c,e)}}this.accessibleObserverFloorCheckCount++}}let F=new Map;if(N)for(let e of N.accessibleNodes){let t=N.work.observers[e];if(t){let e=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode});F.set(e,t)}}if(P)for(let e of P.accessibleNodes){let t=P.work.observers[e];if(t){let e=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode});F.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{F.get(t)?F.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),F.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),F.delete(t)}),this.panoMeshes.forEach((e,t)=>{let n=this.works.getObserver(t);if(n){let r=n.position.distanceTo(n.standingPosition)>this.aerialObserverMinHeight;if(r)e.position.copy(n.position).applyMatrix4(n.work.transform),e.scale.setScalar(18);else{e.position.copy(n.standingPosition).applyMatrix4(n.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(n.panoId);t&&(scratchVector3.set(t.x,t.y,t.z),scratchVector3.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let o=this.camera.position.clone().setY(e.position.y),s=new three.Vector3().copy(e.position).sub(o).normalize();if(t===panoStringify(this.currentPano)){let t=clamp$1((.5-o.distanceTo(e.position))/.5,0,1);s.multiplyScalar(1-t).add(g.clone().multiplyScalar(t))}if(s.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(s.x,s.z);e.quaternion.setFromEuler(new three.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||E)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(j){let n=j.work.observers,[,r]=arrayMin(j.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:j.standingPosition.distanceTo(t.standingPosition)},!0);r=clamp$1(r,2.5,1/0);let o=j.accessibleNodes.concat(j.panoIndex).map(e=>panoStringify({panoIndex:e,workCode:j.work.workCode}));this.panoMeshes.forEach((n,s)=>{let c=this.works.getObserver(s),l=!1,u=1;if(o.indexOf(s)===-1)l=!1,u=0;else if(!c)l=!1,u=0;else if(!c.loadable&&!c.active)l=!1,u=0;else{let e=n.position.clone().project(this.camera);l=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&M!==null&&panoStringify({panoIndex:M.panoIndex,workCode:M.work.workCode})===s;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);u=t<.01?0:clamp$1(r/t,.1,.85)}c&&c===P&&c.position.distanceTo(c.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(u=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(u=0),n.setCurrent(l),n.setOpacity(u),n.updateTime&&n.updateTime(e,t)})}{let e=(u=this.modelScene.parameter.progress)==null?1:u,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,o=t===0?n:r,s;if(o&&(s=this.works.getObserver(o.panoId),s||(s=this.panoPictureObserverMap.get(o))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(canUseNativeImageBitmap()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!s||!o||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:A,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new three.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=getImageSizeLevel(o.mapSize)+1,c=4;this.tiling.setObserver(s);let l={renderer:this.renderer,resolution:A,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:o.map,panoMatrix:o.matrix,panoZoom:o.zoom,minLevel:e,level:4},u=this.tiling.update(l),f={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:t,opacity:(n==null?void 0:n.panoId)===(r==null?void 0:r.panoId)?1:easeInQuart(Math.abs(((d=this.modelScene.parameter.progress)==null?0:d)-.5)*2)},p=this.modelScene.parameter.refinedScreen;(u||f.pano!==(p==null?void 0:p.pano)||f.opacity!==(p==null?void 0:p.opacity))&&this.modelScene.parameter.set(`refinedScreen`,f)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&j&&j.position.y-j.standingPosition.y>10){let e=clamp$1(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1);{let e=C.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((f=this.modelScene.parameter.pano0Depth)==null?void 0:f.panoId)!==t.panoId||((p=this.modelScene.parameter.pano1Depth)==null?void 0:p.panoId)!==n.panoId){let e=500,r=512;this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new three.WebGLCubeRenderTarget(512,{minFilter:three.NearestFilter,magFilter:three.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new three.WebGLCubeRenderTarget(512,{minFilter:three.NearestFilter,magFilter:three.NearestFilter,generateMipmaps:!1});let o=new three.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);o.matrix.copy(t.matrix),o.matrixWorld.copy(o.matrix),o.matrixAutoUpdate=!1,renderDepthCube(this.renderer,this.modelScene,o,500);let s=new three.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);s.matrix.copy(n.matrix),s.matrixWorld.copy(s.matrix),s.matrixAutoUpdate=!1,renderDepthCube(this.renderer,this.modelScene,s,500),this.modelScene.parameter.set({pano0Depth:{panoId:t.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:n.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}render(){if(this.xrManager.session&&this.xrManager.session.renderState.baseLayer){let e=this.xrManager.session.renderState.baseLayer;return this.renderer.setRenderTarget(null),this.renderer.setScissorTest(!1),this.renderer.setFramebuffer(e.framebuffer),this.renderer.render(this.scene,this.xrManager.cameraVR),this.renderer.setFramebuffer(null),!0}return!1}onPanGesture(){}onTapGesture(){}onPinchGesture(){}onMouseMove(){}onMouseOut(){}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}updateControllerHelper(e,t,n){let r=this.xrControllerRay.left,o=this.xrControllerRay.right;if(!e||e.length===0)return;let s={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let c=0;c<e.length;c++){let l=e[c].handedness,u=e[c].gamepad;switch(l){case`left`:u.axes&&(this.emitHandleEvent(u.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(u.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(u.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(u.axes[3]===1,`LeftAxesDown`,t)),u!=null&&u.buttons&&(u.buttons[4]&&this.emitHandleEvent(u.buttons[4].pressed,`X`,t),u.buttons[5]&&this.emitHandleEvent(u.buttons[5].pressed,`Y`,t),u.buttons[0]&&this.emitHandleEvent(u.buttons[0].pressed,`LeftTrigger`,t),u.buttons[1]&&this.emitHandleEvent(u.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:u.axes&&u.axes[3]<0?Math.abs(u.axes[3]):0,down:u.axes&&u.axes[3]<0?0:Math.abs(u.axes[3]),left:u.axes&&u.axes[2]<0?Math.abs(u.axes[2]):0,right:u.axes&&u.axes[2]<0?0:Math.abs(u.axes[2])},deltaTime:n};s.buttons.X=u.buttons&&u.buttons[4]?u.buttons[4].pressed:!1,s.buttons.Y=u.buttons&&u.buttons[5]?u==null?void 0:u.buttons[5].pressed:!1,s.buttons.LeftTrigger=u.buttons&&u.buttons[0]?u==null?void 0:u.buttons[0].pressed:!1,s.buttons.LeftPinch=u.buttons&&u.buttons[1]?u==null?void 0:u.buttons[1].pressed:!1,s.left=e;break;case`right`:u.axes&&(this.emitHandleEvent(u.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(u.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(u.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(u.axes[3]===1,`RightAxesDown`,t)),u.buttons&&(u.buttons[4]&&this.emitHandleEvent(u.buttons[4].pressed,`A`,t),u.buttons[5]&&this.emitHandleEvent(u.buttons[5].pressed,`B`,t),u.buttons[0]&&this.emitHandleEvent(u.buttons[0].pressed,`RightTrigger`,t),u.buttons[1]&&this.emitHandleEvent(u.buttons[1].pressed,`RightPinch`,t)),s.right={raycaster:o,axes:{up:u.axes&&u.axes[3]<0?Math.abs(u.axes[3]):0,down:u.axes&&u.axes[3]<0?0:Math.abs(u.axes[3]),left:u.axes&&u.axes[2]<0?Math.abs(u.axes[2]):0,right:u.axes&&u.axes[2]<0?0:Math.abs(u.axes[2])},deltaTime:n},s.buttons.A=u.buttons&&u.buttons[4]?u==null?void 0:u.buttons[4].pressed:!1,s.buttons.B=u.buttons&&u.buttons[5]?u==null?void 0:u.buttons[5].pressed:!1,s.buttons.RightTrigger=u.buttons&&u.buttons[0]?u==null?void 0:u.buttons[0].pressed:!1,s.buttons.RightPinch=u.buttons&&u.buttons[1]?u==null?void 0:u.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,createEvent(`xr.controller.update`,s))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,o=this.xrControllerRay.right;if(e)this.xrHandleState[t].touchStart===!1?(this.xrHandleState[t].touchStartTime=n,this.xrHandleState[t].touchStart=!0,this.emit(`xr.gesture.buttonDown`,createEvent(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:o}}}))):n-this.xrHandleState[t].touchStartTime>CONTROLLER_EVNET_DELTA_TIME&&this.emit(`xr.gesture.press`,createEvent(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:o}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,createEvent(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:o}}})),n-this.xrHandleState[t].touchStartTime<=CONTROLLER_EVNET_DELTA_TIME){let e=createEvent(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:o}}});!this.emit(`xr.gesture.tap`,e)&&!e.defaultPrevented&&t===`RightTrigger`&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[t].touchStart=!1,this.xrHandleState[t].touchStartTime=0}}initHandEvent(){if(!this.xrManager.session)throw Error(`初始化失败`);this.xrManager.session.addEventListener(`select`,e=>{this.gazeRay&&this.checkSelectedPano(this.gazeRay)})}},Controllers={Floorplan:FloorplanController,Topview:TopviewController,Panorama:PanoramaController,VRPanorama:VRPanoramaController,Model:ModelController,Mapview:MapviewController,XRPanorama:XRPanoramaController},controllersDefaultInitArgs={Floorplan:defaultFloorplanControllerCustomInitArgs,Topview:defaultTopviewControllerCustomInitArgs,Panorama:defaultPanoramaControllerCustomInitArgs,VRPanorama:defaultVRPanoramaControllerCustomInitArgs,Model:defaultModelControllerCustomInitArgs,Mapview:defaultMapviewControllerCustomInitArgs,XRPanorama:defaultXRPanoramaControllerInitArgs},PROXY_CONTROLLER_EVENT_NAMES=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.fire,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.prepare,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function initLegacyEvent(e){e.on(`initAnimation.start`,t=>{e.emit(`initAnimationWillStart`,t.state.panoIndex,t.state,t.userAction)}),e.on(`initAnimation.end`,t=>{e.emit(`initAnimationEnded`,t.state.panoIndex,t.state,t.userAction)}),e.on(`gesture.pan`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pan`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPanGesture`,t.state,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pan`,t.pointers,t.isFinal),e.emit(`panGesture`,t.state,t.isFinal))}),e.on(`gesture.tap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`tap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`tap`,t.pointers,t.isFinal),e.emit(`tapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.dbltap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`dbltap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsDblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`dbltap`,t.pointers,t.isFinal),e.emit(`dblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.press`,t=>{let n=!1;n=e.emit(`wantsGesture`,`press`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`press`,t.pointers,t.isFinal),e.emit(`pressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),e.on(`gesture.pinch`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pinch`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPinchGesture`,t.scale,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pinch`,t.pointers,t.isFinal),e.emit(`pinchGesture`,t.scale,t.state.fov,t.isFinal))}),e.on(`gesture.mousewheel`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseWheel`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsMouseWheel`,t.center.delta,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseWheel`,t.pointers,t.isFinal),e.emit(`mouseWheel`,t.center.delta,t.state.fov,t.isFinal))}),e.on(`gesture.mousemove`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseMove`,t.pointers,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseMove`,t.pointers,t.isFinal),n=e.emit(`wantsChangeCameraFov`,t.state.fov),n&&t.preventDefault())}),e.on(`gesture.momentum`,t=>{let n=!1;n=e.emit(`wantsInteriaPan`,t.state),n&&t.preventDefault(),t.defaultPrevented||e.emit(`interiaPan`,t.state,t.isFinal)}),e.on(`camera.update`,t=>{e.emit(`cameraFovUpdate`,t.state.fov,t.userAction),e.emit(`cameraDirectionUpdate`,t.state,t.userAction);let n=coordinatesToVector(t.state);n.setLength(t.state.distance);let r=t.state.offset.clone().sub(n);e.emit(`cameraPositionUpdate`,r,t.userAction),e.emit(`cameraUpdate`,t.state,t.userAction)}),e.on(`intersect.update`,t=>{if(t.intersection){let n=!1;n=e.emit(`wantsShowIntersectionOnModel`,t.raycaster),n&&t.preventDefault(),t.defaultPrevented||e.emit(`intersectionOnModelUpdate`,t.intersection,t.object)}else e.emit(`intersectionHidden`)}),e.on(`pano.request`,t=>{let n=e.emit(`wantsMoveToPano`,t.state.panoIndex,t.options,t.userAction);n||(n=e.emit(`wantsToMoveToPano`,t.state.panoIndex,t.options,t.userAction)),n&&t.preventDefault(),t.defaultPrevented||e.emit(`panoWillLoad`,t.state.panoIndex)}),e.on(`pano.select`,t=>{e.emit(`panoSelected`,t.state.panoIndex)}),e.on(`pano.moveTo`,t=>{e.emit(`panoLoaded`,t.state.panoIndex),e.emit(`moveToPano`,t.state.panoIndex,t.userAction),e.emit(`panoWillArrive`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.moving`,t=>{e.emit(`movingToPano`,t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),e.on(`pano.arrived`,t=>{e.emit(`panoArrived`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.cancel`,t=>{e.emit(`moveToPanoCanceled`,t.state.panoIndex)}),e.on(`pano.error`,t=>{e.emit(`panoLoadError`,t.error,t.state.panoIndex)}),e.on(`pano.texture.load`,t=>{e.emit(`textureStartLoad`,t.pano.panoIndex)}),e.on(`pano.texture.success`,t=>{e.emit(`textureLoaded`,t.pano.panoIndex,t.meta)}),e.on(`pano.texture.error`,t=>{e.emit(`textureError`,t.error,t.pano.panoIndex)}),e.on(`pano.texture.abort`,t=>{e.emit(`textureAbort`,t.pano.panoIndex)}),e.on(`pano.texture.progress`,t=>{e.emit(`textureLoading`,t.progress,t.pano.panoIndex)}),e.on(`xr.session.start`,t=>{e.emit(`webXRSessionStart`)}),e.on(`xr.session.end`,t=>{e.emit(`webXRSessionEnd`)}),e.on(`xr.gesture.tap`,t=>{e.emit(`webXRControllerEvent`,`tap`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.press`,t=>{e.emit(`webXRControllerEvent`,`press`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonUp`,t=>{e.emit(`webXRControllerEvent`,`buttonUp`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonDown`,t=>{e.emit(`webXRControllerEvent`,`buttonDown`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.controller.update`,t=>{e.emit(`webXRControllerRayUpdate`,{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&e.emit(`webXRAxesUpdate`,`left`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.left.axes.up,down:t.left.axes.down,left:t.left.axes.left,right:t.left.axes.right},deltaTime:t.left.deltaTime}),t.right&&e.emit(`webXRAxesUpdate`,`right`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.right.axes.up,down:t.right.axes.down,left:t.right.axes.left,right:t.right.axes.right},deltaTime:t.right.deltaTime})}),e.on(`works.request`,t=>{e.emit(`willLoad`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.load`,t=>{e.emit(`load`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.ready`,t=>{e.emit(`loaded`,t.input,t.works[0])}),e.on(`state.change`,t=>{e.emit(`stateChange`,t.state,t.userAction)}),e.on(`currentState.change`,t=>{e.emit(`currentStateChange`,t.state,t.userAction)}),e.on(`state.set`,t=>{e.emit(`setState`,t.state)}),e.on(`state.synced`,t=>{e.emit(`stateSynced`,t.state)}),e.on(`model.request`,t=>{e.emit(`modelWillLoad`,t.work.model)}),e.on(`model.error`,t=>{e.emit(`modelLoadError`,t.error,t.model)}),e.on(`model.load`,t=>{e.emit(`modelLoaded`,t.model)}),e.on(`model.changeShownFloor`,t=>{e.emit(`modelShownFloorChange`,t.model.shownFloor,t.model.floorLength)}),e.on(`render`,t=>{e.emit(`renderFrame`,t.needsRender)}),e.on(`mode.change.request`,t=>{e.emit(`wantsChangeMode`,t.mode,t.prevMode)}),e.on(`mode.change`,t=>{e.emit(`modeChange`,t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),e.on(`helpers.visible`,t=>{e.emit(`helpersVisibleChange`,t.object.visible)}),e.on(`network.resource`,t=>{e.emit(`network`,t.source,t.requestType,t.requestState,t.detail)})}function generateDefaultVideoElement(){if(typeof window<`u`){let e=document.createElement(`video`);e.loop=!0,e.autoplay=!0,e.playsInline=!0,e.muted=!0,e.crossOrigin=``;let t=()=>{document.removeEventListener(`touchstart`,t,!1),document.removeEventListener(`mousedown`,t,!1),e.muted=!1};return document.addEventListener(`touchstart`,t,!1),document.addEventListener(`mousedown`,t,!1),e}else return{}}function initLights(){let e=new three.Group;e.name=`internalLights`;{let t=new three.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new three.Vector3(0,1,0)),e.add(t)}{let t=new three.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new three.Vector3(-1,-1,-1)),e.add(t)}{let t=new three.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new three.Vector3(1,1,1)),e.add(t)}{let t=new three.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function parseKeyValue(e){var t,n;let r={},o=e.split(/(\;|\,)/);for(let e of o){let o=e.split(`=`),s=(t=o[0])==null?void 0:t.trim(),c=(n=o[1])==null?void 0:n.trim();s&&c&&(r[s]=c)}return r}function getViewportScale(){var e;if(typeof document<`u`){let t=document.getElementsByTagName(`meta`);for(let n=0;n<t.length;n++){let r=t[n];if(r.getAttribute(`name`)===`viewport`){let t=parseKeyValue((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var realsee_png_data_url_default=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV8AAAA/CAQAAADtPwPkAAAR+0lEQVR4AezYg3LEQACH8d1cbdu23Q5qG9G47z/TN/h6tn2b/H+TUTLc7yjcOXV46OUAnUs6EbUp022ZBXc1NhoZYYd7fjDRvdcHAwrlK2QBVJ4sgoqONmY45RUT23sZ6H42F2hK5CtkMbjhZlDmUUcvq1zyieUVyjbE4I1GBfItwxG56YaUZTQwyh4P6NgJ4YYYvCuQb5kOyI03pORjiqe4Lwpq5pt1vJqfUwKWJVbSMYfppYconG+maNNQOWBZuwHTzicGel75NtFOkxr5apmV8cikcko0DrDQs863AeGl0cE0+1xy573m0/wf0cEKW6H7BWtggiMG8sy3oHRDpJMw4NWb6am/bv9znkqEzjd61t5oo5clTrjhwevO75EJRBKSRt745Z16ZEjcM73sccZplBPm8PyTcxZAkSRdHm/acJ0Z3JZhHB0BxqDHgWFZFmm0ZbCw87twI/zc3e/Cz93vPneXtU/WdQS3oTviXdY/q5PsJKfoGuQjZuO/0in1qsj85cuXrxqeAOJpGqdJOqrUutgVl2Qb0BWqp/RE8AWWVB7t2KrIzY2Wx2fWKl7yfswgxqj8lYummYa3hfwF9MuQRmbfQE4ocPDjtUWQ6Tq1M2w7gC2EcrMGtWS6xlpGKEDDcb1vUQ25zT4lrC2s0dU4gFPppKkbeIYr7NMpqjStuFg5rNU9epGyt8PXyfX4DE1bKLhR/1XPxwJhp5DAV67T9ZPwFdovhBMIGUYoRBN4wim6S3eoXVEHXdLgmwY0x6BQnO4xPJ0Ar5OVxhQF0L9UslRM4yaQQfQImnBegi8vhY2A1k6YLlrj61TwDdNQnIISwiPvpD7TwYQTssZXK47vg8y9Gp2nxRcATkozOEmdCeObSt3IIo+xf/00IDRKAaZ89PBTkHqpkA5LagKeNZKlIhqX8RcQ95GHtdYA62Y6rOg5LLsOSnoyvk4V38hFhytef+V9/3DER1P48W89o1GxE9o5vns2Mk+F7yiftafEN4nhmUv9DKEeyqI0U+l0CQg+B//sZ5+6lOuqKaTgm0LH41RHw/CsLZRk4huiYxrvP2SNr1OSS+Dr1ulBMR+K9SqHa58Oec49VgL3mXHvDr7QfuM7LMNrH1/IS30Moe64SLYBuFVJ+MbnJY7L+GrVQkFcl4ISx/fEll4ZWnz18DpcSzUCX602LqD9svDLzmdaLkP28P1+VsJjsx/4hmh6x/gmm/i6pbrGneCL9iCOg0dQUvF1UwEdVvG19r2uTXxXLz0J37eLjfZoF++tTtPnU/cWp5e8n3An0m/G+U7qjiy4PpHyV16HKx5flCxAV/H9A88nUnZ7l7KN78SBxPcQgzLAepxEScU3l7pZ6fL2+Dot8fXECfj+QRoGYAwlAfBSPrXQXQri0Pd85NJKcVw8XUdt1LZapk7YRhO1RdpmFJwW8ozekYvx2/fjM5Hr5MfQ95HvcY2a/9hoNK4yEntL+dEuGseTdNmxIPqd5v2YRjeaX8pQ8IW2ohuP7+dTN87RMK4aitx8XPsH0r2oBqNRqrv7+gmjjY7uIr6TBxBfL2MlxNRKSVp8S5CTuGgHXxfkFvh69Pq3LD4pkkd2bdRvHaSNC3/l2sQXAccdlIS+lc57qhPJwxPybT7XSxnUrdqnXuHlJHS+mjZfJfUZR9s2FuQR+EQKdSi9Am8UTnsEvlYS+L6TFwW6kl74Vjr6AFHsX89rgg8njRltK0XPOL7NyDL0IurV4VtMwafB1709vu9X4OjWHoP3z1Ii7eaQdG00Lx5n8HXyDSva/dU0Pq2vZnKYxHYMYRo1WY5ov1G7Vh4r3y+kMdgbilxeOrV0aqOFenFl8GGJig7rG0bbPRqiSRpP2AL0w+yon9dHbi43zFetnKcuw9ZLeSa+7kTw/TDfuFu0Z7Vp/uhyHfPkAZ5ufP9wLIfD49E3clR818rR089Lzyy+VRREPneICnYLX9cT8PVKQs36TbQ3i6NcCwYkxEAQ3phN4CjAvC4mFr5vrlKe7AizBKj8cu33s7i9GbeY7BHYujTjjd3Bx54SSyT4m8mxOoYOAGX/DtwvnGE1M+5v5Bgt1hbkJRW9Cxv9X81GL2i5jqaoJ4avBcCsLYp+Ru+VC5sWPpFhXt8/EPvJL2F/alJDEeIjUhcrP5P45rDeATPj+wKl7gBf1fcq+HpVnfHO1vEf//UCHgt/OxfDE3onj5UkfTaThrg3NCGoBUCtZjvgMnwQB0bG5XENeraJ5XEWvtiHkqSVRqN+uQ4lEx2o+69SeY1dC++Wcsj+LCW+H0ZE4KtDWHkGwCtrxstbFqr51e9wbz42E2fpjRQsqEn50PnM4eumO9IbujCi393Hd+3q72TI+p9DPyyfraF+c3rOx0KJyB2z7Fa1yCO8HoHzlDFhPiWD8XoB3aPppRrUQdRp1D8qE9exdgr+Zbpqf8BLfmZ/bMYbh87k58VCSswCjQoLPPw4Jnp4uFi/YQlfKB5eBd/gr6aqB973zbDAF+v5PN+NZEvm+84bSkhxUPE9C9wqbeJ7Hi+gA9Jr5ZM7x9el4mulyK0Bb2xiMTj3/iBtK77Tnii27H/MlCfsjcJY+2oTg2/U4TYWQERE0r+aCouBcx5zEZzEYrqui8JXsQW/X8FLHJ3IVbWXhQV3zAJCjFQst1F25y1arlXwhRR4Bb4rZ3VPy5d+bHEtHIPF27K16ItYuKXM5kHD10M9DKFeSpbqLlOYAlRiC99yCiDmbUf0206jPPO7b/iud71avBkHf+kQP0OrWHBFrhmt75ZyPzbLg5KmWK9oH4Oq1eFZOm0c6n48mdfer46HcLUZU3pGB8R9IDBbJ+N7v1q0J2xhudZ45tcL8PN16vq9WizwtRLwFQtKER+NDypj4QQOdJNY3NC7GEsaGtiSmDsA+CZhyx+hXFHjYrgGGXpZNvDNpn5gWWuiWkUtyEB0UcrO8Y2L9KI9K+cXLmxqruGd6pcKfycj/ij3URVgu6bPUaycN1qXTHD+KoOmjGORnH57q8rh+e9sTHk5r1+7zpEXk36bp7iiXRrBW61e5k/D0fn+EXF/OxYEypFW3ZH1HzPt4Pv5PN2Rd7VJLDZeboGnbpSPwPDcBw5f6AIysadFOR9Hr7vksoFvE91jdbdYvzpYqyIvdQPU87uKL45u3u213CA8qkYPT6H1YgwIfkz7RI5xJdomfjoV4PXjfjgaRkNGhHwG1mNt1oq0y/j+SaZ5pV0LnrlG89Dl1YkmEsc3nKKzMKskJD+fx6NhlFiohdTe5EsZIig5WPgWUYCC9Dx5TG/sA5x15LCBbzXDtx/+uh74VmMZjLDamh8JvhzQtSsoeVTNNXB/Euv96LRR/qjO+By5xTxxJ683/FB00Pj0fZz9F2GPa70Ld2hbbVptWmjWabbGCl/ZAiTsbJa5hQ9OK/eWFE4xva9nG3z1zwCtnFXjYr6c3ykxPn9QiYWEWPhA4uuiDnzBpt4EMcg0QOm28M0gP76hJuELbIdZi4PqaILpJI+RYz4ZV42y+q49wBcxIbyXTmtXgevRWPl3MmjSSJU5vB3J0TA2Uu8mtP+R5/Au4iiF6NrUUiuCieOiJpnJq8gSXzwFLFiLP8X6bV0bYvzt8TXj75eLtKPRauY1RM1HR7GwEHpFbonIWAPwjxpfqJSCyBVUsk/DFOChhC18kyiPHFvwdVGh6XFbmfLx+RRi4jaqYiCnUDO1wc4u4ovo7pfS+XFD32e9GzndwxJiHcbQ/Vz6JrBMDGYyYK5l7YOsfkS2MVePfGkLsNXLGl9hIVbWXAv9fQ5i/j6UFL1RaQffB9qlwn3tS4WxMhaxETCMz6T9ZTqCk5FznoOKL9SEXMMIUwAZW6dNfCEVX61azdxwmIbg4aHdwtcj5KVBeNiqrb2+g5M8hTskSB6exHZ5bMEIF/wCoOT128zvdXziMLbvuDu/Usmh0oG7doMmafKNSmt8hQWUnmzhjJf/RskXCzQL8aYNfLG/QPGLY5KjKtcuNPGsyGytmj0/kPi6qdXwwJCPvOTYI3zTaICCNEh9FGSWM54OX4+A1UI80RV98czWKceJf65ervsleJm164/7ganACHHn+IPz8Nby1ptcnRztRWbipArvp4/gRchodbIFvsBSWPBaW+CHtzWfauFfcmnKRuyr+Fiu1WbzGKtCPWWMHjIgU1/Mgn2B74GKfbkajHwtVIHy3uBbh0Ocj9oplCC+kIJvYuKvI9bbkUUQ2+JaG7AeknwvhLd0YUxx+SZIf4XkGeqHUCNt9N8sQdvYlwtl9H4hMzqI5dHosMIX2taCl2s6LRowaubPyld/IgcvHBJPnKGnHDLh0ArfqzlYtkv5D8++4RsAvPbwTaJzgDcIDzxIRXuEbx4NIsYupjt7gi/6idL3j1AIqPY+OPH5PGO67x/jUS9NvF6hTte7x2kaCvtSZJiMlxjxMSqEtqXr3GPMn/9y4cXUypS/ymPxbIAvmurtYl9o7dqmBV9KdbLOgsik4B3d6xW/lO7w/kfe+yfx7bFuGkwY3/C6sURDj8584rCxJH5QtnYFVrFQVL35HNoQgO0jvt228XVRC4WQPLtANyiEzb1gD/BNoy5kHa5QEnUmiq/uG2fubeXh+kwuNj8IRxAoOqiLIqfTaNw84SfLWsDmqo08k30prHVKbHuYDo7ez6U7EsLX0oJX1ltV2AOg2KfoMPPA/sTx/ZPMqF9YiN11AsHLFrHgaAT3GBvw7hO+U9TH4bX10rgVx7YgMr0p7Pow4tL8XcY3l1kJMfVQmsA3fa/wFQh3JK9eivtV+tCaD4cUjdZvIRI9BfDUDd6PkkbfKhVbOJf/jUpuQcXXlgVNv68ejr4gTflk5AZ71+jR4AvEdPg6PDNpaz6a2AQm2otoWKvVS+LVTyL4OnaE7wSNUjfdpnZb+KbQdcA7Jr5ek0od8MD9dNjiN43t4etk1v0ITfyw6gS+Q4l5XwGwbXli+u/sj6pWGu9XfyYXx75d18+lf6t0tnau/pXKv8+xzorIkltn0l4r2dYCXlO8XDRbu9xw/9g/Zko2FXSFtKPxOxn3q+caluteK5lJsboXwVP/S27cPVz28X3i3/Ll/v8eDVMPDmzwvDbwddMt+NoROhq3yXcC4D7KpmTyA+XnqEzSFQrawDeLrsNemHrEL2+24r7NlENZUMa2vyxkH2DIs628e669ubdsR4VXC7C9u79eIVJtOwgdgO/dOICHGK6jQHaIwdXN4Lwt0LWHr4d6kX8tV+ozqAs+uYCSmO2w+jd4zGNeUYL4nqZxeN5WKVgooSAClmEaYhqhdit89QC7niSbCEM2sdkBuHYxQg9ri5ZjkuhI6DMP+J7cTvEtokEx0aPscyddoFJKpSZqV7G1GTxcpmEthpnw5058c6GfwqpwzGOtGjXSJI3FLYhc+O+jSr9aGhPWQlRshS8AticLX7wnsgbXxt6gsWCpRBa0vRGQM8oB9dhmP3QAwFX4c079dJNq6Qi5xbuyTmpPSJ1Ur4UtF7GoTtmUL3zxaWqMU8P/k3cXSQ1EQRjHGdzdHTa4u7tzBs7CedhykNwF2/5jq56iU11db6Lv2yTj8hs3JoiU9sZZp5/62J5v1z9NjrDHaSbnbFMf52sHrDUVaidDxNG0o9+uLjfosfdb3jT5d5j757riJgst9NIZQ2Pn+ySZll80vjI6Wz/hQJG4vPG0L/H6poQch/dW3vL3B0u8jl0HvVj5PvHCElEF8DUAFikVYTcvmfBdDzQlvvMXSV5lP5zrXj/fJ54zuWaeeuoqkW8AwCIaqeTZKkmYrpPwR2eqN9X72W7EG57vU67OBeuMV8KXLUzv93UTTj42tvaFS++GVsc5JRyLSLJ8nzO555hFBmiSRCqMr4GwrcmGkib5xSvcwmzFK6e8s7DMa2xH4YZdZumSOwsVzFeBWdr37tpIhOpSwXqONNgZq/2KgvBt54znHN1HzlljTO4oVD5fb+prNIJXQNL1ofDKQisbPLJDv3jNSLq9OkYBEIihKIj3v7S1TRQCX5Kdl1ZQlol7LF+E++fwirfiq2sf4cTXxc6hzxffPuLEeqSWrPGWMF58TWr5viyJAP5/4EV4KePiaSE8eNRgjDy8/tyRW+FZjhS+2tlovNJovtJovNJ0uhK6Wo64SDdxEbM//KesjwAAAABJRU5ErkJggg==`,imageSize=[351,63],imageOffset=[20,20],vertices=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),uvs=new Float32Array([0,0,1,0,0,1,1,1]),index=new Uint8Array([0,1,2,1,3,2]),geometry=new three.BufferGeometry;geometry.setAttribute(`position`,new three.BufferAttribute(vertices,3)),geometry.setAttribute(`uv`,new three.BufferAttribute(uvs,2)),geometry.setIndex(new three.BufferAttribute(index,1));var material=new three.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),mesh=new three.Mesh(geometry,material);mesh.matrixAutoUpdate=!1;var scene=new three.Scene;scene.add(mesh),scene.matrixAutoUpdate=!1;var camera=new three.OrthographicCamera(-.5,.5,.5,-.5,.1,1);camera.position.set(0,0,.5),camera.lookAt(0,0,0),camera.updateMatrixWorld(!0),camera.matrixAutoUpdate=!1;var prevViewport=new three.Vector4,prevScissor=new three.Vector4;function renderPoweredByRealsee(e){if(material.map){let t=e.getViewport(prevViewport),n=e.getScissor(prevScissor),r=e.getScissorTest(),o=e.autoClear,s=n.x+imageOffset[0]/3,c=n.y+imageOffset[1]/3,l=imageSize[0]/3,u=imageSize[1]/3;e.setViewport(s,c,l,u),e.setScissor(s,c,l,u),e.setScissorTest(!0),e.autoClear=!1,e.render(scene,camera),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=o}else{let e=new three.Texture,t=new Image;t.onload=()=>{e.image=t,e.wrapS=three.ClampToEdgeWrapping,e.wrapT=three.ClampToEdgeWrapping,e.minFilter=three.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,material.needsUpdate=!0,t.onload=noop},t.src=realsee_png_data_url_default,material.map=e}}var jsContent$1=`(function(){function e(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}async function t(e={}){var t,n=e,r=!1,i=!0,a=self.location.href;if(r||i)try{new URL(\`.\`,a).href}catch{}console.log.bind(console),console.error.bind(console);var o=!1;function s(e){for(var t=0,n=e.length,r=new Uint8Array(n),i;t<n;++t)i=e.charCodeAt(t),r[t]=~i>>8&i;return r}var c,l,u=!1;function d(){var e=M.buffer;new Int8Array(e),new Int16Array(e),n.HEAPU8=l=new Uint8Array(e),new Uint16Array(e),new Int32Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function f(){if(n.preRun)for(typeof n.preRun==\`function\`&&(n.preRun=[n.preRun]);n.preRun.length;)T(n.preRun.shift());x(w)}function p(){u=!0,I.c()}function m(){if(n.postRun)for(typeof n.postRun==\`function\`&&(n.postRun=[n.postRun]);n.postRun.length;)C(n.postRun.shift());x(S)}var h;function g(){return s(\`\\0asm\\0\\0\\00\\b\\\`\\\`}}\\\`|}\\\`}\\\`||\\\`\\v\\0\\\`\\0\\\`\\0\\0\\x07aa\\0\\0\\r\\0\\0\\x07\\x07‚€€\\bAÀ¤\\v\\x07b\\0c\\0\\rd\\0
2239
+ `},LineMaterial=class extends three.ShaderMaterial{constructor(e){super({uniforms:three.UniformsUtils.clone(lineShader.uniforms),vertexShader:lineShader.vertexShader,fragmentShader:lineShader.fragmentShader,clipping:!0}),this.type=`LineMaterial`,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)}};Object.assign(LineMaterial.prototype,{isLineMaterial:!0});var LineSegments2=class extends three.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new LineSegmentsGeometry:e,this.material=t===void 0?new LineMaterial({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count),o=new three.Vector3,s=new three.Vector3;for(var c=0,l=0,u=t.count;c<u;c++,l+=2)o.fromBufferAttribute(t,c),s.fromBufferAttribute(n,c),r[l]=l===0?0:r[l-1],r[l+1]=r[l]+o.distanceTo(s);let d=new three.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new three.InterleavedBufferAttribute(d,1,0)),e.setAttribute(`instanceDistanceEnd`,new three.InterleavedBufferAttribute(d,1,1)),this}raycast(e,t){e.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let n=e.ray,r=e.camera,o=r.projectionMatrix,s=this.geometry,c=this.material,l=c.resolution,u=c.linewidth,d=s.attributes.instanceStart,f=s.attributes.instanceEnd,p=new three.Vector4,m=new three.Vector4,h=new three.Vector4,g=new three.Vector3,_=new three.Matrix4,v=new three.Line3,y=new three.Vector3;n.at(1,h),h.w=1,h.applyMatrix4(r.matrixWorldInverse),h.applyMatrix4(o),h.multiplyScalar(1/h.w),h.x*=l.x/2,h.y*=l.y/2,h.z=0,g.copy(h);let b=this.matrixWorld;_.multiplyMatrices(r.matrixWorldInverse,b);for(var S=0,C=d.count;S<C;S++){p.fromBufferAttribute(d,S),m.fromBufferAttribute(f,S),p.w=1,m.w=1,p.applyMatrix4(_),m.applyMatrix4(_),p.applyMatrix4(o),m.applyMatrix4(o),p.multiplyScalar(1/p.w),m.multiplyScalar(1/m.w);var w=p.z<-1&&m.z<-1,T=p.z>1&&m.z>1;if(w||T)continue;p.x*=l.x/2,p.y*=l.y/2,m.x*=l.x/2,m.y*=l.y/2,v.start.copy(p),v.start.z=0,v.end.copy(m),v.end.z=0;let e=v.closestPointToPointParameter(g,!0);v.at(e,y);let r=three.MathUtils.lerp(p.z,m.z,e),s=r>=-1&&r<=1;var E=g.distanceTo(y)<u*.5;if(s&&E){v.start.fromBufferAttribute(d,S),v.end.fromBufferAttribute(f,S),v.start.applyMatrix4(b),v.end.applyMatrix4(b);var D=new three.Vector3,O=new three.Vector3;n.distanceSqToSegment(v.start,v.end,O,D),t.push({point:O,pointOnLine:D,distance:n.origin.distanceTo(O),object:this,faceIndex:S})}}}};Object.assign(LineSegments2.prototype,{isLineSegments2:!0});var Line2=class extends LineSegments2{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(Line2.prototype,{isLine2:!0});var LineGeometry=class extends LineSegmentsGeometry{constructor(){super(),this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){let t=e.geometry;if(t instanceof three.Geometry){let e=new three.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof three.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}copy(){return this}};Object.assign(LineGeometry.prototype,{isLineGeometry:!0});var circleImageURL=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,DEFAULT_COLOR=14467195,POINT_SIZE=8,DEFAULT_LINEWIDTH=2,DEFAULT_DASHSCALE=20,sharedCircleTexture=null,FiveLine=class extends three.Object3D{static get version(){return`6.8.1`}constructor(e=new three.Vector3,t=new three.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0,this.line=new Line2(new LineGeometry,new LineMaterial({color:DEFAULT_COLOR,linewidth:DEFAULT_LINEWIDTH,dashScale:DEFAULT_DASHSCALE,dashed:!1}));let n=new three.BufferGeometry,r=new three.PointsMaterial({color:DEFAULT_COLOR,size:POINT_SIZE,map:sharedCircleTexture||(sharedCircleTexture=new three.TextureLoader().load(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`)),sizeAttenuation:!1,transparent:!0});this.points=new three.Points(n,r),this.points.renderOrder=11,this.points.frustumCulled=!1,this.setPoints(e,t),this.add(this.line,this.points)}setPoints(e,t){let n=[].concat(e.toArray(),t.toArray());this.points.geometry.setAttribute(`position`,new three.BufferAttribute(new Float32Array(n),3)),this.line.geometry.setPositions(n),this.line.computeLineDistances(),this.needsRender=!0}getPoints(){let e=this.points.geometry.attributes.position.array;return[new three.Vector3(e[0],e[1],e[2]),new three.Vector3(e[3],e[4],e[5])]}setMaterial(e){let t=this.line.material;for(let n in e){if(!e.hasOwnProperty(n))continue;let r=e[n];n===`dashed`?(t.dashed=r,r?t.defines.USE_DASH=``:delete t.defines.USE_DASH,t.needsUpdate=!0):t[n]=e[n]}this.needsRender=!0}setResolution(e,t){let n=this.line.material.resolution;(n.x!==e||n.y!==t)&&(n.set(e,t),this.needsRender=!0)}};Object.assign(FiveLine.prototype,{isFiveLine:!0});var Constants={Handedness:Object.freeze({NONE:`none`,LEFT:`left`,RIGHT:`right`}),ComponentState:Object.freeze({DEFAULT:`default`,TOUCHED:`touched`,PRESSED:`pressed`}),ComponentProperty:Object.freeze({BUTTON:`button`,X_AXIS:`xAxis`,Y_AXIS:`yAxis`,STATE:`state`}),ComponentType:Object.freeze({TRIGGER:`trigger`,SQUEEZE:`squeeze`,TOUCHPAD:`touchpad`,THUMBSTICK:`thumbstick`,BUTTON:`button`}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:`transform`,VISIBILITY:`visibility`})};function fetchJsonFile(e){return __awaiter(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function fetchProfilesList(e){return __awaiter(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield fetchJsonFile(`${e}/profilesList.json`)})}function fetchProfile(e,t){return __awaiter(this,arguments,void 0,function*(e,t,n=null,r=!0){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No basePath supplied`);let o=yield fetchProfilesList(t),s;if(e.profiles.some(e=>{let n=o[e];return n&&(s={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!s}),!s){if(!n)throw Error(`No matching profile name found`);let e=o[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);s={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let c=yield fetchJsonFile(s.profilePath),l;if(r){let t;if(t=c.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${s.profileId}`);t.assetPath&&(l=s.profilePath.replace(`profile.json`,t.assetPath))}return{profile:c,assetPath:l}})}var defaultComponentValues={xAxis:0,yAxis:0,button:0,state:Constants.ComponentState.DEFAULT};function normalizeAxes(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let o=Math.atan2(t,e);n=Math.cos(o),r=Math.sin(o)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var VisualResponse=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Constants.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(defaultComponentValues)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:o,normalizedYAxis:s}=normalizeAxes(e,t);switch(this.componentProperty){case Constants.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?o:.5;break;case Constants.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?s:.5;break;case Constants.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case Constants.ComponentProperty.STATE:this.valueNodeProperty===Constants.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=this.states.includes(r)?1:0;break;default:throw Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},Component=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw Error(`Invalid arguments supplied`);this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(e=>{let n=new VisualResponse(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Constants.ComponentState.DEFAULT,button:this.gamepadIndices.button===void 0?void 0:0,xAxis:this.gamepadIndices.xAxis===void 0?void 0:0,yAxis:this.gamepadIndices.yAxis===void 0?void 0:0}}get data(){return Object.assign({id:this.id},this.values)}updateFromGamepad(e){if(this.values.state=Constants.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){let t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=Constants.ComponentState.PRESSED:(t.touched||this.values.button>Constants.ButtonTouchThreshold)&&(this.values.state=Constants.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},MotionController=class{constructor(e,t,n){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No profile supplied`);this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(e=>{let t=this.layoutDescription.components[e];this.components[e]=new Component(e,t)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){let e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}},DEFAULT_PROFILES_PATH=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,DEFAULT_PROFILE=`generic-trigger`,XRControllerModel=class extends three.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof three.Mesh&&e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(e=>{Object.values(e.visualResponses).forEach(e=>{let{valueNode:t,minNode:n,maxNode:r,value:o,valueNodeProperty:s}=e;t&&(s===Constants.VisualResponseProperty.VISIBILITY?t.visible=o:s===Constants.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,o),t.position.lerpVectors(n.position,r.position,o)))})}))}};function findNodes(e,t){Object.values(e.components).forEach(e=>{let{type:n,touchPointNodeName:r,visualResponses:o}=e;if(n===Constants.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){let t=new three.Mesh(new three.SphereGeometry(.001),new three.MeshBasicMaterial({color:255}));e.touchPointNode.add(t)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(o).forEach(e=>{let{valueNodeName:n,minNodeName:r,maxNodeName:o,valueNodeProperty:s}=e;if(s===Constants.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(r),e.maxNode=t.getObjectByName(o),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${o} in the model`);return}}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)})})}function addAssetSceneToControllerModel(e,t){findNodes(e.motionController,t),e.envMap&&t.traverse(t=>{t instanceof three.Mesh&&t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)}),e.add(t)}var XRControllerModelFactory=class{constructor(e=null){this.gltfLoader=e,this.path=DEFAULT_PROFILES_PATH,this._assetCache={}}createControllerModel(e){let t=new XRControllerModel,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||fetchProfile(r,this.path,DEFAULT_PROFILE).then(({profile:e,assetPath:o})=>{t.motionController=new MotionController(r,e,o);let s=this._assetCache[t.motionController.assetUrl];if(s)n=s.scene.clone(),addAssetSceneToControllerModel(t,n);else{if(!this.gltfLoader)throw Error(`GLTFLoader not set.`);this.gltfLoader.load(t.motionController.assetUrl,e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),addAssetSceneToControllerModel(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},defaultXRPanoramaControllerInitArgs=Object.assign({},omit(defaultPanoramaControllerCustomInitArgs,[`maxLatitude`,`minLatitude`]));function mapPanoResource(e,t){if(!t)return e;let n=e.match(/\d+_[a-z].png/);return e.substring(0,n.index)+t+`/`+e.substring(n.index)}var CONTROLLER_EVNET_DELTA_TIME=300,scratchRaycaster=new three.Raycaster,scratchVector3=new three.Vector3,XRPanoramaController=class e extends PanoramaController{static parseArgs(t){if(t instanceof e)return t;let n=Object.assign(Object.assign({},t),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return super.parseArgs(n)}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`XRPanorama`})}constructor(e){super(e),this.xrManager=new XRManager(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,createEvent(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,createEvent(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new three.Raycaster,right:new three.Raycaster},this.xrControllerRay.left.params.Points={threshold:.1},this.xrControllerRay.left.firstHitOnly=!0,this.xrControllerRay.left.floorIndex=-1,this.xrControllerRay.right.params.Points={threshold:.1},this.xrControllerRay.right.firstHitOnly=!0,this.xrControllerRay.right.floorIndex=-1,this.gazeRay=null,this.pointerLines={left:new FiveLine,right:new FiveLine},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new three.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new three.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new three.Group,new three.Group];let t=this.xrManager.getController(0);this.controllerWrappers[0].add(t);let n=this.xrManager.getController(1);this.controllerWrappers[1].add(n);let r=new XRControllerModelFactory;r.gltfLoader={load(e,t){internalFetcher.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return parseGltf(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:internalFetcher})}).then(e=>t(e))}},(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`)&&this.scene.add(this.pointerLines.left,this.pointerLines.right,this.controllerWrappers[0],this.controllerWrappers[1]),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=createUuid()]={panoId:panoStringify(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:`fade`,effectEasing:defaultEffectEase,fixCameraTransform:new three.Matrix4},this.parallaxCameraMatrixs=[];let o=AnimationFrameLoop.shared.getContext();if(!o){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(o),this.on(`xr.session.start`,()=>{let e=this.xrManager.getControllerGrip(0);e.add(r.createControllerModel(e)),this.controllerWrappers[0].add(e);let t=this.xrManager.getControllerGrip(1);t.add(r.createControllerModel(t)),this.controllerWrappers[1].add(t)}),this.xrHandleState={LeftAxesUp:{touchStartTime:0,touchStart:!1},LeftAxesDown:{touchStartTime:0,touchStart:!1},LeftAxesLeft:{touchStartTime:0,touchStart:!1},LeftAxesRight:{touchStartTime:0,touchStart:!1},LeftTrigger:{touchStartTime:0,touchStart:!1},LeftPinch:{touchStartTime:0,touchStart:!1},RightAxesUp:{touchStartTime:0,touchStart:!1},RightAxesDown:{touchStartTime:0,touchStart:!1},RightAxesLeft:{touchStartTime:0,touchStart:!1},RightAxesRight:{touchStartTime:0,touchStart:!1},RightTrigger:{touchStartTime:0,touchStart:!1},RightPinch:{touchStartTime:0,touchStart:!1},Y:{touchStartTime:0,touchStart:!1},X:{touchStartTime:0,touchStart:!1},A:{touchStartTime:0,touchStart:!1},B:{touchStartTime:0,touchStart:!1}},this.xrManager.machineType===`VP`&&this.initHandEvent()}updateConfiguration(e){return super.updateConfiguration(Object.assign(Object.assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2}))}moveToPano(e,t,n){var r,o,s;let c=(r=t.effect)==null?`fade`:r;this.userAction=n,this.stopMomentumMovement();let l=panoStringify(e),u=this.works.getObserver(e);if(!u)throw Error(`Invalid PanoIndex`);let d=getImageSizeFromURL(u.images.up),f=this.imageOptions.size;f===void 0&&u&&d&&(f=Number(d)),f===void 0&&(f=2048);let p=this.imageOptions.transform,m=(e,t)=>mapPanoResource(applyImageURLOptions(e,p,t)),h=Object.assign({key:`pano.${l}`},pick(this.imageOptions,[`format`,`size`,`quality`])),g={right:u.images.work.getURL(u.images.right),left:u.images.work.getURL(u.images.left),up:u.images.work.getURL(u.images.up),down:u.images.work.getURL(u.images.down),front:u.images.work.getURL(u.images.front),back:u.images.work.getURL(u.images.back)},_=`pano:`+jsonHash([g,h,p]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===_)return;{let t=this.pendingPanoTask.panoId;(o=this.panoMeshes.get(t))==null||o.setProgress(0),this.emit(`pano.texture.abort`,createEvent(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let v=`move-to-pano-`+l;this.pending.add(v);let y=createExtendableEvent(`pano.prepare`,{prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,y),y.defaultPrevented){this.pending.delete(v);return}let b=this.modelScene.parameter,S;if(b.pano0&&b.pano0.map.name===_?S=b.pano0:b.pano1&&b.pano1.map.name===_&&(S=b.pano1),S){let n={panoId:l,effect:c,effectEasing:(s=t.effectEasing)==null?defaultEffectEase:s,leftPanoPicture:{panoId:S.panoId,map:S.map,mapHistogram:S.mapHistogram,mapSize:S.mapSize,matrix:u.matrix.clone().premultiply(u.work.transform),zoom:1},position:u.position.clone().applyMatrix4(u.work.transform),fixCameraTransform:new three.Matrix4};n.leftPanoPicture&&this.panoPictureObserverMap.set(n.leftPanoPicture,u),this.pendingPanoTask=void 0,Promise.resolve().then(()=>waitForExtendableEvent(y)).catch(e=>{let t=toError(e);return this.emit(`error`,t),t}).then(r=>{var o,s;if(!(r instanceof Error))this.pending.delete(v),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(l))==null||o.setProgress(0),this.doMoveToPano(e,n,t);else{let e=null;r instanceof Error&&(e||(e=r));let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.error`,createEvent(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(v),this.pendingPanoTask=void 0,(s=this.panoMeshes.get(l))==null||s.setProgress(0)}});return}let C=this.panoMeshes.get(l);C&&C.tap&&C.tap(),this.pendingPanoTask={panoId:l,hash:_,onLoad:n=>{var r,o;let s=n.body;if(this.destroyed)s.dispose();else{s.name=_;let n=Array.isArray(s.image)?s.image[0]:s.image,d=(r=n==null?void 0:n.width)==null?2048:r,f=new Histogram().formPixels(getRgbaDataFromCubeTexture(this.renderer,s,!0,sharedHistogramRgbaData).data),p={panoId:l,effect:c,effectEasing:(o=t.effectEasing)==null?defaultEffectEase:o,leftPanoPicture:{panoId:l,map:s,mapSize:d,mapHistogram:new three.Vector4().fromArray(f.toArray()),matrix:u.matrix.clone(),zoom:1},position:u.position.clone(),fixCameraTransform:new three.Matrix4};p.leftPanoPicture&&this.panoPictureObserverMap.set(p.leftPanoPicture,u),this.doMoveToPano(e,p,t)}},onError:e=>{let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),this.emit(`pano.error`,createEvent(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:u.panoIndex,workCode:u.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),t.moveCancelCallback&&t.moveCancelCallback()}},Promise.all([Promise.resolve().then(()=>{this.emit(`pano.texture.load`,createEvent(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(g,{imageURL:{transform:m,options:h},format:three.RGBFormat,viaAjax:!0,fetcher:getFetcher(this.fiveId,u.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,createEvent(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===_&&((r=this.panoMeshes.get(l))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=toError(t);return this.emit(`pano.texture.error`,createEvent(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>waitForExtendableEvent(y)).catch(e=>toError(e))]).then(([t,n])=>{var r,o,s,c;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(v),((r=this.pendingPanoTask)==null?void 0:r.hash)===_?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(l))==null||o.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,createEvent(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}));else{let e=null;t instanceof Error?e||(e=t):t.body.dispose(),n instanceof Error&&(e||(e=n)),this.pending.delete(v),((s=this.pendingPanoTask)==null?void 0:s.hash)===_&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(c=this.panoMeshes.get(l))==null||c.setProgress(0))}})}doMoveToPano(e,t,n={}){var r,o,s,c,l,u,d,f,p,m;let h=now(),g=createUuid();this.panoResources[g]=t;let _=1,v,y,b;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,o=this.panoResourceFromLocationMotionKeyframe(n).position,s=t.position;v=Math.max(o.distanceTo(s),1),y=[{key:n.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],b=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),r=this.locationMotion.value,o=this.panoResourceFromLocationMotionKeyframe(e).position,s=this.panoResourceFromLocationMotionKeyframe(n).position,c=t.position,l=n.value.count-r.count,u=Math.max(o.distanceTo(s),1)*l;v=u+Math.max(s.distanceTo(c),1),y=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:u/v,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let d=this.locationMotionKeyframesLength(this.locationMotion.keyframes),f=this.locationMotionKeyframesLength(y);b=this.locationMotion.getProgressVelocity(h)*d/f}let S=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?v:0),C={longitude:n.longitude,latitude:n.latitude,fov:n.fov},w=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(r=C.longitude)==null?this.camera.pose.longitude:r,latitude:(o=C.latitude)==null?this.camera.pose.latitude:o,fov:(s=C.fov)==null?this.camera.pose.fov:s,offset:t.position.clone(),distance:0}),T=this.currentPano;if(this.emit(`pano.moveTo`,createEvent(`pano.moveTo`,{options:n,prevPano:T,pano:{panoIndex:w.panoIndex,workCode:w.workCode},progress:0,state:w,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(w),this.perspToOrthoMotion.set({perspToOrtho:0},S).catch(noop),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],S).catch(noop),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=noop,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(C,S).catch(noop);else{let e=coordinatesToVector({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=coordinatesToVector({longitude:(c=C.longitude)==null?this.cameraMotion.value.longitude:c,latitude:(l=C.latitude)==null?this.cameraMotion.value.latitude:l}),r=new three.Object3D;r.lookAt(e);let o=new three.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let s=new three.Matrix4().makeRotationFromQuaternion(r.quaternion),h=new three.Matrix4().getInverse(o).premultiply(s),g=this.cameraMotion.value.fov,_=(u=C.fov)==null?this.cameraMotion.value.fov:u,v=1;t.effect===`zoomin`?v=1.5:t.effect===`zoomout`&&(v=.4);let b=_*v;for(let e=0;e<y.length-1;e++){let t=y[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(h),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(b/2/180*Math.PI)/Math.tan(g/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=C.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=C.latitude)==null?this.cameraMotion.value.latitude:f,fov:b}},{progress:1,value:{longitude:(p=C.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=C.latitude)==null?this.cameraMotion.value.latitude:m,fov:_}}],S).catch(noop)}this.locationMotion.setKeyframes(y,S,b).then(()=>{for(let e of this.modelScene.children)e instanceof Model&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:0});this.emit(`pano.arrived`,createEvent(`pano.arrived`,{options:n,prevPano:T,pano:{panoIndex:t.panoIndex,workCode:t.workCode},progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(this.currentPano);if(r&&r.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:r.images.video.size.clone(),matrix:r.images.video.matrix.clone(),panoMatrix:r.matrix.clone().premultiply(r.work.transform),alpha:1},t=createUuid(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),canplayVideo().then(o=>{o&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=noop,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=noop,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}},()=>{let e=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose));this.emit(`pano.cancel`,createEvent(`pano.cancel`,{options:n,prevPano:T,pano:{panoIndex:e.panoIndex,workCode:e.workCode},progress:0,state:e,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}checkSelectedPano(e){var t;this.stopMomentumMovement(),this.camera.getDirection(new three.Vector3).setY(0);let n=null,r=this.works.getObserver(this.currentPano);if(!r)return null;let o=r.work.observers,s=r.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&r.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||scratchVector3.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(e);if(c){let[e,r]=arrayMin(s,e=>{let t=o[e];return t?scratchVector3.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&r<this.panoTapTriggerRadius&&(n=(t=o[e])==null?null:t)}if(isNil(n)){let t=this.getForwardObserverOrNot(this.xrManager.cameraVR,e);t&&(n=t)}for(let e of this.locationMotion.keyframes){let t=this.panoResourceFromLocationMotionKeyframe(e);if(!(e.progress<this.locationMotion.progress)&&n){let e=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode});if(t.panoId===e){n=null;break}}}if(isNil(n))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!n.active){let e=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let l={workCode:n.work.workCode,panoIndex:n.panoIndex,mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,distance:0,offset:n?n.position.clone():new three.Vector3};return this.emit(`pano.select`,createEvent(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.workCode},state:l,userAction:!0,options:{},progress:0,error:null})),n&&n.active?(this.emit(`pano.request`,createEvent(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.workCode},progress:0,state:l,options:{},error:null})),{workCode:n.work.workCode,panoIndex:n.panoIndex}):null}destroy(){super.destroy()}isReady(){return!1}updateCamera(e,t,n){return Promise.resolve()}updateCameraWithKeyframes(e,t,n){return Promise.resolve()}updateTime(e,t,...n){var r,o,s,c,l,u,d,f,p;this.userAction=!0;let m={},h={},g=this.camera.getDirection(new three.Vector3),_=this.locationMotion.keyframes[0],v=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[y,b]=this.locationMotion.getKeyFrameSegment(e),S=this.panoResourceFromLocationMotionKeyframe(y),C=this.panoResourceFromLocationMotionKeyframe(b),w=this.panoResourceFromLocationMotionKeyframe(_),T=this.panoResourceFromLocationMotionKeyframe(v),E=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),h.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),m.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-b.value.count+1,n=new three.Vector3().copy(S.position),s=new three.Vector3().copy(C.position);if(m.progress=t,t>=.01&&t<=.99&&(m.progress=clamp$1(C.effectEasing(t),.01,.99)),C.leftPanoPicture&&(t<1?S.leftPanoPicture&&(m.pano0=S.leftPanoPicture):m.pano0=C.leftPanoPicture,m.pano1=C.leftPanoPicture),C.effect===`montage`?m.transition=`BLACK`:C.effect===`spread`?m.transition=`SPREAD`:m.transition=`FADE`,C.effect===`zoomin`||C.effect===`zoomout`?m.progress=Math.pow(t,3):C.effect===`model`&&this.camera.pose.distance<.01&&(m.modelAlpha=1-Math.pow(clamp$1(Math.abs(t-.5)*2,0,1),4)),t<1&&C.effect!==`fly`){if(m.pano0&&S.leftPanoPicture){let e={panoId:m.pano0.panoId,map:m.pano0.map,mapHistogram:m.pano0.mapHistogram,mapSize:m.pano0.mapSize,zoom:m.pano0.zoom,matrix:S.leftPanoPicture.matrix.clone().setPosition(C.position)},t=this.panoPictureObserverMap.get(m.pano0);t&&this.panoPictureObserverMap.set(e,t),m.pano0=e}n.copy(s),E=!0}h.distance=this.locationMotion.value.distance,h.offset=new three.Vector3(n.x+(s.x-n.x)*t,n.y+(s.y-n.y)*t,n.z+(s.z-n.z)*t);let c=[],l=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(c.push(t),n>this.locationMotion.progress&&l.push(t))}for(let e of Object.keys(this.panoResources)){if(l.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((r=m.pano0)==null?void 0:r.map)||e===((o=m.pano1)==null?void 0:o.map))continue;e.dispose(),t.leftPanoPicture=null}}c.indexOf(e)>=0||delete this.panoResources[e]}let u=panoParse(C.panoId);u!==this.currentPano&&(this.currentPano=u,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,createEvent(`pano.moving`,{userAction:this.userAction,prevPano:panoParse(w.panoId),pano:panoParse(T.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},panoParse(T.panoId)),{mode:this.mode}),clonePose(this.camera.pose)),h),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(h),this.xrManager.cameraVR.projectionMatrix.copy(this.camera.projectionMatrix),this.xrManager.cameraVR.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.xrManager.cameraVR.matrix.copy(this.camera.matrix),this.xrManager.cameraVR.position.copy(this.camera.position),this.xrManager.cameraVR.quaternion.copy(this.camera.quaternion),this.xrManager.cameraVR.scale.copy(this.camera.scale),this.xrManager.cameraVR.matrixAutoUpdate=!1,this.xrManager.cameraVR.matrixWorld.copy(this.camera.matrixWorld);let[D,O]=n,k=new three.Vector3(0,0,0),A=new three.Vector2().copy(this.camera.resolution);if(O&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let n=this.xrManager.cameraVR,r=this.xrManager.referenceSpace,o=this.xrManager.session.renderState.baseLayer,u=O.getViewerPose(r),d=(s=u==null?void 0:u.views)==null?[]:s;for(let e=0;e<d.length;e++){let t=d[e],r=n.cameras[e],s=o.getViewport(t);s&&(r.projectionMatrix.fromArray(t.projectionMatrix),r.projectionMatrixInverse.getInverse(r.projectionMatrix),r.matrix.fromArray(t.transform.matrix),r.matrix.setPosition(this.camera.position),r.matrix.decompose(r.position,r.quaternion,r.scale),r.matrixWorld.copy(r.matrix),r.matrixWorldInverse.getInverse(r.matrixWorld),r.matrixAutoUpdate=!1,k.copy(r.position),r.viewport.set(s.x,s.y,s.width,s.height),A.set(s.width,s.height))}if(this.xrManager.setProjectionFromUnion(this.xrManager.cameraVR,this.xrManager.cameraL,this.xrManager.cameraR),this.camera.quaternion.copy(this.xrManager.cameraVR.quaternion),this.camera.scale.copy(this.xrManager.cameraVR.scale),this.camera.matrix.compose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.computePose((c=h.distance)==null?this.camera.pose.distance:c),this.xrManager.session.inputSources){for(let e=0;e<this.xrManager.session.inputSources.length;e++)if(this.xrManager.session.inputSources[e]&&this.xrManager.session.inputSources[e].targetRayMode===`transient-pointer`){let t=O.getPose(this.xrManager.session.inputSources[e].targetRaySpace,r);if(t){let e=t.transform.orientation,n=new three.Quaternion(e.x,e.y,e.z,e.w),r=new three.Vector3(0,0,-1).applyQuaternion(n);this.gazeRay=new three.Raycaster(this.camera.position,r)}}}if(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`){let n=this.xrManager.session.inputSources;for(let e=0;e<n.length;e++){let t=this.xrManager.controllers[e],o=n[e];if(!o)continue;t&&t.update(o,O,r);let s=this.xrManager.getController(e),c=new three.Vector3(0,1.2,0),u=s.position.clone().add(k).sub(c);o.handedness===`left`?this.xrControllerRay.left.set(u,new three.Vector3(0,0,-1).applyEuler(s.rotation)):o.handedness===`right`&&this.xrControllerRay.right.set(u,new three.Vector3(0,0,-1).applyEuler(s.rotation)),this.controllerWrappers[e].position.copy(new three.Vector3(0,0,0).add(k).sub(c));let d=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(d.length===0){let e=this.works.getResolvedObserver(this.currentPano);d=this.xrControllerRay.right.intersectObject(this.modelScene.boundingMesh,!0).map(t=>{var n;let r=(n=e==null?void 0:e.floorIndex)==null?0:n;return Object.assign({floorIndex:r,floor:r},t)})}if(d.length>=1&&d[0].face)if(o.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=d[0].face.normal,n=t.clone(),r=d[0].point.clone();this.intersectMesh.position.copy(r);let o=r.clone().add(n);if(this.intersectMesh.lookAt(o),Math.abs(t.y)>.99){let e=this.camera.position.clone().sub(r);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0,e.length>0?(this.pointerLines.right.setPoints(u,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(u,d[0].point));let s=d[0],c=createEvent(`intersect.update`,{raycaster:(l=this.xrControllerRay.right)==null?null:l,intersection:s==null?null:s,object:this.intersectMesh});if(this.emit(`intersect.update`,c),c.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(u,d[0].point)}this.updateControllerHelper(n,e,t)}}else O||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);isEmptyObject(m)===!1&&this.modelScene.parameter.set(m),this.emit(`camera.update`,createEvent(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),clonePose(this.camera.pose))}));let j=this.works.getResolvedObserver(this.currentPano),M=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,N=this.works.getObserver(S.panoId),P=this.works.getObserver(C.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&j){let e=[],t=j.work.observers;for(let n of j.accessibleNodes){let r=t[n];r&&e.push(r)}let n=new Map;if(e.sort((e,t)=>{let r=n.get(e);r===void 0&&(r=e.standingPosition.distanceTo(j.standingPosition),n.set(e,r));let o=n.get(e);return o===void 0&&(o=t.standingPosition.distanceTo(j.standingPosition),n.set(t,o)),r-o}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let t=e[this.accessibleObserverFloorCheckCount],n=this.modelScene.models.find(e=>e.work===(t==null?void 0:t.work));if(t&&n&&n.visible){let e=.3,r=.05,o=.005,s=t.standingPosition.clone().applyMatrix4(t.work.transform),c=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode}),l=adjustPanoCircleMeshVectors.map(t=>{scratchRaycaster.ray.origin.copy(s),scratchRaycaster.ray.origin.add(scratchVector3.copy(t).setY(e)),scratchRaycaster.ray.direction.set(0,-1,0),scratchRaycaster.firstHitOnly=!0,scratchRaycaster.floorIndex=-1;let[r]=n.intersectRaycaster(scratchRaycaster);return r&&r.distance-o<=e?new three.Vector3().copy(s).setY(r.point.y+o):s});l.sort((e,t)=>t.y-e.y);let u=l[Math.floor(l.length/2)],[d]=l.filter(e=>e.distanceTo(u)<=.05);if(d){let e=new three.Vector4(s.x,s.y,s.z,d.y-s.y),t=this.adjustPanoCircleMeshPositionFix.get(c);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(c,e)}}this.accessibleObserverFloorCheckCount++}}let F=new Map;if(N)for(let e of N.accessibleNodes){let t=N.work.observers[e];if(t){let e=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode});F.set(e,t)}}if(P)for(let e of P.accessibleNodes){let t=P.work.observers[e];if(t){let e=panoStringify({panoIndex:t.panoIndex,workCode:t.work.workCode});F.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{F.get(t)?F.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),F.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),F.delete(t)}),this.panoMeshes.forEach((e,t)=>{let n=this.works.getObserver(t);if(n){let r=n.position.distanceTo(n.standingPosition)>this.aerialObserverMinHeight;if(r)e.position.copy(n.position).applyMatrix4(n.work.transform),e.scale.setScalar(18);else{e.position.copy(n.standingPosition).applyMatrix4(n.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(n.panoId);t&&(scratchVector3.set(t.x,t.y,t.z),scratchVector3.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let o=this.camera.position.clone().setY(e.position.y),s=new three.Vector3().copy(e.position).sub(o).normalize();if(t===panoStringify(this.currentPano)){let t=clamp$1((.5-o.distanceTo(e.position))/.5,0,1);s.multiplyScalar(1-t).add(g.clone().multiplyScalar(t))}if(s.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(s.x,s.z);e.quaternion.setFromEuler(new three.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||E)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(j){let n=j.work.observers,[,r]=arrayMin(j.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:j.standingPosition.distanceTo(t.standingPosition)},!0);r=clamp$1(r,2.5,1/0);let o=j.accessibleNodes.concat(j.panoIndex).map(e=>panoStringify({panoIndex:e,workCode:j.work.workCode}));this.panoMeshes.forEach((n,s)=>{let c=this.works.getObserver(s),l=!1,u=1;if(o.indexOf(s)===-1)l=!1,u=0;else if(!c)l=!1,u=0;else if(!c.loadable&&!c.active)l=!1,u=0;else{let e=n.position.clone().project(this.camera);l=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&M!==null&&panoStringify({panoIndex:M.panoIndex,workCode:M.work.workCode})===s;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);u=t<.01?0:clamp$1(r/t,.1,.85)}c&&c===P&&c.position.distanceTo(c.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(u=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(u=0),n.setCurrent(l),n.setOpacity(u),n.updateTime&&n.updateTime(e,t)})}{let e=(u=this.modelScene.parameter.progress)==null?1:u,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,o=t===0?n:r,s;if(o&&(s=this.works.getObserver(o.panoId),s||(s=this.panoPictureObserverMap.get(o))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(canUseNativeImageBitmap()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!s||!o||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:A,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new three.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=getImageSizeLevel(o.mapSize)+1,c=4;this.tiling.setObserver(s);let l={renderer:this.renderer,resolution:A,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:o.map,panoMatrix:o.matrix,panoZoom:o.zoom,minLevel:e,level:4},u=this.tiling.update(l),f={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:t,opacity:(n==null?void 0:n.panoId)===(r==null?void 0:r.panoId)?1:easeInQuart(Math.abs(((d=this.modelScene.parameter.progress)==null?0:d)-.5)*2)},p=this.modelScene.parameter.refinedScreen;(u||f.pano!==(p==null?void 0:p.pano)||f.opacity!==(p==null?void 0:p.opacity))&&this.modelScene.parameter.set(`refinedScreen`,f)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&j&&j.position.y-j.standingPosition.y>10){let e=clamp$1(this.camera.position.distanceTo(this.intersectMesh.position)*(2*Math.tan(.5*this.camera.fov/180*Math.PI))/5,.5);this.intersectMesh.scale.setScalar(e)}else this.intersectMesh.scale.setScalar(1);{let e=C.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((f=this.modelScene.parameter.pano0Depth)==null?void 0:f.panoId)!==t.panoId||((p=this.modelScene.parameter.pano1Depth)==null?void 0:p.panoId)!==n.panoId){let e=500,r=512;this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new three.WebGLCubeRenderTarget(512,{minFilter:three.NearestFilter,magFilter:three.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new three.WebGLCubeRenderTarget(512,{minFilter:three.NearestFilter,magFilter:three.NearestFilter,generateMipmaps:!1});let o=new three.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);o.matrix.copy(t.matrix),o.matrixWorld.copy(o.matrix),o.matrixAutoUpdate=!1,renderDepthCube(this.renderer,this.modelScene,o,500);let s=new three.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);s.matrix.copy(n.matrix),s.matrixWorld.copy(s.matrix),s.matrixAutoUpdate=!1,renderDepthCube(this.renderer,this.modelScene,s,500),this.modelScene.parameter.set({pano0Depth:{panoId:t.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:n.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}render(){if(this.xrManager.session&&this.xrManager.session.renderState.baseLayer){let e=this.xrManager.session.renderState.baseLayer;return this.renderer.setRenderTarget(null),this.renderer.setScissorTest(!1),this.renderer.setFramebuffer(e.framebuffer),this.renderer.render(this.scene,this.xrManager.cameraVR),this.renderer.setFramebuffer(null),!0}return!1}onPanGesture(){}onTapGesture(){}onPinchGesture(){}onMouseMove(){}onMouseOut(){}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}updateControllerHelper(e,t,n){let r=this.xrControllerRay.left,o=this.xrControllerRay.right;if(!e||e.length===0)return;let s={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let c=0;c<e.length;c++){let l=e[c].handedness,u=e[c].gamepad;switch(l){case`left`:u.axes&&(this.emitHandleEvent(u.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(u.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(u.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(u.axes[3]===1,`LeftAxesDown`,t)),u!=null&&u.buttons&&(u.buttons[4]&&this.emitHandleEvent(u.buttons[4].pressed,`X`,t),u.buttons[5]&&this.emitHandleEvent(u.buttons[5].pressed,`Y`,t),u.buttons[0]&&this.emitHandleEvent(u.buttons[0].pressed,`LeftTrigger`,t),u.buttons[1]&&this.emitHandleEvent(u.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:u.axes&&u.axes[3]<0?Math.abs(u.axes[3]):0,down:u.axes&&u.axes[3]<0?0:Math.abs(u.axes[3]),left:u.axes&&u.axes[2]<0?Math.abs(u.axes[2]):0,right:u.axes&&u.axes[2]<0?0:Math.abs(u.axes[2])},deltaTime:n};s.buttons.X=u.buttons&&u.buttons[4]?u.buttons[4].pressed:!1,s.buttons.Y=u.buttons&&u.buttons[5]?u==null?void 0:u.buttons[5].pressed:!1,s.buttons.LeftTrigger=u.buttons&&u.buttons[0]?u==null?void 0:u.buttons[0].pressed:!1,s.buttons.LeftPinch=u.buttons&&u.buttons[1]?u==null?void 0:u.buttons[1].pressed:!1,s.left=e;break;case`right`:u.axes&&(this.emitHandleEvent(u.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(u.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(u.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(u.axes[3]===1,`RightAxesDown`,t)),u.buttons&&(u.buttons[4]&&this.emitHandleEvent(u.buttons[4].pressed,`A`,t),u.buttons[5]&&this.emitHandleEvent(u.buttons[5].pressed,`B`,t),u.buttons[0]&&this.emitHandleEvent(u.buttons[0].pressed,`RightTrigger`,t),u.buttons[1]&&this.emitHandleEvent(u.buttons[1].pressed,`RightPinch`,t)),s.right={raycaster:o,axes:{up:u.axes&&u.axes[3]<0?Math.abs(u.axes[3]):0,down:u.axes&&u.axes[3]<0?0:Math.abs(u.axes[3]),left:u.axes&&u.axes[2]<0?Math.abs(u.axes[2]):0,right:u.axes&&u.axes[2]<0?0:Math.abs(u.axes[2])},deltaTime:n},s.buttons.A=u.buttons&&u.buttons[4]?u==null?void 0:u.buttons[4].pressed:!1,s.buttons.B=u.buttons&&u.buttons[5]?u==null?void 0:u.buttons[5].pressed:!1,s.buttons.RightTrigger=u.buttons&&u.buttons[0]?u==null?void 0:u.buttons[0].pressed:!1,s.buttons.RightPinch=u.buttons&&u.buttons[1]?u==null?void 0:u.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,createEvent(`xr.controller.update`,s))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,o=this.xrControllerRay.right;if(e)this.xrHandleState[t].touchStart===!1?(this.xrHandleState[t].touchStartTime=n,this.xrHandleState[t].touchStart=!0,this.emit(`xr.gesture.buttonDown`,createEvent(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:o}}}))):n-this.xrHandleState[t].touchStartTime>CONTROLLER_EVNET_DELTA_TIME&&this.emit(`xr.gesture.press`,createEvent(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:o}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,createEvent(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:o}}})),n-this.xrHandleState[t].touchStartTime<=CONTROLLER_EVNET_DELTA_TIME){let e=createEvent(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:o}}});!this.emit(`xr.gesture.tap`,e)&&!e.defaultPrevented&&t===`RightTrigger`&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[t].touchStart=!1,this.xrHandleState[t].touchStartTime=0}}initHandEvent(){if(!this.xrManager.session)throw Error(`初始化失败`);this.xrManager.session.addEventListener(`select`,e=>{this.gazeRay&&this.checkSelectedPano(this.gazeRay)})}},Controllers={Floorplan:FloorplanController,Topview:TopviewController,Panorama:PanoramaController,VRPanorama:VRPanoramaController,Model:ModelController,Mapview:MapviewController,XRPanorama:XRPanoramaController},controllersDefaultInitArgs={Floorplan:defaultFloorplanControllerCustomInitArgs,Topview:defaultTopviewControllerCustomInitArgs,Panorama:defaultPanoramaControllerCustomInitArgs,VRPanorama:defaultVRPanoramaControllerCustomInitArgs,Model:defaultModelControllerCustomInitArgs,Mapview:defaultMapviewControllerCustomInitArgs,XRPanorama:defaultXRPanoramaControllerInitArgs},PROXY_CONTROLLER_EVENT_NAMES=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.fire,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.prepare,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function initLegacyEvent(e){e.on(`initAnimation.start`,t=>{e.emit(`initAnimationWillStart`,t.state.panoIndex,t.state,t.userAction)}),e.on(`initAnimation.end`,t=>{e.emit(`initAnimationEnded`,t.state.panoIndex,t.state,t.userAction)}),e.on(`gesture.pan`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pan`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPanGesture`,t.state,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pan`,t.pointers,t.isFinal),e.emit(`panGesture`,t.state,t.isFinal))}),e.on(`gesture.tap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`tap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`tap`,t.pointers,t.isFinal),e.emit(`tapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.dbltap`,t=>{let n=!1;n=e.emit(`wantsGesture`,`dbltap`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsDblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`dbltap`,t.pointers,t.isFinal),e.emit(`dblTapGesture`,t.center.raycaster,t.center.coords,t.isFinal))}),e.on(`gesture.press`,t=>{let n=!1;n=e.emit(`wantsGesture`,`press`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`press`,t.pointers,t.isFinal),e.emit(`pressGesture`,t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),e.on(`gesture.pinch`,t=>{let n=!1;n=e.emit(`wantsGesture`,`pinch`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsPinchGesture`,t.scale,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`pinch`,t.pointers,t.isFinal),e.emit(`pinchGesture`,t.scale,t.state.fov,t.isFinal))}),e.on(`gesture.mousewheel`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseWheel`,t.pointers,t.isFinal),n&&t.preventDefault(),n=e.emit(`wantsMouseWheel`,t.center.delta,t.state.fov,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseWheel`,t.pointers,t.isFinal),e.emit(`mouseWheel`,t.center.delta,t.state.fov,t.isFinal))}),e.on(`gesture.mousemove`,t=>{let n=!1;n=e.emit(`wantsGesture`,`mouseMove`,t.pointers,t.isFinal),n&&t.preventDefault(),t.defaultPrevented||(e.emit(`gesture`,`mouseMove`,t.pointers,t.isFinal),n=e.emit(`wantsChangeCameraFov`,t.state.fov),n&&t.preventDefault())}),e.on(`gesture.momentum`,t=>{let n=!1;n=e.emit(`wantsInteriaPan`,t.state),n&&t.preventDefault(),t.defaultPrevented||e.emit(`interiaPan`,t.state,t.isFinal)}),e.on(`camera.update`,t=>{e.emit(`cameraFovUpdate`,t.state.fov,t.userAction),e.emit(`cameraDirectionUpdate`,t.state,t.userAction);let n=coordinatesToVector(t.state);n.setLength(t.state.distance);let r=t.state.offset.clone().sub(n);e.emit(`cameraPositionUpdate`,r,t.userAction),e.emit(`cameraUpdate`,t.state,t.userAction)}),e.on(`intersect.update`,t=>{if(t.intersection){let n=!1;n=e.emit(`wantsShowIntersectionOnModel`,t.raycaster),n&&t.preventDefault(),t.defaultPrevented||e.emit(`intersectionOnModelUpdate`,t.intersection,t.object)}else e.emit(`intersectionHidden`)}),e.on(`pano.request`,t=>{let n=e.emit(`wantsMoveToPano`,t.state.panoIndex,t.options,t.userAction);n||(n=e.emit(`wantsToMoveToPano`,t.state.panoIndex,t.options,t.userAction)),n&&t.preventDefault(),t.defaultPrevented||e.emit(`panoWillLoad`,t.state.panoIndex)}),e.on(`pano.select`,t=>{e.emit(`panoSelected`,t.state.panoIndex)}),e.on(`pano.moveTo`,t=>{e.emit(`panoLoaded`,t.state.panoIndex),e.emit(`moveToPano`,t.state.panoIndex,t.userAction),e.emit(`panoWillArrive`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.moving`,t=>{e.emit(`movingToPano`,t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),e.on(`pano.arrived`,t=>{e.emit(`panoArrived`,t.state.panoIndex,t.state,t.userAction)}),e.on(`pano.cancel`,t=>{e.emit(`moveToPanoCanceled`,t.state.panoIndex)}),e.on(`pano.error`,t=>{e.emit(`panoLoadError`,t.error,t.state.panoIndex)}),e.on(`pano.texture.load`,t=>{e.emit(`textureStartLoad`,t.pano.panoIndex)}),e.on(`pano.texture.success`,t=>{e.emit(`textureLoaded`,t.pano.panoIndex,t.meta)}),e.on(`pano.texture.error`,t=>{e.emit(`textureError`,t.error,t.pano.panoIndex)}),e.on(`pano.texture.abort`,t=>{e.emit(`textureAbort`,t.pano.panoIndex)}),e.on(`pano.texture.progress`,t=>{e.emit(`textureLoading`,t.progress,t.pano.panoIndex)}),e.on(`xr.session.start`,t=>{e.emit(`webXRSessionStart`)}),e.on(`xr.session.end`,t=>{e.emit(`webXRSessionEnd`)}),e.on(`xr.gesture.tap`,t=>{e.emit(`webXRControllerEvent`,`tap`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.press`,t=>{e.emit(`webXRControllerEvent`,`press`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonUp`,t=>{e.emit(`webXRControllerEvent`,`buttonUp`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.gesture.buttonDown`,t=>{e.emit(`webXRControllerEvent`,`buttonDown`,t.buttons,{raycaster:t.controllers.raycaster})}),e.on(`xr.controller.update`,t=>{e.emit(`webXRControllerRayUpdate`,{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&e.emit(`webXRAxesUpdate`,`left`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.left.axes.up,down:t.left.axes.down,left:t.left.axes.left,right:t.left.axes.right},deltaTime:t.left.deltaTime}),t.right&&e.emit(`webXRAxesUpdate`,`right`,{raycaster:{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0},axesState:{up:t.right.axes.up,down:t.right.axes.down,left:t.right.axes.left,right:t.right.axes.right},deltaTime:t.right.deltaTime})}),e.on(`works.request`,t=>{e.emit(`willLoad`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.load`,t=>{e.emit(`load`,t.input,t.works[0],e.getCurrentState())}),e.on(`works.ready`,t=>{e.emit(`loaded`,t.input,t.works[0])}),e.on(`state.change`,t=>{e.emit(`stateChange`,t.state,t.userAction)}),e.on(`currentState.change`,t=>{e.emit(`currentStateChange`,t.state,t.userAction)}),e.on(`state.set`,t=>{e.emit(`setState`,t.state)}),e.on(`state.synced`,t=>{e.emit(`stateSynced`,t.state)}),e.on(`model.request`,t=>{e.emit(`modelWillLoad`,t.work.model)}),e.on(`model.error`,t=>{e.emit(`modelLoadError`,t.error,t.model)}),e.on(`model.load`,t=>{e.emit(`modelLoaded`,t.model)}),e.on(`model.changeShownFloor`,t=>{e.emit(`modelShownFloorChange`,t.model.shownFloor,t.model.floorLength)}),e.on(`render`,t=>{e.emit(`renderFrame`,t.needsRender)}),e.on(`mode.change.request`,t=>{e.emit(`wantsChangeMode`,t.mode,t.prevMode)}),e.on(`mode.change`,t=>{e.emit(`modeChange`,t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),e.on(`helpers.visible`,t=>{e.emit(`helpersVisibleChange`,t.object.visible)}),e.on(`network.resource`,t=>{e.emit(`network`,t.source,t.requestType,t.requestState,t.detail)})}function generateDefaultVideoElement(){if(typeof window<`u`){let e=document.createElement(`video`);e.loop=!0,e.autoplay=!0,e.playsInline=!0,e.muted=!0,e.crossOrigin=``;let t=()=>{document.removeEventListener(`touchstart`,t,!1),document.removeEventListener(`mousedown`,t,!1),e.muted=!1};return document.addEventListener(`touchstart`,t,!1),document.addEventListener(`mousedown`,t,!1),e}else return{}}function initLights(){let e=new three.Group;e.name=`internalLights`;{let t=new three.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new three.Vector3(0,1,0)),e.add(t)}{let t=new three.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new three.Vector3(-1,-1,-1)),e.add(t)}{let t=new three.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new three.Vector3(1,1,1)),e.add(t)}{let t=new three.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function parseKeyValue(e){var t,n;let r={},o=e.split(/(\;|\,)/);for(let e of o){let o=e.split(`=`),s=(t=o[0])==null?void 0:t.trim(),c=(n=o[1])==null?void 0:n.trim();s&&c&&(r[s]=c)}return r}function getViewportScale(){var e;if(typeof document<`u`){let t=document.getElementsByTagName(`meta`);for(let n=0;n<t.length;n++){let r=t[n];if(r.getAttribute(`name`)===`viewport`){let t=parseKeyValue((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var realsee_png_data_url_default=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV8AAAA/CAQAAADtPwPkAAAR+0lEQVR4AezYg3LEQACH8d1cbdu23Q5qG9G47z/TN/h6tn2b/H+TUTLc7yjcOXV46OUAnUs6EbUp022ZBXc1NhoZYYd7fjDRvdcHAwrlK2QBVJ4sgoqONmY45RUT23sZ6H42F2hK5CtkMbjhZlDmUUcvq1zyieUVyjbE4I1GBfItwxG56YaUZTQwyh4P6NgJ4YYYvCuQb5kOyI03pORjiqe4Lwpq5pt1vJqfUwKWJVbSMYfppYconG+maNNQOWBZuwHTzicGel75NtFOkxr5apmV8cikcko0DrDQs863AeGl0cE0+1xy573m0/wf0cEKW6H7BWtggiMG8sy3oHRDpJMw4NWb6am/bv9znkqEzjd61t5oo5clTrjhwevO75EJRBKSRt745Z16ZEjcM73sccZplBPm8PyTcxZAkSRdHm/acJ0Z3JZhHB0BxqDHgWFZFmm0ZbCw87twI/zc3e/Cz93vPneXtU/WdQS3oTviXdY/q5PsJKfoGuQjZuO/0in1qsj85cuXrxqeAOJpGqdJOqrUutgVl2Qb0BWqp/RE8AWWVB7t2KrIzY2Wx2fWKl7yfswgxqj8lYummYa3hfwF9MuQRmbfQE4ocPDjtUWQ6Tq1M2w7gC2EcrMGtWS6xlpGKEDDcb1vUQ25zT4lrC2s0dU4gFPppKkbeIYr7NMpqjStuFg5rNU9epGyt8PXyfX4DE1bKLhR/1XPxwJhp5DAV67T9ZPwFdovhBMIGUYoRBN4wim6S3eoXVEHXdLgmwY0x6BQnO4xPJ0Ar5OVxhQF0L9UslRM4yaQQfQImnBegi8vhY2A1k6YLlrj61TwDdNQnIISwiPvpD7TwYQTssZXK47vg8y9Gp2nxRcATkozOEmdCeObSt3IIo+xf/00IDRKAaZ89PBTkHqpkA5LagKeNZKlIhqX8RcQ95GHtdYA62Y6rOg5LLsOSnoyvk4V38hFhytef+V9/3DER1P48W89o1GxE9o5vns2Mk+F7yiftafEN4nhmUv9DKEeyqI0U+l0CQg+B//sZ5+6lOuqKaTgm0LH41RHw/CsLZRk4huiYxrvP2SNr1OSS+Dr1ulBMR+K9SqHa58Oec49VgL3mXHvDr7QfuM7LMNrH1/IS30Moe64SLYBuFVJ+MbnJY7L+GrVQkFcl4ISx/fEll4ZWnz18DpcSzUCX602LqD9svDLzmdaLkP28P1+VsJjsx/4hmh6x/gmm/i6pbrGneCL9iCOg0dQUvF1UwEdVvG19r2uTXxXLz0J37eLjfZoF++tTtPnU/cWp5e8n3An0m/G+U7qjiy4PpHyV16HKx5flCxAV/H9A88nUnZ7l7KN78SBxPcQgzLAepxEScU3l7pZ6fL2+Dot8fXECfj+QRoGYAwlAfBSPrXQXQri0Pd85NJKcVw8XUdt1LZapk7YRhO1RdpmFJwW8ozekYvx2/fjM5Hr5MfQ95HvcY2a/9hoNK4yEntL+dEuGseTdNmxIPqd5v2YRjeaX8pQ8IW2ohuP7+dTN87RMK4aitx8XPsH0r2oBqNRqrv7+gmjjY7uIr6TBxBfL2MlxNRKSVp8S5CTuGgHXxfkFvh69Pq3LD4pkkd2bdRvHaSNC3/l2sQXAccdlIS+lc57qhPJwxPybT7XSxnUrdqnXuHlJHS+mjZfJfUZR9s2FuQR+EQKdSi9Am8UTnsEvlYS+L6TFwW6kl74Vjr6AFHsX89rgg8njRltK0XPOL7NyDL0IurV4VtMwafB1709vu9X4OjWHoP3z1Ii7eaQdG00Lx5n8HXyDSva/dU0Pq2vZnKYxHYMYRo1WY5ov1G7Vh4r3y+kMdgbilxeOrV0aqOFenFl8GGJig7rG0bbPRqiSRpP2AL0w+yon9dHbi43zFetnKcuw9ZLeSa+7kTw/TDfuFu0Z7Vp/uhyHfPkAZ5ufP9wLIfD49E3clR818rR089Lzyy+VRREPneICnYLX9cT8PVKQs36TbQ3i6NcCwYkxEAQ3phN4CjAvC4mFr5vrlKe7AizBKj8cu33s7i9GbeY7BHYujTjjd3Bx54SSyT4m8mxOoYOAGX/DtwvnGE1M+5v5Bgt1hbkJRW9Cxv9X81GL2i5jqaoJ4avBcCsLYp+Ru+VC5sWPpFhXt8/EPvJL2F/alJDEeIjUhcrP5P45rDeATPj+wKl7gBf1fcq+HpVnfHO1vEf//UCHgt/OxfDE3onj5UkfTaThrg3NCGoBUCtZjvgMnwQB0bG5XENeraJ5XEWvtiHkqSVRqN+uQ4lEx2o+69SeY1dC++Wcsj+LCW+H0ZE4KtDWHkGwCtrxstbFqr51e9wbz42E2fpjRQsqEn50PnM4eumO9IbujCi393Hd+3q72TI+p9DPyyfraF+c3rOx0KJyB2z7Fa1yCO8HoHzlDFhPiWD8XoB3aPppRrUQdRp1D8qE9exdgr+Zbpqf8BLfmZ/bMYbh87k58VCSswCjQoLPPw4Jnp4uFi/YQlfKB5eBd/gr6aqB973zbDAF+v5PN+NZEvm+84bSkhxUPE9C9wqbeJ7Hi+gA9Jr5ZM7x9el4mulyK0Bb2xiMTj3/iBtK77Tnii27H/MlCfsjcJY+2oTg2/U4TYWQERE0r+aCouBcx5zEZzEYrqui8JXsQW/X8FLHJ3IVbWXhQV3zAJCjFQst1F25y1arlXwhRR4Bb4rZ3VPy5d+bHEtHIPF27K16ItYuKXM5kHD10M9DKFeSpbqLlOYAlRiC99yCiDmbUf0206jPPO7b/iud71avBkHf+kQP0OrWHBFrhmt75ZyPzbLg5KmWK9oH4Oq1eFZOm0c6n48mdfer46HcLUZU3pGB8R9IDBbJ+N7v1q0J2xhudZ45tcL8PN16vq9WizwtRLwFQtKER+NDypj4QQOdJNY3NC7GEsaGtiSmDsA+CZhyx+hXFHjYrgGGXpZNvDNpn5gWWuiWkUtyEB0UcrO8Y2L9KI9K+cXLmxqruGd6pcKfycj/ij3URVgu6bPUaycN1qXTHD+KoOmjGORnH57q8rh+e9sTHk5r1+7zpEXk36bp7iiXRrBW61e5k/D0fn+EXF/OxYEypFW3ZH1HzPt4Pv5PN2Rd7VJLDZeboGnbpSPwPDcBw5f6AIysadFOR9Hr7vksoFvE91jdbdYvzpYqyIvdQPU87uKL45u3u213CA8qkYPT6H1YgwIfkz7RI5xJdomfjoV4PXjfjgaRkNGhHwG1mNt1oq0y/j+SaZ5pV0LnrlG89Dl1YkmEsc3nKKzMKskJD+fx6NhlFiohdTe5EsZIig5WPgWUYCC9Dx5TG/sA5x15LCBbzXDtx/+uh74VmMZjLDamh8JvhzQtSsoeVTNNXB/Euv96LRR/qjO+By5xTxxJ683/FB00Pj0fZz9F2GPa70Ld2hbbVptWmjWabbGCl/ZAiTsbJa5hQ9OK/eWFE4xva9nG3z1zwCtnFXjYr6c3ykxPn9QiYWEWPhA4uuiDnzBpt4EMcg0QOm28M0gP76hJuELbIdZi4PqaILpJI+RYz4ZV42y+q49wBcxIbyXTmtXgevRWPl3MmjSSJU5vB3J0TA2Uu8mtP+R5/Au4iiF6NrUUiuCieOiJpnJq8gSXzwFLFiLP8X6bV0bYvzt8TXj75eLtKPRauY1RM1HR7GwEHpFbonIWAPwjxpfqJSCyBVUsk/DFOChhC18kyiPHFvwdVGh6XFbmfLx+RRi4jaqYiCnUDO1wc4u4ovo7pfS+XFD32e9GzndwxJiHcbQ/Vz6JrBMDGYyYK5l7YOsfkS2MVePfGkLsNXLGl9hIVbWXAv9fQ5i/j6UFL1RaQffB9qlwn3tS4WxMhaxETCMz6T9ZTqCk5FznoOKL9SEXMMIUwAZW6dNfCEVX61azdxwmIbg4aHdwtcj5KVBeNiqrb2+g5M8hTskSB6exHZ5bMEIF/wCoOT128zvdXziMLbvuDu/Usmh0oG7doMmafKNSmt8hQWUnmzhjJf/RskXCzQL8aYNfLG/QPGLY5KjKtcuNPGsyGytmj0/kPi6qdXwwJCPvOTYI3zTaICCNEh9FGSWM54OX4+A1UI80RV98czWKceJf65ervsleJm164/7ganACHHn+IPz8Nby1ptcnRztRWbipArvp4/gRchodbIFvsBSWPBaW+CHtzWfauFfcmnKRuyr+Fiu1WbzGKtCPWWMHjIgU1/Mgn2B74GKfbkajHwtVIHy3uBbh0Ocj9oplCC+kIJvYuKvI9bbkUUQ2+JaG7AeknwvhLd0YUxx+SZIf4XkGeqHUCNt9N8sQdvYlwtl9H4hMzqI5dHosMIX2taCl2s6LRowaubPyld/IgcvHBJPnKGnHDLh0ArfqzlYtkv5D8++4RsAvPbwTaJzgDcIDzxIRXuEbx4NIsYupjt7gi/6idL3j1AIqPY+OPH5PGO67x/jUS9NvF6hTte7x2kaCvtSZJiMlxjxMSqEtqXr3GPMn/9y4cXUypS/ymPxbIAvmurtYl9o7dqmBV9KdbLOgsik4B3d6xW/lO7w/kfe+yfx7bFuGkwY3/C6sURDj8584rCxJH5QtnYFVrFQVL35HNoQgO0jvt228XVRC4WQPLtANyiEzb1gD/BNoy5kHa5QEnUmiq/uG2fubeXh+kwuNj8IRxAoOqiLIqfTaNw84SfLWsDmqo08k30prHVKbHuYDo7ez6U7EsLX0oJX1ltV2AOg2KfoMPPA/sTx/ZPMqF9YiN11AsHLFrHgaAT3GBvw7hO+U9TH4bX10rgVx7YgMr0p7Pow4tL8XcY3l1kJMfVQmsA3fa/wFQh3JK9eivtV+tCaD4cUjdZvIRI9BfDUDd6PkkbfKhVbOJf/jUpuQcXXlgVNv68ejr4gTflk5AZ71+jR4AvEdPg6PDNpaz6a2AQm2otoWKvVS+LVTyL4OnaE7wSNUjfdpnZb+KbQdcA7Jr5ek0od8MD9dNjiN43t4etk1v0ITfyw6gS+Q4l5XwGwbXli+u/sj6pWGu9XfyYXx75d18+lf6t0tnau/pXKv8+xzorIkltn0l4r2dYCXlO8XDRbu9xw/9g/Zko2FXSFtKPxOxn3q+caluteK5lJsboXwVP/S27cPVz28X3i3/Ll/v8eDVMPDmzwvDbwddMt+NoROhq3yXcC4D7KpmTyA+XnqEzSFQrawDeLrsNemHrEL2+24r7NlENZUMa2vyxkH2DIs628e669ubdsR4VXC7C9u79eIVJtOwgdgO/dOICHGK6jQHaIwdXN4Lwt0LWHr4d6kX8tV+ozqAs+uYCSmO2w+jd4zGNeUYL4nqZxeN5WKVgooSAClmEaYhqhdit89QC7niSbCEM2sdkBuHYxQg9ri5ZjkuhI6DMP+J7cTvEtokEx0aPscyddoFJKpSZqV7G1GTxcpmEthpnw5058c6GfwqpwzGOtGjXSJI3FLYhc+O+jSr9aGhPWQlRshS8AticLX7wnsgbXxt6gsWCpRBa0vRGQM8oB9dhmP3QAwFX4c079dJNq6Qi5xbuyTmpPSJ1Ur4UtF7GoTtmUL3zxaWqMU8P/k3cXSQ1EQRjHGdzdHTa4u7tzBs7CedhykNwF2/5jq56iU11db6Lv2yTj8hs3JoiU9sZZp5/62J5v1z9NjrDHaSbnbFMf52sHrDUVaidDxNG0o9+uLjfosfdb3jT5d5j757riJgst9NIZQ2Pn+ySZll80vjI6Wz/hQJG4vPG0L/H6poQch/dW3vL3B0u8jl0HvVj5PvHCElEF8DUAFikVYTcvmfBdDzQlvvMXSV5lP5zrXj/fJ54zuWaeeuoqkW8AwCIaqeTZKkmYrpPwR2eqN9X72W7EG57vU67OBeuMV8KXLUzv93UTTj42tvaFS++GVsc5JRyLSLJ8nzO555hFBmiSRCqMr4GwrcmGkib5xSvcwmzFK6e8s7DMa2xH4YZdZumSOwsVzFeBWdr37tpIhOpSwXqONNgZq/2KgvBt54znHN1HzlljTO4oVD5fb+prNIJXQNL1ofDKQisbPLJDv3jNSLq9OkYBEIihKIj3v7S1TRQCX5Kdl1ZQlol7LF+E++fwirfiq2sf4cTXxc6hzxffPuLEeqSWrPGWMF58TWr5viyJAP5/4EV4KePiaSE8eNRgjDy8/tyRW+FZjhS+2tlovNJovtJovNJ0uhK6Wo64SDdxEbM//KesjwAAAABJRU5ErkJggg==`,imageSize=[351,63],imageOffset=[20,20],vertices=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),uvs=new Float32Array([0,0,1,0,0,1,1,1]),index=new Uint8Array([0,1,2,1,3,2]),geometry=new three.BufferGeometry;geometry.setAttribute(`position`,new three.BufferAttribute(vertices,3)),geometry.setAttribute(`uv`,new three.BufferAttribute(uvs,2)),geometry.setIndex(new three.BufferAttribute(index,1));var material=new three.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),mesh=new three.Mesh(geometry,material);mesh.matrixAutoUpdate=!1;var scene=new three.Scene;scene.add(mesh),scene.matrixAutoUpdate=!1;var camera=new three.OrthographicCamera(-.5,.5,.5,-.5,.1,1);camera.position.set(0,0,.5),camera.lookAt(0,0,0),camera.updateMatrixWorld(!0),camera.matrixAutoUpdate=!1;var prevViewport=new three.Vector4,prevScissor=new three.Vector4;function renderPoweredByRealsee(e){if(material.map){let t=e.getViewport(prevViewport),n=e.getScissor(prevScissor),r=e.getScissorTest(),o=e.autoClear,s=n.x+imageOffset[0]/3,c=n.y+imageOffset[1]/3,l=imageSize[0]/3,u=imageSize[1]/3;e.setViewport(s,c,l,u),e.setScissor(s,c,l,u),e.setScissorTest(!0),e.autoClear=!1,e.render(scene,camera),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=o}else{let e=new three.Texture,t=new Image;t.onload=()=>{e.image=t,e.wrapS=three.ClampToEdgeWrapping,e.wrapT=three.ClampToEdgeWrapping,e.minFilter=three.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,material.needsUpdate=!0,t.onload=noop},t.src=realsee_png_data_url_default,material.map=e}}var jsContent$1=`(function(){function e(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}async function t(e={}){var t,n=e,r=!1,i=!0,a=self.location.href;if(r||i)try{new URL(\`.\`,a).href}catch{}console.log.bind(console),console.error.bind(console);var o=!1;function s(e){for(var t=0,n=e.length,r=new Uint8Array(n),i;t<n;++t)i=e.charCodeAt(t),r[t]=~i>>8&i;return r}var c,l,u=!1;function d(){var e=M.buffer;new Int8Array(e),new Int16Array(e),n.HEAPU8=l=new Uint8Array(e),new Uint16Array(e),new Int32Array(e),n.HEAPU32=new Uint32Array(e),n.HEAPF32=new Float32Array(e),new Float64Array(e),new BigInt64Array(e),new BigUint64Array(e)}function f(){if(n.preRun)for(typeof n.preRun==\`function\`&&(n.preRun=[n.preRun]);n.preRun.length;)T(n.preRun.shift());x(w)}function p(){u=!0,I.c()}function m(){if(n.postRun)for(typeof n.postRun==\`function\`&&(n.postRun=[n.postRun]);n.postRun.length;)C(n.postRun.shift());x(S)}var h;function g(){return s(\`\\0asm\\0\\0\\00\\b\\\`\\\`}}\\\`|}\\\`}\\\`||\\\`\\v\\0\\\`\\0\\\`\\0\\0\\x07aa\\0\\0\\r\\0\\0\\x07\\x07‚€€\\bAÀ¤\\v\\x07b\\0c\\0\\rd\\0
2240
2240
  e\\0\\ff\\0\\v\\f
2241
2241
  úT\\rO| \\0 \\0¢"\\0 \\0 \\0¢"¢ \\0DiPîàB“ù>¢D'è‡ÀV¿\\xA0¢ DB:áSU¥?¢ \\0D^\\fýÿÿß¿¢D\\0\\0\\0\\0\\0\\0ð?\\xA0\\xA0\\xA0¶\\vT~@AÀ (\\0"­ \\0­B\\x07|Bøÿÿÿƒ|"BÿÿÿÿX@ §"\\0?\\0AtM\\r \\0\\0\\r\\vAÄ A06\\0A\\vAÀ \\x006\\0 \\vK| \\0 \\0 \\0¢"¢"  ¢¢ D§F;Œ‡ÍÆ>¢DtçÊâù\\0*¿\\xA0¢  D²ûn‰?¢Dw¬ËTUUÅ¿\\xA0¢ \\0\\xA0\\xA0¶\\v¨\\0@ A€\\bN@ \\0D\\0\\0\\0\\0\\0\\0à¢!\\0 AÿI@ Aÿ\\x07k!\\f\\v \\0D\\0\\0\\0\\0\\0\\0à¢!\\0Aý  AýO\\x1BAþk!\\f\\v AxJ\\r\\0 \\0D\\0\\0\\0\\0\\0\\0\\\`¢!\\0 A¸pK@ AÉ\\x07j!\\f\\v \\0D\\0\\0\\0\\0\\0\\0\\\`¢!\\0Aðh  AðhM\\x1BA’j!\\v \\0 Aÿ\\x07j­B4†¿¢\\v…} \\0¼"AvAÿq"A•M} Aý\\0M@ \\0C\\0\\0\\0\\0”\\v} \\0‹"\\0C\\0\\0\\0K’C\\0\\0\\0˒ \\0“"C\\0\\0\\0?^@ \\0 ’C\\0\\0€¿’\\f\\v \\0 ’"\\0 C\\0\\0\\0¿_E\\r\\0 \\0C\\0\\0€?’\\v"\\0Œ \\0 A\\0H\\x1B \\0\\v\\v!\\0 \\0C\\0\\0\\0\\0—C\\0\\0\\0\\0 \\0¼Aÿÿÿÿ\\x07qA€€€ü\\x07M\\x1B\\v+\\0 \\0 \\0 \\0CkÓ\\r¼”Cº/½’”Cuª*>’” \\0C®å4¿”C\\0\\0€?’•\\vÈ| \\0C\\\`B¢\\r]A\\0AÿA}C\\0\\0\\0\\0 \\0¼"A€€€üF\\r\\0@ A€€€ü\\x07kAÿÿÿ‡xM@ At"E@#\\0Ak"C\\0\\0€¿8\\f *\\fC\\0\\0\\0\\0•\\f\\v A€€€ü\\x07F\\r A€€€xI A\\0NqE@ \\0 \\0“"\\0 \\0•\\f\\v \\0C\\0\\0\\0K”¼A€€€Ü\\0k!\\vAˆ
2242
2242
  +\\0  A€€Ìùk"A€€€|qk¾» AvAðq"+€\\b¢D\\0\\0\\0\\0\\0\\0ð¿\\xA0" ¢"¢A
@@ -2350,4 +2350,4 @@ AÐ\\0lj"\\v*< \\0*8"” \\v*8 \\0*("” \\v*0 \\0*\\b"” \\0*" \\v*4
2350
2350
   \\rj   ”  ”  ”’’’"C\\0\\0€\\\\ ¼"
2351
2351
  AA€€€€x
2352
2352
  A\\0H\\x1BsA€€€ü\\x07\\v6\\0 \\fAj!\\f\\f\\v\\0\\v\\0\\v \\f\\v\\0\\v\\v \\0A\\b\\v\`)}function _(e){return e}function v(e,t){var n,r=_(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}function y(){return{a:P}}function b(){function e(e,t){return I=e.exports,N(I),d(),I}var t=y();return n.instantiateWasm?new Promise((r,i)=>{n.instantiateWasm(t,(t,n)=>{r(e(t,n))})}):(h??=g(),e(v(h,t)[0]))}for(var x=e=>{for(;e.length>0;)e.shift()(n)},S=[],C=e=>S.push(e),w=[],T=e=>w.push(e),E=()=>2147483648,D=(e,t)=>Math.ceil(e/t)*t,O=e=>{var t=(e-M.buffer.byteLength+65535)/65536|0;try{return M.grow(t),d(),1}catch{}},k=e=>{var t=l.length;e>>>=0;var n=E();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),O(Math.min(n,D(Math.max(e,i),65536))))return!0}return!1},A=new Uint8Array(123),j=25;j>=0;--j)A[48+j]=52+j,A[65+j]=j,A[97+j]=26+j;if(A[43]=62,A[47]=63,n.noExitRuntime&&n.noExitRuntime,n.print&&n.print,n.printErr&&n.printErr,n.wasmBinary&&n.wasmBinary,n.arguments&&n.arguments,n.thisProgram&&n.thisProgram,n.preInit)for(typeof n.preInit==\`function\`&&(n.preInit=[n.preInit]);n.preInit.length>0;)n.preInit.shift()();var M;function N(e){n._sort=e.d,n._malloc=e.e,n._free=e.f,M=e.b,e.__indirect_function_table}var P={a:k};function F(){f();function e(){n.calledRun=!0,!o&&(p(),c?.(n),n.onRuntimeInitialized?.(),m())}n.setStatus?(n.setStatus(\`Running...\`),setTimeout(()=>{setTimeout(()=>n.setStatus(\`\`),1),e()},1)):e()}var I=b();return F(),t=u?n:new Promise((e,t)=>{c=e}),t}let n;function r(){return e(this,void 0,void 0,function*(){n=yield t()})}let i,a,o,s,c,l,u,d,f,p,m=0,h=0,g=!1,_=[],v=!0,y=!0,b=!1,x=!1,S=!1,C=65536,w=()=>e(void 0,void 0,void 0,function*(){if(b){x=!0;return}b=!0,x=!1,n||(yield r());let e=2**Math.ceil(Math.log2(i.vertexCount));m<e&&(m>0&&(n._free(a),n._free(s),n._free(c),n._free(l),n._free(u),n._free(p)),m=e,a=n._malloc(64),s=n._malloc(m*4),c=n._malloc(3*m*4),l=n._malloc(m*4),u=n._malloc(m*4),p=n._malloc(m*4)),g||=(d=n._malloc(C*4),f=n._malloc(C*4),!0),h<i.transforms.length&&(h>0&&n._free(o),h=i.transforms.length,o=n._malloc(h*4)),b=!1,x&&(x=!1,yield w())}),T=()=>{if(b||x||!n)return;b=!0,y&&=(n.HEAPF32.set(i.positions,c/4),n.HEAPF32.set(i.transforms,o/4),n.HEAPU32.set(i.transformIndices,s/4),!1),n.HEAPF32.set(new Float32Array(_),a/4);let e=n._sort(a,o,s,i.vertexCount,c,l,u,d,f,p),t=Math.min(e,i.vertexCount),r=new Uint32Array(n.HEAPU32.buffer,u,t),m=new Uint32Array(r.slice().buffer);self.postMessage({depthIndex:m,generation:i.generation},[m.buffer]),b=!1,v=!1},E=()=>{S||(S=!0,v&&T(),setTimeout(()=>{S=!1,E()}))};self.onmessage=e=>new Promise(t=>{if(e.data.warmup){r().finally(()=>t(!0));return}e.data.sortData&&(i={positions:e.data.sortData.positions,transforms:e.data.sortData.transforms,transformIndices:e.data.sortData.transformIndices,vertexCount:e.data.sortData.vertexCount,generation:e.data.sortData.generation??0},v=!0,y=!0,w()),e.data.viewProj?(e.data.viewProj.every(e=>_.includes(e))===!1&&(_=e.data.viewProj,v=!0),E(),t(!0)):t(!0)})})();`,blob=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,jsContent],{type:`text/javascript;charset=utf-8`});function WorkerWrapper(e){let t;try{if(t=blob&&(self.URL||self.webkitURL).createObjectURL(blob),!t)throw``;let n=new Worker(t,{name:e==null?void 0:e.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(jsContent),{name:e==null?void 0:e.name})}}var vertex_default=function(...e){let t=113,n=126,r=0,o=``;return e[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}("}rpvv|{-uvtu}-sy|nH}rpvv|{-uvtu}-v{Hnvor-sy|n-}ynV{qr\x07H{vs|z-uvtu}-nz}yr?Q-lr\x07rH{vs|z-uvtu}-nz}yr?Q-ln{s|zH{vs|z-uvtu}-nz}yr?Q-ln{s|zV{qvprH{vs|z-uvtu}-nz}yr?Q-lyn\brV{qvprH{vs|z-uvtu}-nz}yr?Q-luar\x07rH{vs|z-rp?-luar\x07r`v rH{vs|z-v{-lzn\x07`uQrtrrH0vs-[bZlT`lPYV]]R_`-K-=----{vs|z-rp?-lyn\brPyv}}r_n{trh[bZlT`lYNfR_`jH----{vs|z-znA-lpyv}}rZnvprV{rrh[bZlT`lPYV]]R_`jH0r{qvs{vs|z-rp?-r|yv|{H{vs|z-o||y-lnttrtnv|{R{noyrqH{vs|z-sy|n-lnttrtnv|{]|trH{vs|z-sy|n-lnttrtnv|{]|v{Qnv|{H{vs|z-rp@-lnttrtnv|{O|{qZv{H{vs|z-rp@-lnttrtnv|{O|{qZn\x07Hn\bv{t-rpA-P|y|Hn\bv{t-rp?-]|vv|{Hn\bv{t-rp?-bHp|{-sy|n-\0E-J-\05E;=6Hp|{-sy|n-xr{ry?Q`v r-J-=;@Hp|{-sy|n-zn\x07`prr{`}npr`}yn`v r-J-?=AE;=Hp|{-sy|n-]V-J-@;>A>BF?CBH<<-Y|t:pnyr-qrp|qv{t-p|{n{-5znpuv{t-qnn;p}}6p|{-sy|n-Y[l`PNYRlZV[-J-:>?;=Hp|{-sy|n-Y[l`PNYRlZNe-J-F;=H<<-`U-p|{n{p|{-sy|n-`UlP>-J-=;AEEC=?B>>F=?F>FFHp|{-sy|n-`UlP?l=-J->;=F?BAEAHp|{-sy|n-`UlP?l>-J-:>;=F?BAEAHp|{-sy|n-`UlP?l?-J-=;@>B@F>CHp|{-sy|n-`UlP?l@-J-:>;=F?BAEAHp|{-sy|n-`UlP?lA-J-=;BAC?DA?H<<-Qrp|qr-y|t:r{p|qrq-v{E-pnyr-onpx-|-sy|nsy|n-qrp|qrY|t`pnyr5v{-r{p|qrq6-\n----vs-5r{p|qrq-JJ-=6-r{-=;=H-<<-?QT`-znxr----sy|n-{|znyv rq-J-5sy|n5r{p|qrq6-:->;=6-<-?BA;=H----r{-r\x07}5{|znyv rq-7-5Y[l`PNYRlZNe-:-Y[l`PNYRlZV[6-8-Y[l`PNYRlZV[6H\f<<-Qrp|qr-|pnurqny-n\x07v:n{tyr-\0nr{v|{-s|z-@-v{E-nyrrpA-qrp|qr^n\\pnurqny5v{-r{pe9-v{-r{pf9-v{-r{pg6-\n----<<-Qrp|qr-|pnurqny-qvrpv|{----sy|n-|\x07-J-sy|n5r{pe6-<-?BB;=-7-?;=-:->;=H----sy|n-|\b-J-sy|n5r{pf6-<-?BB;=-7-?;=-:->;=H----<<-\\pnurqny-|-{v-rp|----sy|n-| -J->;=-:-no5|\x076-:-no5|\b6H----vs-5| -I-=;=6-\n--------sy|n-z}e-J-|\x07H--------|\x07-J-5>;=-:-no5|\b66-7-5|\x07-KJ-=;=-L->;=-G-:>;=6H--------|\b-J-5>;=-:-no5z}e66-7-5|\b-KJ-=;=-L->;=-G-:>;=6H----\f----rp@-n\x07v-J-{|znyv r5rp@5|\x079-|\b9-| 66H----<<-Qrp|qr-n{tyr-h=9-]Vj----sy|n-n{tyr-J-sy|n5r{pg6-<-?BB;=-7-]VH----sy|n-unysN{tyr-J-n{tyr-7-=;BH----sy|n-v{Unys-J-v{5unysN{tyr6H----sy|n-p|Unys-J-p|5unysN{tyr6H----r{-rpA5n\x07v-7-v{Unys9-p|Unys6H-<<-5\x079-\b9- 9-6\f<<-Ovyq-|nv|{-znv\x07-s|z-\0nr{v|{-5\x079-\b9- 9-6zn@-\0na|Zn@5rpA-\x006-\n----sy|n-\x07-J-\0;\x079-\b-J-\0;\b9- -J-\0; 9--J-\0;H----r{-zn@5-------->;=-:-?;=75\b7\b-8- 7 69-?;=75\x077\b-:- 769-------?;=75\x077 -8-\b769--------?;=75\x077\b-8- 769------->;=-:-?;=75\x077\x07-8- 7 69-?;=75\b7 -:-\x07769--------?;=75\x077 -:-\b769-------?;=75\b7 -8-\x07769------->;=-:-?;=75\x077\x07-8-\b7\b6----6H\frp?-tr`UQnnbc5v{-}ynVq\x079-v{-p|z}|{r{\\ssr9-rp?-r\x07r`v r6-\n----v{-uP|z}|{r{P|{-J-=H----vs-5lzn\x07`uQrtrr-KJ->6-uP|z}|{r{P|{-8J-FH----vs-5lzn\x07`uQrtrr-KJ-?6-uP|z}|{r{P|{-8J->BH----vs-5lzn\x07`uQrtrr-KJ-@6-uP|z}|{r{P|{-8J-?>H----v{-}nqqrqP|z}|{r{P|{-J-uP|z}|{r{P|{H----vs-5}nqqrqP|z}|{r{P|{-2-A-.J-=6-\n--------}nqqrqP|z}|{r{P|{-J-55}nqqrqP|z}|{r{P|{-<-A6-8->6-7-AH----\f----sy|n-yv{rnP|z}|{r{V{qr\x07-J-sy|n5}ynVq\x07-7-}nqqrqP|z}|{r{P|{-8-p|z}|{r{\\ssr6H----sy|n-r\x07ryV{qr\x07-J-yv{rnP|z}|{r{V{qr\x07-<-A;=H----sy|n-q-J-r\x07ryV{qr\x07-<-r\x07r`v r;\x07H----sy|n-\b-J-sy||5q6-<-r\x07r`v r;\bH----sy|n-\x07-J-snp5q6H----r{-rp?5\x079-\b6H\f|vq-znv{-56-\n----v{-}ynV{qr\x07b-J-v{5}ynV{qr\x07-8-=;B6H----v{-}ynV{qr\x07V-J-v{5}ynV{qr\x07b6H----<<-JJJ-P|z}np-s|znG-v{tyr-r\x07rySrpu9-A-\x07-v{@?-J->C-o\br<}yn-JJJ----<<-qnnh=jG-_-\v-TIIE-\v-OII>C-\v-NII?A----<<-qnnh>jG-pr{re5s>C6-\v-pr{rf5s>C6----<<-qnnh?jG-pr{rg5s>C6-\v-\0ne5E6II>C-\v-\0nf5E6II?A----<<-qnnh@jG-pnyre5E6-\v-pnyrf5E6IIE-\v-pnyrg5E6II>C-\v-\0ng5E6II?A----rpA-}npxrq-J-r\x07rySrpu5lr\x07r9-vrp?5}ynV{qr\x07b-3-=\x07Dss9-}ynV{qr\x07b-KK->>69-=6H----<<-Qrp|qr-}|vv|{-s|z-sy|n>C----rp?-}|ef-J-{}npxUnys?\x07>C5}npxrq;\b6H----rp?-}|g\0e-J-{}npxUnys?\x07>C5}npxrq; 6H----rp@-}ynPr{r-J-rp@5}|ef;\x079-}|ef;\b9-}|g\0e;\x076H----<<-Qrp|qr-\0nr{v|{-s|z-|pnurqny-r{p|qv{t----v{-\0nR{pe-J-5}npxrq; -KK->C6-3-=\x07ssH----v{-\0nR{pf-J-5}npxrq; -KK-?A6-3-=\x07ssH----v{-\0nR{pg-J-5}npxrq;-KK-?A6-3-=\x07ssH----rpA-\0n-J-qrp|qr^n\\pnurqny5\0nR{pe9-\0nR{pf9-\0nR{pg6H----<<-Qrp|qr-pnyr-s|z-y|t:r{p|qrq-v{E----sy|n-pnyre-J-qrp|qrY|t`pnyr5}npxrq;-3-=\x07ss6H----sy|n-pnyrf-J-qrp|qrY|t`pnyr55}npxrq;-KK-E6-3-=\x07ss6H----sy|n-pnyrg-J-qrp|qrY|t`pnyr55}npxrq;-KK->C6-3-=\x07ss6H----<<-Qrp|qr-p|y|----rpA-p|y|-J-rpA5--------sy|n5}npxrq;\x07-3-=\x07ss69--------sy|n55}npxrq;\x07-KK-E6-3-=\x07ss69--------sy|n55}npxrq;\x07-KK->C6-3-=\x07ss69--------sy|n55}npxrq;\x07-KK-?A6-3-=\x07ss6----6-<-?BB;=H----<<-_rnq-n{s|z----v{-n{s|zV{qr\x07-J-r\x07rySrpu5ln{s|zV{qvpr9-vrp?5}ynV{qr\x07b-3-=\x07@ss9-}ynV{qr\x07b-KK->=69-=6;\x07H----znA-n{s|z-J-znA5--------r\x07rySrpu5ln{s|z9-vrp?5=9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5>9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5?9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5@9-n{s|zV{qr\x0769-=6----6H----znA-n{s|zZ|qrycvrZnv\x07-J-vrZnv\x07-7-n{s|zH----rpA-|yqPr{r-J-n{s|z-7-rpA5}ynPr{r9->;=6H----<<-JJJ-Nttrtnv|{-rssrp-JJJ----sy|n-y|pny]|tr-J-lnttrtnv|{]|trH----sy|n-pnyr]|tr-J-=;=H----o||y-v{O|{qS|Nttrtnv|{-J-snyrH----vs-5lnttrtnv|{R{noyrq-33-lnttrtnv|{]|tr-I->;=6-\n--------o||y-v{O|{q-J-|yqPr{r;\x07-KJ-lnttrtnv|{O|{qZv{;\x07---------------------33-|yqPr{r;\x07-IJ-lnttrtnv|{O|{qZn\x07;\x07---------------------33-|yqPr{r; -KJ-lnttrtnv|{O|{qZv{; ---------------------33-|yqPr{r; -IJ-lnttrtnv|{O|{qZn\x07; H--------vs-5v{O|{q6-\n------------v{O|{qS|Nttrtnv|{-J-rH------------sy|n-urvtu_n{tr-J-lnttrtnv|{O|{qZn\x07;\b-:-lnttrtnv|{O|{qZv{;\bH------------sy|n-{|znyv rqUrvtu-J-urvtu_n{tr-K-=;==>----------------L-pynz}55|yqPr{r;\b-:-lnttrtnv|{O|{qZv{;\b6-<-urvtu_n{tr9-=;=9->;=6----------------G-=;BH------------sy|n-}|v{Q-J-pynz}5lnttrtnv|{]|v{Qnv|{9-=;=>9->;=6H------------sy|n-navzr-J-5>;=-:-{|znyv rqUrvtu6-7-5>;=-:-}|v{Q6H------------y|pny]|tr-J-pynz}55lnttrtnv|{]|tr-:-navzr6-<-}|v{Q9-=;=9->;=6H------------sy|n-|ssr]|tr-J-z||ur}5=;=9->;=9-y|pny]|tr6H------------pnyr]|tr-J-y|pny]|tr-7-y|pny]|tr-7-y|pny]|trH------------rp@-nttrtnv|{Pr{r-J-5lnttrtnv|{O|{qZv{-8-lnttrtnv|{O|{qZn\x076-<-?;=H------------rp@-qv-J-|yqPr{r;\x07\b -:-nttrtnv|{Pr{rH------------sy|n-qv-J-yr{tu5qv6H------------sy|n-n{q`rrq-J-q|5}ynPr{r9-rp@5>?;FEFE9-DE;?@@9-AB;>CA66H------------sy|n-n{qQv-J-snp5v{5n{q`rrq6-7-A@DBE;BAB@6H------------sy|n-n{tyr-J-n{q`rrq-7->=;=H------------rp@-pnrQv-J-{|znyv r5rp@5----------------p|5n{tyr69----------------zv\x075:=;D9-=;>9-snp5v{5n{q`rrq-7->;D6-7-A@DBE;BAB@669----------------v{5n{tyr6------------66H------------sy|n-r\x07}y|v|{Snp|-J-5>;=-:-|ssr]|tr6-7-5>;=-8->;=-7-n{qQv6H------------rp@-|ssr-J-pnrQv-7-qv-7-r\x07}y|v|{Snp|H------------|yqPr{r;\x07\b -8J-|ssrH------------}ynPr{r-J-5v{rr5n{s|z6-7-|yqPr{r6;\x07\b H--------\f----\f----<<-JJJ-Pyv}}r-purpx-JJJ----0vs-[bZlT`lPYV]]R_`-K-=----v{-yn\brV{qr\x07-J-v{5r\x07rySrpu5lyn\brV{qvpr9-vrp?5}ynV{qr\x07b-3-=\x07@ss9-}ynV{qr\x07b-KK->=69-=6;\x076H----vs-5yn\brV{qr\x07-KJ-=-33-yn\brV{qr\x07-I-[bZlT`lYNfR_`6-\n--------rp?-pyv}_n{tr-J-lyn\brPyv}}r_n{trhyn\brV{qr\x07jH--------v{-pyv}`n-J-v{5pyv}_n{tr;\x07-8-=;B6H--------v{-pyv}P|{-J-v{5pyv}_n{tr;\b-8-=;B6H--------v{-pyv}R{q-J-pyv}`n-8-pyv}P|{H--------s|-5v{-v-J-=H-v-I-[bZlT`lPYV]]R_`H-v886-\n----------------vs-5v-I-pyv}`n-\v\v-v-KJ-pyv}R{q6-\n--------------------p|{v{rH----------------\f----------------rpA-pyv}}r]|vv|{-J-lpyv}}rZnvprV{rrhvj-7-|yqPr{rH----------------o||y-pyv}}rq-J-pyv}}r]|vv|{;\x07-K-:=;B-33-pyv}}r]|vv|{;\x07-I-=;BH----------------pyv}}rq-J-pyv}}rq-33-pyv}}r]|vv|{;\b-K-:=;B-33-pyv}}r]|vv|{;\b-I-=;BH----------------pyv}}rq-J-pyv}}rq-33-pyv}}r]|vv|{; -K-:=;B-33-pyv}}r]|vv|{; -I-=;BH----------------vs-5pyv}}rq6-\n--------------------tyl]|vv|{-J-rpA5=;=9-=;=9-?;=9->;=6H--------------------r{H----------------\f--------\f----\f----0r{qvs----rpA-vrPr{r-J-n{s|zZ|qrycvrZnv\x07-7-rpA5}ynPr{r9->;=6H----rpA-pyv}Pr{r-J-}|wrpv|{Znv\x07-7-vrPr{rH----<<-Sz-pyyv{t----sy|n-pyv}-J->;?-7-pyv}Pr{r;H----vs-5pyv}Pr{r; -I-:pyv}Pr{r;-\v\v-pyv}Pr{r; -K-pyv}Pr{r;-\v\v--------pyv}Pr{r;\x07-I-:pyv}-\v\v-pyv}Pr{r;\x07-K-pyv}-\v\v--------pyv}Pr{r;\b-I-:pyv}-\v\v-pyv}Pr{r;\b-K-pyv}6-\n--------tyl]|vv|{-J-rpA5=;=9-=;=9-?;=9->;=6H--------r{H----\f----rp@-{qpPr{r-J-pyv}Pr{r;\x07\b -<-pyv}Pr{r;H----rp?-s|pny-J-rp?5--------}|wrpv|{Znv\x07h=jh=j-7-r|yv|{;\x07-7-=;B9--------}|wrpv|{Znv\x07h>jh>j-7-r|yv|{;\b-7-=;B----6H----]|vv|{-J-}|vv|{;\x07\bH----<<-JJJ-P|z}r-@Q-p|nvn{pr-s|z-\0nr{v|{-8-pnyr-5v{:unqr9-{|-}r:p|z}nv|{6-JJJ----<<-auv-r}ynpr-ur-}r:p|z}rq-p|nvn{pr-rnq-s|z-ur-|yq-@?:o\br-s|zn;----<<-_rsrr{prG-`}nx-p|z}r-p|nvn{pr-v{-rr\x07-unqr-s|z-}npxrq-\0nr{v|{8pnyr;----zn@-|Zn-J-\0na|Zn@5\0n6H----zn@-pnyrZn-J-zn@5--------pnyre9-=;=9-=;=9--------=;=9-pnyrf9-=;=9--------=;=9-=;=9-pnyrg----6H----zn@-Z-J-pnyrZn-7-|ZnH----<<-cx-J-Z-7-Zka-5@Q-p|nvn{pr-v{-|owrp-}npr6----zn@-cx-J-zn@5--------q|5Zh=j9-Zh=j69-q|5Zh=j9-Zh>j69-q|5Zh=j9-Zh?j69--------q|5Zh>j9-Zh=j69-q|5Zh>j9-Zh>j69-q|5Zh>j9-Zh?j69--------q|5Zh?j9-Zh=j69-q|5Zh?j9-Zh>j69-q|5Zh?j9-Zh?j6----6H----<<-Wnp|ovn{-s|-}r}rpvr<|u|tn}uvp-}|wrpv|{----o||y-v\\u|tn}uvp-J-}|wrpv|{Znv\x07h@jh@j-K-=;DH----zn@-WH----vs-5v\\u|tn}uvp6-\n--------W-J-n{}|r5zn@5------------s|pny;\x079-=;=9-=;=9------------=;=9-s|pny;\b9-=;=9------------=;=9-=;=9-=;=--------66H----\f-ryr-\n--------sy|n--J->;=-<-5vrPr{r; -7-vrPr{r; 6H--------W-J-zn@5------------s|pny;\x07-<-vrPr{r; 9-=;=9-:5s|pny;\x07-7-vrPr{r;\x076-7-9------------=;=9-s|pny;\b-<-vrPr{r; 9-:5s|pny;\b-7-vrPr{r;\b6-7-9------------=;=9-=;=9-=;=--------6H----\f----zn@-d-J-n{}|r5zn@5n{s|zZ|qrycvrZnv\x0766H----zn@-a-J-d-7-WH----<<-]|wrp-@Q-p|nvn{pr-|-?Q----zn@-p|?Qz-J-n{}|r5a6-7-cx-7-aH----p|?Qzh=jh=j-8J-xr{ry?Q`v rH----p|?Qzh>jh>j-8J-xr{ry?Q`v rH----rp@-p|?Q-J-rp@5p|?Qzh=jh=j9-p|?Qzh=jh>j9-p|?Qzh>jh>j6H----sy|n-n-J-p|?Q;\x07H----sy|n-q-J-p|?Q; H----sy|n-o-J-p|?Q;\bH----sy|n-Q-J-n-7-q-:-o-7-oH----sy|n-npr-J-n-8-qH----sy|n-npr\\r?-J-=;B-7-nprH----sy|n-rz?-J-\05zn\x075=;>9-npr\\r?-7-npr\\r?-:-Q66H----sy|n-rvtr{cnyr>-J-npr\\r?-8-rz?H----sy|n-rvtr{cnyr?-J-npr\\r?-:-rz?H----vs-5rvtr{cnyr?-IJ-=;=6-\n--------r{H----\f----rp?-rvtr{crp|>-J-{|znyv r5rp?5o9-rvtr{cnyr>-:-n66H----rp?-rvtr{crp|?-J-rp?5rvtr{crp|>;\b9-:rvtr{crp|>;\x076H----rp?-onvcrp|>-J-rvtr{crp|>-7-zv{5\0E-7-\05rvtr{cnyr>69-zn\x07`prr{`}npr`}yn`v r6H----rp?-onvcrp|?-J-rvtr{crp|?-7-zv{5\0E-7-\05rvtr{cnyr?69-zn\x07`prr{`}npr`}yn`v r6H----rp?-onvcvr}|-J-rp?5>;=-<-r|yv|{;\x079->;=-<-r|yv|{;\b6H----rp?-{qp\\ssr-J-rp?5]|vv|{;\x07-7-onvcrp|>-8-]|vv|{;\b-7-onvcrp|?6-7---------------------onvcvr}|-7-?;=H----<<-]|v{:py|q-|-@QT`-n{vv|{----vs-5lnttrtnv|{R{noyrq6-\n--------sy|n-sv{ny`pnyr]|tr-J-v{O|{qS|Nttrtnv|{-L-pnyr]|tr-G-5lnttrtnv|{]|tr-7-lnttrtnv|{]|tr-7-lnttrtnv|{]|tr6H--------{qp\\ssr-7J-zv\x075=;>9->;=9-sv{ny`pnyr]|tr6H----\f----rpA-\0nq]|-J-rpA5{qpPr{r;\x07\b-8-{qp\\ssr9-{qpPr{r; 9->;=6H----tyl]|vv|{-J-\0nq]|H----<<-JJJ-`U-yvtuv{t-JJJ----vs-5lzn\x07`uQrtrr-KJ->6-\n--------rp@-pnzrn]|V{\\owrp-J-rp@5v{rr5n{s|z6-7-rpA5pnzrn]|vv|{9->;=66H--------rp@-|owrpcvrQv-J-{|znyv r5}ynPr{r-:-pnzrn]|V{\\owrp6H--------rpA-u=>?@-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-=9-luar\x07r`v r66H--------rpA-uABCD-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-A9-luar\x07r`v r66H--------rpA-uEF>=>>-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-E9-luar\x07r`v r66H--------rp@-u>-J-u=>?@;toH--------rp@-u?-J-rp@5u=>?@;n9-uABCD;t6H--------rp@-u@-J-rp@5uABCD;on9-uEF>=>>;6H--------sy|n-\x07-J-|owrpcvrQv;\x07H--------sy|n-\b-J-|owrpcvrQv;\bH--------sy|n- -J-|owrpcvrQv; H--------rp@-uP|y|-J-u>-7-5:=;AEEC=?B-7-\b6-8-u?-7-5=;AEEC=?B-7- 6-8-u@-7-5:=;AEEC=?B-7-\x076H--------p|y|;to-8J-uP|y|H--------vs-5lzn\x07`uQrtrr-KJ-?6-\n------------rpA-u>?>@>A>B-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9->?9-luar\x07r`v r66H------------rpA-u>C>D>E>F-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9->C9-luar\x07r`v r66H------------rpA-u?=?>???@-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-?=9-luar\x07r`v r66H------------rp@-uA-J-uEF>=>>;tonH------------rp@-uB-J-u>?>@>A>B;toH------------rp@-uC-J-rp@5u>?>@>A>B;n9-u>C>D>E>F;t6H------------rp@-uD-J-rp@5u>C>D>E>F;on9-u?=?>???@;6H------------rp@-uElqrt?-J-u?=?>???@;tonH------------sy|n-\x07\x07-J-\x07-7-\x07H------------sy|n-\b\b-J-\b-7-\bH------------sy|n- -J- -7- H------------sy|n-\x07\b-J-\x07-7-\bH------------sy|n-\b -J-\b-7- H------------sy|n-\x07 -J-\x07-7- H------------p|y|;to-8J----------------5`UlP?l=-7-\x07\b6-7-uA-8----------------5`UlP?l>-7-\b 6-7-uB-8----------------5`UlP?l?-7-5?;=-7- -:-\x07\x07-:-\b\b66-7-uC-8----------------5`UlP?l@-7-\x07 6-7-uD-8----------------5`UlP?lA-7-5\x07\x07-:-\b\b66-7-uElqrt?H--------\f----\f----p|y|;to-J-pynz}5p|y|;to9-rp@5=;=69-rp@5>;=66H----P|y|-J-p|y|H----]|vv|{-7J-\0EH----b-J-}|vv|{;\x07\bH\f"),fragment_default=function(...e){let t=113,n=126,r=0,o=``;return e[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`}rpvv|{-uvtu}-sy|nH0v{pyqr-Ip|zz|{Kn\bv{t-rpA-P|y|Hn\bv{t-rp?-]|vv|{Hn\bv{t-rp?-bH|vq-znv{-56-
2353
- ----<<-计算从-}yn-中心到当前片段的平方距离----<<-由于-]|vv|{-已经按-\05E6-缩放,平方结果会被缩放-E-倍----<<-如果平方结果大于-E,说明在椭圆外,距离均值超过-\05E6-个标准差----sy|n-N-J-q|5]|vv|{9-]|vv|{6H----vs-5N-K-E;=6-qvpnqH--------rp@-p|y|-J-P|y|;toH--------<<-由于渲染的-}yn-按-\05E6-缩放,高斯公式中的逆协方差矩阵部分变成单位矩阵----<<-因此只剩下-5e-:-zrn{6-7-5e-:-zrn{6,而-zrn{-为零,所以是-e-7-e,即-N----sy|n-|}npv\b-J-r\x07}5:=;B-7-N6-7-P|y|;nH--------tylSntP|y|-J-rpA5p|y|;to9-|}npv\b6H\f`),MAX_POOL_SIZE=2,PBMGaussianSplattingRenderMesh=class extends three.Mesh{constructor(){super(),this.renderData=null,this.needsRender=!1,this.sortWorker=null,this.depthIndex=new Uint32Array,this.splatIndexCapacity=0,this.activeSlot=null,this.pendingSlot=null,this.rebuildGeneration=0,this.forceClipperUniformRefresh=!1,this.incrementalUpdateInFlight=!1,this.freeSlotPool=[],this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.usedSHDegree=0,this.sortDataRebuilding=!1,this.onBeforeRender=(e,t,n)=>{let r=n,o=this.collectObjects(t);if(o.length===0){this.geometry.instanceCount=0;return}let s=0;o.forEach(e=>{e.usedSHDegree>s&&(s=e.usedSHDegree)}),this.setMaxShDegree(s),this.isSceneNeedsRebuild(o)&&(this.tryStartIncrementalUpdate(o)||(this.startPendingRebuild(o),this.gsSceneState.lastClipperHash=``));let c=o.filter(e=>e.transformChanged);c.length>0&&(this.syncTransformsForSlot(this.activeSlot,c),this.syncTransformsForSlot(this.pendingSlot,c),c.forEach(e=>{e.transformChanged=!1,e.selectedChanged=!1})),this.activeSlot&&this.updateSlotTextures(this.activeSlot),this.pendingSlot&&this.updateSlotTextures(this.pendingSlot);let l=new three.Matrix4().multiplyMatrices(r.perspectiveProjectionMatrix,r.matrixWorldInverse).elements;this.pendingSlot&&this.pendingSlot.renderData.initialBuildComplete&&this.pendingSlot.awaitingFirstSort?this.requestSort(this.pendingSlot,l):this.activeSlot&&this.requestSort(this.activeSlot,l);let u=this.getClipperHash(o);if((this.forceClipperUniformRefresh||u!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(o),this.gsSceneState.lastClipperHash=u,this.forceClipperUniformRefresh=!1,this.needsRender=!0),this.activeSlot){let e=Math.min(this.usedSHDegree,this.activeSlot.renderData.maxShDegree);this.material.uniforms.u_maxShDegree.value=e,e>0&&!this.activeSlot.textures.shTexture?this.createSHTexture(this.activeSlot):e===0&&this.activeSlot.textures.shTexture&&(this.activeSlot.textures.shTexture.dispose(),this.activeSlot.textures.shTexture=null),this.material.uniforms.u_shTexture.value=this.activeSlot.textures.shTexture,this.renderData=this.activeSlot.renderData}else this.pendingSlot||(this.bindSlotTextures(null),this.material.uniforms.u_maxShDegree.value=0,this.geometry.instanceCount=0);this.material.uniforms.resolution.value.set(r.resolution.x,r.resolution.y)};let e=this.createGeometry(),t=this.createMaterial();this.geometry=e,this.material=t,this.frustumCulled=!1,this.renderOrder=-99999999999,this.gsSceneState={lastObjectsHash:``,lastClipperHash:``},this.sortWorker=new WorkerWrapper,this.sortWorker.postMessage({warmup:!0}),RenderData.warmupWasm(),this.sortWorker.onmessage=e=>{if(e.data.depthIndex){let t=e.data.generation;if(this.pendingSlot&&t===this.pendingSlot.generation){this.pendingSlot.awaitingFirstSort=!1,this.swapPendingToActive(e.data.depthIndex);return}this.activeSlot&&t===this.activeSlot.generation&&(this.activeSlot.awaitingFirstSort=!1,this.applyDepthIndex(e.data.depthIndex))}}}ensureSplatIndexCapacity(e){let t=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return t;let n=this.getExpandedCapacity(e),r=t.array,o=new Float32Array(n);o.set(r.subarray(0,Math.min(r.length,n)));let s=new three.InstancedBufferAttribute(o,1,!1,1);return s.setUsage(three.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,s),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,s}getExpandedCapacity(e){let t=Math.max(this.splatIndexCapacity,1);for(;t<e;)t*=2;return t}createGeometry(){let e=new three.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new three.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new three.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity);for(let e=0;e<r.length;e++)r[e]=e;let o=new three.InstancedBufferAttribute(r,1,!1,1);return o.setUsage(three.DynamicDrawUsage),e.setAttribute(`splatIndex`,o),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}createMaterial(){return new three.ShaderMaterial({vertexShader:vertex_default,fragmentShader:fragment_default,defines:{NUM_GS_LAYERS:0,NUM_GS_CLIPPERS:0},uniforms:{u_texture:{value:null},u_transforms:{value:null},u_transformIndices:{value:null},u_layerIndices:{value:null},u_numGsLayers:{value:0},u_numGsClippers:{value:0},u_layerClipperRanges:{value:[]},u_clipperMatricesInverse:{value:[]},u_shTexture:{value:null},u_shTextureSize:{value:new three.Vector2},u_maxShDegree:{value:0},resolution:{value:new three.Vector2},u_aggregationEnabled:{value:!0},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new three.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new three.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6}},side:three.DoubleSide,transparent:!0,blending:three.NormalBlending,depthTest:!0,depthWrite:!1})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new three.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new three.Matrix4)}createTextures(e,t){var n;let r;t&&t.dataTexture.image.width===e.width&&t.dataTexture.image.height===e.height?(r=t.dataTexture,r.image.data=e.data,r.needsUpdate=!0):(t&&t.dataTexture.dispose(),r=new three.DataTexture(e.data,e.width,e.height,three.RGBAIntegerFormat,three.UnsignedIntType),r.internalFormat=`RGBA32UI`,r.minFilter=three.NearestFilter,r.magFilter=three.NearestFilter,r.needsUpdate=!0);let o;t&&t.transformsTexture.image.width===e.transformsWidth&&t.transformsTexture.image.height===e.transformsHeight?(o=t.transformsTexture,o.image.data=e.transforms,o.needsUpdate=!0):(t&&t.transformsTexture.dispose(),o=new three.DataTexture(e.transforms,e.transformsWidth,e.transformsHeight,three.RGBAFormat,three.FloatType),o.internalFormat=`RGBA32F`,o.minFilter=three.NearestFilter,o.magFilter=three.NearestFilter,o.needsUpdate=!0);let s;t&&t.transformIndicesTexture.image.width===e.transformIndicesWidth&&t.transformIndicesTexture.image.height===e.transformIndicesHeight?(s=t.transformIndicesTexture,s.image.data=e.transformIndices,s.needsUpdate=!0):(t&&t.transformIndicesTexture.dispose(),s=new three.DataTexture(e.transformIndices,e.transformIndicesWidth,e.transformIndicesHeight,three.RedIntegerFormat,three.UnsignedIntType),s.internalFormat=`R32UI`,s.minFilter=three.NearestFilter,s.magFilter=three.NearestFilter,s.needsUpdate=!0);let c;t&&t.layerIndicesTexture.image.width===e.layerIndicesWidth&&t.layerIndicesTexture.image.height===e.layerIndicesHeight?(c=t.layerIndicesTexture,c.image.data=e.layerIndices,c.needsUpdate=!0):(t&&t.layerIndicesTexture.dispose(),c=new three.DataTexture(e.layerIndices,e.layerIndicesWidth,e.layerIndicesHeight,three.RedIntegerFormat,three.UnsignedIntType),c.internalFormat=`R32UI`,c.minFilter=three.NearestFilter,c.magFilter=three.NearestFilter,c.needsUpdate=!0);let l=(n=t==null?void 0:t.shTexture)==null?null:n;return{dataTexture:r,transformsTexture:o,transformIndicesTexture:s,layerIndicesTexture:c,shTexture:l}}createSHTexture(e){let{renderData:t,textures:n}=e;if(t.shDataReleased)return;n.shTexture&&(n.shTexture.dispose(),n.shTexture=null);let r=Math.min(this.usedSHDegree,t.maxShDegree),o=0;if(r>=1&&(o+=9),r>=2&&(o+=15),r>=3&&(o+=21),o===0)return;let s=4,c=o;c%4!=0&&(c=Math.ceil(c/4)*4);let l=t.numPoints*c/4,u=2048,d=Math.ceil(l/u),f=new Float32Array(u*d*4);for(let e=0;e<t.numPoints;e++){let n=c/4*e,o=0;if(t.sh1&&r>=1)for(let r=0;r<9;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh1[e*9+r],o++}if(t.sh2&&r>=2)for(let r=0;r<15;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh2[e*15+r],o++}if(t.sh3&&r>=3)for(let r=0;r<21;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh3[e*21+r],o++}}n.shTexture=new three.DataTexture(f,u,d,three.RGBAFormat,three.FloatType),n.shTexture.internalFormat=`RGBA32F`,n.shTexture.minFilter=three.NearestFilter,n.shTexture.magFilter=three.NearestFilter,n.shTexture.needsUpdate=!0,this.material.uniforms.u_shTextureSize.value.set(u,d),this.material.uniforms.u_maxShDegree.value=r,e.renderData.releaseSHData()}setMaxShDegree(e){var t,n;if(e<0||e>2){console.warn(`现在只支持012三种阶数,你输入的是${e}`);return}let r=this.usedSHDegree;this.usedSHDegree=e,r!==e&&((t=this.activeSlot)!=null&&t.textures.shTexture&&(this.activeSlot.textures.shTexture.dispose(),this.activeSlot.textures.shTexture=null),(n=this.pendingSlot)!=null&&n.textures.shTexture&&(this.pendingSlot.textures.shTexture.dispose(),this.pendingSlot.textures.shTexture=null),this.material.uniforms.u_maxShDegree.value=e,e===0?this.material.uniforms.u_shTexture.value=null:this.activeSlot&&this.activeSlot.renderData.maxShDegree>0&&(this.createSHTexture(this.activeSlot),this.material.uniforms.u_shTexture.value=this.activeSlot.textures.shTexture))}bindSlotTextures(e){if(!e){this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.material.uniforms.u_texture.value=null,this.material.uniforms.u_transforms.value=null,this.material.uniforms.u_transformIndices.value=null,this.material.uniforms.u_layerIndices.value=null,this.material.uniforms.u_shTexture.value=null;return}this.dataTexture=e.textures.dataTexture,this.transformsTexture=e.textures.transformsTexture,this.transformIndicesTexture=e.textures.transformIndicesTexture,this.layerIndicesTexture=e.textures.layerIndicesTexture,this.shTexture=e.textures.shTexture,this.material.uniforms.u_texture.value=this.dataTexture,this.material.uniforms.u_transforms.value=this.transformsTexture,this.material.uniforms.u_transformIndices.value=this.transformIndicesTexture,this.material.uniforms.u_layerIndices.value=this.layerIndicesTexture,this.material.uniforms.u_shTexture.value=this.shTexture}disposeSlot(e){e&&(e.renderData.dispose(),this.disposeTextures(e.textures))}recycleSlot(e){if(e){if(this.freeSlotPool.length>=MAX_POOL_SIZE){let e=this.freeSlotPool.shift();this.disposeSlot(e)}e.renderData.releaseSortData(),e.renderData.releaseAggregatedData(),e.awaitingFirstSort=!0,e.sortDataUploaded=!1,this.freeSlotPool.push(e)}}disposeTextures(e){e.dataTexture.dispose(),e.transformsTexture.dispose(),e.transformIndicesTexture.dispose(),e.layerIndicesTexture.dispose(),e.shTexture&&(e.shTexture.dispose(),e.shTexture=null)}applyDepthIndex(e){this.depthIndex=e;let t=this.depthIndex.length,n=this.ensureSplatIndexCapacity(t);n.array.set(this.depthIndex,0),n.count=this.depthIndex.length,n.updateRange.offset=0,n.updateRange.count=t,n.needsUpdate=!0,this.geometry.instanceCount=this.depthIndex.length,this.needsRender=!0}swapPendingToActive(e){if(!this.pendingSlot)return;let t=this.activeSlot;this.activeSlot=this.pendingSlot,this.pendingSlot=null,this.renderData=this.activeSlot.renderData,this.ensureSplatIndexCapacity(this.activeSlot.renderData.numPoints),this.bindSlotTextures(this.activeSlot),this.activeSlot.sortDataUploaded=!0,this.forceClipperUniformRefresh=!0,this.applyDepthIndex(e),t&&this.recycleSlot(t)}createSlot(e){let t={generation:e.generation,renderData:e,textures:this.createTextures(e),awaitingFirstSort:!0,sortDataUploaded:!1};return this.usedSHDegree>0&&e.maxShDegree>0&&this.createSHTexture(t),t}updateSlotTextures(e){e.renderData.dataChanged&&(e.textures.dataTexture.needsUpdate=!0,e.renderData.dataChanged=!1),e.renderData.transformsChanged&&(e.textures.transformsTexture.needsUpdate=!0,e.renderData.indexDataReleased||(e.textures.transformIndicesTexture.needsUpdate=!0),e.renderData.transformsChanged=!1)}postSortData(e){var t;let n=e.renderData.positions,r=new Float32Array(e.renderData.transforms.slice().buffer),o=new Uint32Array(e.renderData.transformIndices.slice().buffer);(t=this.sortWorker)==null||t.postMessage({sortData:{positions:n,transforms:r,transformIndices:o,vertexCount:e.renderData.numPoints,generation:e.generation}},[n.buffer,r.buffer,o.buffer]),e.renderData.releaseSortData(),e.renderData.releaseIndexData(),e.sortDataUploaded=!0}requestSort(e,t){var n;if(e.renderData.initialBuildComplete){if(e.renderData.dataChanged||e.renderData.transformsChanged||!e.sortDataUploaded){if(e.renderData.sortDataReleased){this.sortDataRebuilding||(this.sortDataRebuilding=!0,e.renderData.rebuildSortData().then(()=>{this.sortDataRebuilding=!1,(this.activeSlot===e||this.pendingSlot===e)&&(e.sortDataUploaded=!1,this.needsRender=!0)}));return}this.postSortData(e)}(n=this.sortWorker)==null||n.postMessage({viewProj:t})}}syncTransformsForSlot(e,t){e&&t.forEach(t=>{e.renderData.splatIndices.has(t)&&e.renderData.updateTransform(t)})}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof PBMGaussianSplattingObject&&e.visible&&t.push(e)}),t.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:n>r?1:0}),t}isSceneNeedsRebuild(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`),n=t!==this.gsSceneState.lastObjectsHash;return this.gsSceneState.lastObjectsHash=t,n}getClipperHash(e){return e.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`)}updateClipperCounts(e,t){let n=Math.max(0,e|0),r=Math.max(0,t|0),o=this.material.defines;(o.NUM_GS_LAYERS!==n||o.NUM_GS_CLIPPERS!==r)&&(o.NUM_GS_LAYERS=n,o.NUM_GS_CLIPPERS=r,this.material.needsUpdate=!0),this.material.uniforms.u_numGsLayers.value=e,this.material.uniforms.u_numGsClippers.value=t}updateClipperUniforms(e){var t,n,r,o;let s=(n=(t=this.activeSlot)==null?void 0:t.renderData)==null?null:n;if(!s){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let c=new Map;for(let t of e)c.has(t.gsViewLayerKey)||c.set(t.gsViewLayerKey,t.gsClippers);let l=s.layerKeys.length,u=0;for(let e of s.layerKeys)u+=((r=c.get(e))==null?[]:r).length;let d=this.createDefaultLayerClipperRanges(l),f=this.createDefaultClipperMatrices(u),p=0;for(let e of s.layerKeys){let t=s.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(o=c.get(e))==null?[]:o,r=p,l=0;for(let e of n)f[p].getInverse(e.clippingBoxMatrix),p++,l++;l>0&&d[t].set(r,l)}this.material.uniforms.u_layerClipperRanges.value=d,this.material.uniforms.u_clipperMatricesInverse.value=f,this.updateClipperCounts(l,p)}startPendingRebuild(e){this.pendingSlot&&(this.recycleSlot(this.pendingSlot),this.pendingSlot=null),this.rebuildGeneration+=1;let t=new RenderData(e,this.rebuildGeneration),n=this.freeSlotPool.pop();if(n){n.renderData.dispose();let e=this.createTextures(t,n.textures);this.pendingSlot={generation:t.generation,renderData:t,textures:e,awaitingFirstSort:!0,sortDataUploaded:!1}}else this.pendingSlot=this.createSlot(t)}tryStartIncrementalUpdate(e){if(!this.activeSlot||this.pendingSlot||this.incrementalUpdateInFlight)return!1;let t=this.activeSlot.renderData.getObjectsInOrder();if(!this.activeSlot.renderData.canIncrementalAppend(e))return!1;let n=e.slice(t.length);if(n.length===0)return!1;this.incrementalUpdateInFlight=!0;let r=this.activeSlot;return r.renderData.appendObjects(n).then(e=>{e&&(this.activeSlot!==r||r.renderData.disposed||(r.textures=this.createTextures(r.renderData,r.textures),this.usedSHDegree>0&&r.renderData.maxShDegree>0&&this.createSHTexture(r),this.bindSlotTextures(r),this.ensureSplatIndexCapacity(r.renderData.numPoints),r.sortDataUploaded=!1,r.awaitingFirstSort=!0,this.forceClipperUniformRefresh=!0,this.gsSceneState.lastClipperHash=``,this.needsRender=!0))}).catch(e=>{console.warn(`Incremental append failed, fallback to rebuild:`,e)}).finally(()=>{this.incrementalUpdateInFlight=!1}),!0}dispose(){this.disposeSlot(this.pendingSlot),this.pendingSlot=null,this.disposeSlot(this.activeSlot),this.activeSlot=null;for(let e of this.freeSlotPool)this.disposeSlot(e);this.freeSlotPool.length=0,this.renderData=null,this.sortWorker&&this.sortWorker.terminate(),this.bindSlotTextures(null),this.geometry.dispose(),this.material.dispose()}},PBMGaussianSplattingTestMesh=class extends three.Mesh{constructor(){super(),this.onBeforeRender=(e,t,n)=>{this.collectObjects(t).length>0&&console.warn(`未开启webgl2, 3dgs仅支持在开启webgl2模式后使用`)}}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof PBMGaussianSplattingObject&&e.visible&&t.push(e)}),t}},DEFAULT_MODE_CHANGE_DURATION=1e3,DEFAULT_CAMERA_FOV=90,DEFAULT_REQUEST_PROXY=e=>e.replace(`//vrlab-public.ljcdn.com/`,`//vr-public.realsee-cdn.cn/`).replace(`//vrlab-image4.ljcdn.com/`,`//vr-image-4.realsee-cdn.cn/`).replace(`//vrlab-image3.ljcdn.com/`,`//vr-image-3.realsee-cdn.cn/`).replace(`//vrlab-image2.ljcdn.com/`,`//vr-image-2.realsee-cdn.cn/`).replace(`//vrlab-image1.ljcdn.com/`,`//vr-image-1.realsee-cdn.cn/`),scratchSphere=new three.Sphere,scratchBox3=new three.Box3,scratchViewport=new three.Vector4,scratchScissor=new three.Vector4,scratchClearColor=new three.Color,scratchRenderSize=new three.Vector2,worksMap=new WeakMap,emptyWorks=createWorks([parseWork(null)]),Five_Instances={},Five=class e extends Subscribe{static get version(){return`6.8.0`}static get dracoPath(){return draco.decoderPath}static set dracoPath(e){draco.setDecoderPath(e)}static get ktx2Path(){return ktx2.transcoderPath}static set ktx2Path(e){ktx2.setTranscoderPath(e)}static get useNativeImageBitmap(){return canUseNativeImageBitmap()}static set useNativeImageBitmap(e){useNativeImageBitmap(e)}constructor(e={}){var t,n,r,o,s,c,l,u,d,f,p;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=createUuid(),Five_Instances[this.fiveId]=this,this.currentUpdateArgs={time:now(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!1,this.onlyRenderIfNeeds=(t=e.onlyRenderIfNeeds)==null?!0:t,this.imageOptions=Object.assign({},(n=e.imageOptions)==null?{}:n),this.textureOptions=Object.assign({},(r=e.textureOptions)==null?{}:r),this.poweredByRealsee=(o=e.poweredByRealsee)==null?!0:o,this.backgroundColor=new three.Color((s=e.backgroundColor)==null?1579548:s),this.backgroundAlpha=(c=e.backgroundAlpha)==null?1:c,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview),VRPanorama:Object.assign({},e.vrPanorama),XRPanorama:Object.assign({},e.xrPanorama)},this.fps={testCount:0,testTime:now()},this.modeChangeDuration=(l=e.modeChangeDuration)==null?DEFAULT_MODE_CHANGE_DURATION:l,this.enableWheel=(u=e.enableWheel)==null?!0:u,typeof window<`u`)if(`renderer`in e)e.renderer instanceof InternalWebGLRenderer&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new InternalWebGLRenderer({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=getViewportScale();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new three.WebGLRenderTarget(1,1,{encoding:(f=(d=this.renderer)==null?void 0:d.outputEncoding)==null?three.sRGBEncoding:f,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Camera(DEFAULT_CAMERA_FOV),this.scene=new Scene,this.xrCustomObjectsScene=new three.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(p=e.requestProxy)==null?DEFAULT_REQUEST_PROXY:p,this.networkSubscribe=new NetworkSubscribe,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var o;this.emit(`network.resource`,createEvent(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(o=this.analysis)==null||o.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new three.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),worksMap.set(this,emptyWorks),this.modelScene=new ModelScene({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[m]=this.modelScene.setModels(emptyWorks,{forceReplaceImmediately:!0});defineProperty(m,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new three.VideoTexture(e.videoInstance||generateDefaultVideoElement());let h=initLights();this.scene.add(h),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=AnimationFrameLoop.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let g=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,createEvent(`vr.requestExit`,{}))},_=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,g,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,_,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,g,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,_,!1)},this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}initLegacyEvent(this),this.fiveRenderer=new FiveRenderer,this.adaptiveLuminancePass=new AdaptiveLuminancePass,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new EyeDomeLightingPass(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new PBMGaussianSplattingRenderMesh,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new PBMGaussianSplattingTestMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return panoStringify(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Five_Instances[this.fiveId],this.emit(`dispose`),this.destroyed=!0,this.pause(),this.stopAnimationLoop&&(this.stopAnimationLoop(),this.stopAnimationLoop=void 0),this.off(),this.networkSubscribe.off(),this.controller&&(this.controller.destroy(),this.controller=void 0);let t=this.getElement();t&&t.parentNode&&t.parentNode.removeChild(t);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((e=n.pano0)==null?void 0:e.map)&&n.pano1.map.dispose(),n.reset(`pano0`,`pano1`),this.modelScene.dispose(),this.scene.dispose(),this.xrCustomObjectsScene.dispose(),worksMap.set(this,emptyWorks),this.renderer&&this.renderer.render(new three.Scene,new three.Camera),this.fiveRenderer.dispose(),this.renderer instanceof InternalWebGLRenderer&&(this.renderer.forceContextLoss&&this.renderer.forceContextLoss(),this.renderer.dispose())}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,createEvent(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,omitUndefinedFields(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,omitUndefinedFields(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,omitUndefinedFields(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,omitUndefinedFields(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,omitUndefinedFields(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,omitUndefinedFields(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,omitUndefinedFields(e.xrPanorama)),this.currentMode===`XRPanorama`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),(this.currentMode===`Panorama`||this.currentMode===`VRPanorama`)&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof InternalWebGLRenderer)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,o;if(!this.renderer)return;let s=this.renderer.domElement.parentNode,{width:c=(n=s==null?void 0:s.offsetWidth)==null?512:n,height:l=(r=s==null?void 0:s.offsetHeight)==null?512:r}=e;if(c=Math.max(1,c),l=Math.max(1,l),!t){let e=getViewportScale(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(o=e===1?n:1)==null?1:o,t>1){let e=Math.max(c,l)*t,n=Math.min(this.renderer.capabilities.maxTextureSize,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(c,l),this.needsRender=!0;let u=now(),d=u-this.currentUpdateArgs.time,f=this.currentUpdateArgs.args;this.updateTime(u,d,...f)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return worksMap.get(this)||emptyWorks}get work(){return this.works[0]}get observers(){return this.work.observers}get models(){return this.modelScene.models}get model(){return this.modelScene.models[0]}load(e,t,n,r=!0){if(!this.renderer)throw Error(`renderer is not initialized`);let o=this.loadWorkTask.then(()=>isPromise(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=o.catch(e=>{this.throwError(e)}),o}load_(t,n,r,o=!0){var s,c,l,u,d,f,p,m,h,g;let _={};typeof r==`number`?_.duration=r:typeof r==`object`&&Object.assign(_,r),this.works===emptyWorks&&(_.duration===void 0&&(_.duration=0),_.effect===void 0&&(_.effect=`instant`));let v={};Object.assign(v,_.model),!v[`3d-tiles`]&&_[`3d-tiles`]&&(v[`3d-tiles`]=_[`3d-tiles`]),!v.textureOptions&&_.textureOptions&&(v.textureOptions=_.textureOptions),!v.textureOptions&&this.textureOptions&&(v.textureOptions=this.textureOptions);let y=[];if(Array.isArray(t))for(let e of t)e instanceof Work?y.push(e):typeof e!=`string`&&`work`in e?y.push(parseWork(e.work,e)):y.push(parseWork(e));else t instanceof Work?y.push(t):y.push(parseWork(t));_.mode===`add`&&(y=[].concat(this.works,y));let b;try{b=createWorks(y)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of b)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===emptyWorks&&(n=`initial`);let S=this.currentMode,C=b.initial,w=C.work.observers[0],T=w?{workCode:w.work.workCode,panoIndex:w.panoIndex}:{workCode:C.work.workCode,panoIndex:0},E=(s=C.mode)==null?w?`Panorama`:`Mapview`:s,D={};if(n===`inherit`){let e=this.getCurrentState(),[t]=b.filter(t=>t.workCode===e.workCode);if(t)T={workCode:e.workCode,panoIndex:e.panoIndex},E=e.mode,D={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:S};let e=(l=(c=b[0])==null?void 0:c.observers)==null?void 0:l[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof b.initial.panoIndex==`number`?(n.workCode=b.initial.work.workCode,n.panoIndex=b.initial.panoIndex):(n.mode===`Panorama`||n.mode===`VRPanorama`||n.mode===`XRPanorama`)&&(n.mode=`Mapview`),n.mode===S&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof C.panoIndex==`number`&&(T={workCode:C.work.workCode,panoIndex:C.panoIndex}),C.mode&&(E=C.mode),D={longitude:C.longitude,latitude:C.latitude,fov:C.fov,distance:C.distance,offset:(u=C.offset)==null?void 0:u.clone()}),typeof n==`object`){if(E=(d=n.mode)==null?S:d,typeof n.panoIndex==`number`){let e=b.getObserver({workCode:(p=(f=n.workCode)==null?C.work.workCode:f)==null?``:p,panoIndex:n.panoIndex});e&&(T={workCode:e.work.workCode,panoIndex:e.panoIndex})}D={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new three.Vector3().copy(n.offset):void 0}}let O=(m=_.duration)==null?this.modeChangeDuration:m;(E===`Floorplan`||E===`Topview`||E===`Mapview`)&&S===E&&(O=0);let k=`fly`;(E===`Panorama`||E===`VRPanorama`||E===`XRPanorama`)&&S===E&&(k=(h=_.effect)==null?`fade`:h),this.emit(`works.request`,createEvent(`works.request`,{input:t,works:b,userAction:o}));let A=(e,t,r)=>{let s=this.getCurrentState(),c=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(c=this.getCurrentState()),this.pano=t;let l=Object.assign(Object.assign({initial:{state:c,currentState:s,duration:O,effect:k,userAction:o}},this.commonParams()),this.controllerInits[e]),u=Controllers[c.mode].initAnimationEndState(l);if(this.controller&&S===e)this.controller.updateWork(b,u,{effect:k,duration:O},o)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,l));else{if(this.controller)this.controller.destroy();else{let t=Controllers[e].initAnimationEndState(l);this.camera.setFromPose(t),this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o}))}this.controller=this.applyController(e,l);let t=createEvent(`mode.change`,{prevMode:S,mode:e,state:u,userAction:o});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};worksMap.set(this,b);let j=Promise.resolve();if(E===e.Mode.Floorplan||E===e.Mode.Topview||E===e.Mode.Mapview||E===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(D),assignPose(this.state,this.camera.pose));let e=this.modelScene.setModels(b,v);j=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,A(E,T,D),this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o}))})}else{A(E,T,D);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===b&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(b,v);j=Promise.all(r.map(e=>e.initReady)).then(noop),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((g=_.duration)==null?this.modeChangeDuration:g)+1e3)}return this.emit(`works.load`,createEvent(`works.load`,{input:t,userAction:o,works:b})),j.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,createEvent(`works.ready`,{input:t,userAction:o,works:b})),(e=this.analysis)==null||e.work(b)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),worksMap.set(this,emptyWorks),this.modelScene.setModels(emptyWorks,{forceReplaceImmediately:!0}),this.renderer&&this.modelScene.update(this.renderer,this.camera),this.needsRender=!0,this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.camera.setFromPose({distance:0,fov:DEFAULT_CAMERA_FOV,longitude:0,latitude:0,offset:new three.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,o=!0,s=!1){return new Promise((c,l)=>{var u,d,f,p;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let m=0;this.controller&&(m=typeof r==`number`?r:(u=r==null?void 0:r.duration)==null?this.modeChangeDuration:u);let h=`fly`;this.controller&&typeof r==`object`&&r.effect&&(h=r.effect);let g=typeof n.panoIndex==`number`?{workCode:(p=(d=n.workCode)==null?(f=this.work)==null?void 0:f.workCode:d)==null?``:p,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),l(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(g)){let e=Error(`PanoId ${panoStringify(g)} not existed.`);this.throwError(e),l(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(m=0);let _=this.controller,v=this.currentMode,y=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&s===!1&&v===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!panoEqual(this.pano,g)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(g,Object.assign({duration:m},n),o):this.controller.updateCamera(n,m,o).catch(noop):(panoEqual(this.pano,g)||(this.pano=g),this.controller.updateCamera(n,m,o).catch(noop));else{let e=Object.assign(Object.assign({},n),g),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:m,effect:h,userAction:o}},this.commonParams()),this.controllerInits[t]),s=Controllers[t].initAnimationEndState(r),c=createEvent(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:s,userAction:o});if(this.emit(`mode.change.request`,c),!c.defaultPrevented){_&&_.destroy(),this.controller=this.applyController(t,r);let e=createEvent(`mode.change`,{prevMode:this.currentMode,mode:t,state:s,userAction:o});this.emit(`mode.change`,e)}}c()},b=AnimationFrameLoop.shared.getContext();b&&(typeof XRSession<`u`&&b instanceof XRSession&&b.end(),AnimationFrameLoop.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),requestDeviceOrientationPermission().then(()=>y()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),l(t)})):t===e.Mode.XRPanorama?requestXRSessionPermission().then(e=>{AnimationFrameLoop.shared.setContext(e),s=!0,y()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),l(t)}):y()})}getPixels(e,t,n,r,o,s,c){if(!this.renderer)throw Error(`renderer is not initialized.`);let l=now(),u=this.renderer.getPixelRatio(),d=this.renderer.getRenderTarget(),f=this.getSize(new three.Vector2),p=0,m=0,h=1,g=1,_,v,y,b,S;typeof e==`number`?(p=e,typeof t==`number`&&(m=t),typeof n==`number`&&(h=n),typeof r==`number`&&(g=r),_=o,v=s,S=c):(p=e.x,m=e.y,h=e.width,g=e.height,_=e.pixelRatio,v=e.flipY,y=e.helperVisible,b=e.skipPanorama,S=e.buffer),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g),_=Math.floor(_==null?u:_),v=v==null?!1:v;let C=this.helperVisible,w=this.modelScene.parameter.modelAlpha;this.helperVisible=y==null?this.helperVisible:y,b&&(this.controller instanceof Controllers.Panorama||this.controller instanceof Controllers.VRPanorama||this.controller instanceof Controllers.XRPanorama)&&b===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let T=this.getPixelsRenderTarget;T.setSize(h*_,g*_),this.renderer.setRenderTarget(T),this.camera.pixelRatio=_,this.camera.resolution.set(h,g),this.camera.setViewOffset(f.width,f.height,p,f.height-m-g,h,g),this.camera.aspect=f.width/f.height,this.camera.updateTime(l),this.scene.update(this.renderer,this.camera);let E=this.renderer.autoClear,D=this.renderer.autoClearColor,O=this.renderer.autoClearDepth,k=this.renderer.autoClearStencil,A=scratchClearColor.copy(this.renderer.getClearColor()),j=this.renderer.getClearAlpha(),M=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let N=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:N,this.renderer.render(this.scene,this.camera),this.scene.background=N,this.renderer.autoClear=E,this.renderer.autoClearColor=D,this.renderer.autoClearDepth=O,this.renderer.autoClearStencil=k,this.renderer.setClearColor(A,j),this.renderer.setScissorTest(M),this.helperVisible=C,w===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,w),this.renderer.setRenderTarget(d),this.camera.clearViewOffset(),this.camera.pixelRatio=u,this.camera.resolution.copy(f),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(l),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let P=h*_,F=g*_,I=P*F,L=I*4;if(S){if(S.length!==L)throw Error(`buffer length is not equals pixels ${L}`)}else S=new Uint8Array(L);if(this.renderer.readRenderTargetPixels(T,0,0,h*_,g*_,S),v){let e=I/2;for(let t=0,n=0,r=0,o=0;n<e;n++)for(o=(F-Math.floor(n/P)-1)*P+n%P,r=0;r<4;r++)t=S[n*4+r],S[n*4+r]=S[o*4+r],S[o*4+r]=t}return S}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,o=t.autoClearColor,s=t.autoClearDepth,c=t.autoClearStencil,l=scratchClearColor.copy(t.getClearColor()),u=t.getClearAlpha(),d=t.getViewport(scratchViewport),f=t.getScissor(scratchScissor),p=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let m=t.getSize(scratchRenderSize),h=Math.floor(m.x*this.viewport.left),g=Math.floor(m.y*this.viewport.bottom),_=Math.floor(m.x*this.viewport.width),v=Math.floor(m.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(h,g,_,v),t.setScissor(h,g,_,v);let y=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(y);let b=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:b;let S=!0;if(this.controller&&this.controller.render()&&(S=!1),S){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&renderPoweredByRealsee(t)}this.scene.background=b,t.autoClear=r,t.autoClearColor=o,t.autoClearDepth=s,t.autoClearStencil=c,t.setClearColor(l,u),t.setViewport(d),t.setScissor(f),t.setScissorTest(p),t.setRenderTarget(n),e&&AnimationFrameLoop.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&ktx2.detectSupport(this.renderer),this.syncingState=this.syncState(e,t),this.controller&&this.controller.updateTime(e,t,...n),this.renderer&&(this.camera.pixelRatio=this.renderer.getPixelRatio(),this.getSize(this.camera.resolution),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height),this.camera.controllerMode=this.currentMode,this.camera.updateTime(e),this.renderer){let e=this.modelScene.loaded,t=this.modelScene.refined;this.modelScene.update(this.renderer,this.camera),e===!1&&this.modelScene.loaded===!0&&(this.controller&&this.controller.updateModel(this.modelScene),AnimationFrameLoop.shared.add(()=>{this.emit(`models.load`,createEvent(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&AnimationFrameLoop.shared.add(()=>{this.emit(`models.refined`,createEvent(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){scratchBox3.makeEmpty(),scratchBox3.expandByObject(this.modelScene.boundingMesh);let t=scratchBox3.getBoundingSphere(scratchSphere),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=clamp$1(n,800);let r=n/1e4;r=clamp$1(r,.03,.1),this.camera.near!==r&&(this.camera.near=r),this.camera.far!==n&&(this.camera.far=n),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0)return;let r=createEvent(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let o=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,createEvent(`render`,{needsRender:o})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof InternalWebGLRenderer&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:o,renderer:s}=this;if(!o)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!s)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let c=this.works.getObserver(t);if(!c)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let l={workCode:c.work.workCode,panoIndex:c.panoIndex};return`moveToPano`in o&&typeof o.moveToPano==`function`?o.moveToPano(l,n,r):c&&(this.pano=l,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=noop){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],o=now();return Promise.all(r.map(e=>{let t=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},pick(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),o=n.work.getURL(n.images[e]),s=this.imageOptions.transform?this.imageOptions.transform(o,r):imageURL(o,r);return getFetcher(this.fiveId,n.work).preload(s)})).then(()=>{let e=now()-o;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new three.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[o]=this.modelScene.intersectRaycaster(r);if(o&&o.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new three.Vector2),o=r.x*this.viewport.width,s=r.y*this.viewport.height,c=r.x*this.viewport.left+(n.x+1)/2*o,l=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*s;return new three.Vector2(c,l)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,o,s,c,l,u,d,f,p,m;e=pick(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof three.Vector3)&&(e.offset=new three.Vector3(e.offset.x,e.offset.y,e.offset.z));let h;if(typeof e.panoIndex==`number`)if(e.workCode)h={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(o=(r=this.work)==null?void 0:r.workCode)==null?``:o,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),h={workCode:t,panoIndex:e.panoIndex}}let g=(s=e.mode)==null?this.state.mode:s,_,v,y,b,S;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==g){if(g===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let t={workCode:h==null?void 0:h.workCode,panoIndex:h==null?void 0:h.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof three.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[g]),r=Controllers[g].initAnimationEndState(n);_=r.longitude,v=r.latitude,y=r.fov,b=r.offset,S=r.distance}else _=(c=e.longitude)==null?this.state.longitude:c,v=(l=e.latitude)==null?this.state.latitude:l,y=(u=e.fov)==null?this.state.fov:u,b=(d=e.offset)==null?this.state.offset:d,S=(f=e.distance)==null?this.state.distance:f;let C={workCode:(h==null?this.pano:h).workCode,panoIndex:(h==null?this.pano:h).panoIndex,mode:g,longitude:_,latitude:v,fov:y,offset:b,distance:S};this.emit(`state.set`,createEvent(`state.set`,{userAction:n,state:C})),stateEqual(this.state,C)||(this.controller&&C.mode===`VRPanorama`&&C.mode!==this.state.mode?(assignState(this.state,C),this.changeMode(`VRPanorama`)):this.controller&&C.mode===`XRPanorama`&&C.mode!==this.state.mode?(assignState(this.state,C),this.changeMode(`XRPanorama`)):(assignState(this.state,C),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===C.mode&&(this.syncingState=this.syncState(now(),0,t),this.syncingState&&((p=this.controller)==null||p.updateTime(now(),0),this.syncingState=!1)),this.emit(`state.change`,createEvent(`state.change`,{userAction:n,state:this.state})),(m=this.analysis)==null||m.state(this.works,this.state)))}syncState(t,n,r=!1){let o=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof Controllers.Model){if(notSimilarVector3(this.camera.pose.offset,this.state.offset)){let e={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset};return this.controller.moveToPosition(this.state.offset,Object.assign(Object.assign({},e),{duration:r?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!panoEqual(e,this.pano)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`){let t={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.controller.moveToPano(e,t,!1),!0}}if(this.controller instanceof Controllers.Floorplan||this.controller instanceof Controllers.Topview||this.controller instanceof Controllers.Mapview){let e=1,t=.2,n=.2,o=Math.PI/45,s=r?this.state.fov:stepNumber(this.camera.pose.fov,this.state.fov,1),c=Math.abs(this.camera.pose.distance-this.state.distance),l=c>n*15?c/15:.2,u=r?this.state.distance:stepNumber(this.camera.pose.distance,this.state.distance,l),d=this.camera.pose.offset.distanceTo(this.state.offset),f=d>n*15?d/15:n,p=r?new three.Vector3().copy(this.state.offset):stepVector(this.camera.pose.offset,this.state.offset,f),{longitude:m,latitude:h}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:stepCoordinates({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},o);if(notSimilarValue(s,this.camera.pose.fov)||notSimilarVector3(p,this.camera.pose.offset)||notSimilarValue(u,this.camera.pose.distance)||notSimilarValue(m,this.camera.pose.longitude,Math.PI*2)||notSimilarValue(h,this.camera.pose.latitude)){let e={x:p.x,y:p.y,z:p.z},t={fov:s};return Object.assign(e,{distance:u}),Object.assign(t,{longitude:m,latitude:h}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(noop),this.controller.locationMotion.set(e,0).catch(noop),!0}}else{let e=1,t=Math.PI/45,n=r?this.state.fov:stepNumber(this.camera.pose.fov,this.state.fov,1),{longitude:o,latitude:s}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:stepCoordinates({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t),c=this.state.distance,l=new three.Vector3().copy(this.state.offset);if(notSimilarValue(c,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),notSimilarVector3(l,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),notSimilarValue(o,this.camera.pose.longitude,Math.PI*2)||notSimilarValue(s,this.camera.pose.latitude)||notSimilarValue(n,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:o,latitude:s,fov:n},0).catch(noop),!0}if(this.stateSynced=!0,o===!1&&this.emit(`state.synced`,createEvent(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof Controllers.Panorama&&t.tile===!0&&!this.controller.isTileReady()?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(noop)}requestFullscreen(){var e;if(!isMobile)return;let t=(e=this.getElement())==null?void 0:e.parentNode;t&&`requestFullscreen`in t&&typeof document<`u`&&document.fullscreenElement===null&&t.requestFullscreen()}exitFullscreen(){typeof document<`u`&&document.fullscreenElement&&`exitFullscreen`in document&&document.exitFullscreen()}throwError(e){this.hasListener(`error`)?this.emit(`error`,e):console.error(e)}bindModel(e){let t=()=>{AnimationFrameLoop.shared.add(()=>{this.emit(`model.load`,createEvent(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,createEvent(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,createEvent(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},o=t=>{this.emit(`models.tileLoad`,createEvent(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},s=t=>{this.emit(`models.tileUnload`,createEvent(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},c=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,o),e.removeEventListener(`tileUnload`,s),e.removeEventListener(`dispose`,c)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,o),e.addEventListener(`tileUnload`,s),e.addEventListener(`dispose`,c),this.emit(`model.request`,createEvent(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,o=new Fetcher({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=verifyURL(e,r);return t instanceof Error?Promise.reject(t):t})}});registerFetcher(this.fiveId,e,o)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(t,n){if(!this.renderer)throw Error(`renderer is not initialized.`);let r=Controllers[t];this.currentMode=t;let o=new r(n);for(let e of PROXY_CONTROLLER_EVENT_NAMES)o.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=Controllers[t].initAnimationEndState(n),r=n.initial.userAction;stateEqual(this.state,e)||(assignState(this.state,e),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return o.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),o.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),o.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),o.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),o.on(`error`,e=>this.throwError(e)),o}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:o}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:o}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let t=new three.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new three.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().inverse();return n.applyQuaternion(r),{theta:Math.atan2(n.x,-n.z),phi:-Math.asin(n.y),lookAtVector:n}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableHQ(){return this.fiveRenderer.renderMode===`point-cloud-high-quality`}set enableHQ(e){this.fiveRenderer.renderMode=e?`point-cloud-high-quality`:`default`,this.needsRender=!0}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}get enableIOSEDR(){return!1}set enableIOSEDR(e){}get enablePostProcessing(){return!0}set enablePostProcessing(e){}get modelSceneNeedsRender(){return this.modelScene.needsRender}set modelSceneNeedsRender(e){this.modelScene.needsRender=e}};Five.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:three,constructor:Five,instances:Five_Instances}});var XRButton=class{static createButton(e){let t=document.createElement(`button`);function n(){t.style.display=``,t.style.cursor=`pointer`,t.style.left=`calc(50% - 50px)`,t.style.width=`100px`,t.textContent=`ENTER VR`,t.onmouseenter=function(){t.style.opacity=`1.0`},t.onmouseleave=function(){t.style.opacity=`0.5`},t.onclick=function(){e&&e()}}function r(){t.style.display=``,t.style.cursor=`auto`,t.style.left=`calc(50% - 75px)`,t.style.width=`150px`,t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function o(){r(),t.textContent=`VR NOT SUPPORTED`}function s(e){e.style.position=`absolute`,e.style.bottom=`20px`,e.style.padding=`12px 6px`,e.style.border=`1px solid #fff`,e.style.borderRadius=`4px`,e.style.background=`rgba(0,0,0,0.1)`,e.style.color=`#fff`,e.style.font=`normal 13px sans-serif`,e.style.textAlign=`center`,e.style.opacity=`0.5`,e.style.outline=`none`,e.style.zIndex=`999`}if(`xr`in navigator)return t.id=`VRButton`,t.style.display=`none`,s(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():o()}),t;{let e=document.createElement(`a`);return window.isSecureContext===!1?(e.href=document.location.href.replace(/^http:/,`https:`),e.innerHTML=`WEBXR NEEDS HTTPS`):(e.href=`https://immersiveweb.dev/`,e.innerHTML=`WEBXR NOT AVAILABLE`),e.style.left=`calc(50% - 90px)`,e.style.width=`180px`,e.style.textDecoration=`none`,s(e),e}}};exports.AdaptiveLuminancePass=AdaptiveLuminancePass,exports.AnimationFrameLoop=AnimationFrameLoop,exports.BoundingMesh=BoundingMesh,exports.Camera=Camera,exports.CustomShader=PBMCustomShader,exports.PBMCustomShader=PBMCustomShader,exports.EffectComposer=EffectComposer,exports.EyeDomeLightingPass=EyeDomeLightingPass,exports.Fetcher=Fetcher,exports.Five=Five,exports.FivePass=FivePass,exports.FiveRenderer=FiveRenderer,exports.FullScreenQuad=FullScreenQuad,exports.Histogram=Histogram,exports.InternalWebGLRenderer=InternalWebGLRenderer,exports.Model=Model,exports.ModelScene=ModelScene,exports.Motion=Motion,exports.NetworkSubscribe=NetworkSubscribe,exports.PBMContainer=PBMContainer,exports.PBMGSObject=PBMGaussianSplattingObject,exports.PBMGroup=PBMGroup,exports.PBMMesh=PBMMesh,exports.PBMMeshMaterial=PBMMeshMaterial,exports.PBMPanoFilter=PBMPanoFilter,exports.PBMPointCloud=PBMPointCloud,exports.PBMPointCloudMaterial=PBMPointCloudMaterial,exports.PBMSkinnedMesh=PBMSkinnedMesh,exports.PBMUpdateable=PBMUpdateable,exports.PROXY_CONTROLLER_EVENT_NAMES=PROXY_CONTROLLER_EVENT_NAMES,exports.PanoCircleMesh=PanoCircleMesh,exports.PanoCircleMeshCustom=PanoCircleMeshCustom,exports.PanoCircleMeshSolid=PanoCircleMeshSolid,exports.Parameter=Parameter,exports.Scene=Scene,exports.Subscribe=Subscribe,exports.TextureLoader=TextureLoader,exports.Tile=Tile,exports.Tile3D=Tile3D,exports.Tile3DModel=Tile3D,exports.TileCache=TileCache,exports.TileNode=TileNode,exports.TileRequestScheduler=TileRequestScheduler,exports.Tileset=Tileset,exports.Trajectory=Trajectory,exports.TrajectoryNode=TrajectoryNode,exports.Work=Work,exports.WorkResolvedObserver=WorkResolvedObserver,exports.XRButton=XRButton,exports.controllersDefaultInitArgs=controllersDefaultInitArgs,exports.coordinatesToVector=coordinatesToVector,exports.createDebugBoundingMesh=createDebugBoundingMesh,exports.createWorks=createWorks,exports.defaultImageURLTransform=imageURL,exports.draco=draco,exports.getViewportScale=getViewportScale,exports.headingToLongitude=headingToLongitude,exports.imageSupport=imageSupport,exports.isBoundingVolume=isBoundingVolume,exports.isPanoId=isPanoId,exports.ktx2=ktx2,exports.loadAt3d=loadAt3d,exports.loadB3dm=loadB3dm,exports.loadDome=loadDome,exports.loadDomez=loadDomez,exports.loadFbx=loadFbx,exports.loadGltf=loadGltf,exports.loadPbm=loadPbm,exports.loadPly=loadPly,exports.loadPnts=loadPnts,exports.loadSplat=loadSplat,exports.loadSpz=loadSpz,exports.loadX3p=loadX3p,exports.longitudeToHeading=longitudeToHeading,exports.makeBoundingVolume=makeBoundingVolume,exports.panoEqual=panoEqual,exports.panoParse=panoParse,exports.panoStringify=panoStringify,exports.parseWork=parseWork,exports.vectorToCoordinates=vectorToCoordinates,exports.workToJson=workToJson});
2353
+ ----<<-计算从-}yn-中心到当前片段的平方距离----<<-由于-]|vv|{-已经按-\05E6-缩放,平方结果会被缩放-E-倍----<<-如果平方结果大于-E,说明在椭圆外,距离均值超过-\05E6-个标准差----sy|n-N-J-q|5]|vv|{9-]|vv|{6H----vs-5N-K-E;=6-qvpnqH--------rp@-p|y|-J-P|y|;toH--------<<-由于渲染的-}yn-按-\05E6-缩放,高斯公式中的逆协方差矩阵部分变成单位矩阵----<<-因此只剩下-5e-:-zrn{6-7-5e-:-zrn{6,而-zrn{-为零,所以是-e-7-e,即-N----sy|n-|}npv\b-J-r\x07}5:=;B-7-N6-7-P|y|;nH--------tylSntP|y|-J-rpA5p|y|;to9-|}npv\b6H\f`),MAX_POOL_SIZE=2,PBMGaussianSplattingRenderMesh=class extends three.Mesh{constructor(){super(),this.renderData=null,this.needsRender=!1,this.sortWorker=null,this.depthIndex=new Uint32Array,this.splatIndexCapacity=0,this.activeSlot=null,this.pendingSlot=null,this.rebuildGeneration=0,this.forceClipperUniformRefresh=!1,this.incrementalUpdateInFlight=!1,this.freeSlotPool=[],this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.usedSHDegree=0,this.sortDataRebuilding=!1,this.onBeforeRender=(e,t,n)=>{let r=n,o=this.collectObjects(t);if(o.length===0){this.geometry.instanceCount=0;return}let s=0;o.forEach(e=>{e.usedSHDegree>s&&(s=e.usedSHDegree)}),this.setMaxShDegree(s),this.isSceneNeedsRebuild(o)&&(this.tryStartIncrementalUpdate(o)||(this.startPendingRebuild(o),this.gsSceneState.lastClipperHash=``));let c=o.filter(e=>e.transformChanged);c.length>0&&(this.syncTransformsForSlot(this.activeSlot,c),this.syncTransformsForSlot(this.pendingSlot,c),c.forEach(e=>{e.transformChanged=!1,e.selectedChanged=!1})),this.activeSlot&&this.updateSlotTextures(this.activeSlot),this.pendingSlot&&this.updateSlotTextures(this.pendingSlot);let l=new three.Matrix4().multiplyMatrices(r.perspectiveProjectionMatrix,r.matrixWorldInverse).elements;this.pendingSlot&&this.pendingSlot.renderData.initialBuildComplete&&this.pendingSlot.awaitingFirstSort?this.requestSort(this.pendingSlot,l):this.activeSlot&&this.requestSort(this.activeSlot,l);let u=this.getClipperHash(o);if((this.forceClipperUniformRefresh||u!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(o),this.gsSceneState.lastClipperHash=u,this.forceClipperUniformRefresh=!1,this.needsRender=!0),this.activeSlot){let e=Math.min(this.usedSHDegree,this.activeSlot.renderData.maxShDegree);this.material.uniforms.u_maxShDegree.value=e,e>0&&!this.activeSlot.textures.shTexture?this.createSHTexture(this.activeSlot):e===0&&this.activeSlot.textures.shTexture&&(this.activeSlot.textures.shTexture.dispose(),this.activeSlot.textures.shTexture=null),this.material.uniforms.u_shTexture.value=this.activeSlot.textures.shTexture,this.renderData=this.activeSlot.renderData}else this.pendingSlot||(this.bindSlotTextures(null),this.material.uniforms.u_maxShDegree.value=0,this.geometry.instanceCount=0);this.material.uniforms.resolution.value.set(r.resolution.x,r.resolution.y)};let e=this.createGeometry(),t=this.createMaterial();this.geometry=e,this.material=t,this.frustumCulled=!1,this.renderOrder=-99999999999,this.gsSceneState={lastObjectsHash:``,lastClipperHash:``},this.sortWorker=new WorkerWrapper,this.sortWorker.postMessage({warmup:!0}),RenderData.warmupWasm(),this.sortWorker.onmessage=e=>{if(e.data.depthIndex){let t=e.data.generation;if(this.pendingSlot&&t===this.pendingSlot.generation){this.pendingSlot.awaitingFirstSort=!1,this.swapPendingToActive(e.data.depthIndex);return}this.activeSlot&&t===this.activeSlot.generation&&(this.activeSlot.awaitingFirstSort=!1,this.applyDepthIndex(e.data.depthIndex))}}}ensureSplatIndexCapacity(e){let t=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return t;let n=this.getExpandedCapacity(e),r=t.array,o=new Float32Array(n);o.set(r.subarray(0,Math.min(r.length,n)));let s=new three.InstancedBufferAttribute(o,1,!1,1);return s.setUsage(three.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,s),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,s}getExpandedCapacity(e){let t=Math.max(this.splatIndexCapacity,1);for(;t<e;)t*=2;return t}createGeometry(){let e=new three.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new three.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new three.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity);for(let e=0;e<r.length;e++)r[e]=e;let o=new three.InstancedBufferAttribute(r,1,!1,1);return o.setUsage(three.DynamicDrawUsage),e.setAttribute(`splatIndex`,o),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}createMaterial(){return new three.ShaderMaterial({vertexShader:vertex_default,fragmentShader:fragment_default,defines:{NUM_GS_LAYERS:0,NUM_GS_CLIPPERS:0},uniforms:{u_texture:{value:null},u_transforms:{value:null},u_transformIndices:{value:null},u_layerIndices:{value:null},u_numGsLayers:{value:0},u_numGsClippers:{value:0},u_layerClipperRanges:{value:[]},u_clipperMatricesInverse:{value:[]},u_shTexture:{value:null},u_shTextureSize:{value:new three.Vector2},u_maxShDegree:{value:0},resolution:{value:new three.Vector2},u_aggregationEnabled:{value:!0},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new three.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new three.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6}},side:three.DoubleSide,transparent:!0,blending:three.NormalBlending,depthTest:!0,depthWrite:!1})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new three.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new three.Matrix4)}createTextures(e,t){var n;let r;t&&t.dataTexture.image.width===e.width&&t.dataTexture.image.height===e.height?(r=t.dataTexture,r.image.data=e.data,r.needsUpdate=!0):(t&&t.dataTexture.dispose(),r=new three.DataTexture(e.data,e.width,e.height,three.RGBAIntegerFormat,three.UnsignedIntType),r.internalFormat=`RGBA32UI`,r.minFilter=three.NearestFilter,r.magFilter=three.NearestFilter,r.needsUpdate=!0);let o;t&&t.transformsTexture.image.width===e.transformsWidth&&t.transformsTexture.image.height===e.transformsHeight?(o=t.transformsTexture,o.image.data=e.transforms,o.needsUpdate=!0):(t&&t.transformsTexture.dispose(),o=new three.DataTexture(e.transforms,e.transformsWidth,e.transformsHeight,three.RGBAFormat,three.FloatType),o.internalFormat=`RGBA32F`,o.minFilter=three.NearestFilter,o.magFilter=three.NearestFilter,o.needsUpdate=!0);let s;t&&t.transformIndicesTexture.image.width===e.transformIndicesWidth&&t.transformIndicesTexture.image.height===e.transformIndicesHeight?(s=t.transformIndicesTexture,s.image.data=e.transformIndices,s.needsUpdate=!0):(t&&t.transformIndicesTexture.dispose(),s=new three.DataTexture(e.transformIndices,e.transformIndicesWidth,e.transformIndicesHeight,three.RedIntegerFormat,three.UnsignedIntType),s.internalFormat=`R32UI`,s.minFilter=three.NearestFilter,s.magFilter=three.NearestFilter,s.needsUpdate=!0);let c;t&&t.layerIndicesTexture.image.width===e.layerIndicesWidth&&t.layerIndicesTexture.image.height===e.layerIndicesHeight?(c=t.layerIndicesTexture,c.image.data=e.layerIndices,c.needsUpdate=!0):(t&&t.layerIndicesTexture.dispose(),c=new three.DataTexture(e.layerIndices,e.layerIndicesWidth,e.layerIndicesHeight,three.RedIntegerFormat,three.UnsignedIntType),c.internalFormat=`R32UI`,c.minFilter=three.NearestFilter,c.magFilter=three.NearestFilter,c.needsUpdate=!0);let l=(n=t==null?void 0:t.shTexture)==null?null:n;return{dataTexture:r,transformsTexture:o,transformIndicesTexture:s,layerIndicesTexture:c,shTexture:l}}createSHTexture(e){let{renderData:t,textures:n}=e;if(t.shDataReleased)return;n.shTexture&&(n.shTexture.dispose(),n.shTexture=null);let r=Math.min(this.usedSHDegree,t.maxShDegree),o=0;if(r>=1&&(o+=9),r>=2&&(o+=15),r>=3&&(o+=21),o===0)return;let s=4,c=o;c%4!=0&&(c=Math.ceil(c/4)*4);let l=t.numPoints*c/4,u=2048,d=Math.ceil(l/u),f=new Float32Array(u*d*4);for(let e=0;e<t.numPoints;e++){let n=c/4*e,o=0;if(t.sh1&&r>=1)for(let r=0;r<9;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh1[e*9+r],o++}if(t.sh2&&r>=2)for(let r=0;r<15;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh2[e*15+r],o++}if(t.sh3&&r>=3)for(let r=0;r<21;r++){let s=n+Math.floor(o/4),c=o%4,l=s*4+c;f[l]=t.sh3[e*21+r],o++}}n.shTexture=new three.DataTexture(f,u,d,three.RGBAFormat,three.FloatType),n.shTexture.internalFormat=`RGBA32F`,n.shTexture.minFilter=three.NearestFilter,n.shTexture.magFilter=three.NearestFilter,n.shTexture.needsUpdate=!0,this.material.uniforms.u_shTextureSize.value.set(u,d),this.material.uniforms.u_maxShDegree.value=r,e.renderData.releaseSHData()}setMaxShDegree(e){var t,n;if(e<0||e>2){console.warn(`现在只支持012三种阶数,你输入的是${e}`);return}let r=this.usedSHDegree;this.usedSHDegree=e,r!==e&&((t=this.activeSlot)!=null&&t.textures.shTexture&&(this.activeSlot.textures.shTexture.dispose(),this.activeSlot.textures.shTexture=null),(n=this.pendingSlot)!=null&&n.textures.shTexture&&(this.pendingSlot.textures.shTexture.dispose(),this.pendingSlot.textures.shTexture=null),this.material.uniforms.u_maxShDegree.value=e,e===0?this.material.uniforms.u_shTexture.value=null:this.activeSlot&&this.activeSlot.renderData.maxShDegree>0&&(this.createSHTexture(this.activeSlot),this.material.uniforms.u_shTexture.value=this.activeSlot.textures.shTexture))}bindSlotTextures(e){if(!e){this.dataTexture=null,this.transformsTexture=null,this.transformIndicesTexture=null,this.layerIndicesTexture=null,this.shTexture=null,this.material.uniforms.u_texture.value=null,this.material.uniforms.u_transforms.value=null,this.material.uniforms.u_transformIndices.value=null,this.material.uniforms.u_layerIndices.value=null,this.material.uniforms.u_shTexture.value=null;return}this.dataTexture=e.textures.dataTexture,this.transformsTexture=e.textures.transformsTexture,this.transformIndicesTexture=e.textures.transformIndicesTexture,this.layerIndicesTexture=e.textures.layerIndicesTexture,this.shTexture=e.textures.shTexture,this.material.uniforms.u_texture.value=this.dataTexture,this.material.uniforms.u_transforms.value=this.transformsTexture,this.material.uniforms.u_transformIndices.value=this.transformIndicesTexture,this.material.uniforms.u_layerIndices.value=this.layerIndicesTexture,this.material.uniforms.u_shTexture.value=this.shTexture}disposeSlot(e){e&&(e.renderData.dispose(),this.disposeTextures(e.textures))}recycleSlot(e){if(e){if(this.freeSlotPool.length>=MAX_POOL_SIZE){let e=this.freeSlotPool.shift();this.disposeSlot(e)}e.renderData.releaseSortData(),e.renderData.releaseAggregatedData(),e.awaitingFirstSort=!0,e.sortDataUploaded=!1,this.freeSlotPool.push(e)}}disposeTextures(e){e.dataTexture.dispose(),e.transformsTexture.dispose(),e.transformIndicesTexture.dispose(),e.layerIndicesTexture.dispose(),e.shTexture&&(e.shTexture.dispose(),e.shTexture=null)}applyDepthIndex(e){this.depthIndex=e;let t=this.depthIndex.length,n=this.ensureSplatIndexCapacity(t);n.array.set(this.depthIndex,0),n.count=this.depthIndex.length,n.updateRange.offset=0,n.updateRange.count=t,n.needsUpdate=!0,this.geometry.instanceCount=this.depthIndex.length,this.needsRender=!0}swapPendingToActive(e){if(!this.pendingSlot)return;let t=this.activeSlot;this.activeSlot=this.pendingSlot,this.pendingSlot=null,this.renderData=this.activeSlot.renderData,this.ensureSplatIndexCapacity(this.activeSlot.renderData.numPoints),this.bindSlotTextures(this.activeSlot),this.activeSlot.sortDataUploaded=!0,this.forceClipperUniformRefresh=!0,this.applyDepthIndex(e),t&&this.recycleSlot(t)}createSlot(e){let t={generation:e.generation,renderData:e,textures:this.createTextures(e),awaitingFirstSort:!0,sortDataUploaded:!1};return this.usedSHDegree>0&&e.maxShDegree>0&&this.createSHTexture(t),t}updateSlotTextures(e){e.renderData.dataChanged&&(e.textures.dataTexture.needsUpdate=!0,e.renderData.dataChanged=!1),e.renderData.transformsChanged&&(e.textures.transformsTexture.needsUpdate=!0,e.renderData.indexDataReleased||(e.textures.transformIndicesTexture.needsUpdate=!0),e.renderData.transformsChanged=!1)}postSortData(e){var t;let n=e.renderData.positions,r=new Float32Array(e.renderData.transforms.slice().buffer),o=new Uint32Array(e.renderData.transformIndices.slice().buffer);(t=this.sortWorker)==null||t.postMessage({sortData:{positions:n,transforms:r,transformIndices:o,vertexCount:e.renderData.numPoints,generation:e.generation}},[n.buffer,r.buffer,o.buffer]),e.renderData.releaseSortData(),e.renderData.releaseIndexData(),e.sortDataUploaded=!0}requestSort(e,t){var n;if(e.renderData.initialBuildComplete){if(e.renderData.dataChanged||e.renderData.transformsChanged||!e.sortDataUploaded){if(e.renderData.sortDataReleased){this.sortDataRebuilding||(this.sortDataRebuilding=!0,e.renderData.rebuildSortData().then(()=>{this.sortDataRebuilding=!1,(this.activeSlot===e||this.pendingSlot===e)&&(e.sortDataUploaded=!1,this.needsRender=!0)}));return}this.postSortData(e)}(n=this.sortWorker)==null||n.postMessage({viewProj:t})}}syncTransformsForSlot(e,t){e&&t.forEach(t=>{e.renderData.splatIndices.has(t)&&e.renderData.updateTransform(t)})}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof PBMGaussianSplattingObject&&e.visible&&t.push(e)}),t.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:n>r?1:0}),t}isSceneNeedsRebuild(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`),n=t!==this.gsSceneState.lastObjectsHash;return this.gsSceneState.lastObjectsHash=t,n}getClipperHash(e){return e.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`)}updateClipperCounts(e,t){let n=Math.max(0,e|0),r=Math.max(0,t|0),o=this.material.defines;(o.NUM_GS_LAYERS!==n||o.NUM_GS_CLIPPERS!==r)&&(o.NUM_GS_LAYERS=n,o.NUM_GS_CLIPPERS=r,this.material.needsUpdate=!0),this.material.uniforms.u_numGsLayers.value=e,this.material.uniforms.u_numGsClippers.value=t}updateClipperUniforms(e){var t,n,r,o;let s=(n=(t=this.activeSlot)==null?void 0:t.renderData)==null?null:n;if(!s){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let c=new Map;for(let t of e)c.has(t.gsViewLayerKey)||c.set(t.gsViewLayerKey,t.gsClippers);let l=s.layerKeys.length,u=0;for(let e of s.layerKeys)u+=((r=c.get(e))==null?[]:r).length;let d=this.createDefaultLayerClipperRanges(l),f=this.createDefaultClipperMatrices(u),p=0;for(let e of s.layerKeys){let t=s.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(o=c.get(e))==null?[]:o,r=p,l=0;for(let e of n)f[p].getInverse(e.clippingBoxMatrix),p++,l++;l>0&&d[t].set(r,l)}this.material.uniforms.u_layerClipperRanges.value=d,this.material.uniforms.u_clipperMatricesInverse.value=f,this.updateClipperCounts(l,p)}startPendingRebuild(e){this.pendingSlot&&(this.recycleSlot(this.pendingSlot),this.pendingSlot=null),this.rebuildGeneration+=1;let t=new RenderData(e,this.rebuildGeneration),n=this.freeSlotPool.pop();if(n){n.renderData.dispose();let e=this.createTextures(t,n.textures);this.pendingSlot={generation:t.generation,renderData:t,textures:e,awaitingFirstSort:!0,sortDataUploaded:!1}}else this.pendingSlot=this.createSlot(t)}tryStartIncrementalUpdate(e){if(!this.activeSlot||this.pendingSlot||this.incrementalUpdateInFlight)return!1;let t=this.activeSlot.renderData.getObjectsInOrder();if(!this.activeSlot.renderData.canIncrementalAppend(e))return!1;let n=e.slice(t.length);if(n.length===0)return!1;this.incrementalUpdateInFlight=!0;let r=this.activeSlot;return r.renderData.appendObjects(n).then(e=>{e&&(this.activeSlot!==r||r.renderData.disposed||(r.textures=this.createTextures(r.renderData,r.textures),this.usedSHDegree>0&&r.renderData.maxShDegree>0&&this.createSHTexture(r),this.bindSlotTextures(r),this.ensureSplatIndexCapacity(r.renderData.numPoints),r.sortDataUploaded=!1,r.awaitingFirstSort=!0,this.forceClipperUniformRefresh=!0,this.gsSceneState.lastClipperHash=``,this.needsRender=!0))}).catch(e=>{console.warn(`Incremental append failed, fallback to rebuild:`,e)}).finally(()=>{this.incrementalUpdateInFlight=!1}),!0}dispose(){this.disposeSlot(this.pendingSlot),this.pendingSlot=null,this.disposeSlot(this.activeSlot),this.activeSlot=null;for(let e of this.freeSlotPool)this.disposeSlot(e);this.freeSlotPool.length=0,this.renderData=null,this.sortWorker&&this.sortWorker.terminate(),this.bindSlotTextures(null),this.geometry.dispose(),this.material.dispose()}},PBMGaussianSplattingTestMesh=class extends three.Mesh{constructor(){super(),this.onBeforeRender=(e,t,n)=>{this.collectObjects(t).length>0&&console.warn(`未开启webgl2, 3dgs仅支持在开启webgl2模式后使用`)}}collectObjects(e){let t=[];return e.traverse(e=>{e instanceof PBMGaussianSplattingObject&&e.visible&&t.push(e)}),t}},DEFAULT_MODE_CHANGE_DURATION=1e3,DEFAULT_CAMERA_FOV=90,DEFAULT_REQUEST_PROXY=e=>e.replace(`//vrlab-public.ljcdn.com/`,`//vr-public.realsee-cdn.cn/`).replace(`//vrlab-image4.ljcdn.com/`,`//vr-image-4.realsee-cdn.cn/`).replace(`//vrlab-image3.ljcdn.com/`,`//vr-image-3.realsee-cdn.cn/`).replace(`//vrlab-image2.ljcdn.com/`,`//vr-image-2.realsee-cdn.cn/`).replace(`//vrlab-image1.ljcdn.com/`,`//vr-image-1.realsee-cdn.cn/`),scratchSphere=new three.Sphere,scratchBox3=new three.Box3,scratchViewport=new three.Vector4,scratchScissor=new three.Vector4,scratchClearColor=new three.Color,scratchRenderSize=new three.Vector2,worksMap=new WeakMap,emptyWorks=createWorks([parseWork(null)]),Five_Instances={},Five=class e extends Subscribe{static get version(){return`6.8.1`}static get dracoPath(){return draco.decoderPath}static set dracoPath(e){draco.setDecoderPath(e)}static get ktx2Path(){return ktx2.transcoderPath}static set ktx2Path(e){ktx2.setTranscoderPath(e)}static get useNativeImageBitmap(){return canUseNativeImageBitmap()}static set useNativeImageBitmap(e){useNativeImageBitmap(e)}constructor(e={}){var t,n,r,o,s,c,l,u,d,f,p;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=createUuid(),Five_Instances[this.fiveId]=this,this.currentUpdateArgs={time:now(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!1,this.onlyRenderIfNeeds=(t=e.onlyRenderIfNeeds)==null?!0:t,this.imageOptions=Object.assign({},(n=e.imageOptions)==null?{}:n),this.textureOptions=Object.assign({},(r=e.textureOptions)==null?{}:r),this.poweredByRealsee=(o=e.poweredByRealsee)==null?!0:o,this.backgroundColor=new three.Color((s=e.backgroundColor)==null?1579548:s),this.backgroundAlpha=(c=e.backgroundAlpha)==null?1:c,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview),VRPanorama:Object.assign({},e.vrPanorama),XRPanorama:Object.assign({},e.xrPanorama)},this.fps={testCount:0,testTime:now()},this.modeChangeDuration=(l=e.modeChangeDuration)==null?DEFAULT_MODE_CHANGE_DURATION:l,this.enableWheel=(u=e.enableWheel)==null?!0:u,typeof window<`u`)if(`renderer`in e)e.renderer instanceof InternalWebGLRenderer&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new InternalWebGLRenderer({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=getViewportScale();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new three.WebGLRenderTarget(1,1,{encoding:(f=(d=this.renderer)==null?void 0:d.outputEncoding)==null?three.sRGBEncoding:f,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Camera(DEFAULT_CAMERA_FOV),this.scene=new Scene,this.xrCustomObjectsScene=new three.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(p=e.requestProxy)==null?DEFAULT_REQUEST_PROXY:p,this.networkSubscribe=new NetworkSubscribe,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var o;this.emit(`network.resource`,createEvent(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(o=this.analysis)==null||o.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new three.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),worksMap.set(this,emptyWorks),this.modelScene=new ModelScene({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[m]=this.modelScene.setModels(emptyWorks,{forceReplaceImmediately:!0});defineProperty(m,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new three.VideoTexture(e.videoInstance||generateDefaultVideoElement());let h=initLights();this.scene.add(h),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=AnimationFrameLoop.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let g=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,createEvent(`vr.requestExit`,{}))},_=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,g,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,_,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,g,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,_,!1)},this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}initLegacyEvent(this),this.fiveRenderer=new FiveRenderer,this.adaptiveLuminancePass=new AdaptiveLuminancePass,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new EyeDomeLightingPass(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new PBMGaussianSplattingRenderMesh,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new PBMGaussianSplattingTestMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return panoStringify(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Five_Instances[this.fiveId],this.emit(`dispose`),this.destroyed=!0,this.pause(),this.stopAnimationLoop&&(this.stopAnimationLoop(),this.stopAnimationLoop=void 0),this.off(),this.networkSubscribe.off(),this.controller&&(this.controller.destroy(),this.controller=void 0);let t=this.getElement();t&&t.parentNode&&t.parentNode.removeChild(t);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((e=n.pano0)==null?void 0:e.map)&&n.pano1.map.dispose(),n.reset(`pano0`,`pano1`),this.modelScene.dispose(),this.scene.dispose(),this.xrCustomObjectsScene.dispose(),worksMap.set(this,emptyWorks),this.renderer&&this.renderer.render(new three.Scene,new three.Camera),this.fiveRenderer.dispose(),this.renderer instanceof InternalWebGLRenderer&&(this.renderer.forceContextLoss&&this.renderer.forceContextLoss(),this.renderer.dispose())}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,createEvent(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,omitUndefinedFields(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,omitUndefinedFields(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,omitUndefinedFields(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,omitUndefinedFields(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,omitUndefinedFields(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,omitUndefinedFields(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,omitUndefinedFields(e.xrPanorama)),this.currentMode===`XRPanorama`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),(this.currentMode===`Panorama`||this.currentMode===`VRPanorama`)&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof InternalWebGLRenderer)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,o;if(!this.renderer)return;let s=this.renderer.domElement.parentNode,{width:c=(n=s==null?void 0:s.offsetWidth)==null?512:n,height:l=(r=s==null?void 0:s.offsetHeight)==null?512:r}=e;if(c=Math.max(1,c),l=Math.max(1,l),!t){let e=getViewportScale(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(o=e===1?n:1)==null?1:o,t>1){let e=Math.max(c,l)*t,n=Math.min(this.renderer.capabilities.maxTextureSize,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(c,l),this.needsRender=!0;let u=now(),d=u-this.currentUpdateArgs.time,f=this.currentUpdateArgs.args;this.updateTime(u,d,...f)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return worksMap.get(this)||emptyWorks}get work(){return this.works[0]}get observers(){return this.work.observers}get models(){return this.modelScene.models}get model(){return this.modelScene.models[0]}load(e,t,n,r=!0){if(!this.renderer)throw Error(`renderer is not initialized`);let o=this.loadWorkTask.then(()=>isPromise(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=o.catch(e=>{this.throwError(e)}),o}load_(t,n,r,o=!0){var s,c,l,u,d,f,p,m,h,g;let _={};typeof r==`number`?_.duration=r:typeof r==`object`&&Object.assign(_,r),this.works===emptyWorks&&(_.duration===void 0&&(_.duration=0),_.effect===void 0&&(_.effect=`instant`));let v={};Object.assign(v,_.model),!v[`3d-tiles`]&&_[`3d-tiles`]&&(v[`3d-tiles`]=_[`3d-tiles`]),!v.textureOptions&&_.textureOptions&&(v.textureOptions=_.textureOptions),!v.textureOptions&&this.textureOptions&&(v.textureOptions=this.textureOptions);let y=[];if(Array.isArray(t))for(let e of t)e instanceof Work?y.push(e):typeof e!=`string`&&`work`in e?y.push(parseWork(e.work,e)):y.push(parseWork(e));else t instanceof Work?y.push(t):y.push(parseWork(t));_.mode===`add`&&(y=[].concat(this.works,y));let b;try{b=createWorks(y)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of b)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===emptyWorks&&(n=`initial`);let S=this.currentMode,C=b.initial,w=C.work.observers[0],T=w?{workCode:w.work.workCode,panoIndex:w.panoIndex}:{workCode:C.work.workCode,panoIndex:0},E=(s=C.mode)==null?w?`Panorama`:`Mapview`:s,D={};if(n===`inherit`){let e=this.getCurrentState(),[t]=b.filter(t=>t.workCode===e.workCode);if(t)T={workCode:e.workCode,panoIndex:e.panoIndex},E=e.mode,D={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:S};let e=(l=(c=b[0])==null?void 0:c.observers)==null?void 0:l[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof b.initial.panoIndex==`number`?(n.workCode=b.initial.work.workCode,n.panoIndex=b.initial.panoIndex):(n.mode===`Panorama`||n.mode===`VRPanorama`||n.mode===`XRPanorama`)&&(n.mode=`Mapview`),n.mode===S&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof C.panoIndex==`number`&&(T={workCode:C.work.workCode,panoIndex:C.panoIndex}),C.mode&&(E=C.mode),D={longitude:C.longitude,latitude:C.latitude,fov:C.fov,distance:C.distance,offset:(u=C.offset)==null?void 0:u.clone()}),typeof n==`object`){if(E=(d=n.mode)==null?S:d,typeof n.panoIndex==`number`){let e=b.getObserver({workCode:(p=(f=n.workCode)==null?C.work.workCode:f)==null?``:p,panoIndex:n.panoIndex});e&&(T={workCode:e.work.workCode,panoIndex:e.panoIndex})}D={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new three.Vector3().copy(n.offset):void 0}}let O=(m=_.duration)==null?this.modeChangeDuration:m;(E===`Floorplan`||E===`Topview`||E===`Mapview`)&&S===E&&(O=0);let k=`fly`;(E===`Panorama`||E===`VRPanorama`||E===`XRPanorama`)&&S===E&&(k=(h=_.effect)==null?`fade`:h),this.emit(`works.request`,createEvent(`works.request`,{input:t,works:b,userAction:o}));let A=(e,t,r)=>{let s=this.getCurrentState(),c=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(c=this.getCurrentState()),this.pano=t;let l=Object.assign(Object.assign({initial:{state:c,currentState:s,duration:O,effect:k,userAction:o}},this.commonParams()),this.controllerInits[e]),u=Controllers[c.mode].initAnimationEndState(l);if(this.controller&&S===e)this.controller.updateWork(b,u,{effect:k,duration:O},o)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,l));else{if(this.controller)this.controller.destroy();else{let t=Controllers[e].initAnimationEndState(l);this.camera.setFromPose(t),this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o}))}this.controller=this.applyController(e,l);let t=createEvent(`mode.change`,{prevMode:S,mode:e,state:u,userAction:o});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};worksMap.set(this,b);let j=Promise.resolve();if(E===e.Mode.Floorplan||E===e.Mode.Topview||E===e.Mode.Mapview||E===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(D),assignPose(this.state,this.camera.pose));let e=this.modelScene.setModels(b,v);j=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,A(E,T,D),this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o}))})}else{A(E,T,D);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===b&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,createEvent(`camera.update`,{state:this.getCurrentState(),userAction:o})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(b,v);j=Promise.all(r.map(e=>e.initReady)).then(noop),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((g=_.duration)==null?this.modeChangeDuration:g)+1e3)}return this.emit(`works.load`,createEvent(`works.load`,{input:t,userAction:o,works:b})),j.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,createEvent(`works.ready`,{input:t,userAction:o,works:b})),(e=this.analysis)==null||e.work(b)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),worksMap.set(this,emptyWorks),this.modelScene.setModels(emptyWorks,{forceReplaceImmediately:!0}),this.renderer&&this.modelScene.update(this.renderer,this.camera),this.needsRender=!0,this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.camera.setFromPose({distance:0,fov:DEFAULT_CAMERA_FOV,longitude:0,latitude:0,offset:new three.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,o=!0,s=!1){return new Promise((c,l)=>{var u,d,f,p;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let m=0;this.controller&&(m=typeof r==`number`?r:(u=r==null?void 0:r.duration)==null?this.modeChangeDuration:u);let h=`fly`;this.controller&&typeof r==`object`&&r.effect&&(h=r.effect);let g=typeof n.panoIndex==`number`?{workCode:(p=(d=n.workCode)==null?(f=this.work)==null?void 0:f.workCode:d)==null?``:p,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),l(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(g)){let e=Error(`PanoId ${panoStringify(g)} not existed.`);this.throwError(e),l(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(m=0);let _=this.controller,v=this.currentMode,y=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&s===!1&&v===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!panoEqual(this.pano,g)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(g,Object.assign({duration:m},n),o):this.controller.updateCamera(n,m,o).catch(noop):(panoEqual(this.pano,g)||(this.pano=g),this.controller.updateCamera(n,m,o).catch(noop));else{let e=Object.assign(Object.assign({},n),g),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:m,effect:h,userAction:o}},this.commonParams()),this.controllerInits[t]),s=Controllers[t].initAnimationEndState(r),c=createEvent(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:s,userAction:o});if(this.emit(`mode.change.request`,c),!c.defaultPrevented){_&&_.destroy(),this.controller=this.applyController(t,r);let e=createEvent(`mode.change`,{prevMode:this.currentMode,mode:t,state:s,userAction:o});this.emit(`mode.change`,e)}}c()},b=AnimationFrameLoop.shared.getContext();b&&(typeof XRSession<`u`&&b instanceof XRSession&&b.end(),AnimationFrameLoop.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),requestDeviceOrientationPermission().then(()=>y()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),l(t)})):t===e.Mode.XRPanorama?requestXRSessionPermission().then(e=>{AnimationFrameLoop.shared.setContext(e),s=!0,y()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),l(t)}):y()})}getPixels(e,t,n,r,o,s,c){if(!this.renderer)throw Error(`renderer is not initialized.`);let l=now(),u=this.renderer.getPixelRatio(),d=this.renderer.getRenderTarget(),f=this.getSize(new three.Vector2),p=0,m=0,h=1,g=1,_,v,y,b,S;typeof e==`number`?(p=e,typeof t==`number`&&(m=t),typeof n==`number`&&(h=n),typeof r==`number`&&(g=r),_=o,v=s,S=c):(p=e.x,m=e.y,h=e.width,g=e.height,_=e.pixelRatio,v=e.flipY,y=e.helperVisible,b=e.skipPanorama,S=e.buffer),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g),_=Math.floor(_==null?u:_),v=v==null?!1:v;let C=this.helperVisible,w=this.modelScene.parameter.modelAlpha;this.helperVisible=y==null?this.helperVisible:y,b&&(this.controller instanceof Controllers.Panorama||this.controller instanceof Controllers.VRPanorama||this.controller instanceof Controllers.XRPanorama)&&b===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let T=this.getPixelsRenderTarget;T.setSize(h*_,g*_),this.renderer.setRenderTarget(T),this.camera.pixelRatio=_,this.camera.resolution.set(h,g),this.camera.setViewOffset(f.width,f.height,p,f.height-m-g,h,g),this.camera.aspect=f.width/f.height,this.camera.updateTime(l),this.scene.update(this.renderer,this.camera);let E=this.renderer.autoClear,D=this.renderer.autoClearColor,O=this.renderer.autoClearDepth,k=this.renderer.autoClearStencil,A=scratchClearColor.copy(this.renderer.getClearColor()),j=this.renderer.getClearAlpha(),M=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let N=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:N,this.renderer.render(this.scene,this.camera),this.scene.background=N,this.renderer.autoClear=E,this.renderer.autoClearColor=D,this.renderer.autoClearDepth=O,this.renderer.autoClearStencil=k,this.renderer.setClearColor(A,j),this.renderer.setScissorTest(M),this.helperVisible=C,w===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,w),this.renderer.setRenderTarget(d),this.camera.clearViewOffset(),this.camera.pixelRatio=u,this.camera.resolution.copy(f),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(l),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let P=h*_,F=g*_,I=P*F,L=I*4;if(S){if(S.length!==L)throw Error(`buffer length is not equals pixels ${L}`)}else S=new Uint8Array(L);if(this.renderer.readRenderTargetPixels(T,0,0,h*_,g*_,S),v){let e=I/2;for(let t=0,n=0,r=0,o=0;n<e;n++)for(o=(F-Math.floor(n/P)-1)*P+n%P,r=0;r<4;r++)t=S[n*4+r],S[n*4+r]=S[o*4+r],S[o*4+r]=t}return S}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,o=t.autoClearColor,s=t.autoClearDepth,c=t.autoClearStencil,l=scratchClearColor.copy(t.getClearColor()),u=t.getClearAlpha(),d=t.getViewport(scratchViewport),f=t.getScissor(scratchScissor),p=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let m=t.getSize(scratchRenderSize),h=Math.floor(m.x*this.viewport.left),g=Math.floor(m.y*this.viewport.bottom),_=Math.floor(m.x*this.viewport.width),v=Math.floor(m.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(h,g,_,v),t.setScissor(h,g,_,v);let y=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(y);let b=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:b;let S=!0;if(this.controller&&this.controller.render()&&(S=!1),S){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&renderPoweredByRealsee(t)}this.scene.background=b,t.autoClear=r,t.autoClearColor=o,t.autoClearDepth=s,t.autoClearStencil=c,t.setClearColor(l,u),t.setViewport(d),t.setScissor(f),t.setScissorTest(p),t.setRenderTarget(n),e&&AnimationFrameLoop.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&ktx2.detectSupport(this.renderer),this.syncingState=this.syncState(e,t),this.controller&&this.controller.updateTime(e,t,...n),this.renderer&&(this.camera.pixelRatio=this.renderer.getPixelRatio(),this.getSize(this.camera.resolution),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height),this.camera.controllerMode=this.currentMode,this.camera.updateTime(e),this.renderer){let e=this.modelScene.loaded,t=this.modelScene.refined;this.modelScene.update(this.renderer,this.camera),e===!1&&this.modelScene.loaded===!0&&(this.controller&&this.controller.updateModel(this.modelScene),AnimationFrameLoop.shared.add(()=>{this.emit(`models.load`,createEvent(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&AnimationFrameLoop.shared.add(()=>{this.emit(`models.refined`,createEvent(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){scratchBox3.makeEmpty(),scratchBox3.expandByObject(this.modelScene.boundingMesh);let t=scratchBox3.getBoundingSphere(scratchSphere),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=clamp$1(n,800);let r=n/1e4;r=clamp$1(r,.03,.1),this.camera.near!==r&&(this.camera.near=r),this.camera.far!==n&&(this.camera.far=n),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0)return;let r=createEvent(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let o=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,createEvent(`render`,{needsRender:o})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof InternalWebGLRenderer&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:o,renderer:s}=this;if(!o)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!s)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let c=this.works.getObserver(t);if(!c)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let l={workCode:c.work.workCode,panoIndex:c.panoIndex};return`moveToPano`in o&&typeof o.moveToPano==`function`?o.moveToPano(l,n,r):c&&(this.pano=l,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=noop){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],o=now();return Promise.all(r.map(e=>{let t=panoStringify({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},pick(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),o=n.work.getURL(n.images[e]),s=this.imageOptions.transform?this.imageOptions.transform(o,r):imageURL(o,r);return getFetcher(this.fiveId,n.work).preload(s)})).then(()=>{let e=now()-o;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new three.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[o]=this.modelScene.intersectRaycaster(r);if(o&&o.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new three.Vector2),o=r.x*this.viewport.width,s=r.y*this.viewport.height,c=r.x*this.viewport.left+(n.x+1)/2*o,l=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*s;return new three.Vector2(c,l)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,o,s,c,l,u,d,f,p,m;e=pick(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof three.Vector3)&&(e.offset=new three.Vector3(e.offset.x,e.offset.y,e.offset.z));let h;if(typeof e.panoIndex==`number`)if(e.workCode)h={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(o=(r=this.work)==null?void 0:r.workCode)==null?``:o,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),h={workCode:t,panoIndex:e.panoIndex}}let g=(s=e.mode)==null?this.state.mode:s,_,v,y,b,S;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==g){if(g===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let t={workCode:h==null?void 0:h.workCode,panoIndex:h==null?void 0:h.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof three.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[g]),r=Controllers[g].initAnimationEndState(n);_=r.longitude,v=r.latitude,y=r.fov,b=r.offset,S=r.distance}else _=(c=e.longitude)==null?this.state.longitude:c,v=(l=e.latitude)==null?this.state.latitude:l,y=(u=e.fov)==null?this.state.fov:u,b=(d=e.offset)==null?this.state.offset:d,S=(f=e.distance)==null?this.state.distance:f;let C={workCode:(h==null?this.pano:h).workCode,panoIndex:(h==null?this.pano:h).panoIndex,mode:g,longitude:_,latitude:v,fov:y,offset:b,distance:S};this.emit(`state.set`,createEvent(`state.set`,{userAction:n,state:C})),stateEqual(this.state,C)||(this.controller&&C.mode===`VRPanorama`&&C.mode!==this.state.mode?(assignState(this.state,C),this.changeMode(`VRPanorama`)):this.controller&&C.mode===`XRPanorama`&&C.mode!==this.state.mode?(assignState(this.state,C),this.changeMode(`XRPanorama`)):(assignState(this.state,C),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===C.mode&&(this.syncingState=this.syncState(now(),0,t),this.syncingState&&((p=this.controller)==null||p.updateTime(now(),0),this.syncingState=!1)),this.emit(`state.change`,createEvent(`state.change`,{userAction:n,state:this.state})),(m=this.analysis)==null||m.state(this.works,this.state)))}syncState(t,n,r=!1){let o=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof Controllers.Model){if(notSimilarVector3(this.camera.pose.offset,this.state.offset)){let e={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset};return this.controller.moveToPosition(this.state.offset,Object.assign(Object.assign({},e),{duration:r?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!panoEqual(e,this.pano)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`){let t={longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.controller.moveToPano(e,t,!1),!0}}if(this.controller instanceof Controllers.Floorplan||this.controller instanceof Controllers.Topview||this.controller instanceof Controllers.Mapview){let e=1,t=.2,n=.2,o=Math.PI/45,s=r?this.state.fov:stepNumber(this.camera.pose.fov,this.state.fov,1),c=Math.abs(this.camera.pose.distance-this.state.distance),l=c>n*15?c/15:.2,u=r?this.state.distance:stepNumber(this.camera.pose.distance,this.state.distance,l),d=this.camera.pose.offset.distanceTo(this.state.offset),f=d>n*15?d/15:n,p=r?new three.Vector3().copy(this.state.offset):stepVector(this.camera.pose.offset,this.state.offset,f),{longitude:m,latitude:h}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:stepCoordinates({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},o);if(notSimilarValue(s,this.camera.pose.fov)||notSimilarVector3(p,this.camera.pose.offset)||notSimilarValue(u,this.camera.pose.distance)||notSimilarValue(m,this.camera.pose.longitude,Math.PI*2)||notSimilarValue(h,this.camera.pose.latitude)){let e={x:p.x,y:p.y,z:p.z},t={fov:s};return Object.assign(e,{distance:u}),Object.assign(t,{longitude:m,latitude:h}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(noop),this.controller.locationMotion.set(e,0).catch(noop),!0}}else{let e=1,t=Math.PI/45,n=r?this.state.fov:stepNumber(this.camera.pose.fov,this.state.fov,1),{longitude:o,latitude:s}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:stepCoordinates({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t),c=this.state.distance,l=new three.Vector3().copy(this.state.offset);if(notSimilarValue(c,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),notSimilarVector3(l,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),notSimilarValue(o,this.camera.pose.longitude,Math.PI*2)||notSimilarValue(s,this.camera.pose.latitude)||notSimilarValue(n,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:o,latitude:s,fov:n},0).catch(noop),!0}if(this.stateSynced=!0,o===!1&&this.emit(`state.synced`,createEvent(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof Controllers.Panorama&&t.tile===!0&&!this.controller.isTileReady()?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(noop)}requestFullscreen(){var e;if(!isMobile)return;let t=(e=this.getElement())==null?void 0:e.parentNode;t&&`requestFullscreen`in t&&typeof document<`u`&&document.fullscreenElement===null&&t.requestFullscreen()}exitFullscreen(){typeof document<`u`&&document.fullscreenElement&&`exitFullscreen`in document&&document.exitFullscreen()}throwError(e){this.hasListener(`error`)?this.emit(`error`,e):console.error(e)}bindModel(e){let t=()=>{AnimationFrameLoop.shared.add(()=>{this.emit(`model.load`,createEvent(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,createEvent(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,createEvent(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},o=t=>{this.emit(`models.tileLoad`,createEvent(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},s=t=>{this.emit(`models.tileUnload`,createEvent(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},c=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,o),e.removeEventListener(`tileUnload`,s),e.removeEventListener(`dispose`,c)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,o),e.addEventListener(`tileUnload`,s),e.addEventListener(`dispose`,c),this.emit(`model.request`,createEvent(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,o=new Fetcher({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=verifyURL(e,r);return t instanceof Error?Promise.reject(t):t})}});registerFetcher(this.fiveId,e,o)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(t,n){if(!this.renderer)throw Error(`renderer is not initialized.`);let r=Controllers[t];this.currentMode=t;let o=new r(n);for(let e of PROXY_CONTROLLER_EVENT_NAMES)o.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=Controllers[t].initAnimationEndState(n),r=n.initial.userAction;stateEqual(this.state,e)||(assignState(this.state,e),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return o.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),o.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),this.emit(`state.change`,createEvent(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!stateEqual(this.state,n)&&(assignState(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),o.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,createEvent(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),o.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),o.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),o.on(`error`,e=>this.throwError(e)),o}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:o}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:o}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let t=new three.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new three.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().inverse();return n.applyQuaternion(r),{theta:Math.atan2(n.x,-n.z),phi:-Math.asin(n.y),lookAtVector:n}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableHQ(){return this.fiveRenderer.renderMode===`point-cloud-high-quality`}set enableHQ(e){this.fiveRenderer.renderMode=e?`point-cloud-high-quality`:`default`,this.needsRender=!0}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}get enableIOSEDR(){return!1}set enableIOSEDR(e){}get enablePostProcessing(){return!0}set enablePostProcessing(e){}get modelSceneNeedsRender(){return this.modelScene.needsRender}set modelSceneNeedsRender(e){this.modelScene.needsRender=e}};Five.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:three,constructor:Five,instances:Five_Instances}});var XRButton=class{static createButton(e){let t=document.createElement(`button`);function n(){t.style.display=``,t.style.cursor=`pointer`,t.style.left=`calc(50% - 50px)`,t.style.width=`100px`,t.textContent=`ENTER VR`,t.onmouseenter=function(){t.style.opacity=`1.0`},t.onmouseleave=function(){t.style.opacity=`0.5`},t.onclick=function(){e&&e()}}function r(){t.style.display=``,t.style.cursor=`auto`,t.style.left=`calc(50% - 75px)`,t.style.width=`150px`,t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function o(){r(),t.textContent=`VR NOT SUPPORTED`}function s(e){e.style.position=`absolute`,e.style.bottom=`20px`,e.style.padding=`12px 6px`,e.style.border=`1px solid #fff`,e.style.borderRadius=`4px`,e.style.background=`rgba(0,0,0,0.1)`,e.style.color=`#fff`,e.style.font=`normal 13px sans-serif`,e.style.textAlign=`center`,e.style.opacity=`0.5`,e.style.outline=`none`,e.style.zIndex=`999`}if(`xr`in navigator)return t.id=`VRButton`,t.style.display=`none`,s(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():o()}),t;{let e=document.createElement(`a`);return window.isSecureContext===!1?(e.href=document.location.href.replace(/^http:/,`https:`),e.innerHTML=`WEBXR NEEDS HTTPS`):(e.href=`https://immersiveweb.dev/`,e.innerHTML=`WEBXR NOT AVAILABLE`),e.style.left=`calc(50% - 90px)`,e.style.width=`180px`,e.style.textDecoration=`none`,s(e),e}}};exports.AdaptiveLuminancePass=AdaptiveLuminancePass,exports.AnimationFrameLoop=AnimationFrameLoop,exports.BoundingMesh=BoundingMesh,exports.Camera=Camera,exports.CustomShader=PBMCustomShader,exports.PBMCustomShader=PBMCustomShader,exports.EffectComposer=EffectComposer,exports.EyeDomeLightingPass=EyeDomeLightingPass,exports.Fetcher=Fetcher,exports.Five=Five,exports.FivePass=FivePass,exports.FiveRenderer=FiveRenderer,exports.FullScreenQuad=FullScreenQuad,exports.Histogram=Histogram,exports.InternalWebGLRenderer=InternalWebGLRenderer,exports.Model=Model,exports.ModelScene=ModelScene,exports.Motion=Motion,exports.NetworkSubscribe=NetworkSubscribe,exports.PBMContainer=PBMContainer,exports.PBMGSObject=PBMGaussianSplattingObject,exports.PBMGroup=PBMGroup,exports.PBMMesh=PBMMesh,exports.PBMMeshMaterial=PBMMeshMaterial,exports.PBMPanoFilter=PBMPanoFilter,exports.PBMPointCloud=PBMPointCloud,exports.PBMPointCloudMaterial=PBMPointCloudMaterial,exports.PBMSkinnedMesh=PBMSkinnedMesh,exports.PBMUpdateable=PBMUpdateable,exports.PROXY_CONTROLLER_EVENT_NAMES=PROXY_CONTROLLER_EVENT_NAMES,exports.PanoCircleMesh=PanoCircleMesh,exports.PanoCircleMeshCustom=PanoCircleMeshCustom,exports.PanoCircleMeshSolid=PanoCircleMeshSolid,exports.Parameter=Parameter,exports.Scene=Scene,exports.Subscribe=Subscribe,exports.TextureLoader=TextureLoader,exports.Tile=Tile,exports.Tile3D=Tile3D,exports.Tile3DModel=Tile3D,exports.TileCache=TileCache,exports.TileNode=TileNode,exports.TileRequestScheduler=TileRequestScheduler,exports.Tileset=Tileset,exports.Trajectory=Trajectory,exports.TrajectoryNode=TrajectoryNode,exports.Work=Work,exports.WorkResolvedObserver=WorkResolvedObserver,exports.XRButton=XRButton,exports.controllersDefaultInitArgs=controllersDefaultInitArgs,exports.coordinatesToVector=coordinatesToVector,exports.createDebugBoundingMesh=createDebugBoundingMesh,exports.createWorks=createWorks,exports.defaultImageURLTransform=imageURL,exports.draco=draco,exports.getViewportScale=getViewportScale,exports.headingToLongitude=headingToLongitude,exports.imageSupport=imageSupport,exports.isBoundingVolume=isBoundingVolume,exports.isPanoId=isPanoId,exports.ktx2=ktx2,exports.loadAt3d=loadAt3d,exports.loadB3dm=loadB3dm,exports.loadDome=loadDome,exports.loadDomez=loadDomez,exports.loadFbx=loadFbx,exports.loadGltf=loadGltf,exports.loadPbm=loadPbm,exports.loadPly=loadPly,exports.loadPnts=loadPnts,exports.loadSplat=loadSplat,exports.loadSpz=loadSpz,exports.loadX3p=loadX3p,exports.longitudeToHeading=longitudeToHeading,exports.makeBoundingVolume=makeBoundingVolume,exports.panoEqual=panoEqual,exports.panoParse=panoParse,exports.panoStringify=panoStringify,exports.parseWork=parseWork,exports.vectorToCoordinates=vectorToCoordinates,exports.workToJson=workToJson});