@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/five/index.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 c.Color},opacity:{value:1},displacementScalar:{value:0}}};function Jd(e,t,n,r){let i=new Float32Array((n+1)*(r+1)*3),a=new Float32Array((n+1)*(r+1)*3),o=new Float32Array((n+1)*(r+1)*2),s=new Uint32Array(n*r*6),l=e.computeFrenetFrames(n),u=new c.Vector3,d=new c.Vector3,f=new c.Vector2,p=new c.Vector3;for(let s=0;s<=n;s++){p=e.getPointAt(s/n,p);let c=l.normals[s],m=l.binormals[s];for(let e=0;e<=r;e++){let l=s*(r+1)+e,h=e/r*Math.PI*2,g=Math.sin(h),_=-Math.cos(h);d.x=_*c.x+g*m.x,d.y=_*c.y+g*m.y,d.z=_*c.z+g*m.z,d.normalize(),d.toArray(a,l*3),u.x=p.x+t*d.x,u.y=p.y+t*d.y,u.z=p.z+t*d.z,u.toArray(i,l*3),f.x=s/n,f.y=e/r,f.toArray(o,l*2)}}for(let e=0;e<n;e++)for(let t=0;t<r;t++){let n=(e*r+t)*6,i=(r+1)*e+t,a=(r+1)*(e+1)+t,o=(r+1)*(e+1)+(t+1),c=(r+1)*e+(t+1);s[n]=i,s[n+1]=a,s[n+2]=c,s[n+3]=a,s[n+4]=o,s[n+5]=c}let m=new c.BufferGeometry;return m.setIndex(new c.BufferAttribute(s,1)),m.setAttribute(`position`,new c.BufferAttribute(i,3)),m.setAttribute(`normal`,new c.BufferAttribute(a,3)),m.setAttribute(`uv`,new c.BufferAttribute(o,2)),m}function Yd(e,t){let n=new c.Color(0).convertSRGBToLinear(),r=new c.Color(52949).convertSRGBToLinear(),i=new c.Color(3370495).convertSRGBToLinear(),a=new c.Color(16777215).convertSRGBToLinear(),o=0,s=new c.CurvePath,l=e.length;for(let t=3;t<l;t+=3){let n=new c.Vector3().fromArray(e,t-3),r=new c.Vector3().fromArray(e,t);o+=n.distanceTo(r);let i=new c.LineCurve3(n,r);s.add(i)}let u=Jd(s,.03,Math.ceil(o*100),6);u.clearGroups(),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,0),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,1),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,2);let d=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.BackSide});d.uniforms.totalLength.value=o,d.uniforms.diffuse.value=n,d.uniforms.diffuse2.value=n,d.uniforms.opacity.value=.5,d.transparent=!0;let f=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.BackSide});f.uniforms.totalLength.value=o,f.uniforms.displacementScalar.value=-.01,f.uniforms.diffuse.value=r,f.uniforms.diffuse2.value=i;let p=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.DoubleSide});p.uniforms.totalLength.value=o,p.uniforms.displacementScalar.value=-.026,p.uniforms.dashSize.value=new c.Vector2(.06,.09),p.uniforms.diffuse.value=a,p.uniforms.diffuse2.value=a;let m=new c.Mesh(u,[d,f,p]),h=new c.SphereBufferGeometry(.08,24,24);h.clearGroups(),h.addGroup(0,u.index?u.index.count:u.attributes.position.count,0),h.addGroup(0,u.index?u.index.count:u.attributes.position.count,1);let g=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.BackSide});g.uniforms.diffuse.value=n,g.uniforms.opacity.value=.5,g.transparent=!0;let _=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.FrontSide});_.uniforms.displacementScalar.value=-.01,_.uniforms.diffuse.value=r;let v=new c.Mesh(h,[g,_]);v.position.fromArray(e,0),m.add(v);let y=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.FrontSide});y.uniforms.displacementScalar.value=-.01,y.uniforms.diffuse.value=i;let b=new c.Mesh(h,[g,y]);return b.position.fromArray(e,e.length-3),m.add(b),{scene:m,dispose:()=>{u.dispose(),d.dispose(),f.dispose(),p.dispose(),h.dispose(),g.dispose(),_.dispose(),y.dispose()}}}function Xd(e,t){let n=e.name,r=Xr(Tr(e.content.uri,t.search),{key:`model.0`});return e.content.loadState=`LOADING`,e.content.loadStateUpdateTime=H(),Cs(r,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:t.fetcher}).then(t=>{var i,a,o,s;let c=(a=(i=t.scene.attributes)==null?void 0:i.time.array)==null?[]:a,l=(s=(o=t.scene.attributes)==null?void 0:o.position.array)==null?[]:s,u=t.byteLength,d=t.memoryUsage,f=Yd(l,c);f.scene.applyMatrix4(e.transform),f.scene.updateWorldMatrix(!1,!0),f.scene.matrixAutoUpdate=!1;let p=new od(n,f.scene);return e.content.data={uri:r,byteLength:u,memoryUsage:d,positionArray:l,timeArray:c,object:p},e.content.byteLength=u,e.content.memoryUsage=d,e.content.loadState=`READY`,e.content.loadStateUpdateTime=H(),e}).catch(t=>(e.content.data=void 0,e.content.loadState=`FAILED`,e.content.loadStateUpdateTime=H(),t instanceof or&&t.httpStatus===0||t instanceof sr||t instanceof ar?e.content.loadfailRetryDelay=U(e.content.loadfailRetryDelay+Gd,Gd,Wd):e.content.loadfailRetryDelay=1/0,Promise.reject(t)))}function Zd(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=H(),e.content.byteLength=0,e.content.memoryUsage=0)}var Qd=new c.Vector3,$d=new c.Matrix3,ef=new c.Matrix4,tf=6378137,nf=298.257223563;function rf(e){let t=tf-tf/nf,n=(tf*tf-t*t)/(tf*tf),r=Math.sqrt(e.x*e.x+e.y*e.y),i=0,a=Math.atan2(e.z,r),o=0;for(;i++<1e3;){let t=Math.sin(a),i=tf/Math.sqrt(1-n*t*t);o=r/Math.cos(a)-i;let s=Math.atan2(e.z/(i*(1-n)+o),r/(i+o));if(isNaN(s)||Math.abs(s-a)<1e-12)break;a=s}return e.set(a,Math.atan2(e.y,e.x),o)}function af(e){let{x:t,y:n,z:r}=e,i=tf-tf/nf,a=(tf*tf-i*i)/(tf*tf),o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=tf/Math.sqrt(1-a*o*o),d=(u+r)*s*l,f=(u+r)*s*c,p=(i*i/(tf*tf)*u+r)*o;return e.set(d,f,p)}function of(e,t){let{x:n,y:r,z:i}=rf(Qd.copy(e)),a=Math.sin(n),o=Math.sin(r),s=Math.cos(n),c=Math.cos(r);t.fromArray([-o,-a*c,s*c,0,+c,-a*o,s*o,0,0,s,a,0,0,0,0,1]);let l=$d.setFromMatrix4(t),u=Qd.copy(e).applyMatrix3(l).multiplyScalar(-1);t.setPosition(u);let d=ef.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,i,1]);return t.premultiply(d),t}var sf=new c.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),cf=new c.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),lf=new c.Matrix4().copy(sf),uf=new c.Matrix4().copy(cf);function df(e,t={}){var n,r,i;let a,o,s;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){s=4,t.powerPreference===`high`&&(s=2),a=s/1.6;let c=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((i=e.tileset.rootMeta.taskParameters)==null?void 0:i.homo_point_density);isFinite(t)&&!isNaN(t)&&(c=t)}c<=0&&(c=.02),o=c*1.4}else s=5,t.powerPreference===`high`&&(s=4),a=0,o=.03;else s=6,a=0,o=.03,e.name===`aerophoto`?(s=12,t.powerPreference===`high`&&(s=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(s=5,t.powerPreference===`high`&&(s=4));return{pointScale:o,pointMinPixel:a,maxScreenSpaceError:s}}var ff=new c.Vector3,pf=new Ol,mf=new Dl,hf=new WeakMap,gf=new WeakMap,_f=new WeakMap,vf={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},yf=(()=>{let e=new c.MeshBasicMaterial;return e.side=c.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=vf.TILE_MASK,e.stencilFunc=c.AlwaysStencilFunc,e.stencilFuncMask=vf.TILE_MASK,e.stencilZPass=c.ReplaceStencilOp,e.stencilWriteMask=vf.TILE_MASK,e})(),bf=(()=>{let e=new c.MeshBasicMaterial;return e.visible=!1,e})(),xf=new c.BufferGeometry,Sf=new c.MeshBasicMaterial;function Cf(e){let t;t=e instanceof c.Mesh?new c.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?bf:yf):e.material&&e.material.transparent?bf:yf):e instanceof c.Group?new c.Group:new c.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(Cf(n));return t}var wf=class extends c.Object3D{constructor(e,t){var n,r;super(),this.parameter=new G,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 c.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new c.Mesh(xf,Sf),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new vd(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=G.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 df(this,e)}loadContent(e){return Hd(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)Ud(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 Ud(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 Xd(e,{fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(e=>{this.disposed&&Zd(e)})}unloadTrajectory(e){return Zd(e),Promise.resolve()}intersectRaycaster(e,t){var n,r;let i=t==null?[]:t,a=[this.tileset.root],o=this.tileset.transform,s=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,c=e.sortByDistance;e.sortByDistance=!1;let l,u=1/0;for(;l=a.pop();){let t;if(l.boundingVolume){let n;n=l.boundingVolume instanceof Dl?mf.copy(l.boundingVolume):l.boundingVolume instanceof Ol?pf.copy(l.boundingVolume):l.boundingVolume.clone(),n.applyMatrix4(o),t=n.intersectRay(e.ray,s,u)}else t=!0;if(t){for(let e=0,t=l.children.length;e<t;e++)a.push(l.children[e]);if(l.selected&&l.content&&l.content.data&&l.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:l}),t?t.call(e,n):!0},l.content.data.object.intersectRaycaster(e,i),e.hitFilter=t,e.firstHitOnly){let e=i[0];e&&u>e.distance&&(u=e.distance)}}}}return e.sortByDistance=c,Jl(i,e.sortByDistance,e.firstHitOnly),i}update(e,t,n,r){var i,a,o,s,l,u,d;this.renderer=e,this.frameNumber++;let f=!1,p=G.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);hf.get(this)!==p.versionNumber&&(hf.set(this,p.versionNumber),f=!0);let m=(s=this.visible&&((i=this.parent)==null?void 0:i.visible)&&((o=(a=this.parent)==null?void 0:a.parent)==null?void 0:o.visible))==null?!1:s,h=p.maxLevelOfDetail;h=Math.max(h,0);let g=Math.min(p.minLevelOfDetail,h);(!m||!this.loaded||!n.loaded)&&(h=Math.max(g,0));let _=p.maxMemoryUsage;m||(_=Math.min(0,_));let v=p.minGeometricError,y=p.maxRequests,b=p.memoryAdjustedScreenSpaceError;m||(b=!1);let x=t.controllerMode;(x===`Panorama`||x===`VRPanorama`||x===`XRPanorama`)&&(p.modelAlpha<.1&&(v=p.panoramaMinGeometricError,b=!1),p.progress>=.01&&p.progress<=.99&&(y=0));let S=p.maxGeometricError;S=Math.max(v,S);let C={time:t.time,camera:{type:t.type,position:new c.Vector3().copy(t.position),direction:t.getDirection(new c.Vector3),up:new c.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:m&&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 El().setFromCamera(t),minLevelOfDetail:g,maxLevelOfDetail:h,minGeometricError:v,maxGeometricError:S,skipLevelOfDetail:p.skipLevelOfDetail,mostDetail:p.mostDetail,loadSiblings:p.loadSiblings,cameraCulling:p.cameraCulling,maxMemoryUsage:_,maxRequests:y,requestOrder:p.requestOrder,maxScreenSpaceError:p.maxScreenSpaceError,memoryAdjustedScreenSpaceError:b},w=p.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},C),{camera:{type:t.type,position:new c.Vector3().copy(e.position),direction:e.getWorldDirection(new c.Vector3),up:new c.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new El().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),f=!0);let T=!this.autoRefine;if(T===!1&&p.progress>=.01&&p.progress<=.99){let e=new c.Vector3;p.pano0&&e.setFromMatrixPosition(p.pano0.matrix);let t=e.clone();p.pano1&&t.setFromMatrixPosition(p.pano1.matrix),e.distanceTo(t)<10&&(T=!0)}if(T||this.tileset.update(C,w),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),p.minLevelOfDetail>=0)){if(C.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]);C.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 E=[];for(let r of this.tileset.selectedTiles){let i=(u=(l=r.content)==null?void 0:l.data)==null?void 0:u.object;if(!i)continue;let a=i.update(e,t,n,this,r,p);if(E.push(r.id),a&&(f=!0),this.tileset.hasMixedContent&&C.skipLevelOfDetail){if(!r.state.finalResolution){let e=Cf(i);e.name=`skipBackface:`+i.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=vf.TILE_MASK|e<<vf.SKIP_LOD_BIT_SHIFT,n=c.GreaterEqualStencilFunc,a=vf.SKIP_LOD_MASK,o=c.ReplaceStencilOp,s=vf.TILE_MASK|vf.SKIP_LOD_MASK;for(let e of i.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=a,e.stencilZPass=o,e.stencilWriteMask=s}else for(let e of i.materials)e.stencilWrite=!1,e.stencilRef=vf.TILE_MASK,e.stencilFunc=c.AlwaysStencilFunc,e.stencilFuncMask=vf.TILE_MASK,e.stencilZPass=c.ReplaceStencilOp,e.stencilWriteMask=vf.TILE_MASK;this.tileObjects.push(i)}let D=E.toString();if(gf.get(this)!==D&&(gf.set(this,D),f=!0),C.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]);C.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let O=[];for(let r of this.tileset.selectedTrajectories){let i=(d=r.content.data)==null?void 0:d.object;if(!i)continue;let a=i.update(e,t,n,this,r,p);O.push(r.id),a&&(f=!0),this.renderObjects.push(i)}let k=O.toString();if(_f.get(this)!==k&&(_f.set(this,k),f=!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 c.Mesh||e instanceof c.Line||e instanceof c.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return f}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(uf)}enuToLocal(e){return e.applyMatrix4(lf)}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 rf(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(af(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(){ff.setScalar(0);let{x:e,y:t}=this.localToLla(ff);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new c.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(lf),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new c.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return ff.copy(e),this.worldToLla(ff),{latitude:ff.x,longitude:ff.y,altitude:ff.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},Tf={};function Ef(e,t){let n=Tf[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function Df(e,t,n){let r=Tf[e];r||(r=Tf[e]=new WeakMap),r.has(t)||r.set(t,n)}var Of=new c.Matrix4,kf=new c.Vector3,Af=new c.Matrix4;function jf(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:of(t,n);break;default:n.identity();break}return n}function Mf(e){var t;let[n,r]=e.tilesetUrl.split(`#`),i=(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,a=bd(JSON.parse(t.body),e.tilesetUrl),{root:o,rootMeta:s={}}=a,l=e.upAxis;s.upAxis&&s.upAxis!==l&&(l=s.upAxis),`lodVersion`in a&&(l=`-Y`,`floorInfo`in a&&(a.properties=a.properties||{},a.properties.floorInfo=a.floorInfo.map(e=>({ground:-e.ground,height:e.height})),a.floorInfo=void 0),a.asset.tilesetVersion=String(a.lodVersion),a.lodVersion=void 0);let u=l,d=new c.Matrix4;u===`Y`?(u=`Z`,d.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):u===`-Y`&&(u=`Z`,d.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let f=o.boundingVolume?jl(o.boundingVolume):void 0;f&&o.transform&&f.applyMatrix4(Af.fromArray(o.transform));let p=null,m=new c.Matrix4,h=new c.Matrix4;return s.coordinate?(p=s.coordinate.ground_height,m.fromArray(s.coordinate.pose_ecef_to_enu),h.fromArray(s.coordinate.pose_enu_to_ecef)):(f?f.getCenter(kf):kf.setScalar(0),kf.applyMatrix4(d),jf(u,kf,m),h.getInverse(m)),a.root={refine:(n=o.refine)==null?`REPLACE`:n,geometricError:o.geometricError,transform:Af.copy(d).premultiply(u===`Z`?Of:m).premultiply(lf).toArray(),boundingVolume:f?f.toJson():void 0,children:[o]},new wf(a,{name:e.name,type:e.type,upAxis:l,light:e.light,fetcher:e.fetcher,search:i,groundHeight:p,coordinateSystem:{enuToEcefMatrix:h,ecefToEnuMatrix:m},error:r})})}function Nf(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 i=!1;for(let e of r)if(e.type===`mesh`){i=!0;break}if(i===!1){let i=Dr(e.file)||`.at3d`,a=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:{[i.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([a],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let i=r.map(e=>Mf(e).then(e=>e));return Promise.all(i)}function Pf(e=1,t=1,n=1){let r=e/2,i=t/2,a=n/2,o=new Float32Array([-r,+i,+a,+r,+i,+a,+r,+i,-a,-r,+i,-a,-r,-i,+a,+r,-i,+a,+r,-i,-a,-r,-i,-a]),s=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]),l=new c.BufferGeometry;return l.setAttribute(`position`,new c.BufferAttribute(o,3)),l.setIndex(new c.BufferAttribute(s,1)),l.addGroup(0,l.index.count,0),l.computeBoundingBox(),l.computeBoundingSphere(),l}function Ff(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=new c.BufferGeometry,l=0,u=0;u<e.length;++u){var d=e[u];if(n!==(d.index!==null))return null;for(var f in d.attributes){if(!r.has(f))return null;a[f]===void 0&&(a[f]=[]),a[f].push(d.attributes[f])}for(var f in d.morphAttributes){if(!i.has(f))return null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(s.userData.mergedUserData=s.userData.mergedUserData||[],s.userData.mergedUserData.push(d.userData),t){var p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return null;s.addGroup(l,p,u),l+=p}}if(n){for(var m=0,h=[],u=0;u<e.length;++u){for(var g=e[u].index,_=0;_<g.count;++_)h.push(g.getX(_)+m);m+=e[u].attributes.position.count}s.setIndex(h)}for(var f in a){var v=If(a[f]);if(!v)return null;s.setAttribute(f,v)}for(var f in o){var y=o[f][0].length;if(y===0)break;s.morphAttributes=s.morphAttributes||{},s.morphAttributes[f]=[];for(var u=0;u<y;++u){for(var b=[],_=0;_<o[f].length;++_)b.push(o[f][_][u]);var x=If(b);if(!x)return null;s.morphAttributes[f].push(x)}}return s}function If(e){for(var t,n,r,i=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute||(t===void 0&&(t=o.array.constructor),t!==o.array.constructor)||(n===void 0&&(n=o.itemSize),n!==o.itemSize)||(r===void 0&&(r=o.normalized),r!==o.normalized))return null;i+=o.array.length}for(var s=new t(i),l=0,a=0;a<e.length;++a)s.set(e[a].array,l),l+=e[a].array.length;return new c.BufferAttribute(s,n,r)}function Lf(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),l={},u={},d=[],f=[`getX`,`getY`,`getZ`,`getW`],p=0,m=s.length;p<m;p++){var h=s[p];l[h]=[];var g=e.morphAttributes[h];g&&(u[h]=Array(g.length).fill().map(()=>[]))}for(var _=Math.log10(1/t),v=Math.pow(10,_),p=0;p<a;p++){for(var y=r?r.getX(p):p,b=``,x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),C=S.itemSize,w=0;w<C;w++)b+=`${~~(S[f[w]](y)*v)},`;if(b in n)d.push(n[b]);else{for(var x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),g=e.morphAttributes[h],C=S.itemSize,T=l[h],E=u[h],w=0;w<C;w++){var D=f[w];if(T.push(S[D](y)),g)for(var O=0,k=g.length;O<k;O++)E[O].push(g[O][D](y))}n[b]=o,d.push(o),o++}}let A=e.clone();for(var p=0,m=s.length;p<m;p++){var h=s[p],j=e.getAttribute(h),M=new j.array.constructor(l[h]),S=new c.BufferAttribute(M,j.itemSize,j.normalized);if(A.setAttribute(h,S),h in u)for(var x=0;x<u[h].length;x++){var N=e.morphAttributes[h][x],M=new N.array.constructor(u[h][x]),ee=new c.BufferAttribute(M,N.itemSize,N.normalized);A.morphAttributes[h][x]=ee}}return A.setIndex(d),A}var Rf=new c.Sphere,zf=new c.Matrix4,Bf=new c.Matrix4;function Vf(e,t,n=30/180*Math.PI){let r=Math.cos(n),i=[];for(let n of e.children)n instanceof wf&&n.tileset.selectedTiles.forEach(e=>{var n,a,o;let s=(a=(n=e.content)==null?void 0:n.data)==null?void 0:a.object;if(s&&s.visible){let e=[];if(s.traverseVisible(n=>{if(n instanceof c.Mesh){let r=ju(n);if(r){zf.copy(n.matrixWorld),Bf.getInverse(zf),Rf.copy(t).applyMatrix4(Bf);let i=r.trianglesInSphere(Rf.center,Rf.radius),a=new c.BufferGeometry;a.setAttribute(`position`,new c.BufferAttribute(i,3)),a.applyMatrix4(n.matrixWorld),a=Lf(a,.01),e.push(a)}}}),e.length===0)return;let n=[`a`,`b`,`c`],a=Ff(e,!1),l=a.getAttribute(`position`).array,u=((o=a.getIndex())==null?void 0:o.array)||[],d=[],f=[];for(let e=0,t=l.length;e<t;e+=3){let t=new c.Vector3(l[e],l[e+1],l[e+2]);d.push(t)}for(let e=0,t=u.length;e<t;e+=3){let t=u[e],n=u[e+1],r=u[e+2],i=new c.Vector3().crossVectors(d[n].clone().sub(d[t]),d[r].clone().sub(d[t])).normalize();f.push({a:t,b:n,c:r,normal:i})}let p={};for(let e=0,t=f.length;e<t;e++){let t=f[e];for(let r=0;r<3;r++){let i=t[n[r]],a=t[n[(r+1)%3]],o=[Math.min(i,a),Math.max(i,a)],s=o[0]+`-`+o[1];p[s]===void 0?p[s]={index1:o[0],index2:o[1],face1:e}:p[s].face2=e}}for(let e in p){let t=p[e];if(t.face2===void 0||f[t.face1].normal.dot(f[t.face2].normal)<=r){let e=d[t.index1],n=d[t.index2];i.push(new c.Line3(e,n))}}d.length=0,f.length=0}});return i}var Hf=new c.Box3,Uf=new c.Box3,Wf=new c.Box3,Gf=class extends c.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new G,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new c.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let i=0;for(let e of t.observers)i=Math.max(i,e.floorIndex);if(this.floorLength=i+1,t.model){this.metaPending=!0;let e=Nf(t.model,{fetcher:Ef(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),i=e=>this.dispatchEvent({type:`error`,error:e}),a=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),o=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,s=null;for(let t of e){if(t.visible=!1,t.onError=i,t.onTileLoad=a,t.onTileUnload=o,t.error){i(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):s===null&&(s=t)}let c=(t=n==null?r:n)==null?s:t;if(c&&(c.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 Vf(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,Jl(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let i=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 i of this.children)i.autoRefine=this.autoRefine,i.update(e,t,n,this)&&(r=!0),i.refined===!1&&(this.refined=!1),i.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=i.refineProgress[0],this.refineProgress[1]+=i.refineProgress[1];Hf.makeEmpty(),Wf.copy(this.work.observerBox),Wf.isEmpty()||(Wf.max.x+=1,Wf.max.z+=1,Wf.max.y+=1,--Wf.min.x,--Wf.min.z,Hf.union(Wf));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(Uf.copy(e.boundingBox),Hf.union(Uf));return Hf.applyMatrix4(this.matrix),Hf.equals(this.boundingBox)||(this.boundingBox.copy(Hf),this.parameter.set(`boundingBox`,Hf.clone())),i===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(uf)}enuToLocal(e){return e.applyMatrix4(lf)}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 G&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof G&&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 G&&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 G&&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 G&&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()}},Kf=Pf(1,1,1);Kf.applyMatrix4(new c.Matrix4().makeScale(-1,1,1));var qf=new WeakMap,Jf=new c.Vector3(1,1,1),Yf=new c.Box3,Xf=new c.Vector3,Zf=new c.Box3,Qf=new c.Vector3,$f=new c.Vector3,ep=class extends bn{constructor(e={}){var t;let n=new yn(`none`);n.flatShading=!0,n.depthWrite=!1,n.transparent=!1,n.blending=c.CustomBlending,n.blendSrc=c.SrcAlphaFactor,n.blendDst=c.OneMinusSrcAlphaFactor,n.blendSrcAlpha=c.OneFactor,n.blendDstAlpha=c.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(Kf,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999,this.currentResolvedParameterValue=G.resolveValueTo({})}update(e,t,n){var r,i;let a=!1,o=G.resolveValueTo(this.currentResolvedParameterValue,n.parameter);Yf.copy(o.boundingBox),Yf.getSize(Xf);let s=Math.min(Xf.x/2,500);Yf.min.x-=s,Yf.max.x+=s;let c=Math.min(Xf.y/2,500);Yf.min.z-=c,Yf.max.z+=c;let l=Xf.length()/2;if(Yf.max.y=Math.max(Yf.max.y,l),Yf.union(Zf.setFromCenterAndSize(t.position,Jf)),Yf.expandByScalar(1),Yf.getCenter(Qf),Yf.getSize($f),Qf.equals(this.position)||(this.position.copy(Qf),a=!0),$f.equals(this.scale)||(this.scale.copy($f),a=!0),qf.get(this)!==o.versionNumber){qf.set(this,o.versionNumber),a=!0;let e=this.material;for(let t of e)t.customShaders=o.customShaders,t.pano0=o.pano0,t.pano1=o.pano1,t.panoFilter=(i=(r=o.panoFilter)==null?void 0:r.toValue())==null?null:i,t.refinedScreen=o.refinedScreen,t.modelAlpha=o.modelAlpha,t.progress=o.progress,t.transition=o.transition,t.opacity=o.opacity,t.floorStyle=o.floorStyle,t.constantColor=o.constantColor,t.shownFloorIndex=o.shownFloorIndex,t.clippers=o.clippers,t.brightness=o.brightness,t.useHQWeight=o.useHQWeight,t.useHQDepth=o.useHQDepth,t.colorSaturation=o.colorSaturation,t.colorBrightness=o.colorBrightness,t.gradientTexture=o.gradientTexture,t.transparent=!1,t.modelBoundingMax.copy(o.boundingBox.max),t.modelBoundingMin.copy(o.boundingBox.min),o.useAddBlend&&(t.opacity=0),t.opacity===0&&(t.visible=!1)}return a}dispose(){for(let e of this.material)e.dispose(),e.pano0=null,e.pano1=null}},tp=new c.Box3,np=class extends c.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new c.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new G,this.fiveId=e.fiveId,this.boundingMesh=new ep({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;V(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),V(t,`bounding`,{get(){return n.boundingBox}}),V(t,`loaded`,{get(){return n.loaded}}),V(t,`refined`,{get(){return n.refined}}),V(t,`refineProgress`,{get(){return n.refineProgress}}),V(t,`cacheCameras`,{get(){return n.parameter.resolveValue(`cacheCameras`)},set(e){n.parameter.set(`cacheCameras`,e)}}),V(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),V(t,`setMaterial`,{value:e=>n.setMaterial(e)}),V(t,`getMaterial`,{value:()=>n.getMaterial()}),V(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 Gf(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=jl(t.viewerRequestVolume)),e.parameter.set(yr(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=jl(r.viewerRequestVolume)),e.parameter.set(yr(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&&!Ul(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,Jl(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;tp.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 i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}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)&&!Ul(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 i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Gf&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),tp.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&&tp.union(t.boundingBox)}return tp.equals(this.boundingBox)||(this.boundingBox.copy(tp),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 Gf&&this.remove(t)}let e=Gl(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 rp(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 ip(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 ap(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 op(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 sp(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:rp(e.initial),model:ip(e.model),observers:e.observers.map(e=>ap(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>op(e))}}}function cp(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t),s=i*a,l=r,u=i*o,d=Math.abs(s),f=Math.abs(l),p=Math.abs(u),m,h;if(d>=f&&d>=p){let e=1/d;s>0?(m=`right`,h=new c.Vector2(-u*e,l*e)):(m=`left`,h=new c.Vector2(u*e,l*e))}else if(f>=d&&f>=p){let e=1/f;l>0?(m=`up`,h=new c.Vector2(s*e,-u*e)):(m=`down`,h=new c.Vector2(s*e,u*e))}else{let e=1/p;u>0?(m=`front`,h=new c.Vector2(s*e,l*e)):(m=`back`,h=new c.Vector2(-s*e,l*e))}return h.x=(h.x+1)/2,h.y=1-(h.y+1)/2,[m,h]}function lp(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,i=0,a=0,o=0;switch(e){case`right`:i=1,a=r,o=-n;break;case`left`:i=-1,a=r,o=n;break;case`up`:i=n,a=1,o=-r;break;case`down`:i=n,a=-1,o=r;break;case`front`:i=n,a=r,o=1;break;case`back`:i=-n,a=r,o=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let s=Math.sqrt(i*i+a*a+o*o);if(s===0)return new c.Vector2(.5,.5);i/=s,a/=s,o/=s;let l=Math.atan2(i,o),u=Math.asin(Math.max(-1,Math.min(1,a))),d=(l+Math.PI)/(2*Math.PI),f=(Math.PI/2-u)/Math.PI;return d%=1,d=d<0?d+1:d,f=Math.max(0,Math.min(1,f)),new c.Vector2(d,f)}var up={vectorToEquirectangularUv(e,t=`top-left`){let n=new c.Quaternion().setFromRotationMatrix(this.work.transform).inverse(),r=new c.Quaternion().copy(this.quaternion).inverse(),i=new c.Quaternion(0,1,0,0).inverse(),a=new c.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(i),o=Math.atan2(a.x,-a.z),s=Math.asin(-a.y);if(t===`top-left`)return new c.Vector2(o/(Math.PI*2)+.5,s/Math.PI+.5);if(t===`bottom-left`)return new c.Vector2(o/(Math.PI*2)+.5,.5-s/Math.PI);throw Error(`Invalid uvOrigin ${t}`)},vectorToCubemapUv(e,t=`top-left`){let n=cp(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 c.Quaternion().setFromRotationMatrix(this.work.transform),i=new c.Quaternion().copy(this.quaternion),a=new c.Quaternion(0,1,0,0),o=Math.PI*2*(e.x+.5),s=Math.PI*(e.y-.5),l=Math.abs(Math.cos(s)),u=Math.sin(o)*l,d=-Math.sin(s)*n,f=-Math.cos(o)*l;return new c.Vector3(u,d,f).applyQuaternion(a).applyQuaternion(i).applyQuaternion(r)},cubemapUvToVector(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new c.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let i=lp(e,r);return this.equirectangularUvToVector(i)},getWorldPosition(){return new c.Vector3().copy(this.position).applyMatrix4(this.work.transform)},getWorldStandingPosition(){return new c.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}};function dp(e){return typeof e==`number`}function fp(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:fp(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:fp(r)}return t}}function pp(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function mp(e,t){let n=pp(e),r=pp(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return fp(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=mp(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=mp(e[n],t[n]);return e}function hp(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+=hp(e[r],!1)+`,`;return n>-1&&(t+=hp(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return hp(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=hp(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}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 gp(e){return hp(e,!1)}function _p(e){return`hash::${_t(gp(e))}`}var vp=/^(.*)\[(\d+)\]$/;function Z(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function yp(e){let t=e.match(vp);if(t){let[e,n,r]=t,i=Math.floor(Number(r));if(!isNaN(i)&&isFinite(i))return{workCode:n,panoIndex:i}}throw Error(`Invalid PanoId`)}function bp(e,t){return Z(e)===Z(t)}function xp(e){return typeof e==`string`&&vp.test(e)}var Sp=`\\{([^\\}]+)\\}`;function Cp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function wp(e){return RegExp(`^`+e.map(e=>Cp(e)).join(`(.+)`)+`$`)}var Tp=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(Sp,`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?wp(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],i=n[e+1];if(r[t]!==i){if(r[t]!==void 0)return null;r[t]=i}}return r}};function Ep(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])&&Ep(e[r])}),e}var Dp=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,Op=Ep(JSON.parse(function(...e){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`))),kp=/^([^.]+)(\.([^.]+))*$/,Ap=typeof location<`u`?location.hostname:`localhost`;function jp(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function Mp(e,t){if(!kp.test(e)||!kp.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 Np(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return Ap;let t=e.match(Dp);return t?t[2]:Ap}var Pp=()=>Error(`Invalid input.`),Fp=()=>Error(`Invalid certificate.`),Ip=()=>Error(`Invalid signature.`),Lp=e=>Error(`Date(${e.toString()}) expired.`),Rp=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function zp(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Bp(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+=Bp(e[r],!1)+`,`;return n>-1&&(t+=Bp(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return Bp(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=Bp(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function Vp(e){return String(Bp(e,!1))}function Hp(e){var t,n,r;let i={};try{i=typeof e==`string`?JSON.parse(e):e}catch(e){return Pp()}if(typeof i!=`object`)return Pp();let a=Ap,o=Date.now(),s=new Date(typeof i.expire_at==`string`&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at),c=Array.isArray(i.allow_hosts)?i.allow_hosts:[];if(a.length===0||jp(a)||Op.filter(e=>Mp(e,a)).length>0){let e=String((t=i.certificate)==null?``:t);if(e)try{let t=new z;return t.readCertPEM(e),Ep({issuer:t.getSubjectString(),expire:s,allowHosts:c})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return Ep({issuer:`none`,expire:s,allowHosts:c})}let l=String((n=i.certificate)==null?``:n);if(!l)return Fp();let u=new z;u.readCertPEM(l);let d=String((r=i._signature)==null?``:r);return!d||Ct(Vp(zp(i,[`_signature`])),d,u)===!1?Ip():o<s.getTime()?Op.concat(c).filter(e=>Mp(e,a)).length===0?Rp(a):Ep({issuer:u.getSubjectString(),expire:s,allowHosts:c}):Lp(s)}function Up(e,t){let n=Np(e);return Ap.length!==0&&!jp(Ap)&&Op.filter(e=>Mp(e,Ap)).length===0&&!jp(n)&&Op.concat(t).filter(e=>Mp(e,n)).length===0?Rp(n):e}var Wp=new Set,Gp=new c.Vector3(1,1,1),Kp=[`right`,`left`,`up`,`down`,`front`,`back`];function qp(e,t){if(!Sr(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 Jp(e,t,n){return!Sr(e)&&typeof t==`string`&&t.length>0&&(e=wr(t,String(n),e)),e}function Yp(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function Xp(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 Zp(e,t){var n,r,i,a,o,s,l,u,d,f,p,m,h,g,_,v,y,b,x;let S=[],C=null;for(let t of[].concat(e))if(`getURL`in t)C={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},S.push(sp(t));else{let e=typeof t==`string`?JSON.parse(t):fp(t),n=Hp(e);if(n instanceof Error)return n;C===null&&(C=n),S.push(e)}if(C===null)return Error(`Empty`);V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:C.issuer}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.expire)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.allowHosts)});let w=S.reduce((e,t)=>mp(e,t));V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=w.name)==null?`Unknown`:n)}),V(t,`workCode`,{enumerable:!0,writable:!0,value:String(w.resource_code||w.basic_code||w.vr_code||w.code||w.project_id||w.work_code||w.workCode||rn())}),V(t,`projectId`,{enumerable:!0,writable:!0,value:w.project_id}),V(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=w.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let T;typeof w.model==`object`&&(T={},V(T,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(T,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.file_url;if(e)return qp(e,t.baseURL)})()}),V(T,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.material_base_url;return e&&(e=qp(e,t.baseURL)),e})()}),V(T,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(w.model.material_textures)&&(e=w.model.material_textures.slice(),Object.freeze(e)),e})()}),V(T,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:w.model.up_axis}),V(T,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:fp(w.model.coordinate)}),V(T,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let i=[];if(Array.isArray(w.model.layers)){for(let a of w.model.layers)if(a&&a.tileset_url){let o={};V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=a.name)==null?``:e}),V(o,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=a.type)==null?`mesh`:n}),V(o,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=a.up_axis)==null?`Z`:r}),V(o,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:qp(a.tileset_url,t.baseURL)}),i.push(o)}}if(typeof w.model.tiles==`object`){let e=w.model.tiles;if(e&&e.tileset_url){let n={};V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),V(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),V(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),V(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:qp(e.tileset_url,t.baseURL)}),i.push(n)}}return Object.freeze(i)})()})),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:T});let E=[];if(Array.isArray(w.observers)&&w.panorama&&Array.isArray(w.panorama.list||w.panorama.info)){let e=w.observers,n=(r=w.panorama.list||w.panorama.info)==null?[]:r,S=(u=(s=(a=(i=w.panorama)==null?void 0:i.pano_high_cube_base_url)==null?(o=w.panorama)==null?void 0:o.pano_cube_base_url:a)==null?(l=w.panorama)==null?void 0:l.base_url:s)==null?``:u,C=Math.min(e.length,n.length),T={};for(let e of Object.keys((d=w.panorama.pattern)==null?{}:d)){let t=e,n=w.panorama.pattern[t];if(typeof n==`string`){let e=new Tp(n);T[t]=t=>e.stringify(t)}else T[t]=()=>n}let D=(e,t)=>{var n;let r=T[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<C;r++){let i=e[r],a=n[r],o=Object.create(up);V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),V(o,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),V(o,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Z({workCode:t.workCode,panoIndex:r})}),V(o,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(f=i.floor_index)==null?i.floor:f}),V(o,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(m=(p=i.derived_id)==null?D(a,`derived_id`):p)==null?0:m}),V(o,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(g=(h=i.derived_id_str)==null?D(a,`derived_id_str`):h)==null?String(o.derivedId):g}),V(o,`active`,{enumerable:!0,configurable:!1,writable:!1,value:i.active!==!1&&D(a,`active`)!==!1}),V(o,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(v=(_=i.loadable)==null?D(a,`loadable`):_)==null?!1:v}),V(o,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Vector3().fromArray((y=i.position)==null?[0,0,0]:y))}),V(o,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Vector3().fromArray((x=(b=i.standing_position)==null?i.standingPosition:b)==null?[0,0,0]:x))}),V(o,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Quaternion().fromArray(i.quaternion?[i.quaternion.x,i.quaternion.y,i.quaternion.z,i.quaternion.w]:[0,0,0,1]))}),V(o,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Matrix4().compose(o.position,o.quaternion,Gp))}),V(o,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(Wp.clear(),i.accessible_nodes&&Array.isArray(i.accessible_nodes))for(let e of i.accessible_nodes)e>=C||e===r||Wp.add(e);else if(i.accessibleNodes&&Array.isArray(i.accessibleNodes))for(let e of i.accessibleNodes)e>=C||e===r||Wp.add(e);else if(i.visible_nodes&&Array.isArray(i.visible_nodes))for(let e of i.visible_nodes)e>=C||e===r||Wp.add(e);else if(i.visibleNodes&&Array.isArray(i.visibleNodes))for(let e of i.visibleNodes)e>=C||e===r||Wp.add(e);if(Wp.size===0)for(let e=0;e<C;e++)e!==r&&Wp.add(e);let e=Array.from(Wp);return Wp.clear(),Object.freeze(e)})()}),V(o,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:o.accessibleNodes}),V(o,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of Kp)V(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return qp(Jp((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});return V(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=$r(e[Kp[0]]),n=D(a,`size_list`),r=D(a,`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([])})()}),V(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=$r(e.front);if(!n)return;let r=e.sizeList.slice();if(r[0]){let e=Yp(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 i=[];for(let a of r){let r=Yp(a);if(typeof r!=`number`)continue;let o={};if(V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>n){V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of Kp)V(o,t,{enumerable:!0,configurable:!1,writable:!1,value:ei(e[t],a)})}else{V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/n});for(let t of Kp)V(o,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]})}i.push(o)}return i=Xp(i),Object.freeze(i)})()}),V(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=D(a,`video`),n;return e&&(n={},V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),V(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Matrix4().fromArray(e.matrix)}),V(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector2().fromArray(e.size)})),n})()}),e})()}),E.push(o)}}V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(E)});let D={};if(V(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),w.initial){if(t.observers.length>0){let e;dp(w.initial.panoIndex)?e=w.initial.panoIndex:dp(w.initial.pano_index)?e=w.initial.pano_index:dp(w.initial.pano)&&(e=w.initial.pano),typeof e==`number`&&(e=U(e,0,t.observers.length-1),V(D,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(w.initial.mode===`Panorama`&&t.observers.length===0||w.initial.mode===`Floorplan`||w.initial.mode===`Topview`||w.initial.mode===`Model`||w.initial.mode===`Mapview`?V(D,`mode`,{enumerable:!0,writable:!0,value:w.initial.mode}):typeof D.panoIndex==`number`?V(D,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):V(D,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),dp(w.initial.latitude)&&V(D,`latitude`,{enumerable:!0,writable:!0,value:w.initial.latitude}),dp(w.initial.longitude)?V(D,`longitude`,{enumerable:!0,writable:!0,value:w.initial.longitude}):dp(w.initial.heading)&&V(D,`longitude`,{enumerable:!0,writable:!0,value:Gt(w.initial.heading)}),dp(w.initial.fov)&&V(D,`fov`,{enumerable:!0,writable:!0,value:w.initial.fov}),dp(w.initial.distance)&&V(D,`distance`,{enumerable:!0,writable:!0,value:w.initial.distance}),Array.isArray(w.initial.offset)){let e=w.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});V(D,`offset`,{enumerable:!0,writable:!0,value:new c.Vector3().fromArray(t)})}else typeof w.initial.offset==`object`&&typeof w.initial.offset.x==`number`&&typeof w.initial.offset.y==`number`&&typeof w.initial.offset.z==`number`&&V(D,`offset`,{enumerable:!0,writable:!0,value:new c.Vector3().fromArray([w.initial.offset.x,w.initial.offset.y,w.initial.offset.z])})}return V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:D}),t}function Qp(e,t){return V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),V(t,`workCode`,{enumerable:!0,value:`null-`+rn()}),V(t,`baseURL`,{enumerable:!0,value:`/`}),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function $p(e,t){var n,r;return V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),V(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?rn():r}),V(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Z({workCode:t.workCode,panoIndex:0})}),V(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),V(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),V(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector3(0,1.5,0)}),V(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector3(0,0,0)}),V(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Quaternion(0,1,0,0)}),V(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Matrix4().compose(n.position,n.quaternion,Gp)}),V(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),V(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),V(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of Kp)V(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return V(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),V(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=$r(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=Yp(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 i=[];for(let a of r){let r=Yp(a);if(typeof r!=`number`)continue;let o={};if(V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>e){V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of Kp)V(o,e,{enumerable:!0,configurable:!1,writable:!1,value:ei(n[e],a)})}else{V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/e});for(let e of Kp)V(o,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}i.push(o)}return i=Xp(i),Object.freeze(i)})()}),V(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),V(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var em=new WeakSet,tm=class{constructor(e,t){this.observerBox=new c.Box3,this.observerBox=new c.Box3,this.transform=new c.Matrix4,this.shortPath=!1,this.jsonp=!1;let n;if(n=e===null?Qp(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`?$p(e,this):Zp(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
938
+ `,uniforms:{diffuse:{value:new c.Color},opacity:{value:1},displacementScalar:{value:0}}};function Jd(e,t,n,r){let i=new Float32Array((n+1)*(r+1)*3),a=new Float32Array((n+1)*(r+1)*3),o=new Float32Array((n+1)*(r+1)*2),s=new Uint32Array(n*r*6),l=e.computeFrenetFrames(n),u=new c.Vector3,d=new c.Vector3,f=new c.Vector2,p=new c.Vector3;for(let s=0;s<=n;s++){p=e.getPointAt(s/n,p);let c=l.normals[s],m=l.binormals[s];for(let e=0;e<=r;e++){let l=s*(r+1)+e,h=e/r*Math.PI*2,g=Math.sin(h),_=-Math.cos(h);d.x=_*c.x+g*m.x,d.y=_*c.y+g*m.y,d.z=_*c.z+g*m.z,d.normalize(),d.toArray(a,l*3),u.x=p.x+t*d.x,u.y=p.y+t*d.y,u.z=p.z+t*d.z,u.toArray(i,l*3),f.x=s/n,f.y=e/r,f.toArray(o,l*2)}}for(let e=0;e<n;e++)for(let t=0;t<r;t++){let n=(e*r+t)*6,i=(r+1)*e+t,a=(r+1)*(e+1)+t,o=(r+1)*(e+1)+(t+1),c=(r+1)*e+(t+1);s[n]=i,s[n+1]=a,s[n+2]=c,s[n+3]=a,s[n+4]=o,s[n+5]=c}let m=new c.BufferGeometry;return m.setIndex(new c.BufferAttribute(s,1)),m.setAttribute(`position`,new c.BufferAttribute(i,3)),m.setAttribute(`normal`,new c.BufferAttribute(a,3)),m.setAttribute(`uv`,new c.BufferAttribute(o,2)),m}function Yd(e,t){let n=new c.Color(0).convertSRGBToLinear(),r=new c.Color(52949).convertSRGBToLinear(),i=new c.Color(3370495).convertSRGBToLinear(),a=new c.Color(16777215).convertSRGBToLinear(),o=0,s=new c.CurvePath,l=e.length;for(let t=3;t<l;t+=3){let n=new c.Vector3().fromArray(e,t-3),r=new c.Vector3().fromArray(e,t);o+=n.distanceTo(r);let i=new c.LineCurve3(n,r);s.add(i)}let u=Jd(s,.03,Math.ceil(o*100),6);u.clearGroups(),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,0),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,1),u.addGroup(0,u.index?u.index.count:u.attributes.position.count,2);let d=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.BackSide});d.uniforms.totalLength.value=o,d.uniforms.diffuse.value=n,d.uniforms.diffuse2.value=n,d.uniforms.opacity.value=.5,d.transparent=!0;let f=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.BackSide});f.uniforms.totalLength.value=o,f.uniforms.displacementScalar.value=-.01,f.uniforms.diffuse.value=r,f.uniforms.diffuse2.value=i;let p=new c.ShaderMaterial({vertexShader:Kd.vertexShader,fragmentShader:Kd.fragmentShader,uniforms:c.UniformsUtils.clone(Kd.uniforms),side:c.DoubleSide});p.uniforms.totalLength.value=o,p.uniforms.displacementScalar.value=-.026,p.uniforms.dashSize.value=new c.Vector2(.06,.09),p.uniforms.diffuse.value=a,p.uniforms.diffuse2.value=a;let m=new c.Mesh(u,[d,f,p]),h=new c.SphereBufferGeometry(.08,24,24);h.clearGroups(),h.addGroup(0,u.index?u.index.count:u.attributes.position.count,0),h.addGroup(0,u.index?u.index.count:u.attributes.position.count,1);let g=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.BackSide});g.uniforms.diffuse.value=n,g.uniforms.opacity.value=.5,g.transparent=!0;let _=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.FrontSide});_.uniforms.displacementScalar.value=-.01,_.uniforms.diffuse.value=r;let v=new c.Mesh(h,[g,_]);v.position.fromArray(e,0),m.add(v);let y=new c.ShaderMaterial({vertexShader:qd.vertexShader,fragmentShader:qd.fragmentShader,uniforms:c.UniformsUtils.clone(qd.uniforms),side:c.FrontSide});y.uniforms.displacementScalar.value=-.01,y.uniforms.diffuse.value=i;let b=new c.Mesh(h,[g,y]);return b.position.fromArray(e,e.length-3),m.add(b),{scene:m,dispose:()=>{u.dispose(),d.dispose(),f.dispose(),p.dispose(),h.dispose(),g.dispose(),_.dispose(),y.dispose()}}}function Xd(e,t){let n=e.name,r=Xr(Tr(e.content.uri,t.search),{key:`model.0`});return e.content.loadState=`LOADING`,e.content.loadStateUpdateTime=H(),Cs(r,{type:`geometry`,customPropertyMapping:{time:{itemType:`uint32`,itemNames:[`time_milisec`]}},fetcher:t.fetcher}).then(t=>{var i,a,o,s;let c=(a=(i=t.scene.attributes)==null?void 0:i.time.array)==null?[]:a,l=(s=(o=t.scene.attributes)==null?void 0:o.position.array)==null?[]:s,u=t.byteLength,d=t.memoryUsage,f=Yd(l,c);f.scene.applyMatrix4(e.transform),f.scene.updateWorldMatrix(!1,!0),f.scene.matrixAutoUpdate=!1;let p=new od(n,f.scene);return e.content.data={uri:r,byteLength:u,memoryUsage:d,positionArray:l,timeArray:c,object:p},e.content.byteLength=u,e.content.memoryUsage=d,e.content.loadState=`READY`,e.content.loadStateUpdateTime=H(),e}).catch(t=>(e.content.data=void 0,e.content.loadState=`FAILED`,e.content.loadStateUpdateTime=H(),t instanceof or&&t.httpStatus===0||t instanceof sr||t instanceof ar?e.content.loadfailRetryDelay=U(e.content.loadfailRetryDelay+Gd,Gd,Wd):e.content.loadfailRetryDelay=1/0,Promise.reject(t)))}function Zd(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=H(),e.content.byteLength=0,e.content.memoryUsage=0)}var Qd=new c.Vector3,$d=new c.Matrix3,ef=new c.Matrix4,tf=6378137,nf=298.257223563;function rf(e){let t=tf-tf/nf,n=(tf*tf-t*t)/(tf*tf),r=Math.sqrt(e.x*e.x+e.y*e.y),i=0,a=Math.atan2(e.z,r),o=0;for(;i++<1e3;){let t=Math.sin(a),i=tf/Math.sqrt(1-n*t*t);o=r/Math.cos(a)-i;let s=Math.atan2(e.z/(i*(1-n)+o),r/(i+o));if(isNaN(s)||Math.abs(s-a)<1e-12)break;a=s}return e.set(a,Math.atan2(e.y,e.x),o)}function af(e){let{x:t,y:n,z:r}=e,i=tf-tf/nf,a=(tf*tf-i*i)/(tf*tf),o=Math.sin(t),s=Math.cos(t),c=Math.sin(n),l=Math.cos(n),u=tf/Math.sqrt(1-a*o*o),d=(u+r)*s*l,f=(u+r)*s*c,p=(i*i/(tf*tf)*u+r)*o;return e.set(d,f,p)}function of(e,t){let{x:n,y:r,z:i}=rf(Qd.copy(e)),a=Math.sin(n),o=Math.sin(r),s=Math.cos(n),c=Math.cos(r);t.fromArray([-o,-a*c,s*c,0,+c,-a*o,s*o,0,0,s,a,0,0,0,0,1]);let l=$d.setFromMatrix4(t),u=Qd.copy(e).applyMatrix3(l).multiplyScalar(-1);t.setPosition(u);let d=ef.fromArray([1,0,0,0,0,1,0,0,0,0,1,0,0,0,i,1]);return t.premultiply(d),t}var sf=new c.Matrix4().fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]),cf=new c.Matrix4().fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1]),lf=new c.Matrix4().copy(sf),uf=new c.Matrix4().copy(cf);function df(e,t={}){var n,r,i;let a,o,s;if(typeof e.tileset.rootMeta.creationTime==`string`)if(typeof e.tileset.rootMeta.numTotalPoints==`number`&&e.tileset.rootMeta.numTotalPoints>0){s=4,t.powerPreference===`high`&&(s=2),a=s/1.6;let c=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((i=e.tileset.rootMeta.taskParameters)==null?void 0:i.homo_point_density);isFinite(t)&&!isNaN(t)&&(c=t)}c<=0&&(c=.02),o=c*1.4}else s=5,t.powerPreference===`high`&&(s=4),a=0,o=.03;else s=6,a=0,o=.03,e.name===`aerophoto`?(s=12,t.powerPreference===`high`&&(s=10)):e.tileset.asset.extras&&typeof e.tileset.asset.extras.name==`string`&&/^matterport\b/i.test(e.tileset.asset.extras.name)&&(s=5,t.powerPreference===`high`&&(s=4));return{pointScale:o,pointMinPixel:a,maxScreenSpaceError:s}}var ff=new c.Vector3,pf=new Ol,mf=new Dl,hf=new WeakMap,gf=new WeakMap,_f=new WeakMap,vf={TILE_MASK:128,SKIP_LOD_MASK:112,SKIP_LOD_BIT_SHIFT:4,CLASSIFICATION_MASK:15},yf=(()=>{let e=new c.MeshBasicMaterial;return e.side=c.BackSide,e.color.setHex(16711935),e.colorWrite=!1,e.stencilWrite=!0,e.polygonOffset=!0,e.polygonOffsetFactor=2,e.polygonOffsetUnits=2,e.stencilRef=vf.TILE_MASK,e.stencilFunc=c.AlwaysStencilFunc,e.stencilFuncMask=vf.TILE_MASK,e.stencilZPass=c.ReplaceStencilOp,e.stencilWriteMask=vf.TILE_MASK,e})(),bf=(()=>{let e=new c.MeshBasicMaterial;return e.visible=!1,e})(),xf=new c.BufferGeometry,Sf=new c.MeshBasicMaterial;function Cf(e){let t;t=e instanceof c.Mesh?new c.Mesh(e.geometry,Array.isArray(e.material)?e.material.map(e=>e.transparent?bf:yf):e.material&&e.material.transparent?bf:yf):e instanceof c.Group?new c.Group:new c.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(Cf(n));return t}var wf=class extends c.Object3D{constructor(e,t){var n,r;super(),this.parameter=new G,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 c.Box3,this.autoRefine=!0,this.refined=!1,this.refineProgress=[0,0],this.loaded=!1,this.disposed=!1,this.clearStencilObject=new c.Mesh(xf,Sf),this.clearStencilObject.frustumCulled=!1,this.clearStencilObject.onAfterRender=e=>e.clearStencil(),this.tileset=new vd(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=G.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 df(this,e)}loadContent(e){return Hd(e,{light:this.light,fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(t=>{if(e.type===`SCENEGRAPH`){if(this.disposed||!e.content)Ud(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 Ud(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 Xd(e,{fetcher:this.fetcher,search:this.search,renderer:this.renderer}).then(e=>{this.disposed&&Zd(e)})}unloadTrajectory(e){return Zd(e),Promise.resolve()}intersectRaycaster(e,t){var n,r;let i=t==null?[]:t,a=[this.tileset.root],o=this.tileset.transform,s=(r=(n=e.params.Points)==null?void 0:n.threshold)==null?0:r,c=e.sortByDistance;e.sortByDistance=!1;let l,u=1/0;for(;l=a.pop();){let t;if(l.boundingVolume){let n;n=l.boundingVolume instanceof Dl?mf.copy(l.boundingVolume):l.boundingVolume instanceof Ol?pf.copy(l.boundingVolume):l.boundingVolume.clone(),n.applyMatrix4(o),t=n.intersectRay(e.ray,s,u)}else t=!0;if(t){for(let e=0,t=l.children.length;e<t;e++)a.push(l.children[e]);if(l.selected&&l.content&&l.content.data&&l.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:l}),t?t.call(e,n):!0},l.content.data.object.intersectRaycaster(e,i),e.hitFilter=t,e.firstHitOnly){let e=i[0];e&&u>e.distance&&(u=e.distance)}}}}return e.sortByDistance=c,Jl(i,e.sortByDistance,e.firstHitOnly),i}update(e,t,n,r){var i,a,o;this.renderer=e,this.frameNumber++;let s=!1,l=G.resolveValueTo(this.currentResolvedParameterValue,n.parameter,r.parameter,this.parameter);hf.get(this)!==l.versionNumber&&(hf.set(this,l.versionNumber),s=!0);let u=this.visible&&r.visible&&n.visible,d=l.maxLevelOfDetail;d=Math.max(d,0);let f=Math.min(l.minLevelOfDetail,d);(!u||!this.loaded||!n.loaded)&&(d=Math.max(f,0));let p=l.maxMemoryUsage;u||(p=Math.min(0,p));let m=l.minGeometricError,h=l.maxRequests,g=l.memoryAdjustedScreenSpaceError;u||(g=!1);let _=t.controllerMode;(_===`Panorama`||_===`VRPanorama`||_===`XRPanorama`)&&(l.modelAlpha<.1&&(m=l.panoramaMinGeometricError,g=!1),l.progress>=.01&&l.progress<=.99&&(h=0));let v=l.maxGeometricError;v=Math.max(m,v);let y={time:t.time,camera:{type:t.type,position:new c.Vector3().copy(t.position),direction:t.getDirection(new c.Vector3),up:new c.Vector3().copy(t.up).applyQuaternion(t.quaternion),projectionMatrix:t.projectionMatrix.clone(),visible:u&&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 El().setFromCamera(t),minLevelOfDetail:f,maxLevelOfDetail:d,minGeometricError:m,maxGeometricError:v,skipLevelOfDetail:l.skipLevelOfDetail,mostDetail:l.mostDetail,loadSiblings:l.loadSiblings,cameraCulling:l.cameraCulling,maxMemoryUsage:p,maxRequests:h,requestOrder:l.requestOrder,maxScreenSpaceError:l.maxScreenSpaceError,memoryAdjustedScreenSpaceError:g},b=l.cacheCameras.map(e=>(e.updateProjectionMatrix(),Object.assign(Object.assign({},y),{camera:{type:t.type,position:new c.Vector3().copy(e.position),direction:e.getWorldDirection(new c.Vector3),up:new c.Vector3().copy(e.up),projectionMatrix:e.projectionMatrix.clone(),visible:e.visible,refine:!0},cullingVolume:new El().setFromCamera(e)})));this.updateWorldMatrix(!0,!1),this.tileset.transform.equals(this.matrixWorld)||(this.tileset.transform.copy(this.matrixWorld),s=!0);let x=!this.autoRefine;if(x===!1&&l.progress>=.01&&l.progress<=.99){let e=new c.Vector3;l.pano0&&e.setFromMatrixPosition(l.pano0.matrix);let t=e.clone();l.pano1&&t.setFromMatrixPosition(l.pano1.matrix),e.distanceTo(t)<10&&(x=!0)}if(x||this.tileset.update(y,b),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),l.minLevelOfDetail>=0)){if(y.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]);y.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 S=[];for(let r of this.tileset.selectedTiles){let o=(a=(i=r.content)==null?void 0:i.data)==null?void 0:a.object;if(!o)continue;let u=o.update(e,t,n,this,r,l);if(S.push(r.id),u&&(s=!0),this.tileset.hasMixedContent&&y.skipLevelOfDetail){if(!r.state.finalResolution){let e=Cf(o);e.name=`skipBackface:`+o.name,this.backfaceObjects.push(e)}let e=r.state.selectionDepth,t=vf.TILE_MASK|e<<vf.SKIP_LOD_BIT_SHIFT,n=c.GreaterEqualStencilFunc,i=vf.SKIP_LOD_MASK,a=c.ReplaceStencilOp,s=vf.TILE_MASK|vf.SKIP_LOD_MASK;for(let e of o.materials)e.stencilWrite=!0,e.stencilRef=t,e.stencilFunc=n,e.stencilFuncMask=i,e.stencilZPass=a,e.stencilWriteMask=s}else for(let e of o.materials)e.stencilWrite=!1,e.stencilRef=vf.TILE_MASK,e.stencilFunc=c.AlwaysStencilFunc,e.stencilFuncMask=vf.TILE_MASK,e.stencilZPass=c.ReplaceStencilOp,e.stencilWriteMask=vf.TILE_MASK;this.tileObjects.push(o)}let C=S.toString();if(gf.get(this)!==C&&(gf.set(this,C),s=!0),y.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]);y.skipLevelOfDetail&&this.renderObjects.push(this.clearStencilObject);let w=[];for(let r of this.tileset.selectedTrajectories){let i=(o=r.content.data)==null?void 0:o.object;if(!i)continue;let a=i.update(e,t,n,this,r,l);w.push(r.id),a&&(s=!0),this.renderObjects.push(i)}let T=w.toString();if(_f.get(this)!==T&&(_f.set(this,T),s=!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 c.Mesh||e instanceof c.Line||e instanceof c.Points)&&(e.renderOrder=r)})}}if(this.loaded)for(let e=0;e<this.renderObjects.length;e++)this.add(this.renderObjects[e]);return s}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(uf)}enuToLocal(e){return e.applyMatrix4(lf)}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 rf(this.enuToEcef(this.localToEnu(e)))}llaToLocal(e){return this.enuToLocal(this.ecefToEnu(af(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(){ff.setScalar(0);let{x:e,y:t}=this.localToLla(ff);return[e,t].map(e=>(e/Math.PI*180).toFixed(6)).join(`,`)}getTransformMatrix4(e=new c.Matrix4){return e.copy(this.coordinateSystem.ecefToEnuMatrix),e.premultiply(lf),e.premultiply(this.matrixWorld),e}coordinatesToWorldPoint(e){let t=new c.Vector3(e.latitude,e.longitude,e.altitude);return this.llaToWorld(t)}worldPointToCoordinates(e){return ff.copy(e),this.worldToLla(ff),{latitude:ff.x,longitude:ff.y,altitude:ff.z}}resetBrightness(){this.parameter.reset(`brightness`)}get minLevelOfDetail(){let e=[];return this.parent&&this.parent.parameter instanceof G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&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 G&&(e.unshift(this.parent.parameter),this.parent.parent&&this.parent.parent.parameter instanceof G&&e.unshift(this.parent.parent.parameter)),this.parameter.resolveValue(`maxScreenSpaceError`,...e)}set maxScreenSpaceError(e){this.parameter.set(`maxScreenSpaceError`,e)}},Tf={};function Ef(e,t){let n=Tf[e];if(n){let e=n.get(t);if(e)return e}throw Error(`fetcher workCode:${t.workCode} never registered.`)}function Df(e,t,n){let r=Tf[e];r||(r=Tf[e]=new WeakMap),r.has(t)||r.set(t,n)}var Of=new c.Matrix4,kf=new c.Vector3,Af=new c.Matrix4;function jf(e,t,n){switch(e){case`Z`:n.identity();break;case`WGS84`:case`GCJ02`:case`BD09`:of(t,n);break;default:n.identity();break}return n}function Mf(e){var t;let[n,r]=e.tilesetUrl.split(`#`),i=(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,a=bd(JSON.parse(t.body),e.tilesetUrl),{root:o,rootMeta:s={}}=a,l=e.upAxis;s.upAxis&&s.upAxis!==l&&(l=s.upAxis),`lodVersion`in a&&(l=`-Y`,`floorInfo`in a&&(a.properties=a.properties||{},a.properties.floorInfo=a.floorInfo.map(e=>({ground:-e.ground,height:e.height})),a.floorInfo=void 0),a.asset.tilesetVersion=String(a.lodVersion),a.lodVersion=void 0);let u=l,d=new c.Matrix4;u===`Y`?(u=`Z`,d.fromArray([1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1])):u===`-Y`&&(u=`Z`,d.fromArray([1,0,0,0,0,0,-1,0,0,1,0,0,0,0,0,1]));let f=o.boundingVolume?jl(o.boundingVolume):void 0;f&&o.transform&&f.applyMatrix4(Af.fromArray(o.transform));let p=null,m=new c.Matrix4,h=new c.Matrix4;return s.coordinate?(p=s.coordinate.ground_height,m.fromArray(s.coordinate.pose_ecef_to_enu),h.fromArray(s.coordinate.pose_enu_to_ecef)):(f?f.getCenter(kf):kf.setScalar(0),kf.applyMatrix4(d),jf(u,kf,m),h.getInverse(m)),a.root={refine:(n=o.refine)==null?`REPLACE`:n,geometricError:o.geometricError,transform:Af.copy(d).premultiply(u===`Z`?Of:m).premultiply(lf).toArray(),boundingVolume:f?f.toJson():void 0,children:[o]},new wf(a,{name:e.name,type:e.type,upAxis:l,light:e.light,fetcher:e.fetcher,search:i,groundHeight:p,coordinateSystem:{enuToEcefMatrix:h,ecefToEnuMatrix:m},error:r})})}function Nf(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 i=!1;for(let e of r)if(e.type===`mesh`){i=!0;break}if(i===!1){let i=Dr(e.file)||`.at3d`,a=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:{[i.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([a],{type:`application/json`})),fetcher:t.fetcher,light:t.light})}}let i=r.map(e=>Mf(e).then(e=>e));return Promise.all(i)}function Pf(e=1,t=1,n=1){let r=e/2,i=t/2,a=n/2,o=new Float32Array([-r,+i,+a,+r,+i,+a,+r,+i,-a,-r,+i,-a,-r,-i,+a,+r,-i,+a,+r,-i,-a,-r,-i,-a]),s=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]),l=new c.BufferGeometry;return l.setAttribute(`position`,new c.BufferAttribute(o,3)),l.setIndex(new c.BufferAttribute(s,1)),l.addGroup(0,l.index.count,0),l.computeBoundingBox(),l.computeBoundingSphere(),l}function Ff(e,t){for(var n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=new c.BufferGeometry,l=0,u=0;u<e.length;++u){var d=e[u];if(n!==(d.index!==null))return null;for(var f in d.attributes){if(!r.has(f))return null;a[f]===void 0&&(a[f]=[]),a[f].push(d.attributes[f])}for(var f in d.morphAttributes){if(!i.has(f))return null;o[f]===void 0&&(o[f]=[]),o[f].push(d.morphAttributes[f])}if(s.userData.mergedUserData=s.userData.mergedUserData||[],s.userData.mergedUserData.push(d.userData),t){var p;if(n)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return null;s.addGroup(l,p,u),l+=p}}if(n){for(var m=0,h=[],u=0;u<e.length;++u){for(var g=e[u].index,_=0;_<g.count;++_)h.push(g.getX(_)+m);m+=e[u].attributes.position.count}s.setIndex(h)}for(var f in a){var v=If(a[f]);if(!v)return null;s.setAttribute(f,v)}for(var f in o){var y=o[f][0].length;if(y===0)break;s.morphAttributes=s.morphAttributes||{},s.morphAttributes[f]=[];for(var u=0;u<y;++u){for(var b=[],_=0;_<o[f].length;++_)b.push(o[f][_][u]);var x=If(b);if(!x)return null;s.morphAttributes[f].push(x)}}return s}function If(e){for(var t,n,r,i=0,a=0;a<e.length;++a){var o=e[a];if(o.isInterleavedBufferAttribute||(t===void 0&&(t=o.array.constructor),t!==o.array.constructor)||(n===void 0&&(n=o.itemSize),n!==o.itemSize)||(r===void 0&&(r=o.normalized),r!==o.normalized))return null;i+=o.array.length}for(var s=new t(i),l=0,a=0;a<e.length;++a)s.set(e[a].array,l),l+=e[a].array.length;return new c.BufferAttribute(s,n,r)}function Lf(e,t=1e-4){t=Math.max(t,Number.EPSILON);for(var n={},r=e.getIndex(),i=e.getAttribute(`position`),a=r?r.count:i.count,o=0,s=Object.keys(e.attributes),l={},u={},d=[],f=[`getX`,`getY`,`getZ`,`getW`],p=0,m=s.length;p<m;p++){var h=s[p];l[h]=[];var g=e.morphAttributes[h];g&&(u[h]=Array(g.length).fill().map(()=>[]))}for(var _=Math.log10(1/t),v=Math.pow(10,_),p=0;p<a;p++){for(var y=r?r.getX(p):p,b=``,x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),C=S.itemSize,w=0;w<C;w++)b+=`${~~(S[f[w]](y)*v)},`;if(b in n)d.push(n[b]);else{for(var x=0,m=s.length;x<m;x++)for(var h=s[x],S=e.getAttribute(h),g=e.morphAttributes[h],C=S.itemSize,T=l[h],E=u[h],w=0;w<C;w++){var D=f[w];if(T.push(S[D](y)),g)for(var O=0,k=g.length;O<k;O++)E[O].push(g[O][D](y))}n[b]=o,d.push(o),o++}}let A=e.clone();for(var p=0,m=s.length;p<m;p++){var h=s[p],j=e.getAttribute(h),M=new j.array.constructor(l[h]),S=new c.BufferAttribute(M,j.itemSize,j.normalized);if(A.setAttribute(h,S),h in u)for(var x=0;x<u[h].length;x++){var N=e.morphAttributes[h][x],M=new N.array.constructor(u[h][x]),ee=new c.BufferAttribute(M,N.itemSize,N.normalized);A.morphAttributes[h][x]=ee}}return A.setIndex(d),A}var Rf=new c.Sphere,zf=new c.Matrix4,Bf=new c.Matrix4;function Vf(e,t,n=30/180*Math.PI){let r=Math.cos(n),i=[];for(let n of e.children)n instanceof wf&&n.tileset.selectedTiles.forEach(e=>{var n,a,o;let s=(a=(n=e.content)==null?void 0:n.data)==null?void 0:a.object;if(s&&s.visible){let e=[];if(s.traverseVisible(n=>{if(n instanceof c.Mesh){let r=ju(n);if(r){zf.copy(n.matrixWorld),Bf.getInverse(zf),Rf.copy(t).applyMatrix4(Bf);let i=r.trianglesInSphere(Rf.center,Rf.radius),a=new c.BufferGeometry;a.setAttribute(`position`,new c.BufferAttribute(i,3)),a.applyMatrix4(n.matrixWorld),a=Lf(a,.01),e.push(a)}}}),e.length===0)return;let n=[`a`,`b`,`c`],a=Ff(e,!1),l=a.getAttribute(`position`).array,u=((o=a.getIndex())==null?void 0:o.array)||[],d=[],f=[];for(let e=0,t=l.length;e<t;e+=3){let t=new c.Vector3(l[e],l[e+1],l[e+2]);d.push(t)}for(let e=0,t=u.length;e<t;e+=3){let t=u[e],n=u[e+1],r=u[e+2],i=new c.Vector3().crossVectors(d[n].clone().sub(d[t]),d[r].clone().sub(d[t])).normalize();f.push({a:t,b:n,c:r,normal:i})}let p={};for(let e=0,t=f.length;e<t;e++){let t=f[e];for(let r=0;r<3;r++){let i=t[n[r]],a=t[n[(r+1)%3]],o=[Math.min(i,a),Math.max(i,a)],s=o[0]+`-`+o[1];p[s]===void 0?p[s]={index1:o[0],index2:o[1],face1:e}:p[s].face2=e}}for(let e in p){let t=p[e];if(t.face2===void 0||f[t.face1].normal.dot(f[t.face2].normal)<=r){let e=d[t.index1],n=d[t.index2];i.push(new c.Line3(e,n))}}d.length=0,f.length=0}});return i}var Hf=new c.Box3,Uf=new c.Box3,Wf=new c.Box3,Gf=class extends c.Object3D{constructor(e,t,n={}){var r;super(),this.disposed=!1,this.parameter=new G,this.outdated=!1,this.autoRefine=!0,this.metaPending=!1,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.boundingBox=new c.Box3,this.fiveId=e,this.needsRender=!1,this.work=t,this.name=t.workCode;let i=0;for(let e of t.observers)i=Math.max(i,e.floorIndex);if(this.floorLength=i+1,t.model){this.metaPending=!0;let e=Nf(t.model,{fetcher:Ef(this.fiveId,t),light:(r=n.light)==null?!1:r,textureOptions:n.textureOptions}),i=e=>this.dispatchEvent({type:`error`,error:e}),a=e=>this.dispatchEvent({type:`tileLoad`,tile:e}),o=e=>this.dispatchEvent({type:`tileUnload`,tile:e});this.initReady=e.then(e=>{var t;this.metaPending=!1;let n=null,r=null,s=null;for(let t of e){if(t.visible=!1,t.onError=i,t.onTileLoad=a,t.onTileUnload=o,t.error){i(t.error);continue}t.type===`mesh`?n===null&&(n=t):t.type===`point_cloud`?r===null&&(r=t):s===null&&(s=t)}let c=(t=n==null?r:n)==null?s:t;if(c&&(c.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 Vf(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,Jl(n,e.sortByDistance,e.firstHitOnly),n}update(e,t,n){let r=!1;this.needsRender===!0&&(this.needsRender=!1,r=!0);let i=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 i of this.children)i.autoRefine=this.autoRefine,i.update(e,t,n,this)&&(r=!0),i.refined===!1&&(this.refined=!1),i.loaded===!1&&(this.loaded=!1),this.refineProgress[0]+=i.refineProgress[0],this.refineProgress[1]+=i.refineProgress[1];Hf.makeEmpty(),Wf.copy(this.work.observerBox),Wf.isEmpty()||(Wf.max.x+=1,Wf.max.z+=1,Wf.max.y+=1,--Wf.min.x,--Wf.min.z,Hf.union(Wf));for(let e of this.viewLayers)e.boundingBox.isEmpty()||(Uf.copy(e.boundingBox),Hf.union(Uf));return Hf.applyMatrix4(this.matrix),Hf.equals(this.boundingBox)||(this.boundingBox.copy(Hf),this.parameter.set(`boundingBox`,Hf.clone())),i===!1&&this.loaded===!0&&this.dispatchEvent({type:`load`}),r}localToEnu(e){return e.applyMatrix4(uf)}enuToLocal(e){return e.applyMatrix4(lf)}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 G&&e.unshift(this.parent.parameter),this.parameter.resolveValue(...e)}get shownFloorIndex(){let e=[];return this.parent&&this.parent.parameter instanceof G&&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 G&&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 G&&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 G&&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()}},Kf=Pf(1,1,1);Kf.applyMatrix4(new c.Matrix4().makeScale(-1,1,1));var qf=new WeakMap,Jf=new c.Vector3(1,1,1),Yf=new c.Box3,Xf=new c.Vector3,Zf=new c.Box3,Qf=new c.Vector3,$f=new c.Vector3,ep=class extends bn{constructor(e={}){var t;let n=new yn(`none`);n.flatShading=!0,n.depthWrite=!1,n.transparent=!1,n.blending=c.CustomBlending,n.blendSrc=c.SrcAlphaFactor,n.blendDst=c.OneMinusSrcAlphaFactor,n.blendSrcAlpha=c.OneFactor,n.blendDstAlpha=c.OneMinusSrcAlphaFactor,n.floorIndex=-1,super(Kf,[n]),this.name=(t=e.name)==null?``:t,this.frustumCulled=!1,this.renderOrder=-999999,this.currentResolvedParameterValue=G.resolveValueTo({})}update(e,t,n){var r,i;let a=!1,o=G.resolveValueTo(this.currentResolvedParameterValue,n.parameter);Yf.copy(o.boundingBox),Yf.getSize(Xf);let s=Math.min(Xf.x/2,500);Yf.min.x-=s,Yf.max.x+=s;let c=Math.min(Xf.y/2,500);Yf.min.z-=c,Yf.max.z+=c;let l=Xf.length()/2;if(Yf.max.y=Math.max(Yf.max.y,l),Yf.union(Zf.setFromCenterAndSize(t.position,Jf)),Yf.expandByScalar(1),Yf.getCenter(Qf),Yf.getSize($f),Qf.equals(this.position)||(this.position.copy(Qf),a=!0),$f.equals(this.scale)||(this.scale.copy($f),a=!0),qf.get(this)!==o.versionNumber){qf.set(this,o.versionNumber),a=!0;let e=this.material;for(let t of e)t.customShaders=o.customShaders,t.pano0=o.pano0,t.pano1=o.pano1,t.panoFilter=(i=(r=o.panoFilter)==null?void 0:r.toValue())==null?null:i,t.refinedScreen=o.refinedScreen,t.modelAlpha=o.modelAlpha,t.progress=o.progress,t.transition=o.transition,t.opacity=o.opacity,t.floorStyle=o.floorStyle,t.constantColor=o.constantColor,t.shownFloorIndex=o.shownFloorIndex,t.clippers=o.clippers,t.brightness=o.brightness,t.useHQWeight=o.useHQWeight,t.useHQDepth=o.useHQDepth,t.colorSaturation=o.colorSaturation,t.colorBrightness=o.colorBrightness,t.gradientTexture=o.gradientTexture,t.transparent=!1,t.modelBoundingMax.copy(o.boundingBox.max),t.modelBoundingMin.copy(o.boundingBox.min),o.useAddBlend&&(t.opacity=0),t.opacity===0&&(t.visible=!1)}return a}dispose(){for(let e of this.material)e.dispose(),e.pano0=null,e.pano1=null}},tp=new c.Box3,np=class extends c.Scene{constructor(e){super(),this.needsRender=!0,this.autoRefine=!0,this.boundingBox=new c.Box3,this.loaded=!1,this.refined=!1,this.refineProgress=[0,0],this.parameter=new G,this.fiveId=e.fiveId,this.boundingMesh=new ep({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;V(t,`autoUpdate`,{get(){return n.autoRefine},set(e){n.autoRefine=e}}),V(t,`bounding`,{get(){return n.boundingBox}}),V(t,`loaded`,{get(){return n.loaded}}),V(t,`refined`,{get(){return n.refined}}),V(t,`refineProgress`,{get(){return n.refineProgress}}),V(t,`cacheCameras`,{get(){return n.parameter.resolveValue(`cacheCameras`)},set(e){n.parameter.set(`cacheCameras`,e)}}),V(t,`intersectRaycaster`,{value:e=>n.intersectRaycaster(e)}),V(t,`setMaterial`,{value:e=>n.setMaterial(e)}),V(t,`getMaterial`,{value:()=>n.getMaterial()}),V(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 Gf(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=jl(t.viewerRequestVolume)),e.parameter.set(yr(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=jl(r.viewerRequestVolume)),e.parameter.set(yr(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&&!Ul(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,Jl(n,e.sortByDistance,e.firstHitOnly)}return n}update(e,t){let n=!1;tp.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 i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}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)&&!Ul(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 i=r.update(e,t,this);r.autoRefine=n,this.updateModelMap.set(r,i)}}for(let e=this.children.length-1;e>=0;e--){let t=this.children[e];t instanceof Gf&&this.remove(t)}for(let e=0;e<this.shownModels.length;e++){let t=this.shownModels[e];this.updateModelMap.get(t)===!0&&(n=!0),tp.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&&tp.union(t.boundingBox)}return tp.equals(this.boundingBox)||(this.boundingBox.copy(tp),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 Gf&&this.remove(t)}let e=Gl(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 rp(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 ip(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 ap(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 op(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 sp(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:rp(e.initial),model:ip(e.model),observers:e.observers.map(e=>ap(e)),panorama:{count:e.observers.length,list:e.observers.map(e=>op(e))}}}function cp(e){let t=(e.x*2+1)*Math.PI,n=(.5-e.y)*Math.PI,r=Math.sin(n),i=Math.cos(n),a=Math.sin(t),o=Math.cos(t),s=i*a,l=r,u=i*o,d=Math.abs(s),f=Math.abs(l),p=Math.abs(u),m,h;if(d>=f&&d>=p){let e=1/d;s>0?(m=`right`,h=new c.Vector2(-u*e,l*e)):(m=`left`,h=new c.Vector2(u*e,l*e))}else if(f>=d&&f>=p){let e=1/f;l>0?(m=`up`,h=new c.Vector2(s*e,-u*e)):(m=`down`,h=new c.Vector2(s*e,u*e))}else{let e=1/p;u>0?(m=`front`,h=new c.Vector2(s*e,l*e)):(m=`back`,h=new c.Vector2(-s*e,l*e))}return h.x=(h.x+1)/2,h.y=1-(h.y+1)/2,[m,h]}function lp(e,t){let n=t.x*2-1,r=(1-t.y)*2-1,i=0,a=0,o=0;switch(e){case`right`:i=1,a=r,o=-n;break;case`left`:i=-1,a=r,o=n;break;case`up`:i=n,a=1,o=-r;break;case`down`:i=n,a=-1,o=r;break;case`front`:i=n,a=r,o=1;break;case`back`:i=-n,a=r,o=-1;break;default:throw Error(`Invalid cubFace: ${e}`)}let s=Math.sqrt(i*i+a*a+o*o);if(s===0)return new c.Vector2(.5,.5);i/=s,a/=s,o/=s;let l=Math.atan2(i,o),u=Math.asin(Math.max(-1,Math.min(1,a))),d=(l+Math.PI)/(2*Math.PI),f=(Math.PI/2-u)/Math.PI;return d%=1,d=d<0?d+1:d,f=Math.max(0,Math.min(1,f)),new c.Vector2(d,f)}var up={vectorToEquirectangularUv(e,t=`top-left`){let n=new c.Quaternion().setFromRotationMatrix(this.work.transform).inverse(),r=new c.Quaternion().copy(this.quaternion).inverse(),i=new c.Quaternion(0,1,0,0).inverse(),a=new c.Vector3().copy(e).normalize().applyQuaternion(n).applyQuaternion(r).applyQuaternion(i),o=Math.atan2(a.x,-a.z),s=Math.asin(-a.y);if(t===`top-left`)return new c.Vector2(o/(Math.PI*2)+.5,s/Math.PI+.5);if(t===`bottom-left`)return new c.Vector2(o/(Math.PI*2)+.5,.5-s/Math.PI);throw Error(`Invalid uvOrigin ${t}`)},vectorToCubemapUv(e,t=`top-left`){let n=cp(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 c.Quaternion().setFromRotationMatrix(this.work.transform),i=new c.Quaternion().copy(this.quaternion),a=new c.Quaternion(0,1,0,0),o=Math.PI*2*(e.x+.5),s=Math.PI*(e.y-.5),l=Math.abs(Math.cos(s)),u=Math.sin(o)*l,d=-Math.sin(s)*n,f=-Math.cos(o)*l;return new c.Vector3(u,d,f).applyQuaternion(a).applyQuaternion(i).applyQuaternion(r)},cubemapUvToVector(e,t,n=`top-left`){let r;if(n===`top-left`)r=t;else if(n===`bottom-left`)r=new c.Vector2().copy(t),r.y=1-r.y;else throw Error(`Invalid uvOrigin ${n}`);let i=lp(e,r);return this.equirectangularUvToVector(i)},getWorldPosition(){return new c.Vector3().copy(this.position).applyMatrix4(this.work.transform)},getWorldStandingPosition(){return new c.Vector3().copy(this.standingPosition).applyMatrix4(this.work.transform)}};function dp(e){return typeof e==`number`}function fp(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>typeof e!=`object`||!e?e:fp(e));{let t={};for(let n in e){let r=e[n];t[n]=typeof r!=`object`||!r?r:fp(r)}return t}}function pp(e){return e==null?`null`:Array.isArray(e)?`array`:typeof e==`object`?`dict`:`value`}function mp(e,t){let n=pp(e),r=pp(t);if(r===`null`)return e;if(r===`value`)return t;if(r!==n)return fp(t);if(r===`array`)for(let n=0;n<t.length;n++)e[n]=mp(e[n],t[n]);else if(r===`dict`)for(let n in t)e[n]=mp(e[n],t[n]);return e}function hp(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+=hp(e[r],!1)+`,`;return n>-1&&(t+=hp(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return hp(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=hp(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}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 gp(e){return hp(e,!1)}function _p(e){return`hash::${_t(gp(e))}`}var vp=/^(.*)\[(\d+)\]$/;function Z(e){if(!isNaN(e.panoIndex)&&isFinite(e.panoIndex))return`${e.workCode}[${e.panoIndex}]`;throw Error(`Invalid Pano`)}function yp(e){let t=e.match(vp);if(t){let[e,n,r]=t,i=Math.floor(Number(r));if(!isNaN(i)&&isFinite(i))return{workCode:n,panoIndex:i}}throw Error(`Invalid PanoId`)}function bp(e,t){return Z(e)===Z(t)}function xp(e){return typeof e==`string`&&vp.test(e)}var Sp=`\\{([^\\}]+)\\}`;function Cp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function wp(e){return RegExp(`^`+e.map(e=>Cp(e)).join(`(.+)`)+`$`)}var Tp=class{constructor(e){this.strings=[],this.keys=[];let t=new RegExp(Sp,`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?wp(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],i=n[e+1];if(r[t]!==i){if(r[t]!==void 0)return null;r[t]=i}}return r}};function Ep(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])&&Ep(e[r])}),e}var Dp=/^[0-9a-z]+\:\/\/(([^:/?#]*)(?::[0-9]+)?)/i,Op=Ep(JSON.parse(function(...e){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`))),kp=/^([^.]+)(\.([^.]+))*$/,Ap=typeof location<`u`?location.hostname:`localhost`;function jp(e){return/^(([1-9]?\d|1\d\d|2[0-4]\d|25[0-5])(\.(?!$)|$)){4}$/.test(e)}function Mp(e,t){if(!kp.test(e)||!kp.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 Np(e){if(/^blob\:/i.test(e)||/^data\:/i.test(e))return Ap;let t=e.match(Dp);return t?t[2]:Ap}var Pp=()=>Error(`Invalid input.`),Fp=()=>Error(`Invalid certificate.`),Ip=()=>Error(`Invalid signature.`),Lp=e=>Error(`Date(${e.toString()}) expired.`),Rp=e=>Error(`Host(${JSON.stringify(e)}) is not allowed.`);function zp(e,t){let n={};for(let r of Object.keys(e))t.indexOf(r)===-1&&(n[r]=e[r]);return n}function Bp(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+=Bp(e[r],!1)+`,`;return n>-1&&(t+=Bp(e[r],!1)),t+`]`}if(e instanceof Object){if(typeof e.toJSON==`function`)return Bp(e.toJSON(),t);let n=Object.keys(e).sort(),r=n.length,i=``,a=0;for(;a<r;){let t=n[a],r=Bp(e[t],!0);r!==void 0&&(a&&i!==``&&(i+=`,`),i+=JSON.stringify(t)+`:`+r),a++}return`{`+i+`}`}switch(n){case`function`:case`undefined`:return t?void 0:null;case`number`:return 0;default:return isFinite(e)?e:null}}function Vp(e){return String(Bp(e,!1))}function Hp(e){var t,n,r;let i={};try{i=typeof e==`string`?JSON.parse(e):e}catch(e){return Pp()}if(typeof i!=`object`)return Pp();let a=Ap,o=Date.now(),s=new Date(typeof i.expire_at==`string`&&/^\d+$/.test(i.expire_at)?Number(i.expire_at):i.expire_at),c=Array.isArray(i.allow_hosts)?i.allow_hosts:[];if(a.length===0||jp(a)||Op.filter(e=>Mp(e,a)).length>0){let e=String((t=i.certificate)==null?``:t);if(e)try{let t=new z;return t.readCertPEM(e),Ep({issuer:t.getSubjectString(),expire:s,allowHosts:c})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[PARSE Error]: Invalid Certificate. `+t)}return Ep({issuer:`none`,expire:s,allowHosts:c})}let l=String((n=i.certificate)==null?``:n);if(!l)return Fp();let u=new z;u.readCertPEM(l);let d=String((r=i._signature)==null?``:r);return!d||Ct(Vp(zp(i,[`_signature`])),d,u)===!1?Ip():o<s.getTime()?Op.concat(c).filter(e=>Mp(e,a)).length===0?Rp(a):Ep({issuer:u.getSubjectString(),expire:s,allowHosts:c}):Lp(s)}function Up(e,t){let n=Np(e);return Ap.length!==0&&!jp(Ap)&&Op.filter(e=>Mp(e,Ap)).length===0&&!jp(n)&&Op.concat(t).filter(e=>Mp(e,n)).length===0?Rp(n):e}var Wp=new Set,Gp=new c.Vector3(1,1,1),Kp=[`right`,`left`,`up`,`down`,`front`,`back`];function qp(e,t){if(!Sr(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 Jp(e,t,n){return!Sr(e)&&typeof t==`string`&&t.length>0&&(e=wr(t,String(n),e)),e}function Yp(e){for(let t=10;t>=0;t--)if(512*Math.pow(2,t)<=e)return t;return null}function Xp(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 Zp(e,t){var n,r,i,a,o,s,l,u,d,f,p,m,h,g,_,v,y,b,x;let S=[],C=null;for(let t of[].concat(e))if(`getURL`in t)C={allowHosts:t.allowHosts,expire:t.expire,issuer:t.issuer},S.push(sp(t));else{let e=typeof t==`string`?JSON.parse(t):fp(t),n=Hp(e);if(n instanceof Error)return n;C===null&&(C=n),S.push(e)}if(C===null)return Error(`Empty`);V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:C.issuer}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.expire)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(C.allowHosts)});let w=S.reduce((e,t)=>mp(e,t));V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=w.name)==null?`Unknown`:n)}),V(t,`workCode`,{enumerable:!0,writable:!0,value:String(w.resource_code||w.basic_code||w.vr_code||w.code||w.project_id||w.work_code||w.workCode||rn())}),V(t,`projectId`,{enumerable:!0,writable:!0,value:w.project_id}),V(t,`baseURL`,{enumerable:!0,writable:!0,value:(()=>{var e;let t=(e=w.base_url)==null?``:e;return t&&t[t.length-1]!==`/`&&(t+=`/`),t})()});let T;typeof w.model==`object`&&(T={},V(T,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(T,`file`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.file_url;if(e)return qp(e,t.baseURL)})()}),V(T,`textureBase`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=w.model.material_base_url;return e&&(e=qp(e,t.baseURL)),e})()}),V(T,`textures`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e;return Array.isArray(w.model.material_textures)&&(e=w.model.material_textures.slice(),Object.freeze(e)),e})()}),V(T,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:w.model.up_axis}),V(T,`coordinate`,{enumerable:!0,configurable:!1,writable:!1,value:fp(w.model.coordinate)}),V(T,`layers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e,n,r;let i=[];if(Array.isArray(w.model.layers)){for(let a of w.model.layers)if(a&&a.tileset_url){let o={};V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`name`,{enumerable:!0,configurable:!1,writable:!1,value:(e=a.name)==null?``:e}),V(o,`type`,{enumerable:!0,configurable:!1,writable:!1,value:(n=a.type)==null?`mesh`:n}),V(o,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:(r=a.up_axis)==null?`Z`:r}),V(o,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:qp(a.tileset_url,t.baseURL)}),i.push(o)}}if(typeof w.model.tiles==`object`){let e=w.model.tiles;if(e&&e.tileset_url){let n={};V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`lod`}),V(n,`type`,{enumerable:!0,configurable:!1,writable:!1,value:`mesh`}),V(n,`upAxis`,{enumerable:!0,configurable:!1,writable:!1,value:`-Y`}),V(n,`tileset`,{enumerable:!0,configurable:!1,writable:!1,value:qp(e.tileset_url,t.baseURL)}),i.push(n)}}return Object.freeze(i)})()})),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:T});let E=[];if(Array.isArray(w.observers)&&w.panorama&&Array.isArray(w.panorama.list||w.panorama.info)){let e=w.observers,n=(r=w.panorama.list||w.panorama.info)==null?[]:r,S=(u=(s=(a=(i=w.panorama)==null?void 0:i.pano_high_cube_base_url)==null?(o=w.panorama)==null?void 0:o.pano_cube_base_url:a)==null?(l=w.panorama)==null?void 0:l.base_url:s)==null?``:u,C=Math.min(e.length,n.length),T={};for(let e of Object.keys((d=w.panorama.pattern)==null?{}:d)){let t=e,n=w.panorama.pattern[t];if(typeof n==`string`){let e=new Tp(n);T[t]=t=>e.stringify(t)}else T[t]=()=>n}let D=(e,t)=>{var n;let r=T[t];return(n=e[t])==null?r?r(e):void 0:n};for(let r=0;r<C;r++){let i=e[r],a=n[r],o=Object.create(up);V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`index`,{enumerable:!0,configurable:!1,writable:!1,value:r}),V(o,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:r}),V(o,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Z({workCode:t.workCode,panoIndex:r})}),V(o,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:(f=i.floor_index)==null?i.floor:f}),V(o,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:(m=(p=i.derived_id)==null?D(a,`derived_id`):p)==null?0:m}),V(o,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:(g=(h=i.derived_id_str)==null?D(a,`derived_id_str`):h)==null?String(o.derivedId):g}),V(o,`active`,{enumerable:!0,configurable:!1,writable:!1,value:i.active!==!1&&D(a,`active`)!==!1}),V(o,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:(v=(_=i.loadable)==null?D(a,`loadable`):_)==null?!1:v}),V(o,`position`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Vector3().fromArray((y=i.position)==null?[0,0,0]:y))}),V(o,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Vector3().fromArray((x=(b=i.standing_position)==null?i.standingPosition:b)==null?[0,0,0]:x))}),V(o,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Quaternion().fromArray(i.quaternion?[i.quaternion.x,i.quaternion.y,i.quaternion.z,i.quaternion.w]:[0,0,0,1]))}),V(o,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new c.Matrix4().compose(o.position,o.quaternion,Gp))}),V(o,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{if(Wp.clear(),i.accessible_nodes&&Array.isArray(i.accessible_nodes))for(let e of i.accessible_nodes)e>=C||e===r||Wp.add(e);else if(i.accessibleNodes&&Array.isArray(i.accessibleNodes))for(let e of i.accessibleNodes)e>=C||e===r||Wp.add(e);else if(i.visible_nodes&&Array.isArray(i.visible_nodes))for(let e of i.visible_nodes)e>=C||e===r||Wp.add(e);else if(i.visibleNodes&&Array.isArray(i.visibleNodes))for(let e of i.visibleNodes)e>=C||e===r||Wp.add(e);if(Wp.size===0)for(let e=0;e<C;e++)e!==r&&Wp.add(e);let e=Array.from(Wp);return Wp.clear(),Object.freeze(e)})()}),V(o,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:o.accessibleNodes}),V(o,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let n of Kp)V(e,n,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{var e;return qp(Jp((e=D(a,n))==null?``:e,S,r),t.baseURL)})()});return V(e,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let t=$r(e[Kp[0]]),n=D(a,`size_list`),r=D(a,`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([])})()}),V(e,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n=$r(e.front);if(!n)return;let r=e.sizeList.slice();if(r[0]){let e=Yp(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 i=[];for(let a of r){let r=Yp(a);if(typeof r!=`number`)continue;let o={};if(V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>n){V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let t of Kp)V(o,t,{enumerable:!0,configurable:!1,writable:!1,value:ei(e[t],a)})}else{V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:n}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/n});for(let t of Kp)V(o,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]})}i.push(o)}return i=Xp(i),Object.freeze(i)})()}),V(e,`video`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=D(a,`video`),n;return e&&(n={},V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`source`,{enumerable:!0,configurable:!1,writable:!1,value:e.source}),V(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Matrix4().fromArray(e.matrix)}),V(n,`size`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector2().fromArray(e.size)})),n})()}),e})()}),E.push(o)}}V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(E)});let D={};if(V(D,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),w.initial){if(t.observers.length>0){let e;dp(w.initial.panoIndex)?e=w.initial.panoIndex:dp(w.initial.pano_index)?e=w.initial.pano_index:dp(w.initial.pano)&&(e=w.initial.pano),typeof e==`number`&&(e=U(e,0,t.observers.length-1),V(D,`panoIndex`,{enumerable:!0,writable:!0,value:e}))}if(w.initial.mode===`Panorama`&&t.observers.length===0||w.initial.mode===`Floorplan`||w.initial.mode===`Topview`||w.initial.mode===`Model`||w.initial.mode===`Mapview`?V(D,`mode`,{enumerable:!0,writable:!0,value:w.initial.mode}):typeof D.panoIndex==`number`?V(D,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}):V(D,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),dp(w.initial.latitude)&&V(D,`latitude`,{enumerable:!0,writable:!0,value:w.initial.latitude}),dp(w.initial.longitude)?V(D,`longitude`,{enumerable:!0,writable:!0,value:w.initial.longitude}):dp(w.initial.heading)&&V(D,`longitude`,{enumerable:!0,writable:!0,value:Gt(w.initial.heading)}),dp(w.initial.fov)&&V(D,`fov`,{enumerable:!0,writable:!0,value:w.initial.fov}),dp(w.initial.distance)&&V(D,`distance`,{enumerable:!0,writable:!0,value:w.initial.distance}),Array.isArray(w.initial.offset)){let e=w.initial.offset,t=[0,0,0].map((t,n)=>{let r=Number(e[n]);return isNaN(r)||!isFinite(r)?0:r});V(D,`offset`,{enumerable:!0,writable:!0,value:new c.Vector3().fromArray(t)})}else typeof w.initial.offset==`object`&&typeof w.initial.offset.x==`number`&&typeof w.initial.offset.y==`number`&&typeof w.initial.offset.z==`number`&&V(D,`offset`,{enumerable:!0,writable:!0,value:new c.Vector3().fromArray([w.initial.offset.x,w.initial.offset.y,w.initial.offset.z])})}return V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:D}),t}function Qp(e,t){return V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:`Null`}),V(t,`workCode`,{enumerable:!0,value:`null-`+rn()}),V(t,`baseURL`,{enumerable:!0,value:`/`}),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(e,`mode`,{enumerable:!0,writable:!0,value:`Mapview`}),e})()}),t}function $p(e,t){var n,r;return V(t,`issuer`,{enumerable:!0,configurable:!1,writable:!1,value:`null`}),V(t,`expire`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze(new Date)}),V(t,`allowHosts`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([`*`])}),V(t,`name`,{enumerable:!0,configurable:!1,writable:!1,value:String((n=e.name)==null?`Unknown`:n)}),V(t,`workCode`,{enumerable:!0,writable:!0,value:(r=e.code)==null?rn():r}),V(t,`baseURL`,{enumerable:!0,writable:!0,value:`/`}),V(t,`model`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(t,`observers`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};return V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(n,`index`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`panoIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`panoId`,{enumerable:!0,configurable:!1,writable:!1,value:Z({workCode:t.workCode,panoIndex:0})}),V(n,`floorIndex`,{enumerable:!0,configurable:!1,writable:!1,value:0}),V(n,`derivedId`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(n,`derivedIdStr`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),V(n,`active`,{enumerable:!0,configurable:!1,writable:!1,value:!0}),V(n,`loadable`,{enumerable:!0,configurable:!1,writable:!1,value:!1}),V(n,`position`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector3(0,1.5,0)}),V(n,`standingPosition`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Vector3(0,0,0)}),V(n,`quaternion`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Quaternion(0,1,0,0)}),V(n,`matrix`,{enumerable:!0,configurable:!1,writable:!1,value:new c.Matrix4().compose(n.position,n.quaternion,Gp)}),V(n,`accessibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([])}),V(n,`visibleNodes`,{enumerable:!0,configurable:!1,writable:!1,value:n.accessibleNodes}),V(n,`images`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let n={};V(n,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t});for(let t of Kp)V(n,t,{enumerable:!0,configurable:!1,writable:!1,value:e[t]});return V(n,`sizeList`,{enumerable:!0,configurable:!1,writable:!1,value:Object.freeze([e.size])}),V(n,`tiles`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e=$r(n.front);if(!e)return;let r=n.sizeList.slice();if(r[0]){let e=Yp(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 i=[];for(let a of r){let r=Yp(a);if(typeof r!=`number`)continue;let o={};if(V(o,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(o,`level`,{enumerable:!0,configurable:!1,writable:!1,value:r}),a>e){V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:a}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:1});for(let e of Kp)V(o,e,{enumerable:!0,configurable:!1,writable:!1,value:ei(n[e],a)})}else{V(o,`size`,{enumerable:!0,configurable:!1,writable:!1,value:e}),V(o,`scale`,{enumerable:!0,configurable:!1,writable:!1,value:a/e});for(let e of Kp)V(o,e,{enumerable:!0,configurable:!1,writable:!1,value:n[e]})}i.push(o)}return i=Xp(i),Object.freeze(i)})()}),V(n,`video`,{enumerable:!0,configurable:!1,writable:!1,value:void 0}),n})()}),Object.freeze([n])})()}),V(t,`initial`,{enumerable:!0,configurable:!1,writable:!1,value:(()=>{let e={};return V(e,`work`,{enumerable:!1,configurable:!1,writable:!1,value:t}),V(e,`mode`,{enumerable:!0,writable:!0,value:`Panorama`}),V(e,`panoIndex`,{enumerable:!0,writable:!0,value:0}),e})()}),t}var em=new WeakSet,tm=class{constructor(e,t){this.observerBox=new c.Box3,this.observerBox=new c.Box3,this.transform=new c.Matrix4,this.shortPath=!1,this.jsonp=!1;let n;if(n=e===null?Qp(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`?$p(e,this):Zp(e,this),n instanceof Error)throw Error(`[PARSE FAILED]: `+n.message+`
939
939
  Error work input:
940
940
  `+JSON.stringify(e));em.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(sp(e))]}}}}getURL(e){var t;if(!Sr(e)){if(this.jsonp===!0){e=e.replace(/([\?\#].*)?$/i,``);let t=_t(`${e}`).slice(0,7);e=`${e}.${t}.jsonp`}if(this.shortPath===!0){let n=e.replace(e,``).split(`.`),r=(t=n.shift())==null?``:t,i=n.join(`.`);e=_t(r)+(i?`.`+i:``)}e=wr(this.baseURL,e)}return e=Cr(e),e}verifyURL(e){return typeof Up(this.getURL(e),this.allowHosts)==`string`}toJSON(){return sp(this)}};tm.parse=nm;function nm(e,t){typeof e==`string`&&e.trim()[0]===`{`&&(e=JSON.parse(e));try{return new tm(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
- `},gv=class extends c.ShaderMaterial{constructor(e){super({uniforms:c.UniformsUtils.clone(hv.uniforms),vertexShader:hv.vertexShader,fragmentShader:hv.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(gv.prototype,{isLineMaterial:!0});var _v=class extends c.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new mv:e,this.material=t===void 0?new gv({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count),i=new c.Vector3,a=new c.Vector3;for(var o=0,s=0,l=t.count;o<l;o++,s+=2)i.fromBufferAttribute(t,o),a.fromBufferAttribute(n,o),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+i.distanceTo(a);let u=new c.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new c.InterleavedBufferAttribute(u,1,0)),e.setAttribute(`instanceDistanceEnd`,new c.InterleavedBufferAttribute(u,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,i=r.projectionMatrix,a=this.geometry,o=this.material,s=o.resolution,l=o.linewidth,u=a.attributes.instanceStart,d=a.attributes.instanceEnd,f=new c.Vector4,p=new c.Vector4,m=new c.Vector4,h=new c.Vector3,g=new c.Matrix4,_=new c.Line3,v=new c.Vector3;n.at(1,m),m.w=1,m.applyMatrix4(r.matrixWorldInverse),m.applyMatrix4(i),m.multiplyScalar(1/m.w),m.x*=s.x/2,m.y*=s.y/2,m.z=0,h.copy(m);let y=this.matrixWorld;g.multiplyMatrices(r.matrixWorldInverse,y);for(var b=0,x=u.count;b<x;b++){f.fromBufferAttribute(u,b),p.fromBufferAttribute(d,b),f.w=1,p.w=1,f.applyMatrix4(g),p.applyMatrix4(g),f.applyMatrix4(i),p.applyMatrix4(i),f.multiplyScalar(1/f.w),p.multiplyScalar(1/p.w);var S=f.z<-1&&p.z<-1,C=f.z>1&&p.z>1;if(S||C)continue;f.x*=s.x/2,f.y*=s.y/2,p.x*=s.x/2,p.y*=s.y/2,_.start.copy(f),_.start.z=0,_.end.copy(p),_.end.z=0;let e=_.closestPointToPointParameter(h,!0);_.at(e,v);let r=c.MathUtils.lerp(f.z,p.z,e),a=r>=-1&&r<=1;var w=h.distanceTo(v)<l*.5;if(a&&w){_.start.fromBufferAttribute(u,b),_.end.fromBufferAttribute(d,b),_.start.applyMatrix4(y),_.end.applyMatrix4(y);var T=new c.Vector3,E=new c.Vector3;n.distanceSqToSegment(_.start,_.end,E,T),t.push({point:E,pointOnLine:T,distance:n.origin.distanceTo(E),object:this,faceIndex:b})}}}};Object.assign(_v.prototype,{isLineSegments2:!0});var vv=class extends _v{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(vv.prototype,{isLine2:!0});var yv=class extends mv{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 c.Geometry){let e=new c.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof c.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}copy(){return this}};Object.assign(yv.prototype,{isLineGeometry:!0});var bv=14467195,xv=8,Sv=2,Cv=20,wv=null,Tv=class extends c.Object3D{static get version(){return`6.8.0`}constructor(e=new c.Vector3,t=new c.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0,this.line=new vv(new yv,new gv({color:bv,linewidth:Sv,dashScale:Cv,dashed:!1}));let n=new c.BufferGeometry,r=new c.PointsMaterial({color:bv,size:xv,map:wv||(wv=new c.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 c.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 c.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 c.Vector3(e[0],e[1],e[2]),new c.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(Tv.prototype,{isFiveLine:!0});var Ev={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 Dv(e){return Go(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function Ov(e){return Go(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield Dv(`${e}/profilesList.json`)})}function kv(e,t){return Go(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 i=yield Ov(t),a;if(e.profiles.some(e=>{let n=i[e];return n&&(a={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!n)throw Error(`No matching profile name found`);let e=i[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);a={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let o=yield Dv(a.profilePath),s;if(r){let t;if(t=o.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${a.profileId}`);t.assetPath&&(s=a.profilePath.replace(`profile.json`,t.assetPath))}return{profile:o,assetPath:s}})}var Av={xAxis:0,yAxis:0,button:0,state:Ev.ComponentState.DEFAULT};function jv(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let i=Math.atan2(t,e);n=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var Mv=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ev.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Av)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:i,normalizedYAxis:a}=jv(e,t);switch(this.componentProperty){case Ev.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?i:.5;break;case Ev.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case Ev.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case Ev.ComponentProperty.STATE:this.valueNodeProperty===Ev.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}`)}}},Nv=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 Mv(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ev.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=Ev.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=Ev.ComponentState.PRESSED:(t.touched||this.values.button>Ev.ButtonTouchThreshold)&&(this.values.state=Ev.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===Ev.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ev.AxisTouchThreshold&&(this.values.state=Ev.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===Ev.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ev.AxisTouchThreshold&&(this.values.state=Ev.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},Pv=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 Nv(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)})}},Fv=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,Iv=`generic-trigger`,Lv=class extends c.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof c.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:i,valueNodeProperty:a}=e;t&&(a===Ev.VisualResponseProperty.VISIBILITY?t.visible=i:a===Ev.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,i),t.position.lerpVectors(n.position,r.position,i)))})}))}};function Rv(e,t){Object.values(e.components).forEach(e=>{let{type:n,touchPointNodeName:r,visualResponses:i}=e;if(n===Ev.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){let t=new c.Mesh(new c.SphereGeometry(.001),new c.MeshBasicMaterial({color:255}));e.touchPointNode.add(t)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(i).forEach(e=>{let{valueNodeName:n,minNodeName:r,maxNodeName:i,valueNodeProperty:a}=e;if(a===Ev.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(r),e.maxNode=t.getObjectByName(i),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${i} in the model`);return}}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)})})}function zv(e,t){Rv(e.motionController,t),e.envMap&&t.traverse(t=>{t instanceof c.Mesh&&t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)}),e.add(t)}var Bv=class{constructor(e=null){this.gltfLoader=e,this.path=Fv,this._assetCache={}}createControllerModel(e){let t=new Lv,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||kv(r,this.path,Iv).then(({profile:e,assetPath:i})=>{t.motionController=new Pv(r,e,i);let a=this._assetCache[t.motionController.assetUrl];if(a)n=a.scene.clone(),zv(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(),zv(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},Vv=Object.assign({},yr(r_,[`maxLatitude`,`minLatitude`]));function Hv(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 Uv=300,Wv=new c.Raycaster,Gv=new c.Vector3,Kv={Floorplan:rg,Topview:ag,Panorama:i_,VRPanorama:Y_,Model:ev,Mapview:ov,XRPanorama:class e extends i_{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 pv(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,Q(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,Q(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new c.Raycaster,right:new c.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 Tv,right:new Tv},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new c.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new c.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new c.Group,new c.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 Bv;r.gltfLoader={load(e,t){_r.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return ds(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:_r})}).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=rn()]={panoId:Z(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:`fade`,effectEasing:$g,fixCameraTransform:new c.Matrix4},this.parallaxCameraMatrixs=[];let i=si.shared.getContext();if(!i){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(i),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,i,a;let o=(r=t.effect)==null?`fade`:r;this.userAction=n,this.stopMomentumMovement();let s=Z(e),l=this.works.getObserver(e);if(!l)throw Error(`Invalid PanoIndex`);let u=$r(l.images.up),d=this.imageOptions.size;d===void 0&&l&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=(e,t)=>Hv(Zr(e,f,t)),m=Object.assign({key:`pano.${s}`},vr(this.imageOptions,[`format`,`size`,`quality`])),h={right:l.images.work.getURL(l.images.right),left:l.images.work.getURL(l.images.left),up:l.images.work.getURL(l.images.up),down:l.images.work.getURL(l.images.down),front:l.images.work.getURL(l.images.front),back:l.images.work.getURL(l.images.back)},g=`pano:`+_p([h,m,f]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===g)return;{let t=this.pendingPanoTask.panoId;(i=this.panoMeshes.get(t))==null||i.setProgress(0),this.emit(`pano.texture.abort`,Q(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let _=`move-to-pano-`+s;this.pending.add(_);let v=Ah(`pano.prepare`,{prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,v),v.defaultPrevented){this.pending.delete(_);return}let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===g?b=y.pano0:y.pano1&&y.pano1.map.name===g&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?$g:a,leftPanoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};n.leftPanoPicture&&this.panoPictureObserverMap.set(n.leftPanoPicture,l),this.pendingPanoTask=void 0,Promise.resolve().then(()=>jh(v)).catch(e=>{let t=$h(e);return this.emit(`error`,t),t}).then(r=>{var i,a;if(!(r instanceof Error))this.pending.delete(_),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.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}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(_),this.pendingPanoTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)}});return}let x=this.panoMeshes.get(s);x&&x.tap&&x.tap(),this.pendingPanoTask={panoId:s,hash:g,onLoad:n=>{var r,i;let a=n.body;if(this.destroyed)a.dispose();else{a.name=g;let n=Array.isArray(a.image)?a.image[0]:a.image,u=(r=n==null?void 0:n.width)==null?2048:r,d=new bm().formPixels(qh(this.renderer,a,!0,gm).data),f={panoId:s,effect:o,effectEasing:(i=t.effectEasing)==null?$g:i,leftPanoPicture:{panoId:s,map:a,mapSize:u,mapHistogram:new c.Vector4().fromArray(d.toArray()),matrix:l.matrix.clone(),zoom:1},position:l.position.clone(),fixCameraTransform:new c.Matrix4};f.leftPanoPicture&&this.panoPictureObserverMap.set(f.leftPanoPicture,l),this.doMoveToPano(e,f,t)}},onError:e=>{let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.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`,Q(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(h,{imageURL:{transform:p,options:m},format:c.RGBFormat,viaAjax:!0,fetcher:Ef(this.fiveId,l.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,Q(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===g&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=$h(t);return this.emit(`pano.texture.error`,Q(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>jh(v)).catch(e=>$h(e))]).then(([t,n])=>{var r,i,a,o;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(_),((r=this.pendingPanoTask)==null?void 0:r.hash)===g?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,Q(`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(_),((a=this.pendingPanoTask)==null?void 0:a.hash)===g&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(s))==null||o.setProgress(0))}})}doMoveToPano(e,t,n={}){var r,i,a,o,s,l,u,d,f,p;let m=H(),h=rn();this.panoResources[h]=t;let g,_,v;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(n).position,a=t.position;g=Math.max(i.distanceTo(a),1),_=[{key:n.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:h,progress:1,value:{distance:0,count:1}}],v=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(n).position,o=t.position,s=n.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;g=c+Math.max(a.distanceTo(o),1),_=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/g,value:n.value},{key:h,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(_);v=this.locationMotion.getProgressVelocity(m)*l/u}let y=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?g:0),b={longitude:n.longitude,latitude:n.latitude,fov:n.fov},x=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(r=b.longitude)==null?this.camera.pose.longitude:r,latitude:(i=b.latitude)==null?this.camera.pose.latitude:i,fov:(a=b.fov)==null?this.camera.pose.fov:a,offset:t.position.clone(),distance:0}),S=this.currentPano;if(this.emit(`pano.moveTo`,Q(`pano.moveTo`,{options:n,prevPano:S,pano:{panoIndex:x.panoIndex,workCode:x.workCode},progress:0,state:x,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(x),this.perspToOrthoMotion.set({perspToOrtho:0},y).catch(K),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],y).catch(K),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=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(b,y).catch(K);else{let e=Ht({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=Ht({longitude:(o=b.longitude)==null?this.cameraMotion.value.longitude:o,latitude:(s=b.latitude)==null?this.cameraMotion.value.latitude:s}),r=new c.Object3D;r.lookAt(e);let i=new c.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new c.Matrix4().makeRotationFromQuaternion(r.quaternion),m=new c.Matrix4().getInverse(i).premultiply(a),h=this.cameraMotion.value.fov,g=(l=b.fov)==null?this.cameraMotion.value.fov:l,v=1;t.effect===`zoomin`?v=1.5:t.effect===`zoomout`&&(v=.4);let x=g*v;for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(m),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(x/2/180*Math.PI)/Math.tan(h/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:(u=b.longitude)==null?this.cameraMotion.value.longitude:u,latitude:(d=b.latitude)==null?this.cameraMotion.value.latitude:d,fov:x}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:g}}],y).catch(K)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof Gf&&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`,Q(`pano.arrived`,{options:n,prevPano:S,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=rn(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),ug().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,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}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{options:n,prevPano:S,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 c.Vector3).setY(0);let n=null,r=this.works.getObserver(this.currentPano);if(!r)return null;let i=r.work.observers,a=r.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&r.work.workCode===this.currentPano.workCode)return!1;let t=i[e];return!t||Gv.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[o]=this.modelScene.intersectRaycaster(e);if(o){let[e,r]=Hl(a,e=>{let t=i[e];return t?Gv.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(o.point):1/0},!0);typeof e==`number`&&r<this.panoTapTriggerRadius&&(n=(t=i[e])==null?null:t)}if(sv(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=Z({panoIndex:n.panoIndex,workCode:n.work.workCode});if(t.panoId===e){n=null;break}}}if(sv(n))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!n.active){let e=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let s={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 c.Vector3};return this.emit(`pano.select`,Q(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:s.panoIndex,workCode:s.workCode},state:s,userAction:!0,options:{},progress:0,error:null})),n&&n.active?(this.emit(`pano.request`,Q(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:s.panoIndex,workCode:s.workCode},progress:0,state:s,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,i,a,o,s,l,u,d,f;this.userAction=!0;let p={},m={},h=this.camera.getDirection(new c.Vector3),g=this.locationMotion.keyframes[0],_=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[v,y]=this.locationMotion.getKeyFrameSegment(e),b=this.panoResourceFromLocationMotionKeyframe(v),x=this.panoResourceFromLocationMotionKeyframe(y),S=this.panoResourceFromLocationMotionKeyframe(g),C=this.panoResourceFromLocationMotionKeyframe(_),w=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),m.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),p.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(U(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-y.value.count+1,n=new c.Vector3().copy(b.position),a=new c.Vector3().copy(x.position);if(p.progress=t,t>=.01&&t<=.99&&(p.progress=U(x.effectEasing(t),.01,.99)),x.leftPanoPicture&&(t<1?b.leftPanoPicture&&(p.pano0=b.leftPanoPicture):p.pano0=x.leftPanoPicture,p.pano1=x.leftPanoPicture),x.effect===`montage`?p.transition=`BLACK`:x.effect===`spread`?p.transition=`SPREAD`:p.transition=`FADE`,x.effect===`zoomin`||x.effect===`zoomout`?p.progress=Math.pow(t,3):x.effect===`model`&&this.camera.pose.distance<.01&&(p.modelAlpha=1-Math.pow(U(Math.abs(t-.5)*2,0,1),4)),t<1&&x.effect!==`fly`){if(p.pano0&&b.leftPanoPicture){let e={panoId:p.pano0.panoId,map:p.pano0.map,mapHistogram:p.pano0.mapHistogram,mapSize:p.pano0.mapSize,zoom:p.pano0.zoom,matrix:b.leftPanoPicture.matrix.clone().setPosition(x.position)},t=this.panoPictureObserverMap.get(p.pano0);t&&this.panoPictureObserverMap.set(e,t),p.pano0=e}n.copy(a),w=!0}m.distance=this.locationMotion.value.distance,m.offset=new c.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((r=p.pano0)==null?void 0:r.map)||e===((i=p.pano1)==null?void 0:i.map))continue;e.dispose(),t.leftPanoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let l=yp(x.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,Q(`pano.moving`,{userAction:this.userAction,prevPano:yp(S.panoId),pano:yp(C.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},yp(C.panoId)),{mode:this.mode}),$(this.camera.pose)),m),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(m),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[T,E]=n,D=new c.Vector3(0,0,0),O=new c.Vector2().copy(this.camera.resolution);if(E&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let n=this.xrManager.cameraVR,r=this.xrManager.referenceSpace,i=this.xrManager.session.renderState.baseLayer,l=E.getViewerPose(r),u=(a=l==null?void 0:l.views)==null?[]:a;for(let e=0;e<u.length;e++){let t=u[e],r=n.cameras[e],a=i.getViewport(t);a&&(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,D.copy(r.position),r.viewport.set(a.x,a.y,a.width,a.height),O.set(a.width,a.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((o=m.distance)==null?this.camera.pose.distance:o),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=E.getPose(this.xrManager.session.inputSources[e].targetRaySpace,r);if(t){let e=t.transform.orientation,n=new c.Quaternion(e.x,e.y,e.z,e.w),r=new c.Vector3(0,0,-1).applyQuaternion(n);this.gazeRay=new c.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],i=n[e];if(!i)continue;t&&t.update(i,E,r);let a=this.xrManager.getController(e),o=new c.Vector3(0,1.2,0),l=a.position.clone().add(D).sub(o);i.handedness===`left`?this.xrControllerRay.left.set(l,new c.Vector3(0,0,-1).applyEuler(a.rotation)):i.handedness===`right`&&this.xrControllerRay.right.set(l,new c.Vector3(0,0,-1).applyEuler(a.rotation)),this.controllerWrappers[e].position.copy(new c.Vector3(0,0,0).add(D).sub(o));let u=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(u.length===0){let e=this.works.getResolvedObserver(this.currentPano);u=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(u.length>=1&&u[0].face)if(i.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=u[0].face.normal,n=t.clone(),r=u[0].point.clone();this.intersectMesh.position.copy(r);let i=r.clone().add(n);if(this.intersectMesh.lookAt(i),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(l,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(l,u[0].point));let a=u[0],o=Q(`intersect.update`,{raycaster:(s=this.xrControllerRay.right)==null?null:s,intersection:a==null?null:a,object:this.intersectMesh});if(this.emit(`intersect.update`,o),o.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(l,u[0].point)}this.updateControllerHelper(n,e,t)}}else E||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);zh(p)===!1&&this.modelScene.parameter.set(p),this.emit(`camera.update`,Q(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose))}));let k=this.works.getResolvedObserver(this.currentPano),A=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,j=this.works.getObserver(b.panoId),M=this.works.getObserver(x.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&k){let e=[],t=k.work.observers;for(let n of k.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(k.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(k.standingPosition),n.set(t,i)),r-i}),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=.005,i=t.standingPosition.clone().applyMatrix4(t.work.transform),a=Z({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=n_.map(t=>{Wv.ray.origin.copy(i),Wv.ray.origin.add(Gv.copy(t).setY(e)),Wv.ray.direction.set(0,-1,0),Wv.firstHitOnly=!0,Wv.floorIndex=-1;let[a]=n.intersectRaycaster(Wv);return a&&a.distance-r<=e?new c.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[l]=o.filter(e=>e.distanceTo(s)<=.05);if(l){let e=new c.Vector4(i.x,i.y,i.z,l.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let N=new Map;if(j)for(let e of j.accessibleNodes){let t=j.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(M)for(let e of M.accessibleNodes){let t=M.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{N.get(t)?N.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),N.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),N.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&&(Gv.set(t.x,t.y,t.z),Gv.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new c.Vector3().copy(e.position).sub(i).normalize();if(t===Z(this.currentPano)){let t=U((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(h.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new c.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||w)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(k){let n=k.work.observers,[,r]=Hl(k.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:k.standingPosition.distanceTo(t.standingPosition)},!0);r=U(r,2.5,1/0);let i=k.accessibleNodes.concat(k.panoIndex).map(e=>Z({panoIndex:e,workCode:k.work.workCode}));this.panoMeshes.forEach((n,a)=>{let o=this.works.getObserver(a),s=!1,c=1;if(i.indexOf(a)===-1)s=!1,c=0;else if(!o)s=!1,c=0;else if(!o.loadable&&!o.active)s=!1,c=0;else{let e=n.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&A!==null&&Z({panoIndex:A.panoIndex,workCode:A.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:U(r/t,.1,.85)}o&&o===M&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(c=0),n.setCurrent(s),n.setOpacity(c),n.updateTime&&n.updateTime(e,t)})}{let e=(l=this.modelScene.parameter.progress)==null?1:l,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,a;if(i&&(a=this.works.getObserver(i.panoId),a||(a=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(di()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!a||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new c.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=ni(i.mapSize)+1;this.tiling.setObserver(a);let o={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:i.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:e,level:4},s=this.tiling.update(o),c={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:Xu(Math.abs(((u=this.modelScene.parameter.progress)==null?0:u)-.5)*2)},l=this.modelScene.parameter.refinedScreen;(s||c.pano!==(l==null?void 0:l.pano)||c.opacity!==(l==null?void 0:l.opacity))&&this.modelScene.parameter.set(`refinedScreen`,c)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&k&&k.position.y-k.standingPosition.y>10){let e=U(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=x.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((d=this.modelScene.parameter.pano0Depth)==null?void 0:d.panoId)!==t.panoId||((f=this.modelScene.parameter.pano1Depth)==null?void 0:f.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new c.WebGLCubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new c.WebGLCubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1});let e=new c.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,Qg(this.renderer,this.modelScene,e,500);let r=new c.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,Qg(this.renderer,this.modelScene,r,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,i=this.xrControllerRay.right;if(!e||e.length===0)return;let a={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let o=0;o<e.length;o++){let s=e[o].handedness,c=e[o].gamepad;switch(s){case`left`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`LeftAxesDown`,t)),c!=null&&c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`X`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`Y`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`LeftTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n};a.buttons.X=c.buttons&&c.buttons[4]?c.buttons[4].pressed:!1,a.buttons.Y=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.LeftTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.LeftPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1,a.left=e;break;case`right`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`RightAxesDown`,t)),c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`A`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`B`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`RightTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`RightPinch`,t)),a.right={raycaster:i,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n},a.buttons.A=c.buttons&&c.buttons[4]?c==null?void 0:c.buttons[4].pressed:!1,a.buttons.B=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.RightTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.RightPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,Q(`xr.controller.update`,a))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,i=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`,Q(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}))):n-this.xrHandleState[t].touchStartTime>Uv&&this.emit(`xr.gesture.press`,Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,Q(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}})),n-this.xrHandleState[t].touchStartTime<=Uv){let e=Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}});!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)})}}},qv={Floorplan:ng,Topview:ig,Panorama:r_,VRPanorama:J_,Model:$_,Mapview:av,XRPanorama:Vv},Jv=`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 Yv(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=Ht(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 Xv(){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 Zv(){let e=new c.Group;e.name=`internalLights`;{let t=new c.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new c.Vector3(0,1,0)),e.add(t)}{let t=new c.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new c.Vector3(-1,-1,-1)),e.add(t)}{let t=new c.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new c.Vector3(1,1,1)),e.add(t)}{let t=new c.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function Qv(e){var t,n;let r={},i=e.split(/(\;|\,)/);for(let e of i){let i=e.split(`=`),a=(t=i[0])==null?void 0:t.trim(),o=(n=i[1])==null?void 0:n.trim();a&&o&&(r[a]=o)}return r}function $v(){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=Qv((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var ey=`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==`,ty=[351,63],ny=[20,20],ry=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),iy=new Float32Array([0,0,1,0,0,1,1,1]),ay=new Uint8Array([0,1,2,1,3,2]),oy=new c.BufferGeometry;oy.setAttribute(`position`,new c.BufferAttribute(ry,3)),oy.setAttribute(`uv`,new c.BufferAttribute(iy,2)),oy.setIndex(new c.BufferAttribute(ay,1));var sy=new c.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),cy=new c.Mesh(oy,sy);cy.matrixAutoUpdate=!1;var ly=new c.Scene;ly.add(cy),ly.matrixAutoUpdate=!1;var uy=new c.OrthographicCamera(-.5,.5,.5,-.5,.1,1);uy.position.set(0,0,.5),uy.lookAt(0,0,0),uy.updateMatrixWorld(!0),uy.matrixAutoUpdate=!1;var dy=new c.Vector4,fy=new c.Vector4;function py(e){if(sy.map){let t=e.getViewport(dy),n=e.getScissor(fy),r=e.getScissorTest(),i=e.autoClear,a=n.x+ny[0]/3,o=n.y+ny[1]/3,s=ty[0]/3,c=ty[1]/3;e.setViewport(a,o,s,c),e.setScissor(a,o,s,c),e.setScissorTest(!0),e.autoClear=!1,e.render(ly,uy),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=i}else{let e=new c.Texture,t=new Image;t.onload=()=>{e.image=t,e.wrapS=c.ClampToEdgeWrapping,e.wrapT=c.ClampToEdgeWrapping,e.minFilter=c.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,sy.needsUpdate=!0,t.onload=K},t.src=ey,sy.map=e}}var my=`(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
+ `},gv=class extends c.ShaderMaterial{constructor(e){super({uniforms:c.UniformsUtils.clone(hv.uniforms),vertexShader:hv.vertexShader,fragmentShader:hv.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(gv.prototype,{isLineMaterial:!0});var _v=class extends c.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new mv:e,this.material=t===void 0?new gv({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count),i=new c.Vector3,a=new c.Vector3;for(var o=0,s=0,l=t.count;o<l;o++,s+=2)i.fromBufferAttribute(t,o),a.fromBufferAttribute(n,o),r[s]=s===0?0:r[s-1],r[s+1]=r[s]+i.distanceTo(a);let u=new c.InstancedInterleavedBuffer(r,2,1);return e.setAttribute(`instanceDistanceStart`,new c.InterleavedBufferAttribute(u,1,0)),e.setAttribute(`instanceDistanceEnd`,new c.InterleavedBufferAttribute(u,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,i=r.projectionMatrix,a=this.geometry,o=this.material,s=o.resolution,l=o.linewidth,u=a.attributes.instanceStart,d=a.attributes.instanceEnd,f=new c.Vector4,p=new c.Vector4,m=new c.Vector4,h=new c.Vector3,g=new c.Matrix4,_=new c.Line3,v=new c.Vector3;n.at(1,m),m.w=1,m.applyMatrix4(r.matrixWorldInverse),m.applyMatrix4(i),m.multiplyScalar(1/m.w),m.x*=s.x/2,m.y*=s.y/2,m.z=0,h.copy(m);let y=this.matrixWorld;g.multiplyMatrices(r.matrixWorldInverse,y);for(var b=0,x=u.count;b<x;b++){f.fromBufferAttribute(u,b),p.fromBufferAttribute(d,b),f.w=1,p.w=1,f.applyMatrix4(g),p.applyMatrix4(g),f.applyMatrix4(i),p.applyMatrix4(i),f.multiplyScalar(1/f.w),p.multiplyScalar(1/p.w);var S=f.z<-1&&p.z<-1,C=f.z>1&&p.z>1;if(S||C)continue;f.x*=s.x/2,f.y*=s.y/2,p.x*=s.x/2,p.y*=s.y/2,_.start.copy(f),_.start.z=0,_.end.copy(p),_.end.z=0;let e=_.closestPointToPointParameter(h,!0);_.at(e,v);let r=c.MathUtils.lerp(f.z,p.z,e),a=r>=-1&&r<=1;var w=h.distanceTo(v)<l*.5;if(a&&w){_.start.fromBufferAttribute(u,b),_.end.fromBufferAttribute(d,b),_.start.applyMatrix4(y),_.end.applyMatrix4(y);var T=new c.Vector3,E=new c.Vector3;n.distanceSqToSegment(_.start,_.end,E,T),t.push({point:E,pointOnLine:T,distance:n.origin.distanceTo(E),object:this,faceIndex:b})}}}};Object.assign(_v.prototype,{isLineSegments2:!0});var vv=class extends _v{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(vv.prototype,{isLine2:!0});var yv=class extends mv{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 c.Geometry){let e=new c.BufferGeometry().fromGeometry(t);this.setPositions(e.attributes.position.array)}else t instanceof c.BufferGeometry&&this.setPositions(t.attributes.position.array);return this}copy(){return this}};Object.assign(yv.prototype,{isLineGeometry:!0});var bv=14467195,xv=8,Sv=2,Cv=20,wv=null,Tv=class extends c.Object3D{static get version(){return`6.8.1`}constructor(e=new c.Vector3,t=new c.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0,this.line=new vv(new yv,new gv({color:bv,linewidth:Sv,dashScale:Cv,dashed:!1}));let n=new c.BufferGeometry,r=new c.PointsMaterial({color:bv,size:xv,map:wv||(wv=new c.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 c.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 c.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 c.Vector3(e[0],e[1],e[2]),new c.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(Tv.prototype,{isFiveLine:!0});var Ev={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 Dv(e){return Go(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function Ov(e){return Go(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield Dv(`${e}/profilesList.json`)})}function kv(e,t){return Go(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 i=yield Ov(t),a;if(e.profiles.some(e=>{let n=i[e];return n&&(a={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!n)throw Error(`No matching profile name found`);let e=i[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);a={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let o=yield Dv(a.profilePath),s;if(r){let t;if(t=o.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${a.profileId}`);t.assetPath&&(s=a.profilePath.replace(`profile.json`,t.assetPath))}return{profile:o,assetPath:s}})}var Av={xAxis:0,yAxis:0,button:0,state:Ev.ComponentState.DEFAULT};function jv(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let i=Math.atan2(t,e);n=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var Mv=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===Ev.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Av)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:i,normalizedYAxis:a}=jv(e,t);switch(this.componentProperty){case Ev.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?i:.5;break;case Ev.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case Ev.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case Ev.ComponentProperty.STATE:this.valueNodeProperty===Ev.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}`)}}},Nv=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 Mv(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:Ev.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=Ev.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=Ev.ComponentState.PRESSED:(t.touched||this.values.button>Ev.ButtonTouchThreshold)&&(this.values.state=Ev.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===Ev.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Ev.AxisTouchThreshold&&(this.values.state=Ev.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===Ev.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Ev.AxisTouchThreshold&&(this.values.state=Ev.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},Pv=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 Nv(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)})}},Fv=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,Iv=`generic-trigger`,Lv=class extends c.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof c.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:i,valueNodeProperty:a}=e;t&&(a===Ev.VisualResponseProperty.VISIBILITY?t.visible=i:a===Ev.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,i),t.position.lerpVectors(n.position,r.position,i)))})}))}};function Rv(e,t){Object.values(e.components).forEach(e=>{let{type:n,touchPointNodeName:r,visualResponses:i}=e;if(n===Ev.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){let t=new c.Mesh(new c.SphereGeometry(.001),new c.MeshBasicMaterial({color:255}));e.touchPointNode.add(t)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(i).forEach(e=>{let{valueNodeName:n,minNodeName:r,maxNodeName:i,valueNodeProperty:a}=e;if(a===Ev.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(r),e.maxNode=t.getObjectByName(i),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${i} in the model`);return}}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)})})}function zv(e,t){Rv(e.motionController,t),e.envMap&&t.traverse(t=>{t instanceof c.Mesh&&t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)}),e.add(t)}var Bv=class{constructor(e=null){this.gltfLoader=e,this.path=Fv,this._assetCache={}}createControllerModel(e){let t=new Lv,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||kv(r,this.path,Iv).then(({profile:e,assetPath:i})=>{t.motionController=new Pv(r,e,i);let a=this._assetCache[t.motionController.assetUrl];if(a)n=a.scene.clone(),zv(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(),zv(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},Vv=Object.assign({},yr(r_,[`maxLatitude`,`minLatitude`]));function Hv(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 Uv=300,Wv=new c.Raycaster,Gv=new c.Vector3,Kv={Floorplan:rg,Topview:ag,Panorama:i_,VRPanorama:Y_,Model:ev,Mapview:ov,XRPanorama:class e extends i_{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 pv(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,Q(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,Q(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new c.Raycaster,right:new c.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 Tv,right:new Tv},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new c.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new c.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new c.Group,new c.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 Bv;r.gltfLoader={load(e,t){_r.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return ds(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:_r})}).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=rn()]={panoId:Z(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:`fade`,effectEasing:$g,fixCameraTransform:new c.Matrix4},this.parallaxCameraMatrixs=[];let i=si.shared.getContext();if(!i){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(i),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,i,a;let o=(r=t.effect)==null?`fade`:r;this.userAction=n,this.stopMomentumMovement();let s=Z(e),l=this.works.getObserver(e);if(!l)throw Error(`Invalid PanoIndex`);let u=$r(l.images.up),d=this.imageOptions.size;d===void 0&&l&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=(e,t)=>Hv(Zr(e,f,t)),m=Object.assign({key:`pano.${s}`},vr(this.imageOptions,[`format`,`size`,`quality`])),h={right:l.images.work.getURL(l.images.right),left:l.images.work.getURL(l.images.left),up:l.images.work.getURL(l.images.up),down:l.images.work.getURL(l.images.down),front:l.images.work.getURL(l.images.front),back:l.images.work.getURL(l.images.back)},g=`pano:`+_p([h,m,f]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===g)return;{let t=this.pendingPanoTask.panoId;(i=this.panoMeshes.get(t))==null||i.setProgress(0),this.emit(`pano.texture.abort`,Q(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let _=`move-to-pano-`+s;this.pending.add(_);let v=Ah(`pano.prepare`,{prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,v),v.defaultPrevented){this.pending.delete(_);return}let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===g?b=y.pano0:y.pano1&&y.pano1.map.name===g&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?$g:a,leftPanoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};n.leftPanoPicture&&this.panoPictureObserverMap.set(n.leftPanoPicture,l),this.pendingPanoTask=void 0,Promise.resolve().then(()=>jh(v)).catch(e=>{let t=$h(e);return this.emit(`error`,t),t}).then(r=>{var i,a;if(!(r instanceof Error))this.pending.delete(_),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.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}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(_),this.pendingPanoTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)}});return}let x=this.panoMeshes.get(s);x&&x.tap&&x.tap(),this.pendingPanoTask={panoId:s,hash:g,onLoad:n=>{var r,i;let a=n.body;if(this.destroyed)a.dispose();else{a.name=g;let n=Array.isArray(a.image)?a.image[0]:a.image,u=(r=n==null?void 0:n.width)==null?2048:r,d=new bm().formPixels(qh(this.renderer,a,!0,gm).data),f={panoId:s,effect:o,effectEasing:(i=t.effectEasing)==null?$g:i,leftPanoPicture:{panoId:s,map:a,mapSize:u,mapHistogram:new c.Vector4().fromArray(d.toArray()),matrix:l.matrix.clone(),zoom:1},position:l.position.clone(),fixCameraTransform:new c.Matrix4};f.leftPanoPicture&&this.panoPictureObserverMap.set(f.leftPanoPicture,l),this.doMoveToPano(e,f,t)}},onError:e=>{let n=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.work.workCode},progress:0,state:n})),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:t,prevPano:this.currentPano,pano:{panoIndex:l.panoIndex,workCode:l.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`,Q(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(h,{imageURL:{transform:p,options:m},format:c.RGBFormat,viaAjax:!0,fetcher:Ef(this.fiveId,l.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,Q(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===g&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=$h(t);return this.emit(`pano.texture.error`,Q(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>jh(v)).catch(e=>$h(e))]).then(([t,n])=>{var r,i,a,o;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(_),((r=this.pendingPanoTask)==null?void 0:r.hash)===g?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,Q(`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(_),((a=this.pendingPanoTask)==null?void 0:a.hash)===g&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(s))==null||o.setProgress(0))}})}doMoveToPano(e,t,n={}){var r,i,a,o,s,l,u,d,f,p;let m=H(),h=rn();this.panoResources[h]=t;let g,_,v;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(n).position,a=t.position;g=Math.max(i.distanceTo(a),1),_=[{key:n.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:h,progress:1,value:{distance:0,count:1}}],v=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(n).position,o=t.position,s=n.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;g=c+Math.max(a.distanceTo(o),1),_=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/g,value:n.value},{key:h,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(_);v=this.locationMotion.getProgressVelocity(m)*l/u}let y=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?g:0),b={longitude:n.longitude,latitude:n.latitude,fov:n.fov},x=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(r=b.longitude)==null?this.camera.pose.longitude:r,latitude:(i=b.latitude)==null?this.camera.pose.latitude:i,fov:(a=b.fov)==null?this.camera.pose.fov:a,offset:t.position.clone(),distance:0}),S=this.currentPano;if(this.emit(`pano.moveTo`,Q(`pano.moveTo`,{options:n,prevPano:S,pano:{panoIndex:x.panoIndex,workCode:x.workCode},progress:0,state:x,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(x),this.perspToOrthoMotion.set({perspToOrtho:0},y).catch(K),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],y).catch(K),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=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(b,y).catch(K);else{let e=Ht({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=Ht({longitude:(o=b.longitude)==null?this.cameraMotion.value.longitude:o,latitude:(s=b.latitude)==null?this.cameraMotion.value.latitude:s}),r=new c.Object3D;r.lookAt(e);let i=new c.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new c.Matrix4().makeRotationFromQuaternion(r.quaternion),m=new c.Matrix4().getInverse(i).premultiply(a),h=this.cameraMotion.value.fov,g=(l=b.fov)==null?this.cameraMotion.value.fov:l,v=1;t.effect===`zoomin`?v=1.5:t.effect===`zoomout`&&(v=.4);let x=g*v;for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(m),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(x/2/180*Math.PI)/Math.tan(h/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:(u=b.longitude)==null?this.cameraMotion.value.longitude:u,latitude:(d=b.latitude)==null?this.cameraMotion.value.latitude:d,fov:x}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:g}}],y).catch(K)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof Gf&&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`,Q(`pano.arrived`,{options:n,prevPano:S,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=rn(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),ug().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,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}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{options:n,prevPano:S,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 c.Vector3).setY(0);let n=null,r=this.works.getObserver(this.currentPano);if(!r)return null;let i=r.work.observers,a=r.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&r.work.workCode===this.currentPano.workCode)return!1;let t=i[e];return!t||Gv.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[o]=this.modelScene.intersectRaycaster(e);if(o){let[e,r]=Hl(a,e=>{let t=i[e];return t?Gv.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(o.point):1/0},!0);typeof e==`number`&&r<this.panoTapTriggerRadius&&(n=(t=i[e])==null?null:t)}if(sv(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=Z({panoIndex:n.panoIndex,workCode:n.work.workCode});if(t.panoId===e){n=null;break}}}if(sv(n))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!n.active){let e=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let s={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 c.Vector3};return this.emit(`pano.select`,Q(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:s.panoIndex,workCode:s.workCode},state:s,userAction:!0,options:{},progress:0,error:null})),n&&n.active?(this.emit(`pano.request`,Q(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:s.panoIndex,workCode:s.workCode},progress:0,state:s,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,i,a,o,s,l,u,d,f;this.userAction=!0;let p={},m={},h=this.camera.getDirection(new c.Vector3),g=this.locationMotion.keyframes[0],_=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[v,y]=this.locationMotion.getKeyFrameSegment(e),b=this.panoResourceFromLocationMotionKeyframe(v),x=this.panoResourceFromLocationMotionKeyframe(y),S=this.panoResourceFromLocationMotionKeyframe(g),C=this.panoResourceFromLocationMotionKeyframe(_),w=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),m.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),p.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(U(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-y.value.count+1,n=new c.Vector3().copy(b.position),a=new c.Vector3().copy(x.position);if(p.progress=t,t>=.01&&t<=.99&&(p.progress=U(x.effectEasing(t),.01,.99)),x.leftPanoPicture&&(t<1?b.leftPanoPicture&&(p.pano0=b.leftPanoPicture):p.pano0=x.leftPanoPicture,p.pano1=x.leftPanoPicture),x.effect===`montage`?p.transition=`BLACK`:x.effect===`spread`?p.transition=`SPREAD`:p.transition=`FADE`,x.effect===`zoomin`||x.effect===`zoomout`?p.progress=Math.pow(t,3):x.effect===`model`&&this.camera.pose.distance<.01&&(p.modelAlpha=1-Math.pow(U(Math.abs(t-.5)*2,0,1),4)),t<1&&x.effect!==`fly`){if(p.pano0&&b.leftPanoPicture){let e={panoId:p.pano0.panoId,map:p.pano0.map,mapHistogram:p.pano0.mapHistogram,mapSize:p.pano0.mapSize,zoom:p.pano0.zoom,matrix:b.leftPanoPicture.matrix.clone().setPosition(x.position)},t=this.panoPictureObserverMap.get(p.pano0);t&&this.panoPictureObserverMap.set(e,t),p.pano0=e}n.copy(a),w=!0}m.distance=this.locationMotion.value.distance,m.offset=new c.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((r=p.pano0)==null?void 0:r.map)||e===((i=p.pano1)==null?void 0:i.map))continue;e.dispose(),t.leftPanoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let l=yp(x.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,Q(`pano.moving`,{userAction:this.userAction,prevPano:yp(S.panoId),pano:yp(C.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},yp(C.panoId)),{mode:this.mode}),$(this.camera.pose)),m),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(m),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[T,E]=n,D=new c.Vector3(0,0,0),O=new c.Vector2().copy(this.camera.resolution);if(E&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let n=this.xrManager.cameraVR,r=this.xrManager.referenceSpace,i=this.xrManager.session.renderState.baseLayer,l=E.getViewerPose(r),u=(a=l==null?void 0:l.views)==null?[]:a;for(let e=0;e<u.length;e++){let t=u[e],r=n.cameras[e],a=i.getViewport(t);a&&(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,D.copy(r.position),r.viewport.set(a.x,a.y,a.width,a.height),O.set(a.width,a.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((o=m.distance)==null?this.camera.pose.distance:o),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=E.getPose(this.xrManager.session.inputSources[e].targetRaySpace,r);if(t){let e=t.transform.orientation,n=new c.Quaternion(e.x,e.y,e.z,e.w),r=new c.Vector3(0,0,-1).applyQuaternion(n);this.gazeRay=new c.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],i=n[e];if(!i)continue;t&&t.update(i,E,r);let a=this.xrManager.getController(e),o=new c.Vector3(0,1.2,0),l=a.position.clone().add(D).sub(o);i.handedness===`left`?this.xrControllerRay.left.set(l,new c.Vector3(0,0,-1).applyEuler(a.rotation)):i.handedness===`right`&&this.xrControllerRay.right.set(l,new c.Vector3(0,0,-1).applyEuler(a.rotation)),this.controllerWrappers[e].position.copy(new c.Vector3(0,0,0).add(D).sub(o));let u=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(u.length===0){let e=this.works.getResolvedObserver(this.currentPano);u=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(u.length>=1&&u[0].face)if(i.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=u[0].face.normal,n=t.clone(),r=u[0].point.clone();this.intersectMesh.position.copy(r);let i=r.clone().add(n);if(this.intersectMesh.lookAt(i),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(l,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(l,u[0].point));let a=u[0],o=Q(`intersect.update`,{raycaster:(s=this.xrControllerRay.right)==null?null:s,intersection:a==null?null:a,object:this.intersectMesh});if(this.emit(`intersect.update`,o),o.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(l,u[0].point)}this.updateControllerHelper(n,e,t)}}else E||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);zh(p)===!1&&this.modelScene.parameter.set(p),this.emit(`camera.update`,Q(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose))}));let k=this.works.getResolvedObserver(this.currentPano),A=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,j=this.works.getObserver(b.panoId),M=this.works.getObserver(x.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&k){let e=[],t=k.work.observers;for(let n of k.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(k.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(k.standingPosition),n.set(t,i)),r-i}),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=.005,i=t.standingPosition.clone().applyMatrix4(t.work.transform),a=Z({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=n_.map(t=>{Wv.ray.origin.copy(i),Wv.ray.origin.add(Gv.copy(t).setY(e)),Wv.ray.direction.set(0,-1,0),Wv.firstHitOnly=!0,Wv.floorIndex=-1;let[a]=n.intersectRaycaster(Wv);return a&&a.distance-r<=e?new c.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[l]=o.filter(e=>e.distanceTo(s)<=.05);if(l){let e=new c.Vector4(i.x,i.y,i.z,l.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let N=new Map;if(j)for(let e of j.accessibleNodes){let t=j.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(M)for(let e of M.accessibleNodes){let t=M.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{N.get(t)?N.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),N.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),N.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&&(Gv.set(t.x,t.y,t.z),Gv.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new c.Vector3().copy(e.position).sub(i).normalize();if(t===Z(this.currentPano)){let t=U((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(h.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new c.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||w)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(k){let n=k.work.observers,[,r]=Hl(k.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:k.standingPosition.distanceTo(t.standingPosition)},!0);r=U(r,2.5,1/0);let i=k.accessibleNodes.concat(k.panoIndex).map(e=>Z({panoIndex:e,workCode:k.work.workCode}));this.panoMeshes.forEach((n,a)=>{let o=this.works.getObserver(a),s=!1,c=1;if(i.indexOf(a)===-1)s=!1,c=0;else if(!o)s=!1,c=0;else if(!o.loadable&&!o.active)s=!1,c=0;else{let e=n.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!n.loading&&n.progress===0&&A!==null&&Z({panoIndex:A.panoIndex,workCode:A.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:U(r/t,.1,.85)}o&&o===M&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&n.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(c=0),n.setCurrent(s),n.setOpacity(c),n.updateTime&&n.updateTime(e,t)})}{let e=(l=this.modelScene.parameter.progress)==null?1:l,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,a;if(i&&(a=this.works.getObserver(i.panoId),a||(a=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(di()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!a||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new c.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=ni(i.mapSize)+1;this.tiling.setObserver(a);let o={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:i.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:e,level:4},s=this.tiling.update(o),c={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:Xu(Math.abs(((u=this.modelScene.parameter.progress)==null?0:u)-.5)*2)},l=this.modelScene.parameter.refinedScreen;(s||c.pano!==(l==null?void 0:l.pano)||c.opacity!==(l==null?void 0:l.opacity))&&this.modelScene.parameter.set(`refinedScreen`,c)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&k&&k.position.y-k.standingPosition.y>10){let e=U(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=x.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((d=this.modelScene.parameter.pano0Depth)==null?void 0:d.panoId)!==t.panoId||((f=this.modelScene.parameter.pano1Depth)==null?void 0:f.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new c.WebGLCubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new c.WebGLCubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1});let e=new c.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,Qg(this.renderer,this.modelScene,e,500);let r=new c.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,Qg(this.renderer,this.modelScene,r,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,i=this.xrControllerRay.right;if(!e||e.length===0)return;let a={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let o=0;o<e.length;o++){let s=e[o].handedness,c=e[o].gamepad;switch(s){case`left`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`LeftAxesDown`,t)),c!=null&&c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`X`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`Y`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`LeftTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n};a.buttons.X=c.buttons&&c.buttons[4]?c.buttons[4].pressed:!1,a.buttons.Y=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.LeftTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.LeftPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1,a.left=e;break;case`right`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`RightAxesDown`,t)),c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`A`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`B`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`RightTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`RightPinch`,t)),a.right={raycaster:i,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n},a.buttons.A=c.buttons&&c.buttons[4]?c==null?void 0:c.buttons[4].pressed:!1,a.buttons.B=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.RightTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.RightPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,Q(`xr.controller.update`,a))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,i=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`,Q(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}))):n-this.xrHandleState[t].touchStartTime>Uv&&this.emit(`xr.gesture.press`,Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,Q(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}})),n-this.xrHandleState[t].touchStartTime<=Uv){let e=Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}});!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)})}}},qv={Floorplan:ng,Topview:ig,Panorama:r_,VRPanorama:J_,Model:$_,Mapview:av,XRPanorama:Vv},Jv=`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 Yv(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=Ht(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 Xv(){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 Zv(){let e=new c.Group;e.name=`internalLights`;{let t=new c.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new c.Vector3(0,1,0)),e.add(t)}{let t=new c.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new c.Vector3(-1,-1,-1)),e.add(t)}{let t=new c.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new c.Vector3(1,1,1)),e.add(t)}{let t=new c.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function Qv(e){var t,n;let r={},i=e.split(/(\;|\,)/);for(let e of i){let i=e.split(`=`),a=(t=i[0])==null?void 0:t.trim(),o=(n=i[1])==null?void 0:n.trim();a&&o&&(r[a]=o)}return r}function $v(){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=Qv((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var ey=`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==`,ty=[351,63],ny=[20,20],ry=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),iy=new Float32Array([0,0,1,0,0,1,1,1]),ay=new Uint8Array([0,1,2,1,3,2]),oy=new c.BufferGeometry;oy.setAttribute(`position`,new c.BufferAttribute(ry,3)),oy.setAttribute(`uv`,new c.BufferAttribute(iy,2)),oy.setIndex(new c.BufferAttribute(ay,1));var sy=new c.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),cy=new c.Mesh(oy,sy);cy.matrixAutoUpdate=!1;var ly=new c.Scene;ly.add(cy),ly.matrixAutoUpdate=!1;var uy=new c.OrthographicCamera(-.5,.5,.5,-.5,.1,1);uy.position.set(0,0,.5),uy.lookAt(0,0,0),uy.updateMatrixWorld(!0),uy.matrixAutoUpdate=!1;var dy=new c.Vector4,fy=new c.Vector4;function py(e){if(sy.map){let t=e.getViewport(dy),n=e.getScissor(fy),r=e.getScissorTest(),i=e.autoClear,a=n.x+ny[0]/3,o=n.y+ny[1]/3,s=ty[0]/3,c=ty[1]/3;e.setViewport(a,o,s,c),e.setScissor(a,o,s,c),e.setScissorTest(!0),e.autoClear=!1,e.render(ly,uy),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=i}else{let e=new c.Texture,t=new Image;t.onload=()=>{e.image=t,e.wrapS=c.ClampToEdgeWrapping,e.wrapT=c.ClampToEdgeWrapping,e.minFilter=c.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,sy.needsUpdate=!0,t.onload=K},t.src=ey,sy.map=e}}var my=`(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)})})();`,Dy=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,Ey],{type:`text/javascript;charset=utf-8`});function Oy(e){let t;try{if(t=Dy&&(self.URL||self.webkitURL).createObjectURL(Dy),!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(Ey),{name:e==null?void 0:e.name})}}var ky=function(...e){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"),Ay=function(...e){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`),jy=2,My=class extends c.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,i=this.collectObjects(t);if(i.length===0){this.geometry.instanceCount=0;return}let a=0;i.forEach(e=>{e.usedSHDegree>a&&(a=e.usedSHDegree)}),this.setMaxShDegree(a),this.isSceneNeedsRebuild(i)&&(this.tryStartIncrementalUpdate(i)||(this.startPendingRebuild(i),this.gsSceneState.lastClipperHash=``));let o=i.filter(e=>e.transformChanged);o.length>0&&(this.syncTransformsForSlot(this.activeSlot,o),this.syncTransformsForSlot(this.pendingSlot,o),o.forEach(e=>{e.transformChanged=!1,e.selectedChanged=!1})),this.activeSlot&&this.updateSlotTextures(this.activeSlot),this.pendingSlot&&this.updateSlotTextures(this.pendingSlot);let s=new c.Matrix4().multiplyMatrices(r.perspectiveProjectionMatrix,r.matrixWorldInverse).elements;this.pendingSlot&&this.pendingSlot.renderData.initialBuildComplete&&this.pendingSlot.awaitingFirstSort?this.requestSort(this.pendingSlot,s):this.activeSlot&&this.requestSort(this.activeSlot,s);let l=this.getClipperHash(i);if((this.forceClipperUniformRefresh||l!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(i),this.gsSceneState.lastClipperHash=l,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 Oy,this.sortWorker.postMessage({warmup:!0}),Ty.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,i=new Float32Array(n);i.set(r.subarray(0,Math.min(r.length,n)));let a=new c.InstancedBufferAttribute(i,1,!1,1);return a.setUsage(c.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,a),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,a}getExpandedCapacity(e){let t=Math.max(this.splatIndexCapacity,1);for(;t<e;)t*=2;return t}createGeometry(){let e=new c.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new c.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new c.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity);for(let e=0;e<r.length;e++)r[e]=e;let i=new c.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(c.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}createMaterial(){return new c.ShaderMaterial({vertexShader:ky,fragmentShader:Ay,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 c.Vector2},u_maxShDegree:{value:0},resolution:{value:new c.Vector2},u_aggregationEnabled:{value:!0},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new c.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new c.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6}},side:c.DoubleSide,transparent:!0,blending:c.NormalBlending,depthTest:!0,depthWrite:!1})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new c.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new c.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 c.DataTexture(e.data,e.width,e.height,c.RGBAIntegerFormat,c.UnsignedIntType),r.internalFormat=`RGBA32UI`,r.minFilter=c.NearestFilter,r.magFilter=c.NearestFilter,r.needsUpdate=!0);let i;t&&t.transformsTexture.image.width===e.transformsWidth&&t.transformsTexture.image.height===e.transformsHeight?(i=t.transformsTexture,i.image.data=e.transforms,i.needsUpdate=!0):(t&&t.transformsTexture.dispose(),i=new c.DataTexture(e.transforms,e.transformsWidth,e.transformsHeight,c.RGBAFormat,c.FloatType),i.internalFormat=`RGBA32F`,i.minFilter=c.NearestFilter,i.magFilter=c.NearestFilter,i.needsUpdate=!0);let a;t&&t.transformIndicesTexture.image.width===e.transformIndicesWidth&&t.transformIndicesTexture.image.height===e.transformIndicesHeight?(a=t.transformIndicesTexture,a.image.data=e.transformIndices,a.needsUpdate=!0):(t&&t.transformIndicesTexture.dispose(),a=new c.DataTexture(e.transformIndices,e.transformIndicesWidth,e.transformIndicesHeight,c.RedIntegerFormat,c.UnsignedIntType),a.internalFormat=`R32UI`,a.minFilter=c.NearestFilter,a.magFilter=c.NearestFilter,a.needsUpdate=!0);let o;t&&t.layerIndicesTexture.image.width===e.layerIndicesWidth&&t.layerIndicesTexture.image.height===e.layerIndicesHeight?(o=t.layerIndicesTexture,o.image.data=e.layerIndices,o.needsUpdate=!0):(t&&t.layerIndicesTexture.dispose(),o=new c.DataTexture(e.layerIndices,e.layerIndicesWidth,e.layerIndicesHeight,c.RedIntegerFormat,c.UnsignedIntType),o.internalFormat=`R32UI`,o.minFilter=c.NearestFilter,o.magFilter=c.NearestFilter,o.needsUpdate=!0);let s=(n=t==null?void 0:t.shTexture)==null?null:n;return{dataTexture:r,transformsTexture:i,transformIndicesTexture:a,layerIndicesTexture:o,shTexture:s}}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),i=0;if(r>=1&&(i+=9),r>=2&&(i+=15),r>=3&&(i+=21),i===0)return;let a=i;a%4!=0&&(a=Math.ceil(a/4)*4);let o=t.numPoints*a/4,s=2048,l=Math.ceil(o/s),u=new Float32Array(s*l*4);for(let e=0;e<t.numPoints;e++){let n=a/4*e,i=0;if(t.sh1&&r>=1)for(let r=0;r<9;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh1[e*9+r],i++}if(t.sh2&&r>=2)for(let r=0;r<15;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh2[e*15+r],i++}if(t.sh3&&r>=3)for(let r=0;r<21;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh3[e*21+r],i++}}n.shTexture=new c.DataTexture(u,s,l,c.RGBAFormat,c.FloatType),n.shTexture.internalFormat=`RGBA32F`,n.shTexture.minFilter=c.NearestFilter,n.shTexture.magFilter=c.NearestFilter,n.shTexture.needsUpdate=!0,this.material.uniforms.u_shTextureSize.value.set(s,l),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>=jy){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),i=new Uint32Array(e.renderData.transformIndices.slice().buffer);(t=this.sortWorker)==null||t.postMessage({sortData:{positions:n,transforms:r,transformIndices:i,vertexCount:e.renderData.numPoints,generation:e.generation}},[n.buffer,r.buffer,i.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 $n&&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),i=this.material.defines;(i.NUM_GS_LAYERS!==n||i.NUM_GS_CLIPPERS!==r)&&(i.NUM_GS_LAYERS=n,i.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,i;let a=(n=(t=this.activeSlot)==null?void 0:t.renderData)==null?null:n;if(!a){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let o=new Map;for(let t of e)o.has(t.gsViewLayerKey)||o.set(t.gsViewLayerKey,t.gsClippers);let s=a.layerKeys.length,c=0;for(let e of a.layerKeys)c+=((r=o.get(e))==null?[]:r).length;let l=this.createDefaultLayerClipperRanges(s),u=this.createDefaultClipperMatrices(c),d=0;for(let e of a.layerKeys){let t=a.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(i=o.get(e))==null?[]:i,r=d,s=0;for(let e of n)u[d].getInverse(e.clippingBoxMatrix),d++,s++;s>0&&l[t].set(r,s)}this.material.uniforms.u_layerClipperRanges.value=l,this.material.uniforms.u_clipperMatricesInverse.value=u,this.updateClipperCounts(s,d)}startPendingRebuild(e){this.pendingSlot&&(this.recycleSlot(this.pendingSlot),this.pendingSlot=null),this.rebuildGeneration+=1;let t=new Ty(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()}},Ny=class extends c.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 $n&&e.visible&&t.push(e)}),t}},Py=1e3,Fy=90,Iy=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/`),Ly=new c.Sphere,Ry=new c.Box3,zy=new c.Vector4,By=new c.Vector4,Vy=new c.Color,Hy=new c.Vector2,Uy=new WeakMap,Wy=am([nm(null)]),Gy={},Ky=class e extends ln{static get version(){return`6.8.0`}static get dracoPath(){return io.decoderPath}static set dracoPath(e){io.setDecoderPath(e)}static get ktx2Path(){return po.transcoderPath}static set ktx2Path(e){po.setTranscoderPath(e)}static get useNativeImageBitmap(){return di()}static set useNativeImageBitmap(e){ui(e)}constructor(e={}){var t,n,r,i,a,o,s,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=rn(),Gy[this.fiveId]=this,this.currentUpdateArgs={time:H(),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=(i=e.poweredByRealsee)==null?!0:i,this.backgroundColor=new c.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,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:H()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?Py:s,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Qm&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Qm({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=$v();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 c.WebGLRenderTarget(1,1,{encoding:(d=(u=this.renderer)==null?void 0:u.outputEncoding)==null?c.sRGBEncoding:d,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new tn(Fy),this.scene=new ah,this.xrCustomObjectsScene=new c.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(f=e.requestProxy)==null?Iy:f,this.networkSubscribe=new dr,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,Q(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new c.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),Uy.set(this,Wy),this.modelScene=new np({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(Wy,{forceReplaceImmediately:!0});V(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new c.VideoTexture(e.videoInstance||Xv());let m=Zv();this.scene.add(m),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=si.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,Q(`vr.requestExit`,{}))},g=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,g,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,g,!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)}}}Yv(this),this.fiveRenderer=new Zm,this.adaptiveLuminancePass=new Am,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Nm(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new My,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new Ny)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return Z(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Gy[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(),Uy.set(this,Wy),this.renderer&&this.renderer.render(new c.Scene,new c.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Qm&&(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`,Q(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,br(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,br(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,br(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,br(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,br(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,br(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,br(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 Qm)){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,i;if(!this.renderer)return;let a=this.renderer.domElement.parentNode,{width:o=(n=a==null?void 0:a.offsetWidth)==null?512:n,height:s=(r=a==null?void 0:a.offsetHeight)==null?512:r}=e;if(o=Math.max(1,o),s=Math.max(1,s),!t){let e=$v(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(o,s)*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(o,s),this.needsRender=!0;let c=H(),l=c-this.currentUpdateArgs.time,u=this.currentUpdateArgs.args;this.updateTime(c,l,...u)}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 Uy.get(this)||Wy}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 i=this.loadWorkTask.then(()=>Th(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,l,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===Wy&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof tm?v.push(e):typeof e!=`string`&&`work`in e?v.push(nm(e.work,e)):v.push(nm(e));else t instanceof tm?v.push(t):v.push(nm(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=am(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===Wy&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):(n.mode===`Panorama`||n.mode===`VRPanorama`||n.mode===`XRPanorama`)&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(l=x.offset)==null?void 0:l.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new c.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;(w===`Panorama`||w===`VRPanorama`||w===`XRPanorama`)&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,Q(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=Kv[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=Kv[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=Q(`mode.change`,{prevMode:b,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};Uy.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),Ih(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,Q(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,Q(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}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}),Uy.set(this,Wy),this.modelScene.setModels(Wy,{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:Fy,longitude:0,latitude:0,offset:new c.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,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(m)){let e=Error(`PanoId ${Z(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!bp(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(bp(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=Kv[t].initAnimationEndState(r),o=Q(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=Q(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=si.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),si.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),Mh().then(()=>_()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),s(t)})):t===e.Mode.XRPanorama?Nh().then(e=>{si.shared.setContext(e),a=!0,_()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),s(t)}):_()})}getPixels(e,t,n,r,i,a,o){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=H(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new c.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?l:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&(this.controller instanceof Kv.Panorama||this.controller instanceof Kv.VRPanorama||this.controller instanceof Kv.XRPanorama)&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=Vy.copy(this.renderer.getClearColor()),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);if(this.renderer.readRenderTargetPixels(C,0,0,m*g,h*g,b),_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b}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,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=Vy.copy(t.getClearColor()),c=t.getClearAlpha(),l=t.getViewport(zy),u=t.getScissor(By),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(Hy),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:v;let y=!0;if(this.controller&&this.controller.render()&&(y=!1),y){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&py(t)}this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&si.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&po.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),si.shared.add(()=>{this.emit(`models.load`,Q(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&si.shared.add(()=>{this.emit(`models.refined`,Q(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){Ry.makeEmpty(),Ry.expandByObject(this.modelScene.boundingMesh);let t=Ry.getBoundingSphere(Ly),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=U(n,800);let r=n/1e4;r=U(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=Q(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,Q(`render`,{needsRender:i})),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 Qm&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,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=K){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`],i=H();return Promise.all(r.map(e=>{let t=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},vr(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Xr(i,r);return Ef(this.fiveId,n.work).preload(a)})).then(()=>{let e=H()-i;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 c.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.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 c.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new c.Vector2(o,s)}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,i,a,o,s,l,u,d,f,p;e=vr(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof c.Vector3)&&(e.offset=new c.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){if(h===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.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 c.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[h]),r=Kv[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,Q(`state.set`,{userAction:n,state:x})),Fh(this.state,x)||(this.controller&&x.mode===`VRPanorama`&&x.mode!==this.state.mode?(Ph(this.state,x),this.changeMode(`VRPanorama`)):this.controller&&x.mode===`XRPanorama`&&x.mode!==this.state.mode?(Ph(this.state,x),this.changeMode(`XRPanorama`)):(Ph(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(H(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(H(),0),this.syncingState=!1)),this.emit(`state.change`,Q(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state)))}syncState(t,n,r=!1){let i=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 Kv.Model){if(wh(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(!bp(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 Kv.Floorplan||this.controller instanceof Kv.Topview||this.controller instanceof Kv.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:Cm(this.camera.pose.fov,this.state.fov,1),i=Math.abs(this.camera.pose.distance-this.state.distance),a=i>e*15?i/15:.2,o=r?this.state.distance:Cm(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),l=s>e*15?s/15:e,u=r?new c.Vector3().copy(this.state.offset):wm(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Tm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(Sh(n,this.camera.pose.fov)||wh(u,this.camera.pose.offset)||Sh(o,this.camera.pose.distance)||Sh(d,this.camera.pose.longitude,Math.PI*2)||Sh(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:Cm(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Tm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new c.Vector3().copy(this.state.offset);if(Sh(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),wh(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),Sh(n,this.camera.pose.longitude,Math.PI*2)||Sh(i,this.camera.pose.latitude)||Sh(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,Q(`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 Kv.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(K)}requestFullscreen(){var e;if(!Oh)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=()=>{si.shared.add(()=>{this.emit(`model.load`,Q(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,Q(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,Q(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,Q(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,Q(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,Q(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new gr({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=Up(e,r);return t instanceof Error?Promise.reject(t):t})}});Df(this.fiveId,e,i)}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=Kv[t];this.currentMode=t;let i=new r(n);for(let e of Jv)i.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=Kv[t].initAnimationEndState(n),r=n.initial.userAction;Fh(this.state,e)||(Ph(this.state,e),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,Q(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return i.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,Q(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),i.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,Q(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),i.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),i.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),i.on(`error`,e=>this.throwError(e)),i}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:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}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 c.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 c.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}};Ky.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:c,constructor:Ky,instances:Gy}});var qy=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 i(){r(),t.textContent=`VR NOT SUPPORTED`}function a(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`,a(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():i()}),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`,a(e),e}}};exports.AdaptiveLuminancePass=Am,exports.AnimationFrameLoop=si,exports.BoundingMesh=ep,exports.Camera=tn,exports.CustomShader=dn,exports.PBMCustomShader=dn,exports.EffectComposer=om,exports.EyeDomeLightingPass=Nm,exports.Fetcher=gr,exports.Five=Ky,exports.FivePass=cm,exports.FiveRenderer=Zm,exports.FullScreenQuad=sm,exports.Histogram=bm,exports.InternalWebGLRenderer=Qm,exports.Model=Gf,exports.ModelScene=np,exports.Motion=X,exports.NetworkSubscribe=dr,exports.PBMContainer=Xn,exports.PBMGSObject=$n,exports.PBMGroup=wt,exports.PBMMesh=bn,exports.PBMMeshMaterial=yn,exports.PBMPanoFilter=fn,exports.PBMPointCloud=An,exports.PBMPointCloudMaterial=kn,exports.PBMSkinnedMesh=xn,exports.PBMUpdateable=un,exports.PROXY_CONTROLLER_EVENT_NAMES=Jv,exports.PanoCircleMesh=uh,exports.PanoCircleMeshCustom=bh,exports.PanoCircleMeshSolid=hh,exports.Parameter=G,exports.Scene=ah,exports.Subscribe=ln,exports.TextureLoader=yi,exports.Tile=Bl,exports.Tile3D=wf,exports.Tile3DModel=wf,exports.TileCache=fd,exports.TileNode=td,exports.TileRequestScheduler=ld,exports.Tileset=vd,exports.Trajectory=ad,exports.TrajectoryNode=od,exports.Work=tm,exports.WorkResolvedObserver=im,exports.XRButton=qy,exports.controllersDefaultInitArgs=qv,exports.coordinatesToVector=Ht,exports.createDebugBoundingMesh=Fl,exports.createWorks=am,exports.defaultImageURLTransform=Xr,exports.draco=io,exports.getViewportScale=$v,exports.headingToLongitude=Gt,exports.imageSupport=Nr,exports.isBoundingVolume=Al,exports.isPanoId=xp,exports.ktx2=po,exports.loadAt3d=ia,exports.loadB3dm=fs,exports.loadDome=ca,exports.loadDomez=ha,exports.loadFbx=Dc,exports.loadGltf=xs,exports.loadPbm=Ii,exports.loadPly=Cs,exports.loadPnts=ys,exports.loadSplat=ul,exports.loadSpz=is,exports.loadX3p=sl,exports.longitudeToHeading=Wt,exports.makeBoundingVolume=jl,exports.panoEqual=bp,exports.panoParse=yp,exports.panoStringify=Z,exports.parseWork=nm,exports.vectorToCoordinates=Ut,exports.workToJson=sp;
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`),jy=2,My=class extends c.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,i=this.collectObjects(t);if(i.length===0){this.geometry.instanceCount=0;return}let a=0;i.forEach(e=>{e.usedSHDegree>a&&(a=e.usedSHDegree)}),this.setMaxShDegree(a),this.isSceneNeedsRebuild(i)&&(this.tryStartIncrementalUpdate(i)||(this.startPendingRebuild(i),this.gsSceneState.lastClipperHash=``));let o=i.filter(e=>e.transformChanged);o.length>0&&(this.syncTransformsForSlot(this.activeSlot,o),this.syncTransformsForSlot(this.pendingSlot,o),o.forEach(e=>{e.transformChanged=!1,e.selectedChanged=!1})),this.activeSlot&&this.updateSlotTextures(this.activeSlot),this.pendingSlot&&this.updateSlotTextures(this.pendingSlot);let s=new c.Matrix4().multiplyMatrices(r.perspectiveProjectionMatrix,r.matrixWorldInverse).elements;this.pendingSlot&&this.pendingSlot.renderData.initialBuildComplete&&this.pendingSlot.awaitingFirstSort?this.requestSort(this.pendingSlot,s):this.activeSlot&&this.requestSort(this.activeSlot,s);let l=this.getClipperHash(i);if((this.forceClipperUniformRefresh||l!==this.gsSceneState.lastClipperHash)&&(this.updateClipperUniforms(i),this.gsSceneState.lastClipperHash=l,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 Oy,this.sortWorker.postMessage({warmup:!0}),Ty.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,i=new Float32Array(n);i.set(r.subarray(0,Math.min(r.length,n)));let a=new c.InstancedBufferAttribute(i,1,!1,1);return a.setUsage(c.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,a),this.splatIndexCapacity=n,this.geometry._maxInstanceCount=n,a}getExpandedCapacity(e){let t=Math.max(this.splatIndexCapacity,1);for(;t<e;)t*=2;return t}createGeometry(){let e=new c.InstancedBufferGeometry,t=new Float32Array([-1,-1,0,1,-1,0,1,1,0,-1,1,0]);e.setAttribute(`position`,new c.BufferAttribute(t,3));let n=new Uint16Array([0,1,2,0,2,3]);e.setIndex(new c.BufferAttribute(n,1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity);for(let e=0;e<r.length;e++)r[e]=e;let i=new c.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(c.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}createMaterial(){return new c.ShaderMaterial({vertexShader:ky,fragmentShader:Ay,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 c.Vector2},u_maxShDegree:{value:0},resolution:{value:new c.Vector2},u_aggregationEnabled:{value:!0},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new c.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new c.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6}},side:c.DoubleSide,transparent:!0,blending:c.NormalBlending,depthTest:!0,depthWrite:!1})}createDefaultLayerClipperRanges(e){return Array.from({length:e},()=>new c.Vector2(-1,0))}createDefaultClipperMatrices(e){return Array.from({length:e},()=>new c.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 c.DataTexture(e.data,e.width,e.height,c.RGBAIntegerFormat,c.UnsignedIntType),r.internalFormat=`RGBA32UI`,r.minFilter=c.NearestFilter,r.magFilter=c.NearestFilter,r.needsUpdate=!0);let i;t&&t.transformsTexture.image.width===e.transformsWidth&&t.transformsTexture.image.height===e.transformsHeight?(i=t.transformsTexture,i.image.data=e.transforms,i.needsUpdate=!0):(t&&t.transformsTexture.dispose(),i=new c.DataTexture(e.transforms,e.transformsWidth,e.transformsHeight,c.RGBAFormat,c.FloatType),i.internalFormat=`RGBA32F`,i.minFilter=c.NearestFilter,i.magFilter=c.NearestFilter,i.needsUpdate=!0);let a;t&&t.transformIndicesTexture.image.width===e.transformIndicesWidth&&t.transformIndicesTexture.image.height===e.transformIndicesHeight?(a=t.transformIndicesTexture,a.image.data=e.transformIndices,a.needsUpdate=!0):(t&&t.transformIndicesTexture.dispose(),a=new c.DataTexture(e.transformIndices,e.transformIndicesWidth,e.transformIndicesHeight,c.RedIntegerFormat,c.UnsignedIntType),a.internalFormat=`R32UI`,a.minFilter=c.NearestFilter,a.magFilter=c.NearestFilter,a.needsUpdate=!0);let o;t&&t.layerIndicesTexture.image.width===e.layerIndicesWidth&&t.layerIndicesTexture.image.height===e.layerIndicesHeight?(o=t.layerIndicesTexture,o.image.data=e.layerIndices,o.needsUpdate=!0):(t&&t.layerIndicesTexture.dispose(),o=new c.DataTexture(e.layerIndices,e.layerIndicesWidth,e.layerIndicesHeight,c.RedIntegerFormat,c.UnsignedIntType),o.internalFormat=`R32UI`,o.minFilter=c.NearestFilter,o.magFilter=c.NearestFilter,o.needsUpdate=!0);let s=(n=t==null?void 0:t.shTexture)==null?null:n;return{dataTexture:r,transformsTexture:i,transformIndicesTexture:a,layerIndicesTexture:o,shTexture:s}}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),i=0;if(r>=1&&(i+=9),r>=2&&(i+=15),r>=3&&(i+=21),i===0)return;let a=i;a%4!=0&&(a=Math.ceil(a/4)*4);let o=t.numPoints*a/4,s=2048,l=Math.ceil(o/s),u=new Float32Array(s*l*4);for(let e=0;e<t.numPoints;e++){let n=a/4*e,i=0;if(t.sh1&&r>=1)for(let r=0;r<9;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh1[e*9+r],i++}if(t.sh2&&r>=2)for(let r=0;r<15;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh2[e*15+r],i++}if(t.sh3&&r>=3)for(let r=0;r<21;r++){let a=n+Math.floor(i/4),o=i%4,s=a*4+o;u[s]=t.sh3[e*21+r],i++}}n.shTexture=new c.DataTexture(u,s,l,c.RGBAFormat,c.FloatType),n.shTexture.internalFormat=`RGBA32F`,n.shTexture.minFilter=c.NearestFilter,n.shTexture.magFilter=c.NearestFilter,n.shTexture.needsUpdate=!0,this.material.uniforms.u_shTextureSize.value.set(s,l),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>=jy){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),i=new Uint32Array(e.renderData.transformIndices.slice().buffer);(t=this.sortWorker)==null||t.postMessage({sortData:{positions:n,transforms:r,transformIndices:i,vertexCount:e.renderData.numPoints,generation:e.generation}},[n.buffer,r.buffer,i.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 $n&&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),i=this.material.defines;(i.NUM_GS_LAYERS!==n||i.NUM_GS_CLIPPERS!==r)&&(i.NUM_GS_LAYERS=n,i.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,i;let a=(n=(t=this.activeSlot)==null?void 0:t.renderData)==null?null:n;if(!a){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let o=new Map;for(let t of e)o.has(t.gsViewLayerKey)||o.set(t.gsViewLayerKey,t.gsClippers);let s=a.layerKeys.length,c=0;for(let e of a.layerKeys)c+=((r=o.get(e))==null?[]:r).length;let l=this.createDefaultLayerClipperRanges(s),u=this.createDefaultClipperMatrices(c),d=0;for(let e of a.layerKeys){let t=a.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(i=o.get(e))==null?[]:i,r=d,s=0;for(let e of n)u[d].getInverse(e.clippingBoxMatrix),d++,s++;s>0&&l[t].set(r,s)}this.material.uniforms.u_layerClipperRanges.value=l,this.material.uniforms.u_clipperMatricesInverse.value=u,this.updateClipperCounts(s,d)}startPendingRebuild(e){this.pendingSlot&&(this.recycleSlot(this.pendingSlot),this.pendingSlot=null),this.rebuildGeneration+=1;let t=new Ty(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()}},Ny=class extends c.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 $n&&e.visible&&t.push(e)}),t}},Py=1e3,Fy=90,Iy=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/`),Ly=new c.Sphere,Ry=new c.Box3,zy=new c.Vector4,By=new c.Vector4,Vy=new c.Color,Hy=new c.Vector2,Uy=new WeakMap,Wy=am([nm(null)]),Gy={},Ky=class e extends ln{static get version(){return`6.8.1`}static get dracoPath(){return io.decoderPath}static set dracoPath(e){io.setDecoderPath(e)}static get ktx2Path(){return po.transcoderPath}static set ktx2Path(e){po.setTranscoderPath(e)}static get useNativeImageBitmap(){return di()}static set useNativeImageBitmap(e){ui(e)}constructor(e={}){var t,n,r,i,a,o,s,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=rn(),Gy[this.fiveId]=this,this.currentUpdateArgs={time:H(),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=(i=e.poweredByRealsee)==null?!0:i,this.backgroundColor=new c.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,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:H()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?Py:s,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Qm&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Qm({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=$v();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 c.WebGLRenderTarget(1,1,{encoding:(d=(u=this.renderer)==null?void 0:u.outputEncoding)==null?c.sRGBEncoding:d,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new tn(Fy),this.scene=new ah,this.xrCustomObjectsScene=new c.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(f=e.requestProxy)==null?Iy:f,this.networkSubscribe=new dr,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,Q(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new c.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),Uy.set(this,Wy),this.modelScene=new np({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(Wy,{forceReplaceImmediately:!0});V(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new c.VideoTexture(e.videoInstance||Xv());let m=Zv();this.scene.add(m),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=si.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,Q(`vr.requestExit`,{}))},g=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,g,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,g,!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)}}}Yv(this),this.fiveRenderer=new Zm,this.adaptiveLuminancePass=new Am,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Nm(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new My,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new Ny)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return Z(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Gy[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(),Uy.set(this,Wy),this.renderer&&this.renderer.render(new c.Scene,new c.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Qm&&(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`,Q(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,br(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,br(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,br(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,br(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,br(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,br(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,br(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 Qm)){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,i;if(!this.renderer)return;let a=this.renderer.domElement.parentNode,{width:o=(n=a==null?void 0:a.offsetWidth)==null?512:n,height:s=(r=a==null?void 0:a.offsetHeight)==null?512:r}=e;if(o=Math.max(1,o),s=Math.max(1,s),!t){let e=$v(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(o,s)*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(o,s),this.needsRender=!0;let c=H(),l=c-this.currentUpdateArgs.time,u=this.currentUpdateArgs.args;this.updateTime(c,l,...u)}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 Uy.get(this)||Wy}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 i=this.loadWorkTask.then(()=>Th(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,l,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===Wy&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof tm?v.push(e):typeof e!=`string`&&`work`in e?v.push(nm(e.work,e)):v.push(nm(e));else t instanceof tm?v.push(t):v.push(nm(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=am(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===Wy&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):(n.mode===`Panorama`||n.mode===`VRPanorama`||n.mode===`XRPanorama`)&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(l=x.offset)==null?void 0:l.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new c.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;(w===`Panorama`||w===`VRPanorama`||w===`XRPanorama`)&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,Q(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=Kv[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=Kv[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=Q(`mode.change`,{prevMode:b,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};Uy.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),Ih(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,Q(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,Q(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}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}),Uy.set(this,Wy),this.modelScene.setModels(Wy,{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:Fy,longitude:0,latitude:0,offset:new c.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,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(m)){let e=Error(`PanoId ${Z(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!bp(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(bp(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=Kv[t].initAnimationEndState(r),o=Q(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=Q(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=si.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),si.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),Mh().then(()=>_()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),s(t)})):t===e.Mode.XRPanorama?Nh().then(e=>{si.shared.setContext(e),a=!0,_()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),s(t)}):_()})}getPixels(e,t,n,r,i,a,o){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=H(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new c.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?l:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&(this.controller instanceof Kv.Panorama||this.controller instanceof Kv.VRPanorama||this.controller instanceof Kv.XRPanorama)&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=Vy.copy(this.renderer.getClearColor()),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);if(this.renderer.readRenderTargetPixels(C,0,0,m*g,h*g,b),_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b}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,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=Vy.copy(t.getClearColor()),c=t.getClearAlpha(),l=t.getViewport(zy),u=t.getScissor(By),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(Hy),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:v;let y=!0;if(this.controller&&this.controller.render()&&(y=!1),y){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&py(t)}this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&si.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&po.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),si.shared.add(()=>{this.emit(`models.load`,Q(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&si.shared.add(()=>{this.emit(`models.refined`,Q(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){Ry.makeEmpty(),Ry.expandByObject(this.modelScene.boundingMesh);let t=Ry.getBoundingSphere(Ly),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=U(n,800);let r=n/1e4;r=U(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=Q(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,Q(`render`,{needsRender:i})),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 Qm&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,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=K){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`],i=H();return Promise.all(r.map(e=>{let t=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},vr(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Xr(i,r);return Ef(this.fiveId,n.work).preload(a)})).then(()=>{let e=H()-i;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 c.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.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 c.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new c.Vector2(o,s)}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,i,a,o,s,l,u,d,f,p;e=vr(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof c.Vector3)&&(e.offset=new c.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){if(h===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.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 c.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[h]),r=Kv[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,Q(`state.set`,{userAction:n,state:x})),Fh(this.state,x)||(this.controller&&x.mode===`VRPanorama`&&x.mode!==this.state.mode?(Ph(this.state,x),this.changeMode(`VRPanorama`)):this.controller&&x.mode===`XRPanorama`&&x.mode!==this.state.mode?(Ph(this.state,x),this.changeMode(`XRPanorama`)):(Ph(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(H(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(H(),0),this.syncingState=!1)),this.emit(`state.change`,Q(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state)))}syncState(t,n,r=!1){let i=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 Kv.Model){if(wh(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(!bp(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 Kv.Floorplan||this.controller instanceof Kv.Topview||this.controller instanceof Kv.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:Cm(this.camera.pose.fov,this.state.fov,1),i=Math.abs(this.camera.pose.distance-this.state.distance),a=i>e*15?i/15:.2,o=r?this.state.distance:Cm(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),l=s>e*15?s/15:e,u=r?new c.Vector3().copy(this.state.offset):wm(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Tm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(Sh(n,this.camera.pose.fov)||wh(u,this.camera.pose.offset)||Sh(o,this.camera.pose.distance)||Sh(d,this.camera.pose.longitude,Math.PI*2)||Sh(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:Cm(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Tm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new c.Vector3().copy(this.state.offset);if(Sh(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),wh(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),Sh(n,this.camera.pose.longitude,Math.PI*2)||Sh(i,this.camera.pose.latitude)||Sh(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,Q(`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 Kv.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(K)}requestFullscreen(){var e;if(!Oh)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=()=>{si.shared.add(()=>{this.emit(`model.load`,Q(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,Q(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,Q(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,Q(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,Q(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,Q(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new gr({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=Up(e,r);return t instanceof Error?Promise.reject(t):t})}});Df(this.fiveId,e,i)}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=Kv[t];this.currentMode=t;let i=new r(n);for(let e of Jv)i.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=Kv[t].initAnimationEndState(n),r=n.initial.userAction;Fh(this.state,e)||(Ph(this.state,e),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,Q(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return i.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,Q(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),i.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.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&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!Fh(this.state,n)&&(Ph(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,Q(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),i.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),i.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),i.on(`error`,e=>this.throwError(e)),i}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:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}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 c.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 c.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}};Ky.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:c,constructor:Ky,instances:Gy}});var qy=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 i(){r(),t.textContent=`VR NOT SUPPORTED`}function a(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`,a(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():i()}),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`,a(e),e}}};exports.AdaptiveLuminancePass=Am,exports.AnimationFrameLoop=si,exports.BoundingMesh=ep,exports.Camera=tn,exports.CustomShader=dn,exports.PBMCustomShader=dn,exports.EffectComposer=om,exports.EyeDomeLightingPass=Nm,exports.Fetcher=gr,exports.Five=Ky,exports.FivePass=cm,exports.FiveRenderer=Zm,exports.FullScreenQuad=sm,exports.Histogram=bm,exports.InternalWebGLRenderer=Qm,exports.Model=Gf,exports.ModelScene=np,exports.Motion=X,exports.NetworkSubscribe=dr,exports.PBMContainer=Xn,exports.PBMGSObject=$n,exports.PBMGroup=wt,exports.PBMMesh=bn,exports.PBMMeshMaterial=yn,exports.PBMPanoFilter=fn,exports.PBMPointCloud=An,exports.PBMPointCloudMaterial=kn,exports.PBMSkinnedMesh=xn,exports.PBMUpdateable=un,exports.PROXY_CONTROLLER_EVENT_NAMES=Jv,exports.PanoCircleMesh=uh,exports.PanoCircleMeshCustom=bh,exports.PanoCircleMeshSolid=hh,exports.Parameter=G,exports.Scene=ah,exports.Subscribe=ln,exports.TextureLoader=yi,exports.Tile=Bl,exports.Tile3D=wf,exports.Tile3DModel=wf,exports.TileCache=fd,exports.TileNode=td,exports.TileRequestScheduler=ld,exports.Tileset=vd,exports.Trajectory=ad,exports.TrajectoryNode=od,exports.Work=tm,exports.WorkResolvedObserver=im,exports.XRButton=qy,exports.controllersDefaultInitArgs=qv,exports.coordinatesToVector=Ht,exports.createDebugBoundingMesh=Fl,exports.createWorks=am,exports.defaultImageURLTransform=Xr,exports.draco=io,exports.getViewportScale=$v,exports.headingToLongitude=Gt,exports.imageSupport=Nr,exports.isBoundingVolume=Al,exports.isPanoId=xp,exports.ktx2=po,exports.loadAt3d=ia,exports.loadB3dm=fs,exports.loadDome=ca,exports.loadDomez=ha,exports.loadFbx=Dc,exports.loadGltf=xs,exports.loadPbm=Ii,exports.loadPly=Cs,exports.loadPnts=ys,exports.loadSplat=ul,exports.loadSpz=is,exports.loadX3p=sl,exports.longitudeToHeading=Wt,exports.makeBoundingVolume=jl,exports.panoEqual=bp,exports.panoParse=yp,exports.panoStringify=Z,exports.parseWork=nm,exports.vectorToCoordinates=Ut,exports.workToJson=sp;