@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/five/index.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
|
|
@@ -1176,4 +1176,4 @@ void main() {
|
|
|
1176
1176
|
float cameraDepth = length(cameraVertex);
|
|
1177
1177
|
gl_FragColor = packDepthToRGBA(clamp(cameraDepth / maxDepth, 0.0, 1.0));
|
|
1178
1178
|
}
|
|
1179
|
-
`,uniforms:{maxDepth:new c.Uniform(0)}});function VS(e,t,n,r=1e3){BS.uniforms.maxDepth.value=r,e.getClearColor(zS);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=BS,e.setClearColor(RS,0),n.update(e,t),e.setClearColor(zS,i),t.overrideMaterial=a}var HS=Ip,US=new c.Raycaster,WS=new c.Vector3,GS=[new c.Vector3(0,0,0).multiplyScalar(.1),new c.Vector3(1,0,0).multiplyScalar(.1),new c.Vector3(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new c.Vector3(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],KS=Object.assign(Object.assign({},Zx),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new Ub:new Fb,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}),qS=class e extends Qx{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?KS.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?KS.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?KS.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?KS.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?KS.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?KS.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?KS.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?KS.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 J({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Mt()]={panoId:Sv(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:HS,fixCameraTransform:new c.Matrix4},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new Yc,this.tiling=new MS({fiveId:this.fiveId}),this.panoVideo=new LS,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=K,e.ontimeupdate=K,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,l,u;if(this.destroyed)return;let d={},f={},p=this.camera.getDirection(new c.Vector3),m=this.locationMotion.keyframes[0],h=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[g,_]=this.locationMotion.getKeyFrameSegment(e),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(_),b=this.panoResourceFromLocationMotionKeyframe(m),x=this.panoResourceFromLocationMotionKeyframe(h),S=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),f.longitude=this.cameraMotion.value.longitude,f.latitude=this.cameraMotion.value.latitude,f.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),d.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-_.value.count+1,n=new c.Vector3().copy(v.position),a=new c.Vector3().copy(y.position);if(d.progress=y.effectEasing(t),t>=.01&&t<=.99&&(d.progress=H(y.effectEasing(t),.01,.99)),y.panoPicture&&(t<1?v.panoPicture&&(d.pano0=v.panoPicture):d.pano0=y.panoPicture,d.pano1=y.panoPicture),y.effect===`montage`?d.transition=`BLACK`:y.effect===`spread`?d.transition=`SPREAD`:d.transition=`FADE`,y.effect===`zoomin`||y.effect===`zoomout`?d.progress=Math.pow(t,3):y.effect===`model`&&this.camera.pose.distance<.01&&(d.modelAlpha=1-Math.pow(H(Math.abs(t-.5)*2,0,1),4)),t<1&&y.effect!==`fly`&&y.effect!==`model`){if(d.pano0&&v.panoPicture){let e={panoId:d.pano0.panoId,map:d.pano0.map,mapHistogram:d.pano0.mapHistogram,mapSize:d.pano0.mapSize,zoom:d.pano0.zoom,matrix:v.panoPicture.matrix.clone().premultiply(v.fixCameraTransform).setPosition(y.position),hdrConfig:d.pano0.hdrConfig?Object.assign({},d.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(d.pano0);t&&this.panoPictureObserverMap.set(e,t),d.pano0=e}n.copy(a),S=!0}f.distance=this.locationMotion.value.distance,f.offset=new c.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=d.pano0)==null?void 0:r.map)||e===((i=d.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let l=Cv(y.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:Cv(b.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Cv(x.panoId)),{mode:this.mode}),ox(this.camera.pose)),f),options:{},progress:this.locationMotion.progress,error:null}))}lx(d)===!1&&this.modelScene.parameter.set(d),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),lx(f)===!1&&this.setCamera(f);let C=this.works.getObserver(this.currentPano),w=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,T=this.works.getObserver(v.panoId),E=this.works.getObserver(y.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&C){let e=[],t=C.work.observers;for(let n of C.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(C.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(C.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=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=GS.map(t=>{US.ray.origin.copy(i),US.ray.origin.add(WS.copy(t).setY(e)),US.ray.direction.set(0,-1,0),US.firstHitOnly=!0,US.floorIndex=-1;let[a]=n.intersectRaycaster(US);return a&&a.distance-r<=e?new c.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[l]=o.filter(e=>e.distanceTo(s)<=.05);if(l){let e=new c.Vector4(i.x,i.y,i.z,l.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let D=new Map;if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(E)for(let e of E.accessibleNodes){let t=E.work.observers[e];if(t){let e=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{D.get(t)?D.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),D.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),D.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&&(WS.set(t.x,t.y,t.z),WS.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new c.Vector3().copy(e.position).sub(i).normalize();if(t===Sv(this.currentPano)){let t=H((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(p.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new c.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||S)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(C){let n=C.work.observers,[,r]=vf(C.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:C.standingPosition.distanceTo(t.standingPosition)},!0);r=H(r,3,1/0);let i=C.accessibleNodes.concat(C.panoIndex).map(e=>Sv({panoIndex:e,workCode:C.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&&w!==null&&Sv({panoIndex:w.panoIndex,workCode:w.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:H(r/t,.1,.85)}o&&o===E&&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,l;if(i&&(l=this.works.getObserver(i.panoId),l||(l=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(Vc()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!l||!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 c.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Mc(i.mapSize),a=e+1,u=new c.Vector2().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),d=Math.floor(this.tileLevelForFov(this.camera.fov,u)),f=d>e?d:0;this.tiling.setObserver(l);let p={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:f,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},m=this.tiling.update(p),h={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:Rp(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},g=this.modelScene.parameter.refinedScreen;(m||h.pano!==(g==null?void 0:g.pano)||h.opacity!==(g==null?void 0:g.opacity))&&this.modelScene.parameter.set(`refinedScreen`,h)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),C&&C.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&C&&C.position.y-C.standingPosition.y>10){let e=H(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=y.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((l=this.modelScene.parameter.pano0Depth)==null?void 0:l.panoId)!==t.panoId||((u=this.modelScene.parameter.pano1Depth)==null?void 0:u.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new c.CubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new c.CubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1});let e=new c.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,VS(this.renderer,this.modelScene,e,500);let r=new c.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,VS(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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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=Sv(e),l=this.works.getObserver(e);if(!l)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let u=kc(l.images.up),d=this.imageOptions.size;d===void 0&&l&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=Object.assign({key:`pano.${s}`},Js(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),m={right:l.images.work.getURL(l.images.right),left:l.images.work.getURL(l.images.left),up:l.images.work.getURL(l.images.up),down:l.images.work.getURL(l.images.down),front:l.images.work.getURL(l.images.front),back:l.images.work.getURL(l.images.back)},h,g=``;l.images.hdrConfig&&(h={right:l.images.work.getURL(l.images.gainmap_right),left:l.images.work.getURL(l.images.gainmap_left),up:l.images.work.getURL(l.images.gainmap_up),down:l.images.work.getURL(l.images.gainmap_down),front:l.images.work.getURL(l.images.gainmap_front),back:l.images.work.getURL(l.images.gainmap_back)},g=l.images.work.getURL(l.images.hdrConfig));let _=`pano:`+bv([m,p,f]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===_)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:l.panoIndex,workCode:l.work.workCode}}))}}let v=`move-to-pano-`+s;this.pending.add(v);let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===_?b=y.pano0:y.pano1&&y.pano1.map.name===_&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?HS:a,panoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1,hdrConfig:b.hdrConfig?Object.assign({},b.hdrConfig):void 0},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,l),this.pendingTextureTask=void 0,Lc.shared.add(()=>{this.pending.delete(v),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:_,onLoad:(n,r)=>an(this,void 0,void 0,function*(){var i,a;let u=n.body;if(this.destroyed)u.dispose();else{u.name=_;let n=Array.isArray(u.image)?u.image[0]:u.image,d=(i=n==null?void 0:n.width)==null?2048:i,{data:f}=yield Tx(this.renderer,u,!0,My),p=new Iy().formPixels(f),m={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?HS:a,panoPicture:{panoId:s,map:u,mapSize:d,mapHistogram:new c.Vector4().fromArray(p.toArray()),matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1,hdrConfig:r},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};m.panoPicture&&this.panoPictureObserverMap.set(m.panoPicture,l),this.doMoveToPano(e,m,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),ox(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 x=this.panoMeshes.get(s);x&&x.tap&&x.tap();let S=[this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,l.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)===_&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];g&&S.push(fetch(g).then(e=>e.json()),this.textureLoader.loadCubeTexture(h,{imageURL:{transform:f,options:p},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,l.work)},void 0,void 0,void 0,this.renderer)),Promise.all(S).then(([t,n,r])=>{var i,a;this.pending.delete(v),((i=this.pendingTextureTask)==null?void 0:i.hash)===_?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},Wx(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(v),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&(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(K),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(K),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}),ox(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,l,u,d,f,p,m;let h=G(),g=Mt();this.panoResources[g]=t;let _,v,y;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;_=Math.max(a.distanceTo(o),1),v=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],y=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),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;_=c+Math.max(a.distanceTo(o),1),v=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/_,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(v);y=l===0||l===0?0:this.locationMotion.getProgressVelocity(h)*l/u}let b=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?_:0),x={longitude:n.longitude,latitude:n.latitude,fov:n.fov},S=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=x.longitude)==null?this.camera.pose.longitude:i,latitude:(a=x.latitude)==null?this.camera.pose.latitude:a,fov:(o=x.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),C=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(S),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(x,b).catch(K);else{let e=gi({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=gi({longitude:(s=x.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(l=x.latitude)==null?this.cameraMotion.value.latitude:l}),r=new c.Object3D;r.lookAt(e);let i=new c.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new c.Matrix4().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),h=this.cameraMotion.value.fov,g=(u=x.fov)==null?this.cameraMotion.value.fov:u,_=1;t.effect===`zoomin`?_=1.5:t.effect===`zoomout`&&(_=.4);let y=H(g*_,1,170);for(let e=0;e<v.length-1;e++){let t=v[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(y/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=x.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=x.latitude)==null?this.cameraMotion.value.latitude:f,fov:y}},{progress:1,value:{longitude:(p=x.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=x.latitude)==null?this.cameraMotion.value.latitude:m,fov:g}}],b).catch(K)}this.locationMotion.setKeyframes(v,b,y).then(()=>{for(let e of this.modelScene.children)e instanceof U_&&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:C,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=Mt(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=K,n.ontimeupdate=K,tS().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=K,e.ontimeupdate=K}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:C,progress:0,state:S,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 c.Raycaster(e.position.clone(),e.getWorldDirection(new c.Vector3)):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 c.Raycaster(r.ray.origin,new c.Vector3(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 c.Vector3(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,l=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}),u=new Map,d=l.slice().sort((e,t)=>{let n=s[e],r=u.get(n);r===void 0&&(r=WS.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),u.set(n,r));let a=s[t],o=u.get(a);return o===void 0&&(o=WS.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),u.set(a,o)),r-o});u.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of d){let n=s[t];if(n){let t=WS.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let f=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,WS);n&&(n.project(e),Math.abs(n.z)<=1&&(f=n.clone()))}else f=new c.Vector3(0,0,0);if(f){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=WS.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=WS.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=WS.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(f.x-t.x,2)+Math.pow(f.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 c.Vector3).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||WS.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[l]=this.modelScene.intersectRaycaster(n);if(l){let[e,n]=vf(s,e=>{let t=o[e];return t?WS.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(l.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===Sv(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=H(0,H(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),H(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=Sv({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}))}}}},JS=new c.Vector3(0,1.6,0),YS=new c.Box3,XS=new c.Vector3,ZS=Object.assign({},Zx),QS=class e extends Qx{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),l=s.works,{state:u,currentState:d}=e.initial,f=typeof u.panoIndex==`number`?{workCode:(r=(t=u.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:u.panoIndex}:{workCode:d.workCode,panoIndex:d.panoIndex},p=l.getObserver(f),m=H((i=u.fov)==null?!p||cx(d.mode)?d.fov:s.defaultFov:i,s.minFov,s.maxFov),h=(a=u.longitude)==null?d.longitude:a,g=H(typeof s.minLatitude==`function`?s.minLatitude(m):s.minLatitude,-Math.PI/2,Math.PI/2),_=H(typeof s.maxLatitude==`function`?s.maxLatitude(m):s.maxLatitude,-Math.PI/2,Math.PI/2),v=H((o=u.latitude)==null?!p||cx(d.mode)?d.latitude:s.defaultLatitude:o,g,_),y=new c.Vector3;if(s.initial.state.offset)y.copy(s.initial.state.offset);else if(p)y.copy(p.position).applyMatrix4(p.work.transform);else{let e=gi(d).setLength(d.distance);y.copy(s.initial.currentState.offset).sub(e)}return{workCode:f.workCode,panoIndex:f.panoIndex,mode:`Model`,longitude:h,latitude:v,fov:m,offset:y,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new J({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 J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({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(K),this.cameraMotion.set(i,t).catch(K)})}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(K),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(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new c.Vector3(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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=vf(n,e=>XS.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),lx(r)||this.modelScene.parameter.set(r),lx(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=H(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(K),this.modelAlphaMotion.set(s,i).catch(K),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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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 c.Vector3(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 c.Vector3().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=G(),s=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),l=s.distanceTo(e),u=this.locationMotion.getProgressVelocity(o),d=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;d+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let f=l===0?0:u*d/l,p=this.calculateMovingDuration(t.duration,l),m={x:e.x,y:e.y,z:e.z,distance:0},h={longitude:t.longitude,latitude:t.latitude,fov:t.fov},g=[];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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(s)))for(let t of e.observers)g.push(t)}let _=vf(g,e=>XS.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),v=_?{workCode:_.work.workCode,panoIndex:_.panoIndex}:{workCode:``,panoIndex:0},y=Object.assign(Object.assign({},v),{mode:this.mode,longitude:(r=h.longitude)==null?this.camera.pose.longitude:r,latitude:(i=h.latitude)==null?this.camera.pose.latitude:i,fov:(a=h.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),b=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(y),this.cameraMotion.set(h,p).catch(K),this.locationMotion.set(m,p,f).then(()=>{for(let e of this.modelScene.children)e instanceof U_&&e.show();let e=Object.assign(Object.assign(Object.assign({},v),{mode:this.mode}),ox(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:b,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:b,progress:0,state:y,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 c.Vector3(0,1,0).angleTo(e)>Math.PI/3){let r=new c.Raycaster;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new c.Vector3(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new c.Vector3().copy(n.point).add(JS),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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=vf(r,e=>XS.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=XS.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()}},$S=new c.Box3,eC=new c.Vector3,tC=.5,nC=Math.PI/7,rC={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new Vx},iC={Floorplan:Jx,Topview:Xx,Panorama:qS,Model:QS,Mapview:class e extends Dx{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?rC.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?rC.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?rC.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?rC.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?rC.minLatitude:o,cameraType:(s=t.cameraType)==null?rC.cameraType:s,cameraFence:(c=t.cameraFence)==null?rC.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?rC.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,l;let u=this.parseArgs(t),d=u.works,f=u.modelScene,{state:p,currentState:m}=t.initial,h=typeof p.panoIndex==`number`?{workCode:(i=(n=p.workCode)==null?(r=u.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:p.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},g=(a=p.fov)==null?60:a,_=H(typeof u.minLatitude==`function`?u.minLatitude(g):u.minLatitude,-Math.PI/2,Math.PI/2),v=H(typeof u.maxLatitude==`function`?u.maxLatitude(g):u.maxLatitude,-Math.PI/2,Math.PI/2),y=H((o=p.latitude)==null?sx(m.mode)?m.latitude:u.defaultLatitude:o,_,v),b=e.distanceFromModel(u.modelScene,g,u.camera.aspect),x=new c.Vector3,S=(s=p.distance)==null?Math.min(u.defaultDistance,b):s,C=(l=p.longitude)==null?sx(m.mode)?m.longitude:u.defaultLongitude:l;if(p.offset)x.copy(p.offset);else{let e=d.getObserver(h);u.defaultDistance<b&&e?(x.copy(e.position).applyMatrix4(e.work.transform),p.longitude===void 0&&(C=m.longitude)):(f.boundingBox.getCenter(x),S=b)}return Object.assign(Object.assign({},h),{mode:`Mapview`,longitude:C,latitude:y,fov:g,offset:x,distance:S})}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 J({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 J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new Yc,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 c.Box3&&e.cameraFence instanceof c.Box3||this.cameraFence instanceof c.Sphere&&e.cameraFence instanceof c.Sphere?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(K),(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(K),!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(K),this.cameraMotion.set(i,t).catch(K)})}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(K),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 c.Vector3(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(K),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),lx(n)||this.modelScene.parameter.set(n),lx(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=gi(this.camera.pose,new c.Vector3),t=new c.Vector3().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 c.Vector3),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(K)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=H(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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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 c.Vector3(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(K),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(K),this.cameraMotion.set(s,i).catch(K),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}),ox(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)&&($S.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),$S.containsPoint(e.ray.origin)||e.ray.intersectsBox($S)))for(let e of t.observers)n.push(e)}let[r,i]=vf(n,e=>eC.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 c.Vector2);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=hi(this.cameraMotion.value.longitude+a.longitude),l=H(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),u=H(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),d=H(this.cameraMotion.value.latitude+a.latitude,l,u),f=new c.Vector3(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),p=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:d,offset:f,fov:o,distance:this.locationMotion.value.distance}),m=e.state.offset.clone().sub(gi(e.state).setLength(p.distance)),h=!(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(m):!0)===!1&&(h=!0);let g=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:h,state:p}));if(this.inMomentumMovement.event=g,this.emit(`gesture.momentum`,g),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:d},0).catch(K),this.locationMotion.set({x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance},0).catch(K),h?this.inMomentumMovement=null:Lc.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=gi(e,new c.Vector3),n=new c.Vector3().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new c.Raycaster(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>tC+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 c.Plane(new c.Vector3(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new c.Vector3);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&&Xb(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 c.Vector3().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 c.Plane(new c.Vector3(0,1,0),0),t=n.ray.intersectPlane(e,new c.Vector3);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 c.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new c.Plane().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 c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=gi(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new c.Vector3().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new c.Vector2),s=2*t.x*a/o.y,l=2*t.y*a/o.y,u=new c.Vector3;u.setFromMatrixColumn(this.camera.matrix,0),u.multiplyScalar(-s),r.add(u),this.camera.pose.latitude<nC?u.setFromMatrixColumn(this.camera.matrix,1):(u.setFromMatrixColumn(this.camera.matrix,0),u.crossVectors(this.camera.up,u)),u.multiplyScalar(l),r.add(u);let d=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=d,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K),e.isFinal&&(this.fixFinalState(d),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:d.distance,x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K)),e.isFinal){let t=this.renderer.getSize(new c.Vector2),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new c.Vector3,o=new c.Vector3;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<nC?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:Mt()},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=hi(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=H(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=H(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=H(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(K):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(K),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:Mt()},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 c.Vector3),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=H(r/t.scale,tC,1/0),s=t.state.offset.clone().sub(gi(t.state).setLength(o)),l=this.modelScene.boundingBox.containsPoint(s),u;if(!l&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?u=t.state.distance:(u=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=u,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(K),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(K)}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 c.Vector3().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 c.Vector3(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(K)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=gi(this.cameraMotion.value,new c.Vector3).negate(),a=new c.Ray(r,i).intersectBox(this.modelScene.boundingBox,new c.Vector3);a&&(n+=a.distanceTo(r));let o=Math.max(this.locationMotion.value.distance-this.camera.near,0),s=t.center.delta/10*Math.max(o/5,.1);if(o<=n||s>0)if(this.locationMotion.value.distance-s>=tC){let e=this.locationMotion.value.distance-s;t.state.distance=e}else{let e=gi(this.cameraMotion.value);e.setLength(s),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(K)}}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 c.Vector3,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=Mt(),a=Sv({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,l=Object.assign({key:`pano.${a}`},Js(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),u=`pano:`+bv([o,l,s]),d=this.modelScene.parameter,f;if(d.pano0&&d.pano0.map.name===u?f=d.pano0:d.pano1&&d.pano1.map.name===u&&(f=d.pano1),f)d.pano0&&d.pano0.map!==f.map&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==f.map&&d.pano1.map!==((t=d.pano0)==null?void 0:t.map)&&d.pano1.map.dispose(),d.set({pano0:f,pano1:f}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,f=``;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)},f=r.images.work.getURL(r.images.hdrConfig));let p=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:l},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),m=f?[fetch(f).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:l},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([p,...m]).then(t=>an(this,[t],void 0,function*([t,o,s]){var l,f;let{body:p}=t;if(this.destroyed||this.pendingTextureId!==e){p.dispose();return}this.pendingTextureId=null,p.name=u;let m=Array.isArray(p.image)?p.image[0]:p.image,h=(l=m==null?void 0:m.width)==null?2048:l,g=yield Tx(this.renderer,p,!0,My),_=new Iy().formPixels(g.data),v={panoId:a,map:p,mapSize:h,mapHistogram:new c.Vector4().fromArray(_.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},Wx(o)):void 0};d.pano0&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==((f=d.pano0)==null?void 0:f.map)&&d.pano1.map.dispose(),d.set({pano0:v,pano1:v}),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(K),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},aC={Floorplan:qx,Topview:Yx,Panorama:KS,Model:ZS,Mapview:rC},oC=`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 sC(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=gi(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 cC(){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 lC(){let e=new c.Group;e.name=`internalLights`;{let t=new c.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new c.Vector3(0,1,0)),e.add(t)}{let t=new c.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new c.Vector3(-1,-1,-1)),e.add(t)}{let t=new c.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new c.Vector3(1,1,1)),e.add(t)}{let t=new c.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function uC(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 dC(){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=uC((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var fC=1e3,pC=90,mC=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/`),hC=new c.Sphere,gC=new c.Box3,_C=new c.Vector4,vC=new c.Vector4,yC=new c.Color,bC=new c.Vector2,xC=new WeakMap,SC=fy([ly(null)]),CC={},wC=class e extends Lt{static get version(){return`1.0.0-alpha.1`}static get dracoPath(){return Ru.decoderPath}static set dracoPath(e){Ru.setDecoderPath(e)}static get ktx2Path(){return Ku.transcoderPath}static set ktx2Path(e){Ku.setTranscoderPath(e)}static get useNativeImageBitmap(){return Vc()}static set useNativeImageBitmap(e){Bc(e)}constructor(e={}){var t,n,r,i,a,o,s,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Mt(),CC[this.fiveId]=this,this.currentUpdateArgs={time:G(),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 c.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview)},this.fps={testCount:0,testTime:G()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?fC:s,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof xb&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new xb({outputType:e.enableHDR?c.HalfFloatType:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=dC();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new c.RenderTarget(1,1,{colorSpace:(d=(u=this.renderer)==null?void 0:u.outputColorSpace)==null?c.SRGBColorSpace:d,generateMipmaps:!1}),this.renderer&&ks(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new ki(pC),this.scene=new Db,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new c.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(f=e.requestProxy)==null?mC:f,this.networkSubscribe=new Vs,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 c.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),xC.set(this,SC),this.modelScene=new ev({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(SC,{forceReplaceImmediately:!0});Z(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new c.VideoTexture(e.videoInstance||cC());let m=lC();this.scene.add(m),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=Lc.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,h,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,h,!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)}}}sC(this),this.fiveRenderer=new vb({outputType:e.enableHDR?c.HalfFloatType:void 0}),this.adaptiveLuminancePass=new Qy,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new eb(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new kr,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([lc().catch(K)]).then(K)}dispose(){var e;if(this.destroyed===!0)return;delete CC[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(),xC.set(this,SC),this.renderer&&(!(this.renderer instanceof xb)||this.renderer.isInitialized)&&this.renderer.render(new c.Scene,new c.Camera),this.fiveRenderer.dispose(),this.renderer instanceof xb&&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,Xs(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,Xs(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,Xs(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,Xs(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,Xs(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 xb)){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=dC(),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=G(),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 xC.get(this)||SC}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(()=>$b(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,l,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===SC&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof cy?v.push(e):typeof e!=`string`&&`work`in e?v.push(ly(e.work,e)):v.push(ly(e));else t instanceof cy?v.push(t):v.push(ly(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=fy(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===SC&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(l=x.offset)==null?void 0:l.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new c.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;w===`Panorama`&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,$(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=iC[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=iC[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:b,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)};xC.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),ax(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),xC.set(this,SC),this.modelScene.setModels(SC,{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:pC,longitude:0,latitude:0,offset:new c.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if(t===e.Mode.Panorama&&!this.works.getObserver(m)){let e=Error(`PanoId ${Sv(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?!wv(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(wv(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=iC[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=Lc.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),Lc.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return an(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=G(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new c.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?l:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&this.controller instanceof iC.Panorama&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=this.renderer.getClearColor(yC),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);let F=yield this.renderer.readRenderTargetPixelsAsync(C,0,0,M,N),te=M*4;if(F.length===P)b.set(F);else{let e=Math.ceil(te/256)*256;for(let t=0;t<N;t++){let n=t*e;b.set(F.subarray(n,n+te),t*te)}}if(!_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b})}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=t.getClearColor(yC),c=t.getClearAlpha(),l=t.getViewport(_C),u=t.getScissor(vC),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(bC),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&&Lc.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&Ku.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),Lc.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&Lc.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){gC.makeEmpty(),gC.expandByObject(this.modelScene.boundingMesh);let t=gC.getBoundingSphere(hC),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=H(n/500,.001,.1),i=H(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 xb&&!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 xb&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=K){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],i=G();return Promise.all(r.map(e=>{let t=Sv({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},Js(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Ec(i,r);return w_(this.fiveId,n.work).preload(a)})).then(()=>{let e=G()-i;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new c.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new c.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new c.Vector2(o,s)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,i,a,o,s,l,u,d,f,p;e=Js(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof c.Vector3)&&(e.offset=new c.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof c.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),r=iC[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,$(`state.set`,{userAction:n,state:x})),ix(this.state,x)||(rx(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(G(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(G(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state))}syncState(t,n,r=!1){let i=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof iC.Model){if(Qb(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(!wv(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 iC.Floorplan||this.controller instanceof iC.Topview||this.controller instanceof iC.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:zy(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:zy(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),l=s>e*15?s/15:e,u=r?new c.Vector3().copy(this.state.offset):By(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Vy({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(Xb(n,this.camera.pose.fov)||Qb(u,this.camera.pose.offset)||Xb(o,this.camera.pose.distance)||Xb(d,this.camera.pose.longitude,Math.PI*2)||Xb(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:zy(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Vy({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new c.Vector3().copy(this.state.offset);if(Xb(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),Qb(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),Xb(n,this.camera.pose.longitude,Math.PI*2)||Xb(i,this.camera.pose.latitude)||Xb(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`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 iC.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(K)}requestFullscreen(){var e;if(!nx)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=()=>{Lc.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 Ks({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=qv(e,r);return t instanceof Error?Promise.reject(t):t})}});T_(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=iC[e];this.currentMode=e;let r=new n(t);for(let e of oC)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=iC[e].initAnimationEndState(t),r=t.initial.userAction;ix(this.state,n)||(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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 c.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new c.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().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}};wC.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:c,constructor:wC,instances:CC}}),exports.AdaptiveLuminancePass=Qy,exports.AnimationFrameLoop=Lc,exports.BoundingMesh=Q_,exports.Camera=ki,exports.EffectComposer=my,exports.EyeDomeLightingPass=eb,exports.Fetcher=Ks,exports.Five=wC,exports.FivePass=gy,exports.FiveRenderer=vb,exports.FlowingFireworks3DPass=ub,exports.FlowingLight2DPass=ib,exports.FlowingLight3DPass=nb,exports.FullScreenQuad=hy,exports.GaussianBlurPass=tb,exports.Histogram=Iy,exports.InternalWebGPURenderer=xb,exports.Model=U_,exports.ModelScene=ev,exports.Motion=J,exports.NetworkSubscribe=Vs,exports.PBMGSObject=At,exports.PBMGaussianSplattingObject=At,exports.PBMGaussianSplattingNodeMaterial=Dr,exports.PBMGaussianSplattingRenderMesh=kr,exports.PBMGroup=Ct,exports.PBMMesh=Ot,exports.PBMMeshBasicMaterial=Ar,exports.PBMMeshBasicNodeMaterial=bs,exports.PBMMeshPanoOnlyMaterial=jr,exports.PBMMeshPanoOnlyNodeMaterial=Es,exports.PBMMeshPhongMaterial=Mr,exports.PBMMeshPhongNodeMaterial=Ss,exports.PBMMeshPhysicalMaterial=Nr,exports.PBMMeshPhysicalNodeMaterial=ws,exports.PBMPanoFilter=zt,exports.PBMPointCloud=nn,exports.PBMSkinnedMesh=kt,exports.PBMUpdateable=Rt,exports.PROXY_CONTROLLER_EVENT_NAMES=oC,exports.PanoCircleMesh=Fb,exports.PanoCircleMeshCustom=Jb,exports.PanoCircleMeshSolid=Ub,exports.Parameter=X,exports.Scene=Db,exports.Subscribe=Lt,exports.TextureLoader=Yc,exports.Tile=gf,exports.Tile3D=S_,exports.Tile3DModel=S_,exports.TileCache=em,exports.TileNode=Up,exports.TileRequestScheduler=Zp,exports.Tileset=om,exports.Trajectory=qp,exports.TrajectoryNode=Jp,exports.Work=cy,exports.WorkResolvedObserver=dy,exports.controllersDefaultInitArgs=aC,exports.coordinatesToVector=gi,exports.createDebugBoundingMesh=df,exports.createWorks=fy,exports.defaultImageURLTransform=Ec,exports.draco=Ru,exports.getViewportScale=dC,exports.headingToLongitude=yi,exports.imageSupport=lc,exports.isBoundingVolume=of,exports.isPanoId=Tv,exports.loadAt3d=Il,exports.loadDome=Bl,exports.loadDomez=ql,exports.loadGltf=Rd,exports.loadPbm=ml,exports.loadPly=Zl,exports.longitudeToHeading=vi,exports.makeBoundingVolume=sf,exports.panoEqual=wv,exports.panoParse=Cv,exports.panoStringify=Sv,exports.parseWork=ly,exports.registerPBMMaterials=ks,exports.vectorToCoordinates=_i,exports.workToJson=av;
|
|
1179
|
+
`,uniforms:{maxDepth:new c.Uniform(0)}});function VS(e,t,n,r=1e3){BS.uniforms.maxDepth.value=r,e.getClearColor(zS);let i=e.getClearAlpha(),a=t.overrideMaterial;t.overrideMaterial=BS,e.setClearColor(RS,0),n.update(e,t),e.setClearColor(zS,i),t.overrideMaterial=a}var HS=Ip,US=new c.Raycaster,WS=new c.Vector3,GS=[new c.Vector3(0,0,0).multiplyScalar(.1),new c.Vector3(1,0,0).multiplyScalar(.1),new c.Vector3(-.5,0,-Math.sqrt(3)/2).multiplyScalar(.1),new c.Vector3(-.5,0,Math.sqrt(3)/2).multiplyScalar(.1)],KS=Object.assign(Object.assign({},Zx),{maxAccessibleDistance:5,panoTapTriggerRadius:.5,panoCircleMeshCreator:(e,t)=>e.position.distanceTo(e.standingPosition)>t.aerialObserverMinHeight?new Ub:new Fb,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}),qS=class e extends Qx{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?KS.maxAccessibleDistance:n,panoTapTriggerRadius:(r=t.panoTapTriggerRadius)==null?KS.panoTapTriggerRadius:r,panoCircleMeshCreator:(i=t.panoCircleMeshCreator)==null?KS.panoCircleMeshCreator:i,adjustPanoCircleMeshPositionBasedOnModel:(a=t.adjustPanoCircleMeshPositionBasedOnModel)==null?KS.adjustPanoCircleMeshPositionBasedOnModel:a,tileLevelForFov:(o=t.tileLevelForFov)==null?KS.tileLevelForFov:o,tileAppearDuration:(s=t.tileAppearDuration)==null?KS.tileAppearDuration:s,tileMaxRequest:(c=t.tileMaxRequest)==null?KS.tileMaxRequest:c,flyEffectUseDepthBuffer:(l=t.flyEffectUseDepthBuffer)==null?KS.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 J({count:0,distance:this.camera.pose.distance}),this.modelAlphaMotion=new J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Mt()]={panoId:Sv(this.currentPano),panoPicture:this.modelScene.parameter.resolveValue().pano1,position:this.camera.pose.offset.clone(),effect:`fly`,effectEasing:HS,fixCameraTransform:new c.Matrix4},this.panoPictureObserverMap=new WeakMap,this.textureLoader=new Yc,this.tiling=new MS({fiveId:this.fiveId}),this.panoVideo=new LS,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=K,e.ontimeupdate=K,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,l,u;if(this.destroyed)return;let d={},f={},p=this.camera.getDirection(new c.Vector3),m=this.locationMotion.keyframes[0],h=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[g,_]=this.locationMotion.getKeyFrameSegment(e),v=this.panoResourceFromLocationMotionKeyframe(g),y=this.panoResourceFromLocationMotionKeyframe(_),b=this.panoResourceFromLocationMotionKeyframe(m),x=this.panoResourceFromLocationMotionKeyframe(h),S=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),f.longitude=this.cameraMotion.value.longitude,f.latitude=this.cameraMotion.value.latitude,f.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),d.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let t=this.locationMotion.value.count-_.value.count+1,n=new c.Vector3().copy(v.position),a=new c.Vector3().copy(y.position);if(d.progress=y.effectEasing(t),t>=.01&&t<=.99&&(d.progress=H(y.effectEasing(t),.01,.99)),y.panoPicture&&(t<1?v.panoPicture&&(d.pano0=v.panoPicture):d.pano0=y.panoPicture,d.pano1=y.panoPicture),y.effect===`montage`?d.transition=`BLACK`:y.effect===`spread`?d.transition=`SPREAD`:d.transition=`FADE`,y.effect===`zoomin`||y.effect===`zoomout`?d.progress=Math.pow(t,3):y.effect===`model`&&this.camera.pose.distance<.01&&(d.modelAlpha=1-Math.pow(H(Math.abs(t-.5)*2,0,1),4)),t<1&&y.effect!==`fly`&&y.effect!==`model`){if(d.pano0&&v.panoPicture){let e={panoId:d.pano0.panoId,map:d.pano0.map,mapHistogram:d.pano0.mapHistogram,mapSize:d.pano0.mapSize,zoom:d.pano0.zoom,matrix:v.panoPicture.matrix.clone().premultiply(v.fixCameraTransform).setPosition(y.position),hdrConfig:d.pano0.hdrConfig?Object.assign({},d.pano0.hdrConfig):void 0},t=this.panoPictureObserverMap.get(d.pano0);t&&this.panoPictureObserverMap.set(e,t),d.pano0=e}n.copy(a),S=!0}f.distance=this.locationMotion.value.distance,f.offset=new c.Vector3(n.x+(a.x-n.x)*t,n.y+(a.y-n.y)*t,n.z+(a.z-n.z)*t);let o=[],s=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(o.push(t),n>this.locationMotion.progress&&s.push(t))}for(let e of Object.keys(this.panoResources)){if(s.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.panoPicture){let e=t.panoPicture.map;if(e){if(e===((r=d.pano0)==null?void 0:r.map)||e===((i=d.pano1)==null?void 0:i.map))continue;e.dispose(),t.panoPicture=null}}o.indexOf(e)>=0||delete this.panoResources[e]}let l=Cv(y.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,$(`pano.moving`,{userAction:this.userAction,prevPano:Cv(b.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Cv(x.panoId)),{mode:this.mode}),ox(this.camera.pose)),f),options:{},progress:this.locationMotion.progress,error:null}))}lx(d)===!1&&this.modelScene.parameter.set(d),!this.modelScene.parameter.pano0&&this.modelScene.parameter.pano1&&this.modelScene.parameter.set(`pano0`,this.modelScene.parameter.pano1),lx(f)===!1&&this.setCamera(f);let C=this.works.getObserver(this.currentPano),w=this.locationMotion.ended?this.getForwardObserverOrNot(this.camera):null,T=this.works.getObserver(v.panoId),E=this.works.getObserver(y.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&C){let e=[],t=C.work.observers;for(let n of C.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(C.standingPosition),n.set(e,r));let i=n.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(C.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=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode}),o=GS.map(t=>{US.ray.origin.copy(i),US.ray.origin.add(WS.copy(t).setY(e)),US.ray.direction.set(0,-1,0),US.firstHitOnly=!0,US.floorIndex=-1;let[a]=n.intersectRaycaster(US);return a&&a.distance-r<=e?new c.Vector3().copy(i).setY(a.point.y+r):i});o.sort((e,t)=>t.y-e.y);let s=o[Math.floor(o.length/2)],[l]=o.filter(e=>e.distanceTo(s)<=.05);if(l){let e=new c.Vector4(i.x,i.y,i.z,l.y-i.y),t=this.adjustPanoCircleMeshPositionFix.get(a);t&&!e.equals(t)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(a,e)}}this.accessibleObserverFloorCheckCount++}}let D=new Map;if(T)for(let e of T.accessibleNodes){let t=T.work.observers[e];if(t){let e=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(E)for(let e of E.accessibleNodes){let t=E.work.observers[e];if(t){let e=Sv({panoIndex:t.panoIndex,workCode:t.work.workCode});D.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{D.get(t)?D.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),D.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),D.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&&(WS.set(t.x,t.y,t.z),WS.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let i=this.camera.position.clone().setY(e.position.y),a=new c.Vector3().copy(e.position).sub(i).normalize();if(t===Sv(this.currentPano)){let t=H((.5-i.distanceTo(e.position))/.5,0,1);a.multiplyScalar(1-t).add(p.clone().multiplyScalar(t))}if(a.length()>0){let t=r?-Math.PI/2:0,n=Math.atan2(a.x,a.z);e.quaternion.setFromEuler(new c.Euler(t,n,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||S)this.panoMeshes.forEach(n=>{n.setOpacity(0),n.setCurrent(!1),n.updateTime&&n.updateTime(e,t),n.visible=!1});else if(C){let n=C.work.observers,[,r]=vf(C.accessibleNodes,e=>{let t=n[e];return!t||!t.active?1/0:C.standingPosition.distanceTo(t.standingPosition)},!0);r=H(r,3,1/0);let i=C.accessibleNodes.concat(C.panoIndex).map(e=>Sv({panoIndex:e,workCode:C.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&&w!==null&&Sv({panoIndex:w.panoIndex,workCode:w.work.workCode})===a;let t=n.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=t<.01?0:H(r/t,.1,.85)}o&&o===E&&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,l;if(i&&(l=this.works.getObserver(i.panoId),l||(l=this.panoPictureObserverMap.get(i))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(Vc()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!l||!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 c.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Mc(i.mapSize),a=e+1,u=new c.Vector2().copy(this.camera.resolution).multiplyScalar(this.camera.pixelRatio),d=Math.floor(this.tileLevelForFov(this.camera.fov,u)),f=d>e?d:0;this.tiling.setObserver(l);let p={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:f,useHDR:this.modelScene.parameter.useHDR,maxDisplayBoost:this.modelScene.parameter.maxDisplayBoost,hdrConfig:i.hdrConfig?Object.assign({},i.hdrConfig):void 0},m=this.tiling.update(p),h={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:Rp(Math.abs(((s=this.modelScene.parameter.progress)==null?0:s)-.5)*2)},g=this.modelScene.parameter.refinedScreen;(m||h.pano!==(g==null?void 0:g.pano)||h.opacity!==(g==null?void 0:g.opacity))&&this.modelScene.parameter.set(`refinedScreen`,h)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),C&&C.images.video&&(this.needsRender=!0),this.intersectMesh&&this.intersectMesh.parent&&C&&C.position.y-C.standingPosition.y>10){let e=H(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=y.effect,{pano0:t,pano1:n}=this.modelScene.parameter;if(t&&n&&t!==n&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((l=this.modelScene.parameter.pano0Depth)==null?void 0:l.panoId)!==t.panoId||((u=this.modelScene.parameter.pano1Depth)==null?void 0:u.panoId)!==n.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new c.CubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new c.CubeRenderTarget(512,{minFilter:c.NearestFilter,magFilter:c.NearestFilter,generateMipmaps:!1});let e=new c.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(t.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,VS(this.renderer,this.modelScene,e,500);let r=new c.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);r.matrix.copy(n.matrix),r.matrixWorld.copy(r.matrix),r.matrixAutoUpdate=!1,VS(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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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=Sv(e),l=this.works.getObserver(e);if(!l)throw Error(`Invalid PanoId ${JSON.stringify(e)}`);let u=kc(l.images.up),d=this.imageOptions.size;d===void 0&&l&&u&&(d=Number(u)),d===void 0&&(d=2048);let f=this.imageOptions.transform,p=Object.assign({key:`pano.${s}`},Js(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),m={right:l.images.work.getURL(l.images.right),left:l.images.work.getURL(l.images.left),up:l.images.work.getURL(l.images.up),down:l.images.work.getURL(l.images.down),front:l.images.work.getURL(l.images.front),back:l.images.work.getURL(l.images.back)},h,g=``;l.images.hdrConfig&&(h={right:l.images.work.getURL(l.images.gainmap_right),left:l.images.work.getURL(l.images.gainmap_left),up:l.images.work.getURL(l.images.gainmap_up),down:l.images.work.getURL(l.images.gainmap_down),front:l.images.work.getURL(l.images.gainmap_front),back:l.images.work.getURL(l.images.gainmap_back)},g=l.images.work.getURL(l.images.hdrConfig));let _=`pano:`+bv([m,p,f]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===_)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:l.panoIndex,workCode:l.work.workCode}}))}}let v=`move-to-pano-`+s;this.pending.add(v);let y=this.modelScene.parameter,b;if(y.pano0&&y.pano0.map.name===_?b=y.pano0:y.pano1&&y.pano1.map.name===_&&(b=y.pano1),b){let n={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?HS:a,panoPicture:{panoId:b.panoId,map:b.map,mapHistogram:b.mapHistogram,mapSize:b.mapSize,matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1,hdrConfig:b.hdrConfig?Object.assign({},b.hdrConfig):void 0},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};n.panoPicture&&this.panoPictureObserverMap.set(n.panoPicture,l),this.pendingTextureTask=void 0,Lc.shared.add(()=>{this.pending.delete(v),this.doMoveToPano(e,n,t)},!0,1);return}this.pendingTextureTask={panoId:s,hash:_,onLoad:(n,r)=>an(this,void 0,void 0,function*(){var i,a;let u=n.body;if(this.destroyed)u.dispose();else{u.name=_;let n=Array.isArray(u.image)?u.image[0]:u.image,d=(i=n==null?void 0:n.width)==null?2048:i,{data:f}=yield Tx(this.renderer,u,!0,My),p=new Iy().formPixels(f),m={panoId:s,effect:o,effectEasing:(a=t.effectEasing)==null?HS:a,panoPicture:{panoId:s,map:u,mapSize:d,mapHistogram:new c.Vector4().fromArray(p.toArray()),matrix:l.matrix.clone().premultiply(l.work.transform),zoom:1,hdrConfig:r},position:l.position.clone().applyMatrix4(l.work.transform),fixCameraTransform:new c.Matrix4};m.panoPicture&&this.panoPictureObserverMap.set(m.panoPicture,l),this.doMoveToPano(e,m,t)}}),onError:n=>{let r=Object.assign(Object.assign(Object.assign({},e),{mode:this.mode}),ox(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 x=this.panoMeshes.get(s);x&&x.tap&&x.tap();let S=[this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,l.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)===_&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)];g&&S.push(fetch(g).then(e=>e.json()),this.textureLoader.loadCubeTexture(h,{imageURL:{transform:f,options:p},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,l.work)},void 0,void 0,void 0,this.renderer)),Promise.all(S).then(([t,n,r])=>{var i,a;this.pending.delete(v),((i=this.pendingTextureTask)==null?void 0:i.hash)===_?(this.pendingTextureTask.onLoad(t,n&&Object.assign({map:r.body},Wx(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(v),((n=this.pendingTextureTask)==null?void 0:n.hash)===_&&(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(K),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(K),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}),ox(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,l,u,d,f,p,m;let h=G(),g=Mt();this.panoResources[g]=t;let _,v,y;if(this.locationMotion.ended){let[e,n]=this.locationMotion.getKeyFrameSegment(h),i=this.locationMotion.value,a=((r=this.panoResourceFromLocationMotionKeyframe(n))==null?this.camera:r).position,o=t.position;_=Math.max(a.distanceTo(o),1),v=[{key:n.key,progress:0,value:Object.assign(Object.assign({},i),{count:0})},{key:g,progress:1,value:{distance:0,count:1}}],y=0}else{let[e,n]=this.locationMotion.getKeyFrameSegment(h),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;_=c+Math.max(a.distanceTo(o),1),v=[{key:e.key,progress:0,value:Object.assign({},r)},{key:n.key,progress:c/_,value:n.value},{key:g,progress:1,value:{count:n.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(v);y=l===0||l===0?0:this.locationMotion.getProgressVelocity(h)*l/u}let b=t.effect===`instant`?0:this.calculateMovingDuration(n.duration,t.effect===`fly`||t.effect===`model`?_:0),x={longitude:n.longitude,latitude:n.latitude,fov:n.fov},S=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=x.longitude)==null?this.camera.pose.longitude:i,latitude:(a=x.latitude)==null?this.camera.pose.latitude:a,fov:(o=x.fov)==null?this.camera.pose.fov:o,offset:t.position.clone(),distance:this.camera.pose.distance}),C=this.currentPano;if(this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:n,prevPano:C,progress:0,state:S,userAction:this.userAction,error:null})),n.moveStartCallback&&n.moveStartCallback(S),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute(`src`)&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute(`uuid`),this.videoTexture.image.removeAttribute(`src`),this.videoTexture.image.oncanplay=K,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),t.effect===`fly`||t.effect===`model`)this.cameraMotion.set(x,b).catch(K);else{let e=gi({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),n=gi({longitude:(s=x.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(l=x.latitude)==null?this.cameraMotion.value.latitude:l}),r=new c.Object3D;r.lookAt(e);let i=new c.Matrix4().makeRotationFromQuaternion(r.quaternion);r.lookAt(n);let a=new c.Matrix4().makeRotationFromQuaternion(r.quaternion),o=i.clone().invert().premultiply(a),h=this.cameraMotion.value.fov,g=(u=x.fov)==null?this.cameraMotion.value.fov:u,_=1;t.effect===`zoomin`?_=1.5:t.effect===`zoomout`&&(_=.4);let y=H(g*_,1,170);for(let e=0;e<v.length-1;e++){let t=v[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(o),e.panoPicture&&(e.panoPicture.zoom=Math.tan(y/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(d=x.longitude)==null?this.cameraMotion.value.longitude:d,latitude:(f=x.latitude)==null?this.cameraMotion.value.latitude:f,fov:y}},{progress:1,value:{longitude:(p=x.longitude)==null?this.cameraMotion.value.longitude:p,latitude:(m=x.latitude)==null?this.cameraMotion.value.latitude:m,fov:g}}],b).catch(K)}this.locationMotion.setKeyframes(v,b,y).then(()=>{for(let e of this.modelScene.children)e instanceof U_&&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:C,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=Mt(),n=this.videoTexture.image;n.setAttribute(`uuid`,t),n.oncanplay=K,n.ontimeupdate=K,tS().then(i=>{i&&r.images.video&&n.getAttribute(`uuid`)===t&&(n.oncanplay=()=>{n.oncanplay=K,n.play()},n.ontimeupdate=()=>{n.currentTime>.5&&(n.ontimeupdate=K,this.panoVideo.setMaterial(e))},n.src=r.images.video.source)}).catch((()=>{n.removeAttribute(`uuid`)}))}else{let e=this.videoTexture.image;e.removeAttribute(`uuid`),e.oncanplay=K,e.ontimeupdate=K}},()=>{this.emit(`pano.cancel`,$(`pano.cancel`,{options:n,prevPano:C,progress:0,state:S,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 c.Raycaster(e.position.clone(),e.getWorldDirection(new c.Vector3)):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 c.Raycaster(r.ray.origin,new c.Vector3(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 c.Vector3(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,l=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}),u=new Map,d=l.slice().sort((e,t)=>{let n=s[e],r=u.get(n);r===void 0&&(r=WS.copy(n.standingPosition).applyMatrix4(n.work.transform).distanceTo(i),u.set(n,r));let a=s[t],o=u.get(a);return o===void 0&&(o=WS.copy(a.standingPosition).applyMatrix4(a.work.transform).distanceTo(i),u.set(a,o)),r-o});u.clear();for(let e of[Math.PI/8,Math.PI/6,Math.PI/4,Math.PI/3])for(let t of d){let n=s[t];if(n){let t=WS.copy(n.standingPosition).applyMatrix4(n.work.transform).sub(i);if(t&&t.length()!==0&&o.angleTo(t)<e)return n}}let f=null;if(t){let n=t.ray.intersectBox(this.modelScene.boundingBox,WS);n&&(n.project(e),Math.abs(n.z)<=1&&(f=n.clone()))}else f=new c.Vector3(0,0,0);if(f){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=WS.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=WS.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=WS.copy(n.position).applyMatrix4(n.work.transform);if(t.project(e),Math.abs(t.z)>1)continue;if(Math.pow(f.x-t.x,2)+Math.pow(f.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 c.Vector3).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||WS.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[l]=this.modelScene.intersectRaycaster(n);if(l){let[e,n]=vf(s,e=>{let t=o[e];return t?WS.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(l.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===Sv(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=H(0,H(typeof this.minLatitude==`function`?this.minLatitude(n):this.minLatitude,-Math.PI/2,Math.PI/2),H(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=Sv({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}))}}}},JS=new c.Vector3(0,1.6,0),YS=new c.Box3,XS=new c.Vector3,ZS=Object.assign({},Zx),QS=class e extends Qx{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),l=s.works,{state:u,currentState:d}=e.initial,f=typeof u.panoIndex==`number`?{workCode:(r=(t=u.workCode)==null?(n=s.works[0])==null?void 0:n.workCode:t)==null?``:r,panoIndex:u.panoIndex}:{workCode:d.workCode,panoIndex:d.panoIndex},p=l.getObserver(f),m=H((i=u.fov)==null?!p||cx(d.mode)?d.fov:s.defaultFov:i,s.minFov,s.maxFov),h=(a=u.longitude)==null?d.longitude:a,g=H(typeof s.minLatitude==`function`?s.minLatitude(m):s.minLatitude,-Math.PI/2,Math.PI/2),_=H(typeof s.maxLatitude==`function`?s.maxLatitude(m):s.maxLatitude,-Math.PI/2,Math.PI/2),v=H((o=u.latitude)==null?!p||cx(d.mode)?d.latitude:s.defaultLatitude:o,g,_),y=new c.Vector3;if(s.initial.state.offset)y.copy(s.initial.state.offset);else if(p)y.copy(p.position).applyMatrix4(p.work.transform);else{let e=gi(d).setLength(d.distance);y.copy(s.initial.currentState.offset).sub(e)}return{workCode:f.workCode,panoIndex:f.panoIndex,mode:`Model`,longitude:h,latitude:v,fov:m,offset:y,distance:0}}constructor(t){let n=e.parseArgs(t);super(n),this.mode=`Model`,this.locationMotion=new J({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 J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({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(K),this.cameraMotion.set(i,t).catch(K)})}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(K),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(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),!this.locationMotion.ended){this.locationMotion.update(e),i.distance=this.locationMotion.value.distance,i.offset=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z);let t=new c.Vector3(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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(t)))for(let t of e.observers)n.push(t)}let r=vf(n,e=>XS.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),lx(r)||this.modelScene.parameter.set(r),lx(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=H(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(K),this.modelAlphaMotion.set(s,i).catch(K),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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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 c.Vector3(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 c.Vector3().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=G(),s=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),l=s.distanceTo(e),u=this.locationMotion.getProgressVelocity(o),d=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;d+=Math.sqrt(Math.pow(i-t,2)+Math.pow(a-n,2)+Math.pow(o-r,2))}let f=l===0?0:u*d/l,p=this.calculateMovingDuration(t.duration,l),m={x:e.x,y:e.y,z:e.z,distance:0},h={longitude:t.longitude,latitude:t.latitude,fov:t.fov},g=[];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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(s)))for(let t of e.observers)g.push(t)}let _=vf(g,e=>XS.copy(e.position).applyMatrix4(e.work.transform).distanceTo(s)),v=_?{workCode:_.work.workCode,panoIndex:_.panoIndex}:{workCode:``,panoIndex:0},y=Object.assign(Object.assign({},v),{mode:this.mode,longitude:(r=h.longitude)==null?this.camera.pose.longitude:r,latitude:(i=h.latitude)==null?this.camera.pose.latitude:i,fov:(a=h.fov)==null?this.camera.pose.fov:a,offset:e.clone(),distance:0}),b=this.currentPano;this.emit(`pano.moveTo`,$(`pano.moveTo`,{options:t,prevPano:b,progress:0,state:y,userAction:this.userAction,error:null})),t.moveStartCallback&&t.moveStartCallback(y),this.cameraMotion.set(h,p).catch(K),this.locationMotion.set(m,p,f).then(()=>{for(let e of this.modelScene.children)e instanceof U_&&e.show();let e=Object.assign(Object.assign(Object.assign({},v),{mode:this.mode}),ox(this.camera.pose));this.emit(`pano.arrived`,$(`pano.arrived`,{options:t,prevPano:b,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:b,progress:0,state:y,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 c.Vector3(0,1,0).angleTo(e)>Math.PI/3){let r=new c.Raycaster;r.firstHitOnly=!0;let i=e.clone().setLength(.3).add(t);r.set(i,new c.Vector3(0,-1,0)),n=this.modelScene.intersectRaycaster(r)[0]}}if(n){let t=new c.Vector3().copy(n.point).add(JS),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)&&(YS.copy(e.observerBox).expandByScalar(10).applyMatrix4(e.transform),YS.containsPoint(t)))for(let t of e.observers)r.push(t)}let[i,a]=vf(r,e=>XS.copy(e.position).applyMatrix4(e.work.transform).distanceTo(t),!0);i&&a<5&&(t.y=XS.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()}},$S=new c.Box3,eC=new c.Vector3,tC=.5,nC=Math.PI/7,rC={defaultLongitude:Math.PI/4,defaultLatitude:Math.PI/4,defaultDistance:150,maxLatitude:Math.PI/2,minLatitude:0,cameraType:`auto`,cameraFence:null,intersectMeshCreator:()=>new Vx},iC={Floorplan:Jx,Topview:Xx,Panorama:qS,Model:QS,Mapview:class e extends Dx{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?rC.defaultLongitude:n,defaultLatitude:(r=t.defaultLatitude)==null?rC.defaultLatitude:r,defaultDistance:(i=t.defaultDistance)==null?rC.defaultDistance:i,maxLatitude:(a=t.maxLatitude)==null?rC.maxLatitude:a,minLatitude:(o=t.minLatitude)==null?rC.minLatitude:o,cameraType:(s=t.cameraType)==null?rC.cameraType:s,cameraFence:(c=t.cameraFence)==null?rC.cameraFence:c,intersectMeshCreator:(l=t.intersectMeshCreator)==null?rC.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,l;let u=this.parseArgs(t),d=u.works,f=u.modelScene,{state:p,currentState:m}=t.initial,h=typeof p.panoIndex==`number`?{workCode:(i=(n=p.workCode)==null?(r=u.works[0])==null?void 0:r.workCode:n)==null?``:i,panoIndex:p.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},g=(a=p.fov)==null?60:a,_=H(typeof u.minLatitude==`function`?u.minLatitude(g):u.minLatitude,-Math.PI/2,Math.PI/2),v=H(typeof u.maxLatitude==`function`?u.maxLatitude(g):u.maxLatitude,-Math.PI/2,Math.PI/2),y=H((o=p.latitude)==null?sx(m.mode)?m.latitude:u.defaultLatitude:o,_,v),b=e.distanceFromModel(u.modelScene,g,u.camera.aspect),x=new c.Vector3,S=(s=p.distance)==null?Math.min(u.defaultDistance,b):s,C=(l=p.longitude)==null?sx(m.mode)?m.longitude:u.defaultLongitude:l;if(p.offset)x.copy(p.offset);else{let e=d.getObserver(h);u.defaultDistance<b&&e?(x.copy(e.position).applyMatrix4(e.work.transform),p.longitude===void 0&&(C=m.longitude)):(f.boundingBox.getCenter(x),S=b)}return Object.assign(Object.assign({},h),{mode:`Mapview`,longitude:C,latitude:y,fov:g,offset:x,distance:S})}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 J({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 J({modelAlpha:this.modelScene.parameter.resolveValue().modelAlpha}),this.perspToOrthoMotion=new J({perspToOrtho:this.camera.perspToOrtho.x}),this.pendingTextureId=null,this.textureLoader=new Yc,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 c.Box3&&e.cameraFence instanceof c.Box3||this.cameraFence instanceof c.Sphere&&e.cameraFence instanceof c.Sphere?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(K),(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(K),!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(K),this.cameraMotion.set(i,t).catch(K)})}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(K),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 c.Vector3(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(K),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),lx(n)||this.modelScene.parameter.set(n),lx(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=gi(this.camera.pose,new c.Vector3),t=new c.Vector3().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 c.Vector3),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(K)}}if(this.intersectMesh&&this.intersectMesh.parent){let e=H(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(G())[1],t=this.locationMotion.getKeyFrameSegment(G())[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 c.Vector3(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(K),this.modelAlphaMotion.set({modelAlpha:1},i/3).catch(K),this.cameraMotion.set(s,i).catch(K),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}),ox(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)&&($S.copy(t.observerBox).expandByScalar(10).applyMatrix4(t.transform),$S.containsPoint(e.ray.origin)||e.ray.intersectsBox($S)))for(let e of t.observers)n.push(e)}let[r,i]=vf(n,e=>eC.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 c.Vector2);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=hi(this.cameraMotion.value.longitude+a.longitude),l=H(typeof this.minLatitude==`function`?this.minLatitude(o):this.minLatitude,-Math.PI/2,Math.PI/2),u=H(typeof this.maxLatitude==`function`?this.maxLatitude(o):this.maxLatitude,-Math.PI/2,Math.PI/2),d=H(this.cameraMotion.value.latitude+a.latitude,l,u),f=new c.Vector3(this.locationMotion.value.x+a.x,this.locationMotion.value.y+a.y,this.locationMotion.value.z+a.z),p=Object.assign(Object.assign({},this.currentPano),{mode:this.mode,longitude:s,latitude:d,offset:f,fov:o,distance:this.locationMotion.value.distance}),m=e.state.offset.clone().sub(gi(e.state).setLength(p.distance)),h=!(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(m):!0)===!1&&(h=!0);let g=$(`gesture.momentum`,Object.assign(Object.assign({},e),{isFirst:t,isFinal:h,state:p}));if(this.inMomentumMovement.event=g,this.emit(`gesture.momentum`,g),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:s,latitude:d},0).catch(K),this.locationMotion.set({x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance},0).catch(K),h?this.inMomentumMovement=null:Lc.shared.add((t,n)=>{this.requestMomentumMovement(e,!1,i,n)},!0))}fixFinalState(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho===1)return;let t=gi(e,new c.Vector3),n=new c.Vector3().copy(e.offset).sub(t.clone().setLength(e.distance)),r=new c.Raycaster(n,t);r.params.Points={threshold:.1},r.firstHitOnly=!0,r.hitFilter=e=>e.distance>tC+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 c.Plane(new c.Vector3(0,1,0),-this.modelScene.boundingBox.min.y),t=r.ray.intersectPlane(e,new c.Vector3);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&&Xb(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 c.Vector3().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 c.Plane(new c.Vector3(0,1,0),0),t=n.ray.intersectPlane(e,new c.Vector3);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 c.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),t=new c.Plane().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 c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=gi(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(r),a=new c.Vector3().copy(i).sub(n.target).length();a*=Math.tan(this.camera.pose.fov/2*Math.PI/180);let o=this.renderer.getSize(new c.Vector2),s=2*t.x*a/o.y,l=2*t.y*a/o.y,u=new c.Vector3;u.setFromMatrixColumn(this.camera.matrix,0),u.multiplyScalar(-s),r.add(u),this.camera.pose.latitude<nC?u.setFromMatrixColumn(this.camera.matrix,1):(u.setFromMatrixColumn(this.camera.matrix,0),u.crossVectors(this.camera.up,u)),u.multiplyScalar(l),r.add(u);let d=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=d,this.emit(`gesture.pan`,e),e.defaultPrevented)return;if(this.locationMotion.set({x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K),e.isFinal&&(this.fixFinalState(d),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:d.distance,x:d.offset.x,y:d.offset.y,z:d.offset.z},0).catch(K)),e.isFinal){let t=this.renderer.getSize(new c.Vector2),n=2*e.velocityX*a/t.y,r=2*e.velocityY*a/t.y,i=new c.Vector3,o=new c.Vector3;i.setFromMatrixColumn(this.camera.matrix,0),i.multiplyScalar(-n),o.add(i),this.camera.pose.latitude<nC?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:Mt()},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=hi(this.cameraMotion.value.longitude+r.longitude),a=this.camera.pose.fov,o=H(typeof this.minLatitude==`function`?this.minLatitude(a):this.minLatitude,-Math.PI/2,Math.PI/2),s=H(typeof this.maxLatitude==`function`?this.maxLatitude(a):this.maxLatitude,-Math.PI/2,Math.PI/2),c=H(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(K):this.cameraMotion.set({longitude:l.longitude,latitude:l.latitude},0).catch(K),e.isFinal){let t=e.velocityX,n=e.velocityY;this.inMomentumMovement={uuid:Mt()},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 c.Vector3),a=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),o=H(r/t.scale,tC,1/0),s=t.state.offset.clone().sub(gi(t.state).setLength(o)),l=this.modelScene.boundingBox.containsPoint(s),u;if(!l&&this.pinchState&&this.pinchState.scale>t.scale&&i.distanceTo(s)>a?u=t.state.distance:(u=o,this.pinchState&&(this.pinchState.scale=t.scale)),t.state.distance=u,this.emit(`gesture.pinch`,t),!t.defaultPrevented&&(this.locationMotion.set({distance:t.state.distance},0).catch(K),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(K)}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 c.Vector3().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 c.Vector3(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(K)}else{let n=e.distanceFromModel(this.modelScene,this.cameraMotion.value.fov,this.camera.aspect),r=new c.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),i=gi(this.cameraMotion.value,new c.Vector3).negate(),a=new c.Ray(r,i).intersectBox(this.modelScene.boundingBox,new c.Vector3);a&&(n+=a.distanceTo(r));let o=Math.max(this.locationMotion.value.distance-this.camera.near,0),s=t.center.delta/10*Math.max(o/5,.1);if(o<=n||s>0)if(this.locationMotion.value.distance-s>=tC){let e=this.locationMotion.value.distance-s;t.state.distance=e}else{let e=gi(this.cameraMotion.value);e.setLength(s),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(K)}}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 c.Vector3,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=Mt(),a=Sv({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,l=Object.assign({key:`pano.${a}`},Js(this.imageOptions,[`format`,`size`,`quality`,`sharpen`,`forceUseExifOrientation`,`mappings`])),u=`pano:`+bv([o,l,s]),d=this.modelScene.parameter,f;if(d.pano0&&d.pano0.map.name===u?f=d.pano0:d.pano1&&d.pano1.map.name===u&&(f=d.pano1),f)d.pano0&&d.pano0.map!==f.map&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==f.map&&d.pano1.map!==((t=d.pano0)==null?void 0:t.map)&&d.pano1.map.dispose(),d.set({pano0:f,pano1:f}),this.emit(`pano.request`,$(`pano.request`,{userAction:!0,prevPano:this.currentPano,progress:0,state:i,options:n,error:null}));else{let t,f=``;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)},f=r.images.work.getURL(r.images.hdrConfig));let p=this.textureLoader.loadCubeTexture(o,{imageURL:{transform:s,options:l},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer),m=f?[fetch(f).then(e=>e.json()),this.textureLoader.loadCubeTexture(t,{imageURL:{transform:s,options:l},format:c.RGBAFormat,viaAjax:!0,fetcher:w_(this.fiveId,r.work)},void 0,void 0,void 0,this.renderer)]:[];Promise.all([p,...m]).then(t=>an(this,[t],void 0,function*([t,o,s]){var l,f;let{body:p}=t;if(this.destroyed||this.pendingTextureId!==e){p.dispose();return}this.pendingTextureId=null,p.name=u;let m=Array.isArray(p.image)?p.image[0]:p.image,h=(l=m==null?void 0:m.width)==null?2048:l,g=yield Tx(this.renderer,p,!0,My),_=new Iy().formPixels(g.data),v={panoId:a,map:p,mapSize:h,mapHistogram:new c.Vector4().fromArray(_.toArray()),matrix:r.matrix.clone().premultiply(r.work.transform),zoom:1,hdrConfig:o?Object.assign({map:s.body},Wx(o)):void 0};d.pano0&&d.pano0.map.dispose(),d.pano1&&d.pano1.map!==((f=d.pano0)==null?void 0:f.map)&&d.pano1.map.dispose(),d.set({pano0:v,pano1:v}),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(K),this.hideIntersectMesh()}hideIntersectMesh(){this.intersectMesh.visible===!0&&(this.intersectMesh.visible=!1,this.needsRender=!0)}}},aC={Floorplan:qx,Topview:Yx,Panorama:KS,Model:ZS,Mapview:rC},oC=`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 sC(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=gi(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 cC(){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 lC(){let e=new c.Group;e.name=`internalLights`;{let t=new c.DirectionalLight(16777215,.1);t.name=`direction0`,t.position.copy(new c.Vector3(0,1,0)),e.add(t)}{let t=new c.DirectionalLight(16777215,.1);t.name=`direction1`,t.position.copy(new c.Vector3(-1,-1,-1)),e.add(t)}{let t=new c.DirectionalLight(16777215,.3);t.name=`direction2`,t.position.copy(new c.Vector3(1,1,1)),e.add(t)}{let t=new c.AmbientLight(16777215,.6);t.name=`ambient0`,e.add(t)}return e}function uC(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 dC(){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=uC((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var fC=1e3,pC=90,mC=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/`),hC=new c.Sphere,gC=new c.Box3,_C=new c.Vector4,vC=new c.Vector4,yC=new c.Color,bC=new c.Vector2,xC=new WeakMap,SC=fy([ly(null)]),CC={},wC=class e extends Lt{static get version(){return`1.0.0-alpha.2`}static get dracoPath(){return Ru.decoderPath}static set dracoPath(e){Ru.setDecoderPath(e)}static get ktx2Path(){return Ku.transcoderPath}static set ktx2Path(e){Ku.setTranscoderPath(e)}static get useNativeImageBitmap(){return Vc()}static set useNativeImageBitmap(e){Bc(e)}constructor(e={}){var t,n,r,i,a,o,s,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Mt(),CC[this.fiveId]=this,this.currentUpdateArgs={time:G(),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 c.Color((a=e.backgroundColor)==null?1579548:a),this.backgroundAlpha=(o=e.backgroundAlpha)==null?1:o,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview)},this.fps={testCount:0,testTime:G()},this.modeChangeDuration=(s=e.modeChangeDuration)==null?fC:s,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof xb&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new xb({outputType:e.enableHDR?c.HalfFloatType:void 0,logarithmicDepthBuffer:e.logarithmicDepthBuffer});let t=dC();this.renderer.setPixelRatio(t===1?window.devicePixelRatio:1),this.renderer.setSize(512,512),this.renderer.setClearColor(this.backgroundColor,this.backgroundAlpha)}catch(e){let t=e instanceof Error?e:Error(String(e));this.throwError(t)}this.getPixelsRenderTarget=new c.RenderTarget(1,1,{colorSpace:(d=(u=this.renderer)==null?void 0:u.outputColorSpace)==null?c.SRGBColorSpace:d,generateMipmaps:!1}),this.renderer&&ks(this.renderer),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new ki(pC),this.scene=new Db,this.scene.background=this.backgroundColor,this.xrCustomObjectsScene=new c.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.requestProxy=(f=e.requestProxy)==null?mC:f,this.networkSubscribe=new Vs,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 c.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),xC.set(this,SC),this.modelScene=new ev({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(SC,{forceReplaceImmediately:!0});Z(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new c.VideoTexture(e.videoInstance||cC());let m=lC();this.scene.add(m),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.stateSynced=!1,this.destroyed=!1,this.paused=!0,typeof window<`u`&&(e.play!==!1&&this.play(),this.stopAnimationLoop=Lc.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{this.needsRender=!0};if(this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,h,!1),this.removeEventListeners=()=>{this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,h,!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)}}}sC(this),this.fiveRenderer=new vb({outputType:e.enableHDR?c.HalfFloatType:void 0}),this.adaptiveLuminancePass=new Qy,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new eb(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),this.pbmGaussianSplattingRenderMesh=new kr,this.scene.add(this.pbmGaussianSplattingRenderMesh)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}prepare(){return Promise.all([lc().catch(K)]).then(K)}dispose(){var e;if(this.destroyed===!0)return;delete CC[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(),xC.set(this,SC),this.renderer&&(!(this.renderer instanceof xb)||this.renderer.isInitialized)&&this.renderer.render(new c.Scene,new c.Camera),this.fiveRenderer.dispose(),this.renderer instanceof xb&&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,Xs(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,Xs(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,Xs(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,Xs(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,Xs(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 xb)){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=dC(),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=G(),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 xC.get(this)||SC}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(()=>$b(e)?e.then(e=>this.load_(e,t,n,r)):this.load_(e,t,n,r));return this.loadWorkTask=i.catch(e=>{this.throwError(e)}),i}load_(t,n,r,i=!0){var a,o,s,l,u,d,f,p,m,h;let g={};typeof r==`number`?g.duration=r:typeof r==`object`&&Object.assign(g,r),this.works===SC&&(g.duration===void 0&&(g.duration=0),g.effect===void 0&&(g.effect=`instant`));let _={};Object.assign(_,g.model),!_[`3d-tiles`]&&g[`3d-tiles`]&&(_[`3d-tiles`]=g[`3d-tiles`]),!_.textureOptions&&g.textureOptions&&(_.textureOptions=g.textureOptions),!_.textureOptions&&this.textureOptions&&(_.textureOptions=this.textureOptions);let v=[];if(Array.isArray(t))for(let e of t)e instanceof cy?v.push(e):typeof e!=`string`&&`work`in e?v.push(ly(e.work,e)):v.push(ly(e));else t instanceof cy?v.push(t):v.push(ly(t));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=fy(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);n===void 0&&(n=`inherit`),n===`inherit`&&this.works===SC&&(n=`initial`);let b=this.currentMode,x=y.initial,S=x.work.observers[0],C=S?{workCode:S.work.workCode,panoIndex:S.panoIndex}:{workCode:x.work.workCode,panoIndex:0},w=(a=x.mode)==null?S?`Panorama`:`Mapview`:a,T={};if(n===`inherit`){let e=this.getCurrentState(),[t]=y.filter(t=>t.workCode===e.workCode);if(t)C={workCode:e.workCode,panoIndex:e.panoIndex},w=e.mode,T={longitude:e.latitude,latitude:e.latitude,fov:e.fov,distance:e.distance,offset:e.offset.clone()};else{n={mode:b};let e=(s=(o=y[0])==null?void 0:o.observers)==null?void 0:s[this.panoIndex];e?(n.workCode=e.work.workCode,n.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(n.workCode=y.initial.work.workCode,n.panoIndex=y.initial.panoIndex):n.mode===`Panorama`&&(n.mode=`Mapview`),n.mode===b&&(n.longitude=this.camera.pose.longitude,n.latitude=this.camera.pose.latitude,n.fov=this.camera.pose.fov)}}if(n===`initial`&&(typeof x.panoIndex==`number`&&(C={workCode:x.work.workCode,panoIndex:x.panoIndex}),x.mode&&(w=x.mode),T={longitude:x.longitude,latitude:x.latitude,fov:x.fov,distance:x.distance,offset:(l=x.offset)==null?void 0:l.clone()}),typeof n==`object`){if(w=(u=n.mode)==null?b:u,typeof n.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=n.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:n.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:n.longitude,latitude:n.latitude,fov:n.fov,distance:n.distance,offset:n.offset?new c.Vector3().copy(n.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;w===`Panorama`&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,$(`works.request`,{input:t,works:y,userAction:i}));let O=(e,t,r)=>{let a=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),r);n===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:a,duration:E,effect:D,userAction:i}},this.commonParams()),this.controllerInits[e]),c=iC[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},i)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=iC[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:b,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)};xC.set(this,y);let k=Promise.resolve();if(w===e.Mode.Floorplan||w===e.Mode.Topview||w===e.Mode.Mapview||w===e.Mode.Model){this.modelScene.loaded===!1&&(this.camera.setFromPose(T),ax(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,$(`camera.update`,{state:this.getCurrentState(),userAction:i})),t=!0,this.modelScene.autoRefine=!0),e.off(`pano.arrived`,n),e.off(`pano.cancel`,n)},r=this.modelScene.setModels(y,_);k=Promise.all(r.map(e=>e.initReady)).then(K),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,$(`works.load`,{input:t,userAction:i,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,$(`works.ready`,{input:t,userAction:i,works:y})),(e=this.analysis)==null||e.work(y)})}reset(){let e=this.loadWorkTask.then(()=>this.reset_());return this.loadWorkTask=e.catch(e=>{this.throwError(e)}),e}reset_(){return new Promise(e=>{var t;this.controller&&(this.controller.destroy(),this.controller=void 0);let n=this.modelScene.parameter;n.pano0&&n.pano0.map.dispose(),n.pano1&&n.pano1.map!==((t=n.pano0)==null?void 0:t.map)&&n.pano1.map.dispose(),n.set({pano0:null,pano1:null,modelAlpha:1}),xC.set(this,SC),this.modelScene.setModels(SC,{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:pC,longitude:0,latitude:0,offset:new c.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if(t===e.Mode.Panorama&&!this.works.getObserver(m)){let e=Error(`PanoId ${Sv(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?!wv(this.pano,m)&&`moveToPano`in this.controller&&typeof this.controller.moveToPano==`function`?this.controller.moveToPano(m,Object.assign({duration:f},n),i):this.controller.updateCamera(n,f,i).catch(K):(wv(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(K));else{let e=Object.assign(Object.assign({},n),m),r=Object.assign(Object.assign({initial:{state:e,currentState:this.getCurrentState(),duration:f,effect:p,userAction:i}},this.commonParams()),this.controllerInits[t]),a=iC[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=Lc.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),Lc.shared.setContext(null)),_()})}getPixels(e,t,n,r,i,a,o){return an(this,void 0,void 0,function*(){if(!this.renderer)throw Error(`renderer is not initialized.`);let s=G(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new c.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof t==`number`&&(p=t),typeof n==`number`&&(m=n),typeof r==`number`&&(h=r),g=i,_=a,b=o):(f=e.x,p=e.y,m=e.width,h=e.height,g=e.pixelRatio,_=e.flipY,v=e.helperVisible,y=e.skipPanorama,b=e.buffer),f=Math.floor(f),p=Math.floor(p),m=Math.floor(m),h=Math.floor(h),g=Math.floor(g==null?l:g),_=_==null?!1:_;let x=this.helperVisible,S=this.modelScene.parameter.modelAlpha;this.helperVisible=v==null?this.helperVisible:v,y&&this.controller instanceof iC.Panorama&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(s),this.scene.update(this.renderer,this.camera);let w=this.renderer.autoClear,T=this.renderer.autoClearColor,E=this.renderer.autoClearDepth,D=this.renderer.autoClearStencil,O=this.renderer.getClearColor(yC),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(s),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,P=ee*4;if(b){if(b.length!==P)throw Error(`buffer length is not equals pixels ${P}`)}else b=new Uint8Array(P);let F=yield this.renderer.readRenderTargetPixelsAsync(C,0,0,M,N),te=M*4;if(F.length===P)b.set(F);else{let e=Math.ceil(te/256)*256;for(let t=0;t<N;t++){let n=t*e;b.set(F.subarray(n,n+te),t*te)}}if(!_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b})}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=t.getClearColor(yC),c=t.getClearAlpha(),l=t.getViewport(_C),u=t.getScissor(vC),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(bC),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&&Lc.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&Ku.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),Lc.shared.add(()=>{this.emit(`models.load`,$(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&Lc.shared.add(()=>{this.emit(`models.refined`,$(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){gC.makeEmpty(),gC.expandByObject(this.modelScene.boundingMesh);let t=gC.getBoundingSphere(hC),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius);let r=H(n/500,.001,.1),i=H(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 xb&&!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 xb&&this.renderer.clear(!0,!0,!0)}play(){this.needsRender=!0,this.paused=!1}moveToPano(t,n={},r=!0){let{controller:i,renderer:a}=this;if(!i)return this.throwError(Error(`controller is not initialized.`)),Promise.resolve();if(!a)return this.throwError(Error(`renderer is not initialized.`)),Promise.resolve();typeof t==`number`&&this.pano.workCode&&(t={workCode:this.pano.workCode,panoIndex:t});let o=this.works.getObserver(t);if(!o)return this.throwError(Error(`pano ${JSON.stringify(t)} not existed.`)),Promise.resolve();let s={workCode:o.work.workCode,panoIndex:o.panoIndex};return`moveToPano`in i&&typeof i.moveToPano==`function`?i.moveToPano(s,n,r):o&&(this.pano=s,this.once(`initAnimation.start`,e=>{n.moveStartCallback&&n.moveStartCallback(e.state)}),this.once(`initAnimation.end`,e=>{n.moveEndCallback&&n.moveEndCallback(e.state)}),this.changeMode(e.Mode.Panorama,n,{effect:n.effect},r)),this.ready()}preloadPano(e,t=K){let n=this.works.getObserver(e);if(!n)return Promise.reject(Error(`Pano ${JSON.stringify(e)} never found`));let r=[`right`,`left`,`up`,`down`,`front`,`back`],i=G();return Promise.all(r.map(e=>{let t=Sv({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},Js(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Ec(i,r);return w_(this.fiveId,n.work).preload(a)})).then(()=>{let e=G()-i;return t(e),e})}project2d(e,t=!1){if(!this.renderer)return null;if(t){let t=this.camera.position,n=e.clone().sub(t),r=new c.Raycaster(t,n.clone().normalize());r.params.Points={threshold:.1};let[i]=this.modelScene.intersectRaycaster(r);if(i&&i.distance+.01<n.length())return null}let n=e.clone().project(this.camera);if(Math.abs(n.z)>1)return null;let r=this.renderer.getSize(new c.Vector2),i=r.x*this.viewport.width,a=r.y*this.viewport.height,o=r.x*this.viewport.left+(n.x+1)/2*i,s=r.y*(1-this.viewport.bottom-this.viewport.height)+(-n.y+1)/2*a;return new c.Vector2(o,s)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,t=!1,n=!0){var r,i,a,o,s,l,u,d,f,p;e=Js(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof c.Vector3)&&(e.offset=new c.Vector3(e.offset.x,e.offset.y,e.offset.z));let m;if(typeof e.panoIndex==`number`)if(e.workCode)m={workCode:e.workCode,panoIndex:e.panoIndex};else{let t=(i=(r=this.work)==null?void 0:r.workCode)==null?``:i,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(a=e.mode)==null?this.state.mode:a,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){let t={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(t.longitude=e.longitude),typeof e.latitude==`number`&&(t.latitude=e.latitude),typeof e.fov==`number`&&(t.fov=e.fov),typeof e.distance==`number`&&(t.distance=e.distance),e.offset instanceof c.Vector3&&(t.offset=e.offset);let n=Object.assign(Object.assign({initial:{state:t,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),r=iC[h].initAnimationEndState(n);g=r.longitude,_=r.latitude,v=r.fov,y=r.offset,b=r.distance}else g=(o=e.longitude)==null?this.state.longitude:o,_=(s=e.latitude)==null?this.state.latitude:s,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,$(`state.set`,{userAction:n,state:x})),ix(this.state,x)||(rx(this.state,x),this.controller&&n&&(this.controller.userAction=!1),t&&this.state.mode===x.mode&&(this.syncingState=this.syncState(G(),0,t),this.syncingState&&((f=this.controller)==null||f.updateTime(G(),0),this.syncingState=!1)),this.emit(`state.change`,$(`state.change`,{userAction:n,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state))}syncState(t,n,r=!1){let i=this.stateSynced;if(this.stateSynced=!1,!this.controller)return!1;if(this.state.mode!==this.currentMode){let e={mode:this.state.mode,workCode:this.state.workCode,panoIndex:this.state.panoIndex,longitude:this.state.longitude,latitude:this.state.latitude,fov:this.state.fov,offset:this.state.offset,distance:this.state.distance};return this.changeMode(this.state.mode,e,this.modeChangeDuration,this.controller.userAction),!0}if(!this.controller.isReady())return!1;if(this.controller instanceof iC.Model){if(Qb(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(!wv(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 iC.Floorplan||this.controller instanceof iC.Topview||this.controller instanceof iC.Mapview){let e=.2,t=Math.PI/45,n=r?this.state.fov:zy(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:zy(this.camera.pose.distance,this.state.distance,a),s=this.camera.pose.offset.distanceTo(this.state.offset),l=s>e*15?s/15:e,u=r?new c.Vector3().copy(this.state.offset):By(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Vy({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},t);if(Xb(n,this.camera.pose.fov)||Qb(u,this.camera.pose.offset)||Xb(o,this.camera.pose.distance)||Xb(d,this.camera.pose.longitude,Math.PI*2)||Xb(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:n};return Object.assign(e,{distance:o}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(K),this.controller.locationMotion.set(e,0).catch(K),!0}}else{let e=Math.PI/45,t=r?this.state.fov:zy(this.camera.pose.fov,this.state.fov,1),{longitude:n,latitude:i}=r?{longitude:this.state.longitude,latitude:this.state.latitude}:Vy({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),a=this.state.distance,o=new c.Vector3().copy(this.state.offset);if(Xb(a,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),Qb(o,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),Xb(n,this.camera.pose.longitude,Math.PI*2)||Xb(i,this.camera.pose.latitude)||Xb(t,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:n,latitude:i,fov:t},0).catch(K),!0}if(this.stateSynced=!0,i===!1&&this.emit(`state.synced`,$(`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 iC.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(K)}requestFullscreen(){var e;if(!nx)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=()=>{Lc.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 Ks({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=qv(e,r);return t instanceof Error?Promise.reject(t):t})}});T_(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=iC[e];this.currentMode=e;let r=new n(t);for(let e of oC)r.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let n=iC[e].initAnimationEndState(t),r=t.initial.userAction;ix(this.state,n)||(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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&&!ix(this.state,n)&&(rx(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 c.Object3D;t.matrix.copy(e.matrix).premultiply(e.work.transform),t.matrix.decompose(t.position,t.quaternion,t.scale),t.matrixAutoUpdate=!1;let n=new c.Vector3(0,0,-1);n.applyQuaternion(this.camera.quaternion);let r=t.quaternion.clone().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}};wC.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:c,constructor:wC,instances:CC}}),exports.AdaptiveLuminancePass=Qy,exports.AnimationFrameLoop=Lc,exports.BoundingMesh=Q_,exports.Camera=ki,exports.EffectComposer=my,exports.EyeDomeLightingPass=eb,exports.Fetcher=Ks,exports.Five=wC,exports.FivePass=gy,exports.FiveRenderer=vb,exports.FlowingFireworks3DPass=ub,exports.FlowingLight2DPass=ib,exports.FlowingLight3DPass=nb,exports.FullScreenQuad=hy,exports.GaussianBlurPass=tb,exports.Histogram=Iy,exports.InternalWebGPURenderer=xb,exports.Model=U_,exports.ModelScene=ev,exports.Motion=J,exports.NetworkSubscribe=Vs,exports.PBMGSObject=At,exports.PBMGaussianSplattingObject=At,exports.PBMGaussianSplattingNodeMaterial=Dr,exports.PBMGaussianSplattingRenderMesh=kr,exports.PBMGroup=Ct,exports.PBMMesh=Ot,exports.PBMMeshBasicMaterial=Ar,exports.PBMMeshBasicNodeMaterial=bs,exports.PBMMeshPanoOnlyMaterial=jr,exports.PBMMeshPanoOnlyNodeMaterial=Es,exports.PBMMeshPhongMaterial=Mr,exports.PBMMeshPhongNodeMaterial=Ss,exports.PBMMeshPhysicalMaterial=Nr,exports.PBMMeshPhysicalNodeMaterial=ws,exports.PBMPanoFilter=zt,exports.PBMPointCloud=nn,exports.PBMSkinnedMesh=kt,exports.PBMUpdateable=Rt,exports.PROXY_CONTROLLER_EVENT_NAMES=oC,exports.PanoCircleMesh=Fb,exports.PanoCircleMeshCustom=Jb,exports.PanoCircleMeshSolid=Ub,exports.Parameter=X,exports.Scene=Db,exports.Subscribe=Lt,exports.TextureLoader=Yc,exports.Tile=gf,exports.Tile3D=S_,exports.Tile3DModel=S_,exports.TileCache=em,exports.TileNode=Up,exports.TileRequestScheduler=Zp,exports.Tileset=om,exports.Trajectory=qp,exports.TrajectoryNode=Jp,exports.Work=cy,exports.WorkResolvedObserver=dy,exports.controllersDefaultInitArgs=aC,exports.coordinatesToVector=gi,exports.createDebugBoundingMesh=df,exports.createWorks=fy,exports.defaultImageURLTransform=Ec,exports.draco=Ru,exports.getViewportScale=dC,exports.headingToLongitude=yi,exports.imageSupport=lc,exports.isBoundingVolume=of,exports.isPanoId=Tv,exports.loadAt3d=Il,exports.loadDome=Bl,exports.loadDomez=ql,exports.loadGltf=Rd,exports.loadPbm=ml,exports.loadPly=Zl,exports.longitudeToHeading=vi,exports.makeBoundingVolume=sf,exports.panoEqual=wv,exports.panoParse=Cv,exports.panoStringify=Sv,exports.parseWork=ly,exports.registerPBMMaterials=ks,exports.vectorToCoordinates=_i,exports.workToJson=av;
|