@realsee/five-webgpu 1.0.0-alpha.1 → 1.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/ai_guides/README.md +2 -2
- package/ai_guides/features/clipper.md +1 -1
- package/ai_guides/features/coordinate-system.md +1 -1
- package/ai_guides/features/event.md +1 -1
- package/ai_guides/features/five.md +3 -3
- package/ai_guides/features/gesture.md +2 -2
- package/ai_guides/features/get-screen-pixels.md +1 -1
- package/ai_guides/features/image-options.md +3 -3
- package/ai_guides/features/load-external-model.md +9 -9
- package/ai_guides/features/mode.md +2 -2
- package/ai_guides/features/pano-filter.md +3 -3
- package/ai_guides/features/pano-tile.md +2 -2
- package/ai_guides/features/raycast.md +1 -1
- package/ai_guides/features/screen-project.md +1 -1
- package/ai_guides/features/state.md +1 -1
- package/ai_guides/features/work.md +2 -2
- package/ai_guides/quick-start.md +3 -3
- package/ai_guides/release_notes/6.6.md +2 -2
- package/ai_guides/release_notes/6.7.md +1 -1
- package/ai_guides/release_notes/6.8.md +1 -1
- package/docs/documents/README.html +2 -2
- package/docs/documents/features_clipper.html +1 -1
- package/docs/documents/features_coordinate-system.html +1 -1
- package/docs/documents/features_event.html +1 -1
- package/docs/documents/features_five.html +3 -3
- package/docs/documents/features_gesture.html +2 -2
- package/docs/documents/features_get-screen-pixels.html +1 -1
- package/docs/documents/features_image-options.html +3 -3
- package/docs/documents/features_load-external-model.html +8 -8
- package/docs/documents/features_mode.html +2 -2
- package/docs/documents/features_pano-filter.html +3 -3
- package/docs/documents/features_pano-tile.html +2 -2
- package/docs/documents/features_raycast.html +1 -1
- package/docs/documents/features_screen-project.html +1 -1
- package/docs/documents/features_state.html +1 -1
- package/docs/documents/features_work.html +2 -2
- package/docs/documents/quick-start.html +2 -2
- package/docs/documents/release_notes_6.6.html +2 -2
- package/docs/documents/release_notes_6.7.html +1 -1
- package/docs/documents/release_notes_6.8.html +1 -1
- package/docs/index.html +2 -2
- package/five/index.js +3 -3
- package/five/index.mjs +3 -3
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/plugins/BasePlugin/index.d.ts +1 -1
- package/plugins/GaussianSplattingEntranceAnimationPlugin/Controller.d.ts +1 -1
- package/plugins/GaussianSplattingEntranceAnimationPlugin/index.d.ts +1 -1
- package/plugins/index.js +3 -3
- package/plugins/index.mjs +3 -3
- package/react/context.d.ts +1 -1
- package/react/createProvider.d.ts +1 -1
- package/react/fiveApp.d.ts +1 -1
- package/react/hooks/unsafe__useFiveInstance.d.ts +1 -1
- package/react/hooks/useFiveAction.d.ts +1 -1
- package/react/hooks/useFiveCurrentObserver.d.ts +1 -1
- package/react/hooks/useFiveCurrentState.d.ts +1 -1
- package/react/hooks/useFiveEventCallback.d.ts +1 -1
- package/react/hooks/useFiveModelEffect.d.ts +1 -1
- package/react/hooks/useFiveModelIntersectRaycaster.d.ts +1 -1
- package/react/hooks/useFivePlugin.d.ts +1 -1
- package/react/hooks/useFiveSceneEffect.d.ts +1 -1
- package/react/hooks/useFiveState.d.ts +1 -1
- package/react/hooks/useFiveWork.d.ts +1 -1
- package/react/index.js +3 -3
- package/react/index.mjs +3 -3
- package/react/withFive.d.ts +1 -1
- package/umd/five-plugins.js +3 -3
- package/umd/five-react.js +3 -3
- package/umd/five.js +3 -3
package/umd/five.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
3
|
* @realsee/five-webgpu
|
|
4
|
-
* Generated:
|
|
5
|
-
* Version: 1.0.0-alpha.
|
|
4
|
+
* Generated: 7/15/2026
|
|
5
|
+
* Version: 1.0.0-alpha.2
|
|
6
6
|
* Terms:
|
|
7
7
|
* Realsee SDK License Agreement
|
|
8
8
|
* Update: July 28, 2021
|
|
@@ -1576,4 +1576,4 @@ void main() {
|
|
|
1576
1576
|
float cameraDepth = length(cameraVertex);
|
|
1577
1577
|
gl_FragColor = packDepthToRGBA(clamp(cameraDepth / maxDepth, 0.0, 1.0));
|
|
1578
1578
|
}
|
|
1579
|
-
`,uniforms:{maxDepth:new qd(0)}});function f9(e,t,n,r=1e3){d9.uniforms.maxDepth.value=r,e.getClearColor(u9);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=d9,e.setClearColor(l9,0),n.update(e,t),e.setClearColor(u9,i),t.overrideMaterial=a}var p9=S$,m9=new $d,h9=new M,g9=[new M(0,0,0).multiplyScalar(.1),new M(1,0,0).multiplyScalar(.1),new M(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new M(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],_9=Object.assign(Object.assign({},S7),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new m5:new o5,adjustPanoCircleMeshPositionBasedOnModel:!1,tileLevelForFov:((e,t)=>{var n;let r=e=>e/180*Math.PI,i=(n=Math.log2)==null?(e=>Math.log(e)*Math.LOG2E):n,a=t.height/2/Math.tan(r(e/2))*Math.tan(r(45))*2,o=Math.max(i(a/512),0);return o<2.3&&o>.1&&(o=1),o=o%1>.75?Math.ceil(o):Math.floor(o),o}),tileAppearDuration:.5,tileMaxRequest:3,flyEffectUseDepthBuffer:!1}),v9=class e extends C7{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{maxAccessibleDistance:(n=t.maxAccessibleDistance)==null?_9.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?_9.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?_9.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?_9.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?_9.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?_9.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?_9.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?_9.flyEffectUseDepthBuffer:l})}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`Panorama`})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Panorama`,this.initAnimationed=!1,this.maxAccessibleDistance=n.maxAccessibleDistance,this.panoTapTriggerRadius=n.panoTapTriggerRadius,this.panoCircleMeshCreator=n.panoCircleMeshCreator,this.adjustPanoCircleMeshPositionBasedOnModel=n.adjustPanoCircleMeshPositionBasedOnModel,this.tileLevelForFov=n.tileLevelForFov,this.tileAppearDuration=n.tileAppearDuration,this.tileMaxRequest=n.tileMaxRequest,this.flyEffectUseDepthBuffer=n.flyEffectUseDepthBuffer,this.adjustPanoCircleMeshPositionFix=new Map;let{pano0:r,pano1:i}=this.modelScene.parameter.resolveValue();r&&(i==null?void 0:i.map)!==r.map&&(this.modelScene.parameter.set({pano0:i}),r.map.dispose());let a=new Set;r&&a.add(r),i&&a.add(i),this.panoMeshes=new Map,this.locationMotion=new b$({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=eV()]={panoId:u3(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:p9,fixCameraTransform:new N},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new gJ,this.tiling=new r9({fiveId:this.fiveId}),this.panoVideo=new c9,this.scene.add(this.panoVideo.object),this.accessibleObserverFloorCheckCount=0}get tileLevel(){return this.tiling.level}updateConfiguration(e){return super.updateConfiguration(e)===!1?!1:(e.maxAccessibleDistance!==void 0&&this.maxAccessibleDistance!==e.maxAccessibleDistance&&(this.maxAccessibleDistance=e.maxAccessibleDistance),e.panoTapTriggerRadius!==void 0&&this.panoTapTriggerRadius!==e.panoTapTriggerRadius&&(this.panoTapTriggerRadius=e.panoTapTriggerRadius),e.panoCircleMeshCreator!==void 0&&this.panoCircleMeshCreator!==e.panoCircleMeshCreator&&(this.panoCircleMeshCreator=e.panoCircleMeshCreator,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear())),e.tileLevelForFov!==void 0&&this.tileLevelForFov!==e.tileLevelForFov&&(this.tileLevelForFov=e.tileLevelForFov),e.tileMaxRequest!==void 0&&this.tileMaxRequest!==e.tileMaxRequest&&(this.tileMaxRequest=e.tileMaxRequest),e.flyEffectUseDepthBuffer!==void 0&&this.flyEffectUseDepthBuffer!==e.flyEffectUseDepthBuffer&&(this.flyEffectUseDepthBuffer=e.flyEffectUseDepthBuffer),e.adjustPanoCircleMeshPositionBasedOnModel!==void 0&&this.adjustPanoCircleMeshPositionBasedOnModel!==e.adjustPanoCircleMeshPositionBasedOnModel&&(this.adjustPanoCircleMeshPositionBasedOnModel=e.adjustPanoCircleMeshPositionBasedOnModel,this.adjustPanoCircleMeshPositionBasedOnModel||this.adjustPanoCircleMeshPositionFix.clear()),!0)}destroy(){super.destroy(),this.tiling.dispose(),this.modelScene.parameter.set({refinedScreen:null,pano0Depth:null,pano1Depth:null}),this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0),this.locationMotion.dispose(),this.pendingTextureTask=void 0,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear());let e=this.videoTexture.image;e.pause(),e.oncanplay=X,e.ontimeupdate=X,this.scene.remove(this.panoVideo.object),this.panoVideo.setMaterial(null),this.panoVideo.dispose();let{pano0:t,pano1:n}=this.modelScene.parameter.resolveValue();for(let e of Object.keys(this.panoResources)){let r=this.panoResources[e];if(r.panoPicture){let e=r.panoPicture.map;e&&e!==(t==null?void 0:t.map)&&e!==(n==null?void 0:n.map)&&(e.dispose(),r.panoPicture=null)}delete this.panoResources[e]}}isReady(){return this.locationMotion.ended===!0?super.isReady():!1}isTileReady(){let e=this.tiling.pedding<=0;return this.initAnimationed&&e}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&(this.initAnimationed=!1,this.moveToPano({workCode:a.workCode,panoIndex:a.panoIndex},{effect:r.effect,duration:r.duration,longitude:a.longitude,latitude:a.latitude,fov:a.fov,moveEndCallback:()=>{this.initAnimationed=!0},moveCancelCallback:()=>{this.initAnimationed=!0}},i)),!0}updateModel(e){this.modelScene=e,this.hideIntersectMesh()}updateTime(e,t,...n){var r,i,a,o,s,c,l;if(this.destroyed)return;let u={},d={},f=this.camera.getDirection(new M),p=this.locationMotion.keyframes[0],m=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[h,g]=this.locationMotion.getKeyFrameSegment(e),_=this.panoResourceFromLocationMotionKeyframe(h),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(p),b=this.panoResourceFromLocationMotionKeyframe(m),x=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),d.longitude=this.cameraMotion.value.longitude,d.latitude=this.cameraMotion.value.latitude,d.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),u.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-g.value.count+1,n=new M().copy(_.position),a=new M().copy(v.position);if(u.progress=v.effectEasing(t),t>=.01&&t<=.99&&(u.progress=Y(v.effectEasing(t),.01,.99)),v.panoPicture&&(t<1?_.panoPicture&&(u.pano0=_.panoPicture):u.pano0=v.panoPicture,u.pano1=v.panoPicture),v.effect===`montage`?u.transition=`BLACK`:v.effect===`spread`?u.transition=`SPREAD`:u.transition=`FADE`,v.effect===`zoomin`||v.effect===`zoomout`?u.progress=Math.pow(t,3):v.effect===`model`&&this.camera.pose.distance<.01&&(u.modelAlpha=1-Math.pow(Y(Math.abs(t-.5)*2,0,1),4)),t<1&&v.effect!==`fly`&&v.effect!==`model`){if(u.pano0&&_.panoPicture){let e={panoId:u.pano0.panoId,map:u.pano0.map,mapHistogram:u.pano0.mapHistogram,mapSize:u.pano0.mapSize,zoom:u.pano0.zoom,matrix:_.panoPicture.matrix.clone().premultiply(_.fixCameraTransform).setPosition(v.position),hdrConfig:u.pano0.hdrConfig?Object.assign({},u.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(u.pano0);t&&this.panoPictureObserverMap.set(e,t),u.pano0=e}n.copy(a),x=!0}d.distance=this.locationMotion.value.distance,d.offset=new M(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.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=u.pano0)==null?void 0:r.map)||e===((i=u.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let c=d3(v.panoId);c!==this.currentPano&&(this.currentPano=c,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:d3(y.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},d3(b.panoId)),{mode:this.mode}),j5(this.camera.pose)),d),options:{},progress:this.locationMotion.progress,error:null}))}P5(u)===!1&&this.modelScene.parameter.set(u),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),P5(d)===!1&&this.setCamera(d);let S=this.works.getObserver(this.currentPano),C=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,w=this.works.getObserver(_.panoId),T=this.works.getObserver(v.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&S){let e=[],t=S.work.observers;for(let n of S.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(S.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(S.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=u3({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=g9.map(t=>{m9.ray.origin.copy(i),m9.ray.origin.add(h9.copy(t).setY(e)),m9.ray.direction.set(0,-1,0),m9.firstHitOnly=!0,m9.floorIndex=-1;let[a]=n.intersectRaycaster(m9);return a&&a.distance-r<=e?new M().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[c]=o.filter(e=>e.distanceTo(s)<=.05);if(c){let e=new dr(i.x,i.y,i.z,c.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let E=new Map;if(w)for(let e of w.accessibleNodes){let t=w.work.observers[e];if(t){let e=u3({panoIndex:t.panoIndex,workCode:t.work.workCode});E.set(e,t)}}if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=u3({panoIndex:t.panoIndex,workCode:t.work.workCode});E.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{E.get(t)?E.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),E.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),E.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&&(h9.set(t.x,t.y,t.z),h9.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 M().copy(e.position).sub(i).normalize();if(t===u3(this.currentPano)){let t=Y((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(f.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 Dr(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||x)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(S){let n=S.work.observers,[,r]=rQ(S.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:S.standingPosition.distanceTo(t.standingPosition)},!0);r=Y(r,3,1/0);let i=S.accessibleNodes.concat(S.panoIndex).map(e=>u3({panoIndex:e,workCode:S.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&&C!==null&&u3({panoIndex:C.panoIndex,workCode:C.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:Y(r/t,.1,.85)}o&&o===T&&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=(a=this.modelScene.parameter.progress)==null?1:a,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,c;if(i&&(c=this.works.getObserver(i.panoId),c||(c=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(cJ()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!c||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:null,gainMap:void 0,panoMatrix:new N,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=$q(i.mapSize),a=e+1,l=new j().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),u=Math.floor(this.tileLevelForFov(this.camera.fov,l)),d=u>e?u:0;this.tiling.setObserver(c);let f={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:i.map,gainMap:(o=i.hdrConfig)==null?void 0:o.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:a,level:d,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},p=this.tiling.update(f),m={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:w$(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},h=this.modelScene.parameter.refinedScreen;(p||m.pano!==(h==null?void 0:h.pano)||m.opacity!==(h==null?void 0:h.opacity))&&this.modelScene.parameter.set(`refinedScreen`,m)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),S&&S.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&S&&S.position.y-S.standingPosition.y>10){let e=Y(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=v.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((c=this.modelScene.parameter.pano0Depth)==null?void 0:c.panoId)!==t.panoId||((l=this.modelScene.parameter.pano1Depth)==null?void 0:l.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new _w(512,{minFilter:D,magFilter:D,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new _w(512,{minFilter:D,magFilter:D,generateMipmaps:!1});let e=new fd(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,f9(this.renderer,this.modelScene,e,500);let r=new fd(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,f9(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))}}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1],n=this.panoResourceFromLocationMotionKeyframe(t),r=this.works.getObserver(n.panoId);return{workCode:r?r.work.workCode:this.currentPano.workCode,panoIndex:r?r.panoIndex:this.currentPano.panoIndex,mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:r?r.position.clone().applyMatrix4(r.work.transform):this.camera.position.clone(),distance:this.locationMotion.value.distance}}moveToPano(e,t,n){var r,i,a;let o=(r=t.effect)==null?`fly`:r;this.userAction=n,this.stopMomentumMovement();let s=u3(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let l=Xq(c.images.up),u=this.imageOptions.size;u===void 0&&c&&l&&(u=Number(l)),u===void 0&&(u=2048);let d=this.imageOptions.transform,f=Object.assign({key:`pano.${s}`},hq(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),p={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},m,h=``;c.images.hdrConfig&&(m={right:c.images.work.getURL(c.images.gainmap_right),left:c.images.work.getURL(c.images.gainmap_left),up:c.images.work.getURL(c.images.gainmap_up),down:c.images.work.getURL(c.images.gainmap_down),front:c.images.work.getURL(c.images.gainmap_front),back:c.images.work.getURL(c.images.gainmap_back)},h=c.images.work.getURL(c.images.hdrConfig));let g=`pano:`+c3([p,f,d]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===g)return;{let e=this.pendingTextureTask.panoId;(i=this.panoMeshes.get(e))==null||i.setProgress(0),this.emit(`pano.texture.abort`,$(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode}}))}}let _=`move-to-pano-`+s;this.pending.add(_);let v=this.modelScene.parameter,y;if(v.pano0&&v.pano0.map.name===g?y=v.pano0:v.pano1&&v.pano1.map.name===g&&(y=v.pano1),y){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?p9:a,panoPicture:{panoId:y.panoId,map:y.map,mapHistogram:y.mapHistogram,mapSize:y.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:y.hdrConfig?Object.assign({},y.hdrConfig):void 0},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new N};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,c),this.pendingTextureTask=void 0,iJ.shared.add(()=>{this.pending.delete(_),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:g,onLoad:(n,r)=>EV(this,void 0,void 0,function*(){var i,a;let l=n.body;if(this.destroyed)l.dispose();else{l.name=g;let n=Array.isArray(l.image)?l.image[0]:l.image,u=(i=n==null?void 0:n.width)==null?2048:i,{data:d}=yield X5(this.renderer,l,!0,n8),f=new o8().formPixels(d),p={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?p9:a,panoPicture:{panoId:s,map:l,mapSize:u,mapHistogram:new dr().fromArray(f.toArray()),matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:r},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new N};p.panoPicture&&this.panoPictureObserverMap.set(p.panoPicture,c),this.doMoveToPano(e,p,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),j5(this.camera.pose));this.emit(`pano.error`,$(`pano.error`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`pano.cancel`,$(`pano.cancel`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`error`,n),t.moveCancelCallback&&t.moveCancelCallback()}};let b=this.panoMeshes.get(s);b&&b.tap&&b.tap();let x=[this.textureLoader.loadCubeTexture(p,{imageURL:{transform:d,options:f},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,$(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingTextureTask)==null?void 0:n.hash)===g&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];h&&x.push(fetch(h).then(e=>e.json()),this.textureLoader.loadCubeTexture(m,{imageURL:{transform:d,options:f},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,c.work)},void 0,void 0,void 0,this.renderer)),Promise.all(x).then(([t,n,r])=>{var i,a;this.pending.delete(_),((i=this.pendingTextureTask)==null?void 0:i.hash)===g?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},h7(n))),this.pendingTextureTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,$(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}))}).catch(t=>{var n,r;this.pending.delete(_),((n=this.pendingTextureTask)==null?void 0:n.hash)===g&&(this.pendingTextureTask.onError(t),this.pendingTextureTask=void 0,(r=this.panoMeshes.get(s))==null||r.setProgress(0)),this.emit(`pano.texture.error`,$(`pano.texture.error`,{error:t,progress:0,meta:null,pano:e})),this.emit(`error`,t)}),this.emit(`pano.texture.load`,$(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{duration:n,effect:r,userAction:i}=this.initial;this.userAction=i;let a=e.initAnimationEndState(this),o={workCode:a.workCode,panoIndex:a.panoIndex},s={modelAlpha:0},c={perspToOrtho:0},l=!1;this.moveToPano(o,{longitude:a.longitude,latitude:a.latitude,fov:a.fov,effect:r,duration:n,moveStartCallback:e=>{l=!0,this.perspToOrthoMotion.set(c,n).catch(X),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:s}],n).catch(X),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()},moveCancelCallback:()=>{let e=Object.assign(Object.assign(Object.assign({},o),{mode:this.mode}),j5(this.camera.pose));l===!1&&this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction})),this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()}},i)})}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}locationMotionKeyframesLength(e){let t=0;for(let n=1;n<e.length;n++){let r=this.panoResourceFromLocationMotionKeyframe(e[n-1]).position,i=this.panoResourceFromLocationMotionKeyframe(e[n]).position,a=r.distanceTo(i)*(e[n].value.count-e[n-1].value.count);t+=a}return t}doMoveToPano(e,t,n={}){var r,i,a,o,s,c,l,u,d,f,p;let m=HU(),h=eV();this.panoResources[h]=t;let g,_,v;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(m),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;g=Math.max(a.distanceTo(o),1),_=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{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=l===0||l===0?0: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:(i=b.longitude)==null?this.camera.pose.longitude:i,latitude:(a=b.latitude)==null?this.camera.pose.latitude:a,fov:(o=b.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),S=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:S,progress:0,state:x,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(x),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=X,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(b,y).catch(X);else{let e=LU({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=LU({longitude:(s=b.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=b.latitude)==null?this.cameraMotion.value.latitude:c}),r=new Wr;r.lookAt(e);let i=new N().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new N().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),m=this.cameraMotion.value.fov,h=(l=b.fov)==null?this.cameraMotion.value.fov:l,g=1;t.effect===`zoomin`?g=1.5:t.effect===`zoomout`&&(g=.4);let v=Y(h*g,1,170);for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(v/2/180*Math.PI)/Math.tan(m/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:v}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:h}}],y).catch(X)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof j4&&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:this.camera.pose.distance});this.emit(`pano.arrived`,$(`pano.arrived`,{options:n,prevPano:S,progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(e);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=eV(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=X,n.ontimeupdate=X,E7().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=X,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=X,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=X,e.ontimeupdate=X}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:S,progress:0,state:x,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}getForwardObserverOrNot(e,t){let n=this.works.getObserver(this.currentPano);if(!n)return null;let r=t==null?new $d(e.position.clone(),e.getWorldDirection(new M)):t;r.params.Points={threshold:.1},r.firstHitOnly=!0,r.floorIndex=-1;let i=n.standingPosition.clone().applyMatrix4(n.work.transform);if(n.position.clone().applyMatrix4(n.work.transform).distanceTo(r.ray.origin)>1){let e=new $d(r.ray.origin,new M(0,-1,0));e.firstHitOnly=r.firstHitOnly,e.floorIndex=r.floorIndex;let[t]=this.modelScene.intersectRaycaster(e);t&&t.distance<=2?i.copy(t.point):i.copy(r.ray.origin).add(new M(0,-1.5,0))}let[a]=this.modelScene.intersectRaycaster(r),o=(a?a.point:r.ray.origin.clone().add(r.ray.direction.clone().normalize().multiplyScalar(3))).clone().sub(i).normalize();if(o.length()===0)return null;let s=n.work.observers,c=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.standingPosition.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),l=new Map,u=c.slice().sort((e,t)=>{let n=s[e],r=l.get(n);r===void 0&&(r=h9.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),l.set(n,r));let a=s[t],o=l.get(a);return o===void 0&&(o=h9.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),l.set(a,o)),r-o});l.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of u){let n=s[t];if(n){let t=h9.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let d=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,h9);n&&(n.project(e),Math.abs(n.z)<=1&&(d=n.clone()))}else d=new M(0,0,0);if(d){let t=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.position.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),r=new Map,i=t.slice().sort((t,n)=>{let i=s[t],a=r.get(i);a===void 0&&(a=h9.copy(i.position).applyMatrix4(i.work.transform).distanceTo(e.position),r.set(i,a));let o=s[n],c=r.get(o);return c===void 0&&(c=h9.copy(o.position).applyMatrix4(o.work.transform).distanceTo(e.position),r.set(o,c)),a-c});r.clear();for(let t of i){let n=s[t];if(n){let t=h9.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(d.x-t.x,2)+Math.pow(d.y-t.y,2)<Math.pow(.4,2))return n}}}return null}onTapGesture(e){var t;if(this.userAction=e.userAction,this.stopMomentumMovement(),!this.initAnimationed)return;let n=e.center.raycaster;n.floorIndex=-1;let r=this.camera.getDirection(new M).setY(0),i=null,a=this.works.getObserver(this.currentPano);if(!a)return;let o=a.work.observers,s=a.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&a.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||h9.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(n);if(c){let[e,n]=rQ(s,e=>{let t=o[e];return t?h9.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&n<this.panoTapTriggerRadius&&(i=(t=o[e])==null?null:t)}if(i||(i=this.getForwardObserverOrNot(this.camera,n)),i&&i.panoId===u3(this.currentPano)&&(i=null),i&&!this.locationMotion.ended){for(let e of this.locationMotion.keyframes)if(this.panoResourceFromLocationMotionKeyframe(e).panoId===i.panoId){i=null;break}}if(!i)this.emit(`gesture.tap`,e),e.defaultPrevented||this.locationMotion.ended===!0&&this.cameraBounce();else{let t={},n=Math.PI/6,o=Math.PI/12,s=i.position.clone().applyMatrix4(i.work.transform).setY(0).sub(a.position.clone().applyMatrix4(i.work.transform).setY(0)).normalize(),c=[],l=[],u=[],d=i.work.observers;for(let e of i.accessibleNodes){if(i.panoIndex===e||e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)continue;let t=d[e];if(!t)continue;let r=t.position.clone().applyMatrix4(t.work.transform).sub(i.position.clone().applyMatrix4(i.work.transform)).setY(0).normalize();s.angleTo(r)<n&&u.push(r)}let[f]=(u.length>0?u:[...c,...l]).slice().sort((e,t)=>e.angleTo(s)-t.angleTo(s));if(f&&f.angleTo(r)>o&&(t.longitude=Math.atan2(-f.x,-f.z)),this.cameraMotion.value.latitude<-Math.PI/4){let n=e.state.fov;t.latitude=Y(0,Y(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),Y(typeof this.maxLatitude==`function`?this.maxLatitude(n):this.maxLatitude,-Math.PI/2,Math.PI/2))}let p=Object.assign({},e.state);if(p.workCode=i.work.workCode,p.panoIndex=i.panoIndex,t.longitude!==void 0&&(p.longitude=t.longitude),t.latitude!==void 0&&(p.latitude=t.latitude),t.fov!==void 0&&(p.fov=t.fov),p.distance=0,p.offset=i.position.clone(),e.state=p,this.emit(`gesture.tap`,e),!e.defaultPrevented){if(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:p,userAction:e.userAction,options:t,progress:0,error:null})),i&&!i.active){let e=u3({panoIndex:i.panoIndex,workCode:i.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}i&&i.active&&this.emit(`pano.request`,$(`pano.request`,{userAction:e.userAction,prevPano:this.currentPano,progress:0,state:p,options:t,error:null}))}}}},y9=new M(0,1.6,0),b9=new gi,x9=new M,S9=Object.assign({},S7),C9=class e extends C7{static parseArgs(t){return t instanceof e?t:super.parseArgs(t)}static initAnimationEndState(e){var t,n,r,i,a,o;let s=this.parseArgs(e),c=s.works,{state:l,currentState:u}=e.initial,d=typeof l.panoIndex==`number`?{workCode:(r=(t=l.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:l.panoIndex}:{workCode:u.workCode,panoIndex:u.panoIndex},f=c.getObserver(d),p=Y((i=l.fov)==null?!f||N5(u.mode)?u.fov:s.defaultFov:i,s.minFov,s.maxFov),m=(a=l.longitude)==null?u.longitude:a,h=Y(typeof s.minLatitude==`function`?s.minLatitude(p):s.minLatitude,-Math.PI/2,Math.PI/2),g=Y(typeof s.maxLatitude==`function`?s.maxLatitude(p):s.maxLatitude,-Math.PI/2,Math.PI/2),_=Y((o=l.latitude)==null?!f||N5(u.mode)?u.latitude:s.defaultLatitude:o,h,g),v=new M;if(s.initial.state.offset)v.copy(s.initial.state.offset);else if(f)v.copy(f.position).applyMatrix4(f.work.transform);else{let e=LU(u).setLength(u.distance);v.copy(s.initial.currentState.offset).sub(e)}return{workCode:d.workCode,panoIndex:d.panoIndex,mode:`Model`,longitude:m,latitude:_,fov:p,offset:v,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new b$({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x})}updateConfiguration(e){return super.updateConfiguration(e)}destroy(){super.destroy(),this.locationMotion.dispose()}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&this.moveToPosition(a.offset,{duration:0,longitude:a.longitude,latitude:a.latitude,fov:a.fov},i),!0}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return r.distance=0,e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(X),this.cameraMotion.set(i,t).catch(X)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:0,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(X),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t,...n){if(this.destroyed)return;let r={},i={};if(this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),r.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),r.progress=1,r.pano0=r.pano1=t}if(this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),n=[];for(let e of this.works){let r=this.modelScene.models.find(t=>t.work===e);if(!(!r||r.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=rQ(n,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t));this.currentPano=r?{workCode:r.work.workCode,panoIndex:r.panoIndex}:{workCode:``,panoIndex:0}}this.cameraMotion.ended||(this.cameraMotion.update(e),i.longitude=this.cameraMotion.value.longitude,i.latitude=this.cameraMotion.value.latitude,i.fov=this.cameraMotion.value.fov),P5(r)||this.modelScene.parameter.set(r),P5(i)||this.setCamera(i);let a=this.works.getObserver(this.currentPano);if(this.intersectMesh&&this.intersectMesh.parent&&a&&a.position.y-a.standingPosition.y>10){let e=Y(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)}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={modelAlpha:1},c={perspToOrtho:0},l={longitude:o.longitude,latitude:o.latitude,fov:o.fov,duration:i,moveStartCallback:e=>{this.perspToOrthoMotion.set(c,i).catch(X),this.modelAlphaMotion.set(s,i).catch(X),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),t()},moveCancelCallback:()=>{let e=this.currentPano,n=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:this.camera.pose.distance});this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:n,userAction:this.userAction})),t()}};this.moveToPosition(o.offset,l,a)})}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:new M(t.value.x,t.value.y,t.value.z),distance:t.value.distance})}moveToPano(e,t={},n){let r=this.works.getObserver(e);if(r){let e=new M().copy(r.position).applyMatrix4(r.work.transform);this.moveToPosition(e,t,n)}}moveToPosition(e,t={},n){var r,i,a;this.userAction=n,this.stopMomentumMovement();let o=HU(),s=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),c=s.distanceTo(e),l=this.locationMotion.getProgressVelocity(o),u=0;for(let e=1;e<this.locationMotion.keyframes.length;e++){let{x:t,y:n,z:r}=this.locationMotion.keyframes[e-1].value,{x:i,y:a,z:o}=this.locationMotion.keyframes[e].value;u+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let d=c===0?0:l*u/c,f=this.calculateMovingDuration(t.duration,c),p={x:e.x,y:e.y,z:e.z,distance:0},m={longitude:t.longitude,latitude:t.latitude,fov:t.fov},h=[];for(let e of this.works){let t=this.modelScene.models.find(t=>t.work===e);if(!(!t||t.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(s)))for(let t of e.observers)h.push(t)}let g=rQ(h,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),_=g?{workCode:g.work.workCode,panoIndex:g.panoIndex}:{workCode:``,panoIndex:0},v=Object.assign(Object.assign({},_),{mode:this.mode,longitude:(r=m.longitude)==null?this.camera.pose.longitude:r,latitude:(i=m.latitude)==null?this.camera.pose.latitude:i,fov:(a=m.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),y=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:y,progress:0,state:v,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(v),this.cameraMotion.set(m,f).catch(X),this.locationMotion.set(p,f,d).then(()=>{for(let e of this.modelScene.children)e instanceof j4&&e.show();let e=Object.assign(Object.assign(Object.assign({},_),{mode:this.mode}),j5(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:y,progress:0,state:e,userAction:this.userAction,error:null})),t.moveEndCallback&&t.moveEndCallback(e)},()=>{t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.cancel`,$(`pano.cancel`,{options:t,prevPano:y,progress:0,state:v,userAction:this.userAction,error:null}))})}onTapGesture(e){let t=e.center.raycaster;this.stopMomentumMovement();let[n]=this.modelScene.intersectRaycaster(t);if(n&&n.face){let e=n.face.normal,t=n.point;if(new M(0,1,0).angleTo(e)>Math.PI/3){let r=new $d;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new M(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new M().copy(n.point).add(y9),r=[];for(let e of this.works){let n=this.modelScene.models.find(t=>t.work===e);if(!(!n||n.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=rQ(r,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=x9.copy(i.position).applyMatrix4(i.work.transform).y),e.state.offset.copy(t),e.state.distance=0,this.emit(`gesture.tap`,e),e.defaultPrevented||this.moveToPosition(t,{},!0)}else this.emit(`gesture.tap`,e),e.defaultPrevented||this.cameraBounce()}},w9=new gi,T9=new M,E9=.5,D9=Math.PI/7,O9={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new f7},k9={Floorplan:y7,Topview:x7,Panorama:v9,Model:C9,Mapview:class e extends Q5{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{defaultLongitude:(n=t.defaultLongitude)==null?O9.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?O9.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?O9.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?O9.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?O9.minLatitude:o,cameraType:(s=t.cameraType)==null?O9.cameraType:s,cameraFence:(c=t.cameraFence)==null?O9.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?O9.intersectMeshCreator:l})}static distanceFromModel(e,t,n){let r=e.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2);i=isNaN(i)||!isFinite(i)?1:i;let a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),isNaN(a)||!isFinite(a)?i:a}static initAnimationEndState(t){var n,r,i,a,o,s,c;let l=this.parseArgs(t),u=l.works,d=l.modelScene,{state:f,currentState:p}=t.initial,m=typeof f.panoIndex==`number`?{workCode:(i=(n=f.workCode)==null?(r=l.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:f.panoIndex}:{workCode:p.workCode,panoIndex:p.panoIndex},h=(a=f.fov)==null?60:a,g=Y(typeof l.minLatitude==`function`?l.minLatitude(h):l.minLatitude,-Math.PI/2,Math.PI/2),_=Y(typeof l.maxLatitude==`function`?l.maxLatitude(h):l.maxLatitude,-Math.PI/2,Math.PI/2),v=Y((o=f.latitude)==null?M5(p.mode)?p.latitude:l.defaultLatitude:o,g,_),y=e.distanceFromModel(l.modelScene,h,l.camera.aspect),b=new M,x=(s=f.distance)==null?Math.min(l.defaultDistance,y):s,S=(c=f.longitude)==null?M5(p.mode)?p.longitude:l.defaultLongitude:c;if(f.offset)b.copy(f.offset);else{let e=u.getObserver(m);l.defaultDistance<y&&e?(b.copy(e.position).applyMatrix4(e.work.transform),f.longitude===void 0&&(S=p.longitude)):(d.boundingBox.getCenter(b),x=y)}return Object.assign(Object.assign({},m),{mode:`Mapview`,longitude:S,latitude:v,fov:h,offset:b,distance:x})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Mapview`,this.defaultLongitude=n.defaultLongitude,this.defaultLatitude=n.defaultLatitude,this.defaultDistance=n.defaultDistance,this.maxLatitude=n.maxLatitude,this.minLatitude=n.minLatitude,this.cameraType=n.cameraType,this.cameraFence=n.cameraFence,this.locationMotion=new b$({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new gJ,this.intersectMeshCreator=n.intersectMeshCreator,this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=`intersect`,this.intersectMesh.visible=!1,this.helper.add(this.intersectMesh)}updateConfiguration(e){if(super.updateConfiguration(e)===!1)return!1;if(e.defaultLongitude!==void 0&&this.defaultLongitude!==e.defaultLongitude&&(this.defaultLongitude=e.defaultLongitude),e.defaultLatitude!==void 0&&this.defaultLatitude!==e.defaultLatitude&&(this.defaultLatitude=e.defaultLatitude),e.defaultDistance!==void 0&&this.defaultDistance!==e.defaultDistance&&(this.defaultDistance=e.defaultDistance),e.maxLatitude!==void 0&&this.maxLatitude!==e.maxLatitude&&(this.maxLatitude=e.maxLatitude),e.minLatitude!==void 0&&this.minLatitude!==e.minLatitude&&(this.minLatitude=e.minLatitude),e.cameraType!==void 0&&this.cameraType!==e.cameraType&&(this.cameraType=e.cameraType),this.cameraFence instanceof gi&&e.cameraFence instanceof gi||this.cameraFence instanceof Zi&&e.cameraFence instanceof Zi?this.cameraFence.equals(e.cameraFence)||(this.cameraFence=e.cameraFence):e.cameraFence!==void 0&&(this.cameraFence=e.cameraFence),e.intersectMeshCreator!==void 0&&this.intersectMeshCreator!==e.intersectMeshCreator){this.intersectMeshCreator=e.intersectMeshCreator;let t=this.intersectMesh;this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=t.name,this.intersectMesh.visible=t.visible;let n=this.intersectMesh.parent;n&&n.add(this.intersectMesh),t.dispose()}return!0}destroy(){super.destroy(),this.pendingTextureId=null,this.locationMotion.dispose(),this.panState=void 0,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));this.currentPano={workCode:a.workCode,panoIndex:a.panoIndex};let o={longitude:a.longitude,latitude:a.latitude,fov:a.fov},s={x:a.offset.x,y:a.offset.y,z:a.offset.z,distance:a.distance};return(o.longitude!==this.cameraMotion.value.longitude||o.latitude!==this.cameraMotion.value.latitude||o.fov!==this.cameraMotion.value.fov)&&this.cameraMotion.set(o,r.duration).catch(X),(s.x!==this.locationMotion.value.x||s.y!==this.locationMotion.value.y||s.z!==this.locationMotion.value.z||s.distance!==this.locationMotion.value.distance)&&this.locationMotion.set(s,r.duration).catch(X),!0}updateModel(e){super.updateModel(e),this.hideIntersectMesh()}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return e.distance!==void 0&&(r.distance=e.distance),e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(X),this.cameraMotion.set(i,t).catch(X)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:t.value.distance,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(X),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t){if(this.destroyed)return;let n={},r={};if(this.locationMotion.ended||(this.locationMotion.update(e),r.distance=this.locationMotion.value.distance,r.offset=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),r.longitude=this.cameraMotion.value.longitude,r.latitude=this.cameraMotion.value.latitude,r.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),n.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),n.progress=1,n.pano0=n.pano1=t}let i=0;if(this.cameraType===`auto`?i=+(Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02):this.cameraType===`perspective`?i=0:this.cameraType===`orthographic`&&(i=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==i&&this.perspToOrthoMotion.set({perspToOrtho:i},500).catch(X),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),P5(n)||this.modelScene.parameter.set(n),P5(r)||this.setCamera(r),this.cameraFence&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&!this.inMomentumMovement&&this.locationMotion.ended&&this.perspToOrthoMotion.ended&&this.cameraMotion.ended){let e=LU(this.camera.pose,new M),t=new M().copy(this.camera.pose.offset).sub(e.clone().multiplyScalar(this.camera.pose.distance));if(this.cameraFence.distanceToPoint(t)>.01){let e=this.cameraFence.clampPoint(t,new M),n=this.camera.pose.offset.clone().add(e).sub(t),r=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:n,distance:this.camera.pose.distance});this.fixFinalState(r),this.locationMotion.set({x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance},300).catch(X)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=Y(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)}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:t.value.distance,offset:new M(t.value.x,t.value.y,t.value.z)})}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={longitude:o.longitude,latitude:o.latitude,fov:o.fov},c={x:o.offset.x,y:o.offset.y,z:o.offset.z,distance:o.distance};this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:o,userAction:this.userAction})),this.perspToOrthoMotion.set({perspToOrtho:0},i).catch(X),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(X),this.cameraMotion.set(s,i).catch(X),this.locationMotion.set(c,i).then(()=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:o,userAction:this.userAction}))},e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),j5(this.camera.pose));this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:t,userAction:this.userAction}))}).then(()=>{t()})})}getForwardObserverOrNot(e){let[t]=this.modelScene.intersectRaycaster(e);if(!t)return null;let n=[];for(let t of this.works){let r=this.modelScene.models.find(e=>e.work===t);if(!(!r||r.visible===!1)&&!(t.observers.length<=0)&&(w9.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),w9.containsPoint(e.ray.origin)||e.ray.intersectsBox(w9)))for(let e of t.observers)n.push(e)}let[r,i]=rQ(n,e=>T9.copy(e.standingPosition).applyMatrix4(e.work.transform).distanceTo(t.point),!0);return r&&i<Math.max(r.standingPosition.distanceTo(this.camera.position)/5,10)?r:null}coordinatesForOffset(e){let t=this.renderer.getSize(new j);return{longitude:-2*e.x/(t.x*this.viewport.width),latitude:2*e.y/(t.y*this.viewport.height)}}requestMomentumMovement(e,t,n,r){if(this.inMomentumMovement===null)return;r=Math.max(r,1);let i=Object.assign({},n),a={longitude:0,latitude:0,x:0,y:0,z:0};for(let e=0;e<r;e++)i.longitude*=.996,i.latitude*=.996*.998,i.x*=.99,i.y*=.99,i.z*=.99,a.longitude+=i.longitude,a.latitude+=i.latitude,a.x+=i.x,a.y+=i.y,a.z+=i.z;let o=this.cameraMotion.value.fov,s=IU(this.cameraMotion.value.longitude+a.longitude),c=Y(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),l=Y(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),u=Y(this.cameraMotion.value.latitude+a.latitude,c,l),d=new M(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),f=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:u,offset:d,fov:o,distance:this.locationMotion.value.distance}),p=e.state.offset.clone().sub(LU(e.state).setLength(f.distance)),m=!(Math.abs(i.longitude)>1e-4||Math.abs(i.latitude)>1e-4||Math.abs(i.x)>1e-4||Math.abs(i.y)>1e-4||Math.abs(i.z)>1e-4);(this.cameraFence?this.cameraFence.containsPoint(p):!0)===!1&&(m=!0);let h=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:m,state:f}));if(this.inMomentumMovement.event=h,this.emit(`gesture.momentum`,h),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:u},0).catch(X),this.locationMotion.set({x:f.offset.x,y:f.offset.y,z:f.offset.z,distance:f.distance},0).catch(X),m?this.inMomentumMovement=null:iJ.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=LU(e,new M),n=new M().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new $d(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>E9+r.near,r.near=this.camera.near,r.far=this.camera.far;let i;if(i=this.modelScene.intersectRaycaster(r)[0],i&&i.distance<this.camera.near&&(i=void 0),!i){let e=new Do(new M(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new M);if(t){let e=t.distanceTo(r.ray.origin);e<1e3&&e>=r.near&&(i={distance:e,floorIndex:0,floor:0,point:t,object:this.scene,face:null})}}if(!i){let r=Math.max(e.distance,3);i={distance:r,floorIndex:0,floor:0,point:n.clone().add(t.clone().setLength(r)),object:this.scene,face:null}}i.distance>=this.camera.near&&x5(e.distance,i.distance)&&(e.distance=i.distance,e.offset=i.point)}onPanGesture(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.pointers.length,n=this.panState,r=0,i=!1;e.pointerType===`mouse`&&(r=e.center.buttons,i=e.center.shiftKey),n&&r===0&&n.buttons!==0&&(r=n.buttons);let a=n==null?void 0:n.target;if(!a){let t=this.relativeClientPosition(e.center),n=this.createRaycasterFromCamera(t,this.camera);a=new M().copy(n.ray.direction).multiplyScalar(3).add(n.ray.origin);let[r]=this.modelScene.intersectRaycaster(n);if(!r&&n.ray.direction.y<-.3){let e=new Do(new M(0,1,0),0),t=n.ray.intersectPlane(e,new M);if(t){let e=t.distanceTo(n.ray.origin);e<1e4&&e>=n.near&&(r={distance:e,floorIndex:0,floor:0,point:t,object:this.scene})}}if(r)a.copy(r.point);else{let e=new M().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new Do().setFromNormalAndCoplanarPoint(e,this.camera.pose.offset);n.ray.intersectPlane(t,a)}}if(e.isFinal?this.panState=void 0:this.panState={target:a,buttons:r,pointerLength:t,x:e.center.x,y:e.center.y},!(n===void 0||n.pointerLength!==t))if(t>1||r===2||i){let t={x:e.center.x-n.x,y:e.center.y-n.y},r=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=LU(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new M().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new j),s=2*t.x*a/o.y,c=2*t.y*a/o.y,l=new M;l.setFromMatrixColumn(this.camera.matrix,0),l.multiplyScalar(-s),r.add(l),this.camera.pose.latitude<D9?l.setFromMatrixColumn(this.camera.matrix,1):(l.setFromMatrixColumn(this.camera.matrix,0),l.crossVectors(this.camera.up,l)),l.multiplyScalar(c),r.add(l);let u=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:r,distance:this.camera.pose.distance});if(e.state=u,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:u.offset.x,y:u.offset.y,z:u.offset.z},0).catch(X),e.isFinal&&(this.fixFinalState(u),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:u.distance,x:u.offset.x,y:u.offset.y,z:u.offset.z},0).catch(X)),e.isFinal){let t=this.renderer.getSize(new j),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new M,o=new M;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<D9?i.setFromMatrixColumn(this.camera.matrix,1):(i.setFromMatrixColumn(this.camera.matrix,0),i.crossVectors(this.camera.up,i)),i.multiplyScalar(r),o.add(i),this.inMomentumMovement={uuid:eV()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:o.x,y:o.y,z:o.z},0)}}else{let t={x:e.center.x-n.x,y:e.center.y-n.y},r=this.coordinatesForOffset(t),i=IU(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=Y(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=Y(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=Y(this.cameraMotion.value.latitude+r.latitude,o,s);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(c=this.cameraMotion.value.latitude);let l=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:i,latitude:c,fov:a,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=l,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:l.distance,x:l.offset.x,y:l.offset.y,z:l.offset.z},0).catch(X):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(X),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:eV()},this.requestMomentumMovement(e,!0,Object.assign(Object.assign({},this.coordinatesForOffset({x:t,y:n})),{x:0,y:0,z:0}),0)}}}onPinchGesture(t){var n;if(!this.initAnimationIsReady)return;this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let r=(n=this.pinchState)==null?void 0:n.distance;if(t.isFirst){this.pinchState={x:t.center.x,y:t.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(r===void 0)return;let i=this.modelScene.boundingBox.getCenter(new M),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=Y(r/t.scale,E9,1/0),s=t.state.offset.clone().sub(LU(t.state).setLength(o)),c=this.modelScene.boundingBox.containsPoint(s),l;if(!c&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?l=t.state.distance:(l=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=l,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(X),t.pointerType!==`mouse`&&(t.type=`gesture.pan`,this.onPanGesture(t)),t.isFinal)){if(!(`__fixFinalState`in t)){let e=t.state;this.fixFinalState(t.state);let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(X)}this.panState=void 0,this.pinchState=void 0}}onMouseMove(e){var t,n;if(!this.intersectMesh.parent||this.panState||this.pinchState||this.mouseWheelState||(this.emit(`gesture.mousemove`,e),e.defaultPrevented))return;let r=e.center.raycaster;if(e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}let[i]=this.modelScene.intersectRaycaster(r),a=$(`intersect.update`,{raycaster:r,intersection:i==null?null:i,object:this.intersectMesh});if(this.emit(`intersect.update`,a),a.defaultPrevented){this.hideIntersectMesh();return}if(i){let e=(n=(t=i.face)==null?void 0:t.normal)==null?new M().copy(r.ray.direction).multiplyScalar(-1):n,a=e.clone(),o=i.point.clone();this.intersectMesh.position.copy(o);let s=o.clone().add(a);if(this.intersectMesh.lookAt(s),Math.abs(e.y)>.99){let e=this.camera.position.clone().sub(o);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}onMouseWheel(t){if(this.initAnimationIsReady)if(this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),t.isFinal){let e=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov,offset:new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),distance:this.locationMotion.value.distance});if(this.fixFinalState(e),this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(X)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=new La(r,LU(this.cameraMotion.value,new M).negate()).intersectBox(this.modelScene.boundingBox,new M);i&&(n+=i.distanceTo(r));let a=Math.max(this.locationMotion.value.distance-this.camera.near,0),o=t.center.delta/10*Math.max(a/5,.1);if(a<=n||o>0)if(this.locationMotion.value.distance-o>=E9){let e=this.locationMotion.value.distance-o;t.state.distance=e}else{let e=LU(this.cameraMotion.value);e.setLength(o),t.state.offset.add(e)}if(this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;this.locationMotion.set({distance:t.state.distance,x:t.state.offset.x,y:t.state.offset.y,z:t.state.offset.z},0).catch(X)}}onTapGesture(e){var t;this.userAction=e.userAction,this.stopMomentumMovement();let n=e.center.raycaster,r=this.getForwardObserverOrNot(n);if(!r)this.emit(`gesture.tap`,e);else{let n={longitude:this.camera.pose.longitude,latitude:0},i=Object.assign(Object.assign({},e.state),{mode:`Panorama`,workCode:r.work.workCode,panoIndex:r.panoIndex,longitude:n.longitude,latitude:n.latitude,offset:r?r.position.clone():new M,distance:0});if(e.state=i,this.emit(`gesture.tap`,e),!e.defaultPrevented&&(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:i,userAction:e.userAction,options:n,progress:0,error:null})),r&&r.active)){let e=this.pendingTextureId=eV(),a=u3({panoIndex:r.panoIndex,workCode:r.work.workCode}),o={right:r.images.work.getURL(r.images.right),left:r.images.work.getURL(r.images.left),up:r.images.work.getURL(r.images.up),down:r.images.work.getURL(r.images.down),front:r.images.work.getURL(r.images.front),back:r.images.work.getURL(r.images.back)},s=this.imageOptions.transform,c=Object.assign({key:`pano.${a}`},hq(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),l=`pano:`+c3([o,c,s]),u=this.modelScene.parameter,d;if(u.pano0&&u.pano0.map.name===l?d=u.pano0:u.pano1&&u.pano1.map.name===l&&(d=u.pano1),d)u.pano0&&u.pano0.map!==d.map&&u.pano0.map.dispose(),u.pano1&&u.pano1.map!==d.map&&u.pano1.map!==((t=u.pano0)==null?void 0:t.map)&&u.pano1.map.dispose(),u.set({pano0:d,pano1:d}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,d=``;r.images.hdrConfig&&(t={right:r.images.work.getURL(r.images.gainmap_right),left:r.images.work.getURL(r.images.gainmap_left),up:r.images.work.getURL(r.images.gainmap_up),down:r.images.work.getURL(r.images.gainmap_down),front:r.images.work.getURL(r.images.gainmap_front),back:r.images.work.getURL(r.images.gainmap_back)},d=r.images.work.getURL(r.images.hdrConfig));let f=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:c},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),p=d?[fetch(d).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:c},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([f,...p]).then(t=>EV(this,[t],void 0,function*([t,o,s]){var c,d;let{body:f}=t;if(this.destroyed||this.pendingTextureId!==e){f.dispose();return}this.pendingTextureId=null,f.name=l;let p=Array.isArray(f.image)?f.image[0]:f.image,m=(c=p==null?void 0:p.width)==null?2048:c,h=yield X5(this.renderer,f,!0,n8),g=new o8().formPixels(h.data),_={panoId:a,map:f,mapSize:m,mapHistogram:new dr().fromArray(g.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},h7(o)):void 0};u.pano0&&u.pano0.map.dispose(),u.pano1&&u.pano1.map!==((d=u.pano0)==null?void 0:d.map)&&u.pano1.map.dispose(),u.set({pano0:_,pano1:_}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}))})).catch(t=>{this.destroyed||this.pendingTextureId!==e||(this.pendingTextureId=null)})}}}}onDblTapGesture(e){if(!this.initAnimationIsReady)return;this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.state,n=e.center.raycaster,r=n.ray.origin.clone().add(n.ray.direction.clone().setLength(3)),i=1,[a]=this.modelScene.intersectRaycaster(n);if(a&&(r=a.point.clone(),i=a.distance>4/2?1:3),e.state.distance=i,e.state.offset=r,this.emit(`gesture.dbltap`,e),e.defaultPrevented)return;let o={x:t.offset.x,y:t.offset.y,z:t.offset.z,distance:t.distance};this.locationMotion.set(o,360).catch(X),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},A9={Floorplan:v7,Topview:b7,Panorama:_9,Model:S9,Mapview:O9},j9=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.create,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,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 M9(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=LU(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 N9(){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 P9(){let e=new Gr;e.name=`internalLights`;{let t=new Hu(16777215,.1);t.name=`direction0`,t.position.copy(new M(0,1,0)),e.add(t)}{let t=new Hu(16777215,.1);t.name=`direction1`,t.position.copy(new M(-1,-1,-1)),e.add(t)}{let t=new Hu(16777215,.3);t.name=`direction2`,t.position.copy(new M(1,1,1)),e.add(t)}{let t=new Uu(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function F9(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 I9(){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=F9((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var L9=1e3,R9=90,z9=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/`),B9=new Zi,V9=new gi,H9=new dr,U9=new dr,W9=new P,G9=new j,K9=new WeakMap,q9=e6([Z3(null)]),J9={},Y9=class e extends aV{static get version(){return`1.0.0-alpha.1`}static get dracoPath(){return wX.decoderPath}static set dracoPath(e){wX.setDecoderPath(e)}static get ktx2Path(){return MX.transcoderPath}static set ktx2Path(e){MX.setTranscoderPath(e)}static get useNativeImageBitmap(){return cJ()}static set useNativeImageBitmap(e){sJ(e)}constructor(e={}){var t,n,r,i,a,o,s,c,l,u,d;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=eV(),J9[this.fiveId]=this,this.currentUpdateArgs={time:HU(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!0,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 P((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)},this.fps={testCount:0,testTime:HU()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?L9:s,this.enableWheel=(c=e.enableWheel)==null?!0:c,typeof window<`u`)if(`renderer`in e)e.renderer instanceof K8&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new K8({outputType:e.enableHDR?he:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=I9();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 fr(1,1,{colorSpace:(u=(l=this.renderer)==null?void 0:l.outputColorSpace)==null?At:u,generateMipmaps:!1}),this.renderer&&XK(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new ZU(R9),this.scene=new Q8,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new ti,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(d=e.requestProxy)==null?z9:d,this.networkSubscribe=new cq,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,$(`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 Gr,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),K9.set(this,q9),this.modelScene=new H4({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[f]=this.modelScene.setModels(q9,{forceReplaceImmediately:!0});Z(f,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new xs(e.videoInstance||N9());let p=P9();this.scene.add(p),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=iJ.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let m=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,m,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,m,!1)},this.loadWorkTask=this.prepare(),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)}}}M9(this),this.fiveRenderer=new U8({outputType:e.enableHDR?he:void 0}),this.adaptiveLuminancePass=new S8,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new w8(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new YH,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([Aq().catch(X)]).then(X)}dispose(){var e;if(this.destroyed===!0)return;delete J9[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(),K9.set(this,q9),this.renderer&&(!(this.renderer instanceof K8)||this.renderer.isInitialized)&&this.renderer.render(new ti,new ju),this.fiveRenderer.dispose(),this.renderer instanceof K8&&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`,$(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,_q(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,_q(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,_q(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,_q(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,_q(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),this.currentMode===`Panorama`&&(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 K8)){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,a,o,s;if(!this.renderer)return;let c=this.renderer.domElement.parentNode,{width:l=(n=c==null?void 0:c.offsetWidth)==null?512:n,height:u=(r=c==null?void 0:c.offsetHeight)==null?512:r}=e;if(l=Math.max(1,l),u=Math.max(1,u),!t){let e=I9(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(l,u)*t,n=Math.min((s=(o=(a=this.renderer.backend.device)==null?void 0:a.limits)==null?void 0:o.maxTextureDimension2D)==null?8192:s,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(l,u),this.needsRender=!0;let d=HU(),f=d-this.currentUpdateArgs.time,p=this.currentUpdateArgs.args;this.updateTime(d,f,...p)}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 K9.get(this)||q9}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(()=>w5(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,c,l,u,d,f,p,m;let h={};typeof r==`number`?h.duration=r:typeof r==`object`&&Object.assign(h,r),this.works===q9&&(h.duration===void 0&&(h.duration=0),h.effect===void 0&&(h.effect=`instant`));let g={};Object.assign(g,h.model),!g[`3d-tiles`]&&h[`3d-tiles`]&&(g[`3d-tiles`]=h[`3d-tiles`]),!g.textureOptions&&h.textureOptions&&(g.textureOptions=h.textureOptions),!g.textureOptions&&this.textureOptions&&(g.textureOptions=this.textureOptions);let _=[];if(Array.isArray(t))for(let e of t)e instanceof X3?_.push(e):typeof e!=`string`&&`work`in e?_.push(Z3(e.work,e)):_.push(Z3(e));else t instanceof X3?_.push(t):_.push(Z3(t));h.mode===`add`&&(_=[].concat(this.works,_));let v;try{v=e6(_)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of v)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===q9&&(n=`initial`);let y=this.currentMode,b=v.initial,x=b.work.observers[0],S=x?{workCode:x.work.workCode,panoIndex:x.panoIndex}:{workCode:b.work.workCode,panoIndex:0},C=(a=b.mode)==null?x?`Panorama`:`Mapview`:a,w={};if(n===`inherit`){let e=this.getCurrentState(),[t]=v.filter(t=>t.workCode===e.workCode);if(t)S={workCode:e.workCode,panoIndex:e.panoIndex},C=e.mode,w={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:y};let e=(s=(o=v[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof v.initial.panoIndex==`number`?(n.workCode=v.initial.work.workCode,n.panoIndex=v.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===y&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof b.panoIndex==`number`&&(S={workCode:b.work.workCode,panoIndex:b.panoIndex}),b.mode&&(C=b.mode),w={longitude:b.longitude,latitude:b.latitude,fov:b.fov,distance:b.distance,offset:(c=b.offset)==null?void 0:c.clone()}),typeof n==`object`){if(C=(l=n.mode)==null?y:l,typeof n.panoIndex==`number`){let e=v.getObserver({workCode:(d=(u=n.workCode)==null?b.work.workCode:u)==null?``:d,panoIndex:n.panoIndex});e&&(S={workCode:e.work.workCode,panoIndex:e.panoIndex})}w={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new M().copy(n.offset):void 0}}let T=(f=h.duration)==null?this.modeChangeDuration:f;(C===`Floorplan`||C===`Topview`||C===`Mapview`)&&y===C&&(T=0);let E=`fly`;C===`Panorama`&&y===C&&(E=(p=h.effect)==null?`fade`:p),this.emit(`works.request`,$(`works.request`,{input:t,works:v,userAction:i}));let D=(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:T,effect:E,userAction:i}},this.commonParams()),this.controllerInits[e]),c=k9[o.mode].initAnimationEndState(s);if(this.controller&&y===e)this.controller.updateWork(v,c,{effect:E,duration:T},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=k9[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=$(`mode.change`,{prevMode:y,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.state.workCode=this.pano.workCode,this.state.panoIndex=this.pano.panoIndex,this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};K9.set(this,v);let ee=Promise.resolve();if(C===e.Mode.Floorplan||C===e.Mode.Topview||C===e.Mode.Mapview||C===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(w),A5(this.state,this.camera.pose));let e=this.modelScene.setModels(v,g);ee=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,D(C,S,w),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{D(C,S,w);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===v&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`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(v,g);ee=Promise.all(r.map(e=>e.initReady)).then(X),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((m=h.duration)==null?this.modeChangeDuration:m)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:v})),ee.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:v})),(e=this.analysis)==null||e.work(v)})}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}),K9.set(this,q9),this.modelScene.setModels(q9,{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:R9,longitude:0,latitude:0,offset:new M(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&&!this.works.getObserver(m)){let e=Error(`PanoId ${u3(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?!f3(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(X):(f3(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(X));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=k9[t].initAnimationEndState(r),o=$(`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=$(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=iJ.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),iJ.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return EV(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=HU(),c=this.renderer.getPixelRatio(),l=this.renderer.getRenderTarget(),u=this.getSize(new j),d=0,f=0,p=1,m=1,h,g,_,v,y;typeof e==`number`?(d=e,typeof t==`number`&&(f=t),typeof n==`number`&&(p=n),typeof r==`number`&&(m=r),h=i,g=a,y=o):(d=e.x,f=e.y,p=e.width,m=e.height,h=e.pixelRatio,g=e.flipY,_=e.helperVisible,v=e.skipPanorama,y=e.buffer),d=Math.floor(d),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h==null?c:h),g=g==null?!1:g;let b=this.helperVisible,x=this.modelScene.parameter.modelAlpha;this.helperVisible=_==null?this.helperVisible:_,v&&this.controller instanceof k9.Panorama&&v===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let S=this.getPixelsRenderTarget;S.setSize(p*h,m*h),this.renderer.setRenderTarget(S),this.camera.pixelRatio=h,this.camera.resolution.set(p,m),this.camera.setViewOffset(u.width,u.height,d,u.height-f-m,p,m),this.camera.aspect=u.width/u.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let C=this.renderer.autoClear,w=this.renderer.autoClearColor,T=this.renderer.autoClearDepth,E=this.renderer.autoClearStencil,D=this.renderer.getClearColor(W9),ee=this.renderer.getClearAlpha(),te=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let ne=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:ne,this.renderer.render(this.scene,this.camera),this.scene.background=ne,this.renderer.autoClear=C,this.renderer.autoClearColor=w,this.renderer.autoClearDepth=T,this.renderer.autoClearStencil=E,this.renderer.setClearColor(D,ee),this.renderer.setScissorTest(te),this.helperVisible=b,x===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,x),this.renderer.setRenderTarget(l),this.camera.clearViewOffset(),this.camera.pixelRatio=c,this.camera.resolution.copy(u),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 re=p*h,O=m*h,ie=re*O,ae=ie*4;if(y){if(y.length!==ae)throw Error(`buffer length is not equals pixels ${ae}`)}else y=new Uint8Array(ae);let oe=yield this.renderer.readRenderTargetPixelsAsync(S,0,0,re,O),se=re*4;if(oe.length===ae)y.set(oe);else{let e=Math.ceil(se/256)*256;for(let t=0;t<O;t++){let n=t*e;y.set(oe.subarray(n,n+se),t*se)}}if(!g){let e=ie/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(O-Math.floor(n/re)-1)*re+n%re,r=0;r<4;r++)t=y[n*4+r],y[n*4+r]=y[i*4+r],y[i*4+r]=t}return y})}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=t.getClearColor(W9),c=t.getClearAlpha(),l=t.getViewport(H9),u=t.getScissor(U9),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(G9),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;this.controller&&this.controller.render()&&(y=!1),y&&this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender),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&&iJ.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&MX.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),iJ.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&iJ.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){V9.makeEmpty(),V9.expandByObject(this.modelScene.boundingMesh);let t=V9.getBoundingSphere(B9),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=Y(n/500,.001,.1),i=Y(n,800);this.camera.near!==r&&(this.camera.near=r),this.camera.far!==i&&(this.camera.far=i),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||this.renderer instanceof K8&&!this.renderer.isInitialized)return;let r=$(`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`,$(`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 K8&&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=X){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=HU();return Promise.all(r.map(e=>{let t=u3({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},hq(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):qq(i,r);return f4(this.fiveId,n.work).preload(a)})).then(()=>{let e=HU()-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 $d(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 j),i=r.x*this.viewport.width,a=r.y*this.viewport.height;return new j(r.x*this.viewport.left+(n.x+1)/2*i,r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a)}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,c,l,u,d,f;e=hq(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof M)&&(e.offset=new M(e.offset.x,e.offset.y,e.offset.z));let p;if(typeof e.panoIndex==`number`)if(e.workCode)p={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),p={workCode:t,panoIndex:e.panoIndex}}let m=(a=e.mode)==null?this.state.mode:a,h,g,_,v,y;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==m){let t={workCode:p==null?void 0:p.workCode,panoIndex:p==null?void 0:p.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 M&&(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[m]),r=k9[m].initAnimationEndState(n);h=r.longitude,g=r.latitude,_=r.fov,v=r.offset,y=r.distance}else h=(o=e.longitude)==null?this.state.longitude:o,g=(s=e.latitude)==null?this.state.latitude:s,_=(c=e.fov)==null?this.state.fov:c,v=(l=e.offset)==null?this.state.offset:l,y=(u=e.distance)==null?this.state.distance:u;let b={workCode:(p==null?this.pano:p).workCode,panoIndex:(p==null?this.pano:p).panoIndex,mode:m,longitude:h,latitude:g,fov:_,offset:v,distance:y};this.emit(`state.set`,$(`state.set`,{userAction:n,state:b})),k5(this.state,b)||(O5(this.state,b),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===b.mode&&(this.syncingState=this.syncState(HU(),0,t),this.syncingState&&((d=this.controller)==null||d.updateTime(HU(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(f=this.analysis)==null||f.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 k9.Model){if(C5(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(!f3(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 k9.Floorplan||this.controller instanceof k9.Topview||this.controller instanceof k9.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:l8(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:l8(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),c=s>e*15?s/15:e,l=r?new M().copy(this.state.offset):u8(this.camera.pose.offset,this.state.offset,c),{longitude:u,latitude:d}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:d8({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(x5(n,this.camera.pose.fov)||C5(l,this.camera.pose.offset)||x5(o,this.camera.pose.distance)||x5(u,this.camera.pose.longitude,Math.PI*2)||x5(d,this.camera.pose.latitude)){let e={x:l.x,y:l.y,z:l.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:u,latitude:d}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(X),this.controller.locationMotion.set(e,0).catch(X),!0}}else{let e=Math.PI/45,t=r?this.state.fov:l8(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:d8({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 M().copy(this.state.offset);if(x5(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),C5(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),x5(n,this.camera.pose.longitude,Math.PI*2)||x5(i,this.camera.pose.latitude)||x5(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(X),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`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 k9.Panorama&&t.tile===!0?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(X)}requestFullscreen(){var e;if(!D5)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=()=>{iJ.shared.add(()=>{this.emit(`model.load`,$(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,$(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,$(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,$(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,$(`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`,$(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new pq({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=F3(e,r);return t instanceof Error?Promise.reject(t):t})}});p4(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(e,t){if(!this.renderer)throw Error(`renderer is not initialized.`);let n=k9[e];this.currentMode=e;let r=new n(t);for(let e of j9)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=k9[e].initAnimationEndState(t),r=t.initial.userAction;k5(this.state,n)||(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,$(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return r.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,$(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),r.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,$(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),r.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),r.on(`error`,e=>this.throwError(e)),r}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 Wr;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new M(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().invert();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 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}};Y9.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:np,constructor:Y9,instances:J9}}),e.AdaptiveLuminancePass=S8,e.AnimationFrameLoop=iJ,e.BoundingMesh=B4,e.Camera=ZU,e.EffectComposer=n6,e.EyeDomeLightingPass=w8,e.Fetcher=pq,e.Five=Y9,e.FivePass=i6,e.FiveRenderer=U8,e.FlowingFireworks3DPass=P8,e.FlowingLight2DPass=O8,e.FlowingLight3DPass=E8,e.FullScreenQuad=r6,e.GaussianBlurPass=T8,e.Histogram=o8,e.InternalWebGPURenderer=K8,e.Model=j4,e.ModelScene=H4,e.Motion=b$,e.NetworkSubscribe=cq,e.PBMGSObject=QB,e.PBMGaussianSplattingObject=QB,e.PBMGaussianSplattingNodeMaterial=qH,e.PBMGaussianSplattingRenderMesh=YH,e.PBMGroup=GB,e.PBMMesh=XB,e.PBMMeshBasicMaterial=XH,e.PBMMeshBasicNodeMaterial=VK,e.PBMMeshPanoOnlyMaterial=ZH,e.PBMMeshPanoOnlyNodeMaterial=qK,e.PBMMeshPhongMaterial=QH,e.PBMMeshPhongNodeMaterial=UK,e.PBMMeshPhysicalMaterial=$H,e.PBMMeshPhysicalNodeMaterial=GK,e.PBMPanoFilter=sV,e.PBMPointCloud=wV,e.PBMSkinnedMesh=ZB,e.PBMUpdateable=oV,e.PROXY_CONTROLLER_EVENT_NAMES=j9,e.PanoCircleMesh=o5,e.PanoCircleMeshCustom=y5,e.PanoCircleMeshSolid=m5,e.Parameter=Z2,e.Scene=Q8,e.Subscribe=aV,e.TextureLoader=gJ,e.Tile=tQ,e.Tile3D=u4,e.Tile3DModel=u4,e.TileCache=B$,e.TileNode=k$,e.TileRequestScheduler=L$,e.Tileset=K$,e.Trajectory=N$,e.TrajectoryNode=P$,e.Work=X3,e.WorkResolvedObserver=$3,e.controllersDefaultInitArgs=A9,e.coordinatesToVector=LU,e.createDebugBoundingMesh=XZ,e.createWorks=e6,e.defaultImageURLTransform=qq,e.draco=wX,e.getViewportScale=I9,e.headingToLongitude=BU,e.imageSupport=Aq,e.isBoundingVolume=GZ,e.isPanoId=p3,e.loadAt3d=xY,e.loadDome=EY,e.loadDomez=NY,e.loadGltf=wZ,e.loadPbm=$J,e.loadPly=LY,e.longitudeToHeading=zU,e.makeBoundingVolume=KZ,e.panoEqual=f3,e.panoParse=d3,e.panoStringify=u3,e.parseWork=Z3,e.registerPBMMaterials=XK,e.vectorToCoordinates=RU,e.workToJson=q4});
|
|
1579
|
+
`,uniforms:{maxDepth:new qd(0)}});function f9(e,t,n,r=1e3){d9.uniforms.maxDepth.value=r,e.getClearColor(u9);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=d9,e.setClearColor(l9,0),n.update(e,t),e.setClearColor(u9,i),t.overrideMaterial=a}var p9=S$,m9=new $d,h9=new M,g9=[new M(0,0,0).multiplyScalar(.1),new M(1,0,0).multiplyScalar(.1),new M(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new M(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],_9=Object.assign(Object.assign({},S7),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new m5:new o5,adjustPanoCircleMeshPositionBasedOnModel:!1,tileLevelForFov:((e,t)=>{var n;let r=e=>e/180*Math.PI,i=(n=Math.log2)==null?(e=>Math.log(e)*Math.LOG2E):n,a=t.height/2/Math.tan(r(e/2))*Math.tan(r(45))*2,o=Math.max(i(a/512),0);return o<2.3&&o>.1&&(o=1),o=o%1>.75?Math.ceil(o):Math.floor(o),o}),tileAppearDuration:.5,tileMaxRequest:3,flyEffectUseDepthBuffer:!1}),v9=class e extends C7{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{maxAccessibleDistance:(n=t.maxAccessibleDistance)==null?_9.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?_9.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?_9.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?_9.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?_9.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?_9.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?_9.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?_9.flyEffectUseDepthBuffer:l})}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`Panorama`})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Panorama`,this.initAnimationed=!1,this.maxAccessibleDistance=n.maxAccessibleDistance,this.panoTapTriggerRadius=n.panoTapTriggerRadius,this.panoCircleMeshCreator=n.panoCircleMeshCreator,this.adjustPanoCircleMeshPositionBasedOnModel=n.adjustPanoCircleMeshPositionBasedOnModel,this.tileLevelForFov=n.tileLevelForFov,this.tileAppearDuration=n.tileAppearDuration,this.tileMaxRequest=n.tileMaxRequest,this.flyEffectUseDepthBuffer=n.flyEffectUseDepthBuffer,this.adjustPanoCircleMeshPositionFix=new Map;let{pano0:r,pano1:i}=this.modelScene.parameter.resolveValue();r&&(i==null?void 0:i.map)!==r.map&&(this.modelScene.parameter.set({pano0:i}),r.map.dispose());let a=new Set;r&&a.add(r),i&&a.add(i),this.panoMeshes=new Map,this.locationMotion=new b$({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=eV()]={panoId:u3(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:p9,fixCameraTransform:new N},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new gJ,this.tiling=new r9({fiveId:this.fiveId}),this.panoVideo=new c9,this.scene.add(this.panoVideo.object),this.accessibleObserverFloorCheckCount=0}get tileLevel(){return this.tiling.level}updateConfiguration(e){return super.updateConfiguration(e)===!1?!1:(e.maxAccessibleDistance!==void 0&&this.maxAccessibleDistance!==e.maxAccessibleDistance&&(this.maxAccessibleDistance=e.maxAccessibleDistance),e.panoTapTriggerRadius!==void 0&&this.panoTapTriggerRadius!==e.panoTapTriggerRadius&&(this.panoTapTriggerRadius=e.panoTapTriggerRadius),e.panoCircleMeshCreator!==void 0&&this.panoCircleMeshCreator!==e.panoCircleMeshCreator&&(this.panoCircleMeshCreator=e.panoCircleMeshCreator,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear())),e.tileLevelForFov!==void 0&&this.tileLevelForFov!==e.tileLevelForFov&&(this.tileLevelForFov=e.tileLevelForFov),e.tileMaxRequest!==void 0&&this.tileMaxRequest!==e.tileMaxRequest&&(this.tileMaxRequest=e.tileMaxRequest),e.flyEffectUseDepthBuffer!==void 0&&this.flyEffectUseDepthBuffer!==e.flyEffectUseDepthBuffer&&(this.flyEffectUseDepthBuffer=e.flyEffectUseDepthBuffer),e.adjustPanoCircleMeshPositionBasedOnModel!==void 0&&this.adjustPanoCircleMeshPositionBasedOnModel!==e.adjustPanoCircleMeshPositionBasedOnModel&&(this.adjustPanoCircleMeshPositionBasedOnModel=e.adjustPanoCircleMeshPositionBasedOnModel,this.adjustPanoCircleMeshPositionBasedOnModel||this.adjustPanoCircleMeshPositionFix.clear()),!0)}destroy(){super.destroy(),this.tiling.dispose(),this.modelScene.parameter.set({refinedScreen:null,pano0Depth:null,pano1Depth:null}),this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0),this.locationMotion.dispose(),this.pendingTextureTask=void 0,this.panoMeshes&&(this.panoMeshes.forEach(e=>{this.helper.remove(e),e.dispose()}),this.panoMeshes.clear());let e=this.videoTexture.image;e.pause(),e.oncanplay=X,e.ontimeupdate=X,this.scene.remove(this.panoVideo.object),this.panoVideo.setMaterial(null),this.panoVideo.dispose();let{pano0:t,pano1:n}=this.modelScene.parameter.resolveValue();for(let e of Object.keys(this.panoResources)){let r=this.panoResources[e];if(r.panoPicture){let e=r.panoPicture.map;e&&e!==(t==null?void 0:t.map)&&e!==(n==null?void 0:n.map)&&(e.dispose(),r.panoPicture=null)}delete this.panoResources[e]}}isReady(){return this.locationMotion.ended===!0?super.isReady():!1}isTileReady(){let e=this.tiling.pedding<=0;return this.initAnimationed&&e}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&(this.initAnimationed=!1,this.moveToPano({workCode:a.workCode,panoIndex:a.panoIndex},{effect:r.effect,duration:r.duration,longitude:a.longitude,latitude:a.latitude,fov:a.fov,moveEndCallback:()=>{this.initAnimationed=!0},moveCancelCallback:()=>{this.initAnimationed=!0}},i)),!0}updateModel(e){this.modelScene=e,this.hideIntersectMesh()}updateTime(e,t,...n){var r,i,a,o,s,c,l;if(this.destroyed)return;let u={},d={},f=this.camera.getDirection(new M),p=this.locationMotion.keyframes[0],m=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[h,g]=this.locationMotion.getKeyFrameSegment(e),_=this.panoResourceFromLocationMotionKeyframe(h),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(p),b=this.panoResourceFromLocationMotionKeyframe(m),x=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),d.longitude=this.cameraMotion.value.longitude,d.latitude=this.cameraMotion.value.latitude,d.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),u.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-g.value.count+1,n=new M().copy(_.position),a=new M().copy(v.position);if(u.progress=v.effectEasing(t),t>=.01&&t<=.99&&(u.progress=Y(v.effectEasing(t),.01,.99)),v.panoPicture&&(t<1?_.panoPicture&&(u.pano0=_.panoPicture):u.pano0=v.panoPicture,u.pano1=v.panoPicture),v.effect===`montage`?u.transition=`BLACK`:v.effect===`spread`?u.transition=`SPREAD`:u.transition=`FADE`,v.effect===`zoomin`||v.effect===`zoomout`?u.progress=Math.pow(t,3):v.effect===`model`&&this.camera.pose.distance<.01&&(u.modelAlpha=1-Math.pow(Y(Math.abs(t-.5)*2,0,1),4)),t<1&&v.effect!==`fly`&&v.effect!==`model`){if(u.pano0&&_.panoPicture){let e={panoId:u.pano0.panoId,map:u.pano0.map,mapHistogram:u.pano0.mapHistogram,mapSize:u.pano0.mapSize,zoom:u.pano0.zoom,matrix:_.panoPicture.matrix.clone().premultiply(_.fixCameraTransform).setPosition(v.position),hdrConfig:u.pano0.hdrConfig?Object.assign({},u.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(u.pano0);t&&this.panoPictureObserverMap.set(e,t),u.pano0=e}n.copy(a),x=!0}d.distance=this.locationMotion.value.distance,d.offset=new M(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.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=u.pano0)==null?void 0:r.map)||e===((i=u.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let c=d3(v.panoId);c!==this.currentPano&&(this.currentPano=c,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:d3(y.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},d3(b.panoId)),{mode:this.mode}),j5(this.camera.pose)),d),options:{},progress:this.locationMotion.progress,error:null}))}P5(u)===!1&&this.modelScene.parameter.set(u),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),P5(d)===!1&&this.setCamera(d);let S=this.works.getObserver(this.currentPano),C=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,w=this.works.getObserver(_.panoId),T=this.works.getObserver(v.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&S){let e=[],t=S.work.observers;for(let n of S.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(S.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(S.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=u3({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=g9.map(t=>{m9.ray.origin.copy(i),m9.ray.origin.add(h9.copy(t).setY(e)),m9.ray.direction.set(0,-1,0),m9.firstHitOnly=!0,m9.floorIndex=-1;let[a]=n.intersectRaycaster(m9);return a&&a.distance-r<=e?new M().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[c]=o.filter(e=>e.distanceTo(s)<=.05);if(c){let e=new dr(i.x,i.y,i.z,c.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let E=new Map;if(w)for(let e of w.accessibleNodes){let t=w.work.observers[e];if(t){let e=u3({panoIndex:t.panoIndex,workCode:t.work.workCode});E.set(e,t)}}if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=u3({panoIndex:t.panoIndex,workCode:t.work.workCode});E.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{E.get(t)?E.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),E.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),E.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&&(h9.set(t.x,t.y,t.z),h9.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 M().copy(e.position).sub(i).normalize();if(t===u3(this.currentPano)){let t=Y((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(f.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 Dr(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||x)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(S){let n=S.work.observers,[,r]=rQ(S.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:S.standingPosition.distanceTo(t.standingPosition)},!0);r=Y(r,3,1/0);let i=S.accessibleNodes.concat(S.panoIndex).map(e=>u3({panoIndex:e,workCode:S.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&&C!==null&&u3({panoIndex:C.panoIndex,workCode:C.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:Y(r/t,.1,.85)}o&&o===T&&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=(a=this.modelScene.parameter.progress)==null?1:a,t=Math.round(e),n=this.modelScene.parameter.pano0,r=this.modelScene.parameter.pano1,i=t===0?n:r,c;if(i&&(c=this.works.getObserver(i.panoId),c||(c=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(cJ()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!c||!i||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:null,gainMap:void 0,panoMatrix:new N,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=$q(i.mapSize),a=e+1,l=new j().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),u=Math.floor(this.tileLevelForFov(this.camera.fov,l)),d=u>e?u:0;this.tiling.setObserver(c);let f={renderer:this.renderer,resolution:this.camera.resolution,pixelRatio:this.camera.pixelRatio,time:this.camera.time,cameraMatrix:this.camera.matrixWorld,cameraProjectionMatrix:this.camera.projectionMatrix,panoMap:i.map,gainMap:(o=i.hdrConfig)==null?void 0:o.map,panoMatrix:i.matrix,panoZoom:i.zoom,minLevel:a,level:d,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},p=this.tiling.update(f),m={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:w$(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},h=this.modelScene.parameter.refinedScreen;(p||m.pano!==(h==null?void 0:h.pano)||m.opacity!==(h==null?void 0:h.opacity))&&this.modelScene.parameter.set(`refinedScreen`,m)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),S&&S.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&S&&S.position.y-S.standingPosition.y>10){let e=Y(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=v.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((c=this.modelScene.parameter.pano0Depth)==null?void 0:c.panoId)!==t.panoId||((l=this.modelScene.parameter.pano1Depth)==null?void 0:l.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new _w(512,{minFilter:D,magFilter:D,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new _w(512,{minFilter:D,magFilter:D,generateMipmaps:!1});let e=new fd(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,f9(this.renderer,this.modelScene,e,500);let r=new fd(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,f9(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))}}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1],n=this.panoResourceFromLocationMotionKeyframe(t),r=this.works.getObserver(n.panoId);return{workCode:r?r.work.workCode:this.currentPano.workCode,panoIndex:r?r.panoIndex:this.currentPano.panoIndex,mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:r?r.position.clone().applyMatrix4(r.work.transform):this.camera.position.clone(),distance:this.locationMotion.value.distance}}moveToPano(e,t,n){var r,i,a;let o=(r=t.effect)==null?`fly`:r;this.userAction=n,this.stopMomentumMovement();let s=u3(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let l=Xq(c.images.up),u=this.imageOptions.size;u===void 0&&c&&l&&(u=Number(l)),u===void 0&&(u=2048);let d=this.imageOptions.transform,f=Object.assign({key:`pano.${s}`},hq(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),p={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},m,h=``;c.images.hdrConfig&&(m={right:c.images.work.getURL(c.images.gainmap_right),left:c.images.work.getURL(c.images.gainmap_left),up:c.images.work.getURL(c.images.gainmap_up),down:c.images.work.getURL(c.images.gainmap_down),front:c.images.work.getURL(c.images.gainmap_front),back:c.images.work.getURL(c.images.gainmap_back)},h=c.images.work.getURL(c.images.hdrConfig));let g=`pano:`+c3([p,f,d]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===g)return;{let e=this.pendingTextureTask.panoId;(i=this.panoMeshes.get(e))==null||i.setProgress(0),this.emit(`pano.texture.abort`,$(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode}}))}}let _=`move-to-pano-`+s;this.pending.add(_);let v=this.modelScene.parameter,y;if(v.pano0&&v.pano0.map.name===g?y=v.pano0:v.pano1&&v.pano1.map.name===g&&(y=v.pano1),y){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?p9:a,panoPicture:{panoId:y.panoId,map:y.map,mapHistogram:y.mapHistogram,mapSize:y.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:y.hdrConfig?Object.assign({},y.hdrConfig):void 0},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new N};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,c),this.pendingTextureTask=void 0,iJ.shared.add(()=>{this.pending.delete(_),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:g,onLoad:(n,r)=>EV(this,void 0,void 0,function*(){var i,a;let l=n.body;if(this.destroyed)l.dispose();else{l.name=g;let n=Array.isArray(l.image)?l.image[0]:l.image,u=(i=n==null?void 0:n.width)==null?2048:i,{data:d}=yield X5(this.renderer,l,!0,n8),f=new o8().formPixels(d),p={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?p9:a,panoPicture:{panoId:s,map:l,mapSize:u,mapHistogram:new dr().fromArray(f.toArray()),matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1,hdrConfig:r},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new N};p.panoPicture&&this.panoPictureObserverMap.set(p.panoPicture,c),this.doMoveToPano(e,p,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),j5(this.camera.pose));this.emit(`pano.error`,$(`pano.error`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`pano.cancel`,$(`pano.cancel`,{error:n,userAction:this.userAction,options:t,prevPano:this.currentPano,progress:0,state:r})),this.emit(`error`,n),t.moveCancelCallback&&t.moveCancelCallback()}};let b=this.panoMeshes.get(s);b&&b.tap&&b.tap();let x=[this.textureLoader.loadCubeTexture(p,{imageURL:{transform:d,options:f},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,$(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingTextureTask)==null?void 0:n.hash)===g&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];h&&x.push(fetch(h).then(e=>e.json()),this.textureLoader.loadCubeTexture(m,{imageURL:{transform:d,options:f},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,c.work)},void 0,void 0,void 0,this.renderer)),Promise.all(x).then(([t,n,r])=>{var i,a;this.pending.delete(_),((i=this.pendingTextureTask)==null?void 0:i.hash)===g?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},h7(n))),this.pendingTextureTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,$(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}))}).catch(t=>{var n,r;this.pending.delete(_),((n=this.pendingTextureTask)==null?void 0:n.hash)===g&&(this.pendingTextureTask.onError(t),this.pendingTextureTask=void 0,(r=this.panoMeshes.get(s))==null||r.setProgress(0)),this.emit(`pano.texture.error`,$(`pano.texture.error`,{error:t,progress:0,meta:null,pano:e})),this.emit(`error`,t)}),this.emit(`pano.texture.load`,$(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{duration:n,effect:r,userAction:i}=this.initial;this.userAction=i;let a=e.initAnimationEndState(this),o={workCode:a.workCode,panoIndex:a.panoIndex},s={modelAlpha:0},c={perspToOrtho:0},l=!1;this.moveToPano(o,{longitude:a.longitude,latitude:a.latitude,fov:a.fov,effect:r,duration:n,moveStartCallback:e=>{l=!0,this.perspToOrthoMotion.set(c,n).catch(X),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:s}],n).catch(X),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()},moveCancelCallback:()=>{let e=Object.assign(Object.assign(Object.assign({},o),{mode:this.mode}),j5(this.camera.pose));l===!1&&this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction})),this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),this.initAnimationed=!0,t()}},i)})}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}locationMotionKeyframesLength(e){let t=0;for(let n=1;n<e.length;n++){let r=this.panoResourceFromLocationMotionKeyframe(e[n-1]).position,i=this.panoResourceFromLocationMotionKeyframe(e[n]).position,a=r.distanceTo(i)*(e[n].value.count-e[n-1].value.count);t+=a}return t}doMoveToPano(e,t,n={}){var r,i,a,o,s,c,l,u,d,f,p;let m=HU(),h=eV();this.panoResources[h]=t;let g,_,v;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(m),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;g=Math.max(a.distanceTo(o),1),_=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{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=l===0||l===0?0: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:(i=b.longitude)==null?this.camera.pose.longitude:i,latitude:(a=b.latitude)==null?this.camera.pose.latitude:a,fov:(o=b.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),S=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:S,progress:0,state:x,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(x),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=X,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(b,y).catch(X);else{let e=LU({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=LU({longitude:(s=b.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=b.latitude)==null?this.cameraMotion.value.latitude:c}),r=new Wr;r.lookAt(e);let i=new N().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new N().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),m=this.cameraMotion.value.fov,h=(l=b.fov)==null?this.cameraMotion.value.fov:l,g=1;t.effect===`zoomin`?g=1.5:t.effect===`zoomout`&&(g=.4);let v=Y(h*g,1,170);for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(v/2/180*Math.PI)/Math.tan(m/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:v}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:h}}],y).catch(X)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof j4&&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:this.camera.pose.distance});this.emit(`pano.arrived`,$(`pano.arrived`,{options:n,prevPano:S,progress:1,state:t,userAction:this.userAction,error:null})),n.moveEndCallback&&n.moveEndCallback(t);let r=this.works.getObserver(e);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=eV(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=X,n.ontimeupdate=X,E7().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=X,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=X,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=X,e.ontimeupdate=X}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:S,progress:0,state:x,userAction:this.userAction,error:null})),n.moveCancelCallback&&n.moveCancelCallback()})}getForwardObserverOrNot(e,t){let n=this.works.getObserver(this.currentPano);if(!n)return null;let r=t==null?new $d(e.position.clone(),e.getWorldDirection(new M)):t;r.params.Points={threshold:.1},r.firstHitOnly=!0,r.floorIndex=-1;let i=n.standingPosition.clone().applyMatrix4(n.work.transform);if(n.position.clone().applyMatrix4(n.work.transform).distanceTo(r.ray.origin)>1){let e=new $d(r.ray.origin,new M(0,-1,0));e.firstHitOnly=r.firstHitOnly,e.floorIndex=r.floorIndex;let[t]=this.modelScene.intersectRaycaster(e);t&&t.distance<=2?i.copy(t.point):i.copy(r.ray.origin).add(new M(0,-1.5,0))}let[a]=this.modelScene.intersectRaycaster(r),o=(a?a.point:r.ray.origin.clone().add(r.ray.direction.clone().normalize().multiplyScalar(3))).clone().sub(i).normalize();if(o.length()===0)return null;let s=n.work.observers,c=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.standingPosition.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),l=new Map,u=c.slice().sort((e,t)=>{let n=s[e],r=l.get(n);r===void 0&&(r=h9.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),l.set(n,r));let a=s[t],o=l.get(a);return o===void 0&&(o=h9.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),l.set(a,o)),r-o});l.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of u){let n=s[t];if(n){let t=h9.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let d=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,h9);n&&(n.project(e),Math.abs(n.z)<=1&&(d=n.clone()))}else d=new M(0,0,0);if(d){let t=n.accessibleNodes.filter(t=>{if(t===this.currentPano.panoIndex&&n.work.workCode===this.currentPano.workCode)return!1;let r=s[t];if(!r)return!1;let i=r.position.clone().applyMatrix4(r.work.transform).project(e);return Math.abs(i.z)>1||Math.abs(i.x)>1||Math.abs(i.y)>1?!1:r.loadable||r.active}),r=new Map,i=t.slice().sort((t,n)=>{let i=s[t],a=r.get(i);a===void 0&&(a=h9.copy(i.position).applyMatrix4(i.work.transform).distanceTo(e.position),r.set(i,a));let o=s[n],c=r.get(o);return c===void 0&&(c=h9.copy(o.position).applyMatrix4(o.work.transform).distanceTo(e.position),r.set(o,c)),a-c});r.clear();for(let t of i){let n=s[t];if(n){let t=h9.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(d.x-t.x,2)+Math.pow(d.y-t.y,2)<Math.pow(.4,2))return n}}}return null}onTapGesture(e){var t;if(this.userAction=e.userAction,this.stopMomentumMovement(),!this.initAnimationed)return;let n=e.center.raycaster;n.floorIndex=-1;let r=this.camera.getDirection(new M).setY(0),i=null,a=this.works.getObserver(this.currentPano);if(!a)return;let o=a.work.observers,s=a.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&a.work.workCode===this.currentPano.workCode)return!1;let t=o[e];return!t||h9.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[c]=this.modelScene.intersectRaycaster(n);if(c){let[e,n]=rQ(s,e=>{let t=o[e];return t?h9.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(c.point):1/0},!0);typeof e==`number`&&n<this.panoTapTriggerRadius&&(i=(t=o[e])==null?null:t)}if(i||(i=this.getForwardObserverOrNot(this.camera,n)),i&&i.panoId===u3(this.currentPano)&&(i=null),i&&!this.locationMotion.ended){for(let e of this.locationMotion.keyframes)if(this.panoResourceFromLocationMotionKeyframe(e).panoId===i.panoId){i=null;break}}if(!i)this.emit(`gesture.tap`,e),e.defaultPrevented||this.locationMotion.ended===!0&&this.cameraBounce();else{let t={},n=Math.PI/6,o=Math.PI/12,s=i.position.clone().applyMatrix4(i.work.transform).setY(0).sub(a.position.clone().applyMatrix4(i.work.transform).setY(0)).normalize(),c=[],l=[],u=[],d=i.work.observers;for(let e of i.accessibleNodes){if(i.panoIndex===e||e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)continue;let t=d[e];if(!t)continue;let r=t.position.clone().applyMatrix4(t.work.transform).sub(i.position.clone().applyMatrix4(i.work.transform)).setY(0).normalize();s.angleTo(r)<n&&u.push(r)}let[f]=(u.length>0?u:[...c,...l]).slice().sort((e,t)=>e.angleTo(s)-t.angleTo(s));if(f&&f.angleTo(r)>o&&(t.longitude=Math.atan2(-f.x,-f.z)),this.cameraMotion.value.latitude<-Math.PI/4){let n=e.state.fov;t.latitude=Y(0,Y(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),Y(typeof this.maxLatitude==`function`?this.maxLatitude(n):this.maxLatitude,-Math.PI/2,Math.PI/2))}let p=Object.assign({},e.state);if(p.workCode=i.work.workCode,p.panoIndex=i.panoIndex,t.longitude!==void 0&&(p.longitude=t.longitude),t.latitude!==void 0&&(p.latitude=t.latitude),t.fov!==void 0&&(p.fov=t.fov),p.distance=0,p.offset=i.position.clone(),e.state=p,this.emit(`gesture.tap`,e),!e.defaultPrevented){if(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:p,userAction:e.userAction,options:t,progress:0,error:null})),i&&!i.active){let e=u3({panoIndex:i.panoIndex,workCode:i.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}i&&i.active&&this.emit(`pano.request`,$(`pano.request`,{userAction:e.userAction,prevPano:this.currentPano,progress:0,state:p,options:t,error:null}))}}}},y9=new M(0,1.6,0),b9=new gi,x9=new M,S9=Object.assign({},S7),C9=class e extends C7{static parseArgs(t){return t instanceof e?t:super.parseArgs(t)}static initAnimationEndState(e){var t,n,r,i,a,o;let s=this.parseArgs(e),c=s.works,{state:l,currentState:u}=e.initial,d=typeof l.panoIndex==`number`?{workCode:(r=(t=l.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:l.panoIndex}:{workCode:u.workCode,panoIndex:u.panoIndex},f=c.getObserver(d),p=Y((i=l.fov)==null?!f||N5(u.mode)?u.fov:s.defaultFov:i,s.minFov,s.maxFov),m=(a=l.longitude)==null?u.longitude:a,h=Y(typeof s.minLatitude==`function`?s.minLatitude(p):s.minLatitude,-Math.PI/2,Math.PI/2),g=Y(typeof s.maxLatitude==`function`?s.maxLatitude(p):s.maxLatitude,-Math.PI/2,Math.PI/2),_=Y((o=l.latitude)==null?!f||N5(u.mode)?u.latitude:s.defaultLatitude:o,h,g),v=new M;if(s.initial.state.offset)v.copy(s.initial.state.offset);else if(f)v.copy(f.position).applyMatrix4(f.work.transform);else{let e=LU(u).setLength(u.distance);v.copy(s.initial.currentState.offset).sub(e)}return{workCode:d.workCode,panoIndex:d.panoIndex,mode:`Model`,longitude:m,latitude:_,fov:p,offset:v,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new b$({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x})}updateConfiguration(e){return super.updateConfiguration(e)}destroy(){super.destroy(),this.locationMotion.dispose()}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));return(a.workCode!==this.currentPano.workCode||a.panoIndex!==this.currentPano.panoIndex||a.longitude!==this.cameraMotion.value.longitude||a.latitude!==this.cameraMotion.value.latitude||a.fov!==this.cameraMotion.value.fov)&&this.moveToPosition(a.offset,{duration:0,longitude:a.longitude,latitude:a.latitude,fov:a.fov},i),!0}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return r.distance=0,e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(X),this.cameraMotion.set(i,t).catch(X)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:0,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(X),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t,...n){if(this.destroyed)return;let r={},i={};if(this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),r.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),r.progress=1,r.pano0=r.pano1=t}if(this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),n=[];for(let e of this.works){let r=this.modelScene.models.find(t=>t.work===e);if(!(!r||r.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=rQ(n,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t));this.currentPano=r?{workCode:r.work.workCode,panoIndex:r.panoIndex}:{workCode:``,panoIndex:0}}this.cameraMotion.ended||(this.cameraMotion.update(e),i.longitude=this.cameraMotion.value.longitude,i.latitude=this.cameraMotion.value.latitude,i.fov=this.cameraMotion.value.fov),P5(r)||this.modelScene.parameter.set(r),P5(i)||this.setCamera(i);let a=this.works.getObserver(this.currentPano);if(this.intersectMesh&&this.intersectMesh.parent&&a&&a.position.y-a.standingPosition.y>10){let e=Y(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)}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={modelAlpha:1},c={perspToOrtho:0},l={longitude:o.longitude,latitude:o.latitude,fov:o.fov,duration:i,moveStartCallback:e=>{this.perspToOrthoMotion.set(c,i).catch(X),this.modelAlphaMotion.set(s,i).catch(X),this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:e,userAction:this.userAction}))},moveEndCallback:e=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:e,userAction:this.userAction})),t()},moveCancelCallback:()=>{let e=this.currentPano,n=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:this.camera.pose.distance});this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:n,userAction:this.userAction})),t()}};this.moveToPosition(o.offset,l,a)})}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,offset:new M(t.value.x,t.value.y,t.value.z),distance:t.value.distance})}moveToPano(e,t={},n){let r=this.works.getObserver(e);if(r){let e=new M().copy(r.position).applyMatrix4(r.work.transform);this.moveToPosition(e,t,n)}}moveToPosition(e,t={},n){var r,i,a;this.userAction=n,this.stopMomentumMovement();let o=HU(),s=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),c=s.distanceTo(e),l=this.locationMotion.getProgressVelocity(o),u=0;for(let e=1;e<this.locationMotion.keyframes.length;e++){let{x:t,y:n,z:r}=this.locationMotion.keyframes[e-1].value,{x:i,y:a,z:o}=this.locationMotion.keyframes[e].value;u+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let d=c===0?0:l*u/c,f=this.calculateMovingDuration(t.duration,c),p={x:e.x,y:e.y,z:e.z,distance:0},m={longitude:t.longitude,latitude:t.latitude,fov:t.fov},h=[];for(let e of this.works){let t=this.modelScene.models.find(t=>t.work===e);if(!(!t||t.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(s)))for(let t of e.observers)h.push(t)}let g=rQ(h,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),_=g?{workCode:g.work.workCode,panoIndex:g.panoIndex}:{workCode:``,panoIndex:0},v=Object.assign(Object.assign({},_),{mode:this.mode,longitude:(r=m.longitude)==null?this.camera.pose.longitude:r,latitude:(i=m.latitude)==null?this.camera.pose.latitude:i,fov:(a=m.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),y=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:y,progress:0,state:v,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(v),this.cameraMotion.set(m,f).catch(X),this.locationMotion.set(p,f,d).then(()=>{for(let e of this.modelScene.children)e instanceof j4&&e.show();let e=Object.assign(Object.assign(Object.assign({},_),{mode:this.mode}),j5(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:y,progress:0,state:e,userAction:this.userAction,error:null})),t.moveEndCallback&&t.moveEndCallback(e)},()=>{t.moveCancelCallback&&t.moveCancelCallback(),this.emit(`pano.cancel`,$(`pano.cancel`,{options:t,prevPano:y,progress:0,state:v,userAction:this.userAction,error:null}))})}onTapGesture(e){let t=e.center.raycaster;this.stopMomentumMovement();let[n]=this.modelScene.intersectRaycaster(t);if(n&&n.face){let e=n.face.normal,t=n.point;if(new M(0,1,0).angleTo(e)>Math.PI/3){let r=new $d;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new M(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new M().copy(n.point).add(y9),r=[];for(let e of this.works){let n=this.modelScene.models.find(t=>t.work===e);if(!(!n||n.visible===!1)&&!(e.observers.length<=0)&&(b9.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),b9.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=rQ(r,e=>x9.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=x9.copy(i.position).applyMatrix4(i.work.transform).y),e.state.offset.copy(t),e.state.distance=0,this.emit(`gesture.tap`,e),e.defaultPrevented||this.moveToPosition(t,{},!0)}else this.emit(`gesture.tap`,e),e.defaultPrevented||this.cameraBounce()}},w9=new gi,T9=new M,E9=.5,D9=Math.PI/7,O9={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new f7},k9={Floorplan:y7,Topview:x7,Panorama:v9,Model:C9,Mapview:class e extends Q5{static parseArgs(t){var n,r,i,a,o,s,c,l;if(t instanceof e)return t;let u=super.parseArgs(t);return Object.assign(Object.assign({},u),{defaultLongitude:(n=t.defaultLongitude)==null?O9.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?O9.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?O9.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?O9.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?O9.minLatitude:o,cameraType:(s=t.cameraType)==null?O9.cameraType:s,cameraFence:(c=t.cameraFence)==null?O9.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?O9.intersectMeshCreator:l})}static distanceFromModel(e,t,n){let r=e.boundingBox,i=r.isEmpty()?10:Math.pow(Math.pow(r.max.x-r.min.x+1,2)+Math.pow(r.max.y-r.min.y+1,2)+Math.pow(r.max.z-r.min.z+1,2),1/2);i=isNaN(i)||!isFinite(i)?1:i;let a=i/2/Math.tan(Math.PI*t/360);return n<1&&(a/=n),isNaN(a)||!isFinite(a)?i:a}static initAnimationEndState(t){var n,r,i,a,o,s,c;let l=this.parseArgs(t),u=l.works,d=l.modelScene,{state:f,currentState:p}=t.initial,m=typeof f.panoIndex==`number`?{workCode:(i=(n=f.workCode)==null?(r=l.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:f.panoIndex}:{workCode:p.workCode,panoIndex:p.panoIndex},h=(a=f.fov)==null?60:a,g=Y(typeof l.minLatitude==`function`?l.minLatitude(h):l.minLatitude,-Math.PI/2,Math.PI/2),_=Y(typeof l.maxLatitude==`function`?l.maxLatitude(h):l.maxLatitude,-Math.PI/2,Math.PI/2),v=Y((o=f.latitude)==null?M5(p.mode)?p.latitude:l.defaultLatitude:o,g,_),y=e.distanceFromModel(l.modelScene,h,l.camera.aspect),b=new M,x=(s=f.distance)==null?Math.min(l.defaultDistance,y):s,S=(c=f.longitude)==null?M5(p.mode)?p.longitude:l.defaultLongitude:c;if(f.offset)b.copy(f.offset);else{let e=u.getObserver(m);l.defaultDistance<y&&e?(b.copy(e.position).applyMatrix4(e.work.transform),f.longitude===void 0&&(S=p.longitude)):(d.boundingBox.getCenter(b),x=y)}return Object.assign(Object.assign({},m),{mode:`Mapview`,longitude:S,latitude:v,fov:h,offset:b,distance:x})}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Mapview`,this.defaultLongitude=n.defaultLongitude,this.defaultLatitude=n.defaultLatitude,this.defaultDistance=n.defaultDistance,this.maxLatitude=n.maxLatitude,this.minLatitude=n.minLatitude,this.cameraType=n.cameraType,this.cameraFence=n.cameraFence,this.locationMotion=new b$({x:this.camera.pose.offset.x,y:this.camera.pose.offset.y,z:this.camera.pose.offset.z,distance:this.camera.pose.distance}),this.modelAlphaMotion=new b$({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new b$({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new gJ,this.intersectMeshCreator=n.intersectMeshCreator,this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=`intersect`,this.intersectMesh.visible=!1,this.helper.add(this.intersectMesh)}updateConfiguration(e){if(super.updateConfiguration(e)===!1)return!1;if(e.defaultLongitude!==void 0&&this.defaultLongitude!==e.defaultLongitude&&(this.defaultLongitude=e.defaultLongitude),e.defaultLatitude!==void 0&&this.defaultLatitude!==e.defaultLatitude&&(this.defaultLatitude=e.defaultLatitude),e.defaultDistance!==void 0&&this.defaultDistance!==e.defaultDistance&&(this.defaultDistance=e.defaultDistance),e.maxLatitude!==void 0&&this.maxLatitude!==e.maxLatitude&&(this.maxLatitude=e.maxLatitude),e.minLatitude!==void 0&&this.minLatitude!==e.minLatitude&&(this.minLatitude=e.minLatitude),e.cameraType!==void 0&&this.cameraType!==e.cameraType&&(this.cameraType=e.cameraType),this.cameraFence instanceof gi&&e.cameraFence instanceof gi||this.cameraFence instanceof Zi&&e.cameraFence instanceof Zi?this.cameraFence.equals(e.cameraFence)||(this.cameraFence=e.cameraFence):e.cameraFence!==void 0&&(this.cameraFence=e.cameraFence),e.intersectMeshCreator!==void 0&&this.intersectMeshCreator!==e.intersectMeshCreator){this.intersectMeshCreator=e.intersectMeshCreator;let t=this.intersectMesh;this.intersectMesh=this.intersectMeshCreator(),this.intersectMesh.name=t.name,this.intersectMesh.visible=t.visible;let n=this.intersectMesh.parent;n&&n.add(this.intersectMesh),t.dispose()}return!0}destroy(){super.destroy(),this.pendingTextureId=null,this.locationMotion.dispose(),this.panState=void 0,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)}isReady(){return this.locationMotion.ended===!1?!1:super.isReady()}updateWork(t,n,r,i){this.userAction=i,this.works=t;let a=e.initAnimationEndState(Object.assign(Object.assign({},this),{initial:{currentState:Object.assign(Object.assign({},this.currentPano),this.camera.pose),duration:r.duration,effect:r.effect,state:n,userAction:i}}));this.currentPano={workCode:a.workCode,panoIndex:a.panoIndex};let o={longitude:a.longitude,latitude:a.latitude,fov:a.fov},s={x:a.offset.x,y:a.offset.y,z:a.offset.z,distance:a.distance};return(o.longitude!==this.cameraMotion.value.longitude||o.latitude!==this.cameraMotion.value.latitude||o.fov!==this.cameraMotion.value.fov)&&this.cameraMotion.set(o,r.duration).catch(X),(s.x!==this.locationMotion.value.x||s.y!==this.locationMotion.value.y||s.z!==this.locationMotion.value.z||s.distance!==this.locationMotion.value.distance)&&this.locationMotion.set(s,r.duration).catch(X),!0}updateModel(e){super.updateModel(e),this.hideIntersectMesh()}updateCamera(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r={},i={};return e.distance!==void 0&&(r.distance=e.distance),e.offset!==void 0&&(r.x=e.offset.x,r.y=e.offset.y,r.z=e.offset.z),e.longitude!==void 0&&(i.longitude=e.longitude),e.latitude!==void 0&&(i.latitude=e.latitude),e.fov!==void 0&&(i.fov=e.fov),this.locationMotion.set(r,t).catch(X),this.cameraMotion.set(i,t).catch(X)})}updateCameraWithKeyframes(e,t,n){return this.initAnimationReady.then(()=>{this.userAction=n,this.stopMomentumMovement();let r=[],i=[];for(let t of e)r.push({key:t.key,progress:t.progress,value:{distance:t.value.distance,x:t.value.offset.x,y:t.value.offset.x,z:t.value.offset.x}}),i.push({key:t.key,progress:t.progress,value:{longitude:t.value.longitude,latitude:t.value.latitude,fov:t.value.fov}});return this.locationMotion.setKeyframes(r,t).catch(X),this.cameraMotion.setKeyframes(e,t)})}updateTime(e,t){if(this.destroyed)return;let n={},r={};if(this.locationMotion.ended||(this.locationMotion.update(e),r.distance=this.locationMotion.value.distance,r.offset=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),r.longitude=this.cameraMotion.value.longitude,r.latitude=this.cameraMotion.value.latitude,r.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),n.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.modelScene.parameter.modelAlpha===0&&this.modelScene.parameter.progress!==1){let{pano0:e,pano1:t}=this.modelScene.parameter;e&&e.map!==(t==null?void 0:t.map)&&e.map.dispose(),n.progress=1,n.pano0=n.pano1=t}let i=0;if(this.cameraType===`auto`?i=+(Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02):this.cameraType===`perspective`?i=0:this.cameraType===`orthographic`&&(i=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==i&&this.perspToOrthoMotion.set({perspToOrtho:i},500).catch(X),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(Y(this.perspToOrthoMotion.value.perspToOrtho,0,1))),P5(n)||this.modelScene.parameter.set(n),P5(r)||this.setCamera(r),this.cameraFence&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&!this.inMomentumMovement&&this.locationMotion.ended&&this.perspToOrthoMotion.ended&&this.cameraMotion.ended){let e=LU(this.camera.pose,new M),t=new M().copy(this.camera.pose.offset).sub(e.clone().multiplyScalar(this.camera.pose.distance));if(this.cameraFence.distanceToPoint(t)>.01){let e=this.cameraFence.clampPoint(t,new M),n=this.camera.pose.offset.clone().add(e).sub(t),r=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:n,distance:this.camera.pose.distance});this.fixFinalState(r),this.locationMotion.set({x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance},300).catch(X)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=Y(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)}getTargetState(){let e=this.cameraMotion.getKeyFrameSegment(HU())[1],t=this.locationMotion.getKeyFrameSegment(HU())[1];return Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:t.value.distance,offset:new M(t.value.x,t.value.y,t.value.z)})}initAnimation(){return this.destroyed?Promise.resolve():new Promise(t=>{let{state:n,currentState:r,duration:i,userAction:a}=this.initial;this.userAction=a;let o=e.initAnimationEndState(this),s={longitude:o.longitude,latitude:o.latitude,fov:o.fov},c={x:o.offset.x,y:o.offset.y,z:o.offset.z,distance:o.distance};this.emit(`initAnimation.start`,$(`initAnimation.start`,{state:o,userAction:this.userAction})),this.perspToOrthoMotion.set({perspToOrtho:0},i).catch(X),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(X),this.cameraMotion.set(s,i).catch(X),this.locationMotion.set(c,i).then(()=>{this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:o,userAction:this.userAction}))},e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),j5(this.camera.pose));this.emit(`initAnimation.end`,$(`initAnimation.end`,{state:t,userAction:this.userAction}))}).then(()=>{t()})})}getForwardObserverOrNot(e){let[t]=this.modelScene.intersectRaycaster(e);if(!t)return null;let n=[];for(let t of this.works){let r=this.modelScene.models.find(e=>e.work===t);if(!(!r||r.visible===!1)&&!(t.observers.length<=0)&&(w9.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),w9.containsPoint(e.ray.origin)||e.ray.intersectsBox(w9)))for(let e of t.observers)n.push(e)}let[r,i]=rQ(n,e=>T9.copy(e.standingPosition).applyMatrix4(e.work.transform).distanceTo(t.point),!0);return r&&i<Math.max(r.standingPosition.distanceTo(this.camera.position)/5,10)?r:null}coordinatesForOffset(e){let t=this.renderer.getSize(new j);return{longitude:-2*e.x/(t.x*this.viewport.width),latitude:2*e.y/(t.y*this.viewport.height)}}requestMomentumMovement(e,t,n,r){if(this.inMomentumMovement===null)return;r=Math.max(r,1);let i=Object.assign({},n),a={longitude:0,latitude:0,x:0,y:0,z:0};for(let e=0;e<r;e++)i.longitude*=.996,i.latitude*=.996*.998,i.x*=.99,i.y*=.99,i.z*=.99,a.longitude+=i.longitude,a.latitude+=i.latitude,a.x+=i.x,a.y+=i.y,a.z+=i.z;let o=this.cameraMotion.value.fov,s=IU(this.cameraMotion.value.longitude+a.longitude),c=Y(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),l=Y(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),u=Y(this.cameraMotion.value.latitude+a.latitude,c,l),d=new M(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),f=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:u,offset:d,fov:o,distance:this.locationMotion.value.distance}),p=e.state.offset.clone().sub(LU(e.state).setLength(f.distance)),m=!(Math.abs(i.longitude)>1e-4||Math.abs(i.latitude)>1e-4||Math.abs(i.x)>1e-4||Math.abs(i.y)>1e-4||Math.abs(i.z)>1e-4);(this.cameraFence?this.cameraFence.containsPoint(p):!0)===!1&&(m=!0);let h=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:m,state:f}));if(this.inMomentumMovement.event=h,this.emit(`gesture.momentum`,h),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:u},0).catch(X),this.locationMotion.set({x:f.offset.x,y:f.offset.y,z:f.offset.z,distance:f.distance},0).catch(X),m?this.inMomentumMovement=null:iJ.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=LU(e,new M),n=new M().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new $d(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>E9+r.near,r.near=this.camera.near,r.far=this.camera.far;let i;if(i=this.modelScene.intersectRaycaster(r)[0],i&&i.distance<this.camera.near&&(i=void 0),!i){let e=new Do(new M(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new M);if(t){let e=t.distanceTo(r.ray.origin);e<1e3&&e>=r.near&&(i={distance:e,floorIndex:0,floor:0,point:t,object:this.scene,face:null})}}if(!i){let r=Math.max(e.distance,3);i={distance:r,floorIndex:0,floor:0,point:n.clone().add(t.clone().setLength(r)),object:this.scene,face:null}}i.distance>=this.camera.near&&x5(e.distance,i.distance)&&(e.distance=i.distance,e.offset=i.point)}onPanGesture(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.pointers.length,n=this.panState,r=0,i=!1;e.pointerType===`mouse`&&(r=e.center.buttons,i=e.center.shiftKey),n&&r===0&&n.buttons!==0&&(r=n.buttons);let a=n==null?void 0:n.target;if(!a){let t=this.relativeClientPosition(e.center),n=this.createRaycasterFromCamera(t,this.camera);a=new M().copy(n.ray.direction).multiplyScalar(3).add(n.ray.origin);let[r]=this.modelScene.intersectRaycaster(n);if(!r&&n.ray.direction.y<-.3){let e=new Do(new M(0,1,0),0),t=n.ray.intersectPlane(e,new M);if(t){let e=t.distanceTo(n.ray.origin);e<1e4&&e>=n.near&&(r={distance:e,floorIndex:0,floor:0,point:t,object:this.scene})}}if(r)a.copy(r.point);else{let e=new M().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new Do().setFromNormalAndCoplanarPoint(e,this.camera.pose.offset);n.ray.intersectPlane(t,a)}}if(e.isFinal?this.panState=void 0:this.panState={target:a,buttons:r,pointerLength:t,x:e.center.x,y:e.center.y},!(n===void 0||n.pointerLength!==t))if(t>1||r===2||i){let t={x:e.center.x-n.x,y:e.center.y-n.y},r=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=LU(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new M().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new j),s=2*t.x*a/o.y,c=2*t.y*a/o.y,l=new M;l.setFromMatrixColumn(this.camera.matrix,0),l.multiplyScalar(-s),r.add(l),this.camera.pose.latitude<D9?l.setFromMatrixColumn(this.camera.matrix,1):(l.setFromMatrixColumn(this.camera.matrix,0),l.crossVectors(this.camera.up,l)),l.multiplyScalar(c),r.add(l);let u=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:r,distance:this.camera.pose.distance});if(e.state=u,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:u.offset.x,y:u.offset.y,z:u.offset.z},0).catch(X),e.isFinal&&(this.fixFinalState(u),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:u.distance,x:u.offset.x,y:u.offset.y,z:u.offset.z},0).catch(X)),e.isFinal){let t=this.renderer.getSize(new j),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new M,o=new M;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<D9?i.setFromMatrixColumn(this.camera.matrix,1):(i.setFromMatrixColumn(this.camera.matrix,0),i.crossVectors(this.camera.up,i)),i.multiplyScalar(r),o.add(i),this.inMomentumMovement={uuid:eV()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:o.x,y:o.y,z:o.z},0)}}else{let t={x:e.center.x-n.x,y:e.center.y-n.y},r=this.coordinatesForOffset(t),i=IU(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=Y(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=Y(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=Y(this.cameraMotion.value.latitude+r.latitude,o,s);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(c=this.cameraMotion.value.latitude);let l=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:i,latitude:c,fov:a,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=l,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:l.distance,x:l.offset.x,y:l.offset.y,z:l.offset.z},0).catch(X):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(X),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:eV()},this.requestMomentumMovement(e,!0,Object.assign(Object.assign({},this.coordinatesForOffset({x:t,y:n})),{x:0,y:0,z:0}),0)}}}onPinchGesture(t){var n;if(!this.initAnimationIsReady)return;this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let r=(n=this.pinchState)==null?void 0:n.distance;if(t.isFirst){this.pinchState={x:t.center.x,y:t.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(r===void 0)return;let i=this.modelScene.boundingBox.getCenter(new M),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=Y(r/t.scale,E9,1/0),s=t.state.offset.clone().sub(LU(t.state).setLength(o)),c=this.modelScene.boundingBox.containsPoint(s),l;if(!c&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?l=t.state.distance:(l=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=l,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(X),t.pointerType!==`mouse`&&(t.type=`gesture.pan`,this.onPanGesture(t)),t.isFinal)){if(!(`__fixFinalState`in t)){let e=t.state;this.fixFinalState(t.state);let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(X)}this.panState=void 0,this.pinchState=void 0}}onMouseMove(e){var t,n;if(!this.intersectMesh.parent||this.panState||this.pinchState||this.mouseWheelState||(this.emit(`gesture.mousemove`,e),e.defaultPrevented))return;let r=e.center.raycaster;if(e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}let[i]=this.modelScene.intersectRaycaster(r),a=$(`intersect.update`,{raycaster:r,intersection:i==null?null:i,object:this.intersectMesh});if(this.emit(`intersect.update`,a),a.defaultPrevented){this.hideIntersectMesh();return}if(i){let e=(n=(t=i.face)==null?void 0:t.normal)==null?new M().copy(r.ray.direction).multiplyScalar(-1):n,a=e.clone(),o=i.point.clone();this.intersectMesh.position.copy(o);let s=o.clone().add(a);if(this.intersectMesh.lookAt(s),Math.abs(e.y)>.99){let e=this.camera.position.clone().sub(o);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}onMouseWheel(t){if(this.initAnimationIsReady)if(this.userAction=t.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),t.isFinal){let e=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov,offset:new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),distance:this.locationMotion.value.distance});if(this.fixFinalState(e),this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;let n={x:e.offset.x,y:e.offset.y,z:e.offset.z,distance:e.distance};this.locationMotion.set(n,0).catch(X)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new M(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=new La(r,LU(this.cameraMotion.value,new M).negate()).intersectBox(this.modelScene.boundingBox,new M);i&&(n+=i.distanceTo(r));let a=Math.max(this.locationMotion.value.distance-this.camera.near,0),o=t.center.delta/10*Math.max(a/5,.1);if(a<=n||o>0)if(this.locationMotion.value.distance-o>=E9){let e=this.locationMotion.value.distance-o;t.state.distance=e}else{let e=LU(this.cameraMotion.value);e.setLength(o),t.state.offset.add(e)}if(this.emit(`gesture.mousewheel`,t),t.defaultPrevented)return;this.locationMotion.set({distance:t.state.distance,x:t.state.offset.x,y:t.state.offset.y,z:t.state.offset.z},0).catch(X)}}onTapGesture(e){var t;this.userAction=e.userAction,this.stopMomentumMovement();let n=e.center.raycaster,r=this.getForwardObserverOrNot(n);if(!r)this.emit(`gesture.tap`,e);else{let n={longitude:this.camera.pose.longitude,latitude:0},i=Object.assign(Object.assign({},e.state),{mode:`Panorama`,workCode:r.work.workCode,panoIndex:r.panoIndex,longitude:n.longitude,latitude:n.latitude,offset:r?r.position.clone():new M,distance:0});if(e.state=i,this.emit(`gesture.tap`,e),!e.defaultPrevented&&(this.emit(`pano.select`,$(`pano.select`,{prevPano:this.currentPano,state:i,userAction:e.userAction,options:n,progress:0,error:null})),r&&r.active)){let e=this.pendingTextureId=eV(),a=u3({panoIndex:r.panoIndex,workCode:r.work.workCode}),o={right:r.images.work.getURL(r.images.right),left:r.images.work.getURL(r.images.left),up:r.images.work.getURL(r.images.up),down:r.images.work.getURL(r.images.down),front:r.images.work.getURL(r.images.front),back:r.images.work.getURL(r.images.back)},s=this.imageOptions.transform,c=Object.assign({key:`pano.${a}`},hq(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),l=`pano:`+c3([o,c,s]),u=this.modelScene.parameter,d;if(u.pano0&&u.pano0.map.name===l?d=u.pano0:u.pano1&&u.pano1.map.name===l&&(d=u.pano1),d)u.pano0&&u.pano0.map!==d.map&&u.pano0.map.dispose(),u.pano1&&u.pano1.map!==d.map&&u.pano1.map!==((t=u.pano0)==null?void 0:t.map)&&u.pano1.map.dispose(),u.set({pano0:d,pano1:d}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,d=``;r.images.hdrConfig&&(t={right:r.images.work.getURL(r.images.gainmap_right),left:r.images.work.getURL(r.images.gainmap_left),up:r.images.work.getURL(r.images.gainmap_up),down:r.images.work.getURL(r.images.gainmap_down),front:r.images.work.getURL(r.images.gainmap_front),back:r.images.work.getURL(r.images.gainmap_back)},d=r.images.work.getURL(r.images.hdrConfig));let f=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:c},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),p=d?[fetch(d).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:c},format:Ce,viaAjax:!0,fetcher:f4(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([f,...p]).then(t=>EV(this,[t],void 0,function*([t,o,s]){var c,d;let{body:f}=t;if(this.destroyed||this.pendingTextureId!==e){f.dispose();return}this.pendingTextureId=null,f.name=l;let p=Array.isArray(f.image)?f.image[0]:f.image,m=(c=p==null?void 0:p.width)==null?2048:c,h=yield X5(this.renderer,f,!0,n8),g=new o8().formPixels(h.data),_={panoId:a,map:f,mapSize:m,mapHistogram:new dr().fromArray(g.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},h7(o)):void 0};u.pano0&&u.pano0.map.dispose(),u.pano1&&u.pano1.map!==((d=u.pano0)==null?void 0:d.map)&&u.pano1.map.dispose(),u.set({pano0:_,pano1:_}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}))})).catch(t=>{this.destroyed||this.pendingTextureId!==e||(this.pendingTextureId=null)})}}}}onDblTapGesture(e){if(!this.initAnimationIsReady)return;this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();let t=e.state,n=e.center.raycaster,r=n.ray.origin.clone().add(n.ray.direction.clone().setLength(3)),i=1,[a]=this.modelScene.intersectRaycaster(n);if(a&&(r=a.point.clone(),i=a.distance>4/2?1:3),e.state.distance=i,e.state.offset=r,this.emit(`gesture.dbltap`,e),e.defaultPrevented)return;let o={x:t.offset.x,y:t.offset.y,z:t.offset.z,distance:t.distance};this.locationMotion.set(o,360).catch(X),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},A9={Floorplan:v7,Topview:b7,Panorama:_9,Model:S9,Mapview:O9},j9=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.create,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,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 M9(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=LU(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 N9(){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 P9(){let e=new Gr;e.name=`internalLights`;{let t=new Hu(16777215,.1);t.name=`direction0`,t.position.copy(new M(0,1,0)),e.add(t)}{let t=new Hu(16777215,.1);t.name=`direction1`,t.position.copy(new M(-1,-1,-1)),e.add(t)}{let t=new Hu(16777215,.3);t.name=`direction2`,t.position.copy(new M(1,1,1)),e.add(t)}{let t=new Uu(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function F9(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 I9(){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=F9((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var L9=1e3,R9=90,z9=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/`),B9=new Zi,V9=new gi,H9=new dr,U9=new dr,W9=new P,G9=new j,K9=new WeakMap,q9=e6([Z3(null)]),J9={},Y9=class e extends aV{static get version(){return`1.0.0-alpha.2`}static get dracoPath(){return wX.decoderPath}static set dracoPath(e){wX.setDecoderPath(e)}static get ktx2Path(){return MX.transcoderPath}static set ktx2Path(e){MX.setTranscoderPath(e)}static get useNativeImageBitmap(){return cJ()}static set useNativeImageBitmap(e){sJ(e)}constructor(e={}){var t,n,r,i,a,o,s,c,l,u,d;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=eV(),J9[this.fiveId]=this,this.currentUpdateArgs={time:HU(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!0,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 P((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)},this.fps={testCount:0,testTime:HU()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?L9:s,this.enableWheel=(c=e.enableWheel)==null?!0:c,typeof window<`u`)if(`renderer`in e)e.renderer instanceof K8&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new K8({outputType:e.enableHDR?he:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=I9();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 fr(1,1,{colorSpace:(u=(l=this.renderer)==null?void 0:l.outputColorSpace)==null?At:u,generateMipmaps:!1}),this.renderer&&XK(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new ZU(R9),this.scene=new Q8,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new ti,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(d=e.requestProxy)==null?z9:d,this.networkSubscribe=new cq,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,$(`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 Gr,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),K9.set(this,q9),this.modelScene=new H4({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[f]=this.modelScene.setModels(q9,{forceReplaceImmediately:!0});Z(f,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new xs(e.videoInstance||N9());let p=P9();this.scene.add(p),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=iJ.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let m=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,m,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,m,!1)},this.loadWorkTask=this.prepare(),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)}}}M9(this),this.fiveRenderer=new U8({outputType:e.enableHDR?he:void 0}),this.adaptiveLuminancePass=new S8,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new w8(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new YH,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([Aq().catch(X)]).then(X)}dispose(){var e;if(this.destroyed===!0)return;delete J9[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(),K9.set(this,q9),this.renderer&&(!(this.renderer instanceof K8)||this.renderer.isInitialized)&&this.renderer.render(new ti,new ju),this.fiveRenderer.dispose(),this.renderer instanceof K8&&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`,$(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,_q(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,_q(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,_q(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,_q(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,_q(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),this.currentMode===`Panorama`&&(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 K8)){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,a,o,s;if(!this.renderer)return;let c=this.renderer.domElement.parentNode,{width:l=(n=c==null?void 0:c.offsetWidth)==null?512:n,height:u=(r=c==null?void 0:c.offsetHeight)==null?512:r}=e;if(l=Math.max(1,l),u=Math.max(1,u),!t){let e=I9(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(l,u)*t,n=Math.min((s=(o=(a=this.renderer.backend.device)==null?void 0:a.limits)==null?void 0:o.maxTextureDimension2D)==null?8192:s,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(l,u),this.needsRender=!0;let d=HU(),f=d-this.currentUpdateArgs.time,p=this.currentUpdateArgs.args;this.updateTime(d,f,...p)}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 K9.get(this)||q9}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(()=>w5(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,c,l,u,d,f,p,m;let h={};typeof r==`number`?h.duration=r:typeof r==`object`&&Object.assign(h,r),this.works===q9&&(h.duration===void 0&&(h.duration=0),h.effect===void 0&&(h.effect=`instant`));let g={};Object.assign(g,h.model),!g[`3d-tiles`]&&h[`3d-tiles`]&&(g[`3d-tiles`]=h[`3d-tiles`]),!g.textureOptions&&h.textureOptions&&(g.textureOptions=h.textureOptions),!g.textureOptions&&this.textureOptions&&(g.textureOptions=this.textureOptions);let _=[];if(Array.isArray(t))for(let e of t)e instanceof X3?_.push(e):typeof e!=`string`&&`work`in e?_.push(Z3(e.work,e)):_.push(Z3(e));else t instanceof X3?_.push(t):_.push(Z3(t));h.mode===`add`&&(_=[].concat(this.works,_));let v;try{v=e6(_)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of v)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===q9&&(n=`initial`);let y=this.currentMode,b=v.initial,x=b.work.observers[0],S=x?{workCode:x.work.workCode,panoIndex:x.panoIndex}:{workCode:b.work.workCode,panoIndex:0},C=(a=b.mode)==null?x?`Panorama`:`Mapview`:a,w={};if(n===`inherit`){let e=this.getCurrentState(),[t]=v.filter(t=>t.workCode===e.workCode);if(t)S={workCode:e.workCode,panoIndex:e.panoIndex},C=e.mode,w={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:y};let e=(s=(o=v[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof v.initial.panoIndex==`number`?(n.workCode=v.initial.work.workCode,n.panoIndex=v.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===y&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof b.panoIndex==`number`&&(S={workCode:b.work.workCode,panoIndex:b.panoIndex}),b.mode&&(C=b.mode),w={longitude:b.longitude,latitude:b.latitude,fov:b.fov,distance:b.distance,offset:(c=b.offset)==null?void 0:c.clone()}),typeof n==`object`){if(C=(l=n.mode)==null?y:l,typeof n.panoIndex==`number`){let e=v.getObserver({workCode:(d=(u=n.workCode)==null?b.work.workCode:u)==null?``:d,panoIndex:n.panoIndex});e&&(S={workCode:e.work.workCode,panoIndex:e.panoIndex})}w={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new M().copy(n.offset):void 0}}let T=(f=h.duration)==null?this.modeChangeDuration:f;(C===`Floorplan`||C===`Topview`||C===`Mapview`)&&y===C&&(T=0);let E=`fly`;C===`Panorama`&&y===C&&(E=(p=h.effect)==null?`fade`:p),this.emit(`works.request`,$(`works.request`,{input:t,works:v,userAction:i}));let D=(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:T,effect:E,userAction:i}},this.commonParams()),this.controllerInits[e]),c=k9[o.mode].initAnimationEndState(s);if(this.controller&&y===e)this.controller.updateWork(v,c,{effect:E,duration:T},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=k9[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))}this.controller=this.applyController(e,s);let t=$(`mode.change`,{prevMode:y,mode:e,state:c,userAction:i});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.state.workCode=this.pano.workCode,this.state.panoIndex=this.pano.panoIndex,this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};K9.set(this,v);let ee=Promise.resolve();if(C===e.Mode.Floorplan||C===e.Mode.Topview||C===e.Mode.Mapview||C===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(w),A5(this.state,this.camera.pose));let e=this.modelScene.setModels(v,g);ee=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,D(C,S,w),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{D(C,S,w);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===v&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`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(v,g);ee=Promise.all(r.map(e=>e.initReady)).then(X),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((m=h.duration)==null?this.modeChangeDuration:m)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:v})),ee.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:v})),(e=this.analysis)==null||e.work(v)})}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}),K9.set(this,q9),this.modelScene.setModels(q9,{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:R9,longitude:0,latitude:0,offset:new M(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&&!this.works.getObserver(m)){let e=Error(`PanoId ${u3(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?!f3(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(X):(f3(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(X));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=k9[t].initAnimationEndState(r),o=$(`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=$(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=iJ.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),iJ.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return EV(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=HU(),c=this.renderer.getPixelRatio(),l=this.renderer.getRenderTarget(),u=this.getSize(new j),d=0,f=0,p=1,m=1,h,g,_,v,y;typeof e==`number`?(d=e,typeof t==`number`&&(f=t),typeof n==`number`&&(p=n),typeof r==`number`&&(m=r),h=i,g=a,y=o):(d=e.x,f=e.y,p=e.width,m=e.height,h=e.pixelRatio,g=e.flipY,_=e.helperVisible,v=e.skipPanorama,y=e.buffer),d=Math.floor(d),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h==null?c:h),g=g==null?!1:g;let b=this.helperVisible,x=this.modelScene.parameter.modelAlpha;this.helperVisible=_==null?this.helperVisible:_,v&&this.controller instanceof k9.Panorama&&v===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let S=this.getPixelsRenderTarget;S.setSize(p*h,m*h),this.renderer.setRenderTarget(S),this.camera.pixelRatio=h,this.camera.resolution.set(p,m),this.camera.setViewOffset(u.width,u.height,d,u.height-f-m,p,m),this.camera.aspect=u.width/u.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let C=this.renderer.autoClear,w=this.renderer.autoClearColor,T=this.renderer.autoClearDepth,E=this.renderer.autoClearStencil,D=this.renderer.getClearColor(W9),ee=this.renderer.getClearAlpha(),te=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let ne=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:ne,this.renderer.render(this.scene,this.camera),this.scene.background=ne,this.renderer.autoClear=C,this.renderer.autoClearColor=w,this.renderer.autoClearDepth=T,this.renderer.autoClearStencil=E,this.renderer.setClearColor(D,ee),this.renderer.setScissorTest(te),this.helperVisible=b,x===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,x),this.renderer.setRenderTarget(l),this.camera.clearViewOffset(),this.camera.pixelRatio=c,this.camera.resolution.copy(u),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 re=p*h,O=m*h,ie=re*O,ae=ie*4;if(y){if(y.length!==ae)throw Error(`buffer length is not equals pixels ${ae}`)}else y=new Uint8Array(ae);let oe=yield this.renderer.readRenderTargetPixelsAsync(S,0,0,re,O),se=re*4;if(oe.length===ae)y.set(oe);else{let e=Math.ceil(se/256)*256;for(let t=0;t<O;t++){let n=t*e;y.set(oe.subarray(n,n+se),t*se)}}if(!g){let e=ie/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(O-Math.floor(n/re)-1)*re+n%re,r=0;r<4;r++)t=y[n*4+r],y[n*4+r]=y[i*4+r],y[i*4+r]=t}return y})}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=t.getClearColor(W9),c=t.getClearAlpha(),l=t.getViewport(H9),u=t.getScissor(U9),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(G9),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;this.controller&&this.controller.render()&&(y=!1),y&&this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender),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&&iJ.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&MX.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),iJ.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&iJ.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){V9.makeEmpty(),V9.expandByObject(this.modelScene.boundingMesh);let t=V9.getBoundingSphere(B9),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=Y(n/500,.001,.1),i=Y(n,800);this.camera.near!==r&&(this.camera.near=r),this.camera.far!==i&&(this.camera.far=i),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||this.renderer instanceof K8&&!this.renderer.isInitialized)return;let r=$(`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`,$(`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 K8&&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=X){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=HU();return Promise.all(r.map(e=>{let t=u3({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},hq(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):qq(i,r);return f4(this.fiveId,n.work).preload(a)})).then(()=>{let e=HU()-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 $d(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 j),i=r.x*this.viewport.width,a=r.y*this.viewport.height;return new j(r.x*this.viewport.left+(n.x+1)/2*i,r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a)}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,c,l,u,d,f;e=hq(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof M)&&(e.offset=new M(e.offset.x,e.offset.y,e.offset.z));let p;if(typeof e.panoIndex==`number`)if(e.workCode)p={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),p={workCode:t,panoIndex:e.panoIndex}}let m=(a=e.mode)==null?this.state.mode:a,h,g,_,v,y;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==m){let t={workCode:p==null?void 0:p.workCode,panoIndex:p==null?void 0:p.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 M&&(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[m]),r=k9[m].initAnimationEndState(n);h=r.longitude,g=r.latitude,_=r.fov,v=r.offset,y=r.distance}else h=(o=e.longitude)==null?this.state.longitude:o,g=(s=e.latitude)==null?this.state.latitude:s,_=(c=e.fov)==null?this.state.fov:c,v=(l=e.offset)==null?this.state.offset:l,y=(u=e.distance)==null?this.state.distance:u;let b={workCode:(p==null?this.pano:p).workCode,panoIndex:(p==null?this.pano:p).panoIndex,mode:m,longitude:h,latitude:g,fov:_,offset:v,distance:y};this.emit(`state.set`,$(`state.set`,{userAction:n,state:b})),k5(this.state,b)||(O5(this.state,b),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===b.mode&&(this.syncingState=this.syncState(HU(),0,t),this.syncingState&&((d=this.controller)==null||d.updateTime(HU(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(f=this.analysis)==null||f.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 k9.Model){if(C5(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(!f3(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 k9.Floorplan||this.controller instanceof k9.Topview||this.controller instanceof k9.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:l8(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:l8(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),c=s>e*15?s/15:e,l=r?new M().copy(this.state.offset):u8(this.camera.pose.offset,this.state.offset,c),{longitude:u,latitude:d}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:d8({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(x5(n,this.camera.pose.fov)||C5(l,this.camera.pose.offset)||x5(o,this.camera.pose.distance)||x5(u,this.camera.pose.longitude,Math.PI*2)||x5(d,this.camera.pose.latitude)){let e={x:l.x,y:l.y,z:l.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:u,latitude:d}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(X),this.controller.locationMotion.set(e,0).catch(X),!0}}else{let e=Math.PI/45,t=r?this.state.fov:l8(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:d8({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 M().copy(this.state.offset);if(x5(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),C5(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),x5(n,this.camera.pose.longitude,Math.PI*2)||x5(i,this.camera.pose.latitude)||x5(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(X),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`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 k9.Panorama&&t.tile===!0?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(X)}requestFullscreen(){var e;if(!D5)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=()=>{iJ.shared.add(()=>{this.emit(`model.load`,$(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,$(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,$(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,$(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,$(`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`,$(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new pq({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=F3(e,r);return t instanceof Error?Promise.reject(t):t})}});p4(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(e,t){if(!this.renderer)throw Error(`renderer is not initialized.`);let n=k9[e];this.currentMode=e;let r=new n(t);for(let e of j9)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=k9[e].initAnimationEndState(t),r=t.initial.userAction;k5(this.state,n)||(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,$(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return r.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,$(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),r.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.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&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!k5(this.state,n)&&(O5(this.state,n),this.emit(`state.change`,$(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),r.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,$(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),r.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),r.on(`error`,e=>this.throwError(e)),r}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 Wr;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new M(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().invert();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 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}};Y9.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:np,constructor:Y9,instances:J9}}),e.AdaptiveLuminancePass=S8,e.AnimationFrameLoop=iJ,e.BoundingMesh=B4,e.Camera=ZU,e.EffectComposer=n6,e.EyeDomeLightingPass=w8,e.Fetcher=pq,e.Five=Y9,e.FivePass=i6,e.FiveRenderer=U8,e.FlowingFireworks3DPass=P8,e.FlowingLight2DPass=O8,e.FlowingLight3DPass=E8,e.FullScreenQuad=r6,e.GaussianBlurPass=T8,e.Histogram=o8,e.InternalWebGPURenderer=K8,e.Model=j4,e.ModelScene=H4,e.Motion=b$,e.NetworkSubscribe=cq,e.PBMGSObject=QB,e.PBMGaussianSplattingObject=QB,e.PBMGaussianSplattingNodeMaterial=qH,e.PBMGaussianSplattingRenderMesh=YH,e.PBMGroup=GB,e.PBMMesh=XB,e.PBMMeshBasicMaterial=XH,e.PBMMeshBasicNodeMaterial=VK,e.PBMMeshPanoOnlyMaterial=ZH,e.PBMMeshPanoOnlyNodeMaterial=qK,e.PBMMeshPhongMaterial=QH,e.PBMMeshPhongNodeMaterial=UK,e.PBMMeshPhysicalMaterial=$H,e.PBMMeshPhysicalNodeMaterial=GK,e.PBMPanoFilter=sV,e.PBMPointCloud=wV,e.PBMSkinnedMesh=ZB,e.PBMUpdateable=oV,e.PROXY_CONTROLLER_EVENT_NAMES=j9,e.PanoCircleMesh=o5,e.PanoCircleMeshCustom=y5,e.PanoCircleMeshSolid=m5,e.Parameter=Z2,e.Scene=Q8,e.Subscribe=aV,e.TextureLoader=gJ,e.Tile=tQ,e.Tile3D=u4,e.Tile3DModel=u4,e.TileCache=B$,e.TileNode=k$,e.TileRequestScheduler=L$,e.Tileset=K$,e.Trajectory=N$,e.TrajectoryNode=P$,e.Work=X3,e.WorkResolvedObserver=$3,e.controllersDefaultInitArgs=A9,e.coordinatesToVector=LU,e.createDebugBoundingMesh=XZ,e.createWorks=e6,e.defaultImageURLTransform=qq,e.draco=wX,e.getViewportScale=I9,e.headingToLongitude=BU,e.imageSupport=Aq,e.isBoundingVolume=GZ,e.isPanoId=p3,e.loadAt3d=xY,e.loadDome=EY,e.loadDomez=NY,e.loadGltf=wZ,e.loadPbm=$J,e.loadPly=LY,e.longitudeToHeading=zU,e.makeBoundingVolume=KZ,e.panoEqual=f3,e.panoParse=d3,e.panoStringify=u3,e.parseWork=Z3,e.registerPBMMaterials=XK,e.vectorToCoordinates=RU,e.workToJson=q4});
|