@realsee/five 6.9.0-alpha.4 → 6.9.0

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/five/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @license
3
3
  * @realsee/five
4
4
  * Generated: 2026/8/24
5
- * Version: 6.9.0-alpha.4
5
+ * Version: 6.9.0
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -2840,7 +2840,7 @@ void main() {
2840
2840
  #include <premultiplied_alpha_fragment>
2841
2841
 
2842
2842
  }
2843
- `},cy=class extends t.ShaderMaterial{constructor(e){super({uniforms:t.UniformsUtils.clone(sy.uniforms),vertexShader:sy.vertexShader,fragmentShader:sy.fragmentShader,clipping:!0}),this.type=`LineMaterial`,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)}};Object.assign(cy.prototype,{isLineMaterial:!0});var ly=class extends t.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new oy:e,this.material=t===void 0?new cy({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count),a=new t.Vector3,o=new t.Vector3;for(var s=0,c=0,l=n.count;s<l;s++,c+=2)a.fromBufferAttribute(n,s),o.fromBufferAttribute(r,s),i[c]=c===0?0:i[c-1],i[c+1]=i[c]+a.distanceTo(o);let u=new t.InstancedInterleavedBuffer(i,2,1);return e.setAttribute(`instanceDistanceStart`,new t.InterleavedBufferAttribute(u,1,0)),e.setAttribute(`instanceDistanceEnd`,new t.InterleavedBufferAttribute(u,1,1)),this}raycast(e,n){e.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let r=e.ray,i=e.camera,a=i.projectionMatrix,o=this.geometry,s=this.material,c=s.resolution,l=s.linewidth,u=o.attributes.instanceStart,d=o.attributes.instanceEnd,f=new t.Vector4,p=new t.Vector4,m=new t.Vector4,h=new t.Vector3,g=new t.Matrix4,_=new t.Line3,v=new t.Vector3;r.at(1,m),m.w=1,m.applyMatrix4(i.matrixWorldInverse),m.applyMatrix4(a),m.multiplyScalar(1/m.w),m.x*=c.x/2,m.y*=c.y/2,m.z=0,h.copy(m);let y=this.matrixWorld;g.multiplyMatrices(i.matrixWorldInverse,y);for(var b=0,x=u.count;b<x;b++){f.fromBufferAttribute(u,b),p.fromBufferAttribute(d,b),f.w=1,p.w=1,f.applyMatrix4(g),p.applyMatrix4(g),f.applyMatrix4(a),p.applyMatrix4(a),f.multiplyScalar(1/f.w),p.multiplyScalar(1/p.w);var S=f.z<-1&&p.z<-1,C=f.z>1&&p.z>1;if(S||C)continue;f.x*=c.x/2,f.y*=c.y/2,p.x*=c.x/2,p.y*=c.y/2,_.start.copy(f),_.start.z=0,_.end.copy(p),_.end.z=0;let e=_.closestPointToPointParameter(h,!0);_.at(e,v);let i=t.MathUtils.lerp(f.z,p.z,e),o=i>=-1&&i<=1;var w=h.distanceTo(v)<l*.5;if(o&&w){_.start.fromBufferAttribute(u,b),_.end.fromBufferAttribute(d,b),_.start.applyMatrix4(y),_.end.applyMatrix4(y);var T=new t.Vector3,E=new t.Vector3;r.distanceSqToSegment(_.start,_.end,E,T),n.push({point:E,pointOnLine:T,distance:r.origin.distanceTo(E),object:this,faceIndex:b})}}}};Object.assign(ly.prototype,{isLineSegments2:!0});var uy=class extends ly{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(uy.prototype,{isLine2:!0});var dy=class extends oy{constructor(){super(),this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){let n=e.geometry;if(n instanceof t.Geometry){let e=new t.BufferGeometry().fromGeometry(n);this.setPositions(e.attributes.position.array)}else n instanceof t.BufferGeometry&&this.setPositions(n.attributes.position.array);return this}copy(){return this}};Object.assign(dy.prototype,{isLineGeometry:!0});var fy=14467195,py=8,my=2,hy=20,gy=null,_y=class extends t.Object3D{static get version(){return`6.9.0-alpha.4`}constructor(e=new t.Vector3,n=new t.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0;let r=new dy,i=new cy({color:fy,linewidth:my,dashScale:hy,dashed:!1});this.line=new uy(r,i);let a=new t.BufferGeometry,o=new t.PointsMaterial({color:fy,size:py,map:gy||(gy=new t.TextureLoader().load(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`)),sizeAttenuation:!1,transparent:!0});this.points=new t.Points(a,o),this.points.renderOrder=11,this.points.frustumCulled=!1,this.setPoints(e,n),this.add(this.line,this.points)}setPoints(e,n){let r=[].concat(e.toArray(),n.toArray());this.points.geometry.setAttribute(`position`,new t.BufferAttribute(new Float32Array(r),3)),this.line.geometry.setPositions(r),this.line.computeLineDistances(),this.needsRender=!0}getPoints(){let e=this.points.geometry.attributes.position.array;return[new t.Vector3(e[0],e[1],e[2]),new t.Vector3(e[3],e[4],e[5])]}setMaterial(e){let t=this.line.material;for(let n in e){if(!e.hasOwnProperty(n))continue;let r=e[n];n===`dashed`?(t.dashed=r,r?t.defines.USE_DASH=``:delete t.defines.USE_DASH,t.needsUpdate=!0):t[n]=e[n]}this.needsRender=!0}setResolution(e,t){let n=this.line.material.resolution;(n.x!==e||n.y!==t)&&(n.set(e,t),this.needsRender=!0)}};Object.assign(_y.prototype,{isFiveLine:!0});var vy={Handedness:Object.freeze({NONE:`none`,LEFT:`left`,RIGHT:`right`}),ComponentState:Object.freeze({DEFAULT:`default`,TOUCHED:`touched`,PRESSED:`pressed`}),ComponentProperty:Object.freeze({BUTTON:`button`,X_AXIS:`xAxis`,Y_AXIS:`yAxis`,STATE:`state`}),ComponentType:Object.freeze({TRIGGER:`trigger`,SQUEEZE:`squeeze`,TOUCHPAD:`touchpad`,THUMBSTICK:`thumbstick`,BUTTON:`button`}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:`transform`,VISIBILITY:`visibility`})};function yy(e){return Xo(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function by(e){return Xo(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield yy(`${e}/profilesList.json`)})}function xy(e,t){return Xo(this,arguments,void 0,function*(e,t,n=null,r=!0){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No basePath supplied`);let i=yield by(t),a;if(e.profiles.some(e=>{let n=i[e];return n&&(a={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!n)throw Error(`No matching profile name found`);let e=i[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);a={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let o=yield yy(a.profilePath),s;if(r){let t;if(t=o.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${a.profileId}`);t.assetPath&&(s=a.profilePath.replace(`profile.json`,t.assetPath))}return{profile:o,assetPath:s}})}var Sy={xAxis:0,yAxis:0,button:0,state:vy.ComponentState.DEFAULT};function Cy(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let i=Math.atan2(t,e);n=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var wy=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===vy.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Sy)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:i,normalizedYAxis:a}=Cy(e,t);switch(this.componentProperty){case vy.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?i:.5;break;case vy.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case vy.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case vy.ComponentProperty.STATE:this.valueNodeProperty===vy.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=+!!this.states.includes(r);break;default:throw Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},Ty=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw Error(`Invalid arguments supplied`);this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(e=>{let n=new wy(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:vy.ComponentState.DEFAULT,button:this.gamepadIndices.button===void 0?void 0:0,xAxis:this.gamepadIndices.xAxis===void 0?void 0:0,yAxis:this.gamepadIndices.yAxis===void 0?void 0:0}}get data(){return Object.assign({id:this.id},this.values)}updateFromGamepad(e){if(this.values.state=vy.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){let t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=vy.ComponentState.PRESSED:(t.touched||this.values.button>vy.ButtonTouchThreshold)&&(this.values.state=vy.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===vy.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>vy.AxisTouchThreshold&&(this.values.state=vy.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===vy.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>vy.AxisTouchThreshold&&(this.values.state=vy.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},Ey=class{constructor(e,t,n){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No profile supplied`);this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(e=>{let t=this.layoutDescription.components[e];this.components[e]=new Ty(e,t)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){let e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}},Dy=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,Oy=`generic-trigger`,ky=class extends t.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof t.Mesh&&e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(e=>{Object.values(e.visualResponses).forEach(e=>{let{valueNode:t,minNode:n,maxNode:r,value:i,valueNodeProperty:a}=e;t&&(a===vy.VisualResponseProperty.VISIBILITY?t.visible=i:a===vy.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,i),t.position.lerpVectors(n.position,r.position,i)))})}))}};function Ay(e,n){Object.values(e.components).forEach(e=>{let{type:r,touchPointNodeName:i,visualResponses:a}=e;if(r===vy.ComponentType.TOUCHPAD)if(e.touchPointNode=n.getObjectByName(i),e.touchPointNode){let n=new t.Mesh(new t.SphereGeometry(.001),new t.MeshBasicMaterial({color:255}));e.touchPointNode.add(n)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(a).forEach(e=>{let{valueNodeName:t,minNodeName:r,maxNodeName:i,valueNodeProperty:a}=e;if(a===vy.VisualResponseProperty.TRANSFORM){if(e.minNode=n.getObjectByName(r),e.maxNode=n.getObjectByName(i),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${i} in the model`);return}}e.valueNode=n.getObjectByName(t),e.valueNode||console.warn(`Could not find ${t} in the model`)})})}function jy(e,n){Ay(e.motionController,n),e.envMap&&n.traverse(n=>{n instanceof t.Mesh&&n.isMesh&&(n.material.envMap=e.envMap,n.material.needsUpdate=!0)}),e.add(n)}var My=class{constructor(e=null){this.gltfLoader=e,this.path=Dy,this._assetCache={}}createControllerModel(e){let t=new ky,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||xy(r,this.path,Oy).then(({profile:e,assetPath:i})=>{t.motionController=new Ey(r,e,i);let a=this._assetCache[t.motionController.assetUrl];if(a)n=a.scene.clone(),jy(t,n);else{if(!this.gltfLoader)throw Error(`GLTFLoader not set.`);this.gltfLoader.load(t.motionController.assetUrl,e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),jy(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},Ny=`fade`,Py=Object.assign({},fr(Y_,[`maxLatitude`,`minLatitude`]));function Fy(e,t){if(!t)return e;let n=e.match(/\d+_[a-z].png/);return e.substring(0,n.index)+t+`/`+e.substring(n.index)}var Iy=300,Ly=new t.Raycaster,Ry=new t.Vector3,zy={Floorplan:Jg,Topview:Xg,Panorama:X_,VRPanorama:Vv,Model:Kv,Mapview:Qv,XRPanorama:class e extends X_{static parseArgs(t){if(t instanceof e)return t;let n=Object.assign(Object.assign({},t),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return super.parseArgs(n)}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`XRPanorama`})}constructor(e){super(e),this.xrManager=new ay(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,Q(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,Q(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new t.Raycaster,right:new t.Raycaster},this.xrControllerRay.left.params.Points={threshold:.1},this.xrControllerRay.left.firstHitOnly=!0,this.xrControllerRay.left.floorIndex=-1,this.xrControllerRay.right.params.Points={threshold:.1},this.xrControllerRay.right.firstHitOnly=!0,this.xrControllerRay.right.floorIndex=-1,this.gazeRay=null,this.pointerLines={left:new _y,right:new _y},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new t.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new t.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new t.Group,new t.Group];let n=this.xrManager.getController(0);this.controllerWrappers[0].add(n);let r=this.xrManager.getController(1);this.controllerWrappers[1].add(r);let i=new My;i.gltfLoader={load(e,t){ur.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return Us(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:ur})}).then(e=>t(e))}},(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`)&&this.scene.add(this.pointerLines.left,this.pointerLines.right,this.controllerWrappers[0],this.controllerWrappers[1]),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Zt()]={panoId:Z(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:Ny,effectEasing:G_,fixCameraTransform:new t.Matrix4},this.parallaxCameraMatrixs=[];let a=ei.shared.getContext();if(!a){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(a),this.on(`xr.session.start`,()=>{let e=this.xrManager.getControllerGrip(0);e.add(i.createControllerModel(e)),this.controllerWrappers[0].add(e);let t=this.xrManager.getControllerGrip(1);t.add(i.createControllerModel(t)),this.controllerWrappers[1].add(t)}),this.xrHandleState={LeftAxesUp:{touchStartTime:0,touchStart:!1},LeftAxesDown:{touchStartTime:0,touchStart:!1},LeftAxesLeft:{touchStartTime:0,touchStart:!1},LeftAxesRight:{touchStartTime:0,touchStart:!1},LeftTrigger:{touchStartTime:0,touchStart:!1},LeftPinch:{touchStartTime:0,touchStart:!1},RightAxesUp:{touchStartTime:0,touchStart:!1},RightAxesDown:{touchStartTime:0,touchStart:!1},RightAxesLeft:{touchStartTime:0,touchStart:!1},RightAxesRight:{touchStartTime:0,touchStart:!1},RightTrigger:{touchStartTime:0,touchStart:!1},RightPinch:{touchStartTime:0,touchStart:!1},Y:{touchStartTime:0,touchStart:!1},X:{touchStartTime:0,touchStart:!1},A:{touchStartTime:0,touchStart:!1},B:{touchStartTime:0,touchStart:!1}},this.xrManager.machineType===`VP`&&this.initHandEvent()}updateConfiguration(e){return super.updateConfiguration(Object.assign(Object.assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2}))}moveToPano(e,n,r){var i,a,o;this.userAction=r,this.stopMomentumMovement();let s=Z(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoIndex`);let l=Kr(c.images.up),u=this.imageOptions.size;u===void 0&&c&&l&&(u=Number(l)),u===void 0&&(u=2048);let d=this.imageOptions.transform,f=(e,t)=>Fy(Wr(e,d,t)),p=Object.assign({key:`pano.${s}`},dr(this.imageOptions,[`format`,`size`,`quality`])),m={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},h=`pano:`+Ip([m,p,d]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===h)return;{let t=this.pendingPanoTask.panoId;(i=this.panoMeshes.get(t))==null||i.setProgress(0),this.emit(`pano.texture.abort`,Q(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let g=`move-to-pano-`+s;this.pending.add(g);let _=xg(`pano.prepare`,{options:n,prevMode:this.mode,prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,_),_.defaultPrevented){this.pending.delete(g);return}_.options!==n&&Object.assign(n,_.options);let v=this.modelScene.parameter,y;v.pano0&&v.pano0.map.name===h?y=v.pano0:v.pano1&&v.pano1.map.name===h&&(y=v.pano1);let b=(a=n.effect)==null?Ny:a,x=(o=n.effectEasing)==null?G_:o;if(y){let r={panoId:s,effect:b,effectEasing:x,leftPanoPicture:{panoId:y.panoId,map:y.map,mapHistogram:y.mapHistogram,mapSize:y.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new t.Matrix4};r.leftPanoPicture&&this.panoPictureObserverMap.set(r.leftPanoPicture,c),this.pendingPanoTask=void 0,Promise.resolve().then(()=>Sg(_)).catch(e=>{let t=Wg(e);return this.emit(`error`,t),t}).then(t=>{var i,a;if(!(t instanceof Error))this.pending.delete(g),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0),this.doMoveToPano(e,r,n);else{let e=null;t instanceof Error&&(e||(e=t));let r=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:r})),n.moveCancelCallback&&n.moveCancelCallback(),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:r})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(g),this.pendingPanoTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)}});return}let S=this.panoMeshes.get(s);S&&S.tap&&S.tap(),this.pendingPanoTask={panoId:s,hash:h,onLoad:r=>{var i;let a=r.body;if(this.destroyed)a.dispose();else{a.name=h;let r=Array.isArray(a.image)?a.image[0]:a.image,o=(i=r==null?void 0:r.width)==null?2048:i,l=new zm().formPixels(Rg(this.renderer,a,!0,Fm).data),u={panoId:s,effect:b,effectEasing:x,leftPanoPicture:{panoId:s,map:a,mapSize:o,mapHistogram:new t.Vector4().fromArray(l.toArray()),matrix:c.matrix.clone(),zoom:1},position:c.position.clone(),fixCameraTransform:new t.Matrix4};u.leftPanoPicture&&this.panoPictureObserverMap.set(u.leftPanoPicture,c),this.doMoveToPano(e,u,n)}},onError:e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:t})),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:t})),e instanceof Error&&e.message&&this.emit(`error`,e),n.moveCancelCallback&&n.moveCancelCallback()}},Promise.all([Promise.resolve().then(()=>{this.emit(`pano.texture.load`,Q(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:t.RGBFormat,viaAjax:!0,fetcher:Gf(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,Q(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===h&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=Wg(t);return this.emit(`pano.texture.error`,Q(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>Sg(_)).catch(e=>Wg(e))]).then(([t,n])=>{var r,i,a,o;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(g),((r=this.pendingPanoTask)==null?void 0:r.hash)===h?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,Q(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}));else{let e=null;t instanceof Error?e||(e=t):t.body.dispose(),n instanceof Error&&(e||(e=n)),this.pending.delete(g),((a=this.pendingPanoTask)==null?void 0:a.hash)===h&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(s))==null||o.setProgress(0))}})}doMoveToPano(e,n,r={}){var i,a,o,s,c,l,u,d,f,p;let m=V(),h=Zt();this.panoResources[h]=n;let g,_,v;if(this.locationMotion.ended){let[e,t]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(t).position,a=n.position;g=Math.max(i.distanceTo(a),1),_=[{key:t.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:h,progress:1,value:{distance:0,count:1}}],v=0}else{let[e,t]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(t).position,o=n.position,s=t.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;g=c+Math.max(a.distanceTo(o),1),_=[{key:e.key,progress:0,value:Object.assign({},r)},{key:t.key,progress:c/g,value:t.value},{key:h,progress:1,value:{count:t.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(_);v=this.locationMotion.getProgressVelocity(m)*l/u}let y=n.effect===`instant`?0:this.calculateMovingDuration(r.duration,n.effect===`fly`||n.effect===`model`?g:0),b={longitude:r.longitude,latitude:r.latitude,fov:r.fov},x=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=b.longitude)==null?this.camera.pose.longitude:i,latitude:(a=b.latitude)==null?this.camera.pose.latitude:a,fov:(o=b.fov)==null?this.camera.pose.fov:o,offset:n.position.clone(),distance:0}),S=this.currentPano;if(this.emit(`pano.moveTo`,Q(`pano.moveTo`,{options:r,prevPano:S,pano:{panoIndex:x.panoIndex,workCode:x.workCode},progress:0,state:x,userAction:this.userAction,error:null})),r.moveStartCallback&&r.moveStartCallback(x),this.perspToOrthoMotion.set({perspToOrtho:0},y).catch(G),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],y).catch(G),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=G,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),n.effect===`fly`||n.effect===`model`)this.cameraMotion.set(b,y).catch(G);else{let e=It({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),r=It({longitude:(s=b.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=b.latitude)==null?this.cameraMotion.value.latitude:c}),i=new t.Object3D;i.lookAt(e);let a=new t.Matrix4().makeRotationFromQuaternion(i.quaternion);i.lookAt(r);let o=new t.Matrix4().makeRotationFromQuaternion(i.quaternion),m=new t.Matrix4().getInverse(a).premultiply(o),h=this.cameraMotion.value.fov,g=(l=b.fov)==null?this.cameraMotion.value.fov:l,v=1;n.effect===`zoomin`?v=1.5:n.effect===`zoomout`&&(v=.4);let x=g*v;for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(m),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(x/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(u=b.longitude)==null?this.cameraMotion.value.longitude:u,latitude:(d=b.latitude)==null?this.cameraMotion.value.latitude:d,fov:x}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:g}}],y).catch(G)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof up&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:0});this.emit(`pano.arrived`,Q(`pano.arrived`,{options:r,prevPano:S,pano:{panoIndex:t.panoIndex,workCode:t.workCode},progress:1,state:t,userAction:this.userAction,error:null})),r.moveEndCallback&&r.moveEndCallback(t);let n=this.works.getObserver(this.currentPano);if(n&&n.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:n.images.video.size.clone(),matrix:n.images.video.matrix.clone(),panoMatrix:n.matrix.clone().premultiply(n.work.transform),alpha:1},t=Zt(),r=this.videoTexture.image;r.setAttribute(`uuid`,t),t_().then(i=>{i&&n.images.video&&r.getAttribute(`uuid`)===t&&(r.oncanplay=()=>{r.oncanplay=G,r.play()},r.ontimeupdate=()=>{r.currentTime>.5&&(r.ontimeupdate=G,this.panoVideo.setMaterial(e))},r.src=n.images.video.source)}).catch((()=>{r.removeAttribute(`uuid`)}))}},()=>{let e=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{options:r,prevPano:S,pano:{panoIndex:e.panoIndex,workCode:e.workCode},progress:0,state:e,userAction:this.userAction,error:null})),r.moveCancelCallback&&r.moveCancelCallback()})}checkSelectedPano(e){var n;this.stopMomentumMovement(),this.camera.getDirection(new t.Vector3).setY(0);let r=null,i=this.works.getObserver(this.currentPano);if(!i)return null;let a=i.work.observers,o=i.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)return!1;let t=a[e];return!t||Ry.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[s]=this.modelScene.intersectRaycaster(e);if(s){let[e,t]=vu(o,e=>{let t=a[e];return t?Ry.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(s.point):1/0},!0);typeof e==`number`&&t<this.panoTapTriggerRadius&&(r=(n=a[e])==null?null:n)}if($v(r)){let t=this.getForwardObserverOrNot(this.xrManager.cameraVR,e);t&&(r=t)}for(let e of this.locationMotion.keyframes){let t=this.panoResourceFromLocationMotionKeyframe(e);if(!(e.progress<this.locationMotion.progress)&&r){let e=Z({panoIndex:r.panoIndex,workCode:r.work.workCode});if(t.panoId===e){r=null;break}}}if($v(r))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!r.active){let e=Z({panoIndex:r.panoIndex,workCode:r.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let c={workCode:r.work.workCode,panoIndex:r.panoIndex,mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,distance:0,offset:r?r.position.clone():new t.Vector3};return this.emit(`pano.select`,Q(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.workCode},state:c,userAction:!0,options:{},progress:0,error:null})),r&&r.active?(this.emit(`pano.request`,Q(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.workCode},progress:0,state:c,options:{},error:null})),{workCode:r.work.workCode,panoIndex:r.panoIndex}):null}destroy(){super.destroy()}isReady(){return!1}updateCamera(e,t,n){return Promise.resolve()}updateCameraWithKeyframes(e,t,n){return Promise.resolve()}updateTime(e,n,...r){var i,a,o,s,c,l,u,d,f;this.userAction=!0;let p={},m={},h=this.camera.getDirection(new t.Vector3),g=this.locationMotion.keyframes[0],_=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[v,y]=this.locationMotion.getKeyFrameSegment(e),b=this.panoResourceFromLocationMotionKeyframe(v),x=this.panoResourceFromLocationMotionKeyframe(y),S=this.panoResourceFromLocationMotionKeyframe(g),C=this.panoResourceFromLocationMotionKeyframe(_),w=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),m.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),p.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let n=this.locationMotion.value.count-y.value.count+1,r=new t.Vector3().copy(b.position),o=new t.Vector3().copy(x.position);if(p.progress=n,n>=.01&&n<=.99&&(p.progress=H(x.effectEasing(n),.01,.99)),x.leftPanoPicture&&(n<1?b.leftPanoPicture&&(p.pano0=b.leftPanoPicture):p.pano0=x.leftPanoPicture,p.pano1=x.leftPanoPicture),x.effect===`montage`?p.transition=`BLACK`:x.effect===`spread`?p.transition=`SPREAD`:p.transition=`FADE`,x.effect===`zoomin`||x.effect===`zoomout`?p.progress=Math.pow(n,3):x.effect===`model`&&this.camera.pose.distance<.01&&(p.modelAlpha=1-Math.pow(H(Math.abs(n-.5)*2,0,1),4)),n<1&&x.effect!==`fly`){if(p.pano0&&b.leftPanoPicture){let e={panoId:p.pano0.panoId,map:p.pano0.map,mapHistogram:p.pano0.mapHistogram,mapSize:p.pano0.mapSize,zoom:p.pano0.zoom,matrix:b.leftPanoPicture.matrix.clone().setPosition(x.position)},t=this.panoPictureObserverMap.get(p.pano0);t&&this.panoPictureObserverMap.set(e,t),p.pano0=e}r.copy(o),w=!0}m.distance=this.locationMotion.value.distance,m.offset=new t.Vector3(r.x+(o.x-r.x)*n,r.y+(o.y-r.y)*n,r.z+(o.z-r.z)*n);let s=[],c=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(s.push(t),n>this.locationMotion.progress&&c.push(t))}for(let e of Object.keys(this.panoResources)){if(c.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((i=p.pano0)==null?void 0:i.map)||e===((a=p.pano1)==null?void 0:a.map))continue;e.dispose(),t.leftPanoPicture=null}}s.indexOf(e)>=0||delete this.panoResources[e]}let l=Rp(x.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,Q(`pano.moving`,{userAction:this.userAction,prevPano:Rp(S.panoId),pano:Rp(C.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Rp(C.panoId)),{mode:this.mode}),$(this.camera.pose)),m),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(m),this.xrManager.cameraVR.projectionMatrix.copy(this.camera.projectionMatrix),this.xrManager.cameraVR.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.xrManager.cameraVR.matrix.copy(this.camera.matrix),this.xrManager.cameraVR.position.copy(this.camera.position),this.xrManager.cameraVR.quaternion.copy(this.camera.quaternion),this.xrManager.cameraVR.scale.copy(this.camera.scale),this.xrManager.cameraVR.matrixAutoUpdate=!1,this.xrManager.cameraVR.matrixWorld.copy(this.camera.matrixWorld);let[T,E]=r,D=new t.Vector3(0,0,0),O=new t.Vector2().copy(this.camera.resolution);if(E&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let r=this.xrManager.cameraVR,i=this.xrManager.referenceSpace,a=this.xrManager.session.renderState.baseLayer,l=E.getViewerPose(i),u=(o=l==null?void 0:l.views)==null?[]:o;for(let e=0;e<u.length;e++){let t=u[e],n=r.cameras[e],i=a.getViewport(t);i&&(n.projectionMatrix.fromArray(t.projectionMatrix),n.projectionMatrixInverse.getInverse(n.projectionMatrix),n.matrix.fromArray(t.transform.matrix),n.matrix.setPosition(this.camera.position),n.matrix.decompose(n.position,n.quaternion,n.scale),n.matrixWorld.copy(n.matrix),n.matrixWorldInverse.getInverse(n.matrixWorld),n.matrixAutoUpdate=!1,D.copy(n.position),n.viewport.set(i.x,i.y,i.width,i.height),O.set(i.width,i.height))}if(this.xrManager.setProjectionFromUnion(this.xrManager.cameraVR,this.xrManager.cameraL,this.xrManager.cameraR),this.camera.quaternion.copy(this.xrManager.cameraVR.quaternion),this.camera.scale.copy(this.xrManager.cameraVR.scale),this.camera.matrix.compose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.computePose((s=m.distance)==null?this.camera.pose.distance:s),this.xrManager.session.inputSources){for(let e=0;e<this.xrManager.session.inputSources.length;e++)if(this.xrManager.session.inputSources[e]&&this.xrManager.session.inputSources[e].targetRayMode===`transient-pointer`){let n=E.getPose(this.xrManager.session.inputSources[e].targetRaySpace,i);if(n){let e=n.transform.orientation,r=new t.Quaternion(e.x,e.y,e.z,e.w),i=new t.Vector3(0,0,-1).applyQuaternion(r),a=new t.Raycaster(this.camera.position,i);this.gazeRay=a}}}if(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`){let r=this.xrManager.session.inputSources;for(let e=0;e<r.length;e++){let n=this.xrManager.controllers[e],a=r[e];if(!a)continue;n&&n.update(a,E,i);let o=this.xrManager.getController(e),s=new t.Vector3(0,1.2,0),l=o.position.clone().add(D).sub(s);a.handedness===`left`?this.xrControllerRay.left.set(l,new t.Vector3(0,0,-1).applyEuler(o.rotation)):a.handedness===`right`&&this.xrControllerRay.right.set(l,new t.Vector3(0,0,-1).applyEuler(o.rotation)),this.controllerWrappers[e].position.copy(new t.Vector3(0,0,0).add(D).sub(s));let u=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(u.length===0){let e=this.works.getResolvedObserver(this.currentPano);u=this.xrControllerRay.right.intersectObject(this.modelScene.boundingMesh,!0).map(t=>{var n;let r=(n=e==null?void 0:e.floorIndex)==null?0:n;return Object.assign({floorIndex:r,floor:r},t)})}if(u.length>=1&&u[0].face)if(a.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=u[0].face.normal,n=t.clone(),r=u[0].point.clone();this.intersectMesh.position.copy(r);let i=r.clone().add(n);if(this.intersectMesh.lookAt(i),Math.abs(t.y)>.99){let e=this.camera.position.clone().sub(r);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0,e.length>0?(this.pointerLines.right.setPoints(l,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(l,u[0].point));let a=u[0],o=Q(`intersect.update`,{raycaster:(c=this.xrControllerRay.right)==null?null:c,intersection:a==null?null:a,object:this.intersectMesh});if(this.emit(`intersect.update`,o),o.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(l,u[0].point)}this.updateControllerHelper(r,e,n)}}else E||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);Ag(p)===!1&&this.modelScene.parameter.set(p),this.emit(`camera.update`,Q(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose))}));let k=this.works.getResolvedObserver(this.currentPano),A=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,j=this.works.getObserver(b.panoId),M=this.works.getObserver(x.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&k){let e=[],n=k.work.observers;for(let t of k.accessibleNodes){let r=n[t];r&&e.push(r)}let r=new Map;if(e.sort((e,t)=>{let n=r.get(e);n===void 0&&(n=e.standingPosition.distanceTo(k.standingPosition),r.set(e,n));let i=r.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(k.standingPosition),r.set(t,i)),n-i}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let n=e[this.accessibleObserverFloorCheckCount],r=this.modelScene.models.find(e=>e.work===(n==null?void 0:n.work));if(n&&r&&r.visible){let e=.3,i=.005,a=n.standingPosition.clone().applyMatrix4(n.work.transform),o=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),s=J_.map(n=>{Ly.ray.origin.copy(a),Ly.ray.origin.add(Ry.copy(n).setY(e)),Ly.ray.direction.set(0,-1,0),Ly.firstHitOnly=!0,Ly.floorIndex=-1;let[o]=r.intersectRaycaster(Ly);return o&&o.distance-i<=e?new t.Vector3().copy(a).setY(o.point.y+i):a});s.sort((e,t)=>t.y-e.y);let c=s[Math.floor(s.length/2)],[l]=s.filter(e=>e.distanceTo(c)<=.05);if(l){let e=new t.Vector4(a.x,a.y,a.z,l.y-a.y),n=this.adjustPanoCircleMeshPositionFix.get(o);n&&!e.equals(n)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(o,e)}}this.accessibleObserverFloorCheckCount++}}let N=new Map;if(j)for(let e of j.accessibleNodes){let t=j.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(M)for(let e of M.accessibleNodes){let t=M.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{N.get(t)?N.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),N.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),N.delete(t)}),this.panoMeshes.forEach((e,n)=>{let r=this.works.getObserver(n);if(r){let i=r.position.distanceTo(r.standingPosition)>this.aerialObserverMinHeight;if(i)e.position.copy(r.position).applyMatrix4(r.work.transform),e.scale.setScalar(18);else{e.position.copy(r.standingPosition).applyMatrix4(r.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(r.panoId);t&&(Ry.set(t.x,t.y,t.z),Ry.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let a=this.camera.position.clone().setY(e.position.y),o=new t.Vector3().copy(e.position).sub(a).normalize();if(n===Z(this.currentPano)){let t=H((.5-a.distanceTo(e.position))/.5,0,1);o.multiplyScalar(1-t).add(h.clone().multiplyScalar(t))}if(o.length()>0){let n=i?-Math.PI/2:0,r=Math.atan2(o.x,o.z);e.quaternion.setFromEuler(new t.Euler(n,r,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||w)this.panoMeshes.forEach(t=>{t.setOpacity(0),t.setCurrent(!1),t.updateTime&&t.updateTime(e,n),t.visible=!1});else if(k){let t=k.work.observers,[,r]=vu(k.accessibleNodes,e=>{let n=t[e];return!n||!n.active?1/0:k.standingPosition.distanceTo(n.standingPosition)},!0);r=H(r,2.5,1/0);let i=k.accessibleNodes.concat(k.panoIndex).map(e=>Z({panoIndex:e,workCode:k.work.workCode}));this.panoMeshes.forEach((t,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=t.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!t.loading&&t.progress===0&&A!==null&&Z({panoIndex:A.panoIndex,workCode:A.work.workCode})===a;let n=t.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=n<.01?0:H(r/n,.1,.85)}o&&o===M&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&t.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(c=0),t.setCurrent(s),t.setOpacity(c),t.updateTime&&t.updateTime(e,n)})}{let e=(l=this.modelScene.parameter.progress)==null?1:l,n=Math.round(e),r=this.modelScene.parameter.pano0,i=this.modelScene.parameter.pano1,a=n===0?r:i,o;if(a&&(o=this.works.getObserver(a.panoId),o||(o=this.panoPictureObserverMap.get(a))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(ii()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!o||!a||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new t.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Yr(a.mapSize)+1;this.tiling.setObserver(o);let t={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:a.map,panoMatrix:a.matrix,panoZoom:a.zoom,minLevel:e,level:4},s=this.tiling.update(t),c={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:n,opacity:(r==null?void 0:r.panoId)===(i==null?void 0:i.panoId)?1:Ed(Math.abs(((u=this.modelScene.parameter.progress)==null?0:u)-.5)*2)},l=this.modelScene.parameter.refinedScreen;(s||c.pano!==(l==null?void 0:l.pano)||c.opacity!==(l==null?void 0:l.opacity))&&this.modelScene.parameter.set(`refinedScreen`,c)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&k&&k.position.y-k.standingPosition.y>10){let e=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=x.effect,{pano0:n,pano1:r}=this.modelScene.parameter;if(n&&r&&n!==r&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((d=this.modelScene.parameter.pano0Depth)==null?void 0:d.panoId)!==n.panoId||((f=this.modelScene.parameter.pano1Depth)==null?void 0:f.panoId)!==r.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new t.WebGLCubeRenderTarget(512,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new t.WebGLCubeRenderTarget(512,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,generateMipmaps:!1});let e=new t.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(n.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,U_(this.renderer,this.modelScene,e,500);let i=new t.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);i.matrix.copy(r.matrix),i.matrixWorld.copy(i.matrix),i.matrixAutoUpdate=!1,U_(this.renderer,this.modelScene,i,500),this.modelScene.parameter.set({pano0Depth:{panoId:n.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:r.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}render(){if(this.xrManager.session&&this.xrManager.session.renderState.baseLayer){let e=this.xrManager.session.renderState.baseLayer;return this.renderer.setRenderTarget(null),this.renderer.setScissorTest(!1),this.renderer.setFramebuffer(e.framebuffer),this.renderer.render(this.scene,this.xrManager.cameraVR),this.renderer.setFramebuffer(null),!0}return!1}onPanGesture(){}onTapGesture(){}onPinchGesture(){}onMouseMove(){}onMouseOut(){}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}updateControllerHelper(e,t,n){let r=this.xrControllerRay.left,i=this.xrControllerRay.right;if(!e||e.length===0)return;let a={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let o=0;o<e.length;o++){let s=e[o].handedness,c=e[o].gamepad;switch(s){case`left`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`LeftAxesDown`,t)),c!=null&&c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`X`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`Y`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`LeftTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n};a.buttons.X=c.buttons&&c.buttons[4]?c.buttons[4].pressed:!1,a.buttons.Y=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.LeftTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.LeftPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1,a.left=e;break;case`right`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`RightAxesDown`,t)),c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`A`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`B`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`RightTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`RightPinch`,t)),a.right={raycaster:i,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n},a.buttons.A=c.buttons&&c.buttons[4]?c==null?void 0:c.buttons[4].pressed:!1,a.buttons.B=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.RightTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.RightPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,Q(`xr.controller.update`,a))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,i=this.xrControllerRay.right;if(e)this.xrHandleState[t].touchStart===!1?(this.xrHandleState[t].touchStartTime=n,this.xrHandleState[t].touchStart=!0,this.emit(`xr.gesture.buttonDown`,Q(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}))):n-this.xrHandleState[t].touchStartTime>Iy&&this.emit(`xr.gesture.press`,Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,Q(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}})),n-this.xrHandleState[t].touchStartTime<=Iy){let e=Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}});!this.emit(`xr.gesture.tap`,e)&&!e.defaultPrevented&&t===`RightTrigger`&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[t].touchStart=!1,this.xrHandleState[t].touchStartTime=0}}initHandEvent(){if(!this.xrManager.session)throw Error(`初始化失败`);this.xrManager.session.addEventListener(`select`,e=>{this.gazeRay&&this.checkSelectedPano(this.gazeRay)})}}},By={Floorplan:qg,Topview:Yg,Panorama:Y_,VRPanorama:Bv,Model:Gv,Mapview:Zv,XRPanorama:Py},Vy=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.fire,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.prepare,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function Hy(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=It(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 Uy(){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 Wy(){let e=new t.Group;e.name=`internalLights`;{let n=new t.DirectionalLight(16777215,.1);n.name=`direction0`,n.position.copy(new t.Vector3(0,1,0)),e.add(n)}{let n=new t.DirectionalLight(16777215,.1);n.name=`direction1`,n.position.copy(new t.Vector3(-1,-1,-1)),e.add(n)}{let n=new t.DirectionalLight(16777215,.3);n.name=`direction2`,n.position.copy(new t.Vector3(1,1,1)),e.add(n)}{let n=new t.AmbientLight(16777215,.6);n.name=`ambient0`,e.add(n)}return e}function Gy(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 Ky(){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=Gy((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var qy=`data:image/png;base64,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`,Jy=[351,63],Yy=[20,20],Xy=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),Zy=new Float32Array([0,0,1,0,0,1,1,1]),Qy=new Uint8Array([0,1,2,1,3,2]),$y=new t.BufferGeometry;$y.setAttribute(`position`,new t.BufferAttribute(Xy,3)),$y.setAttribute(`uv`,new t.BufferAttribute(Zy,2)),$y.setIndex(new t.BufferAttribute(Qy,1));var eb=new t.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),tb=new t.Mesh($y,eb);tb.matrixAutoUpdate=!1;var nb=new t.Scene;nb.add(tb),nb.matrixAutoUpdate=!1;var rb=new t.OrthographicCamera(-.5,.5,.5,-.5,.1,1);rb.position.set(0,0,.5),rb.lookAt(0,0,0),rb.updateMatrixWorld(!0),rb.matrixAutoUpdate=!1;var ib=new t.Vector4,ab=new t.Vector4;function ob(e){if(eb.map){let t=e.getViewport(ib),n=e.getScissor(ab),r=e.getScissorTest(),i=e.autoClear,a=n.x+Yy[0]/3,o=n.y+Yy[1]/3,s=Jy[0]/3,c=Jy[1]/3;e.setViewport(a,o,s,c),e.setScissor(a,o,s,c),e.setScissorTest(!0),e.autoClear=!1,e.render(nb,rb),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=i}else{let e=new t.Texture,n=new Image;n.onload=()=>{e.image=n,e.wrapS=t.ClampToEdgeWrapping,e.wrapT=t.ClampToEdgeWrapping,e.minFilter=t.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,eb.needsUpdate=!0,n.onload=G},n.src=qy,eb.map=e}}var sb=class{constructor(e=2048){this._count=0,this.width=e,this.height=1,this.data=new Uint32Array(this.width*this.height),this.texture=this.createTexture(this.data,this.width,this.height)}get count(){return this._count}createTexture(e,n,r){let i=new t.DataTexture(e,n,r,t.RedIntegerFormat,t.UnsignedIntType);return i.internalFormat=`R32UI`,i.minFilter=t.NearestFilter,i.magFilter=t.NearestFilter,i.generateMipmaps=!1,i.needsUpdate=!0,i}update(e){let t=e.length,n=Math.max(1,Math.ceil(t/this.width));n>this.height&&(this.height=n,this.data=new Uint32Array(this.width*this.height),this.texture.dispose(),this.texture=this.createTexture(this.data,this.width,this.height)),this.data.set(e,0),this._count=t,this.texture.needsUpdate=!0}dispose(){this.texture.dispose()}},cb=2,lb=8,ub=class{constructor(e){let n=e.numPoints,r=e.packedData;if(!r||r.length<n*lb)throw Error(`[TileTexture] object 缺少足量 packedData`);let i=n*cb,a=Math.max(1,Math.min(2048,i)),o=Math.max(1,Math.ceil(i/a)),s=new Uint32Array(a*o*4);s.set(r.subarray(0,n*lb),0);let c=new t.DataTexture(s,a,o,t.RGBAIntegerFormat,t.UnsignedIntType);c.internalFormat=`RGBA32UI`,c.minFilter=t.NearestFilter,c.magFilter=t.NearestFilter,c.generateMipmaps=!1,c.needsUpdate=!0,this.texture=c,this.count=n,this.width=a,this.height=o}dispose(){this.texture.dispose()}},db=2,fb=class e{constructor(n=2048){this.target=null,this.targetHeight=0,this.regionMap=new Map,this.regionList=[],this.width=n,this.material=new t.RawShaderMaterial({vertexShader:e.VERTEX,fragmentShader:e.FRAGMENT,uniforms:{u_tileTex:{value:null},u_tileWidth:{value:1},u_bigWidth:{value:n},u_startTexel:{value:0},u_count:{value:0},u_transformIndex:{value:0},u_layerIndex:{value:0}},depthTest:!1,depthWrite:!1}),this.scene=new t.Scene,this.mesh=new t.Mesh(new t.PlaneGeometry(2,2),this.material),this.mesh.frustumCulled=!1,this.scene.add(this.mesh),this.camera=new t.Camera}get texture(){return this.target?this.target.texture:null}get totalPoints(){let e=0;for(let t of this.regionList)e+=t.count;return e}get regions(){return this.regionList}has(e){return this.regionMap.has(e)}add(e,t,n,r){if(this.regionMap.has(e))return;let i={object:e,tile:t,start:0,count:t.count,transformIndex:n,layerIndex:r};this.regionMap.set(e,i),this.regionList.push(i)}sync(e,t){let n=new Set(e);for(let e of Array.from(this.regionMap.keys()))n.has(e)||(this.regionMap.get(e).tile.dispose(),this.regionMap.delete(e));let r=[];for(let n of e){let e=this.regionMap.get(n),{transformIndex:i,layerIndex:a}=t(n);e?(e.transformIndex=i,e.layerIndex=a):(e={object:n,tile:new ub(n),start:0,count:n.numPoints,transformIndex:i,layerIndex:a},this.regionMap.set(n,e)),r.push(e)}this.regionList=r}remove(e){let t=this.regionMap.get(e);if(!t)return;t.tile.dispose(),this.regionMap.delete(e);let n=this.regionList.indexOf(t);n>=0&&this.regionList.splice(n,1)}clear(){for(let e of this.regionList)e.tile.dispose();this.regionMap.clear(),this.regionList=[]}assemble(e){let n=0;for(let e of this.regionList)e.start=n,n+=e.count;let r=Math.max(1,Math.ceil(n*db/this.width));(!this.target||r>this.targetHeight)&&(this.target&&this.target.dispose(),this.targetHeight=r,this.target=new t.WebGLRenderTarget(this.width,r,{format:t.RGBAIntegerFormat,type:t.UnsignedIntType,minFilter:t.NearestFilter,magFilter:t.NearestFilter,depthBuffer:!1,stencilBuffer:!1}),this.target.texture.internalFormat=`RGBA32UI`,this.target.texture.generateMipmaps=!1);let i=e.getRenderTarget(),a=e.autoClear,o=e.getScissorTest(),s=e.getScissor(new t.Vector4),c=e.getPixelRatio()||1;e.autoClear=!1,e.setRenderTarget(this.target),e.setScissorTest(!0);for(let t of this.regionList){let n=t.start*db,r=(t.start+t.count)*db,i=Math.floor(n/this.width),a=Math.ceil(r/this.width),o=Math.max(0,Math.floor(i/c)-1),s=Math.ceil(a/c)+1,l=Math.ceil(this.width/c)+1;e.setScissor(0,o,l,s-o);let u=this.material.uniforms;u.u_tileTex.value=t.tile.texture,u.u_tileWidth.value=t.tile.width,u.u_bigWidth.value=this.width,u.u_startTexel.value=n,u.u_count.value=t.count,u.u_transformIndex.value=t.transformIndex,u.u_layerIndex.value=t.layerIndex,this.material.uniformsNeedUpdate=!0,e.render(this.scene,this.camera)}e.setScissorTest(o),e.setScissor(s),e.setRenderTarget(i),e.autoClear=a}snapshot(){return this.regionList.map(e=>Object.assign({},e))}extractSortInputs(){let e=this.totalPoints,t=new Float32Array(e*3),n=new Uint32Array(e);for(let e of this.regionList){let r=e.object.packedData;if(!r)continue;let i=new Float32Array(r.buffer,r.byteOffset,r.length),a=e.transformIndex;for(let r=0;r<e.count;r++){let o=e.start+r;t[o*3+0]=i[r*8+0],t[o*3+1]=i[r*8+1],t[o*3+2]=i[r*8+2],n[o]=a}}return{positions:t,transformIndices:n,count:e}}readback(e){if(!this.target)return new Uint32Array;let t=this.width,n=this.targetHeight,r=new Uint32Array(t*n*4),i=e.getRenderTarget();e.setRenderTarget(this.target);let a=e.getContext();return a.readPixels(0,0,t,n,a.RGBA_INTEGER,a.UNSIGNED_INT,r),e.setRenderTarget(i),r}dispose(){this.clear(),this.target&&(this.target.dispose(),this.target=null),this.mesh.geometry.dispose(),this.material.dispose()}};fb.VERTEX=`#version 300 es
2843
+ `},cy=class extends t.ShaderMaterial{constructor(e){super({uniforms:t.UniformsUtils.clone(sy.uniforms),vertexShader:sy.vertexShader,fragmentShader:sy.fragmentShader,clipping:!0}),this.type=`LineMaterial`,this.dashed=!1,Object.defineProperties(this,{color:{enumerable:!0,get(){return this.uniforms.diffuse.value},set(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get(){return this.uniforms.linewidth.value},set(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get(){return this.uniforms.dashScale.value},set(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get(){return this.uniforms.dashSize.value},set(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get(){return this.uniforms.gapSize.value},set(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get(){return this.uniforms.opacity.value},set(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get(){return this.uniforms.resolution.value},set(e){this.uniforms.resolution.value.copy(e)}}}),this.setValues(e)}};Object.assign(cy.prototype,{isLineMaterial:!0});var ly=class extends t.Mesh{constructor(e,t){super(),this.type=`LineSegments2`,this.geometry=e===void 0?new oy:e,this.material=t===void 0?new cy({color:Math.random()*16777215}):t}computeLineDistances(){let e=this.geometry,n=e.attributes.instanceStart,r=e.attributes.instanceEnd,i=new Float32Array(2*n.count),a=new t.Vector3,o=new t.Vector3;for(var s=0,c=0,l=n.count;s<l;s++,c+=2)a.fromBufferAttribute(n,s),o.fromBufferAttribute(r,s),i[c]=c===0?0:i[c-1],i[c+1]=i[c]+a.distanceTo(o);let u=new t.InstancedInterleavedBuffer(i,2,1);return e.setAttribute(`instanceDistanceStart`,new t.InterleavedBufferAttribute(u,1,0)),e.setAttribute(`instanceDistanceEnd`,new t.InterleavedBufferAttribute(u,1,1)),this}raycast(e,n){e.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let r=e.ray,i=e.camera,a=i.projectionMatrix,o=this.geometry,s=this.material,c=s.resolution,l=s.linewidth,u=o.attributes.instanceStart,d=o.attributes.instanceEnd,f=new t.Vector4,p=new t.Vector4,m=new t.Vector4,h=new t.Vector3,g=new t.Matrix4,_=new t.Line3,v=new t.Vector3;r.at(1,m),m.w=1,m.applyMatrix4(i.matrixWorldInverse),m.applyMatrix4(a),m.multiplyScalar(1/m.w),m.x*=c.x/2,m.y*=c.y/2,m.z=0,h.copy(m);let y=this.matrixWorld;g.multiplyMatrices(i.matrixWorldInverse,y);for(var b=0,x=u.count;b<x;b++){f.fromBufferAttribute(u,b),p.fromBufferAttribute(d,b),f.w=1,p.w=1,f.applyMatrix4(g),p.applyMatrix4(g),f.applyMatrix4(a),p.applyMatrix4(a),f.multiplyScalar(1/f.w),p.multiplyScalar(1/p.w);var S=f.z<-1&&p.z<-1,C=f.z>1&&p.z>1;if(S||C)continue;f.x*=c.x/2,f.y*=c.y/2,p.x*=c.x/2,p.y*=c.y/2,_.start.copy(f),_.start.z=0,_.end.copy(p),_.end.z=0;let e=_.closestPointToPointParameter(h,!0);_.at(e,v);let i=t.MathUtils.lerp(f.z,p.z,e),o=i>=-1&&i<=1;var w=h.distanceTo(v)<l*.5;if(o&&w){_.start.fromBufferAttribute(u,b),_.end.fromBufferAttribute(d,b),_.start.applyMatrix4(y),_.end.applyMatrix4(y);var T=new t.Vector3,E=new t.Vector3;r.distanceSqToSegment(_.start,_.end,E,T),n.push({point:E,pointOnLine:T,distance:r.origin.distanceTo(E),object:this,faceIndex:b})}}}};Object.assign(ly.prototype,{isLineSegments2:!0});var uy=class extends ly{constructor(e,t){super(e,t),this.type=`Line2`}};Object.assign(uy.prototype,{isLine2:!0});var dy=class extends oy{constructor(){super(),this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}fromLine(e){let n=e.geometry;if(n instanceof t.Geometry){let e=new t.BufferGeometry().fromGeometry(n);this.setPositions(e.attributes.position.array)}else n instanceof t.BufferGeometry&&this.setPositions(n.attributes.position.array);return this}copy(){return this}};Object.assign(dy.prototype,{isLineGeometry:!0});var fy=14467195,py=8,my=2,hy=20,gy=null,_y=class extends t.Object3D{static get version(){return`6.9.0`}constructor(e=new t.Vector3,n=new t.Vector3){super(),this.type=`FiveLine`,this.needsRender=!0;let r=new dy,i=new cy({color:fy,linewidth:my,dashScale:hy,dashed:!1});this.line=new uy(r,i);let a=new t.BufferGeometry,o=new t.PointsMaterial({color:fy,size:py,map:gy||(gy=new t.TextureLoader().load(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`)),sizeAttenuation:!1,transparent:!0});this.points=new t.Points(a,o),this.points.renderOrder=11,this.points.frustumCulled=!1,this.setPoints(e,n),this.add(this.line,this.points)}setPoints(e,n){let r=[].concat(e.toArray(),n.toArray());this.points.geometry.setAttribute(`position`,new t.BufferAttribute(new Float32Array(r),3)),this.line.geometry.setPositions(r),this.line.computeLineDistances(),this.needsRender=!0}getPoints(){let e=this.points.geometry.attributes.position.array;return[new t.Vector3(e[0],e[1],e[2]),new t.Vector3(e[3],e[4],e[5])]}setMaterial(e){let t=this.line.material;for(let n in e){if(!e.hasOwnProperty(n))continue;let r=e[n];n===`dashed`?(t.dashed=r,r?t.defines.USE_DASH=``:delete t.defines.USE_DASH,t.needsUpdate=!0):t[n]=e[n]}this.needsRender=!0}setResolution(e,t){let n=this.line.material.resolution;(n.x!==e||n.y!==t)&&(n.set(e,t),this.needsRender=!0)}};Object.assign(_y.prototype,{isFiveLine:!0});var vy={Handedness:Object.freeze({NONE:`none`,LEFT:`left`,RIGHT:`right`}),ComponentState:Object.freeze({DEFAULT:`default`,TOUCHED:`touched`,PRESSED:`pressed`}),ComponentProperty:Object.freeze({BUTTON:`button`,X_AXIS:`xAxis`,Y_AXIS:`yAxis`,STATE:`state`}),ComponentType:Object.freeze({TRIGGER:`trigger`,SQUEEZE:`squeeze`,TOUCHPAD:`touchpad`,THUMBSTICK:`thumbstick`,BUTTON:`button`}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:`transform`,VISIBILITY:`visibility`})};function yy(e){return Xo(this,void 0,void 0,function*(){let t=yield fetch(e);if(t.ok)return t.json();throw Error(t.statusText)})}function by(e){return Xo(this,void 0,void 0,function*(){if(!e)throw Error(`No basePath supplied`);return yield yy(`${e}/profilesList.json`)})}function xy(e,t){return Xo(this,arguments,void 0,function*(e,t,n=null,r=!0){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No basePath supplied`);let i=yield by(t),a;if(e.profiles.some(e=>{let n=i[e];return n&&(a={profileId:e,profilePath:`${t}/${n.path}`,deprecated:!!n.deprecated}),!!a}),!a){if(!n)throw Error(`No matching profile name found`);let e=i[n];if(!e)throw Error(`No matching profile name found and default profile "${n}" missing.`);a={profileId:n,profilePath:`${t}/${e.path}`,deprecated:!!e.deprecated}}let o=yield yy(a.profilePath),s;if(r){let t;if(t=o.layouts[e.handedness],!t)throw Error(`No matching handedness, ${e.handedness}, in profile ${a.profileId}`);t.assetPath&&(s=a.profilePath.replace(`profile.json`,t.assetPath))}return{profile:o,assetPath:s}})}var Sy={xAxis:0,yAxis:0,button:0,state:vy.ComponentState.DEFAULT};function Cy(e=0,t=0){let n=e,r=t;if(Math.sqrt(e*e+t*t)>1){let i=Math.atan2(t,e);n=Math.cos(i),r=Math.sin(i)}return{normalizedXAxis:n*.5+.5,normalizedYAxis:r*.5+.5}}var wy=class{constructor(e){this.componentProperty=e.componentProperty,this.states=e.states,this.valueNodeName=e.valueNodeName,this.valueNodeProperty=e.valueNodeProperty,this.valueNodeProperty===vy.VisualResponseProperty.TRANSFORM&&(this.minNodeName=e.minNodeName,this.maxNodeName=e.maxNodeName),this.value=0,this.updateFromComponent(Sy)}updateFromComponent({xAxis:e,yAxis:t,button:n,state:r}){let{normalizedXAxis:i,normalizedYAxis:a}=Cy(e,t);switch(this.componentProperty){case vy.ComponentProperty.X_AXIS:this.value=this.states.includes(r)?i:.5;break;case vy.ComponentProperty.Y_AXIS:this.value=this.states.includes(r)?a:.5;break;case vy.ComponentProperty.BUTTON:this.value=this.states.includes(r)?n:0;break;case vy.ComponentProperty.STATE:this.valueNodeProperty===vy.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(r):this.value=+!!this.states.includes(r);break;default:throw Error(`Unexpected visualResponse componentProperty ${this.componentProperty}`)}}},Ty=class{constructor(e,t){if(!e||!t||!t.visualResponses||!t.gamepadIndices||Object.keys(t.gamepadIndices).length===0)throw Error(`Invalid arguments supplied`);this.id=e,this.type=t.type,this.rootNodeName=t.rootNodeName,this.touchPointNodeName=t.touchPointNodeName,this.visualResponses={},Object.keys(t.visualResponses).forEach(e=>{let n=new wy(t.visualResponses[e]);this.visualResponses[e]=n}),this.gamepadIndices=Object.assign({},t.gamepadIndices),this.values={state:vy.ComponentState.DEFAULT,button:this.gamepadIndices.button===void 0?void 0:0,xAxis:this.gamepadIndices.xAxis===void 0?void 0:0,yAxis:this.gamepadIndices.yAxis===void 0?void 0:0}}get data(){return Object.assign({id:this.id},this.values)}updateFromGamepad(e){if(this.values.state=vy.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&e.buttons.length>this.gamepadIndices.button){let t=e.buttons[this.gamepadIndices.button];this.values.button=t.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,t.pressed||this.values.button===1?this.values.state=vy.ComponentState.PRESSED:(t.touched||this.values.button>vy.ButtonTouchThreshold)&&(this.values.state=vy.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&e.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=e.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===vy.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>vy.AxisTouchThreshold&&(this.values.state=vy.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&e.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=e.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===vy.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>vy.AxisTouchThreshold&&(this.values.state=vy.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(e=>{e.updateFromComponent(this.values)})}},Ey=class{constructor(e,t,n){if(!e)throw Error(`No xrInputSource supplied`);if(!t)throw Error(`No profile supplied`);this.xrInputSource=e,this.assetUrl=n,this.id=t.profileId,this.layoutDescription=t.layouts[e.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(e=>{let t=this.layoutDescription.components[e];this.components[e]=new Ty(e,t)}),this.updateFromGamepad()}get gripSpace(){return this.xrInputSource.gripSpace}get targetRaySpace(){return this.xrInputSource.targetRaySpace}get data(){let e=[];return Object.values(this.components).forEach(t=>{e.push(t.data)}),e}updateFromGamepad(){Object.values(this.components).forEach(e=>{e.updateFromGamepad(this.xrInputSource.gamepad)})}},Dy=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,Oy=`generic-trigger`,ky=class extends t.Object3D{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e instanceof t.Mesh&&e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(e=>{Object.values(e.visualResponses).forEach(e=>{let{valueNode:t,minNode:n,maxNode:r,value:i,valueNodeProperty:a}=e;t&&(a===vy.VisualResponseProperty.VISIBILITY?t.visible=i:a===vy.VisualResponseProperty.TRANSFORM&&(t.quaternion.copy(n.quaternion).slerp(r.quaternion,i),t.position.lerpVectors(n.position,r.position,i)))})}))}};function Ay(e,n){Object.values(e.components).forEach(e=>{let{type:r,touchPointNodeName:i,visualResponses:a}=e;if(r===vy.ComponentType.TOUCHPAD)if(e.touchPointNode=n.getObjectByName(i),e.touchPointNode){let n=new t.Mesh(new t.SphereGeometry(.001),new t.MeshBasicMaterial({color:255}));e.touchPointNode.add(n)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(a).forEach(e=>{let{valueNodeName:t,minNodeName:r,maxNodeName:i,valueNodeProperty:a}=e;if(a===vy.VisualResponseProperty.TRANSFORM){if(e.minNode=n.getObjectByName(r),e.maxNode=n.getObjectByName(i),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${i} in the model`);return}}e.valueNode=n.getObjectByName(t),e.valueNode||console.warn(`Could not find ${t} in the model`)})})}function jy(e,n){Ay(e.motionController,n),e.envMap&&n.traverse(n=>{n instanceof t.Mesh&&n.isMesh&&(n.material.envMap=e.envMap,n.material.needsUpdate=!0)}),e.add(n)}var My=class{constructor(e=null){this.gltfLoader=e,this.path=Dy,this._assetCache={}}createControllerModel(e){let t=new ky,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||xy(r,this.path,Oy).then(({profile:e,assetPath:i})=>{t.motionController=new Ey(r,e,i);let a=this._assetCache[t.motionController.assetUrl];if(a)n=a.scene.clone(),jy(t,n);else{if(!this.gltfLoader)throw Error(`GLTFLoader not set.`);this.gltfLoader.load(t.motionController.assetUrl,e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),jy(t,n)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},Ny=`fade`,Py=Object.assign({},fr(Y_,[`maxLatitude`,`minLatitude`]));function Fy(e,t){if(!t)return e;let n=e.match(/\d+_[a-z].png/);return e.substring(0,n.index)+t+`/`+e.substring(n.index)}var Iy=300,Ly=new t.Raycaster,Ry=new t.Vector3,zy={Floorplan:Jg,Topview:Xg,Panorama:X_,VRPanorama:Vv,Model:Kv,Mapview:Qv,XRPanorama:class e extends X_{static parseArgs(t){if(t instanceof e)return t;let n=Object.assign(Object.assign({},t),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return super.parseArgs(n)}static initAnimationEndState(e){let t=this.parseArgs(e),n=super.initAnimationEndState(t);return Object.assign(Object.assign({},n),{mode:`XRPanorama`})}constructor(e){super(e),this.xrManager=new ay(this.renderer,this.renderer.getContext(),{onSessionStart:e=>{this.emit(`xr.session.start`,Q(`xr.session.start`,{session:e,machineType:this.xrManager.machineType}))},onSessionEnd:()=>{this.emit(`xr.session.end`,Q(`xr.session.end`,{session:null,machineType:this.xrManager.machineType}))}}),this.xrControllerRay={left:new t.Raycaster,right:new t.Raycaster},this.xrControllerRay.left.params.Points={threshold:.1},this.xrControllerRay.left.firstHitOnly=!0,this.xrControllerRay.left.floorIndex=-1,this.xrControllerRay.right.params.Points={threshold:.1},this.xrControllerRay.right.firstHitOnly=!0,this.xrControllerRay.right.floorIndex=-1,this.gazeRay=null,this.pointerLines={left:new _y,right:new _y},this.pointerLines.left.visible=!1,this.pointerLines.right.visible=!0,this.pointerLines.left.setMaterial({color:new t.Vector3(1,1,1)}),this.pointerLines.left.points.material.depthTest=!1,this.pointerLines.right.setMaterial({color:new t.Vector3(1,1,1)}),this.pointerLines.right.points.material.depthTest=!1,this.controllerWrappers=[new t.Group,new t.Group];let n=this.xrManager.getController(0);this.controllerWrappers[0].add(n);let r=this.xrManager.getController(1);this.controllerWrappers[1].add(r);let i=new My;i.gltfLoader={load(e,t){ur.ajax(e,{responseType:`arraybuffer`}).then(t=>{var n;return Us(t.body,{resourcePath:e.slice(0,e.lastIndexOf(`/`)+1),search:(n=e.split(`?`)[1])==null?``:n,fetcher:ur})}).then(e=>t(e))}},(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`)&&this.scene.add(this.pointerLines.left,this.pointerLines.right,this.controllerWrappers[0],this.controllerWrappers[1]),this.panoResources={},this.panoResources[this.locationMotion.keyframes[0].key=this.locationMotion.keyframes[1].key=Zt()]={panoId:Z(this.currentPano),leftPanoPicture:null,position:this.camera.pose.offset.clone(),effect:Ny,effectEasing:G_,fixCameraTransform:new t.Matrix4},this.parallaxCameraMatrixs=[];let a=ei.shared.getContext();if(!a){console.error(`获取session失败,请退出重试`);return}this.on(`xr.session.end`,()=>{this.scene.remove(this.pointerLines.left,this.pointerLines.right)}),this.xrManager.setSession(a),this.on(`xr.session.start`,()=>{let e=this.xrManager.getControllerGrip(0);e.add(i.createControllerModel(e)),this.controllerWrappers[0].add(e);let t=this.xrManager.getControllerGrip(1);t.add(i.createControllerModel(t)),this.controllerWrappers[1].add(t)}),this.xrHandleState={LeftAxesUp:{touchStartTime:0,touchStart:!1},LeftAxesDown:{touchStartTime:0,touchStart:!1},LeftAxesLeft:{touchStartTime:0,touchStart:!1},LeftAxesRight:{touchStartTime:0,touchStart:!1},LeftTrigger:{touchStartTime:0,touchStart:!1},LeftPinch:{touchStartTime:0,touchStart:!1},RightAxesUp:{touchStartTime:0,touchStart:!1},RightAxesDown:{touchStartTime:0,touchStart:!1},RightAxesLeft:{touchStartTime:0,touchStart:!1},RightAxesRight:{touchStartTime:0,touchStart:!1},RightTrigger:{touchStartTime:0,touchStart:!1},RightPinch:{touchStartTime:0,touchStart:!1},Y:{touchStartTime:0,touchStart:!1},X:{touchStartTime:0,touchStart:!1},A:{touchStartTime:0,touchStart:!1},B:{touchStartTime:0,touchStart:!1}},this.xrManager.machineType===`VP`&&this.initHandEvent()}updateConfiguration(e){return super.updateConfiguration(Object.assign(Object.assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2}))}moveToPano(e,n,r){var i,a,o;this.userAction=r,this.stopMomentumMovement();let s=Z(e),c=this.works.getObserver(e);if(!c)throw Error(`Invalid PanoIndex`);let l=Kr(c.images.up),u=this.imageOptions.size;u===void 0&&c&&l&&(u=Number(l)),u===void 0&&(u=2048);let d=this.imageOptions.transform,f=(e,t)=>Fy(Wr(e,d,t)),p=Object.assign({key:`pano.${s}`},dr(this.imageOptions,[`format`,`size`,`quality`])),m={right:c.images.work.getURL(c.images.right),left:c.images.work.getURL(c.images.left),up:c.images.work.getURL(c.images.up),down:c.images.work.getURL(c.images.down),front:c.images.work.getURL(c.images.front),back:c.images.work.getURL(c.images.back)},h=`pano:`+Ip([m,p,d]);if(this.pendingPanoTask){if(this.pendingPanoTask.hash===h)return;{let t=this.pendingPanoTask.panoId;(i=this.panoMeshes.get(t))==null||i.setProgress(0),this.emit(`pano.texture.abort`,Q(`pano.texture.abort`,{error:null,progress:0,meta:null,pano:e}))}}let g=`move-to-pano-`+s;this.pending.add(g);let _=xg(`pano.prepare`,{options:n,prevMode:this.mode,prevPano:this.currentPano,pano:e});if(this.emit(`pano.prepare`,_),_.defaultPrevented){this.pending.delete(g);return}_.options!==n&&Object.assign(n,_.options);let v=this.modelScene.parameter,y;v.pano0&&v.pano0.map.name===h?y=v.pano0:v.pano1&&v.pano1.map.name===h&&(y=v.pano1);let b=(a=n.effect)==null?Ny:a,x=(o=n.effectEasing)==null?G_:o;if(y){let r={panoId:s,effect:b,effectEasing:x,leftPanoPicture:{panoId:y.panoId,map:y.map,mapHistogram:y.mapHistogram,mapSize:y.mapSize,matrix:c.matrix.clone().premultiply(c.work.transform),zoom:1},position:c.position.clone().applyMatrix4(c.work.transform),fixCameraTransform:new t.Matrix4};r.leftPanoPicture&&this.panoPictureObserverMap.set(r.leftPanoPicture,c),this.pendingPanoTask=void 0,Promise.resolve().then(()=>Sg(_)).catch(e=>{let t=Wg(e);return this.emit(`error`,t),t}).then(t=>{var i,a;if(!(t instanceof Error))this.pending.delete(g),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0),this.doMoveToPano(e,r,n);else{let e=null;t instanceof Error&&(e||(e=t));let r=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:r})),n.moveCancelCallback&&n.moveCancelCallback(),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:r})),e instanceof Error&&e.message&&this.emit(`error`,e),this.pending.delete(g),this.pendingPanoTask=void 0,(a=this.panoMeshes.get(s))==null||a.setProgress(0)}});return}let S=this.panoMeshes.get(s);S&&S.tap&&S.tap(),this.pendingPanoTask={panoId:s,hash:h,onLoad:r=>{var i;let a=r.body;if(this.destroyed)a.dispose();else{a.name=h;let r=Array.isArray(a.image)?a.image[0]:a.image,o=(i=r==null?void 0:r.width)==null?2048:i,l=new zm().formPixels(Rg(this.renderer,a,!0,Fm).data),u={panoId:s,effect:b,effectEasing:x,leftPanoPicture:{panoId:s,map:a,mapSize:o,mapHistogram:new t.Vector4().fromArray(l.toArray()),matrix:c.matrix.clone(),zoom:1},position:c.position.clone(),fixCameraTransform:new t.Matrix4};u.leftPanoPicture&&this.panoPictureObserverMap.set(u.leftPanoPicture,c),this.doMoveToPano(e,u,n)}},onError:e=>{let t=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{error:null,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:t})),this.emit(`pano.error`,Q(`pano.error`,{error:e,userAction:this.userAction,options:n,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.work.workCode},progress:0,state:t})),e instanceof Error&&e.message&&this.emit(`error`,e),n.moveCancelCallback&&n.moveCancelCallback()}},Promise.all([Promise.resolve().then(()=>{this.emit(`pano.texture.load`,Q(`pano.texture.load`,{error:null,progress:0,meta:null,pano:e}))}).then(()=>this.textureLoader.loadCubeTexture(m,{imageURL:{transform:f,options:p},format:t.RGBFormat,viaAjax:!0,fetcher:Gf(this.fiveId,c.work)},void 0,void 0,t=>{var n,r;this.emit(`pano.texture.progress`,Q(`pano.texture.progress`,{error:null,progress:t,meta:null,pano:e})),((n=this.pendingPanoTask)==null?void 0:n.hash)===h&&((r=this.panoMeshes.get(s))==null||r.setProgress(t))},this.renderer)).catch(t=>{let n=Wg(t);return this.emit(`pano.texture.error`,Q(`pano.texture.error`,{error:n,progress:0,meta:null,pano:e})),n}),Promise.resolve().then(()=>Sg(_)).catch(e=>Wg(e))]).then(([t,n])=>{var r,i,a,o;if(!(t instanceof Error)&&!(n instanceof Error))this.pending.delete(g),((r=this.pendingPanoTask)==null?void 0:r.hash)===h?(this.pendingPanoTask.onLoad(t),this.pendingPanoTask=void 0,(i=this.panoMeshes.get(s))==null||i.setProgress(0)):t.body.dispose(),this.emit(`pano.texture.success`,Q(`pano.texture.success`,{error:null,progress:1,meta:t.meta,pano:e}));else{let e=null;t instanceof Error?e||(e=t):t.body.dispose(),n instanceof Error&&(e||(e=n)),this.pending.delete(g),((a=this.pendingPanoTask)==null?void 0:a.hash)===h&&(this.pendingPanoTask.onError(e),this.pendingPanoTask=void 0,(o=this.panoMeshes.get(s))==null||o.setProgress(0))}})}doMoveToPano(e,n,r={}){var i,a,o,s,c,l,u,d,f,p;let m=V(),h=Zt();this.panoResources[h]=n;let g,_,v;if(this.locationMotion.ended){let[e,t]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(t).position,a=n.position;g=Math.max(i.distanceTo(a),1),_=[{key:t.key,progress:0,value:Object.assign(Object.assign({},r),{count:0})},{key:h,progress:1,value:{distance:0,count:1}}],v=0}else{let[e,t]=this.locationMotion.getKeyFrameSegment(m),r=this.locationMotion.value,i=this.panoResourceFromLocationMotionKeyframe(e).position,a=this.panoResourceFromLocationMotionKeyframe(t).position,o=n.position,s=t.value.count-r.count,c=Math.max(i.distanceTo(a),1)*s;g=c+Math.max(a.distanceTo(o),1),_=[{key:e.key,progress:0,value:Object.assign({},r)},{key:t.key,progress:c/g,value:t.value},{key:h,progress:1,value:{count:t.value.count+1,distance:0}}];let l=this.locationMotionKeyframesLength(this.locationMotion.keyframes),u=this.locationMotionKeyframesLength(_);v=this.locationMotion.getProgressVelocity(m)*l/u}let y=n.effect===`instant`?0:this.calculateMovingDuration(r.duration,n.effect===`fly`||n.effect===`model`?g:0),b={longitude:r.longitude,latitude:r.latitude,fov:r.fov},x=Object.assign(Object.assign({},e),{mode:this.mode,longitude:(i=b.longitude)==null?this.camera.pose.longitude:i,latitude:(a=b.latitude)==null?this.camera.pose.latitude:a,fov:(o=b.fov)==null?this.camera.pose.fov:o,offset:n.position.clone(),distance:0}),S=this.currentPano;if(this.emit(`pano.moveTo`,Q(`pano.moveTo`,{options:r,prevPano:S,pano:{panoIndex:x.panoIndex,workCode:x.workCode},progress:0,state:x,userAction:this.userAction,error:null})),r.moveStartCallback&&r.moveStartCallback(x),this.perspToOrthoMotion.set({perspToOrtho:0},y).catch(G),this.modelAlphaMotion.setKeyframes([{progress:0,value:Object.assign({},this.modelAlphaMotion.value)},{progress:.6,value:Object.assign({},this.modelAlphaMotion.value)},{progress:1,value:{modelAlpha:0}}],y).catch(G),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=G,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),n.effect===`fly`||n.effect===`model`)this.cameraMotion.set(b,y).catch(G);else{let e=It({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),r=It({longitude:(s=b.longitude)==null?this.cameraMotion.value.longitude:s,latitude:(c=b.latitude)==null?this.cameraMotion.value.latitude:c}),i=new t.Object3D;i.lookAt(e);let a=new t.Matrix4().makeRotationFromQuaternion(i.quaternion);i.lookAt(r);let o=new t.Matrix4().makeRotationFromQuaternion(i.quaternion),m=new t.Matrix4().getInverse(a).premultiply(o),h=this.cameraMotion.value.fov,g=(l=b.fov)==null?this.cameraMotion.value.fov:l,v=1;n.effect===`zoomin`?v=1.5:n.effect===`zoomout`&&(v=.4);let x=g*v;for(let e=0;e<_.length-1;e++){let t=_[e].key;if(t){let e=this.panoResources[t];e&&(e.fixCameraTransform.copy(m),e.leftPanoPicture&&(e.leftPanoPicture.zoom=Math.tan(x/2/180*Math.PI)/Math.tan(h/2/180*Math.PI)))}}this.cameraMotion.setKeyframes([{progress:0,value:{longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude,fov:this.cameraMotion.value.fov}},{progress:0,value:{longitude:(u=b.longitude)==null?this.cameraMotion.value.longitude:u,latitude:(d=b.latitude)==null?this.cameraMotion.value.latitude:d,fov:x}},{progress:1,value:{longitude:(f=b.longitude)==null?this.cameraMotion.value.longitude:f,latitude:(p=b.latitude)==null?this.cameraMotion.value.latitude:p,fov:g}}],y).catch(G)}this.locationMotion.setKeyframes(_,y,v).then(()=>{for(let e of this.modelScene.children)e instanceof up&&e.show();let t=Object.assign(Object.assign({},e),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:0});this.emit(`pano.arrived`,Q(`pano.arrived`,{options:r,prevPano:S,pano:{panoIndex:t.panoIndex,workCode:t.workCode},progress:1,state:t,userAction:this.userAction,error:null})),r.moveEndCallback&&r.moveEndCallback(t);let n=this.works.getObserver(this.currentPano);if(n&&n.images.video&&this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement){let e={map:this.videoTexture,size:n.images.video.size.clone(),matrix:n.images.video.matrix.clone(),panoMatrix:n.matrix.clone().premultiply(n.work.transform),alpha:1},t=Zt(),r=this.videoTexture.image;r.setAttribute(`uuid`,t),t_().then(i=>{i&&n.images.video&&r.getAttribute(`uuid`)===t&&(r.oncanplay=()=>{r.oncanplay=G,r.play()},r.ontimeupdate=()=>{r.currentTime>.5&&(r.ontimeupdate=G,this.panoVideo.setMaterial(e))},r.src=n.images.video.source)}).catch((()=>{r.removeAttribute(`uuid`)}))}},()=>{let e=Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose));this.emit(`pano.cancel`,Q(`pano.cancel`,{options:r,prevPano:S,pano:{panoIndex:e.panoIndex,workCode:e.workCode},progress:0,state:e,userAction:this.userAction,error:null})),r.moveCancelCallback&&r.moveCancelCallback()})}checkSelectedPano(e){var n;this.stopMomentumMovement(),this.camera.getDirection(new t.Vector3).setY(0);let r=null,i=this.works.getObserver(this.currentPano);if(!i)return null;let a=i.work.observers,o=i.accessibleNodes.filter(e=>{if(e===this.currentPano.panoIndex&&i.work.workCode===this.currentPano.workCode)return!1;let t=a[e];return!t||Ry.copy(t.position).applyMatrix4(t.work.transform).distanceTo(this.camera.position)>this.maxAccessibleDistance?!1:t.loadable||t.active}),[s]=this.modelScene.intersectRaycaster(e);if(s){let[e,t]=vu(o,e=>{let t=a[e];return t?Ry.copy(t.standingPosition).applyMatrix4(t.work.transform).distanceTo(s.point):1/0},!0);typeof e==`number`&&t<this.panoTapTriggerRadius&&(r=(n=a[e])==null?null:n)}if($v(r)){let t=this.getForwardObserverOrNot(this.xrManager.cameraVR,e);t&&(r=t)}for(let e of this.locationMotion.keyframes){let t=this.panoResourceFromLocationMotionKeyframe(e);if(!(e.progress<this.locationMotion.progress)&&r){let e=Z({panoIndex:r.panoIndex,workCode:r.work.workCode});if(t.panoId===e){r=null;break}}}if($v(r))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(!r.active){let e=Z({panoIndex:r.panoIndex,workCode:r.work.workCode}),t=this.panoMeshes.get(e);t&&(t.setDisabled(!1),t.setLoading(!0))}let c={workCode:r.work.workCode,panoIndex:r.panoIndex,mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,distance:0,offset:r?r.position.clone():new t.Vector3};return this.emit(`pano.select`,Q(`pano.select`,{prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.workCode},state:c,userAction:!0,options:{},progress:0,error:null})),r&&r.active?(this.emit(`pano.request`,Q(`pano.request`,{userAction:!0,prevPano:this.currentPano,pano:{panoIndex:c.panoIndex,workCode:c.workCode},progress:0,state:c,options:{},error:null})),{workCode:r.work.workCode,panoIndex:r.panoIndex}):null}destroy(){super.destroy()}isReady(){return!1}updateCamera(e,t,n){return Promise.resolve()}updateCameraWithKeyframes(e,t,n){return Promise.resolve()}updateTime(e,n,...r){var i,a,o,s,c,l,u,d,f;this.userAction=!0;let p={},m={},h=this.camera.getDirection(new t.Vector3),g=this.locationMotion.keyframes[0],_=this.locationMotion.keyframes[this.locationMotion.keyframes.length-1],[v,y]=this.locationMotion.getKeyFrameSegment(e),b=this.panoResourceFromLocationMotionKeyframe(v),x=this.panoResourceFromLocationMotionKeyframe(y),S=this.panoResourceFromLocationMotionKeyframe(g),C=this.panoResourceFromLocationMotionKeyframe(_),w=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),m.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),p.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(H(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);let n=this.locationMotion.value.count-y.value.count+1,r=new t.Vector3().copy(b.position),o=new t.Vector3().copy(x.position);if(p.progress=n,n>=.01&&n<=.99&&(p.progress=H(x.effectEasing(n),.01,.99)),x.leftPanoPicture&&(n<1?b.leftPanoPicture&&(p.pano0=b.leftPanoPicture):p.pano0=x.leftPanoPicture,p.pano1=x.leftPanoPicture),x.effect===`montage`?p.transition=`BLACK`:x.effect===`spread`?p.transition=`SPREAD`:p.transition=`FADE`,x.effect===`zoomin`||x.effect===`zoomout`?p.progress=Math.pow(n,3):x.effect===`model`&&this.camera.pose.distance<.01&&(p.modelAlpha=1-Math.pow(H(Math.abs(n-.5)*2,0,1),4)),n<1&&x.effect!==`fly`){if(p.pano0&&b.leftPanoPicture){let e={panoId:p.pano0.panoId,map:p.pano0.map,mapHistogram:p.pano0.mapHistogram,mapSize:p.pano0.mapSize,zoom:p.pano0.zoom,matrix:b.leftPanoPicture.matrix.clone().setPosition(x.position)},t=this.panoPictureObserverMap.get(p.pano0);t&&this.panoPictureObserverMap.set(e,t),p.pano0=e}r.copy(o),w=!0}m.distance=this.locationMotion.value.distance,m.offset=new t.Vector3(r.x+(o.x-r.x)*n,r.y+(o.y-r.y)*n,r.z+(o.z-r.z)*n);let s=[],c=[];for(let e of this.locationMotion.keyframes){let{key:t,progress:n}=e;t!==void 0&&(s.push(t),n>this.locationMotion.progress&&c.push(t))}for(let e of Object.keys(this.panoResources)){if(c.indexOf(e)>=0)continue;let t=this.panoResources[e];if(t.leftPanoPicture){let e=t.leftPanoPicture.map;if(e){if(e===((i=p.pano0)==null?void 0:i.map)||e===((a=p.pano1)==null?void 0:a.map))continue;e.dispose(),t.leftPanoPicture=null}}s.indexOf(e)>=0||delete this.panoResources[e]}let l=Rp(x.panoId);l!==this.currentPano&&(this.currentPano=l,this.accessibleObserverFloorCheckCount=0),this.emit(`pano.moving`,Q(`pano.moving`,{userAction:this.userAction,prevPano:Rp(S.panoId),pano:Rp(C.panoId),state:Object.assign(Object.assign(Object.assign(Object.assign({},Rp(C.panoId)),{mode:this.mode}),$(this.camera.pose)),m),options:{},progress:this.locationMotion.progress,error:null}))}this.camera.setFromPose(m),this.xrManager.cameraVR.projectionMatrix.copy(this.camera.projectionMatrix),this.xrManager.cameraVR.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse),this.xrManager.cameraVR.matrix.copy(this.camera.matrix),this.xrManager.cameraVR.position.copy(this.camera.position),this.xrManager.cameraVR.quaternion.copy(this.camera.quaternion),this.xrManager.cameraVR.scale.copy(this.camera.scale),this.xrManager.cameraVR.matrixAutoUpdate=!1,this.xrManager.cameraVR.matrixWorld.copy(this.camera.matrixWorld);let[T,E]=r,D=new t.Vector3(0,0,0),O=new t.Vector2().copy(this.camera.resolution);if(E&&this.xrManager.session&&this.xrManager.referenceSpace&&this.xrManager.session.renderState.baseLayer){let r=this.xrManager.cameraVR,i=this.xrManager.referenceSpace,a=this.xrManager.session.renderState.baseLayer,l=E.getViewerPose(i),u=(o=l==null?void 0:l.views)==null?[]:o;for(let e=0;e<u.length;e++){let t=u[e],n=r.cameras[e],i=a.getViewport(t);i&&(n.projectionMatrix.fromArray(t.projectionMatrix),n.projectionMatrixInverse.getInverse(n.projectionMatrix),n.matrix.fromArray(t.transform.matrix),n.matrix.setPosition(this.camera.position),n.matrix.decompose(n.position,n.quaternion,n.scale),n.matrixWorld.copy(n.matrix),n.matrixWorldInverse.getInverse(n.matrixWorld),n.matrixAutoUpdate=!1,D.copy(n.position),n.viewport.set(i.x,i.y,i.width,i.height),O.set(i.width,i.height))}if(this.xrManager.setProjectionFromUnion(this.xrManager.cameraVR,this.xrManager.cameraL,this.xrManager.cameraR),this.camera.quaternion.copy(this.xrManager.cameraVR.quaternion),this.camera.scale.copy(this.xrManager.cameraVR.scale),this.camera.matrix.compose(this.camera.position,this.camera.quaternion,this.camera.scale),this.camera.computePose((s=m.distance)==null?this.camera.pose.distance:s),this.xrManager.session.inputSources){for(let e=0;e<this.xrManager.session.inputSources.length;e++)if(this.xrManager.session.inputSources[e]&&this.xrManager.session.inputSources[e].targetRayMode===`transient-pointer`){let n=E.getPose(this.xrManager.session.inputSources[e].targetRaySpace,i);if(n){let e=n.transform.orientation,r=new t.Quaternion(e.x,e.y,e.z,e.w),i=new t.Vector3(0,0,-1).applyQuaternion(r),a=new t.Raycaster(this.camera.position,i);this.gazeRay=a}}}if(this.xrManager.machineType===`Oculus`||this.xrManager.machineType===`Pico`){let r=this.xrManager.session.inputSources;for(let e=0;e<r.length;e++){let n=this.xrManager.controllers[e],a=r[e];if(!a)continue;n&&n.update(a,E,i);let o=this.xrManager.getController(e),s=new t.Vector3(0,1.2,0),l=o.position.clone().add(D).sub(s);a.handedness===`left`?this.xrControllerRay.left.set(l,new t.Vector3(0,0,-1).applyEuler(o.rotation)):a.handedness===`right`&&this.xrControllerRay.right.set(l,new t.Vector3(0,0,-1).applyEuler(o.rotation)),this.controllerWrappers[e].position.copy(new t.Vector3(0,0,0).add(D).sub(s));let u=this.modelScene.intersectRaycaster(this.xrControllerRay.right);if(u.length===0){let e=this.works.getResolvedObserver(this.currentPano);u=this.xrControllerRay.right.intersectObject(this.modelScene.boundingMesh,!0).map(t=>{var n;let r=(n=e==null?void 0:e.floorIndex)==null?0:n;return Object.assign({floorIndex:r,floor:r},t)})}if(u.length>=1&&u[0].face)if(a.handedness===`right`){let e=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),t=u[0].face.normal,n=t.clone(),r=u[0].point.clone();this.intersectMesh.position.copy(r);let i=r.clone().add(n);if(this.intersectMesh.lookAt(i),Math.abs(t.y)>.99){let e=this.camera.position.clone().sub(r);this.intersectMesh.rotation.z=-Math.atan2(e.z,e.x)}this.intersectMesh.visible=!0,this.needsRender=!0,e.length>0?(this.pointerLines.right.setPoints(l,e[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(l,u[0].point));let a=u[0],o=Q(`intersect.update`,{raycaster:(c=this.xrControllerRay.right)==null?null:c,intersection:a==null?null:a,object:this.intersectMesh});if(this.emit(`intersect.update`,o),o.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(l,u[0].point)}this.updateControllerHelper(r,e,n)}}else E||console.error(`xrFrame丢失,请重试`),this.xrManager.session||console.error(`session丢失,请重试`),this.xrManager.session&&!this.xrManager.session.renderState.baseLayer&&console.error(`no layer found`);Ag(p)===!1&&this.modelScene.parameter.set(p),this.emit(`camera.update`,Q(`camera.update`,{userAction:this.userAction,state:Object.assign(Object.assign(Object.assign({},this.currentPano),{mode:this.mode}),$(this.camera.pose))}));let k=this.works.getResolvedObserver(this.currentPano),A=this.locationMotion.ended?this.getForwardObserverOrNot(this.xrManager.cameraVR):null,j=this.works.getObserver(b.panoId),M=this.works.getObserver(x.panoId);if(this.adjustPanoCircleMeshPositionBasedOnModel&&this.helper.visible&&k){let e=[],n=k.work.observers;for(let t of k.accessibleNodes){let r=n[t];r&&e.push(r)}let r=new Map;if(e.sort((e,t)=>{let n=r.get(e);n===void 0&&(n=e.standingPosition.distanceTo(k.standingPosition),r.set(e,n));let i=r.get(e);return i===void 0&&(i=t.standingPosition.distanceTo(k.standingPosition),r.set(t,i)),n-i}),e.length){this.accessibleObserverFloorCheckCount%=e.length;let n=e[this.accessibleObserverFloorCheckCount],r=this.modelScene.models.find(e=>e.work===(n==null?void 0:n.work));if(n&&r&&r.visible){let e=.3,i=.005,a=n.standingPosition.clone().applyMatrix4(n.work.transform),o=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),s=J_.map(n=>{Ly.ray.origin.copy(a),Ly.ray.origin.add(Ry.copy(n).setY(e)),Ly.ray.direction.set(0,-1,0),Ly.firstHitOnly=!0,Ly.floorIndex=-1;let[o]=r.intersectRaycaster(Ly);return o&&o.distance-i<=e?new t.Vector3().copy(a).setY(o.point.y+i):a});s.sort((e,t)=>t.y-e.y);let c=s[Math.floor(s.length/2)],[l]=s.filter(e=>e.distanceTo(c)<=.05);if(l){let e=new t.Vector4(a.x,a.y,a.z,l.y-a.y),n=this.adjustPanoCircleMeshPositionFix.get(o);n&&!e.equals(n)&&(this.needsRender=!0),this.adjustPanoCircleMeshPositionFix.set(o,e)}}this.accessibleObserverFloorCheckCount++}}let N=new Map;if(j)for(let e of j.accessibleNodes){let t=j.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(M)for(let e of M.accessibleNodes){let t=M.work.observers[e];if(t){let e=Z({panoIndex:t.panoIndex,workCode:t.work.workCode});N.set(e,t)}}if(this.panoMeshes.forEach((e,t)=>{N.get(t)?N.delete(t):(this.helper.remove(e),e.dispose(),this.panoMeshes.delete(t))}),N.forEach((e,t)=>{let n=this.panoCircleMeshCreator(e,{aerialObserverMinHeight:this.aerialObserverMinHeight});this.panoMeshes.set(t,n),this.helper.add(n),N.delete(t)}),this.panoMeshes.forEach((e,n)=>{let r=this.works.getObserver(n);if(r){let i=r.position.distanceTo(r.standingPosition)>this.aerialObserverMinHeight;if(i)e.position.copy(r.position).applyMatrix4(r.work.transform),e.scale.setScalar(18);else{e.position.copy(r.standingPosition).applyMatrix4(r.work.transform);let t=this.adjustPanoCircleMeshPositionFix.get(r.panoId);t&&(Ry.set(t.x,t.y,t.z),Ry.equals(e.position)&&(e.position.y+=t.w)),e.scale.setScalar(1.2)}let a=this.camera.position.clone().setY(e.position.y),o=new t.Vector3().copy(e.position).sub(a).normalize();if(n===Z(this.currentPano)){let t=H((.5-a.distanceTo(e.position))/.5,0,1);o.multiplyScalar(1-t).add(h.clone().multiplyScalar(t))}if(o.length()>0){let n=i?-Math.PI/2:0,r=Math.atan2(o.x,o.z);e.quaternion.setFromEuler(new t.Euler(n,r,0,`YXZ`))}}else e.visible=!1}),this.camera.pose.distance>.1||w)this.panoMeshes.forEach(t=>{t.setOpacity(0),t.setCurrent(!1),t.updateTime&&t.updateTime(e,n),t.visible=!1});else if(k){let t=k.work.observers,[,r]=vu(k.accessibleNodes,e=>{let n=t[e];return!n||!n.active?1/0:k.standingPosition.distanceTo(n.standingPosition)},!0);r=H(r,2.5,1/0);let i=k.accessibleNodes.concat(k.panoIndex).map(e=>Z({panoIndex:e,workCode:k.work.workCode}));this.panoMeshes.forEach((t,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=t.position.clone().project(this.camera);s=Math.abs(e.x)<1&&Math.abs(e.y)<1&&Math.abs(e.z)<1&&!t.loading&&t.progress===0&&A!==null&&Z({panoIndex:A.panoIndex,workCode:A.work.workCode})===a;let n=t.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);c=n<.01?0:H(r/n,.1,.85)}o&&o===M&&o.position.distanceTo(o.standingPosition)>this.aerialObserverMinHeight&&t.position.distanceTo(this.camera.position)<35&&(c=0),this.modelScene.parameter.resolveValue(`modelAlpha`)>0&&(c=0),t.setCurrent(s),t.setOpacity(c),t.updateTime&&t.updateTime(e,n)})}{let e=(l=this.modelScene.parameter.progress)==null?1:l,n=Math.round(e),r=this.modelScene.parameter.pano0,i=this.modelScene.parameter.pano1,a=n===0?r:i,o;if(a&&(o=this.works.getObserver(a.panoId),o||(o=this.panoPictureObserverMap.get(a))),this.tiling.appearDuration=this.tileAppearDuration,this.tiling.maxRequest=e<(ii()?.6:.99)?0:this.tileMaxRequest,this.tiling.imageOptions=this.imageOptions,!o||!a||this.tileLevelForFov===!1||this.camera.perspToOrtho.x>0){this.tiling.setObserver(null);let e={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:null,panoMatrix:new t.Matrix4,panoZoom:1,minLevel:0,level:0};this.tiling.update(e),this.modelScene.parameter.set(`refinedScreen`,null)}else{let e=Yr(a.mapSize)+1;this.tiling.setObserver(o);let t={renderer:this.renderer,resolution:O,pixelRatio:1,time:this.camera.time,cameraMatrix:this.xrManager.cameraVR.matrixWorld,cameraProjectionMatrix:this.xrManager.cameraVR.projectionMatrix,panoMap:a.map,panoMatrix:a.matrix,panoZoom:a.zoom,minLevel:e,level:4},s=this.tiling.update(t),c={map:this.tiling.renderTarget.texture,matrixInverse:this.tiling.camera.matrixWorldInverse,projectionMatrix:this.tiling.camera.projectionMatrix,pano:n,opacity:(r==null?void 0:r.panoId)===(i==null?void 0:i.panoId)?1:Ed(Math.abs(((u=this.modelScene.parameter.progress)==null?0:u)-.5)*2)},l=this.modelScene.parameter.refinedScreen;(s||c.pano!==(l==null?void 0:l.pano)||c.opacity!==(l==null?void 0:l.opacity))&&this.modelScene.parameter.set(`refinedScreen`,c)}}if(this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e),this.intersectMesh&&this.intersectMesh.parent&&k&&k.position.y-k.standingPosition.y>10){let e=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=x.effect,{pano0:n,pano1:r}=this.modelScene.parameter;if(n&&r&&n!==r&&(e===`fly`||e===`model`)&&this.flyEffectUseDepthBuffer){if(((d=this.modelScene.parameter.pano0Depth)==null?void 0:d.panoId)!==n.panoId||((f=this.modelScene.parameter.pano1Depth)==null?void 0:f.panoId)!==r.panoId){this.pano0DepthCubeRenderTarget?this.pano0DepthCubeRenderTarget.width!==512&&this.pano0DepthCubeRenderTarget.setSize(512,512):this.pano0DepthCubeRenderTarget=new t.WebGLCubeRenderTarget(512,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,generateMipmaps:!1}),this.pano1DepthCubeRenderTarget?this.pano1DepthCubeRenderTarget.width!==512&&this.pano1DepthCubeRenderTarget.setSize(512,512):this.pano1DepthCubeRenderTarget=new t.WebGLCubeRenderTarget(512,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,generateMipmaps:!1});let e=new t.CubeCamera(this.camera.near,this.camera.far,this.pano0DepthCubeRenderTarget);e.matrix.copy(n.matrix),e.matrixWorld.copy(e.matrix),e.matrixAutoUpdate=!1,U_(this.renderer,this.modelScene,e,500);let i=new t.CubeCamera(this.camera.near,this.camera.far,this.pano1DepthCubeRenderTarget);i.matrix.copy(r.matrix),i.matrixWorld.copy(i.matrix),i.matrixAutoUpdate=!1,U_(this.renderer,this.modelScene,i,500),this.modelScene.parameter.set({pano0Depth:{panoId:n.panoId,map:this.pano0DepthCubeRenderTarget.texture,mapSize:this.pano0DepthCubeRenderTarget.width,maxDepth:500},pano1Depth:{panoId:r.panoId,map:this.pano1DepthCubeRenderTarget.texture,mapSize:this.pano1DepthCubeRenderTarget.width,maxDepth:500}})}}else this.modelScene.parameter.set({pano0Depth:null,pano1Depth:null}),this.flyEffectUseDepthBuffer||(this.pano0DepthCubeRenderTarget&&(this.pano0DepthCubeRenderTarget.dispose(),this.pano0DepthCubeRenderTarget=void 0),this.pano1DepthCubeRenderTarget&&(this.pano1DepthCubeRenderTarget.dispose(),this.pano1DepthCubeRenderTarget=void 0))}}render(){if(this.xrManager.session&&this.xrManager.session.renderState.baseLayer){let e=this.xrManager.session.renderState.baseLayer;return this.renderer.setRenderTarget(null),this.renderer.setScissorTest(!1),this.renderer.setFramebuffer(e.framebuffer),this.renderer.render(this.scene,this.xrManager.cameraVR),this.renderer.setFramebuffer(null),!0}return!1}onPanGesture(){}onTapGesture(){}onPinchGesture(){}onMouseMove(){}onMouseOut(){}panoResourceFromLocationMotionKeyframe(e){return this.panoResources[e.key]}updateControllerHelper(e,t,n){let r=this.xrControllerRay.left,i=this.xrControllerRay.right;if(!e||e.length===0)return;let a={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}};for(let o=0;o<e.length;o++){let s=e[o].handedness,c=e[o].gamepad;switch(s){case`left`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`LeftAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`LeftAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`LeftAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`LeftAxesDown`,t)),c!=null&&c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`X`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`Y`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`LeftTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`LeftPinch`,t));let e={raycaster:r,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n};a.buttons.X=c.buttons&&c.buttons[4]?c.buttons[4].pressed:!1,a.buttons.Y=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.LeftTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.LeftPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1,a.left=e;break;case`right`:c.axes&&(this.emitHandleEvent(c.axes[2]===-1,`RightAxesLeft`,t),this.emitHandleEvent(c.axes[2]===1,`RightAxesRight`,t),this.emitHandleEvent(c.axes[3]===-1,`RightAxesUp`,t),this.emitHandleEvent(c.axes[3]===1,`RightAxesDown`,t)),c.buttons&&(c.buttons[4]&&this.emitHandleEvent(c.buttons[4].pressed,`A`,t),c.buttons[5]&&this.emitHandleEvent(c.buttons[5].pressed,`B`,t),c.buttons[0]&&this.emitHandleEvent(c.buttons[0].pressed,`RightTrigger`,t),c.buttons[1]&&this.emitHandleEvent(c.buttons[1].pressed,`RightPinch`,t)),a.right={raycaster:i,axes:{up:c.axes&&c.axes[3]<0?Math.abs(c.axes[3]):0,down:c.axes&&c.axes[3]<0?0:Math.abs(c.axes[3]),left:c.axes&&c.axes[2]<0?Math.abs(c.axes[2]):0,right:c.axes&&c.axes[2]<0?0:Math.abs(c.axes[2])},deltaTime:n},a.buttons.A=c.buttons&&c.buttons[4]?c==null?void 0:c.buttons[4].pressed:!1,a.buttons.B=c.buttons&&c.buttons[5]?c==null?void 0:c.buttons[5].pressed:!1,a.buttons.RightTrigger=c.buttons&&c.buttons[0]?c==null?void 0:c.buttons[0].pressed:!1,a.buttons.RightPinch=c.buttons&&c.buttons[1]?c==null?void 0:c.buttons[1].pressed:!1;break;default:break}}this.emit(`xr.controller.update`,Q(`xr.controller.update`,a))}emitHandleEvent(e,t,n){let r=this.xrControllerRay.left,i=this.xrControllerRay.right;if(e)this.xrHandleState[t].touchStart===!1?(this.xrHandleState[t].touchStartTime=n,this.xrHandleState[t].touchStart=!0,this.emit(`xr.gesture.buttonDown`,Q(`xr.gesture.buttonDown`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}))):n-this.xrHandleState[t].touchStartTime>Iy&&this.emit(`xr.gesture.press`,Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:r,rightRay:i}}}));else if(this.xrHandleState[t].touchStart===!0){if(this.emit(`xr.gesture.buttonUp`,Q(`xr.gesture.buttonUp`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}})),n-this.xrHandleState[t].touchStartTime<=Iy){let e=Q(`xr.gesture.tap`,{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:t,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:r,rightRay:i}}});!this.emit(`xr.gesture.tap`,e)&&!e.defaultPrevented&&t===`RightTrigger`&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[t].touchStart=!1,this.xrHandleState[t].touchStartTime=0}}initHandEvent(){if(!this.xrManager.session)throw Error(`初始化失败`);this.xrManager.session.addEventListener(`select`,e=>{this.gazeRay&&this.checkSelectedPano(this.gazeRay)})}}},By={Floorplan:qg,Topview:Yg,Panorama:Y_,VRPanorama:Bv,Model:Gv,Mapview:Zv,XRPanorama:Py},Vy=`gesture.pan,gesture.tap,gesture.dbltap,gesture.press,gesture.pinch,gesture.mousewheel,gesture.mousemove,gesture.momentum,gesture.fire,initAnimation.start,initAnimation.end,camera.update,intersect.update,pano.select,pano.moveTo,pano.moving,pano.arrived,pano.cancel,pano.error,pano.prepare,pano.texture.load,pano.texture.progress,pano.texture.success,pano.texture.error,pano.texture.abort,xr.session.start,xr.session.end,xr.gesture.tap,xr.gesture.press,xr.gesture.buttonUp,xr.gesture.buttonDown,xr.controller.update`.split(`,`);function Hy(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=It(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 Uy(){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 Wy(){let e=new t.Group;e.name=`internalLights`;{let n=new t.DirectionalLight(16777215,.1);n.name=`direction0`,n.position.copy(new t.Vector3(0,1,0)),e.add(n)}{let n=new t.DirectionalLight(16777215,.1);n.name=`direction1`,n.position.copy(new t.Vector3(-1,-1,-1)),e.add(n)}{let n=new t.DirectionalLight(16777215,.3);n.name=`direction2`,n.position.copy(new t.Vector3(1,1,1)),e.add(n)}{let n=new t.AmbientLight(16777215,.6);n.name=`ambient0`,e.add(n)}return e}function Gy(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 Ky(){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=Gy((e=r.getAttribute(`content`))==null?``:e),n=Number(t[`initial-scale`]);if(!isNaN(n))return n}}}return 1}var qy=`data:image/png;base64,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`,Jy=[351,63],Yy=[20,20],Xy=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),Zy=new Float32Array([0,0,1,0,0,1,1,1]),Qy=new Uint8Array([0,1,2,1,3,2]),$y=new t.BufferGeometry;$y.setAttribute(`position`,new t.BufferAttribute(Xy,3)),$y.setAttribute(`uv`,new t.BufferAttribute(Zy,2)),$y.setIndex(new t.BufferAttribute(Qy,1));var eb=new t.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),tb=new t.Mesh($y,eb);tb.matrixAutoUpdate=!1;var nb=new t.Scene;nb.add(tb),nb.matrixAutoUpdate=!1;var rb=new t.OrthographicCamera(-.5,.5,.5,-.5,.1,1);rb.position.set(0,0,.5),rb.lookAt(0,0,0),rb.updateMatrixWorld(!0),rb.matrixAutoUpdate=!1;var ib=new t.Vector4,ab=new t.Vector4;function ob(e){if(eb.map){let t=e.getViewport(ib),n=e.getScissor(ab),r=e.getScissorTest(),i=e.autoClear,a=n.x+Yy[0]/3,o=n.y+Yy[1]/3,s=Jy[0]/3,c=Jy[1]/3;e.setViewport(a,o,s,c),e.setScissor(a,o,s,c),e.setScissorTest(!0),e.autoClear=!1,e.render(nb,rb),e.setViewport(t),e.setScissor(n),e.setScissorTest(r),e.autoClear=i}else{let e=new t.Texture,n=new Image;n.onload=()=>{e.image=n,e.wrapS=t.ClampToEdgeWrapping,e.wrapT=t.ClampToEdgeWrapping,e.minFilter=t.LinearFilter,e.needsUpdate=!0,e.generateMipmaps=!1,eb.needsUpdate=!0,n.onload=G},n.src=qy,eb.map=e}}var sb=class{constructor(e=2048){this._count=0,this.width=e,this.height=1,this.data=new Uint32Array(this.width*this.height),this.texture=this.createTexture(this.data,this.width,this.height)}get count(){return this._count}createTexture(e,n,r){let i=new t.DataTexture(e,n,r,t.RedIntegerFormat,t.UnsignedIntType);return i.internalFormat=`R32UI`,i.minFilter=t.NearestFilter,i.magFilter=t.NearestFilter,i.generateMipmaps=!1,i.needsUpdate=!0,i}update(e){let t=e.length,n=Math.max(1,Math.ceil(t/this.width));n>this.height&&(this.height=n,this.data=new Uint32Array(this.width*this.height),this.texture.dispose(),this.texture=this.createTexture(this.data,this.width,this.height)),this.data.set(e,0),this._count=t,this.texture.needsUpdate=!0}dispose(){this.texture.dispose()}},cb=2,lb=8,ub=class{constructor(e){let n=e.numPoints,r=e.packedData;if(!r||r.length<n*lb)throw Error(`[TileTexture] object 缺少足量 packedData`);let i=n*cb,a=Math.max(1,Math.min(2048,i)),o=Math.max(1,Math.ceil(i/a)),s=new Uint32Array(a*o*4);s.set(r.subarray(0,n*lb),0);let c=new t.DataTexture(s,a,o,t.RGBAIntegerFormat,t.UnsignedIntType);c.internalFormat=`RGBA32UI`,c.minFilter=t.NearestFilter,c.magFilter=t.NearestFilter,c.generateMipmaps=!1,c.needsUpdate=!0,this.texture=c,this.count=n,this.width=a,this.height=o}dispose(){this.texture.dispose()}},db=2,fb=class e{constructor(n=2048){this.target=null,this.targetHeight=0,this.regionMap=new Map,this.regionList=[],this.width=n,this.material=new t.RawShaderMaterial({vertexShader:e.VERTEX,fragmentShader:e.FRAGMENT,uniforms:{u_tileTex:{value:null},u_tileWidth:{value:1},u_bigWidth:{value:n},u_startTexel:{value:0},u_count:{value:0},u_transformIndex:{value:0},u_layerIndex:{value:0}},depthTest:!1,depthWrite:!1}),this.scene=new t.Scene,this.mesh=new t.Mesh(new t.PlaneGeometry(2,2),this.material),this.mesh.frustumCulled=!1,this.scene.add(this.mesh),this.camera=new t.Camera}get texture(){return this.target?this.target.texture:null}get totalPoints(){let e=0;for(let t of this.regionList)e+=t.count;return e}get regions(){return this.regionList}has(e){return this.regionMap.has(e)}add(e,t,n,r){if(this.regionMap.has(e))return;let i={object:e,tile:t,start:0,count:t.count,transformIndex:n,layerIndex:r};this.regionMap.set(e,i),this.regionList.push(i)}sync(e,t){let n=new Set(e);for(let e of Array.from(this.regionMap.keys()))n.has(e)||(this.regionMap.get(e).tile.dispose(),this.regionMap.delete(e));let r=[];for(let n of e){let e=this.regionMap.get(n),{transformIndex:i,layerIndex:a}=t(n);e?(e.transformIndex=i,e.layerIndex=a):(e={object:n,tile:new ub(n),start:0,count:n.numPoints,transformIndex:i,layerIndex:a},this.regionMap.set(n,e)),r.push(e)}this.regionList=r}remove(e){let t=this.regionMap.get(e);if(!t)return;t.tile.dispose(),this.regionMap.delete(e);let n=this.regionList.indexOf(t);n>=0&&this.regionList.splice(n,1)}clear(){for(let e of this.regionList)e.tile.dispose();this.regionMap.clear(),this.regionList=[]}assemble(e){let n=0;for(let e of this.regionList)e.start=n,n+=e.count;let r=Math.max(1,Math.ceil(n*db/this.width));(!this.target||r>this.targetHeight)&&(this.target&&this.target.dispose(),this.targetHeight=r,this.target=new t.WebGLRenderTarget(this.width,r,{format:t.RGBAIntegerFormat,type:t.UnsignedIntType,minFilter:t.NearestFilter,magFilter:t.NearestFilter,depthBuffer:!1,stencilBuffer:!1}),this.target.texture.internalFormat=`RGBA32UI`,this.target.texture.generateMipmaps=!1);let i=e.getRenderTarget(),a=e.autoClear,o=e.getScissorTest(),s=e.getScissor(new t.Vector4),c=e.getPixelRatio()||1;e.autoClear=!1,e.setRenderTarget(this.target),e.setScissorTest(!0);for(let t of this.regionList){let n=t.start*db,r=(t.start+t.count)*db,i=Math.floor(n/this.width),a=Math.ceil(r/this.width),o=Math.max(0,Math.floor(i/c)-1),s=Math.ceil(a/c)+1,l=Math.ceil(this.width/c)+1;e.setScissor(0,o,l,s-o);let u=this.material.uniforms;u.u_tileTex.value=t.tile.texture,u.u_tileWidth.value=t.tile.width,u.u_bigWidth.value=this.width,u.u_startTexel.value=n,u.u_count.value=t.count,u.u_transformIndex.value=t.transformIndex,u.u_layerIndex.value=t.layerIndex,this.material.uniformsNeedUpdate=!0,e.render(this.scene,this.camera)}e.setScissorTest(o),e.setScissor(s),e.setRenderTarget(i),e.autoClear=a}snapshot(){return this.regionList.map(e=>Object.assign({},e))}extractSortInputs(){let e=this.totalPoints,t=new Float32Array(e*3),n=new Uint32Array(e);for(let e of this.regionList){let r=e.object.packedData;if(!r)continue;let i=new Float32Array(r.buffer,r.byteOffset,r.length),a=e.transformIndex;for(let r=0;r<e.count;r++){let o=e.start+r;t[o*3+0]=i[r*8+0],t[o*3+1]=i[r*8+1],t[o*3+2]=i[r*8+2],n[o]=a}}return{positions:t,transformIndices:n,count:e}}readback(e){if(!this.target)return new Uint32Array;let t=this.width,n=this.targetHeight,r=new Uint32Array(t*n*4),i=e.getRenderTarget();e.setRenderTarget(this.target);let a=e.getContext();return a.readPixels(0,0,t,n,a.RGBA_INTEGER,a.UNSIGNED_INT,r),e.setRenderTarget(i),r}dispose(){this.clear(),this.target&&(this.target.dispose(),this.target=null),this.mesh.geometry.dispose(),this.material.dispose()}};fb.VERTEX=`#version 300 es
2844
2844
  in vec3 position;
2845
2845
  void main() {
2846
2846
  gl_Position = vec4(position.xy, 0.0, 1.0);
@@ -2950,4 +2950,4 @@ Aj$\\0 \\0\\v†
2950
2950
  *\\0 ”
2951
2951
  * ”’’’! \\v!
2952
2952
  \\v  j   ”  ”  ”’’’¼"\\v \\vAsAÿÿÿÿ\\x07q \\vA\\0H\\x1B"\\v6\\0 \\b \\vAÿÿqAtj" (\\0Aj6\\0 \\vAvAüÿqj"\\v \\v(\\0Aj6\\0 \\fAj!\\f\\f\\v\\v\\v\\0\\v\\v \\0A\\b\\v\`)}function v(e){return e}function y(e,t){var n,r=v(e);return n=new WebAssembly.Module(r),[new WebAssembly.Instance(n,t),n]}function b(){return{a:F}}function x(){function e(e,t){return L=e.exports,P(L),f(),L}var t=b();return r.instantiateWasm?new Promise((n,i)=>{r.instantiateWasm(t,(t,r)=>{n(e(t,r))})}):(g!=null||(g=_()),e(y(g,t)[0]))}for(var S=e=>{for(;e.length>0;)e.shift()(r)},C=[],w=e=>C.push(e),T=[],E=e=>T.push(e),D=()=>2147483648,O=(e,t)=>Math.ceil(e/t)*t,k=e=>{var t=(e-N.buffer.byteLength+65535)/65536|0;try{return N.grow(t),f(),1}catch(e){}},A=e=>{var t=u.length;e>>>=0;var n=D();if(e>n)return!1;for(var r=1;r<=4;r*=2){var i=t*(1+.2/r);if(i=Math.min(i,e+100663296),k(Math.min(n,O(Math.max(e,i),65536))))return!0}return!1},j=new Uint8Array(123),M=25;M>=0;--M)j[48+M]=52+M,j[65+M]=M,j[97+M]=26+M;if(j[43]=62,j[47]=63,r.noExitRuntime&&r.noExitRuntime,r.print&&r.print,r.printErr&&r.printErr,r.wasmBinary&&r.wasmBinary,r.arguments&&r.arguments,r.thisProgram&&r.thisProgram,r.preInit)for(typeof r.preInit==\`function\`&&(r.preInit=[r.preInit]);r.preInit.length>0;)r.preInit.shift()();var N;function P(e){r._sort=e.d,r._malloc=e.e,r._free=e.f,N=e.b,e.__indirect_function_table}var F={a:A};function I(){p();function e(){var e;r.calledRun=!0,!s&&(m(),l==null||l(r),(e=r.onRuntimeInitialized)==null||e.call(r),h())}r.setStatus?(r.setStatus(\`Running...\`),setTimeout(()=>{setTimeout(()=>r.setStatus(\`\`),1),e()},1)):e()}var L=x();return I(),t=d?r:new Promise((e,t)=>{l=e}),t}),i.apply(this,arguments)}let a;function o(){return e(this,void 0,void 0,function*(){a=yield r()})}let s,c,l,u,d,f,p,m,h,g,_=0,v=0,y=!1,b=[],x=!0,S=!0,C=!1,w=!1,T=!1;function E(e,t){if(t.length!==16)return!0;for(let n=0;n<16;n++)if(Math.abs(e[n]-t[n])>1e-7)return!0;return!1}let D=[],O=65536,k=()=>e(void 0,void 0,void 0,function*(){if(C){w=!0;return}C=!0,w=!1,a||(yield o());let e=Math.pow(2,Math.ceil(Math.log2(s.vertexCount)));_<e&&(_>0&&(a._free(c),a._free(u),a._free(d),a._free(f),a._free(p),a._free(m)),_=e,c=a._malloc(64),u=a._malloc(_*4),d=a._malloc(3*_*4),f=a._malloc(_*4),p=a._malloc(_*4),m=a._malloc(_*4)),y||(h=a._malloc(O*4),g=a._malloc(O*4),y=!0),v<s.transforms.length&&(v>0&&a._free(l),v=s.transforms.length,l=a._malloc(v*4)),C=!1,w&&(w=!1,yield k())}),A=()=>{if(C||w||!a)return;C=!0,S&&(a.HEAPF32.set(s.positions,d/4),a.HEAPF32.set(s.transforms,l/4),a.HEAPU32.set(s.transformIndices,u/4),S=!1),a.HEAPF32.set(new Float32Array(b),c/4),a._sort(c,l,u,s.vertexCount,d,f,p,m,h,g);let e=s.vertexCount,t=new Uint32Array(a.HEAPU32.buffer,p,e),n=e*4,r=D.pop();(!r||r.byteLength<n)&&(r=new ArrayBuffer(n));let i=new Uint32Array(r,0,e);i.set(t),self.postMessage({depthIndex:i,generation:s.generation},[r]),C=!1,x=!1},j=()=>{T||(T=!0,x&&A(),setTimeout(()=>{T=!1,j()}))};self.onmessage=t=>new Promise(n=>e(void 0,void 0,void 0,function*(){var e;if(t.data.warmup){yield o(),n(!0);return}if(t.data.returnBuffer){D.length<3&&D.push(t.data.returnBuffer),n(!0);return}let r=!1,i=!!t.data.sortData;if(t.data.sortData&&(s={positions:t.data.sortData.positions,transforms:t.data.sortData.transforms,transformIndices:t.data.sortData.transformIndices,vertexCount:t.data.sortData.vertexCount,generation:(e=t.data.sortData.generation)==null?0:e},x=!0,S=!0,yield k(),r=!0),t.data.viewProj){let e=t.data.viewProj;(E(e,b)||i)&&(b=e,x=!0,r=!0)}r&&x&&j(),n(!0)}))})();`,Eb=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,Tb],{type:`text/javascript;charset=utf-8`});function Db(e){let t;try{if(t=Eb&&(self.URL||self.webkitURL).createObjectURL(Eb),!t)throw``;let n=new Worker(t,{name:e==null?void 0:e.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch(t){return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(Tb),{name:e==null?void 0:e.name})}}var Ob=function(...e){return e[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}("}rpvv|{-uvtu}-sy|nH}rpvv|{-uvtu}-v{H0vsqrs-b`Rl\\_QR_laReab_R{vs|z-uvtu}-nz}yr?Q-l|qrar\x07rH{vs|z-v{-l|qrdvquH{vs|z-v{-l{z]|v{H0ryrnvor-sy|n-}ynV{qr\x07H0r{qvs{vs|z-uvtu}-nz}yr?Q-lr\x07rH{vs|z-uvtu}-nz}yr?Q-ln{s|zH{vs|z-uvtu}-nz}yr?Q-luar\x07rH{vs|z-rp?-luar\x07r`v rH{vs|z-v{-lzn\x07`uQrtrrH0vs-[bZlT`lPYV]]R_`-K-=----{vs|z-rp?-lyn\brPyv}}r_n{trh[bZlT`lYNfR_`jH----{vs|z-znA-lpyv}}rZnvprV{rrh[bZlT`lPYV]]R_`jH0r{qvs{vs|z-rp?-r|yv|{H<<-每对象渲染参数,按-n{s|zV{qr\x07-索引(与-ln{s|z-同一套索引)<<-r\x07ry-=G-h}rOyNz|{9-oyNz|{9-rrrq9-rrrqj,单位为方差-}\x07²{vs|z-uvtu}-nz}yr?Q-l|owrp]nnzH0vs-R[NOYRlT`lV[ValN[VZNaV\\[{vs|z-sy|n-lnttrtnv|{]|trH{vs|z-sy|n-lnttrtnv|{]|v{Qnv|{H{vs|z-rp@-lnttrtnv|{O|{qZv{H{vs|z-rp@-lnttrtnv|{O|{qZn\x07H0r{qvsn\bv{t-rpA-P|y|Hn\bv{t-rp?-]|vv|{Hn\bv{t-rp?-bHp|{-sy|n-zn\x07`prr{`}npr`}yn`v r-J-?=AE;=H<<-}npx-阶段(qnn;p}})把-@Q-协方差整体-×A-存入-unys,因此-unqr-里的-p|?Qz<<-也是真实屏幕空间协方差的-A-倍。屏幕空间低通核以-}\x07²(方差)为单位给出,<<-加到对角线前需换算到同一量纲,即-×A。<<-这样-}rOyNz|{-<-oyNz|{-的数值语义与-`}nx-<-t}yn-完全一致(=;@-}\x07²-≈-=;BB}\x07-σ)。p|{-sy|n-P\\cl]NPXl`PNYR-J-A;=Hp|{-sy|n-`UlP>-J-=;AEEC=?B>>F=?F>FFHp|{-sy|n-`UlP?l=-J->;=F?BAEAHp|{-sy|n-`UlP?l>-J-:>;=F?BAEAHp|{-sy|n-`UlP?l?-J-=;@>B@F>CHp|{-sy|n-`UlP?l@-J-:>;=F?BAEAHp|{-sy|n-`UlP?lA-J-=;BAC?DA?Hrp?-tr`UQnnbc5v{-}ynVq\x079-v{-p|z}|{r{\\ssr9-rp?-r\x07r`v r6-\n----v{-uP|z}|{r{P|{-J-=H----vs-5lzn\x07`uQrtrr-KJ->6-uP|z}|{r{P|{-8J-FH----vs-5lzn\x07`uQrtrr-KJ-?6-uP|z}|{r{P|{-8J->BH----vs-5lzn\x07`uQrtrr-KJ-@6-uP|z}|{r{P|{-8J-?>H----v{-}nqqrqP|z}|{r{P|{-J-uP|z}|{r{P|{H----vs-5}nqqrqP|z}|{r{P|{-2-A-.J-=6-\n--------}nqqrqP|z}|{r{P|{-J-55}nqqrqP|z}|{r{P|{-<-A6-8->6-7-AH----\f----sy|n-yv{rnP|z}|{r{V{qr\x07-J-sy|n5}ynVq\x07-7-}nqqrqP|z}|{r{P|{-8-p|z}|{r{\\ssr6H----sy|n-r\x07ryV{qr\x07-J-yv{rnP|z}|{r{V{qr\x07-<-A;=H----sy|n-q-J-r\x07ryV{qr\x07-<-r\x07r`v r;\x07H----sy|n-\b-J-sy||5q6-<-r\x07r`v r;\bH----sy|n-\x07-J-snp5q6H----r{-rp?5\x079-\b6H\f|vq-znv{-56-\n0vsqrs-b`Rl\\_QR_laReab_R----<<-|qr-走纹理:用实例号从-|qrar\x07r-取本实例要画的全局点索引----vrp?-|qrP||q-J-vrp?5tylV{n{prVQ-2-l|qrdvqu9-tylV{n{prVQ-<-l|qrdvqu6H----v{-}ynV{qr\x07b-J-r\x07rySrpu5l|qrar\x07r9-|qrP||q9-=6;H----<<-r|qr-标记为-`R[aV[RY5KJ-{z]|v{6-的实例被剔除----vs-5}ynV{qr\x07b-KJ-v{5l{z]|v{66-\n--------tyl]|vv|{-J-rpA5=;=9-=;=9-?;=9->;=6H--------r{H----\f0ryr----v{-}ynV{qr\x07b-J-v{5}ynV{qr\x07-8-=;B6H0r{qvs----v{-}ynV{qr\x07V-J-v{5}ynV{qr\x07b6H----<<-每-}yn-?-r\x07ry-5_TON@?bV6G----<<-r\x07ry-=G-h}|els@?ov9-}|fls@?ov9-}|gls@?ov9-_TONl}npxrqj----<<-r\x07ry->G-hp|==\vp|=>5unys?69-p|=?\vp|>>5unys?69-p|>?\vp|??5unys?69-n{s|zV{qr\x07II>C\vyn\brV{qr\x07j----v{-onrar\x07ry-J-}ynV{qr\x07b-7-?H----v{-r\x07dvqu-J-v{5r\x07r`v r5lr\x07r9-=6;\x076H----vrp?-p||q=-J-vrp?5onrar\x07ry-2-r\x07dvqu9-onrar\x07ry-<-r\x07dvqu6H----vrp?-p||q>-J-vrp?55onrar\x07ry-8->6-2-r\x07dvqu9-5onrar\x07ry-8->6-<-r\x07dvqu6H----rpA-=-J-r\x07rySrpu5lr\x07r9-p||q=9-=6H----rpA->-J-r\x07rySrpu5lr\x07r9-p||q>9-=6H----<<-全精度位置-5|owrp-}npr6----rp@-}ynPr{r-J-rp@5--------v{Ova|Sy|n5=;69--------v{Ova|Sy|n5=;t69--------v{Ova|Sy|n5=;o6----6H----<<-颜色----rpA-p|y|-J-rpA5--------sy|n5=;n-3-=\x07SS69--------sy|n55=;n-KK-E6-3-=\x07SS69--------sy|n55=;n-KK->C6-3-=\x07SS69--------sy|n55=;n-KK-?A6-3-=\x07SS6----6-<-?BB;=H----<<-预计算的-@Q-协方差(|owrp-}npr),对称矩阵-C-分量-5unys:}rpvv|{6----rp?-p|ln-J-{}npxUnys?\x07>C5>;6H--<<-5p|==9-p|=>6----rp?-p|lo-J-{}npxUnys?\x07>C5>;t6H--<<-5p|=?9-p|>>6----rp?-p|lp-J-{}npxUnys?\x07>C5>;o6H--<<-5p|>?9-p|??6----zn@-cx-J-zn@5--------p|ln;\x079-p|ln;\b9-p|lo;\x079--------p|ln;\b9-p|lo;\b9-p|lp;\x079--------p|lo;\x079-p|lp;\x079-p|lp;\b----6H----<<-n{s|zV{qr\x07-和-yn\brV{qr\x07-从->;n-解包----v{-n{s|zV{qr\x07-J->;n-KK->CH----v{-yn\brV{qr\x07-J->;n-3-=\x07SSSSH----znA-n{s|z-J-znA5--------r\x07rySrpu5ln{s|z9-vrp?5=9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5>9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5?9-n{s|zV{qr\x0769-=69--------r\x07rySrpu5ln{s|z9-vrp?5@9-n{s|zV{qr\x0769-=6----6H----znA-n{s|zZ|qrycvrZnv\x07-J-vrZnv\x07-7-n{s|zH----rpA-|yqPr{r-J-n{s|z-7-rpA5}ynPr{r9->;=6H0vs-R[NOYRlT`lV[ValN[VZNaV\\[----sy|n-y|pny]|tr-J-lnttrtnv|{]|trH----sy|n-pnyr]|tr-J-=;=H----o||y-v{O|{qS|Nttrtnv|{-J-snyrH----vs-5lnttrtnv|{]|tr-I->;=6-\n--------o||y-v{O|{q-J-|yqPr{r;\x07-KJ-lnttrtnv|{O|{qZv{;\x07---------------------33-|yqPr{r;\x07-IJ-lnttrtnv|{O|{qZn\x07;\x07---------------------33-|yqPr{r; -KJ-lnttrtnv|{O|{qZv{; ---------------------33-|yqPr{r; -IJ-lnttrtnv|{O|{qZn\x07; H--------vs-5v{O|{q6-\n------------v{O|{qS|Nttrtnv|{-J-rH------------sy|n-urvtu_n{tr-J-lnttrtnv|{O|{qZn\x07;\b-:-lnttrtnv|{O|{qZv{;\bH------------sy|n-{|znyv rqUrvtu-J-urvtu_n{tr-K-=;==>----------------L-pynz}55|yqPr{r;\b-:-lnttrtnv|{O|{qZv{;\b6-<-urvtu_n{tr9-=;=9->;=6----------------G-=;BH------------sy|n-}|v{Q-J-pynz}5lnttrtnv|{]|v{Qnv|{9-=;=>9->;=6H------------sy|n-navzr-J-5>;=-:-{|znyv rqUrvtu6-7-5>;=-:-}|v{Q6H------------y|pny]|tr-J-pynz}55lnttrtnv|{]|tr-:-navzr6-<-}|v{Q9-=;=9->;=6H------------sy|n-|ssr]|tr-J-z||ur}5=;=9->;=9-y|pny]|tr6H------------pnyr]|tr-J-y|pny]|tr-7-y|pny]|tr-7-y|pny]|trH------------rp@-nttrtnv|{Pr{r-J-5lnttrtnv|{O|{qZv{-8-lnttrtnv|{O|{qZn\x076-<-?;=H------------rp@-qv-J-|yqPr{r;\x07\b -:-nttrtnv|{Pr{rH------------sy|n-qv-J-yr{tu5qv6H------------sy|n-n{q`rrq-J-q|5}ynPr{r9-rp@5>?;FEFE9-DE;?@@9-AB;>CA66H------------sy|n-n{qQv-J-snp5v{5n{q`rrq6-7-A@DBE;BAB@6H------------sy|n-n{tyr-J-n{q`rrq-7->=;=H------------rp@-pnrQv-J-{|znyv r5rp@5----------------p|5n{tyr69----------------zv\x075:=;D9-=;>9-snp5v{5n{q`rrq-7->;D6-7-A@DBE;BAB@669----------------v{5n{tyr6------------66H------------sy|n-r\x07}y|v|{Snp|-J-5>;=-:-|ssr]|tr6-7-5>;=-8->;=-7-n{qQv6H------------rp@-|ssr-J-pnrQv-7-qv-7-r\x07}y|v|{Snp|H------------|yqPr{r;\x07\b -8J-|ssrH------------}ynPr{r-J-5v{rr5n{s|z6-7-|yqPr{r6;\x07\b H--------\f----\f0r{qvs----0vs-[bZlT`lPYV]]R_`-K-=----vs-5yn\brV{qr\x07-I-v{5[bZlT`lYNfR_`66-\n--------rp?-pyv}_n{tr-J-lyn\brPyv}}r_n{trhyn\brV{qr\x07jH--------v{-pyv}`n-J-v{5pyv}_n{tr;\x07-8-=;B6H--------v{-pyv}P|{-J-v{5pyv}_n{tr;\b-8-=;B6H--------v{-pyv}R{q-J-pyv}`n-8-pyv}P|{H--------s|-5v{-v-J-=H-v-I-[bZlT`lPYV]]R_`H-v886-\n----------------vs-5v-I-pyv}`n-\v\v-v-KJ-pyv}R{q6-\n--------------------p|{v{rH----------------\f----------------rpA-pyv}}r]|vv|{-J-lpyv}}rZnvprV{rrhvj-7-|yqPr{rH----------------o||y-pyv}}rq-J-pyv}}r]|vv|{;\x07-K-:=;B-33-pyv}}r]|vv|{;\x07-I-=;BH----------------pyv}}rq-J-pyv}}rq-33-pyv}}r]|vv|{;\b-K-:=;B-33-pyv}}r]|vv|{;\b-I-=;BH----------------pyv}}rq-J-pyv}}rq-33-pyv}}r]|vv|{; -K-:=;B-33-pyv}}r]|vv|{; -I-=;BH----------------vs-5pyv}}rq6-\n--------------------tyl]|vv|{-J-rpA5=;=9-=;=9-?;=9->;=6H--------------------r{H----------------\f--------\f----\f----0r{qvs----rpA-vrPr{r-J-n{s|zZ|qrycvrZnv\x07-7-rpA5}ynPr{r9->;=6H----rpA-pyv}Pr{r-J-}|wrpv|{Znv\x07-7-vrPr{rH----sy|n-pyv}-J->;?-7-pyv}Pr{r;H----vs-5pyv}Pr{r; -I-:pyv}Pr{r;-\v\v-pyv}Pr{r; -K-pyv}Pr{r;-\v\v--------pyv}Pr{r;\x07-I-:pyv}-\v\v-pyv}Pr{r;\x07-K-pyv}-\v\v--------pyv}Pr{r;\b-I-:pyv}-\v\v-pyv}Pr{r;\b-K-pyv}6-\n--------tyl]|vv|{-J-rpA5=;=9-=;=9-?;=9->;=6H--------r{H----\f----rp@-{qpPr{r-J-pyv}Pr{r;\x07\b -<-pyv}Pr{r;H----]|vv|{-J-}|vv|{;\x07\bH----rp?-s|pny-J-rp?5--------}|wrpv|{Znv\x07h=jh=j-7-r|yv|{;\x07-7-=;B9--------}|wrpv|{Znv\x07h>jh>j-7-r|yv|{;\b-7-=;B----6H----o||y-v\\u|tn}uvp-J-}|wrpv|{Znv\x07h@jh@j-K-=;DH----zn@-WH----vs-5v\\u|tn}uvp6-\n--------W-J-n{}|r5zn@5------------s|pny;\x079-=;=9-=;=9------------=;=9-s|pny;\b9-=;=9------------=;=9-=;=9-=;=--------66H----\f-ryr-\n--------sy|n--J->;=-<-5vrPr{r; -7-vrPr{r; 6H--------W-J-zn@5------------s|pny;\x07-<-vrPr{r; 9-=;=9-:5s|pny;\x07-7-vrPr{r;\x076-7-9------------=;=9-s|pny;\b-<-vrPr{r; 9-:5s|pny;\b-7-vrPr{r;\b6-7-9------------=;=9-=;=9-=;=--------6H----\f----zn@-d-J-n{}|r5zn@5n{s|zZ|qrycvrZnv\x0766H----zn@-a-J-d-7-WH----<<-@Q-→-?Q-协方差投影-5nyvt{rq-vu-t}yn-_r{qr]|tnz6----zn@-p|?Qz-J-n{}|r5a6-7-cx-7-aH----<<-───-屏幕空间抗锯齿:qvynv|{-<-Zv}:`}ynv{t-?Q-zv}-───----<<-每对象参数(放在视锥<裁剪早退之后再取,避免被剔除的-}yn-白付一次采样)----<<-;\x07-J-}rOyNz|{9-;\b-J-oyNz|{,单位为方差-}\x07²----rp?-oy]nnz-J-r\x07rySrpu5l|owrp]nnz9-vrp?5=9-n{s|zV{qr\x0769-=6;\x07\bH----sy|n-}rOyNz|{-J-oy]nnz;\x07H----sy|n-oyNz|{-J-oy]nnz;\bH----<<-Σ?Q-是对称矩阵,只需-@-个分量----sy|n-p==-J-p|?Qzh=jh=jH----sy|n-p=>-J-p|?Qzh=jh>jH----sy|n-p>>-J-p|?Qzh>jh>jH----<<-①-qvynv|{(}rOyNz|{):只膨胀协方差,不动-|}npv\b。----<<----用于未经抗锯齿训练的数据,避免亚像素-}yn-因采样不到而闪烁<消失。----<<----代价是远景-}yn-会偏亮偏胖(能量没有随面积增大而摊薄)。----sy|n-}rOy-J-}rOyNz|{-7-P\\cl]NPXl`PNYRH----p==-8J-}rOyH----p>>-8J-}rOyH----<<-②-Zv}:`}ynv{t-?Q-zv}(oyNz|{):膨胀协方差-8-|}npv\b-补偿。----<<----与一个方差为-ε-的各向同性高斯做卷积:Σ4-J-Σ-8-εV,----<<----并按-ρ-J-\05qr5Σ6-<-qr5Σ466-衰减-|}npv\b,使-}yn-的积分能量守恒----<<----——面积变大、浓度变淡,于是既不闪烁也不变亮。这是-RdN-低通滤波的近似,----<<----等价于-t}yn-的-nrv rlz|qrJ/n{vnyvnrq/。----<<----<<----注意-qr-对整体缩放的齐次性:qr5x·Σ6-J-x²·qr5Σ6,----<<----只要-ε-与-Σ-同样被-×P\\cl]NPXl`PNYR,比值中的-x²-会约掉,----<<----因此-ρ-与-}npx-缩放无关,恒等于真实-}\x07²-量纲下的补偿系数。----vs-5oyNz|{-K-=;=6-\n--------sy|n-qr\\vt-J-p==-7-p>>-:-p=>-7-p=>H--------sy|n-oy-J-oyNz|{-7-P\\cl]NPXl`PNYRH--------p==-8J-oyH--------p>>-8J-oyH--------sy|n-qr-J-p==-7-p>>-:-p=>-7-p=>H--------<<-qr-单调增(εK=-时-qr5Σ8εV6-K-qr5Σ6),故-ρ-∈-5=9->j--------p|y|;n-7J-\05pynz}5qr\\vt-<-zn\x075qr9->r:F69-=;=9->;=66H----\f----sy|n-zvq-J-5p==-8-p>>6-<-?;=H----sy|n-nqv-J-yr{tu5rp?55p==-:-p>>6-<-?;=9-p=>66H----sy|n-ynzoqn>-J-zvq-8-nqvH----sy|n-ynzoqn?-J-zvq-:-nqvH----vs-5ynzoqn?-I-=;=6-\n--------r{H----\f----rp?-qvnt|{nycrp|-J-{|znyv r5rp?5p=>9-ynzoqn>-:-p==66H----<<-协方差已在-}npx-阶段-×A(与-t}yn-对齐),故用-\05?7ynzoqn6-而非-\05E7ynzoqn6----rp?-znw|N\x07v-J-zv{5\05?;=-7-ynzoqn>69-zn\x07`prr{`}npr`}yn`v r6-7-qvnt|{nycrp|H----rp?-zv{|N\x07v-J-zv{5\05?;=-7-ynzoqn?69-zn\x07`prr{`}npr`}yn`v r6-7-rp?5qvnt|{nycrp|;\b9-:qvnt|{nycrp|;\x076H----<<-\0nq-顶点为-h:?9?j,等价于-t}yn-的-}|vv|{-7-n\x07v-<-vr}|----rp?-onvcvr}|-J-rp?5>;=-<-r|yv|{;\x079->;=-<-r|yv|{;\b6H----rp?-{qp\\ssr-J-5]|vv|{;\x07-7-znw|N\x07v-8-]|vv|{;\b-7-zv{|N\x07v6-7-onvcvr}|H0vs-R[NOYRlT`lV[ValN[VZNaV\\[----sy|n-sv{ny`pnyr]|tr-J-v{O|{qS|Nttrtnv|{-L-pnyr]|tr-G-5lnttrtnv|{]|tr-7-lnttrtnv|{]|tr-7-lnttrtnv|{]|tr6H----{qp\\ssr-7J-zv\x075=;>9->;=9-sv{ny`pnyr]|tr6H0r{qvs----rpA-\0nq]|-J-rpA5{qpPr{r;\x07\b-8-{qp\\ssr9-{qpPr{r; 9->;=6H----tyl]|vv|{-J-\0nq]|H----vs-5lzn\x07`uQrtrr-KJ->6-\n--------rp@-pnzrn]|V{\\owrp-J-rp@5v{rr5n{s|z6-7-rpA5pnzrn]|vv|{9->;=66H--------rp@-|owrpcvrQv-J-{|znyv r5}ynPr{r-:-pnzrn]|V{\\owrp6H--------rpA-u=>?@-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-=9-luar\x07r`v r66H--------rpA-uABCD-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-A9-luar\x07r`v r66H--------rpA-uEF>=>>-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-E9-luar\x07r`v r66H--------rp@-u>-J-u=>?@;toH--------rp@-u?-J-rp@5u=>?@;n9-uABCD;t6H--------rp@-u@-J-rp@5uABCD;on9-uEF>=>>;6H--------sy|n-\x07-J-|owrpcvrQv;\x07H--------sy|n-\b-J-|owrpcvrQv;\bH--------sy|n- -J-|owrpcvrQv; H--------rp@-uP|y|-J-u>-7-5:=;AEEC=?B-7-\b6-8-u?-7-5=;AEEC=?B-7- 6-8-u@-7-5:=;AEEC=?B-7-\x076H--------p|y|;to-8J-uP|y|H--------vs-5lzn\x07`uQrtrr-KJ-?6-\n------------rpA-u>?>@>A>B-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9->?9-luar\x07r`v r66H------------rpA-u>C>D>E>F-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9->C9-luar\x07r`v r66H------------rpA-u?=?>???@-J-r\x07r5luar\x07r9-tr`UQnnbc5}ynV{qr\x07V9-?=9-luar\x07r`v r66H------------rp@-uA-J-uEF>=>>;tonH------------rp@-uB-J-u>?>@>A>B;toH------------rp@-uC-J-rp@5u>?>@>A>B;n9-u>C>D>E>F;t6H------------rp@-uD-J-rp@5u>C>D>E>F;on9-u?=?>???@;6H------------rp@-uElqrt?-J-u?=?>???@;tonH------------sy|n-\x07\x07-J-\x07-7-\x07H------------sy|n-\b\b-J-\b-7-\bH------------sy|n- -J- -7- H------------sy|n-\x07\b-J-\x07-7-\bH------------sy|n-\b -J-\b-7- H------------sy|n-\x07 -J-\x07-7- H------------p|y|;to-8J----------------5`UlP?l=-7-\x07\b6-7-uA-8----------------5`UlP?l>-7-\b 6-7-uB-8----------------5`UlP?l?-7-5?;=-7- -:-\x07\x07-:-\b\b66-7-uC-8----------------5`UlP?l@-7-\x07 6-7-uD-8----------------5`UlP?lA-7-5\x07\x07-:-\b\b66-7-uElqrt?H--------\f----\f----p|y|;to-J-pynz}5p|y|;to9-rp@5=;=69-rp@5>;=66H----P|y|-J-p|y|H----<<-]|vv|{-直接传-h:?9?j-的-\0nq-坐标给-sntzr{(与-t}yn-一致)----b-J-}|vv|{;\x07\bH\f"),kb=function(...e){return e[0].split(``).map(e=>e.charCodeAt(0)>126?e:String.fromCharCode((e.charCodeAt(0)+113)%126)).join(``)}(`}rpvv|{-uvtu}-sy|nH0v{pyqr-Ip|zz|{Kn\bv{t-rpA-P|y|Hn\bv{t-rp?-]|vv|{Hn\bv{t-rp?-bH|vq-znv{-56-
2953
- ----<<-与-t}yn-_r{qr]|tnz-一致:]|vv|{-为-h:?9?j-的-\0nq-坐标----sy|n-N-J-:q|5]|vv|{9-]|vv|{6H----vs-5N-I-:A;=6-qvpnqH----rp@-p|y|-J-P|y|;toH----sy|n-|}npv\b-J-r\x07}5N6-7-P|y|;nH----tylSntP|y|-J-rpA5p|y|;to9-|}npv\b6H\f`),Ab=new t.Vector3,jb=new t.Vector3,Mb=new t.Quaternion,Nb=new t.Quaternion,Pb=new t.Vector3,Fb=class extends t.Mesh{constructor(){super(),this.needsRender=!1,this.sortWorker=null,this.splatIndexCapacity=0,this.sortDataUploaded=!1,this.usedSHDegree=0,this.transformStore=null,this.objectParamsStore=null,this.transformsDirty=!1,this.layerRegistry=null,this.shStore=null,this.orderTexture=null,this.assembler=null,this.reorderPass=null,this.orderTarget=null,this.orderBaseSnapshot=[],this.sortGeneration=0,this.snapshotByGen=new Map,this.orderCount=0,this.orderDirty=!1,this.layoutDirty=!1,this.lastObjectsHash=``,this.lastClipperHash=``,this.prevSortCameraMatrix=null,this.sortCameraDistance=1,this.sortCameraCoorient=.99,this.sortMinIntervalMs=0,this.sortLastTime=-1/0,this.onBeforeRender=(e,n,r)=>{let i=r,a=this.collectObjects(n);if(a.length===0){this.geometry.instanceCount=0;return}let o=0,s=!1;for(let e of a)e.usedSHDegree>o&&(o=e.usedSHDegree),e.initAnimationEnabled&&(s=!0);let c=o!==this.usedSHDegree;this.usedSHDegree=o,this.updateInitAnimationDefine(s),this.isSceneChanged(a)?this.rebuild(e,a):c&&this.updateSH(a);for(let e of a)e.transformChanged&&this.transformStore.indexOf(e)!==void 0&&(this.transformStore.updateOne(e),this.transformsDirty=!0,e.transformChanged=!1,e.selectedChanged=!1),e.renderParamsChanged&&(this.objectParamsStore.updateOne(e),e.renderParamsChanged=!1,this.needsRender=!0);let l=new t.Matrix4().multiplyMatrices(i.perspectiveProjectionMatrix,i.matrixWorldInverse);this.requestSort(i,l.elements),(this.orderDirty||this.layoutDirty)&&(this.runReorder(e),this.orderDirty=!1,this.layoutDirty=!1);let u=a.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`);u!==this.lastClipperHash&&(this.updateClipperUniforms(a),this.lastClipperHash=u,this.needsRender=!0),this.material.uniforms.resolution.value.set(i.resolution.x,i.resolution.y)},this.geometry=this.createGeometry(),this.material=this.createMaterial(),this.orderTexture=new sb,this.assembler=new fb,this.reorderPass=new wb,this.transformStore=new hb,this.objectParamsStore=new vb,this.layerRegistry=new yb,this.shStore=new Sb,this.material.uniforms.u_orderTexture.value=this.orderTexture.texture,this.material.uniforms.u_orderWidth.value=this.orderTexture.width,this.frustumCulled=!1,this.renderOrder=-99999999999,this.sortWorker=new Db,this.sortWorker.postMessage({warmup:!0}),this.sortWorker.onmessage=e=>{var t;if(e.data.depthIndex){let n=e.data.depthIndex;this.applyDepthIndex(n,e.data.generation);let r=n.buffer;r.byteLength>0&&((t=this.sortWorker)==null||t.postMessage({returnBuffer:r},[r]))}}}createGeometry(){let e=new t.InstancedBufferGeometry,n=new Float32Array([-2,-2,0,2,-2,0,2,2,0,-2,2,0]);e.setAttribute(`position`,new t.BufferAttribute(n,3)),e.setIndex(new t.BufferAttribute(new Uint16Array([0,1,2,0,2,3]),1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity),i=new t.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(t.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}ensureSplatIndexCapacity(e){let n=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return n;let r=Math.max(this.splatIndexCapacity,1);for(;r<e;)r*=2;let i=new Float32Array(r);i.set(n.array.subarray(0,Math.min(n.array.length,r)));let a=new t.InstancedBufferAttribute(i,1,!1,1);return a.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,a),this.splatIndexCapacity=r,this.geometry._maxInstanceCount=r,a}createMaterial(){return new t.ShaderMaterial({vertexShader:Ob,fragmentShader:kb,defines:{NUM_GS_LAYERS:0,NUM_GS_CLIPPERS:0,ENABLE_GS_INIT_ANIMATION:0,USE_ORDER_TEXTURE:1},uniforms:{u_texture:{value:null},u_transforms:{value:null},u_orderTexture:{value:null},u_orderWidth:{value:2048},u_numPoints:{value:0},u_numGsLayers:{value:0},u_numGsClippers:{value:0},u_layerClipperRanges:{value:[]},u_clipperMatricesInverse:{value:[]},u_shTexture:{value:null},u_shTextureSize:{value:new t.Vector2},u_maxShDegree:{value:0},resolution:{value:new t.Vector2},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new t.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new t.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6},u_objectParams:{value:null}},side:t.DoubleSide,transparent:!0,blending:t.NormalBlending,depthTest:!0,depthWrite:!1})}rebuildTransformsTexture(e){this.transformStore.sync(e),this.material.uniforms.u_transforms.value=this.transformStore.texture,this.transformsDirty=!0}rebuildObjectParamsTexture(e){this.objectParamsStore.sync(e,e=>this.transformStore.indexOf(e)),this.material.uniforms.u_objectParams.value=this.objectParamsStore.texture;for(let t of e)t.renderParamsChanged=!1}rebuildAssembled(e,t){this.assembler.sync(t,e=>({transformIndex:this.transformStore.indexOf(e),layerIndex:this.layerRegistry.layerIndexOf(e)})),this.assembler.assemble(e),this.material.uniforms.u_texture.value=this.assembler.texture}updateSH(e){this.shStore.sync(e,this.usedSHDegree),this.material.uniforms.u_shTexture.value=this.shStore.texture,this.material.uniforms.u_shTextureSize.value.copy(this.shStore.textureSize),this.material.uniforms.u_maxShDegree.value=this.shStore.appliedDegree}applyDepthIndex(e,t){let n=e.length,r=this.ensureSplatIndexCapacity(n);r.array.set(e,0),r.count=n,r.updateRange.offset=0,r.updateRange.count=n,r.needsUpdate=!0,this.orderTexture&&this.orderTexture.update(e);let i=this.snapshotByGen.get(t);if(i){this.orderBaseSnapshot=i;for(let e of this.snapshotByGen.keys())e<t&&this.snapshotByGen.delete(e)}this.orderCount=n,this.orderDirty=!0,this.geometry.instanceCount=n,this.needsRender=!0}snapshotLayout(){return this.assembler?this.assembler.regions.map(e=>({object:e.object,start:e.start,count:e.count})):[]}buildSegments(e,t){let n=new Map;for(let e of t)n.set(e.object,e.start);let r=[];for(let t of e){let e=n.get(t.object),i=e===void 0,a=i?0:e-t.start,o=r[r.length-1];o&&o.removed===i&&(i||o.delta===a)&&o.oldEnd===t.start?o.oldEnd=t.start+t.count:r.push({oldStart:t.start,oldEnd:t.start+t.count,delta:a,removed:i})}return r}runReorder(e){if(!this.reorderPass||!this.orderTexture||this.orderCount===0)return;let t=this.snapshotLayout(),n=this.buildSegments(this.orderBaseSnapshot,t),r=this.orderTexture.width,i=Math.max(1,Math.ceil(this.orderCount/r));this.orderTarget?(this.orderTarget.width!==r||this.orderTarget.height<i)&&this.orderTarget.setSize(r,Math.max(this.orderTarget.height,i)):this.orderTarget=wb.createOrderTarget(r,i),this.reorderPass.run(e,this.orderTexture.texture,r,this.orderTarget,n);let a=0;for(let e of t)a+=e.count;this.material.uniforms.u_orderTexture.value=this.orderTarget.texture,this.material.uniforms.u_orderWidth.value=r,this.material.uniforms.u_numPoints.value=a}postSortData(){var e;let t=++this.sortGeneration;this.snapshotByGen.set(t,this.snapshotLayout());let{positions:n,transformIndices:r,count:i}=this.assembler.extractSortInputs(),a=this.transformStore.transforms.slice(0,this.transformStore.objectCount*20);(e=this.sortWorker)==null||e.postMessage({sortData:{positions:n,transforms:a,transformIndices:r,vertexCount:i,generation:t}},[n.buffer,a.buffer,r.buffer]),this.sortDataUploaded=!0,this.transformsDirty=!1}shouldSort(e){if(this.transformsDirty||!this.sortDataUploaded||!this.prevSortCameraMatrix)return!0;this.prevSortCameraMatrix.decompose(Ab,Mb,Pb),e.matrixWorld.decompose(jb,Nb,Pb);let t=Ab.distanceTo(jb),n=Math.abs(Mb.dot(Nb));return t>this.sortCameraDistance||n<this.sortCameraCoorient}requestSort(e,n){var r;!this.assembler||this.assembler.totalPoints===0||this.shouldSort(e)&&(performance.now()-this.sortLastTime<this.sortMinIntervalMs||((this.transformsDirty||!this.sortDataUploaded)&&this.postSortData(),(r=this.sortWorker)==null||r.postMessage({viewProj:n}),this.prevSortCameraMatrix||(this.prevSortCameraMatrix=new t.Matrix4),this.prevSortCameraMatrix.copy(e.matrixWorld),this.sortLastTime=performance.now()))}collectObjects(t){let n=[];return t.traverse(t=>{t instanceof e.t&&t.visible&&n.push(t)}),n.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:+(n>r)}),n}isSceneChanged(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`);return t===this.lastObjectsHash?!1:(this.lastObjectsHash=t,!0)}rebuild(e,t){this.sortDataUploaded=!1,this.layerRegistry.sync(t),this.rebuildTransformsTexture(t),this.rebuildObjectParamsTexture(t),this.rebuildAssembled(e,t),this.material.uniforms.u_numPoints.value=this.assembler.totalPoints,this.ensureSplatIndexCapacity(this.assembler.totalPoints),this.updateSH(t),this.lastClipperHash=``,this.layoutDirty=!0,this.needsRender=!0}updateClipperUniforms(e){var n,r;let i=this.layerRegistry;if(!i||i.layerCount===0){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let a=new Map;for(let t of e)a.has(t.gsViewLayerKey)||a.set(t.gsViewLayerKey,t.gsClippers);let o=i.layerKeys.length,s=0;for(let e of i.layerKeys)s+=((n=a.get(e))==null?[]:n).length;let c=Array.from({length:o},()=>new t.Vector2(-1,0)),l=Array.from({length:s},()=>new t.Matrix4),u=0;for(let e of i.layerKeys){let t=i.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(r=a.get(e))==null?[]:r,o=u;for(let e of n)l[u].getInverse(e.clippingBoxMatrix),u++;n.length>0&&c[t].set(o,n.length)}this.material.uniforms.u_layerClipperRanges.value=c,this.material.uniforms.u_clipperMatricesInverse.value=l,this.updateClipperCounts(o,u)}updateClipperCounts(e,t){let n=this.material.defines;(n.NUM_GS_LAYERS!==e||n.NUM_GS_CLIPPERS!==t)&&(n.NUM_GS_LAYERS=e,n.NUM_GS_CLIPPERS=t,this.material.needsUpdate=!0),this.material.uniforms.u_numGsLayers.value=e,this.material.uniforms.u_numGsClippers.value=t}updateInitAnimationDefine(e){let t=this.material.defines,n=+!!e;t.ENABLE_GS_INIT_ANIMATION!==n&&(t.ENABLE_GS_INIT_ANIMATION=n,this.material.needsUpdate=!0,this.needsRender=!0)}dispose(){this.sortWorker&&(this.sortWorker.terminate(),this.sortWorker=null),this.assembler&&(this.assembler.dispose(),this.assembler=null),this.reorderPass&&(this.reorderPass.dispose(),this.reorderPass=null),this.orderTarget&&(this.orderTarget.dispose(),this.orderTarget=null),this.transformStore&&(this.transformStore.dispose(),this.transformStore=null),this.objectParamsStore&&(this.objectParamsStore.dispose(),this.objectParamsStore=null),this.shStore&&(this.shStore.dispose(),this.shStore=null),this.layerRegistry=null,this.orderTexture&&(this.orderTexture.dispose(),this.orderTexture=null),this.geometry.dispose(),this.material.dispose()}},Ib=class extends t.Mesh{constructor(){super(),this.onBeforeRender=(e,t,n)=>{this.collectObjects(t).length>0&&console.warn(`未开启webgl2, 3dgs仅支持在开启webgl2模式后使用`)}}collectObjects(t){let n=[];return t.traverse(t=>{t instanceof e.t&&t.visible&&n.push(t)}),n}},Lb=1e3,Rb=90,zb=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/`),Bb=new t.Sphere,Vb=new t.Box3,Hb=new t.Vector4,Ub=new t.Vector4,Wb=new t.Color,Gb=new t.Vector2,Kb=new WeakMap,qb=wm([xm(null)]),Jb={},Yb=class e extends nn{static get version(){return`6.9.0-alpha.4`}static get dracoPath(){return co.decoderPath}static set dracoPath(e){co.setDecoderPath(e)}static get ktx2Path(){return _o.transcoderPath}static set ktx2Path(e){_o.setTranscoderPath(e)}static get useNativeImageBitmap(){return ii()}static set useNativeImageBitmap(e){ri(e)}constructor(e={}){var n,r,i,a,o,s,c,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Zt(),Jb[this.fiveId]=this,this.currentUpdateArgs={time:V(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!1,this.onlyRenderIfNeeds=(n=e.onlyRenderIfNeeds)==null?!0:n,this.imageOptions=Object.assign({},(r=e.imageOptions)==null?{}:r),this.textureOptions=Object.assign({},(i=e.textureOptions)==null?{}:i),this.poweredByRealsee=(a=e.poweredByRealsee)==null?!0:a,this.backgroundColor=new t.Color((o=e.backgroundColor)==null?1579548:o),this.backgroundAlpha=(s=e.backgroundAlpha)==null?1:s,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview),VRPanorama:Object.assign({},e.vrPanorama),XRPanorama:Object.assign({},e.xrPanorama)},this.fps={testCount:0,testTime:V()},this.modeChangeDuration=(c=e.modeChangeDuration)==null?Lb:c,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Uh&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Uh({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=Ky();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 t.WebGLRenderTarget(1,1,{encoding:(d=(u=this.renderer)==null?void 0:u.outputEncoding)==null?t.sRGBEncoding:d,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Yt(Rb),this.scene=new Xh,this.xrCustomObjectsScene=new t.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(f=e.requestProxy)==null?zb:f,this.networkSubscribe=new ir,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,Q(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new t.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),Kb.set(this,qb),this.modelScene=new xp({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(qb,{forceReplaceImmediately:!0});B(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new t.VideoTexture(e.videoInstance||Uy());let m=Wy();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=ei.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,Q(`vr.requestExit`,{}))},g=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,g,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,g,!1)},this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}Hy(this),this.fiveRenderer=new Hh,this.adaptiveLuminancePass=new Ym,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Qm(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new Fb,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new Ib)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return Z(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Jb[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 n=this.getElement();n&&n.parentNode&&n.parentNode.removeChild(n);let r=this.modelScene.parameter;r.pano0&&r.pano0.map.dispose(),r.pano1&&r.pano1.map!==((e=r.pano0)==null?void 0:e.map)&&r.pano1.map.dispose(),r.reset(`pano0`,`pano1`),this.modelScene.dispose(),this.scene.dispose(),this.xrCustomObjectsScene.dispose(),Kb.set(this,qb),this.renderer&&this.renderer.render(new t.Scene,new t.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Uh&&(this.renderer.forceContextLoss&&this.renderer.forceContextLoss(),this.renderer.dispose())}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,Q(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,pr(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,pr(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,pr(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,pr(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,pr(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,pr(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,pr(e.xrPanorama)),this.currentMode===`XRPanorama`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),(this.currentMode===`Panorama`||this.currentMode===`VRPanorama`)&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof Uh)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,i;if(!this.renderer)return;let a=this.renderer.domElement.parentNode,{width:o=(n=a==null?void 0:a.offsetWidth)==null?512:n,height:s=(r=a==null?void 0:a.offsetHeight)==null?512:r}=e;if(o=Math.max(1,o),s=Math.max(1,s),!t){let e=Ky(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(o,s)*t,n=Math.min(this.renderer.capabilities.maxTextureSize,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(o,s),this.needsRender=!0;let c=V(),l=c-this.currentUpdateArgs.time,u=this.currentUpdateArgs.args;this.updateTime(c,l,...u)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return Kb.get(this)||qb}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(()=>gg(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_(n,r,i,a=!0){var o,s,c,l,u,d,f,p,m,h;let g={};typeof i==`number`?g.duration=i:typeof i==`object`&&Object.assign(g,i),this.works===qb&&(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(n))for(let e of n)e instanceof bm?v.push(e):typeof e!=`string`&&`work`in e?v.push(xm(e.work,e)):v.push(xm(e));else n instanceof bm?v.push(n):v.push(xm(n));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=wm(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);r===void 0&&(r=`inherit`),r===`inherit`&&this.works===qb&&(r=`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=(o=x.mode)==null?S?`Panorama`:`Mapview`:o,T={};if(r===`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{r={mode:b};let e=(c=(s=y[0])==null?void 0:s.observers)==null?void 0:c[this.panoIndex];e?(r.workCode=e.work.workCode,r.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(r.workCode=y.initial.work.workCode,r.panoIndex=y.initial.panoIndex):(r.mode===`Panorama`||r.mode===`VRPanorama`||r.mode===`XRPanorama`)&&(r.mode=`Mapview`),r.mode===b&&(r.longitude=this.camera.pose.longitude,r.latitude=this.camera.pose.latitude,r.fov=this.camera.pose.fov)}}if(r===`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 r==`object`){if(w=(u=r.mode)==null?b:u,typeof r.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=r.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:r.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:r.longitude,latitude:r.latitude,fov:r.fov,distance:r.distance,offset:r.offset?new t.Vector3().copy(r.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;(w===`Panorama`||w===`VRPanorama`||w===`XRPanorama`)&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,Q(`works.request`,{input:n,works:y,userAction:a}));let O=(e,t,n)=>{let i=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),n);r===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:i,duration:E,effect:D,userAction:a}},this.commonParams()),this.controllerInits[e]),c=zy[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},a)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=zy[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a}))}this.controller=this.applyController(e,s);let t=Q(`mode.change`,{prevMode:b,mode:e,state:c,userAction:a});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};Kb.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),Dg(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a})),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(G),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,Q(`works.load`,{input:n,userAction:a,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,Q(`works.ready`,{input:n,userAction:a,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 n;this.controller&&(this.controller.destroy(),this.controller=void 0);let r=this.modelScene.parameter;r.pano0&&r.pano0.map.dispose(),r.pano1&&r.pano1.map!==((n=r.pano0)==null?void 0:n.map)&&r.pano1.map.dispose(),r.set({pano0:null,pano1:null,modelAlpha:1}),Kb.set(this,qb),this.modelScene.setModels(qb,{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:Rb,longitude:0,latitude:0,offset:new t.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(m)){let e=Error(`PanoId ${Z(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!zp(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(G):(zp(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(G));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=zy[t].initAnimationEndState(r),o=Q(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=Q(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=ei.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),ei.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),Cg().then(()=>_()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),s(t)})):t===e.Mode.XRPanorama?wg().then(e=>{ei.shared.setContext(e),a=!0,_()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),s(t)}):_()})}getPixels(e,n,r,i,a,o,s){if(!this.renderer)throw Error(`renderer is not initialized.`);let c=V(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new t.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof n==`number`&&(p=n),typeof r==`number`&&(m=r),typeof i==`number`&&(h=i),g=a,_=o,b=s):(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 zy.Panorama||this.controller instanceof zy.VRPanorama||this.controller instanceof zy.XRPanorama)&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(c),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=Wb.copy(this.renderer.getClearColor()),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(c),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,te=ee*4;if(b){if(b.length!==te)throw Error(`buffer length is not equals pixels ${te}`)}else b=new Uint8Array(te);if(this.renderer.readRenderTargetPixels(C,0,0,m*g,h*g,b),_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=Wb.copy(t.getClearColor()),c=t.getClearAlpha(),l=t.getViewport(Hb),u=t.getScissor(Ub),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(Gb),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:v;let y=!0;if(this.controller&&this.controller.render()&&(y=!1),y){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&ob(t)}this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&ei.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&_o.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),ei.shared.add(()=>{this.emit(`models.load`,Q(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&ei.shared.add(()=>{this.emit(`models.refined`,Q(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){Vb.makeEmpty(),Vb.expandByObject(this.modelScene.boundingMesh);let t=Vb.getBoundingSphere(Bb),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=H(n,800);let r=n/1e4;r=H(r,.03,.1),this.camera.near!==r&&(this.camera.near=r),this.camera.far!==n&&(this.camera.far=n),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0)return;let r=Q(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,Q(`render`,{needsRender:i})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof Uh&&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=G){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=V();return Promise.all(r.map(e=>{let t=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},dr(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Ur(i,r);return Gf(this.fiveId,n.work).preload(a)})).then(()=>{let e=V()-i;return t(e),e})}project2d(e,n=!1){if(!this.renderer)return null;if(n){let n=this.camera.position,r=e.clone().sub(n),i=new t.Raycaster(n,r.clone().normalize());i.params.Points={threshold:.1};let[a]=this.modelScene.intersectRaycaster(i);if(a&&a.distance+.01<r.length())return null}let r=e.clone().project(this.camera);if(Math.abs(r.z)>1)return null;let i=this.renderer.getSize(new t.Vector2),a=i.x*this.viewport.width,o=i.y*this.viewport.height,s=i.x*this.viewport.left+(r.x+1)/2*a,c=i.y*(1-this.viewport.bottom-this.viewport.height)+(-r.y+1)/2*o;return new t.Vector2(s,c)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,n=!1,r=!0){var i,a,o,s,c,l,u,d,f,p;e=dr(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof t.Vector3)&&(e.offset=new t.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=(a=(i=this.work)==null?void 0:i.workCode)==null?``:a,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(o=e.mode)==null?this.state.mode:o,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){if(h===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let n={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(n.longitude=e.longitude),typeof e.latitude==`number`&&(n.latitude=e.latitude),typeof e.fov==`number`&&(n.fov=e.fov),typeof e.distance==`number`&&(n.distance=e.distance),e.offset instanceof t.Vector3&&(n.offset=e.offset);let r=Object.assign(Object.assign({initial:{state:n,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),i=zy[h].initAnimationEndState(r);g=i.longitude,_=i.latitude,v=i.fov,y=i.offset,b=i.distance}else g=(s=e.longitude)==null?this.state.longitude:s,_=(c=e.latitude)==null?this.state.latitude:c,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,Q(`state.set`,{userAction:r,state:x})),Eg(this.state,x)||(this.controller&&x.mode===`VRPanorama`&&x.mode!==this.state.mode?(Tg(this.state,x),this.changeMode(`VRPanorama`)):this.controller&&x.mode===`XRPanorama`&&x.mode!==this.state.mode?(Tg(this.state,x),this.changeMode(`XRPanorama`)):(Tg(this.state,x),this.controller&&r&&(this.controller.userAction=!1),n&&this.state.mode===x.mode&&(this.syncingState=this.syncState(V(),0,n),this.syncingState&&((f=this.controller)==null||f.updateTime(V(),0),this.syncingState=!1)),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state)))}syncState(n,r,i=!1){let a=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 zy.Model){if(hg(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:i?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!zp(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 zy.Floorplan||this.controller instanceof zy.Topview||this.controller instanceof zy.Mapview){let e=.2,n=Math.PI/45,r=i?this.state.fov:Hm(this.camera.pose.fov,this.state.fov,1),a=Math.abs(this.camera.pose.distance-this.state.distance),o=a>e*15?a/15:.2,s=i?this.state.distance:Hm(this.camera.pose.distance,this.state.distance,o),c=this.camera.pose.offset.distanceTo(this.state.offset),l=c>e*15?c/15:e,u=i?new t.Vector3().copy(this.state.offset):Um(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=i?{longitude:this.state.longitude,latitude:this.state.latitude}:Wm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},n);if(pg(r,this.camera.pose.fov)||hg(u,this.camera.pose.offset)||pg(s,this.camera.pose.distance)||pg(d,this.camera.pose.longitude,Math.PI*2)||pg(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:r};return Object.assign(e,{distance:s}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(G),this.controller.locationMotion.set(e,0).catch(G),!0}}else{let e=Math.PI/45,n=i?this.state.fov:Hm(this.camera.pose.fov,this.state.fov,1),{longitude:r,latitude:a}=i?{longitude:this.state.longitude,latitude:this.state.latitude}:Wm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),o=this.state.distance,s=new t.Vector3().copy(this.state.offset);if(pg(o,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),hg(s,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),pg(r,this.camera.pose.longitude,Math.PI*2)||pg(a,this.camera.pose.latitude)||pg(n,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:r,latitude:a,fov:n},0).catch(G),!0}if(this.stateSynced=!0,a===!1&&this.emit(`state.synced`,Q(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof zy.Panorama&&t.tile===!0&&!this.controller.isTileReady()?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(G)}requestFullscreen(){var e;if(!yg)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=()=>{ei.shared.add(()=>{this.emit(`model.load`,Q(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,Q(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,Q(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,Q(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,Q(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,Q(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new lr({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=cm(e,r);return t instanceof Error?Promise.reject(t):t})}});Kf(this.fiveId,e,i)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(t,n){if(!this.renderer)throw Error(`renderer is not initialized.`);let r=zy[t];this.currentMode=t;let i=new r(n);for(let e of Vy)i.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=zy[t].initAnimationEndState(n),r=n.initial.userAction;Eg(this.state,e)||(Tg(this.state,e),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,Q(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return i.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,Q(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),i.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,Q(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),i.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),i.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),i.on(`error`,e=>this.throwError(e)),i}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let n=new t.Object3D;n.matrix.copy(e.matrix).premultiply(e.work.transform),n.matrix.decompose(n.position,n.quaternion,n.scale),n.matrixAutoUpdate=!1;let r=new t.Vector3(0,0,-1);r.applyQuaternion(this.camera.quaternion);let i=n.quaternion.clone().inverse();return r.applyQuaternion(i),{theta:Math.atan2(r.x,-r.z),phi:-Math.asin(r.y),lookAtVector:r}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableHQ(){return this.fiveRenderer.renderMode===`point-cloud-high-quality`}set enableHQ(e){this.fiveRenderer.renderMode=e?`point-cloud-high-quality`:`default`,this.needsRender=!0}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}get enableIOSEDR(){return!1}set enableIOSEDR(e){}get enablePostProcessing(){return!0}set enablePostProcessing(e){}get modelSceneNeedsRender(){return this.modelScene.needsRender}set modelSceneNeedsRender(e){this.modelScene.needsRender=e}};Yb.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:t,constructor:Yb,instances:Jb}});var Xb=class{static createButton(e){let t=document.createElement(`button`);function n(){t.style.display=``,t.style.cursor=`pointer`,t.style.left=`calc(50% - 50px)`,t.style.width=`100px`,t.textContent=`ENTER VR`,t.onmouseenter=function(){t.style.opacity=`1.0`},t.onmouseleave=function(){t.style.opacity=`0.5`},t.onclick=function(){e&&e()}}function r(){t.style.display=``,t.style.cursor=`auto`,t.style.left=`calc(50% - 75px)`,t.style.width=`150px`,t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function i(){r(),t.textContent=`VR NOT SUPPORTED`}function a(e){e.style.position=`absolute`,e.style.bottom=`20px`,e.style.padding=`12px 6px`,e.style.border=`1px solid #fff`,e.style.borderRadius=`4px`,e.style.background=`rgba(0,0,0,0.1)`,e.style.color=`#fff`,e.style.font=`normal 13px sans-serif`,e.style.textAlign=`center`,e.style.opacity=`0.5`,e.style.outline=`none`,e.style.zIndex=`999`}if(`xr`in navigator)return t.id=`VRButton`,t.style.display=`none`,a(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():i()}),t;{let e=document.createElement(`a`);return window.isSecureContext===!1?(e.href=document.location.href.replace(/^http:/,`https:`),e.innerHTML=`WEBXR NEEDS HTTPS`):(e.href=`https://immersiveweb.dev/`,e.innerHTML=`WEBXR NOT AVAILABLE`),e.style.left=`calc(50% - 90px)`,e.style.width=`180px`,e.style.textDecoration=`none`,a(e),e}}};exports.AdaptiveLuminancePass=Ym,exports.AnimationFrameLoop=ei,exports.BoundingMesh=yp,exports.Camera=Yt,exports.CustomShader=an,exports.PBMCustomShader=an,exports.EffectComposer=Tm,exports.EyeDomeLightingPass=Qm,exports.Fetcher=lr,exports.Five=Yb,exports.FivePass=Dm,exports.FiveRenderer=Hh,exports.FlowingFireworks3DPass=wh,exports.FlowingLight2DPass=lh,exports.FlowingLight3DPass=mh,exports.FullScreenQuad=Em,exports.GaussianBlurPass=th,exports.Histogram=zm,exports.InternalWebGLRenderer=Uh,exports.Model=up,exports.ModelScene=xp,exports.Motion=X,exports.NetworkSubscribe=ir,exports.PBMContainer=Wn,exports.PBMGSObject=e.t,exports.PBMGroup=vt,exports.PBMMesh=mn,exports.PBMMeshMaterial=pn,exports.PBMPanoFilter=on,exports.PBMPointCloud=wn,exports.PBMPointCloudMaterial=Cn,exports.PBMSkinnedMesh=hn,exports.PBMUpdateable=rn,exports.PROXY_CONTROLLER_EVENT_NAMES=Vy,exports.PanoCircleMesh=tg,exports.PanoCircleMeshCustom=dg,exports.PanoCircleMeshSolid=og,exports.Parameter=W,exports.Scene=Xh,exports.Subscribe=nn,exports.TextureLoader=fi,exports.Tile=gu,exports.Tile3D=Uf,exports.Tile3DModel=Uf,exports.TileCache=Hd,exports.TileNode=jd,exports.TileRequestScheduler=zd,exports.Tileset=Jd,exports.Trajectory=Fd,exports.TrajectoryNode=Id,exports.Work=bm,exports.WorkResolvedObserver=Cm,exports.XRButton=Xb,exports.controllersDefaultInitArgs=By,exports.coordinatesToVector=It,exports.createDebugBoundingMesh=du,exports.createWorks=wm,exports.defaultImageURLTransform=Ur,exports.draco=co,exports.getViewportScale=Ky,exports.headingToLongitude=zt,exports.imageSupport=Er,exports.isBoundingVolume=ou,exports.isPanoId=Bp,exports.ktx2=_o,exports.loadAt3d=ca,exports.loadB3dm=Ws,exports.loadDome=fa,exports.loadDomez=ya,exports.loadFbx=al,exports.loadGltf=$s,exports.loadObj=Ji,exports.loadPbm=ki,exports.loadPly=tc,exports.loadPnts=Zs,exports.loadSpz=Is,exports.loadX3p=zl,exports.longitudeToHeading=Rt,exports.makeBoundingVolume=su,exports.panoEqual=zp,exports.panoParse=Rp,exports.panoStringify=Z,exports.parseWork=xm,exports.vectorToCoordinates=Lt,exports.workToJson=Ep;
2953
+ ----<<-与-t}yn-_r{qr]|tnz-一致:]|vv|{-为-h:?9?j-的-\0nq-坐标----sy|n-N-J-:q|5]|vv|{9-]|vv|{6H----vs-5N-I-:A;=6-qvpnqH----rp@-p|y|-J-P|y|;toH----sy|n-|}npv\b-J-r\x07}5N6-7-P|y|;nH----tylSntP|y|-J-rpA5p|y|;to9-|}npv\b6H\f`),Ab=new t.Vector3,jb=new t.Vector3,Mb=new t.Quaternion,Nb=new t.Quaternion,Pb=new t.Vector3,Fb=class extends t.Mesh{constructor(){super(),this.needsRender=!1,this.sortWorker=null,this.splatIndexCapacity=0,this.sortDataUploaded=!1,this.usedSHDegree=0,this.transformStore=null,this.objectParamsStore=null,this.transformsDirty=!1,this.layerRegistry=null,this.shStore=null,this.orderTexture=null,this.assembler=null,this.reorderPass=null,this.orderTarget=null,this.orderBaseSnapshot=[],this.sortGeneration=0,this.snapshotByGen=new Map,this.orderCount=0,this.orderDirty=!1,this.layoutDirty=!1,this.lastObjectsHash=``,this.lastClipperHash=``,this.prevSortCameraMatrix=null,this.sortCameraDistance=1,this.sortCameraCoorient=.99,this.sortMinIntervalMs=0,this.sortLastTime=-1/0,this.onBeforeRender=(e,n,r)=>{let i=r,a=this.collectObjects(n);if(a.length===0){this.geometry.instanceCount=0;return}let o=0,s=!1;for(let e of a)e.usedSHDegree>o&&(o=e.usedSHDegree),e.initAnimationEnabled&&(s=!0);let c=o!==this.usedSHDegree;this.usedSHDegree=o,this.updateInitAnimationDefine(s),this.isSceneChanged(a)?this.rebuild(e,a):c&&this.updateSH(a);for(let e of a)e.transformChanged&&this.transformStore.indexOf(e)!==void 0&&(this.transformStore.updateOne(e),this.transformsDirty=!0,e.transformChanged=!1,e.selectedChanged=!1),e.renderParamsChanged&&(this.objectParamsStore.updateOne(e),e.renderParamsChanged=!1,this.needsRender=!0);let l=new t.Matrix4().multiplyMatrices(i.perspectiveProjectionMatrix,i.matrixWorldInverse);this.requestSort(i,l.elements),(this.orderDirty||this.layoutDirty)&&(this.runReorder(e),this.orderDirty=!1,this.layoutDirty=!1);let u=a.map(e=>{let t=e.gsClippers.map(e=>{var t;return`${(t=e.floorIndex)==null?-1:t}:${e.clippingBoxMatrix.elements.join(`,`)}`}).join(`;`);return`${e.gsViewLayerKey}:${t}`}).join(`|`);u!==this.lastClipperHash&&(this.updateClipperUniforms(a),this.lastClipperHash=u,this.needsRender=!0),this.material.uniforms.resolution.value.set(i.resolution.x,i.resolution.y)},this.geometry=this.createGeometry(),this.material=this.createMaterial(),this.orderTexture=new sb,this.assembler=new fb,this.reorderPass=new wb,this.transformStore=new hb,this.objectParamsStore=new vb,this.layerRegistry=new yb,this.shStore=new Sb,this.material.uniforms.u_orderTexture.value=this.orderTexture.texture,this.material.uniforms.u_orderWidth.value=this.orderTexture.width,this.frustumCulled=!1,this.renderOrder=-99999999999,this.sortWorker=new Db,this.sortWorker.postMessage({warmup:!0}),this.sortWorker.onmessage=e=>{var t;if(e.data.depthIndex){let n=e.data.depthIndex;this.applyDepthIndex(n,e.data.generation);let r=n.buffer;r.byteLength>0&&((t=this.sortWorker)==null||t.postMessage({returnBuffer:r},[r]))}}}createGeometry(){let e=new t.InstancedBufferGeometry,n=new Float32Array([-2,-2,0,2,-2,0,2,2,0,-2,2,0]);e.setAttribute(`position`,new t.BufferAttribute(n,3)),e.setIndex(new t.BufferAttribute(new Uint16Array([0,1,2,0,2,3]),1)),this.splatIndexCapacity=1;let r=new Float32Array(this.splatIndexCapacity),i=new t.InstancedBufferAttribute(r,1,!1,1);return i.setUsage(t.DynamicDrawUsage),e.setAttribute(`splatIndex`,i),e._maxInstanceCount=this.splatIndexCapacity,e.instanceCount=0,e}ensureSplatIndexCapacity(e){let n=this.geometry.getAttribute(`splatIndex`);if(e<=this.splatIndexCapacity)return n;let r=Math.max(this.splatIndexCapacity,1);for(;r<e;)r*=2;let i=new Float32Array(r);i.set(n.array.subarray(0,Math.min(n.array.length,r)));let a=new t.InstancedBufferAttribute(i,1,!1,1);return a.setUsage(t.DynamicDrawUsage),this.geometry.setAttribute(`splatIndex`,a),this.splatIndexCapacity=r,this.geometry._maxInstanceCount=r,a}createMaterial(){return new t.ShaderMaterial({vertexShader:Ob,fragmentShader:kb,defines:{NUM_GS_LAYERS:0,NUM_GS_CLIPPERS:0,ENABLE_GS_INIT_ANIMATION:0,USE_ORDER_TEXTURE:1},uniforms:{u_texture:{value:null},u_transforms:{value:null},u_orderTexture:{value:null},u_orderWidth:{value:2048},u_numPoints:{value:0},u_numGsLayers:{value:0},u_numGsClippers:{value:0},u_layerClipperRanges:{value:[]},u_clipperMatricesInverse:{value:[]},u_shTexture:{value:null},u_shTextureSize:{value:new t.Vector2},u_maxShDegree:{value:0},resolution:{value:new t.Vector2},u_aggregationProgress:{value:0},u_aggregationBoundsMin:{value:new t.Vector3(0,0,0)},u_aggregationBoundsMax:{value:new t.Vector3(0,0,0)},u_aggregationPointDuration:{value:.6},u_objectParams:{value:null}},side:t.DoubleSide,transparent:!0,blending:t.NormalBlending,depthTest:!0,depthWrite:!1})}rebuildTransformsTexture(e){this.transformStore.sync(e),this.material.uniforms.u_transforms.value=this.transformStore.texture,this.transformsDirty=!0}rebuildObjectParamsTexture(e){this.objectParamsStore.sync(e,e=>this.transformStore.indexOf(e)),this.material.uniforms.u_objectParams.value=this.objectParamsStore.texture;for(let t of e)t.renderParamsChanged=!1}rebuildAssembled(e,t){this.assembler.sync(t,e=>({transformIndex:this.transformStore.indexOf(e),layerIndex:this.layerRegistry.layerIndexOf(e)})),this.assembler.assemble(e),this.material.uniforms.u_texture.value=this.assembler.texture}updateSH(e){this.shStore.sync(e,this.usedSHDegree),this.material.uniforms.u_shTexture.value=this.shStore.texture,this.material.uniforms.u_shTextureSize.value.copy(this.shStore.textureSize),this.material.uniforms.u_maxShDegree.value=this.shStore.appliedDegree}applyDepthIndex(e,t){let n=e.length,r=this.ensureSplatIndexCapacity(n);r.array.set(e,0),r.count=n,r.updateRange.offset=0,r.updateRange.count=n,r.needsUpdate=!0,this.orderTexture&&this.orderTexture.update(e);let i=this.snapshotByGen.get(t);if(i){this.orderBaseSnapshot=i;for(let e of this.snapshotByGen.keys())e<t&&this.snapshotByGen.delete(e)}this.orderCount=n,this.orderDirty=!0,this.geometry.instanceCount=n,this.needsRender=!0}snapshotLayout(){return this.assembler?this.assembler.regions.map(e=>({object:e.object,start:e.start,count:e.count})):[]}buildSegments(e,t){let n=new Map;for(let e of t)n.set(e.object,e.start);let r=[];for(let t of e){let e=n.get(t.object),i=e===void 0,a=i?0:e-t.start,o=r[r.length-1];o&&o.removed===i&&(i||o.delta===a)&&o.oldEnd===t.start?o.oldEnd=t.start+t.count:r.push({oldStart:t.start,oldEnd:t.start+t.count,delta:a,removed:i})}return r}runReorder(e){if(!this.reorderPass||!this.orderTexture||this.orderCount===0)return;let t=this.snapshotLayout(),n=this.buildSegments(this.orderBaseSnapshot,t),r=this.orderTexture.width,i=Math.max(1,Math.ceil(this.orderCount/r));this.orderTarget?(this.orderTarget.width!==r||this.orderTarget.height<i)&&this.orderTarget.setSize(r,Math.max(this.orderTarget.height,i)):this.orderTarget=wb.createOrderTarget(r,i),this.reorderPass.run(e,this.orderTexture.texture,r,this.orderTarget,n);let a=0;for(let e of t)a+=e.count;this.material.uniforms.u_orderTexture.value=this.orderTarget.texture,this.material.uniforms.u_orderWidth.value=r,this.material.uniforms.u_numPoints.value=a}postSortData(){var e;let t=++this.sortGeneration;this.snapshotByGen.set(t,this.snapshotLayout());let{positions:n,transformIndices:r,count:i}=this.assembler.extractSortInputs(),a=this.transformStore.transforms.slice(0,this.transformStore.objectCount*20);(e=this.sortWorker)==null||e.postMessage({sortData:{positions:n,transforms:a,transformIndices:r,vertexCount:i,generation:t}},[n.buffer,a.buffer,r.buffer]),this.sortDataUploaded=!0,this.transformsDirty=!1}shouldSort(e){if(this.transformsDirty||!this.sortDataUploaded||!this.prevSortCameraMatrix)return!0;this.prevSortCameraMatrix.decompose(Ab,Mb,Pb),e.matrixWorld.decompose(jb,Nb,Pb);let t=Ab.distanceTo(jb),n=Math.abs(Mb.dot(Nb));return t>this.sortCameraDistance||n<this.sortCameraCoorient}requestSort(e,n){var r;!this.assembler||this.assembler.totalPoints===0||this.shouldSort(e)&&(performance.now()-this.sortLastTime<this.sortMinIntervalMs||((this.transformsDirty||!this.sortDataUploaded)&&this.postSortData(),(r=this.sortWorker)==null||r.postMessage({viewProj:n}),this.prevSortCameraMatrix||(this.prevSortCameraMatrix=new t.Matrix4),this.prevSortCameraMatrix.copy(e.matrixWorld),this.sortLastTime=performance.now()))}collectObjects(t){let n=[];return t.traverse(t=>{t instanceof e.t&&t.visible&&n.push(t)}),n.sort((e,t)=>{let n=e.uuid+e.gsViewLayerKey,r=t.uuid+t.gsViewLayerKey;return n<r?-1:+(n>r)}),n}isSceneChanged(e){let t=e.map(e=>`${e.uuid}:${e.gsViewLayerKey}`).join(`|`);return t===this.lastObjectsHash?!1:(this.lastObjectsHash=t,!0)}rebuild(e,t){this.sortDataUploaded=!1,this.layerRegistry.sync(t),this.rebuildTransformsTexture(t),this.rebuildObjectParamsTexture(t),this.rebuildAssembled(e,t),this.material.uniforms.u_numPoints.value=this.assembler.totalPoints,this.ensureSplatIndexCapacity(this.assembler.totalPoints),this.updateSH(t),this.lastClipperHash=``,this.layoutDirty=!0,this.needsRender=!0}updateClipperUniforms(e){var n,r;let i=this.layerRegistry;if(!i||i.layerCount===0){this.material.uniforms.u_layerClipperRanges.value=[],this.material.uniforms.u_clipperMatricesInverse.value=[],this.updateClipperCounts(0,0);return}let a=new Map;for(let t of e)a.has(t.gsViewLayerKey)||a.set(t.gsViewLayerKey,t.gsClippers);let o=i.layerKeys.length,s=0;for(let e of i.layerKeys)s+=((n=a.get(e))==null?[]:n).length;let c=Array.from({length:o},()=>new t.Vector2(-1,0)),l=Array.from({length:s},()=>new t.Matrix4),u=0;for(let e of i.layerKeys){let t=i.layerKeyToIndex.get(e);if(t===void 0)continue;let n=(r=a.get(e))==null?[]:r,o=u;for(let e of n)l[u].getInverse(e.clippingBoxMatrix),u++;n.length>0&&c[t].set(o,n.length)}this.material.uniforms.u_layerClipperRanges.value=c,this.material.uniforms.u_clipperMatricesInverse.value=l,this.updateClipperCounts(o,u)}updateClipperCounts(e,t){let n=this.material.defines;(n.NUM_GS_LAYERS!==e||n.NUM_GS_CLIPPERS!==t)&&(n.NUM_GS_LAYERS=e,n.NUM_GS_CLIPPERS=t,this.material.needsUpdate=!0),this.material.uniforms.u_numGsLayers.value=e,this.material.uniforms.u_numGsClippers.value=t}updateInitAnimationDefine(e){let t=this.material.defines,n=+!!e;t.ENABLE_GS_INIT_ANIMATION!==n&&(t.ENABLE_GS_INIT_ANIMATION=n,this.material.needsUpdate=!0,this.needsRender=!0)}dispose(){this.sortWorker&&(this.sortWorker.terminate(),this.sortWorker=null),this.assembler&&(this.assembler.dispose(),this.assembler=null),this.reorderPass&&(this.reorderPass.dispose(),this.reorderPass=null),this.orderTarget&&(this.orderTarget.dispose(),this.orderTarget=null),this.transformStore&&(this.transformStore.dispose(),this.transformStore=null),this.objectParamsStore&&(this.objectParamsStore.dispose(),this.objectParamsStore=null),this.shStore&&(this.shStore.dispose(),this.shStore=null),this.layerRegistry=null,this.orderTexture&&(this.orderTexture.dispose(),this.orderTexture=null),this.geometry.dispose(),this.material.dispose()}},Ib=class extends t.Mesh{constructor(){super(),this.onBeforeRender=(e,t,n)=>{this.collectObjects(t).length>0&&console.warn(`未开启webgl2, 3dgs仅支持在开启webgl2模式后使用`)}}collectObjects(t){let n=[];return t.traverse(t=>{t instanceof e.t&&t.visible&&n.push(t)}),n}},Lb=1e3,Rb=90,zb=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/`),Bb=new t.Sphere,Vb=new t.Box3,Hb=new t.Vector4,Ub=new t.Vector4,Wb=new t.Color,Gb=new t.Vector2,Kb=new WeakMap,qb=wm([xm(null)]),Jb={},Yb=class e extends nn{static get version(){return`6.9.0`}static get dracoPath(){return co.decoderPath}static set dracoPath(e){co.setDecoderPath(e)}static get ktx2Path(){return _o.transcoderPath}static set ktx2Path(e){_o.setTranscoderPath(e)}static get useNativeImageBitmap(){return ii()}static set useNativeImageBitmap(e){ri(e)}constructor(e={}){var n,r,i,a,o,s,c,l,u,d,f;if(super(),this.pbmGaussianSplattingRenderMesh=null,this.fiveId=Zt(),Jb[this.fiveId]=this,this.currentUpdateArgs={time:V(),args:[]},this.currentMode=`Panorama`,this.pano={workCode:``,panoIndex:0},this.needsRender=!1,this.onlyRenderIfNeeds=(n=e.onlyRenderIfNeeds)==null?!0:n,this.imageOptions=Object.assign({},(r=e.imageOptions)==null?{}:r),this.textureOptions=Object.assign({},(i=e.textureOptions)==null?{}:i),this.poweredByRealsee=(a=e.poweredByRealsee)==null?!0:a,this.backgroundColor=new t.Color((o=e.backgroundColor)==null?1579548:o),this.backgroundAlpha=(s=e.backgroundAlpha)==null?1:s,this.extraElements=[],this.controllerInits={Panorama:Object.assign({},e.panorama),Model:Object.assign({},e.model),Floorplan:Object.assign({},e.floorplan),Topview:Object.assign({},e.topview),Mapview:Object.assign({},e.mapview),VRPanorama:Object.assign({},e.vrPanorama),XRPanorama:Object.assign({},e.xrPanorama)},this.fps={testCount:0,testTime:V()},this.modeChangeDuration=(c=e.modeChangeDuration)==null?Lb:c,this.enableWheel=(l=e.enableWheel)==null?!0:l,typeof window<`u`)if(`renderer`in e)e.renderer instanceof Uh&&this.throwError(Error(`cannot render a internal renderer`)),this.renderer=e.renderer;else try{this.renderer=new Uh({preserveDrawingBuffer:e.preserveDrawingBuffer,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});let t=Ky();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 t.WebGLRenderTarget(1,1,{encoding:(d=(u=this.renderer)==null?void 0:u.outputEncoding)==null?t.sRGBEncoding:d,generateMipmaps:!1}),this.viewport=Object.assign({left:0,bottom:0,width:1,height:1},e.viewport),this.camera=new Yt(Rb),this.scene=new Xh,this.xrCustomObjectsScene=new t.Scene,this.scene.add(this.xrCustomObjectsScene),this.scene.matrixAutoUpdate=!1,this.loadWorkTask=Promise.resolve(),this.requestProxy=(f=e.requestProxy)==null?zb:f,this.networkSubscribe=new ir,this.networkSubscribe.on(`network`,(e,t,n,r)=>{var i;this.emit(`network.resource`,Q(`network.resource`,{source:e,requestType:t,requestState:n,detail:r})),(i=this.analysis)==null||i.network(this.works,e,t,n,r)}),this.readyCallbacks=[],this.syncingState=!1,this.helperGroup=new t.Group,this.helperGroup.name=`helper`,this.helperGroup.matrixAutoUpdate=!1,this.scene.add(this.helperGroup),Kb.set(this,qb),this.modelScene=new xp({fiveId:this.fiveId}),this.modelScene.addEventListener(`model.create`,e=>{this.bindModel(e.model)}),this.scene.add(this.modelScene);let[p]=this.modelScene.setModels(qb,{forceReplaceImmediately:!0});B(p,`loaded`,{get(){return!1},set(e){}}),this.videoTexture=new t.VideoTexture(e.videoInstance||Uy());let m=Wy();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=ei.shared.add((e,t,...n)=>{this.updateTime(e,t,...n)},!1,0,10));let h=()=>{typeof document<`u`&&document.fullscreenElement===null&&this.currentMode===`VRPanorama`&&this.controller.emit(`vr.requestExit`,Q(`vr.requestExit`,{}))},g=()=>{this.needsRender=!0};if(typeof document<`u`&&document.addEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.addEventListener(`webglcontextrestored`,g,!1),this.removeEventListeners=()=>{typeof document<`u`&&document.removeEventListener(`fullscreenchange`,h,!1),this.renderer&&this.renderer.domElement.removeEventListener(`webglcontextrestored`,g,!1)},this.plugins={},e.plugins&&e.plugins.length){for(let t of e.plugins)if(typeof t==`function`)t(this);else if(Array.isArray(t)){let[e,n,r]=t;if(typeof e==`function`){let t=e(this,r);typeof n==`string`&&(this.plugins[n]?this.throwError(Error(`plugin name ${n} is exists.`)):this.plugins[n]=t)}}}Hy(this),this.fiveRenderer=new Hh,this.adaptiveLuminancePass=new Ym,this.adaptiveLuminancePass.enabled=!1,this.fiveRenderer.composer.addPass(this.adaptiveLuminancePass),this.eyeDomeLightingPass=new Qm(this.camera),this.eyeDomeLightingPass.enabled=!1,this.fiveRenderer.composer.addPass(this.eyeDomeLightingPass),e.webgl2?(this.pbmGaussianSplattingRenderMesh=new Fb,this.scene.add(this.pbmGaussianSplattingRenderMesh)):this.scene.add(new Ib)}get ident(){return this.fiveId}get panoIndex(){return this.pano.panoIndex}get panoId(){return Z(this.pano)}dispose(){var e;if(this.destroyed===!0)return;delete Jb[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 n=this.getElement();n&&n.parentNode&&n.parentNode.removeChild(n);let r=this.modelScene.parameter;r.pano0&&r.pano0.map.dispose(),r.pano1&&r.pano1.map!==((e=r.pano0)==null?void 0:e.map)&&r.pano1.map.dispose(),r.reset(`pano0`,`pano1`),this.modelScene.dispose(),this.scene.dispose(),this.xrCustomObjectsScene.dispose(),Kb.set(this,qb),this.renderer&&this.renderer.render(new t.Scene,new t.Camera),this.fiveRenderer.dispose(),this.renderer instanceof Uh&&(this.renderer.forceContextLoss&&this.renderer.forceContextLoss(),this.renderer.dispose())}setViewport(e){Object.assign(this.viewport,e),this.needsRender=!0}get boundingMesh(){return this.modelScene.boundingMesh}get helperVisible(){return this.helperGroup.visible}set helperVisible(e){this.helperGroup.visible!==e&&(this.helperGroup.visible=e,this.emit(`helpers.visible`,Q(`helpers.visible`,{object:this.helperGroup})),this.needsRender=!0)}updateConfiguration(e,t=!0){let n=!1,r=!1;e.panorama&&(Object.assign(this.controllerInits.Panorama,pr(e.panorama)),this.currentMode===`Panorama`&&(n=!0)),e.model&&(Object.assign(this.controllerInits.Model,pr(e.model)),this.currentMode===`Model`&&(n=!0)),e.floorplan&&(Object.assign(this.controllerInits.Floorplan,pr(e.floorplan)),this.currentMode===`Floorplan`&&(n=!0)),e.topview&&(Object.assign(this.controllerInits.Topview,pr(e.topview)),this.currentMode===`Topview`&&(n=!0)),e.mapview&&(Object.assign(this.controllerInits.Mapview,pr(e.mapview)),this.currentMode===`Mapview`&&(n=!0)),e.vrPanorama&&(Object.assign(this.controllerInits.VRPanorama,pr(e.vrPanorama)),this.currentMode===`VRPanorama`&&(n=!0)),e.xrPanorama&&(Object.assign(this.controllerInits.XRPanorama,pr(e.xrPanorama)),this.currentMode===`XRPanorama`&&(n=!0)),e.imageOptions&&(Object.assign(this.imageOptions,e.imageOptions),(this.currentMode===`Panorama`||this.currentMode===`VRPanorama`)&&(r=!0,n=!0)),e.textureOptions&&Object.assign(this.textureOptions,e.textureOptions),t&&n&&this.controller&&this.currentMode&&(!this.controller.updateConfiguration(this.controllerInits[this.currentMode])||r)&&this.changeMode(this.currentMode,this.getCurrentState(),0,!1,!0)}appendTo(e,t={}){if(!this.renderer)return;if(!(this.renderer instanceof Uh)){this.throwError(Error(`cannot call appendTo method when render a external renderer`));return}let n=this.getElement();if(!n)return;e.appendChild(n),this.refresh(t);let r=window.getComputedStyle(e).position;r!==`relative`&&r!==`absolute`&&r!==`fixed`&&r!==`sticky`&&(e.style.position=`relative`)}refresh(e={},t){var n,r,i;if(!this.renderer)return;let a=this.renderer.domElement.parentNode,{width:o=(n=a==null?void 0:a.offsetWidth)==null?512:n,height:s=(r=a==null?void 0:a.offsetHeight)==null?512:r}=e;if(o=Math.max(1,o),s=Math.max(1,s),!t){let e=Ky(),n=typeof window<`u`?window.devicePixelRatio:1;if(t=(i=e===1?n:1)==null?1:i,t>1){let e=Math.max(o,s)*t,n=Math.min(this.renderer.capabilities.maxTextureSize,4096);e>n&&(t=Math.max(t/e*n,1),t=Math.floor(t*100)/100)}}this.renderer.setPixelRatio(t),this.renderer.setSize(o,s),this.needsRender=!0;let c=V(),l=c-this.currentUpdateArgs.time,u=this.currentUpdateArgs.args;this.updateTime(c,l,...u)}addExtraElement(e){return this.extraElements.indexOf(e)===-1&&(this.extraElements.push(e),this.controller&&this.controller.bindExtraElement(e)),()=>this.removeExtraElement(e)}removeExtraElement(e){let t=this.extraElements.indexOf(e);t!==-1&&(this.extraElements.splice(t,1),this.controller&&this.controller.unbindExtraElement(e))}getSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}getDrawingBufferSize(e){if(!this.renderer)throw Error(`renderer is not initialized`);return this.renderer.getDrawingBufferSize(e),e.x*=this.viewport.width,e.y*=this.viewport.height,e}updateCamera(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCamera(e,t,n)}updateCameraWithKeyframes(e,t,n=!0){if(!this.controller)throw Error(`controller is not initialized.`);return this.controller.updateCameraWithKeyframes(e,t,n)}get works(){return Kb.get(this)||qb}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(()=>gg(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_(n,r,i,a=!0){var o,s,c,l,u,d,f,p,m,h;let g={};typeof i==`number`?g.duration=i:typeof i==`object`&&Object.assign(g,i),this.works===qb&&(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(n))for(let e of n)e instanceof bm?v.push(e):typeof e!=`string`&&`work`in e?v.push(xm(e.work,e)):v.push(xm(e));else n instanceof bm?v.push(n):v.push(xm(n));g.mode===`add`&&(v=[].concat(this.works,v));let y;try{y=wm(v)}catch(e){return this.throwError(e),Promise.reject(e)}for(let e of y)this.bindWorkFetcher(e);r===void 0&&(r=`inherit`),r===`inherit`&&this.works===qb&&(r=`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=(o=x.mode)==null?S?`Panorama`:`Mapview`:o,T={};if(r===`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{r={mode:b};let e=(c=(s=y[0])==null?void 0:s.observers)==null?void 0:c[this.panoIndex];e?(r.workCode=e.work.workCode,r.panoIndex=e.panoIndex):typeof y.initial.panoIndex==`number`?(r.workCode=y.initial.work.workCode,r.panoIndex=y.initial.panoIndex):(r.mode===`Panorama`||r.mode===`VRPanorama`||r.mode===`XRPanorama`)&&(r.mode=`Mapview`),r.mode===b&&(r.longitude=this.camera.pose.longitude,r.latitude=this.camera.pose.latitude,r.fov=this.camera.pose.fov)}}if(r===`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 r==`object`){if(w=(u=r.mode)==null?b:u,typeof r.panoIndex==`number`){let e=y.getObserver({workCode:(f=(d=r.workCode)==null?x.work.workCode:d)==null?``:f,panoIndex:r.panoIndex});e&&(C={workCode:e.work.workCode,panoIndex:e.panoIndex})}T={longitude:r.longitude,latitude:r.latitude,fov:r.fov,distance:r.distance,offset:r.offset?new t.Vector3().copy(r.offset):void 0}}let E=(p=g.duration)==null?this.modeChangeDuration:p;(w===`Floorplan`||w===`Topview`||w===`Mapview`)&&b===w&&(E=0);let D=`fly`;(w===`Panorama`||w===`VRPanorama`||w===`XRPanorama`)&&b===w&&(D=(m=g.effect)==null?`fade`:m),this.emit(`works.request`,Q(`works.request`,{input:n,works:y,userAction:a}));let O=(e,t,n)=>{let i=this.getCurrentState(),o=Object.assign(Object.assign({mode:e},t),n);r===`inherit`&&(o=this.getCurrentState()),this.pano=t;let s=Object.assign(Object.assign({initial:{state:o,currentState:i,duration:E,effect:D,userAction:a}},this.commonParams()),this.controllerInits[e]),c=zy[o.mode].initAnimationEndState(s);if(this.controller&&b===e)this.controller.updateWork(y,c,{effect:D,duration:E},a)===!1&&(this.controller.destroy(),this.controller=this.applyController(e,s));else{if(this.controller)this.controller.destroy();else{let t=zy[e].initAnimationEndState(s);this.camera.setFromPose(t),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a}))}this.controller=this.applyController(e,s);let t=Q(`mode.change`,{prevMode:b,mode:e,state:c,userAction:a});try{this.emit(`mode.change`,t)}catch(e){console.error(e)}}this.updateTime(this.currentUpdateArgs.time,0,...this.currentUpdateArgs.args)};Kb.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),Dg(this.state,this.camera.pose));let e=this.modelScene.setModels(y,_);k=Promise.all(e.map(e=>e.loadedReady)).then(()=>{this.needsRender=!0,O(w,C,T),this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a}))})}else{O(w,C,T);let e=this.controller,t=!1;this.modelScene.autoRefine=!1;let n=()=>{this.works===y&&t===!1&&(this.needsRender=!0,this.emit(`camera.update`,Q(`camera.update`,{state:this.getCurrentState(),userAction:a})),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(G),e.once(`pano.arrived`,n),e.once(`pano.cancel`,n),setTimeout(n,((h=g.duration)==null?this.modeChangeDuration:h)+1e3)}return this.emit(`works.load`,Q(`works.load`,{input:n,userAction:a,works:y})),k.then(()=>this.ready()).then(()=>{var e;this.emit(`works.ready`,Q(`works.ready`,{input:n,userAction:a,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 n;this.controller&&(this.controller.destroy(),this.controller=void 0);let r=this.modelScene.parameter;r.pano0&&r.pano0.map.dispose(),r.pano1&&r.pano1.map!==((n=r.pano0)==null?void 0:n.map)&&r.pano1.map.dispose(),r.set({pano0:null,pano1:null,modelAlpha:1}),Kb.set(this,qb),this.modelScene.setModels(qb,{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:Rb,longitude:0,latitude:0,offset:new t.Vector3(0,0,0)}),this.state={mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:this.camera.pose.offset.clone(),distance:this.camera.pose.distance},this.camera.needsRender=!1,this.needsRender=!1,e()})}changeMode(t,n={},r,i=!0,a=!1){return new Promise((o,s)=>{var c,l,u,d;if(!this.renderer)throw Error(`renderer is not initialized.`);n=Object.assign({},n);let f=0;this.controller&&(f=typeof r==`number`?r:(c=r==null?void 0:r.duration)==null?this.modeChangeDuration:c);let p=`fly`;this.controller&&typeof r==`object`&&r.effect&&(p=r.effect);let m=typeof n.panoIndex==`number`?{workCode:(d=(l=n.workCode)==null?(u=this.work)==null?void 0:u.workCode:l)==null?``:d,panoIndex:n.panoIndex}:this.pano;if(!e.Mode.hasOwnProperty(t)){let e=Error(`mode "${t}" is not existed`);this.throwError(e),s(e);return}if((t===e.Mode.Panorama||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama)&&!this.works.getObserver(m)){let e=Error(`PanoId ${Z(m)} not existed.`);this.throwError(e),s(e);return}(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)&&this.modelScene.empty&&(f=0);let h=this.controller,g=this.currentMode,_=()=>{if(this.controller&&this.controller.stopMomentumMovement(),this.controller&&a===!1&&g===t)t===e.Mode.Panorama||t===e.Mode.Model||t===e.Mode.VRPanorama||t===e.Mode.XRPanorama?!zp(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(G):(zp(this.pano,m)||(this.pano=m),this.controller.updateCamera(n,f,i).catch(G));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=zy[t].initAnimationEndState(r),o=Q(`mode.change.request`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});if(this.emit(`mode.change.request`,o),!o.defaultPrevented){h&&h.destroy(),this.controller=this.applyController(t,r);let e=Q(`mode.change`,{prevMode:this.currentMode,mode:t,state:a,userAction:i});this.emit(`mode.change`,e)}}o()},v=ei.shared.getContext();v&&(typeof XRSession<`u`&&v instanceof XRSession&&v.end(),ei.shared.setContext(null)),t===e.Mode.VRPanorama?(this.requestFullscreen(),Cg().then(()=>_()).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.exitFullscreen(),this.throwError(t),s(t)})):t===e.Mode.XRPanorama?wg().then(e=>{ei.shared.setContext(e),a=!0,_()}).catch(e=>{let t=e instanceof Error?e:Error(String(e));this.throwError(t),s(t)}):_()})}getPixels(e,n,r,i,a,o,s){if(!this.renderer)throw Error(`renderer is not initialized.`);let c=V(),l=this.renderer.getPixelRatio(),u=this.renderer.getRenderTarget(),d=this.getSize(new t.Vector2),f=0,p=0,m=1,h=1,g,_,v,y,b;typeof e==`number`?(f=e,typeof n==`number`&&(p=n),typeof r==`number`&&(m=r),typeof i==`number`&&(h=i),g=a,_=o,b=s):(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 zy.Panorama||this.controller instanceof zy.VRPanorama||this.controller instanceof zy.XRPanorama)&&y===!0&&this.modelScene.parameter.set(`modelAlpha`,1),this.modelScene.update(this.renderer,this.camera);let C=this.getPixelsRenderTarget;C.setSize(m*g,h*g),this.renderer.setRenderTarget(C),this.camera.pixelRatio=g,this.camera.resolution.set(m,h),this.camera.setViewOffset(d.width,d.height,f,d.height-p-h,m,h),this.camera.aspect=d.width/d.height,this.camera.updateTime(c),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=Wb.copy(this.renderer.getClearColor()),k=this.renderer.getClearAlpha(),A=this.renderer.getScissorTest();this.renderer.autoClear=!0,this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.autoClearStencil=!0,this.renderer.setScissorTest(!1);let j=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:j,this.renderer.render(this.scene,this.camera),this.scene.background=j,this.renderer.autoClear=w,this.renderer.autoClearColor=T,this.renderer.autoClearDepth=E,this.renderer.autoClearStencil=D,this.renderer.setClearColor(O,k),this.renderer.setScissorTest(A),this.helperVisible=x,S===void 0?this.modelScene.parameter.reset(`modelAlpha`):this.modelScene.parameter.set(`modelAlpha`,S),this.renderer.setRenderTarget(u),this.camera.clearViewOffset(),this.camera.pixelRatio=l,this.camera.resolution.copy(d),this.camera.aspect=this.camera.resolution.width/this.camera.resolution.height,this.camera.updateTime(c),this.modelScene.update(this.renderer,this.camera),this.scene.update(this.renderer,this.camera);let M=m*g,N=h*g,ee=M*N,te=ee*4;if(b){if(b.length!==te)throw Error(`buffer length is not equals pixels ${te}`)}else b=new Uint8Array(te);if(this.renderer.readRenderTargetPixels(C,0,0,m*g,h*g,b),_){let e=ee/2;for(let t=0,n=0,r=0,i=0;n<e;n++)for(i=(N-Math.floor(n/M)-1)*M+n%M,r=0;r<4;r++)t=b[n*4+r],b[n*4+r]=b[i*4+r],b[i*4+r]=t}return b}getElement(){var e;return(e=this.renderer)==null?void 0:e.domElement}render(e){let t=this.renderer;if(!t)return;let n=t.getRenderTarget();t.setRenderTarget(null);let r=t.autoClear,i=t.autoClearColor,a=t.autoClearDepth,o=t.autoClearStencil,s=Wb.copy(t.getClearColor()),c=t.getClearAlpha(),l=t.getViewport(Hb),u=t.getScissor(Ub),d=t.getScissorTest();t.autoClear=!0,t.autoClearColor=!0,t.autoClearDepth=!0,t.autoClearStencil=!0;let f=t.getSize(Gb),p=Math.floor(f.x*this.viewport.left),m=Math.floor(f.y*this.viewport.bottom),h=Math.floor(f.x*this.viewport.width),g=Math.floor(f.y*this.viewport.height);t.setClearColor(this.backgroundColor,this.backgroundAlpha),t.setViewport(p,m,h,g),t.setScissor(p,m,h,g);let _=this.viewport.bottom!==0||this.viewport.left!==0||this.viewport.width!==1||this.viewport.height!==1;t.setScissorTest(_);let v=this.scene.background;this.scene.background=this.camera.isOrthographicCamera?null:v;let y=!0;if(this.controller&&this.controller.render()&&(y=!1),y){let e=this.fiveRenderer.render(t,this.scene,this.modelScene,this.camera,this.needsRender);this.poweredByRealsee&&e&&ob(t)}this.scene.background=v,t.autoClear=r,t.autoClearColor=i,t.autoClearDepth=a,t.autoClearStencil=o,t.setClearColor(s,c),t.setViewport(l),t.setScissor(u),t.setScissorTest(d),t.setRenderTarget(n),e&&ei.shared.add(e,!0)}updateTime(e,t,...n){if(this.currentUpdateArgs={time:e,args:n},this.destroyed)return;if(this.renderer&&_o.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),ei.shared.add(()=>{this.emit(`models.load`,Q(`models.load`,{modelScene:this.modelScene}))},!0,0,10)),t===!1&&this.modelScene.refined===!0&&ei.shared.add(()=>{this.emit(`models.refined`,Q(`models.refined`,{modelScene:this.modelScene}))},!0,0,10)}if(this.camera.autoNearFar){Vb.makeEmpty(),Vb.expandByObject(this.modelScene.boundingMesh);let t=Vb.getBoundingSphere(Bb),n=t.radius*2;t.containsPoint(this.camera.position)||(n=this.camera.position.distanceTo(t.center)+t.radius),n=H(n,800);let r=n/1e4;r=H(r,.03,.1),this.camera.near!==r&&(this.camera.near=r),this.camera.far!==n&&(this.camera.far=n),this.camera.updateTime(e)}if(this.renderer){let e=this.modelScene.visible;this.modelScene.visible=!1,this.scene.update(this.renderer,this.camera),this.modelScene.visible=e}if(this.syncingState=!1,this.controller&&this.controller.needsRender===!0&&(this.controller.needsRender=!1,this.needsRender=!0),this.camera.needsRender===!0&&(this.camera.needsRender=!1,this.needsRender=!0),this.modelScene.needsRender===!0&&(this.modelScene.needsRender=!1,this.needsRender=!0),this.scene.needsRender===!0&&(this.scene.needsRender=!1,this.needsRender=!0),this.pbmGaussianSplattingRenderMesh&&this.pbmGaussianSplattingRenderMesh.needsRender===!0&&(this.pbmGaussianSplattingRenderMesh.needsRender=!1,this.needsRender=!0),this.onlyRenderIfNeeds!==!0&&(this.needsRender=!0),this.paused===!0)return;let r=Q(`render.prepare`,{needsRender:this.needsRender});this.emit(`render.prepare`,r),r.defaultPrevented&&(this.needsRender=!1);let i=this.needsRender;this.render(),this.needsRender=!1,this.emit(`render`,Q(`render`,{needsRender:i})),this.hasListener(`fps`)&&(this.fps.testTime&&e-this.fps.testTime<1e3?this.fps.testCount++:(this.emit(`fps`,this.fps.testCount),this.fps.testTime=e,this.fps.testCount=0))}pause(){this.paused=!0,this.renderer&&this.renderer instanceof Uh&&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=G){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=V();return Promise.all(r.map(e=>{let t=Z({panoIndex:n.panoIndex,workCode:n.work.workCode}),r=Object.assign({key:`pano.${t}.${e}`},dr(this.imageOptions,[`size`,`format`,`quality`,`forceUseExifOrientation`,`mappings`])),i=n.work.getURL(n.images[e]),a=this.imageOptions.transform?this.imageOptions.transform(i,r):Ur(i,r);return Gf(this.fiveId,n.work).preload(a)})).then(()=>{let e=V()-i;return t(e),e})}project2d(e,n=!1){if(!this.renderer)return null;if(n){let n=this.camera.position,r=e.clone().sub(n),i=new t.Raycaster(n,r.clone().normalize());i.params.Points={threshold:.1};let[a]=this.modelScene.intersectRaycaster(i);if(a&&a.distance+.01<r.length())return null}let r=e.clone().project(this.camera);if(Math.abs(r.z)>1)return null;let i=this.renderer.getSize(new t.Vector2),a=i.x*this.viewport.width,o=i.y*this.viewport.height,s=i.x*this.viewport.left+(r.x+1)/2*a,c=i.y*(1-this.viewport.bottom-this.viewport.height)+(-r.y+1)/2*o;return new t.Vector2(s,c)}getCurrentState(){return Object.assign(Object.assign({},this.camera.copyPose()),{mode:this.currentMode,workCode:this.pano.workCode,panoIndex:this.pano.panoIndex})}setState(e,n=!1,r=!0){var i,a,o,s,c,l,u,d,f,p;e=dr(e,[`mode`,`workCode`,`panoIndex`,`longitude`,`latitude`,`fov`,`offset`,`distance`]),e.offset&&!(e instanceof t.Vector3)&&(e.offset=new t.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=(a=(i=this.work)==null?void 0:i.workCode)==null?``:a,n=this.state.workCode;this.works.filter(e=>e.workCode===n).length>0&&(t=n),m={workCode:t,panoIndex:e.panoIndex}}let h=(o=e.mode)==null?this.state.mode:o,g,_,v,y,b;if(this.controller&&this.controller.stopMomentumMovement(),this.state.mode!==h){if(h===`VRPanorama`){this.changeMode(`VRPanorama`,void 0,void 0,!0);return}let n={workCode:m==null?void 0:m.workCode,panoIndex:m==null?void 0:m.panoIndex};typeof e.longitude==`number`&&(n.longitude=e.longitude),typeof e.latitude==`number`&&(n.latitude=e.latitude),typeof e.fov==`number`&&(n.fov=e.fov),typeof e.distance==`number`&&(n.distance=e.distance),e.offset instanceof t.Vector3&&(n.offset=e.offset);let r=Object.assign(Object.assign({initial:{state:n,currentState:this.getCurrentState(),duration:this.modeChangeDuration,effect:`fly`,userAction:!1}},this.commonParams()),this.controllerInits[h]),i=zy[h].initAnimationEndState(r);g=i.longitude,_=i.latitude,v=i.fov,y=i.offset,b=i.distance}else g=(s=e.longitude)==null?this.state.longitude:s,_=(c=e.latitude)==null?this.state.latitude:c,v=(l=e.fov)==null?this.state.fov:l,y=(u=e.offset)==null?this.state.offset:u,b=(d=e.distance)==null?this.state.distance:d;let x={workCode:(m==null?this.pano:m).workCode,panoIndex:(m==null?this.pano:m).panoIndex,mode:h,longitude:g,latitude:_,fov:v,offset:y,distance:b};this.emit(`state.set`,Q(`state.set`,{userAction:r,state:x})),Eg(this.state,x)||(this.controller&&x.mode===`VRPanorama`&&x.mode!==this.state.mode?(Tg(this.state,x),this.changeMode(`VRPanorama`)):this.controller&&x.mode===`XRPanorama`&&x.mode!==this.state.mode?(Tg(this.state,x),this.changeMode(`XRPanorama`)):(Tg(this.state,x),this.controller&&r&&(this.controller.userAction=!1),n&&this.state.mode===x.mode&&(this.syncingState=this.syncState(V(),0,n),this.syncingState&&((f=this.controller)==null||f.updateTime(V(),0),this.syncingState=!1)),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(p=this.analysis)==null||p.state(this.works,this.state)))}syncState(n,r,i=!1){let a=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 zy.Model){if(hg(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:i?0:void 0}),!1),!0}}else{let e={workCode:this.state.workCode,panoIndex:this.state.panoIndex};if(!zp(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 zy.Floorplan||this.controller instanceof zy.Topview||this.controller instanceof zy.Mapview){let e=.2,n=Math.PI/45,r=i?this.state.fov:Hm(this.camera.pose.fov,this.state.fov,1),a=Math.abs(this.camera.pose.distance-this.state.distance),o=a>e*15?a/15:.2,s=i?this.state.distance:Hm(this.camera.pose.distance,this.state.distance,o),c=this.camera.pose.offset.distanceTo(this.state.offset),l=c>e*15?c/15:e,u=i?new t.Vector3().copy(this.state.offset):Um(this.camera.pose.offset,this.state.offset,l),{longitude:d,latitude:f}=i?{longitude:this.state.longitude,latitude:this.state.latitude}:Wm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},n);if(pg(r,this.camera.pose.fov)||hg(u,this.camera.pose.offset)||pg(s,this.camera.pose.distance)||pg(d,this.camera.pose.longitude,Math.PI*2)||pg(f,this.camera.pose.latitude)){let e={x:u.x,y:u.y,z:u.z},t={fov:r};return Object.assign(e,{distance:s}),Object.assign(t,{longitude:d,latitude:f}),this.controller.stopMomentumMovement(),this.controller.cameraMotion.set(t,0).catch(G),this.controller.locationMotion.set(e,0).catch(G),!0}}else{let e=Math.PI/45,n=i?this.state.fov:Hm(this.camera.pose.fov,this.state.fov,1),{longitude:r,latitude:a}=i?{longitude:this.state.longitude,latitude:this.state.latitude}:Wm({longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude},{longitude:this.state.longitude,latitude:this.state.latitude},e),o=this.state.distance,s=new t.Vector3().copy(this.state.offset);if(pg(o,this.camera.pose.distance)&&(this.state.distance=this.camera.pose.distance),hg(s,this.camera.pose.offset)&&(this.state.offset=this.camera.pose.offset.clone()),pg(r,this.camera.pose.longitude,Math.PI*2)||pg(a,this.camera.pose.latitude)||pg(n,this.camera.pose.fov))return this.controller.stopMomentumMovement(),this.controller.cameraMotion.set({longitude:r,latitude:a,fov:n},0).catch(G),!0}if(this.stateSynced=!0,a===!1&&this.emit(`state.synced`,Q(`state.synced`,{userAction:!1,state:this.state})),this.readyCallbacks.length&&this.stateSynced){let t=this.currentMode;if(!(t===e.Mode.Floorplan||t===e.Mode.Topview||t===e.Mode.Mapview||t===e.Mode.Model)||this.modelScene.loaded){let e=this.readyCallbacks.slice();this.readyCallbacks.length=0;for(let t of e)this.controller instanceof zy.Panorama&&t.tile===!0&&!this.controller.isTileReady()?this.readyCallbacks.push(t):t()}}return!1}ready(e={}){return new Promise(t=>{var n;this.readyCallbacks.push(Object.assign(t,{tile:(n=e.tile)==null?!1:n}))}).then(()=>this.model.initReady).then(G)}requestFullscreen(){var e;if(!yg)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=()=>{ei.shared.add(()=>{this.emit(`model.load`,Q(`model.load`,{work:e.work,model:e,error:null}))},!0)},n=t=>{let{error:n}=t;this.emit(`model.error`,Q(`model.error`,{work:e.work,model:e,error:n})),this.throwError(n)},r=()=>{this.emit(`model.changeShownFloor`,Q(`model.changeShownFloor`,{work:e.work,model:e,error:null}))},i=t=>{this.emit(`models.tileLoad`,Q(`model.tileLoad`,{work:e.work,model:e,tile:t.tile}))},a=t=>{this.emit(`models.tileUnload`,Q(`model.tileUnload`,{work:e.work,model:e,tile:t.tile}))},o=()=>{e.removeEventListener(`load`,t),e.removeEventListener(`error`,n),e.removeEventListener(`changeShownFloor`,r),e.removeEventListener(`tileLoad`,i),e.removeEventListener(`tileUnload`,a),e.removeEventListener(`dispose`,o)};e.addEventListener(`load`,t),e.addEventListener(`error`,n),e.addEventListener(`changeShownFloor`,r),e.addEventListener(`tileLoad`,i),e.addEventListener(`tileUnload`,a),e.addEventListener(`dispose`,o),this.emit(`model.request`,Q(`model.request`,{work:e.work,model:e,error:null}))}bindWorkFetcher(e){let t=this,n=e.workCode,r=e.allowHosts,i=new lr({get networkSubscribe(){return t.networkSubscribe},requestProxy(e){return Promise.resolve(e).then(e=>t.requestProxy(e,n)).then(e=>{let t=cm(e,r);return t instanceof Error?Promise.reject(t):t})}});Kf(this.fiveId,e,i)}commonParams(){return{fiveId:this.fiveId,scene:this.scene,xrCustomObjectsScene:this.xrCustomObjectsScene,helper:this.helperGroup,camera:this.camera,renderer:this.renderer,viewport:this.viewport,element:this.getElement(),works:this.works,imageOptions:this.imageOptions,enableWheel:this.enableWheel,extraElements:this.extraElements,videoTexture:this.videoTexture,modelScene:this.modelScene}}applyController(t,n){if(!this.renderer)throw Error(`renderer is not initialized.`);let r=zy[t];this.currentMode=t;let i=new r(n);for(let e of Vy)i.on(e,(...t)=>{if(this.emit(e,...t))return!1});{let e=zy[t].initAnimationEndState(n),r=n.initial.userAction;Eg(this.state,e)||(Tg(this.state,e),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state}))),this.emit(`currentState.change`,Q(`currentState.change`,{userAction:r,state:this.getCurrentState()}))}return i.on(`camera.update`,e=>{var t;if(this.controller){let n=this.controller.getTargetState();e.userAction&&this.syncingState===!1&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:e.userAction,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}this.emit(`currentState.change`,Q(`currentState.change`,{userAction:e.userAction,state:this.getCurrentState()}))}),i.on(`initAnimation.start`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`initAnimation.end`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.arrived`,e=>{var t;let{state:n,userAction:r}=e;this.pano={workCode:n.workCode,panoIndex:n.panoIndex},r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.cancel`,e=>{var t;let{state:n,userAction:r}=e;r&&this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),this.emit(`state.change`,Q(`state.change`,{userAction:r,state:this.state})),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.error`,e=>{var t;let{state:n}=e;this.state.mode===n.mode&&!Eg(this.state,n)&&(Tg(this.state,n),(t=this.analysis)==null||t.state(this.works,this.state))}),i.on(`pano.moveTo`,e=>{let{userAction:t}=e;this.emit(`currentState.change`,Q(`currentState.change`,{userAction:t,state:this.getCurrentState()}))}),i.on(`pano.request`,e=>{this.emit(`pano.request`,e),e.defaultPrevented||this.moveToPano(e.state,e.options,e.userAction)}),i.on(`vr.requestExit`,()=>{this.currentMode===e.Mode.VRPanorama&&(this.exitFullscreen(),this.changeMode(e.Mode.Panorama))}),i.on(`error`,e=>this.throwError(e)),i}removeEventListeners(){}get internalLightsEnabled(){let e=this.scene.children.find(e=>e.name===`internalLights`);return e?e.visible:!1}set internalLightsEnabled(e){let t=this.scene.children.find(e=>e.name===`internalLights`);t&&(t.visible=e),t=this.modelScene.children.find(e=>e.name===`internalLights`),t&&(t.visible=e)}get scissor(){return this.viewport}setScissor(e){return this.setViewport(e)}getPose(){let{longitude:e,latitude:t,fov:n,offset:r,distance:i}=this.camera.copyPose();return{longitude:e,latitude:t,fov:n,offset:r.clone(),distance:i}}getLongitudeAndLatitude(){let{longitude:e,latitude:t}=this.getPose();return{longitude:e,latitude:t}}getOffset(){return this.getPose().offset}getCameraLocal(){if(this.pano.workCode&&this.controller&&this.works){let e=this.works.getObserver(this.pano);if(e){let n=new t.Object3D;n.matrix.copy(e.matrix).premultiply(e.work.transform),n.matrix.decompose(n.position,n.quaternion,n.scale),n.matrixAutoUpdate=!1;let r=new t.Vector3(0,0,-1);r.applyQuaternion(this.camera.quaternion);let i=n.quaternion.clone().inverse();return r.applyQuaternion(i),{theta:Math.atan2(r.x,-r.z),phi:-Math.asin(r.y),lookAtVector:r}}}return null}addPass(e){this.fiveRenderer.composer.addPass(e)}removePass(e){let t=this.fiveRenderer.composer.passes.indexOf(e);t!==-1&&this.fiveRenderer.composer.passes.splice(t,1)}insertPass(e,t){this.fiveRenderer.composer.insertPass(e,t)}get renderMode(){return this.fiveRenderer.renderMode}set renderMode(e){this.fiveRenderer.renderMode=e}get enableHQ(){return this.fiveRenderer.renderMode===`point-cloud-high-quality`}set enableHQ(e){this.fiveRenderer.renderMode=e?`point-cloud-high-quality`:`default`,this.needsRender=!0}get enableEDL(){return this.eyeDomeLightingPass.enabled}set enableEDL(e){this.eyeDomeLightingPass.enabled=e,this.needsRender=!0}get enableAdaptiveLuminance(){return this.adaptiveLuminancePass.enabled}set enableAdaptiveLuminance(e){this.adaptiveLuminancePass.enabled=e,this.needsRender=!0}get enableIOSEDR(){return!1}set enableIOSEDR(e){}get enablePostProcessing(){return!0}set enablePostProcessing(e){}get modelSceneNeedsRender(){return this.modelScene.needsRender}set modelSceneNeedsRender(e){this.modelScene.needsRender=e}};Yb.Mode={Panorama:`Panorama`,Model:`Model`,Floorplan:`Floorplan`,Topview:`Topview`,Mapview:`Mapview`,VRPanorama:`VRPanorama`,XRPanorama:`XRPanorama`},typeof window<`u`&&Object.assign(window,{__FIVE_DEBUG__:{THREE:t,constructor:Yb,instances:Jb}});var Xb=class{static createButton(e){let t=document.createElement(`button`);function n(){t.style.display=``,t.style.cursor=`pointer`,t.style.left=`calc(50% - 50px)`,t.style.width=`100px`,t.textContent=`ENTER VR`,t.onmouseenter=function(){t.style.opacity=`1.0`},t.onmouseleave=function(){t.style.opacity=`0.5`},t.onclick=function(){e&&e()}}function r(){t.style.display=``,t.style.cursor=`auto`,t.style.left=`calc(50% - 75px)`,t.style.width=`150px`,t.onmouseenter=null,t.onmouseleave=null,t.onclick=null}function i(){r(),t.textContent=`VR NOT SUPPORTED`}function a(e){e.style.position=`absolute`,e.style.bottom=`20px`,e.style.padding=`12px 6px`,e.style.border=`1px solid #fff`,e.style.borderRadius=`4px`,e.style.background=`rgba(0,0,0,0.1)`,e.style.color=`#fff`,e.style.font=`normal 13px sans-serif`,e.style.textAlign=`center`,e.style.opacity=`0.5`,e.style.outline=`none`,e.style.zIndex=`999`}if(`xr`in navigator)return t.id=`VRButton`,t.style.display=`none`,a(t),navigator.xr.isSessionSupported(`immersive-vr`).then(function(e){e?n():i()}),t;{let e=document.createElement(`a`);return window.isSecureContext===!1?(e.href=document.location.href.replace(/^http:/,`https:`),e.innerHTML=`WEBXR NEEDS HTTPS`):(e.href=`https://immersiveweb.dev/`,e.innerHTML=`WEBXR NOT AVAILABLE`),e.style.left=`calc(50% - 90px)`,e.style.width=`180px`,e.style.textDecoration=`none`,a(e),e}}};exports.AdaptiveLuminancePass=Ym,exports.AnimationFrameLoop=ei,exports.BoundingMesh=yp,exports.Camera=Yt,exports.CustomShader=an,exports.PBMCustomShader=an,exports.EffectComposer=Tm,exports.EyeDomeLightingPass=Qm,exports.Fetcher=lr,exports.Five=Yb,exports.FivePass=Dm,exports.FiveRenderer=Hh,exports.FlowingFireworks3DPass=wh,exports.FlowingLight2DPass=lh,exports.FlowingLight3DPass=mh,exports.FullScreenQuad=Em,exports.GaussianBlurPass=th,exports.Histogram=zm,exports.InternalWebGLRenderer=Uh,exports.Model=up,exports.ModelScene=xp,exports.Motion=X,exports.NetworkSubscribe=ir,exports.PBMContainer=Wn,exports.PBMGSObject=e.t,exports.PBMGroup=vt,exports.PBMMesh=mn,exports.PBMMeshMaterial=pn,exports.PBMPanoFilter=on,exports.PBMPointCloud=wn,exports.PBMPointCloudMaterial=Cn,exports.PBMSkinnedMesh=hn,exports.PBMUpdateable=rn,exports.PROXY_CONTROLLER_EVENT_NAMES=Vy,exports.PanoCircleMesh=tg,exports.PanoCircleMeshCustom=dg,exports.PanoCircleMeshSolid=og,exports.Parameter=W,exports.Scene=Xh,exports.Subscribe=nn,exports.TextureLoader=fi,exports.Tile=gu,exports.Tile3D=Uf,exports.Tile3DModel=Uf,exports.TileCache=Hd,exports.TileNode=jd,exports.TileRequestScheduler=zd,exports.Tileset=Jd,exports.Trajectory=Fd,exports.TrajectoryNode=Id,exports.Work=bm,exports.WorkResolvedObserver=Cm,exports.XRButton=Xb,exports.controllersDefaultInitArgs=By,exports.coordinatesToVector=It,exports.createDebugBoundingMesh=du,exports.createWorks=wm,exports.defaultImageURLTransform=Ur,exports.draco=co,exports.getViewportScale=Ky,exports.headingToLongitude=zt,exports.imageSupport=Er,exports.isBoundingVolume=ou,exports.isPanoId=Bp,exports.ktx2=_o,exports.loadAt3d=ca,exports.loadB3dm=Ws,exports.loadDome=fa,exports.loadDomez=ya,exports.loadFbx=al,exports.loadGltf=$s,exports.loadObj=Ji,exports.loadPbm=ki,exports.loadPly=tc,exports.loadPnts=Zs,exports.loadSpz=Is,exports.loadX3p=zl,exports.longitudeToHeading=Rt,exports.makeBoundingVolume=su,exports.panoEqual=zp,exports.panoParse=Rp,exports.panoStringify=Z,exports.parseWork=xm,exports.vectorToCoordinates=Lt,exports.workToJson=Ep;