@realsee/five 6.4.0-alpha.13 → 6.4.0-alpha.14

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/umd/five.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five
4
- * Generated: 1/14/2025
5
- * Version: 6.4.0-alpha.13
4
+ * Generated: 1/15/2025
5
+ * Version: 6.4.0-alpha.14
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -1967,7 +1967,7 @@ void main() {
1967
1967
  `,e},t.prototype.updateShaderSource=function(){var e=this.getDefines()+edlVertexShader,r=this.getDefines()+edlFragmentShader;this.setValues({vertexShader:e,fragmentShader:r}),this.needsUpdate=!0},__decorate([uniform$1("screenWidth"),__metadata("design:type",Number)],t.prototype,"screenWidth",void 0),__decorate([uniform$1("screenHeight"),__metadata("design:type",Number)],t.prototype,"screenHeight",void 0),__decorate([uniform$1("edlStrength"),__metadata("design:type",Number)],t.prototype,"edlStrength",void 0),__decorate([uniform$1("uNear"),__metadata("design:type",Number)],t.prototype,"uNear",void 0),__decorate([uniform$1("uFar"),__metadata("design:type",Number)],t.prototype,"uFar",void 0),__decorate([uniform$1("radius"),__metadata("design:type",Number)],t.prototype,"radius",void 0),__decorate([uniform$1("neighbours",!0),__metadata("design:type",Float32Array)],t.prototype,"neighbours",void 0),__decorate([uniform$1("depthMap"),__metadata("design:type",THREE__namespace.Texture)],t.prototype,"depthMap",void 0),__decorate([uniform$1("uEDLColor"),__metadata("design:type",THREE__namespace.Texture)],t.prototype,"uEDLColor",void 0),__decorate([uniform$1("uEDLDepth"),__metadata("design:type",THREE__namespace.Texture)],t.prototype,"uEDLDepth",void 0),__decorate([uniform$1("uProj"),__metadata("design:type",Array)],t.prototype,"uProj",void 0),t}(THREE__namespace.RawShaderMaterial);function makeUniform$1(n,t){return{type:n,value:t}}function uniform$1(n,t){return t===void 0&&(t=!1),function(e,r){Object.defineProperty(e,r,{get:function(){return this.getUniform(n)},set:function(o){o!==this.getUniform(n)&&(this.setUniform(n,o),t&&this.updateShaderSource())}})}}var passCamera$1=new THREE__namespace.OrthographicCamera(-1,1,1,-1,0,1),geometry$2=new THREE__namespace.BufferGeometry;geometry$2.setAttribute("position",new THREE__namespace.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),geometry$2.setAttribute("uv",new THREE__namespace.Float32BufferAttribute([0,2,0,0,2,0],2));var mesh$2=new THREE__namespace.Mesh(geometry$2),edlEffectScene=new THREE__namespace.Scene;edlEffectScene.add(mesh$2);var EDLEffect=function(n){__extends(t,n);function t(e,r,o,s){var u=n.call(this,e,r,o,s)||this;return u.sharedV2=new THREE__namespace.Vector2,u.renderer=e,u.material=new EDLMaterial,mesh$2.material=u.material,u.material.needsUpdate=!0,u}return t.prototype.render=function(e){this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.setRenderTarget(e[0]),this.renderer.render(this.scene,this.camera);var r=this.camera,o=this.material.uniforms,s=this.renderer.getSize(this.sharedV2);o.screenWidth.value=s.x,o.screenHeight.value=s.y;var u=r.projectionMatrix,l=new Float32Array(16);l.set(u.elements);for(var c=new Float32Array(this.material.neighbourCount*2),f=0;f<this.material.neighbourCount;f++)c[2*f+0]=Math.cos(2*f*Math.PI/this.material.neighbourCount),c[2*f+1]=Math.sin(2*f*Math.PI/this.material.neighbourCount);o.neighbours.value=c,o.uNear.value=r.near,o.uFar.value=r.far,o.uEDLColor.value=e[0].texture,o.uProj.value=l,o.edlStrength.value=.5,o.radius.value=1,o.opacity.value=1,this.renderer.setRenderTarget(e[1]),this.renderer.render(edlEffectScene,passCamera$1)},t.prototype.dispose=function(){this.copyPass.dispose()},t}(Effect);const fragment=function n(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,o=126,s=0,u="";return t[s].split(u).map(function(l){return l.charCodeAt(s)>o?l:String.fromCharCode((l.charCodeAt(s)+r)%o)}).join(u)}(`}rpvv|{-zrqvz}-sy|nH}rpvv|{-zrqvz}-v{H{vs|z-nz}yr?Q-drvtuZn}H{vs|z-nz}yr?Q-Qr}uZn}Hn\bv{t-rp?-bH|vq-znv{56-
1968
1968
  sy|n-qr}u-J-r\x07r?Q5Qr}uZn}9-b6;Hvs5qr}u-KJ->;=6
1969
1969
  qvpnqH\frpA-p|y|-J-r\x07r?Q5drvtuZn}9-b6H-p|y|-J-p|y|-<-p|y|;HtylSntP|y|-J-rpA5p|y|;\x07\b 9->;=6H-\f`),vertex=function n(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var r=113,o=126,s=0,u="";return t[s].split(u).map(function(l){return l.charCodeAt(s)>o?l:String.fromCharCode((l.charCodeAt(s)+r)%o)}).join(u)}(`}rpvv|{-zrqvz}-sy|nH}rpvv|{-zrqvz}-v{Hnvor-rp@-}|vv|{Hnvor-rp?-H{vs|z-znA-}|wrpv|{Znv\x07H{vs|z-znA-z|qrycvrZnv\x07Hn\bv{t-rp?-bH|vq-znv{56-
1970
- b-J-Htyl]|vv|{-J-}|wrpv|{Znv\x07-7-z|qrycvrZnv\x07-7-rpA5}|vv|{9>;=6H\f`);var HQMaterial=function(n){__extends(t,n);function t(e){var r=n.call(this,{vertexShader:vertex,fragmentShader:fragment})||this;return r.uniforms={uDepthMap:makeUniform("t",null),uWeightMap:makeUniform("t",null)},r.depthTest=!0,r.depthWrite=!0,r.opacity=1,r}return t.prototype.getUniform=function(e){return this.uniforms===void 0?void 0:this.uniforms[e].value},t.prototype.setUniform=function(e,r){if(this.uniforms!==void 0){var o=this.uniforms[e];o.value=r}},__decorate([uniform("uDepthMap"),__metadata("design:type",Number)],t.prototype,"uDepthMap",void 0),__decorate([uniform("uWeightMap"),__metadata("design:type",Number)],t.prototype,"uWeightMap",void 0),t}(THREE__namespace.RawShaderMaterial);function makeUniform(n,t){return{type:n,value:t}}function uniform(n,t){return t===void 0&&(t=!1),function(e,r){Object.defineProperty(e,r,{get:function(){return this.getUniform(n)},set:function(o){o!==this.getUniform(n)&&(this.setUniform(n,o),t&&this.updateShaderSource())}})}}var passCamera=new THREE__namespace.OrthographicCamera(-1,1,1,-1,0,1),geometry$1=new THREE__namespace.BufferGeometry;geometry$1.setAttribute("position",new THREE__namespace.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),geometry$1.setAttribute("uv",new THREE__namespace.Float32BufferAttribute([0,2,0,0,2,0],2));var mesh$1=new THREE__namespace.Mesh(geometry$1),hqScene=new THREE__namespace.Scene;hqScene.add(mesh$1);var HQEffect=function(n){__extends(t,n);function t(e,r,o,s){var u=n.call(this,e,r,o,s)||this;return u.sharedV2=new THREE__namespace.Vector2,u.renderer=e,u.material=new HQMaterial,u.camera=o,mesh$1.material=u.material,u}return t.prototype.render=function(e){this.models.setMaterial({useHQDepth:!0,useHQWeight:!1}),this.models.update(this.renderer,this.camera,"Mapview"),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.setRenderTarget(e[0]),this.renderer.render(this.scene,this.camera),this.models.setMaterial({useHQWeight:!0,useHQDepth:!1}),this.models.update(this.renderer,this.camera,"Mapview"),this.renderer.autoClearDepth=!1,this.renderer.autoClearColor=!0,this.renderer.setClearColor(new THREE__namespace.Color(0,0,0)),this.renderer.setClearAlpha(0),this.renderer.setRenderTarget(e[1]),this.renderer.render(this.scene,this.camera),this.material.uniforms.uWeightMap.value=e[1].texture,this.material.uniforms.uDepthMap.value=e[0].depthTexture,this.renderer.autoClearDepth=!0,this.renderer.autoClearColor=!0,this.renderer.setClearColor(new THREE__namespace.Color(0,0,0)),this.renderer.setClearAlpha(1),this.renderer.setRenderTarget(e[2]),this.renderer.render(hqScene,passCamera)},t.prototype.dispose=function(){this.copyPass.dispose()},t}(Effect),RAYCASTER_NEAR=.5,minDistance=.5,PANGESTURE_FORWARD_ANGLE=Math.PI/7,MapviewController=function(n){__extends(t,n);function t(e){var r=this,o,s=t.parseArgs(e);return r=n.call(this,s)||this,r.mode="Mapview",r.defaultLongitude=s.defaultLongitude,r.defaultLatitude=s.defaultLatitude,r.defaultDistance=s.defaultDistance,r.maxLatitude=s.maxLatitude,r.minLatitude=s.minLatitude,r.cameraType=s.cameraType,r.modelInScreen=s.modelInScreen,r.locationMotion=new Motion({x:r.camera.pose.offset.x,y:r.camera.pose.offset.y,z:r.camera.pose.offset.z,distance:r.camera.pose.distance}),r.modelAlphaMotion=new Motion({modelAlpha:(o=r.models.getMaterial().modelAlpha)!==null&&o!==void 0?o:0}),r.perspToOrthoMotion=new Motion({perspToOrtho:r.camera.perspToOrtho.x}),r.intersectMeshCreator=s.intersectMeshCreator,r.intersectMesh=r.intersectMeshCreator(),r.intersectMesh.name="intersect",r.intersectMesh.visible=!1,r.currentTapId=null,r.helper.add(r.intersectMesh),r.edlTarget=new THREE__namespace.WebGLRenderTarget(1024,1024,{generateMipmaps:!1,minFilter:THREE__namespace.NearestFilter,magFilter:THREE__namespace.NearestFilter,format:THREE__namespace.RGBAFormat,type:THREE__namespace.FloatType,depthTexture:new THREE__namespace.DepthTexture(1024,1024,THREE__namespace.UnsignedIntType)}),r.edlEffect=new EDLEffect(r.renderer,r.modelScene,r.camera,r.models),r.hqEffect=new HQEffect(r.renderer,r.modelScene,r.camera,r.models),r}return t.parseArgs=function(e){var r,o,s,u,l,c,f,d;if(e instanceof t)return e;var p=n.parseArgs.call(this,e);return __assign(__assign({},p),{defaultLongitude:(r=e.defaultLongitude)!==null&&r!==void 0?r:Math.PI/4,defaultLatitude:(o=e.defaultLatitude)!==null&&o!==void 0?o:Math.PI/4,defaultDistance:(s=e.defaultDistance)!==null&&s!==void 0?s:150,maxLatitude:(u=e.maxLatitude)!==null&&u!==void 0?u:+Math.PI/2,minLatitude:(l=e.minLatitude)!==null&&l!==void 0?l:0,cameraType:(c=e.cameraType)!==null&&c!==void 0?c:"auto",modelInScreen:(f=e.modelInScreen)!==null&&f!==void 0?f:"boundingbox-center",intersectMeshCreator:(d=e.intersectMeshCreator)!==null&&d!==void 0?d:function(){return new IntersectMesh}})},t.distanceFromModel=function(e,r,o){var s=e.bounding,u=Math.pow(Math.pow(s.max.x-s.min.x+1,2)+Math.pow(s.max.y-s.min.y+1,2)+Math.pow(s.max.z-s.min.z+1,2),1/2),l=u/2/Math.tan(Math.PI*r/360);return o<1&&(l=l/o),isNaN(l)?u:l},t.initAnimationEndState=function(e){var r,o,s,u,l,c,f,d=this.parseArgs(e),p=d.works,v=d.models,g=e.initial,h=g.state,m=g.currentState,y=typeof h.panoIndex=="number"?{workCode:(s=(r=h.workCode)!==null&&r!==void 0?r:(o=d.works[0])===null||o===void 0?void 0:o.workCode)!==null&&s!==void 0?s:"",panoIndex:h.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},A=p.getResolvedObserver(y),E=(u=h.fov)!==null&&u!==void 0?u:60,b=clamp$1((l=h.latitude)!==null&&l!==void 0?l:isThirdPersonMode(m.mode)?m.latitude:d.defaultLatitude,d.minLatitude,d.maxLatitude),T=t.distanceFromModel(d.models,E,d.camera.aspect),_=new THREE__namespace.Vector3,R=(c=h.distance)!==null&&c!==void 0?c:Math.min(d.defaultDistance,T),S=(f=h.longitude)!==null&&f!==void 0?f:isThirdPersonMode(m.mode)?m.longitude:d.defaultLongitude;return h.offset?_.copy(h.offset):d.defaultDistance<T&&A?(_.copy(A.position),h.longitude===void 0&&(S=m.longitude)):(v.bounding.getCenter(_),R=T/2),__assign(__assign({},y),{mode:"Mapview",longitude:S,latitude:b,fov:E,offset:_,distance:R})},t.prototype.destroy=function(){n.prototype.destroy.call(this),this.locationMotion.dispose(),delete this.panState,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)},t.prototype.isReady=function(){return this.locationMotion.ended===!1?!1:n.prototype.isReady.call(this)},t.prototype.updateWork=function(e,r,o,s){this.userAction=s,this.works=e;var u=t.initAnimationEndState(__assign(__assign({},this),{initial:{currentState:__assign(__assign({},this.currentPano),this.camera.pose),duration:o.duration,effect:o.effect,state:r,userAction:s}}));this.currentPano={workCode:u.workCode,panoIndex:u.panoIndex};var l={longitude:u.longitude,latitude:u.latitude,fov:u.fov},c={x:u.offset.x,y:u.offset.y,z:u.offset.z,distance:u.distance,orthoDistance:u.distance};return this.locationMotion.set(c,o.duration).catch(noop$1),this.cameraMotion.set(l,o.duration).catch(noop$1),!0},t.prototype.updateModel=function(e){n.prototype.updateModel.call(this,e);var r=e.bounding.getCenter(new THREE__namespace.Vector3),o=t.distanceFromModel(e,this.cameraMotion.value.fov,this.camera.aspect);this.updateCamera({offset:r,distance:o},0,!0)},t.prototype.updateCamera=function(e,r,o){var s=this;return this.initAnimationReady.then(function(){s.userAction=o,s.stopMomentumMovement();var u={},l={};return e.distance!==void 0&&(u.distance=e.distance),e.offset!==void 0&&(u.x=e.offset.x,u.y=e.offset.y,u.z=e.offset.z),e.longitude!==void 0&&(l.longitude=e.longitude),e.latitude!==void 0&&(l.latitude=e.latitude),e.fov!==void 0&&(l.fov=e.fov),s.locationMotion.set(u,r).catch(noop$1),s.cameraMotion.set(l,r).catch(noop$1)})},t.prototype.updateCameraWithKeyframes=function(e,r,o){var s=this;return this.initAnimationReady.then(function(){s.userAction=o,s.stopMomentumMovement();for(var u=[],l=[],c=0,f=e;c<f.length;c++){var d=f[c];u.push({key:d.key,progress:d.progress,value:{distance:d.value.distance,x:d.value.offset.x,y:d.value.offset.x,z:d.value.offset.x}}),l.push({key:d.key,progress:d.progress,value:{longitude:d.value.longitude,latitude:d.value.latitude,fov:d.value.fov}})}return s.locationMotion.setKeyframes(u,r).catch(noop$1),s.cameraMotion.setKeyframes(e,r)})},t.prototype.updateTime=function(e,r){if(!this.destroyed){var o={},s={};this.locationMotion.ended||(this.locationMotion.update(e),s.distance=this.locationMotion.value.distance,s.offset=new THREE__namespace.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),s.longitude=this.cameraMotion.value.longitude,s.latitude=this.cameraMotion.value.latitude,s.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),o.modelAlpha=this.modelAlphaMotion.value.modelAlpha);var u=0;this.cameraType==="auto"?u=Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02?1:0:this.cameraType==="perspective"?u=0:this.cameraType==="orthographic"&&(u=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==u&&this.perspToOrthoMotion.set({perspToOrtho:u},500).catch(noop$1),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),isEmptyObject(o)||this.models.setMaterial(o),isEmptyObject(s)||this.setCamera(s)}},t.prototype.getTargetState=function(){var e=this.cameraMotion.getKeyFrameSegment(now())[1],r=this.locationMotion.getKeyFrameSegment(now())[1];return __assign(__assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:r.value.distance,offset:new THREE__namespace.Vector3(r.value.x,r.value.y,r.value.z)})},t.prototype.initAnimation=function(){var e=this;return this.destroyed?Promise.resolve():new Promise(function(r){var o=e.initial;o.state,o.currentState;var s=o.duration,u=o.userAction;e.userAction=u;var l=t.initAnimationEndState(e),c={longitude:l.longitude,latitude:l.latitude,fov:l.fov},f={x:l.offset.x,y:l.offset.y,z:l.offset.z,distance:l.distance},d={modelAlpha:1},p={perspToOrtho:0};e.emit("initAnimation.start",createEvent("initAnimation.start",{state:l,userAction:e.userAction})),e.perspToOrthoMotion.set(p,s).catch(noop$1),e.modelAlphaMotion.set(d,s/3).catch(noop$1),e.cameraMotion.set(c,s).catch(noop$1),e.locationMotion.set(f,s).then(function(){e.emit("initAnimation.end",createEvent("initAnimation.end",{state:l,userAction:e.userAction}))},function(v){var g=__assign(__assign(__assign({},e.currentPano),{mode:e.mode}),clonePose(e.camera.pose));e.emit("initAnimation.end",createEvent("initAnimation.end",{state:g,userAction:e.userAction}))}).then(function(){r()})})},t.prototype.getForwardObserverOrNot=function(e){var r=this,o=this.models.intersectRaycaster(e)[0];if(!o)return null;var s=this.works.resolvedObservers.filter(function(f){for(var d,p=0,v=r.models;p<v.length;p++){var g=v[p];if(g.visible&&((d=g.work)===null||d===void 0?void 0:d.workCode)===f.work.workCode)return!0}return!1}),u=arrayMin(s,function(f){return f.standingPosition.distanceTo(o.point)},!0),l=u[0],c=u[1];return l&&c<10?l:null},t.prototype.coordinatesForOffset=function(e){var r=this.renderer.getSize(new THREE__namespace.Vector2);return{longitude:-2*e.x/(r.x*this.scissor.width),latitude:2*e.y/(r.y*this.scissor.height)}},t.prototype.requestMomentumMovement=function(e,r,o,s){var u=this;if(this.inMomentumMovement!==null){for(var l=__assign({},o),c={longitude:0,latitude:0,x:0,y:0,z:0},f=0;f<s;f++)l.longitude*=.996,l.latitude*=.996*.998,l.x*=.99,l.y*=.99,l.z*=.99,c.longitude+=l.longitude,c.latitude+=l.latitude,c.x+=l.x,c.y+=l.y,c.z+=l.z;var d=formatRad(this.cameraMotion.value.longitude+c.longitude),p=clamp$1(this.cameraMotion.value.latitude+c.latitude,this.minLatitude,this.maxLatitude),v=new THREE__namespace.Vector3(this.locationMotion.value.x+c.x,this.locationMotion.value.y+c.y,this.locationMotion.value.z+c.z),g=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:d,latitude:p,offset:v,fov:this.cameraMotion.value.fov,distance:this.camera.pose.distance}),h=!(Math.abs(l.longitude)>1e-4||Math.abs(l.latitude)>1e-4||Math.abs(l.x)>1e-4||Math.abs(l.y)>1e-4||Math.abs(l.z)>1e-4),m=createEvent("gesture.momentum",__assign(__assign({},e),{isFirst:r,isFinal:h,state:g}));if(this.inMomentumMovement.event=m,this.emit("gesture.momentum",m),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:d,latitude:p},0).catch(noop$1),this.locationMotion.set({x:g.offset.x,y:g.offset.y,z:g.offset.z},0).catch(noop$1),h?this.inMomentumMovement=null:AnimationFrameLoop.shared.add(function(y,A){u.requestMomentumMovement(e,!1,l,A|0)},!0,1))}},t.prototype.fixFinalState=function(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==1){var r=coordinatesToVector(e,new THREE__namespace.Vector3),o=new THREE__namespace.Vector3().copy(e.offset).sub(r.clone().multiplyScalar(e.distance)),s=new THREE__namespace.Raycaster(o,r);s.params.Points={threshold:.1},s.near=RAYCASTER_NEAR;var u;if(s.ray.direction.y<-.3&&(u=this.models.intersectRaycaster(s).filter(function(p){var v,g=(v=p.face)===null||v===void 0?void 0:v.normal;return g&&s.ray.direction.dot(g)>=0?!1:p.distance>minDistance+s.near})[0],!u)){var l=new THREE__namespace.Plane(new THREE__namespace.Vector3(0,1,0),-this.models.bounding.min.y),c=s.ray.intersectPlane(l,new THREE__namespace.Vector3);if(c){var f=c.distanceTo(s.ray.origin);f<1e4&&f>=s.near&&(u={distance:f,floor:0,point:c,object:this.scene,face:null})}}if(!u){var d=Math.max(e.distance,3);u={distance:d,floor:0,point:s.ray.direction.clone().setLength(d).add(s.ray.origin),object:this.scene,face:null}}u&&(e.distance=clamp$1(u.distance,0,1/0),e.offset.copy(o).add(r.clone().multiplyScalar(e.distance)))}},t.prototype.onPanGesture=function(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var r=e.pointers.length,o=this.panState,s=0;e.pointerType==="mouse"&&(s=e.srcEvent.buttons),o&&s===0&&o.buttons!==0&&(s=o.buttons);var u=o==null?void 0:o.target;if(!u){var l=this.relativeClientPosition(e.center),c=new THREE__namespace.Raycaster;c.params.Points={threshold:.1},c.setFromCamera(l,this.camera),c.near=RAYCASTER_NEAR,u=new THREE__namespace.Vector3().copy(c.ray.direction).multiplyScalar(3).add(c.ray.origin);var f=this.models.intersectRaycaster(c)[0];if(!f&&c.ray.direction.y<-.3){var d=new THREE__namespace.Plane(new THREE__namespace.Vector3(0,1,0),0),p=c.ray.intersectPlane(d,new THREE__namespace.Vector3);if(p){var v=p.distanceTo(c.ray.origin);v<1e4&&v>=c.near&&(f={distance:v,floor:0,point:p,object:this.scene})}}if(f)u.copy(f.point);else{var g=new THREE__namespace.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),d=new THREE__namespace.Plane().setFromNormalAndCoplanarPoint(g,this.camera.pose.offset);c.ray.intersectPlane(d,u)}}if(e.isFinal?delete this.panState:this.panState={target:u,buttons:s,pointerLength:r,x:e.center.x,y:e.center.y},!(typeof o=="undefined"||o.pointerLength!==r)){var h=r>1||s===2;if(h){var m={x:e.center.x-o.x,y:e.center.y-o.y},y=new THREE__namespace.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),A=coordinatesToVector(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(y),E=new THREE__namespace.Vector3().copy(A).sub(o.target).length();E*=Math.tan(this.camera.pose.fov/2*Math.PI/180);var b=this.renderer.getSize(new THREE__namespace.Vector2),T=2*m.x*E/b.y,_=2*m.y*E/b.y,R=new THREE__namespace.Vector3;if(R.setFromMatrixColumn(this.camera.matrix,0),R.multiplyScalar(-T),y.add(R),this.camera.pose.latitude<PANGESTURE_FORWARD_ANGLE?R.setFromMatrixColumn(this.camera.matrix,1):(R.setFromMatrixColumn(this.camera.matrix,0),R.crossVectors(this.camera.up,R)),R.multiplyScalar(_),y.add(R),this.modelInScreen==="boundingbox-center"){var S=this.models.bounding.clone();S.expandByScalar(this.camera.pose.distance),y.clamp(S.min,S.max)}var M=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:y,distance:this.camera.pose.distance});if(e.state=M,this.emit("gesture.pan",e),e.defaultPrevented)return;if(this.locationMotion.set({x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1),e.isFinal&&(this.fixFinalState(M),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:M.distance,x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1)),e.isFinal){var B=this.renderer.getSize(new THREE__namespace.Vector2),H=2*e.velocityX*E/B.y,w=2*e.velocityY*E/B.y,C=new THREE__namespace.Vector3,F=new THREE__namespace.Vector3;C.setFromMatrixColumn(this.camera.matrix,0),C.multiplyScalar(-H),F.add(C),this.camera.pose.latitude<PANGESTURE_FORWARD_ANGLE?C.setFromMatrixColumn(this.camera.matrix,1):(C.setFromMatrixColumn(this.camera.matrix,0),C.crossVectors(this.camera.up,C)),C.multiplyScalar(w),F.add(C),this.inMomentumMovement={uuid:createUuid()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:F.x,y:F.y,z:F.z},0)}}else{var m={x:e.center.x-o.x,y:e.center.y-o.y},I=this.coordinatesForOffset(m),L=formatRad(this.cameraMotion.value.longitude+I.longitude),k=clamp$1(this.cameraMotion.value.latitude+I.latitude,this.minLatitude,this.maxLatitude);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(k=this.cameraMotion.value.latitude);var M=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:L,latitude:k,fov:this.camera.pose.fov,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=M,this.emit("gesture.pan",e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:M.distance,x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1):this.cameraMotion.set({longitude:M.longitude,latitude:M.latitude},0).catch(noop$1),e.isFinal){var N=e.velocityX,D=e.velocityY;this.inMomentumMovement={uuid:createUuid()},this.requestMomentumMovement(e,!0,__assign(__assign({},this.coordinatesForOffset({x:N,y:D})),{x:0,y:0,z:0}),0)}}}},t.prototype.onPinchGesture=function(e){var r;if(this.initAnimationIsReady){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var o=(r=this.pinchState)===null||r===void 0?void 0:r.distance;if(e.isFirst){this.pinchState={x:e.center.x,y:e.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(typeof o!="undefined"){var s=this.models.bounding.getCenter(new THREE__namespace.Vector3),u=t.distanceFromModel(this.models,this.cameraMotion.value.fov,this.camera.aspect),l=clamp$1(o/e.scale,minDistance,1/0),c=e.state.offset.clone().sub(coordinatesToVector(e.state).setLength(l)),f=this.models.bounding.containsPoint(c),d;if(!f&&this.pinchState&&this.pinchState.scale>e.scale&&s.distanceTo(c)>u?d=e.state.distance:(d=l,this.pinchState&&(this.pinchState.scale=e.scale)),e.state.distance=d,this.emit("gesture.pinch",e),!e.defaultPrevented&&(this.locationMotion.set({distance:e.state.distance},0).catch(noop$1),e.pointerType!=="mouse"&&(e.type="gesture.pan",this.onPanGesture(e)),e.isFinal)){if(!("__fixFinalState"in e)){var p=e.state;this.fixFinalState(e.state);var v={x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance};this.locationMotion.set(v,0).catch(noop$1)}delete this.panState,delete this.pinchState}}}},t.prototype.onMouseMove=function(e){var r,o;if(this.intersectMesh.parent&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&(this.emit("gesture.mousemove",e),!e.defaultPrevented)){var s=e.center.raycaster;if(s.near=RAYCASTER_NEAR,s.far=500,e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}var u=this.models.intersectRaycaster(s)[0],l=createEvent("intersect.update",{raycaster:s,intersection:u!=null?u:null,object:this.intersectMesh});if(this.emit("intersect.update",l),l.defaultPrevented){this.hideIntersectMesh();return}if(u){var c=(o=(r=u.face)===null||r===void 0?void 0:r.normal)!==null&&o!==void 0?o:new THREE__namespace.Vector3().copy(s.ray.direction).multiplyScalar(-1),f=c.clone(),d=u.point.clone();this.intersectMesh.position.copy(d);var p=s.ray.origin.distanceTo(d),v=2*Math.tan(.5*this.camera.fov/180*Math.PI),g=Math.max(p*v/10,1);this.intersectMesh.scale.set(g,g,g);var h=d.clone().add(f);if(this.intersectMesh.lookAt(h),Math.abs(c.y)>.99){var m=this.camera.position.clone().sub(d);this.intersectMesh.rotation.z=-Math.atan2(m.z,m.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}},t.prototype.onMouseWheel=function(e){if(this.initAnimationIsReady)if(this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),e.isFinal){var r=e.state;if(this.fixFinalState(r),this.emit("gesture.mousewheel",e),e.defaultPrevented)return;var o={x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance};this.locationMotion.set(o,0).catch(noop$1)}else{var s=e.center.delta/2*Math.max(Math.log(this.locationMotion.value.distance),1);if(this.locationMotion.value.distance-s>=minDistance){var u=this.locationMotion.value.distance-s;e.state.distance=u}else{var l=coordinatesToVector(this.cameraMotion.value);l.setLength(s),e.state.offset.add(l),this.modelInScreen==="boundingbox-center"&&e.state.offset.clamp(this.models.bounding.min,this.models.bounding.max)}if(this.emit("gesture.mousewheel",e),e.defaultPrevented)return;this.locationMotion.set({distance:e.state.distance,x:e.state.offset.x,y:e.state.offset.y,z:e.state.offset.z},0).catch(noop$1)}},t.prototype.onTapGesture=function(e){var r=this;this.userAction=e.userAction,this.stopMomentumMovement();var o=e.center.raycaster,s=this.getForwardObserverOrNot(o);if(!s)this.emit("gesture.tap",e);else{var u={longitude:this.camera.pose.longitude,latitude:0},l=__assign(__assign({},e.state),{mode:"Panorama",workCode:s.pano.workCode,panoIndex:s.pano.panoIndex,longitude:u.longitude,latitude:u.latitude,offset:s?s.position.clone():new THREE__namespace.Vector3,distance:0});if(e.state=l,this.emit("gesture.tap",e),!e.defaultPrevented&&(this.emit("pano.select",createEvent("pano.select",{prevPano:this.currentPano,state:l,userAction:e.userAction,options:u,progress:0,error:null})),s&&s.active)){var c=this.currentTapId=createUuid();this.preloadPano(s.pano).then(function(f){r.currentTapId===c&&r.emit("pano.request",createEvent("pano.request",{userAction:!0,prevPano:r.currentPano,progress:0,state:l,options:u,error:null}))})}}},t.prototype.onDblTapGesture=function(e){if(this.initAnimationIsReady){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var r=e.state,o=e.center.raycaster,s=o.ray.origin.clone().add(o.ray.direction.clone().setLength(3)),u=1,l=3,c=u,f=this.models.intersectRaycaster(o)[0];if(f&&(s=f.point.clone(),f.distance>(u+l)/2?c=u:c=l),e.state.distance=c,e.state.offset=s,this.emit("gesture.dbltap",e),!e.defaultPrevented){var d={x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance};this.locationMotion.set(d,360).catch(noop$1),this.hideIntersectMesh()}}},t.prototype.hideIntersectMesh=function(){this.intersectMesh.visible=!1,this.needsRender=!0},t.prototype.render=function(e,r){var o=this.renderer.getRenderTarget();this.updateScreenBuffer(r),e&&(r==="edl"?this.edlEffect.render(this.screenBuffers):r==="hq"?this.hqEffect.render(this.screenBuffers):(this.renderer.setRenderTarget(this.modelRenderTarget),this.renderer.render(this.modelScene,this.camera))),this.depthCopyPass.render(this.modelRenderTarget.depthTexture,o),this.renderer.autoClearDepth=!1,this.renderer.autoClearColor=!0,this.copyPass.render(this.modelRenderTarget,o),this.renderer.setRenderTarget(o),this.renderer.autoClearColor=!1,this.renderer.autoClearDepth=!1,this.renderer.render(this.scene,this.camera),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0},t}(BaseController);function isNil(n){return n==null}var _moveEvent={type:"move"},XRController=function(){function n(){this._targetRay=null,this._grip=null,this._hand=null,this._axes=[0,0]}return n.prototype.getHandSpace=function(){return this._hand===null&&(this._hand=new THREE__namespace.Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},n.prototype.getTargetRaySpace=function(){return this._targetRay===null&&(this._targetRay=new THREE__namespace.Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new THREE__namespace.Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new THREE__namespace.Vector3),this._targetRay},n.prototype.getGripSpace=function(){return this._grip===null&&(this._grip=new THREE__namespace.Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new THREE__namespace.Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new THREE__namespace.Vector3),this._grip},n.prototype.dispatchEvent=function(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this},n.prototype.disconnect=function(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},n.prototype.getAxes=function(){return this._axes},n.prototype.update=function(t,e,r){var o=null,s=null,u=null,l=this._targetRay,c=this._grip,f=this._hand;if(t&&t.gamepad&&t.gamepad.axes&&(this._axes=[t.gamepad.axes[2],t.gamepad.axes[3]]),t&&e.session.visibilityState!=="visible-blurred")if(l!==null&&(o=e.getPose(t.targetRaySpace,r),o!==null&&(l.matrix.fromArray(o.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),o.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(o.linearVelocity)):l.hasLinearVelocity=!1,o.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(o.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent))),f&&t.hand){u=!0;for(var d=0,p=t.hand.values();d<p.length;d++){var v=p[d],g=e.getJointPose(v,r);if(f.joints[v.jointName]===void 0){var h=new THREE__namespace.Group;h.matrixAutoUpdate=!1,h.visible=!1,f.joints[v.jointName]=h,f.add(h)}var m=f.joints[v.jointName];g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}var y=f.joints["index-finger-tip"],A=f.joints["thumb-tip"],E=y.position.distanceTo(A.position),b=.02,T=.005;f.inputState.pinching&&E>b+T?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!f.inputState.pinching&&E<=b-T&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));return l!==null&&(l.visible=o!==null),c!==null&&(c.visible=s!==null),f!==null&&(f.visible=u!==null),this},n}(),framebufferScaleFactor=1,XRManager=function(){function n(t,e,r){var o,s,u,l,c;this.isPanorama=(o=r==null?void 0:r.isPanorama)!==null&&o!==void 0?o:!0;var f=navigator.userAgent.toLowerCase(),d;f.includes("pico")?d="Pico":f.includes("oculus")?d="Oculus":d="VP",this.machineType=(s=r==null?void 0:r.machineType)!==null&&s!==void 0?s:d,this.renderer=t,this.gl=e,this.enabled=!1,this.session=null,this.referenceSpaceType=(u=r==null?void 0:r.referenceSpaceType)!==null&&u!==void 0?u:"local-floor",this.referenceSpace=null,this.onSessionStartCallback=(l=r==null?void 0:r.onSessionStart)!==null&&l!==void 0?l:noop$1,this.onSessionEndCallback=(c=r==null?void 0:r.onSessionEnd)!==null&&c!==void 0?c:noop$1,this.controllers=[new XRController,new XRController],this.inputSourcesMap=new Map,this.cameraVR=new THREE__namespace.ArrayCamera,this.cameraL=new THREE__namespace.PerspectiveCamera,this.cameraR=new THREE__namespace.PerspectiveCamera,this.cameraL.viewport=new THREE__namespace.Vector4,this.cameraR.viewport=new THREE__namespace.Vector4,this.cameraL.layers.enable(1),this.cameraR.layers.enable(2),this.cameraVR.layers.enable(1),this.cameraVR.layers.enable(2),this.isPresenting=!1,this.currentDepthNear=null,this.currentDepthFar=null,this.cameraLPos=new THREE__namespace.Vector3,this.cameraRPos=new THREE__namespace.Vector3}return n.prototype.getController=function(t){var e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getRightController=function(){if(!this.session)return null;var t=this.session.inputSources[0].handedness==="right"?0:1,e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getLeftController=function(){if(!this.session)return null;var t=this.session.inputSources[0].handedness==="left"?0:1,e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getControllerGrip=function(t){var e=this.controllers[t];return e||console.warn("no controller find"),e.getGripSpace()},n.prototype.getCameras=function(){return{cameraL:this.cameraL,cameraR:this.cameraR,cameraVR:this.cameraVR}},n.prototype.updateCamera=function(t,e){e===null?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.getInverse(t.matrixWorld)},n.prototype.setProjectionFromUnion=function(t,e,r){this.cameraLPos.setFromMatrixPosition(e.matrixWorld),this.cameraRPos.setFromMatrixPosition(r.matrixWorld);var o=this.cameraLPos.distanceTo(this.cameraRPos),s=e.projectionMatrix.elements,u=r.projectionMatrix.elements,l=s[14]/(s[10]-1),c=s[14]/(s[10]+1),f=(s[9]+1)/s[5],d=(s[9]-1)/s[5],p=(s[8]-1)/s[0],v=(u[8]+1)/u[0],g=l*p,h=l*v,m=o/(-p+v),y=m*-p;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(y),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.getInverse(t.matrixWorld);var A=l+m,E=c+m,b=g-y,T=h+(o-y),_=f*c/E*A,R=d*c/E*A;t.projectionMatrix.makePerspective(b,T,_,R,A,E)},n.prototype.getCamera=function(t){this.cameraVR.near=this.cameraR.near=this.cameraL.near=t.near,this.cameraVR.far=this.cameraR.far=this.cameraL.far=t.far,this.session&&(this.currentDepthNear!==this.cameraVR.near||this.currentDepthFar!==this.cameraVR.far)&&(this.session.updateRenderState({depthNear:this.cameraVR.near,depthFar:this.cameraVR.far}),this.currentDepthNear=this.cameraVR.near,this.currentDepthFar=this.cameraVR.far);var e=t.parent,r=this.cameraVR.cameras;this.updateCamera(this.cameraVR,e);for(var o=0;o<r.length;o++)this.updateCamera(r[o],e);t.matrixWorld.copy(this.cameraVR.matrixWorld);for(var s=t.children,o=0,u=s.length;o<u;o++)s[o].updateMatrixWorld(!0);return r.length===2?this.setProjectionFromUnion(this.cameraVR,this.cameraL,this.cameraR):this.cameraVR.projectionMatrix.copy(this.cameraL.projectionMatrix),this.cameraVR},n.prototype.updateInputSources=function(t){if(!this.session){console.warn("session is lose!");return}for(var e=this.session.inputSources,r=0;r<this.controllers.length;r++)this.inputSourcesMap.set(e[r],this.controllers[r]);for(var r=0;r<t.removed.length;r++){var o=t.removed[r],s=this.inputSourcesMap.get(o);s&&(s.dispatchEvent({type:"disconnected",data:o}),this.inputSourcesMap.delete(o))}for(var r=0;r<t.added.length;r++){var o=t.added[r],s=this.inputSourcesMap.get(o);s&&s.dispatchEvent({type:"connected",data:o})}},n.prototype.onSessionEvent=function(t){var e=this.inputSourcesMap.get(t.inputSource);e&&e.dispatchEvent({type:t.type})},n.prototype.onSessionEnd=function(){this.inputSourcesMap.forEach(function(t,e){t.disconnect(e)}),this.inputSourcesMap.clear(),this.renderer.setFramebuffer(null),this.renderer.setRenderTarget(this.renderer.getRenderTarget()),this.isPresenting=!1,this.session=null,AnimationFrameLoop.shared.setContext(null),this.onSessionEndCallback()},n.prototype.onRequestReferenceSpace=function(t){this.referenceSpace=t,this.isPresenting=!0,this.session&&this.onSessionStartCallback(this.session)},n.prototype.setSession=function(t){var e=this;if(this.session=t,this.session){this.session.addEventListener("select",function(o){e.onSessionEvent(o)}),this.session.addEventListener("selectstart",function(o){e.onSessionEvent(o)}),this.session.addEventListener("selectend",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeeze",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeezestart",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeezeend",function(o){e.onSessionEvent(o)}),this.session.addEventListener("end",function(o){e.onSessionEnd()});var r=this.gl.getContextAttributes();this.gl.makeXRCompatible().then(function(){var o={antialias:r==null?void 0:r.antialias,alpha:r==null?void 0:r.alpha,depth:r==null?void 0:r.depth,stencil:r==null?void 0:r.stencil,framebufferScaleFactor};if(!e.session){console.error("session is lose while set session!");return}switch(e.machineType){case"Pico":case"VP":e.session.updateRenderState({baseLayer:new XRWebGLLayer(e.session,e.gl,o)});break;case"Oculus":e.session.updateRenderState({baseLayer:new XRWebGLLayer(e.session,e.gl,o)});break;default:e.machineType;break}e.session.requestReferenceSpace(e.referenceSpaceType).then(function(s){e.onRequestReferenceSpace(s)}),e.session.addEventListener("inputsourceschange",function(s){e.updateInputSources(s)})})}},n}(),LineSegmentsGeometry=function(n){__extends(t,n);function t(){var e=n.call(this)||this;e.type="LineSegmentsGeometry";var r=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],o=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],s=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];return e.setIndex(s),e.setAttribute("position",new THREE__namespace.Float32BufferAttribute(r,3)),e.setAttribute("uv",new THREE__namespace.Float32BufferAttribute(o,2)),e}return t.prototype.applyMatrix4=function(e){var r=this.attributes.instanceStart,o=this.attributes.instanceEnd;return r!==void 0&&(r.applyMatrix4(e),o.applyMatrix4(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},t.prototype.setPositions=function(e){var r;e instanceof Float32Array?r=e:Array.isArray(e)?r=new Float32Array(e):r=new Float32Array;var o=new THREE__namespace.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceStart",new THREE__namespace.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceEnd",new THREE__namespace.InterleavedBufferAttribute(o,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},t.prototype.setColors=function(e){var r;e instanceof Float32Array?r=e:Array.isArray(e)?r=new Float32Array(e):r=new Float32Array;var o=new THREE__namespace.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceColorStart",new THREE__namespace.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceColorEnd",new THREE__namespace.InterleavedBufferAttribute(o,3,3)),this},t.prototype.fromWireframeGeometry=function(e){return this.setPositions(e.attributes.position.array),this},t.prototype.fromEdgesGeometry=function(e){return this.setPositions(e.attributes.position.array),this},t.prototype.fromMesh=function(e){return this.fromWireframeGeometry(new THREE__namespace.WireframeGeometry(e.geometry)),this},t.prototype.fromLineSegments=function(e){var r=e.geometry;if(r instanceof THREE__namespace.Geometry){var o=new THREE__namespace.BufferGeometry().fromGeometry(r);this.setPositions(o.attributes.position.array)}else r instanceof THREE__namespace.BufferGeometry&&this.setPositions(r.attributes.position.array);return this},t.prototype.computeBoundingBox=function(){this.boundingBox===null&&(this.boundingBox=new THREE__namespace.Box3);var e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(e!==void 0&&r!==void 0){var o=new THREE__namespace.Box3;this.boundingBox.setFromBufferAttribute(e),o.setFromBufferAttribute(r),this.boundingBox.union(o)}},t.prototype.computeBoundingSphere=function(){this.boundingSphere===null&&(this.boundingSphere=new THREE__namespace.Sphere),this.boundingBox===null&&this.computeBoundingBox();var e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(e!==void 0&&r!==void 0){var o=this.boundingSphere.center;this.boundingBox.getCenter(o);for(var s=0,u=new THREE__namespace.Vector3,l=0,c=e.count;l<c;l++)u.fromBufferAttribute(e,l),s=Math.max(s,o.distanceToSquared(u)),u.fromBufferAttribute(r,l),s=Math.max(s,o.distanceToSquared(u));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}},t.prototype.toJSON=function(){},t}(THREE__namespace.InstancedBufferGeometry);Object.assign(LineSegmentsGeometry.prototype,{isLineSegmentsGeometry:!0});var lineShader={uniforms:THREE__namespace.UniformsUtils.merge([THREE__namespace.UniformsLib.common,THREE__namespace.UniformsLib.fog,{linewidth:{value:1},resolution:{value:new THREE__namespace.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},opacity:{value:1}}]),vertexShader:`
1970
+ b-J-Htyl]|vv|{-J-}|wrpv|{Znv\x07-7-z|qrycvrZnv\x07-7-rpA5}|vv|{9>;=6H\f`);var HQMaterial=function(n){__extends(t,n);function t(e){var r=n.call(this,{vertexShader:vertex,fragmentShader:fragment})||this;return r.uniforms={uDepthMap:makeUniform("t",null),uWeightMap:makeUniform("t",null)},r.depthTest=!0,r.depthWrite=!0,r.opacity=1,r}return t.prototype.getUniform=function(e){return this.uniforms===void 0?void 0:this.uniforms[e].value},t.prototype.setUniform=function(e,r){if(this.uniforms!==void 0){var o=this.uniforms[e];o.value=r}},__decorate([uniform("uDepthMap"),__metadata("design:type",Number)],t.prototype,"uDepthMap",void 0),__decorate([uniform("uWeightMap"),__metadata("design:type",Number)],t.prototype,"uWeightMap",void 0),t}(THREE__namespace.RawShaderMaterial);function makeUniform(n,t){return{type:n,value:t}}function uniform(n,t){return t===void 0&&(t=!1),function(e,r){Object.defineProperty(e,r,{get:function(){return this.getUniform(n)},set:function(o){o!==this.getUniform(n)&&(this.setUniform(n,o),t&&this.updateShaderSource())}})}}var passCamera=new THREE__namespace.OrthographicCamera(-1,1,1,-1,0,1),geometry$1=new THREE__namespace.BufferGeometry;geometry$1.setAttribute("position",new THREE__namespace.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),geometry$1.setAttribute("uv",new THREE__namespace.Float32BufferAttribute([0,2,0,0,2,0],2));var mesh$1=new THREE__namespace.Mesh(geometry$1),hqScene=new THREE__namespace.Scene;hqScene.add(mesh$1);var HQEffect=function(n){__extends(t,n);function t(e,r,o,s){var u=n.call(this,e,r,o,s)||this;return u.sharedV2=new THREE__namespace.Vector2,u.renderer=e,u.material=new HQMaterial,u.camera=o,mesh$1.material=u.material,u}return t.prototype.render=function(e){this.models.setMaterial({useHQDepth:!0,useHQWeight:!1}),this.models.update(this.renderer,this.camera,"Mapview"),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0,this.renderer.setRenderTarget(e[0]),this.renderer.render(this.scene,this.camera),this.models.setMaterial({useHQWeight:!0,useHQDepth:!1}),this.models.update(this.renderer,this.camera,"Mapview"),this.renderer.autoClearDepth=!1,this.renderer.autoClearColor=!0,this.renderer.setClearColor(new THREE__namespace.Color(0,0,0)),this.renderer.setClearAlpha(0),this.renderer.setRenderTarget(e[1]),this.renderer.render(this.scene,this.camera),this.material.uniforms.uWeightMap.value=e[1].texture,this.material.uniforms.uDepthMap.value=e[0].depthTexture,this.renderer.autoClearDepth=!0,this.renderer.autoClearColor=!0,this.renderer.setClearColor(new THREE__namespace.Color(0,0,0)),this.renderer.setClearAlpha(1),this.renderer.setRenderTarget(e[2]),this.renderer.render(hqScene,passCamera)},t.prototype.dispose=function(){this.copyPass.dispose()},t}(Effect),RAYCASTER_NEAR=.5,minDistance=.5,PANGESTURE_FORWARD_ANGLE=Math.PI/7,MapviewController=function(n){__extends(t,n);function t(e){var r=this,o,s=t.parseArgs(e);return r=n.call(this,s)||this,r.mode="Mapview",r.defaultLongitude=s.defaultLongitude,r.defaultLatitude=s.defaultLatitude,r.defaultDistance=s.defaultDistance,r.maxLatitude=s.maxLatitude,r.minLatitude=s.minLatitude,r.cameraType=s.cameraType,r.modelInScreen=s.modelInScreen,r.locationMotion=new Motion({x:r.camera.pose.offset.x,y:r.camera.pose.offset.y,z:r.camera.pose.offset.z,distance:r.camera.pose.distance}),r.modelAlphaMotion=new Motion({modelAlpha:(o=r.models.getMaterial().modelAlpha)!==null&&o!==void 0?o:0}),r.perspToOrthoMotion=new Motion({perspToOrtho:r.camera.perspToOrtho.x}),r.intersectMeshCreator=s.intersectMeshCreator,r.intersectMesh=r.intersectMeshCreator(),r.intersectMesh.name="intersect",r.intersectMesh.visible=!1,r.currentTapId=null,r.helper.add(r.intersectMesh),r.edlTarget=new THREE__namespace.WebGLRenderTarget(1024,1024,{generateMipmaps:!1,minFilter:THREE__namespace.NearestFilter,magFilter:THREE__namespace.NearestFilter,format:THREE__namespace.RGBAFormat,type:THREE__namespace.FloatType,depthTexture:new THREE__namespace.DepthTexture(1024,1024,THREE__namespace.UnsignedIntType)}),r.edlEffect=new EDLEffect(r.renderer,r.modelScene,r.camera,r.models),r.hqEffect=new HQEffect(r.renderer,r.modelScene,r.camera,r.models),r}return t.parseArgs=function(e){var r,o,s,u,l,c,f,d;if(e instanceof t)return e;var p=n.parseArgs.call(this,e);return __assign(__assign({},p),{defaultLongitude:(r=e.defaultLongitude)!==null&&r!==void 0?r:Math.PI/4,defaultLatitude:(o=e.defaultLatitude)!==null&&o!==void 0?o:Math.PI/4,defaultDistance:(s=e.defaultDistance)!==null&&s!==void 0?s:150,maxLatitude:(u=e.maxLatitude)!==null&&u!==void 0?u:+Math.PI/2,minLatitude:(l=e.minLatitude)!==null&&l!==void 0?l:0,cameraType:(c=e.cameraType)!==null&&c!==void 0?c:"auto",modelInScreen:(f=e.modelInScreen)!==null&&f!==void 0?f:"boundingbox-center",intersectMeshCreator:(d=e.intersectMeshCreator)!==null&&d!==void 0?d:function(){return new IntersectMesh}})},t.distanceFromModel=function(e,r,o){var s=e.bounding,u=Math.pow(Math.pow(s.max.x-s.min.x+1,2)+Math.pow(s.max.y-s.min.y+1,2)+Math.pow(s.max.z-s.min.z+1,2),1/2),l=u/2/Math.tan(Math.PI*r/360);return o<1&&(l=l/o),isNaN(l)?u:l},t.initAnimationEndState=function(e){var r,o,s,u,l,c,f,d=this.parseArgs(e),p=d.works,v=d.models,g=e.initial,h=g.state,m=g.currentState,y=typeof h.panoIndex=="number"?{workCode:(s=(r=h.workCode)!==null&&r!==void 0?r:(o=d.works[0])===null||o===void 0?void 0:o.workCode)!==null&&s!==void 0?s:"",panoIndex:h.panoIndex}:{workCode:m.workCode,panoIndex:m.panoIndex},A=p.getResolvedObserver(y),E=(u=h.fov)!==null&&u!==void 0?u:60,b=clamp$1((l=h.latitude)!==null&&l!==void 0?l:isThirdPersonMode(m.mode)?m.latitude:d.defaultLatitude,d.minLatitude,d.maxLatitude),T=t.distanceFromModel(d.models,E,d.camera.aspect),_=new THREE__namespace.Vector3,R=(c=h.distance)!==null&&c!==void 0?c:Math.min(d.defaultDistance,T),S=(f=h.longitude)!==null&&f!==void 0?f:isThirdPersonMode(m.mode)?m.longitude:d.defaultLongitude;return h.offset?_.copy(h.offset):d.defaultDistance<T&&A?(_.copy(A.position),h.longitude===void 0&&(S=m.longitude)):(v.bounding.getCenter(_),R=T),__assign(__assign({},y),{mode:"Mapview",longitude:S,latitude:b,fov:E,offset:_,distance:R})},t.prototype.destroy=function(){n.prototype.destroy.call(this),this.locationMotion.dispose(),delete this.panState,this.intersectMesh.dispose(),this.helper.remove(this.intersectMesh)},t.prototype.isReady=function(){return this.locationMotion.ended===!1?!1:n.prototype.isReady.call(this)},t.prototype.updateWork=function(e,r,o,s){this.userAction=s,this.works=e;var u=t.initAnimationEndState(__assign(__assign({},this),{initial:{currentState:__assign(__assign({},this.currentPano),this.camera.pose),duration:o.duration,effect:o.effect,state:r,userAction:s}}));this.currentPano={workCode:u.workCode,panoIndex:u.panoIndex};var l={longitude:u.longitude,latitude:u.latitude,fov:u.fov},c={x:u.offset.x,y:u.offset.y,z:u.offset.z,distance:u.distance,orthoDistance:u.distance};return this.locationMotion.set(c,o.duration).catch(noop$1),this.cameraMotion.set(l,o.duration).catch(noop$1),!0},t.prototype.updateModel=function(e){n.prototype.updateModel.call(this,e);var r=e.bounding.getCenter(new THREE__namespace.Vector3),o=t.distanceFromModel(e,this.cameraMotion.value.fov,this.camera.aspect);this.updateCamera({offset:r,distance:o},0,!0)},t.prototype.updateCamera=function(e,r,o){var s=this;return this.initAnimationReady.then(function(){s.userAction=o,s.stopMomentumMovement();var u={},l={};return e.distance!==void 0&&(u.distance=e.distance),e.offset!==void 0&&(u.x=e.offset.x,u.y=e.offset.y,u.z=e.offset.z),e.longitude!==void 0&&(l.longitude=e.longitude),e.latitude!==void 0&&(l.latitude=e.latitude),e.fov!==void 0&&(l.fov=e.fov),s.locationMotion.set(u,r).catch(noop$1),s.cameraMotion.set(l,r).catch(noop$1)})},t.prototype.updateCameraWithKeyframes=function(e,r,o){var s=this;return this.initAnimationReady.then(function(){s.userAction=o,s.stopMomentumMovement();for(var u=[],l=[],c=0,f=e;c<f.length;c++){var d=f[c];u.push({key:d.key,progress:d.progress,value:{distance:d.value.distance,x:d.value.offset.x,y:d.value.offset.x,z:d.value.offset.x}}),l.push({key:d.key,progress:d.progress,value:{longitude:d.value.longitude,latitude:d.value.latitude,fov:d.value.fov}})}return s.locationMotion.setKeyframes(u,r).catch(noop$1),s.cameraMotion.setKeyframes(e,r)})},t.prototype.updateTime=function(e,r){if(!this.destroyed){var o={},s={};this.locationMotion.ended||(this.locationMotion.update(e),s.distance=this.locationMotion.value.distance,s.offset=new THREE__namespace.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z)),this.cameraMotion.ended||(this.cameraMotion.update(e),s.longitude=this.cameraMotion.value.longitude,s.latitude=this.cameraMotion.value.latitude,s.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended||(this.modelAlphaMotion.update(e),o.modelAlpha=this.modelAlphaMotion.value.modelAlpha);var u=0;this.cameraType==="auto"?u=Math.abs(Math.PI/2-this.cameraMotion.value.latitude)<.02||Math.abs(-Math.PI/2-this.cameraMotion.value.latitude)<.02?1:0:this.cameraType==="perspective"?u=0:this.cameraType==="orthographic"&&(u=1),this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==u&&this.perspToOrthoMotion.set({perspToOrtho:u},500).catch(noop$1),this.perspToOrthoMotion.ended||(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),isEmptyObject(o)||this.models.setMaterial(o),isEmptyObject(s)||this.setCamera(s)}},t.prototype.getTargetState=function(){var e=this.cameraMotion.getKeyFrameSegment(now())[1],r=this.locationMotion.getKeyFrameSegment(now())[1];return __assign(__assign({},this.currentPano),{mode:this.mode,longitude:e.value.longitude,latitude:e.value.latitude,fov:e.value.fov,distance:r.value.distance,offset:new THREE__namespace.Vector3(r.value.x,r.value.y,r.value.z)})},t.prototype.initAnimation=function(){var e=this;return this.destroyed?Promise.resolve():new Promise(function(r){var o=e.initial;o.state,o.currentState;var s=o.duration,u=o.userAction;e.userAction=u;var l=t.initAnimationEndState(e),c={longitude:l.longitude,latitude:l.latitude,fov:l.fov},f={x:l.offset.x,y:l.offset.y,z:l.offset.z,distance:l.distance},d={modelAlpha:1},p={perspToOrtho:0};e.emit("initAnimation.start",createEvent("initAnimation.start",{state:l,userAction:e.userAction})),e.perspToOrthoMotion.set(p,s).catch(noop$1),e.modelAlphaMotion.set(d,s/3).catch(noop$1),e.cameraMotion.set(c,s).catch(noop$1),e.locationMotion.set(f,s).then(function(){e.emit("initAnimation.end",createEvent("initAnimation.end",{state:l,userAction:e.userAction}))},function(v){var g=__assign(__assign(__assign({},e.currentPano),{mode:e.mode}),clonePose(e.camera.pose));e.emit("initAnimation.end",createEvent("initAnimation.end",{state:g,userAction:e.userAction}))}).then(function(){r()})})},t.prototype.getForwardObserverOrNot=function(e){var r=this,o=this.models.intersectRaycaster(e)[0];if(!o)return null;var s=this.works.resolvedObservers.filter(function(f){for(var d,p=0,v=r.models;p<v.length;p++){var g=v[p];if(g.visible&&((d=g.work)===null||d===void 0?void 0:d.workCode)===f.work.workCode)return!0}return!1}),u=arrayMin(s,function(f){return f.standingPosition.distanceTo(o.point)},!0),l=u[0],c=u[1];return l&&c<10?l:null},t.prototype.coordinatesForOffset=function(e){var r=this.renderer.getSize(new THREE__namespace.Vector2);return{longitude:-2*e.x/(r.x*this.scissor.width),latitude:2*e.y/(r.y*this.scissor.height)}},t.prototype.requestMomentumMovement=function(e,r,o,s){var u=this;if(this.inMomentumMovement!==null){for(var l=__assign({},o),c={longitude:0,latitude:0,x:0,y:0,z:0},f=0;f<s;f++)l.longitude*=.996,l.latitude*=.996*.998,l.x*=.99,l.y*=.99,l.z*=.99,c.longitude+=l.longitude,c.latitude+=l.latitude,c.x+=l.x,c.y+=l.y,c.z+=l.z;var d=formatRad(this.cameraMotion.value.longitude+c.longitude),p=clamp$1(this.cameraMotion.value.latitude+c.latitude,this.minLatitude,this.maxLatitude),v=new THREE__namespace.Vector3(this.locationMotion.value.x+c.x,this.locationMotion.value.y+c.y,this.locationMotion.value.z+c.z),g=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:d,latitude:p,offset:v,fov:this.cameraMotion.value.fov,distance:this.camera.pose.distance}),h=!(Math.abs(l.longitude)>1e-4||Math.abs(l.latitude)>1e-4||Math.abs(l.x)>1e-4||Math.abs(l.y)>1e-4||Math.abs(l.z)>1e-4),m=createEvent("gesture.momentum",__assign(__assign({},e),{isFirst:r,isFinal:h,state:g}));if(this.inMomentumMovement.event=m,this.emit("gesture.momentum",m),e.defaultPrevented){this.inMomentumMovement=null;return}this.inMomentumMovement&&(this.cameraMotion.set({longitude:d,latitude:p},0).catch(noop$1),this.locationMotion.set({x:g.offset.x,y:g.offset.y,z:g.offset.z},0).catch(noop$1),h?this.inMomentumMovement=null:AnimationFrameLoop.shared.add(function(y,A){u.requestMomentumMovement(e,!1,l,A|0)},!0,1))}},t.prototype.fixFinalState=function(e){if(this.perspToOrthoMotion.getTargetKeyframe().value.perspToOrtho!==1){var r=coordinatesToVector(e,new THREE__namespace.Vector3),o=new THREE__namespace.Vector3().copy(e.offset).sub(r.clone().multiplyScalar(e.distance)),s=new THREE__namespace.Raycaster(o,r);s.params.Points={threshold:.1},s.near=RAYCASTER_NEAR;var u;if(s.ray.direction.y<-.3&&(u=this.models.intersectRaycaster(s).filter(function(p){var v,g=(v=p.face)===null||v===void 0?void 0:v.normal;return g&&s.ray.direction.dot(g)>=0?!1:p.distance>minDistance+s.near})[0],!u)){var l=new THREE__namespace.Plane(new THREE__namespace.Vector3(0,1,0),-this.models.bounding.min.y),c=s.ray.intersectPlane(l,new THREE__namespace.Vector3);if(c){var f=c.distanceTo(s.ray.origin);f<1e4&&f>=s.near&&(u={distance:f,floor:0,point:c,object:this.scene,face:null})}}if(!u){var d=Math.max(e.distance,3);u={distance:d,floor:0,point:s.ray.direction.clone().setLength(d).add(s.ray.origin),object:this.scene,face:null}}u&&(e.distance=clamp$1(u.distance,0,1/0),e.offset.copy(o).add(r.clone().multiplyScalar(e.distance)))}},t.prototype.onPanGesture=function(e){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var r=e.pointers.length,o=this.panState,s=0;e.pointerType==="mouse"&&(s=e.srcEvent.buttons),o&&s===0&&o.buttons!==0&&(s=o.buttons);var u=o==null?void 0:o.target;if(!u){var l=this.relativeClientPosition(e.center),c=new THREE__namespace.Raycaster;c.params.Points={threshold:.1},c.setFromCamera(l,this.camera),c.near=RAYCASTER_NEAR,u=new THREE__namespace.Vector3().copy(c.ray.direction).multiplyScalar(3).add(c.ray.origin);var f=this.models.intersectRaycaster(c)[0];if(!f&&c.ray.direction.y<-.3){var d=new THREE__namespace.Plane(new THREE__namespace.Vector3(0,1,0),0),p=c.ray.intersectPlane(d,new THREE__namespace.Vector3);if(p){var v=p.distanceTo(c.ray.origin);v<1e4&&v>=c.near&&(f={distance:v,floor:0,point:p,object:this.scene})}}if(f)u.copy(f.point);else{var g=new THREE__namespace.Vector3().copy(this.camera.pose.offset).sub(this.camera.position).normalize(),d=new THREE__namespace.Plane().setFromNormalAndCoplanarPoint(g,this.camera.pose.offset);c.ray.intersectPlane(d,u)}}if(e.isFinal?delete this.panState:this.panState={target:u,buttons:s,pointerLength:r,x:e.center.x,y:e.center.y},!(typeof o=="undefined"||o.pointerLength!==r)){var h=r>1||s===2;if(h){var m={x:e.center.x-o.x,y:e.center.y-o.y},y=new THREE__namespace.Vector3(this.locationMotion.value.x,this.locationMotion.value.y,this.locationMotion.value.z),A=coordinatesToVector(this.cameraMotion.value).setLength(this.locationMotion.value.distance).add(y),E=new THREE__namespace.Vector3().copy(A).sub(o.target).length();E*=Math.tan(this.camera.pose.fov/2*Math.PI/180);var b=this.renderer.getSize(new THREE__namespace.Vector2),T=2*m.x*E/b.y,_=2*m.y*E/b.y,R=new THREE__namespace.Vector3;if(R.setFromMatrixColumn(this.camera.matrix,0),R.multiplyScalar(-T),y.add(R),this.camera.pose.latitude<PANGESTURE_FORWARD_ANGLE?R.setFromMatrixColumn(this.camera.matrix,1):(R.setFromMatrixColumn(this.camera.matrix,0),R.crossVectors(this.camera.up,R)),R.multiplyScalar(_),y.add(R),this.modelInScreen==="boundingbox-center"){var S=this.models.bounding.clone();S.expandByScalar(this.camera.pose.distance),y.clamp(S.min,S.max)}var M=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:this.camera.pose.longitude,latitude:this.camera.pose.latitude,fov:this.camera.pose.fov,offset:y,distance:this.camera.pose.distance});if(e.state=M,this.emit("gesture.pan",e),e.defaultPrevented)return;if(this.locationMotion.set({x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1),e.isFinal&&(this.fixFinalState(M),Object.assign(e,{__fixFinalState:!0}),this.locationMotion.set({distance:M.distance,x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1)),e.isFinal){var B=this.renderer.getSize(new THREE__namespace.Vector2),H=2*e.velocityX*E/B.y,w=2*e.velocityY*E/B.y,C=new THREE__namespace.Vector3,F=new THREE__namespace.Vector3;C.setFromMatrixColumn(this.camera.matrix,0),C.multiplyScalar(-H),F.add(C),this.camera.pose.latitude<PANGESTURE_FORWARD_ANGLE?C.setFromMatrixColumn(this.camera.matrix,1):(C.setFromMatrixColumn(this.camera.matrix,0),C.crossVectors(this.camera.up,C)),C.multiplyScalar(w),F.add(C),this.inMomentumMovement={uuid:createUuid()},this.requestMomentumMovement(e,!0,{longitude:0,latitude:0,x:F.x,y:F.y,z:F.z},0)}}else{var m={x:e.center.x-o.x,y:e.center.y-o.y},I=this.coordinatesForOffset(m),L=formatRad(this.cameraMotion.value.longitude+I.longitude),k=clamp$1(this.cameraMotion.value.latitude+I.latitude,this.minLatitude,this.maxLatitude);this.camera.aspect<1&&Math.abs(e.overallVelocityX)>.2&&Math.atan2(Math.abs(e.overallVelocityY),Math.abs(e.overallVelocityX))<Math.PI/6.923&&(k=this.cameraMotion.value.latitude);var M=__assign(__assign({},this.currentPano),{mode:this.mode,longitude:L,latitude:k,fov:this.camera.pose.fov,offset:this.camera.pose.offset,distance:this.camera.pose.distance});if(e.isFinal&&Object.assign(e,{__fixFinalState:!0}),e.state=M,this.emit("gesture.pan",e),e.defaultPrevented)return;if(e.isFinal?this.locationMotion.set({distance:M.distance,x:M.offset.x,y:M.offset.y,z:M.offset.z},0).catch(noop$1):this.cameraMotion.set({longitude:M.longitude,latitude:M.latitude},0).catch(noop$1),e.isFinal){var N=e.velocityX,D=e.velocityY;this.inMomentumMovement={uuid:createUuid()},this.requestMomentumMovement(e,!0,__assign(__assign({},this.coordinatesForOffset({x:N,y:D})),{x:0,y:0,z:0}),0)}}}},t.prototype.onPinchGesture=function(e){var r;if(this.initAnimationIsReady){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var o=(r=this.pinchState)===null||r===void 0?void 0:r.distance;if(e.isFirst){this.pinchState={x:e.center.x,y:e.center.y,scale:1,distance:this.locationMotion.value.distance};return}if(typeof o!="undefined"){var s=this.models.bounding.getCenter(new THREE__namespace.Vector3),u=t.distanceFromModel(this.models,this.cameraMotion.value.fov,this.camera.aspect),l=clamp$1(o/e.scale,minDistance,1/0),c=e.state.offset.clone().sub(coordinatesToVector(e.state).setLength(l)),f=this.models.bounding.containsPoint(c),d;if(!f&&this.pinchState&&this.pinchState.scale>e.scale&&s.distanceTo(c)>u?d=e.state.distance:(d=l,this.pinchState&&(this.pinchState.scale=e.scale)),e.state.distance=d,this.emit("gesture.pinch",e),!e.defaultPrevented&&(this.locationMotion.set({distance:e.state.distance},0).catch(noop$1),e.pointerType!=="mouse"&&(e.type="gesture.pan",this.onPanGesture(e)),e.isFinal)){if(!("__fixFinalState"in e)){var p=e.state;this.fixFinalState(e.state);var v={x:p.offset.x,y:p.offset.y,z:p.offset.z,distance:p.distance};this.locationMotion.set(v,0).catch(noop$1)}delete this.panState,delete this.pinchState}}}},t.prototype.onMouseMove=function(e){var r,o;if(this.intersectMesh.parent&&!this.panState&&!this.pinchState&&!this.mouseWheelState&&(this.emit("gesture.mousemove",e),!e.defaultPrevented)){var s=e.center.raycaster;if(s.near=RAYCASTER_NEAR,s.far=500,e.isFinal&&this.intersectMesh.parent&&this.intersectMesh.visible===!0){this.hideIntersectMesh();return}var u=this.models.intersectRaycaster(s)[0],l=createEvent("intersect.update",{raycaster:s,intersection:u!=null?u:null,object:this.intersectMesh});if(this.emit("intersect.update",l),l.defaultPrevented){this.hideIntersectMesh();return}if(u){var c=(o=(r=u.face)===null||r===void 0?void 0:r.normal)!==null&&o!==void 0?o:new THREE__namespace.Vector3().copy(s.ray.direction).multiplyScalar(-1),f=c.clone(),d=u.point.clone();this.intersectMesh.position.copy(d);var p=s.ray.origin.distanceTo(d),v=2*Math.tan(.5*this.camera.fov/180*Math.PI),g=Math.max(p*v/10,1);this.intersectMesh.scale.set(g,g,g);var h=d.clone().add(f);if(this.intersectMesh.lookAt(h),Math.abs(c.y)>.99){var m=this.camera.position.clone().sub(d);this.intersectMesh.rotation.z=-Math.atan2(m.z,m.x)}this.intersectMesh.visible=!0,this.needsRender=!0}else this.hideIntersectMesh()}},t.prototype.onMouseWheel=function(e){if(this.initAnimationIsReady)if(this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh(),e.isFinal){var r=e.state;if(this.fixFinalState(r),this.emit("gesture.mousewheel",e),e.defaultPrevented)return;var o={x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance};this.locationMotion.set(o,0).catch(noop$1)}else{var s=e.center.delta/2*Math.max(Math.log(this.locationMotion.value.distance),1);if(this.locationMotion.value.distance-s>=minDistance){var u=this.locationMotion.value.distance-s;e.state.distance=u}else{var l=coordinatesToVector(this.cameraMotion.value);l.setLength(s),e.state.offset.add(l),this.modelInScreen==="boundingbox-center"&&e.state.offset.clamp(this.models.bounding.min,this.models.bounding.max)}if(this.emit("gesture.mousewheel",e),e.defaultPrevented)return;this.locationMotion.set({distance:e.state.distance,x:e.state.offset.x,y:e.state.offset.y,z:e.state.offset.z},0).catch(noop$1)}},t.prototype.onTapGesture=function(e){var r=this;this.userAction=e.userAction,this.stopMomentumMovement();var o=e.center.raycaster,s=this.getForwardObserverOrNot(o);if(!s)this.emit("gesture.tap",e);else{var u={longitude:this.camera.pose.longitude,latitude:0},l=__assign(__assign({},e.state),{mode:"Panorama",workCode:s.pano.workCode,panoIndex:s.pano.panoIndex,longitude:u.longitude,latitude:u.latitude,offset:s?s.position.clone():new THREE__namespace.Vector3,distance:0});if(e.state=l,this.emit("gesture.tap",e),!e.defaultPrevented&&(this.emit("pano.select",createEvent("pano.select",{prevPano:this.currentPano,state:l,userAction:e.userAction,options:u,progress:0,error:null})),s&&s.active)){var c=this.currentTapId=createUuid();this.preloadPano(s.pano).then(function(f){r.currentTapId===c&&r.emit("pano.request",createEvent("pano.request",{userAction:!0,prevPano:r.currentPano,progress:0,state:l,options:u,error:null}))})}}},t.prototype.onDblTapGesture=function(e){if(this.initAnimationIsReady){this.userAction=e.userAction,this.stopMomentumMovement(),this.hideIntersectMesh();var r=e.state,o=e.center.raycaster,s=o.ray.origin.clone().add(o.ray.direction.clone().setLength(3)),u=1,l=3,c=u,f=this.models.intersectRaycaster(o)[0];if(f&&(s=f.point.clone(),f.distance>(u+l)/2?c=u:c=l),e.state.distance=c,e.state.offset=s,this.emit("gesture.dbltap",e),!e.defaultPrevented){var d={x:r.offset.x,y:r.offset.y,z:r.offset.z,distance:r.distance};this.locationMotion.set(d,360).catch(noop$1),this.hideIntersectMesh()}}},t.prototype.hideIntersectMesh=function(){this.intersectMesh.visible=!1,this.needsRender=!0},t.prototype.render=function(e,r){var o=this.renderer.getRenderTarget();this.updateScreenBuffer(r),e&&(r==="edl"?this.edlEffect.render(this.screenBuffers):r==="hq"?this.hqEffect.render(this.screenBuffers):(this.renderer.setRenderTarget(this.modelRenderTarget),this.renderer.render(this.modelScene,this.camera))),this.depthCopyPass.render(this.modelRenderTarget.depthTexture,o),this.renderer.autoClearDepth=!1,this.renderer.autoClearColor=!0,this.copyPass.render(this.modelRenderTarget,o),this.renderer.setRenderTarget(o),this.renderer.autoClearColor=!1,this.renderer.autoClearDepth=!1,this.renderer.render(this.scene,this.camera),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0},t}(BaseController);function isNil(n){return n==null}var _moveEvent={type:"move"},XRController=function(){function n(){this._targetRay=null,this._grip=null,this._hand=null,this._axes=[0,0]}return n.prototype.getHandSpace=function(){return this._hand===null&&(this._hand=new THREE__namespace.Group,this._hand.matrixAutoUpdate=!1,this._hand.visible=!1,this._hand.joints={},this._hand.inputState={pinching:!1}),this._hand},n.prototype.getTargetRaySpace=function(){return this._targetRay===null&&(this._targetRay=new THREE__namespace.Group,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new THREE__namespace.Vector3,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new THREE__namespace.Vector3),this._targetRay},n.prototype.getGripSpace=function(){return this._grip===null&&(this._grip=new THREE__namespace.Group,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new THREE__namespace.Vector3,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new THREE__namespace.Vector3),this._grip},n.prototype.dispatchEvent=function(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this},n.prototype.disconnect=function(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this},n.prototype.getAxes=function(){return this._axes},n.prototype.update=function(t,e,r){var o=null,s=null,u=null,l=this._targetRay,c=this._grip,f=this._hand;if(t&&t.gamepad&&t.gamepad.axes&&(this._axes=[t.gamepad.axes[2],t.gamepad.axes[3]]),t&&e.session.visibilityState!=="visible-blurred")if(l!==null&&(o=e.getPose(t.targetRaySpace,r),o!==null&&(l.matrix.fromArray(o.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),o.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(o.linearVelocity)):l.hasLinearVelocity=!1,o.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(o.angularVelocity)):l.hasAngularVelocity=!1,this.dispatchEvent(_moveEvent))),f&&t.hand){u=!0;for(var d=0,p=t.hand.values();d<p.length;d++){var v=p[d],g=e.getJointPose(v,r);if(f.joints[v.jointName]===void 0){var h=new THREE__namespace.Group;h.matrixAutoUpdate=!1,h.visible=!1,f.joints[v.jointName]=h,f.add(h)}var m=f.joints[v.jointName];g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.jointRadius=g.radius),m.visible=g!==null}var y=f.joints["index-finger-tip"],A=f.joints["thumb-tip"],E=y.position.distanceTo(A.position),b=.02,T=.005;f.inputState.pinching&&E>b+T?(f.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!f.inputState.pinching&&E<=b-T&&(f.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(s=e.getPose(t.gripSpace,r),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1));return l!==null&&(l.visible=o!==null),c!==null&&(c.visible=s!==null),f!==null&&(f.visible=u!==null),this},n}(),framebufferScaleFactor=1,XRManager=function(){function n(t,e,r){var o,s,u,l,c;this.isPanorama=(o=r==null?void 0:r.isPanorama)!==null&&o!==void 0?o:!0;var f=navigator.userAgent.toLowerCase(),d;f.includes("pico")?d="Pico":f.includes("oculus")?d="Oculus":d="VP",this.machineType=(s=r==null?void 0:r.machineType)!==null&&s!==void 0?s:d,this.renderer=t,this.gl=e,this.enabled=!1,this.session=null,this.referenceSpaceType=(u=r==null?void 0:r.referenceSpaceType)!==null&&u!==void 0?u:"local-floor",this.referenceSpace=null,this.onSessionStartCallback=(l=r==null?void 0:r.onSessionStart)!==null&&l!==void 0?l:noop$1,this.onSessionEndCallback=(c=r==null?void 0:r.onSessionEnd)!==null&&c!==void 0?c:noop$1,this.controllers=[new XRController,new XRController],this.inputSourcesMap=new Map,this.cameraVR=new THREE__namespace.ArrayCamera,this.cameraL=new THREE__namespace.PerspectiveCamera,this.cameraR=new THREE__namespace.PerspectiveCamera,this.cameraL.viewport=new THREE__namespace.Vector4,this.cameraR.viewport=new THREE__namespace.Vector4,this.cameraL.layers.enable(1),this.cameraR.layers.enable(2),this.cameraVR.layers.enable(1),this.cameraVR.layers.enable(2),this.isPresenting=!1,this.currentDepthNear=null,this.currentDepthFar=null,this.cameraLPos=new THREE__namespace.Vector3,this.cameraRPos=new THREE__namespace.Vector3}return n.prototype.getController=function(t){var e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getRightController=function(){if(!this.session)return null;var t=this.session.inputSources[0].handedness==="right"?0:1,e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getLeftController=function(){if(!this.session)return null;var t=this.session.inputSources[0].handedness==="left"?0:1,e=this.controllers[t];return e||console.warn("no controller find"),e.getTargetRaySpace()},n.prototype.getControllerGrip=function(t){var e=this.controllers[t];return e||console.warn("no controller find"),e.getGripSpace()},n.prototype.getCameras=function(){return{cameraL:this.cameraL,cameraR:this.cameraR,cameraVR:this.cameraVR}},n.prototype.updateCamera=function(t,e){e===null?t.matrixWorld.copy(t.matrix):t.matrixWorld.multiplyMatrices(e.matrixWorld,t.matrix),t.matrixWorldInverse.getInverse(t.matrixWorld)},n.prototype.setProjectionFromUnion=function(t,e,r){this.cameraLPos.setFromMatrixPosition(e.matrixWorld),this.cameraRPos.setFromMatrixPosition(r.matrixWorld);var o=this.cameraLPos.distanceTo(this.cameraRPos),s=e.projectionMatrix.elements,u=r.projectionMatrix.elements,l=s[14]/(s[10]-1),c=s[14]/(s[10]+1),f=(s[9]+1)/s[5],d=(s[9]-1)/s[5],p=(s[8]-1)/s[0],v=(u[8]+1)/u[0],g=l*p,h=l*v,m=o/(-p+v),y=m*-p;e.matrixWorld.decompose(t.position,t.quaternion,t.scale),t.translateX(y),t.translateZ(m),t.matrixWorld.compose(t.position,t.quaternion,t.scale),t.matrixWorldInverse.getInverse(t.matrixWorld);var A=l+m,E=c+m,b=g-y,T=h+(o-y),_=f*c/E*A,R=d*c/E*A;t.projectionMatrix.makePerspective(b,T,_,R,A,E)},n.prototype.getCamera=function(t){this.cameraVR.near=this.cameraR.near=this.cameraL.near=t.near,this.cameraVR.far=this.cameraR.far=this.cameraL.far=t.far,this.session&&(this.currentDepthNear!==this.cameraVR.near||this.currentDepthFar!==this.cameraVR.far)&&(this.session.updateRenderState({depthNear:this.cameraVR.near,depthFar:this.cameraVR.far}),this.currentDepthNear=this.cameraVR.near,this.currentDepthFar=this.cameraVR.far);var e=t.parent,r=this.cameraVR.cameras;this.updateCamera(this.cameraVR,e);for(var o=0;o<r.length;o++)this.updateCamera(r[o],e);t.matrixWorld.copy(this.cameraVR.matrixWorld);for(var s=t.children,o=0,u=s.length;o<u;o++)s[o].updateMatrixWorld(!0);return r.length===2?this.setProjectionFromUnion(this.cameraVR,this.cameraL,this.cameraR):this.cameraVR.projectionMatrix.copy(this.cameraL.projectionMatrix),this.cameraVR},n.prototype.updateInputSources=function(t){if(!this.session){console.warn("session is lose!");return}for(var e=this.session.inputSources,r=0;r<this.controllers.length;r++)this.inputSourcesMap.set(e[r],this.controllers[r]);for(var r=0;r<t.removed.length;r++){var o=t.removed[r],s=this.inputSourcesMap.get(o);s&&(s.dispatchEvent({type:"disconnected",data:o}),this.inputSourcesMap.delete(o))}for(var r=0;r<t.added.length;r++){var o=t.added[r],s=this.inputSourcesMap.get(o);s&&s.dispatchEvent({type:"connected",data:o})}},n.prototype.onSessionEvent=function(t){var e=this.inputSourcesMap.get(t.inputSource);e&&e.dispatchEvent({type:t.type})},n.prototype.onSessionEnd=function(){this.inputSourcesMap.forEach(function(t,e){t.disconnect(e)}),this.inputSourcesMap.clear(),this.renderer.setFramebuffer(null),this.renderer.setRenderTarget(this.renderer.getRenderTarget()),this.isPresenting=!1,this.session=null,AnimationFrameLoop.shared.setContext(null),this.onSessionEndCallback()},n.prototype.onRequestReferenceSpace=function(t){this.referenceSpace=t,this.isPresenting=!0,this.session&&this.onSessionStartCallback(this.session)},n.prototype.setSession=function(t){var e=this;if(this.session=t,this.session){this.session.addEventListener("select",function(o){e.onSessionEvent(o)}),this.session.addEventListener("selectstart",function(o){e.onSessionEvent(o)}),this.session.addEventListener("selectend",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeeze",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeezestart",function(o){e.onSessionEvent(o)}),this.session.addEventListener("squeezeend",function(o){e.onSessionEvent(o)}),this.session.addEventListener("end",function(o){e.onSessionEnd()});var r=this.gl.getContextAttributes();this.gl.makeXRCompatible().then(function(){var o={antialias:r==null?void 0:r.antialias,alpha:r==null?void 0:r.alpha,depth:r==null?void 0:r.depth,stencil:r==null?void 0:r.stencil,framebufferScaleFactor};if(!e.session){console.error("session is lose while set session!");return}switch(e.machineType){case"Pico":case"VP":e.session.updateRenderState({baseLayer:new XRWebGLLayer(e.session,e.gl,o)});break;case"Oculus":e.session.updateRenderState({baseLayer:new XRWebGLLayer(e.session,e.gl,o)});break;default:e.machineType;break}e.session.requestReferenceSpace(e.referenceSpaceType).then(function(s){e.onRequestReferenceSpace(s)}),e.session.addEventListener("inputsourceschange",function(s){e.updateInputSources(s)})})}},n}(),LineSegmentsGeometry=function(n){__extends(t,n);function t(){var e=n.call(this)||this;e.type="LineSegmentsGeometry";var r=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],o=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],s=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];return e.setIndex(s),e.setAttribute("position",new THREE__namespace.Float32BufferAttribute(r,3)),e.setAttribute("uv",new THREE__namespace.Float32BufferAttribute(o,2)),e}return t.prototype.applyMatrix4=function(e){var r=this.attributes.instanceStart,o=this.attributes.instanceEnd;return r!==void 0&&(r.applyMatrix4(e),o.applyMatrix4(e),r.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this},t.prototype.setPositions=function(e){var r;e instanceof Float32Array?r=e:Array.isArray(e)?r=new Float32Array(e):r=new Float32Array;var o=new THREE__namespace.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceStart",new THREE__namespace.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceEnd",new THREE__namespace.InterleavedBufferAttribute(o,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this},t.prototype.setColors=function(e){var r;e instanceof Float32Array?r=e:Array.isArray(e)?r=new Float32Array(e):r=new Float32Array;var o=new THREE__namespace.InstancedInterleavedBuffer(r,6,1);return this.setAttribute("instanceColorStart",new THREE__namespace.InterleavedBufferAttribute(o,3,0)),this.setAttribute("instanceColorEnd",new THREE__namespace.InterleavedBufferAttribute(o,3,3)),this},t.prototype.fromWireframeGeometry=function(e){return this.setPositions(e.attributes.position.array),this},t.prototype.fromEdgesGeometry=function(e){return this.setPositions(e.attributes.position.array),this},t.prototype.fromMesh=function(e){return this.fromWireframeGeometry(new THREE__namespace.WireframeGeometry(e.geometry)),this},t.prototype.fromLineSegments=function(e){var r=e.geometry;if(r instanceof THREE__namespace.Geometry){var o=new THREE__namespace.BufferGeometry().fromGeometry(r);this.setPositions(o.attributes.position.array)}else r instanceof THREE__namespace.BufferGeometry&&this.setPositions(r.attributes.position.array);return this},t.prototype.computeBoundingBox=function(){this.boundingBox===null&&(this.boundingBox=new THREE__namespace.Box3);var e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(e!==void 0&&r!==void 0){var o=new THREE__namespace.Box3;this.boundingBox.setFromBufferAttribute(e),o.setFromBufferAttribute(r),this.boundingBox.union(o)}},t.prototype.computeBoundingSphere=function(){this.boundingSphere===null&&(this.boundingSphere=new THREE__namespace.Sphere),this.boundingBox===null&&this.computeBoundingBox();var e=this.attributes.instanceStart,r=this.attributes.instanceEnd;if(e!==void 0&&r!==void 0){var o=this.boundingSphere.center;this.boundingBox.getCenter(o);for(var s=0,u=new THREE__namespace.Vector3,l=0,c=e.count;l<c;l++)u.fromBufferAttribute(e,l),s=Math.max(s,o.distanceToSquared(u)),u.fromBufferAttribute(r,l),s=Math.max(s,o.distanceToSquared(u));this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}},t.prototype.toJSON=function(){},t}(THREE__namespace.InstancedBufferGeometry);Object.assign(LineSegmentsGeometry.prototype,{isLineSegmentsGeometry:!0});var lineShader={uniforms:THREE__namespace.UniformsUtils.merge([THREE__namespace.UniformsLib.common,THREE__namespace.UniformsLib.fog,{linewidth:{value:1},resolution:{value:new THREE__namespace.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},opacity:{value:1}}]),vertexShader:`
1971
1971
  #include <common>
1972
1972
  #include <color_pars_vertex>
1973
1973
  #include <fog_pars_vertex>
@@ -2166,7 +2166,7 @@ void main() {
2166
2166
  #include <premultiplied_alpha_fragment>
2167
2167
 
2168
2168
  }
2169
- `},LineMaterial=function(n){__extends(t,n);function t(e){var r=n.call(this,{uniforms:THREE__namespace.UniformsUtils.clone(lineShader.uniforms),vertexShader:lineShader.vertexShader,fragmentShader:lineShader.fragmentShader,clipping:!0})||this;return r.type="LineMaterial",r.dashed=!1,Object.defineProperties(r,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(o){this.uniforms.diffuse.value=o}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(o){this.uniforms.linewidth.value=o}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(o){this.uniforms.dashScale.value=o}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(o){this.uniforms.dashSize.value=o}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(o){this.uniforms.gapSize.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}}}),r.setValues(e),r}return t}(THREE__namespace.ShaderMaterial);Object.assign(LineMaterial.prototype,{isLineMaterial:!0});var LineSegments2=function(n){__extends(t,n);function t(e,r){var o=n.call(this)||this;return o.type="LineSegments2",o.geometry=e!==void 0?e:new LineSegmentsGeometry,o.material=r!==void 0?r:new LineMaterial({color:Math.random()*16777215}),o}return t.prototype.computeLineDistances=function(){for(var e=this.geometry,r=e.attributes.instanceStart,o=e.attributes.instanceEnd,s=new Float32Array(2*r.count),u=new THREE__namespace.Vector3,l=new THREE__namespace.Vector3,c=0,f=0,d=r.count;c<d;c++,f+=2)u.fromBufferAttribute(r,c),l.fromBufferAttribute(o,c),s[f]=f===0?0:s[f-1],s[f+1]=s[f]+u.distanceTo(l);var p=new THREE__namespace.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new THREE__namespace.InterleavedBufferAttribute(p,1,0)),e.setAttribute("instanceDistanceEnd",new THREE__namespace.InterleavedBufferAttribute(p,1,1)),this},t.prototype.raycast=function(e,r){e.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var o=e.ray,s=e.camera,u=s.projectionMatrix,l=this.geometry,c=this.material,f=c.resolution,d=c.linewidth,p=l.attributes.instanceStart,v=l.attributes.instanceEnd,g=new THREE__namespace.Vector4,h=new THREE__namespace.Vector4,m=new THREE__namespace.Vector4,y=new THREE__namespace.Vector3,A=new THREE__namespace.Matrix4,E=new THREE__namespace.Line3,b=new THREE__namespace.Vector3;o.at(1,m),m.w=1,m.applyMatrix4(s.matrixWorldInverse),m.applyMatrix4(u),m.multiplyScalar(1/m.w),m.x*=f.x/2,m.y*=f.y/2,m.z=0,y.copy(m);var T=this.matrixWorld;A.multiplyMatrices(s.matrixWorldInverse,T);for(var _=0,R=p.count;_<R;_++){g.fromBufferAttribute(p,_),h.fromBufferAttribute(v,_),g.w=1,h.w=1,g.applyMatrix4(A),h.applyMatrix4(A),g.applyMatrix4(u),h.applyMatrix4(u),g.multiplyScalar(1/g.w),h.multiplyScalar(1/h.w);var S=g.z<-1&&h.z<-1,M=g.z>1&&h.z>1;if(!(S||M)){g.x*=f.x/2,g.y*=f.y/2,h.x*=f.x/2,h.y*=f.y/2,E.start.copy(g),E.start.z=0,E.end.copy(h),E.end.z=0;var B=E.closestPointToPointParameter(y,!0);E.at(B,b);var H=THREE__namespace.MathUtils.lerp(g.z,h.z,B),w=H>=-1&&H<=1,C=y.distanceTo(b)<d*.5;if(w&&C){E.start.fromBufferAttribute(p,_),E.end.fromBufferAttribute(v,_),E.start.applyMatrix4(T),E.end.applyMatrix4(T);var F=new THREE__namespace.Vector3,I=new THREE__namespace.Vector3;o.distanceSqToSegment(E.start,E.end,I,F),r.push({point:I,pointOnLine:F,distance:o.origin.distanceTo(I),object:this,faceIndex:_})}}}},t}(THREE__namespace.Mesh);Object.assign(LineSegments2.prototype,{isLineSegments2:!0});var Line2=function(n){__extends(t,n);function t(e,r){var o=n.call(this,e,r)||this;return o.type="Line2",o}return t}(LineSegments2);Object.assign(Line2.prototype,{isLine2:!0});var LineGeometry=function(n){__extends(t,n);function t(){var e=n.call(this)||this;return e.type="LineGeometry",e}return t.prototype.setPositions=function(e){for(var r=e.length-3,o=new Float32Array(2*r),s=0;s<r;s+=3)o[2*s]=e[s],o[2*s+1]=e[s+1],o[2*s+2]=e[s+2],o[2*s+3]=e[s+3],o[2*s+4]=e[s+4],o[2*s+5]=e[s+5];return n.prototype.setPositions.call(this,o),this},t.prototype.setColors=function(e){for(var r=e.length-3,o=new Float32Array(2*r),s=0;s<r;s+=3)o[2*s]=e[s],o[2*s+1]=e[s+1],o[2*s+2]=e[s+2],o[2*s+3]=e[s+3],o[2*s+4]=e[s+4],o[2*s+5]=e[s+5];return n.prototype.setColors.call(this,o),this},t.prototype.fromLine=function(e){var r=e.geometry;if(r instanceof THREE__namespace.Geometry){var o=new THREE__namespace.BufferGeometry().fromGeometry(r);this.setPositions(o.attributes.position.array)}else r instanceof THREE__namespace.BufferGeometry&&this.setPositions(r.attributes.position.array);return this},t.prototype.copy=function(){return this},t}(LineSegmentsGeometry);Object.assign(LineGeometry.prototype,{isLineGeometry:!0});var circleImageURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==",DEFAULT_COLOR=14467195,POINT_SIZE=8,DEFAULT_LINEWIDTH=2,DEFAULT_DASHSCALE=20,sharedCircleTexture=null,FiveLine=function(n){__extends(t,n);function t(e,r){e===void 0&&(e=new THREE__namespace.Vector3),r===void 0&&(r=new THREE__namespace.Vector3);var o=n.call(this)||this;o.type="FiveLine",o.needsRender=!0;var s=new LineGeometry,u=new LineMaterial({color:DEFAULT_COLOR,linewidth:DEFAULT_LINEWIDTH,dashScale:DEFAULT_DASHSCALE,dashed:!1});o.line=new Line2(s,u);var l=new THREE__namespace.BufferGeometry,c=new THREE__namespace.PointsMaterial({color:DEFAULT_COLOR,size:POINT_SIZE,map:sharedCircleTexture||(sharedCircleTexture=new THREE__namespace.TextureLoader().load(circleImageURL)),sizeAttenuation:!1,transparent:!0});return o.points=new THREE__namespace.Points(l,c),o.points.renderOrder=11,o.points.frustumCulled=!1,o.setPoints(e,r),o.add(o.line,o.points),o}return Object.defineProperty(t,"version",{get:function(){return"6.4.0-alpha.13"},enumerable:!1,configurable:!0}),t.prototype.setPoints=function(e,r){var o=[].concat(e.toArray(),r.toArray());this.points.geometry.setAttribute("position",new THREE__namespace.BufferAttribute(new Float32Array(o),3)),this.line.geometry.setPositions(o),this.line.computeLineDistances(),this.needsRender=!0},t.prototype.getPoints=function(){var e=this.points.geometry.attributes.position.array;return[new THREE__namespace.Vector3(e[0],e[1],e[2]),new THREE__namespace.Vector3(e[3],e[4],e[5])]},t.prototype.setMaterial=function(e){var r=this.line.material;for(var o in e)if(e.hasOwnProperty(o)){var s=e[o];o==="dashed"?(r.dashed=s,s?r.defines.USE_DASH="":delete r.defines.USE_DASH,r.needsUpdate=!0):r[o]=e[o]}this.needsRender=!0},t.prototype.setResolution=function(e,r){var o=this.line.material.resolution;(o.x!==e||o.y!==r)&&(o.set(e,r),this.needsRender=!0)},t}(THREE__namespace.Object3D);Object.assign(FiveLine.prototype,{isFiveLine:!0});var Constants={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};function fetchJsonFile(n){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,fetch(n)];case 1:if(t=e.sent(),t.ok)return[2,t.json()];throw new Error(t.statusText)}})})}function fetchProfilesList(n){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:if(!n)throw new Error("No basePath supplied");return t="profilesList.json",[4,fetchJsonFile("".concat(n,"/").concat(t))];case 1:return e=r.sent(),[2,e]}})})}function fetchProfile(n,t){return __awaiter(this,arguments,void 0,function(e,r,o,s){var u,l,c,f,d,p;return o===void 0&&(o=null),s===void 0&&(s=!0),__generator(this,function(v){switch(v.label){case 0:if(!e)throw new Error("No xrInputSource supplied");if(!r)throw new Error("No basePath supplied");return[4,fetchProfilesList(r)];case 1:if(u=v.sent(),e.profiles.some(function(g){var h=u[g];return h&&(l={profileId:g,profilePath:"".concat(r,"/").concat(h.path),deprecated:!!h.deprecated}),!!l}),!l){if(!o)throw new Error("No matching profile name found");if(c=u[o],!c)throw new Error('No matching profile name found and default profile "'.concat(o,'" missing.'));l={profileId:o,profilePath:"".concat(r,"/").concat(c.path),deprecated:!!c.deprecated}}return[4,fetchJsonFile(l.profilePath)];case 2:if(f=v.sent(),s){if(p=void 0,p=f.layouts[e.handedness],!p)throw new Error("No matching handedness, ".concat(e.handedness,", in profile ").concat(l.profileId));p.assetPath&&(d=l.profilePath.replace("profile.json",p.assetPath))}return[2,{profile:f,assetPath:d}]}})})}var defaultComponentValues={xAxis:0,yAxis:0,button:0,state:Constants.ComponentState.DEFAULT};function normalizeAxes(n,t){n===void 0&&(n=0),t===void 0&&(t=0);var e=n,r=t,o=Math.sqrt(n*n+t*t);if(o>1){var s=Math.atan2(t,n);e=Math.cos(s),r=Math.sin(s)}var u={normalizedXAxis:e*.5+.5,normalizedYAxis:r*.5+.5};return u}var VisualResponse=function(){function n(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===Constants.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(defaultComponentValues)}return n.prototype.updateFromComponent=function(t){var e=t.xAxis,r=t.yAxis,o=t.button,s=t.state,u=normalizeAxes(e,r),l=u.normalizedXAxis,c=u.normalizedYAxis;switch(this.componentProperty){case Constants.ComponentProperty.X_AXIS:this.value=this.states.includes(s)?l:.5;break;case Constants.ComponentProperty.Y_AXIS:this.value=this.states.includes(s)?c:.5;break;case Constants.ComponentProperty.BUTTON:this.value=this.states.includes(s)?o:0;break;case Constants.ComponentProperty.STATE:this.valueNodeProperty===Constants.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(s):this.value=this.states.includes(s)?1:0;break;default:throw new Error("Unexpected visualResponse componentProperty ".concat(this.componentProperty))}},n}(),Component=function(){function n(t,e){var r=this;if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(function(o){var s=new VisualResponse(e.visualResponses[o]);r.visualResponses[o]=s}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:Constants.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}return Object.defineProperty(n.prototype,"data",{get:function(){var t=__assign({id:this.id},this.values);return t},enumerable:!1,configurable:!0}),n.prototype.updateFromGamepad=function(t){var e=this;if(this.values.state=Constants.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){var r=t.buttons[this.gamepadIndices.button];this.values.button=r.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,r.pressed||this.values.button===1?this.values.state=Constants.ComponentState.PRESSED:(r.touched||this.values.button>Constants.ButtonTouchThreshold)&&(this.values.state=Constants.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(function(o){o.updateFromComponent(e.values)})},n}(),MotionController=function(){function n(t,e,r){var o=this;if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=r,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(function(s){var u=o.layoutDescription.components[s];o.components[s]=new Component(s,u)}),this.updateFromGamepad()}return Object.defineProperty(n.prototype,"gripSpace",{get:function(){return this.xrInputSource.gripSpace},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"targetRaySpace",{get:function(){return this.xrInputSource.targetRaySpace},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"data",{get:function(){var t=[];return Object.values(this.components).forEach(function(e){t.push(e.data)}),t},enumerable:!1,configurable:!0}),n.prototype.updateFromGamepad=function(){var t=this;Object.values(this.components).forEach(function(e){e.updateFromGamepad(t.xrInputSource.gamepad)})},n}(),DEFAULT_PROFILES_PATH="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",DEFAULT_PROFILE="generic-trigger",XRControllerModel=function(n){__extends(t,n);function t(){var e=n.call(this)||this;return e.motionController=null,e.envMap=null,e}return t.prototype.setEnvironmentMap=function(e){var r=this;return this.envMap==e?this:(this.envMap=e,this.traverse(function(o){o instanceof THREE__namespace.Mesh&&o.isMesh&&(o.material.envMap=r.envMap,o.material.needsUpdate=!0)}),this)},t.prototype.updateMatrixWorld=function(e){n.prototype.updateMatrixWorld.call(this,e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(function(r){Object.values(r.visualResponses).forEach(function(o){var s=o.valueNode,u=o.minNode,l=o.maxNode,c=o.value,f=o.valueNodeProperty;s&&(f===Constants.VisualResponseProperty.VISIBILITY?s.visible=c:f===Constants.VisualResponseProperty.TRANSFORM&&(s.quaternion.copy(u.quaternion).slerp(l.quaternion,c),s.position.lerpVectors(u.position,l.position,c)))})}))},t}(THREE.Object3D);function findNodes(n,t){Object.values(n.components).forEach(function(e){var r=e.type,o=e.touchPointNodeName,s=e.visualResponses;if(r===Constants.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(o),e.touchPointNode){var u=new THREE.SphereGeometry(.001),l=new THREE.MeshBasicMaterial({color:255}),c=new THREE.Mesh(u,l);e.touchPointNode.add(c)}else console.warn("Could not find touch dot, ".concat(e.touchPointNodeName,", in touchpad component ").concat(e.id));Object.values(s).forEach(function(f){var d=f.valueNodeName,p=f.minNodeName,v=f.maxNodeName,g=f.valueNodeProperty;if(g===Constants.VisualResponseProperty.TRANSFORM){if(f.minNode=t.getObjectByName(p),f.maxNode=t.getObjectByName(v),!f.minNode){console.warn("Could not find ".concat(p," in the model"));return}if(!f.maxNode){console.warn("Could not find ".concat(v," in the model"));return}}f.valueNode=t.getObjectByName(d),f.valueNode||console.warn("Could not find ".concat(d," in the model"))})})}function addAssetSceneToControllerModel(n,t){findNodes(n.motionController,t),n.envMap&&t.traverse(function(e){e instanceof THREE__namespace.Mesh&&e.isMesh&&(e.material.envMap=n.envMap,e.material.needsUpdate=!0)}),n.add(t)}var XRControllerModelFactory=function(){function n(t){t===void 0&&(t=null),this.gltfLoader=t,this.path=DEFAULT_PROFILES_PATH,this._assetCache={}}return n.prototype.createControllerModel=function(t){var e=this,r=new XRControllerModel,o=null;return t.addEventListener("connected",function(s){var u=s.data;u.targetRayMode!=="tracked-pointer"||!u.gamepad||fetchProfile(u,e.path,DEFAULT_PROFILE).then(function(l){var c=l.profile,f=l.assetPath;r.motionController=new MotionController(u,c,f);var d=e._assetCache[r.motionController.assetUrl];if(d)o=d.scene.clone(),addAssetSceneToControllerModel(r,o);else{if(!e.gltfLoader)throw new Error("GLTFLoader not set.");e.gltfLoader.load(r.motionController.assetUrl,function(p){e._assetCache[r.motionController.assetUrl]=p,o=p.scene.clone(),addAssetSceneToControllerModel(r,o)})}}).catch(function(l){console.warn(l)})}),t.addEventListener("disconnected",function(){r.motionController=null,r.remove(o),o=null}),r},n}();function mapPanoResource(n,t){return n}var CONTROLLER_EVNET_DELTA_TIME=300,ROTATE_Y_PI_MATRIX=new THREE__namespace.Matrix4().makeRotationAxis(new THREE__namespace.Vector3(0,1,0),Math.PI),PANO_TEXTURE_SCALE=new THREE__namespace.Vector3(-1,1,1),XRPanoramaController=function(n){__extends(t,n);function t(e){var r=n.call(this,e)||this;r.xrManager=new XRManager(r.renderer,r.renderer.getContext(),{onSessionStart:function(c){r.emit("xr.session.start",createEvent("xr.session.start",{session:c,machineType:r.xrManager.machineType}))},onSessionEnd:function(){r.emit("xr.session.end",createEvent("xr.session.end",{session:null,machineType:r.xrManager.machineType}))}}),r.xrControllerRay={left:new THREE__namespace.Raycaster,right:new THREE__namespace.Raycaster},r.xrControllerRay.left.params.Points={threshold:.1},r.xrControllerRay.right.params.Points={threshold:.1},r.gazeRay=null,r.pointerLines={left:new FiveLine,right:new FiveLine},r.pointerLines.left.visible=!1,r.pointerLines.right.visible=!0,r.pointerLines.left.setMaterial({color:new THREE__namespace.Vector3(1,1,1)}),r.pointerLines.left.points.material.depthTest=!1,r.pointerLines.right.setMaterial({color:new THREE__namespace.Vector3(1,1,1)}),r.pointerLines.right.points.material.depthTest=!1,r.controllerWrappers=[new THREE__namespace.Group,new THREE__namespace.Group];var o=r.xrManager.getController(0);r.controllerWrappers[0].add(o);var s=r.xrManager.getController(1);r.controllerWrappers[1].add(s);var u=new XRControllerModelFactory;u.gltfLoader={load:function(c,f){internalFetcher.ajax(c,{responseType:"arraybuffer"}).then(function(d){var p;return parseGltf(d.body,{resourcePath:c.slice(0,c.lastIndexOf("/")+1),search:(p=c.split("?")[1])!==null&&p!==void 0?p:"",fetcher:internalFetcher})}).then(function(d){return f(d)})}},(r.xrManager.machineType==="Oculus"||r.xrManager.machineType==="Pico")&&r.scene.add(r.pointerLines.left,r.pointerLines.right,r.controllerWrappers[0],r.controllerWrappers[1]),r.panoResources={},r.panoResources[r.locationMotion.keyframes[0].key=r.locationMotion.keyframes[1].key=createUuid()]={panoId:panoStringify(r.currentPano),leftPanoPicture:null,position:r.camera.pose.offset.clone(),effect:"fade",fixCameraTransform:new THREE__namespace.Matrix4},r.parallaxCameraMatrixs=[];var l=AnimationFrameLoop.shared.getContext();return l?(r.on("xr.session.end",function(){r.scene.remove(r.pointerLines.left,r.pointerLines.right)}),r.xrManager.setSession(l),r.on("xr.session.start",function(){var c=r.xrManager.getControllerGrip(0);c.add(u.createControllerModel(c)),r.controllerWrappers[0].add(c);var f=r.xrManager.getControllerGrip(1);f.add(u.createControllerModel(f)),r.controllerWrappers[1].add(f)}),r.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}},r.xrManager.machineType==="VP"&&r.initHandEvent(),r):(console.error("获取session失败,请退出重试"),r)}return t.parseArgs=function(e){if(e instanceof t)return e;var r=__assign(__assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return n.parseArgs.call(this,r)},t.initAnimationEndState=function(e){var r=this.parseArgs(e),o=n.initAnimationEndState.call(this,r);return __assign(__assign({},o),{mode:"XRPanorama"})},t.prototype.moveToPano=function(e,r,o){var s=this,u,l,c,f,d=(u=r.effect)!==null&&u!==void 0?u:"fade";this.userAction=o,this.stopMomentumMovement();var p=this.works.getResolvedObserver(e);if(!p)throw new Error("Invalid PanoIndex");var v=getImageSizeFromURL(p.images.up),g=this.imageOptions.size;typeof g=="undefined"&&p&&v&&(g=Number(v)),typeof g=="undefined"&&(g=2048);var h=this.imageOptions.transform,m=function(w,C){return mapPanoResource(applyImageURLOptions(w,h,C))},y=__assign({key:"pano.".concat(p.panoId)},pick(this.imageOptions,["format","size","quality"])),A=p.images,E=(c=(l=p.images.tiles)===null||l===void 0?void 0:l.filter(function(w){return w.size>g}))!==null&&c!==void 0?c:null,b="pano:"+jsonHash([A,y,h]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===b)return;var T=this.pendingTextureTask.panoId;(f=this.panoMeshes[T])===null||f===void 0||f.setProgress(0),this.emit("pano.texture.abort",createEvent("pano.texture.abort",{error:null,progress:0,meta:null,pano:p.pano}))}var _=this.models.getMaterial()||{},R=_.pano0,S=_.pano1,M;if((R==null?void 0:R.map.name)===b?M=R:(S==null?void 0:S.map.name)===b&&(M=S),M){var B={panoId:p.panoId,effect:d,leftPanoPicture:{zoom:1,map:M.map,luminanceMap:M.luminanceMap,matrix:new THREE__namespace.Matrix4().compose(p.position,p.quaternion,PANO_TEXTURE_SCALE)},position:p.position.clone(),fixCameraTransform:new THREE__namespace.Matrix4};this.doMoveToPano(p.pano,B,r);return}var H="move-to-pano-"+p.panoId;this.pending.add(H),this.pendingTextureTask={panoId:p.panoId,hash:b,onLoad:function(w){if(s.pending.delete(H),s.destroyed)w.body.dispose();else{w.body.name=b;var C={panoId:p.panoId,effect:d,leftPanoPicture:{zoom:1,map:w.body,luminanceMap:null,matrix:new THREE__namespace.Matrix4().compose(p.position,p.quaternion,PANO_TEXTURE_SCALE)},position:p.position.clone(),fixCameraTransform:new THREE__namespace.Matrix4};s.doMoveToPano(p.pano,C,r)}},onError:function(w){s.pending.delete(H);var C=__assign(__assign(__assign({},p.pano),{mode:s.mode}),clonePose(s.camera.pose));s.emit("pano.error",createEvent("pano.error",{error:w,userAction:s.userAction,options:r,prevPano:s.currentPano,progress:0,state:C})),s.emit("pano.cancel",createEvent("pano.cancel",{error:null,userAction:s.userAction,options:r,prevPano:s.currentPano,progress:0,state:C})),r.moveCancelCallback&&r.moveCancelCallback()}},Promise.all([this.tileLevelForFov&&E&&E.length?this.textureLoader.loadTiledCubeTexture(A,E,{tileMaxLevel:this.TILED_CUBE_TEXTURE_LEVEL,imageURL:{transform:m,options:y},format:THREE__namespace.RGBAFormat,minFilter:THREE__namespace.LinearFilter,magFilter:THREE__namespace.LinearFilter,generateMipmaps:!1,viaAjax:!0,fetcher:getFetcher(p.work)},void 0,void 0,function(w){var C,F;s.emit("pano.texture.progress",createEvent("pano.texture.progress",{error:null,progress:w,meta:null,pano:p.pano})),((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&((F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(w))},this.renderer):this.textureLoader.loadCubeTexture(A,{imageURL:{transform:m,options:y},format:THREE__namespace.RGBAFormat,fetcher:getFetcher(p.work)},void 0,void 0,function(w){var C,F;((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&((F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(w)),s.emit("pano.texture.progress",createEvent("pano.texture.progress",{error:null,progress:w,meta:null,pano:p.pano}))},this.renderer)]).then(function(w){var C,F,I=w[0];((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b?(s.pendingTextureTask.onLoad(I),(F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(0),delete s.pendingTextureTask,s.emit("pano.texture.success",createEvent("pano.texture.success",{error:null,progress:1,meta:I.meta,pano:p.pano}))):I.body.dispose()}).catch(function(w){var C,F;((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&(s.pendingTextureTask.onError(w),(F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(0),delete s.pendingTextureTask,s.emit("pano.texture.error",createEvent("pano.texture.error",{error:w,progress:0,meta:null,pano:p.pano})),s.emit("error",w))}),this.emit("pano.texture.load",createEvent("pano.texture.load",{error:null,progress:0,meta:null,pano:p.pano}))},t.prototype.doMoveToPano=function(e,r,o){var s=this,u,l,c,f,d,p,v,g,h,m;o===void 0&&(o={});var y=now(),A=createUuid();this.panoResources[A]=r;var E=1,b,T,_;if(this.locationMotion.ended){var R=this.locationMotion.getKeyFrameSegment(y);R[0];var S=R[1],M=this.locationMotion.value,B=this.panoResourceFromLocationMotionKeyframe(S).position,H=r.position;b=Math.max(B.distanceTo(H),E),T=[{key:S.key,progress:0,value:__assign(__assign({},M),{count:0})},{key:A,progress:1,value:{distance:0,count:1}}],_=0}else{var w=this.locationMotion.getKeyFrameSegment(y),C=w[0],S=w[1],M=this.locationMotion.value,F=this.panoResourceFromLocationMotionKeyframe(C).position,B=this.panoResourceFromLocationMotionKeyframe(S).position,H=r.position,I=S.value.count-M.count,L=Math.max(F.distanceTo(B),E)*I,k=Math.max(B.distanceTo(H),E);b=L+k,T=[{key:C.key,progress:0,value:__assign({},M)},{key:S.key,progress:L/b,value:S.value},{key:A,progress:1,value:{count:S.value.count+1,distance:0}}];var N=this.locationMotionKeyframesLength(this.locationMotion.keyframes),D=this.locationMotionKeyframesLength(T);_=this.locationMotion.getProgressVelocity(y)*N/D}var U=r.effect==="instant"?0:this.calculateMovingDuration(o.duration,r.effect==="fly"?b:0),z={longitude:o.longitude,latitude:o.latitude,fov:o.fov},q=__assign(__assign({},e),{mode:this.mode,longitude:(u=z.longitude)!==null&&u!==void 0?u:this.camera.pose.longitude,latitude:(l=z.latitude)!==null&&l!==void 0?l:this.camera.pose.latitude,fov:(c=z.fov)!==null&&c!==void 0?c:this.camera.pose.fov,offset:r.position.clone(),distance:0}),G=this.currentPano;if(this.emit("pano.moveTo",createEvent("pano.moveTo",{options:o,prevPano:G,progress:0,state:q,userAction:this.userAction,error:null})),o.moveStartCallback&&o.moveStartCallback(q),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute("src")&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute("uuid"),this.videoTexture.image.removeAttribute("src"),this.videoTexture.image.oncanplay=noop$1,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),r.effect==="fly")this.cameraMotion.set(z,U).catch(noop$1);else{var J=coordinatesToVector({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),X=coordinatesToVector({longitude:(f=z.longitude)!==null&&f!==void 0?f:this.cameraMotion.value.longitude,latitude:(d=z.latitude)!==null&&d!==void 0?d:this.cameraMotion.value.latitude}),j=new THREE__namespace.Object3D;j.lookAt(J);var Y=new THREE__namespace.Matrix4().makeRotationFromQuaternion(j.quaternion);j.lookAt(X);var Z=new THREE__namespace.Matrix4().makeRotationFromQuaternion(j.quaternion),W=new THREE__namespace.Matrix4().getInverse(Y).premultiply(Z),ae=this.cameraMotion.value.fov,re=(p=z.fov)!==null&&p!==void 0?p:this.cameraMotion.value.fov,se=1;r.effect==="zoomin"?se=1.5:r.effect==="zoomout"&&(se=.4);for(var ie=re*se,fe=0;fe<T.length-1;fe++){var ne=T[fe].key;if(ne){var pe=this.panoResources[ne];pe&&(pe.fixCameraTransform.copy(W),pe.leftPanoPicture&&(pe.leftPanoPicture.zoom=Math.tan(ae/2/180*Math.PI)/Math.tan(ie/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:(v=z.longitude)!==null&&v!==void 0?v:this.cameraMotion.value.longitude,latitude:(g=z.latitude)!==null&&g!==void 0?g:this.cameraMotion.value.latitude,fov:ie}},{progress:1,value:{longitude:(h=z.longitude)!==null&&h!==void 0?h:this.cameraMotion.value.longitude,latitude:(m=z.latitude)!==null&&m!==void 0?m:this.cameraMotion.value.latitude,fov:re}}],U).catch(noop$1)}var _e=this.locationMotion.setKeyframes(T,U,_);_e.then(function(){for(var me,xe,$,te=0,Q=s.models;te<Q.length;te++){var be=Q[te];be.show()}var ye=__assign(__assign({},e),{mode:s.mode,longitude:s.camera.pose.longitude,latitude:s.camera.pose.latitude,fov:s.camera.pose.fov,offset:s.camera.pose.offset.clone(),distance:0});s.emit("pano.arrived",createEvent("pano.arrived",{options:o,prevPano:G,progress:1,state:ye,userAction:s.userAction,error:null})),o.moveEndCallback&&o.moveEndCallback(ye);var Ae=s.works.getResolvedObserver(s.currentPano);if(Ae&&Ae.video&&s.videoTexture&&s.videoTexture.image instanceof HTMLVideoElement){var Me=ROTATE_Y_PI_MATRIX.clone().multiply(($=(xe=(me=s.models.getMaterial())===null||me===void 0?void 0:me.pano1)===null||xe===void 0?void 0:xe.matrix)!==null&&$!==void 0?$:new THREE__namespace.Matrix4).multiply(Ae.video.matrix),ge={map:s.videoTexture,size:Ae.video.size,matrix:Me,alpha:1},he=createUuid(),de=s.videoTexture.image;de.setAttribute("uuid",he),canplayVideo().then(function(ce){ce&&Ae.video&&de.getAttribute("uuid")===he&&(de.oncanplay=function(){de.oncanplay=noop$1,de.play()},de.ontimeupdate=function(){de.currentTime>.5&&(de.ontimeupdate=noop$1,s.panoVideo.setMaterial(ge))},de.src=Ae.video.source)}).catch(function(){de.removeAttribute("uuid")})}},function(){s.emit("pano.cancel",createEvent("pano.cancel",{options:o,prevPano:G,progress:0,state:q,userAction:s.userAction,error:null})),o.moveCancelCallback&&o.moveCancelCallback()})},t.prototype.checkSelectedPano=function(e){var r=this,o,s,u,l;this.stopMomentumMovement();var c=this.camera.getDirection(new THREE__namespace.Vector3).setY(0),f=null,d=this.works.getResolvedObserver(this.currentPano);if(!d)return null;var p=d.accessibleIds.filter(function(X){var j=panoParse(X);if(panoEqual(j,r.currentPano))return!1;var Y=r.works.getResolvedObserver(j);return!Y||Y.position.distanceTo(r.camera.position)>r.maxAccessibleDistance?!1:Y.loadable||Y.active}),v=this.models.intersectRaycaster(e)[0];if(v){var g=arrayMin(p,function(X){var j=r.works.getResolvedObserver(X);if(!j)return 1/0;var Y=j.standingPosition.clone();return Y.distanceTo(v.point)},!0),h=g[0],m=g[1];h&&m<this.panoTapTriggerRadius&&(f=(o=this.works.getResolvedObserver(h))!==null&&o!==void 0?o:null)}if(isNil(f)){var y=this.getForwardObserverOrNot(e);y&&(f=y)}for(var A=0,E=this.locationMotion.keyframes;A<E.length;A++){var b=E[A],T=this.panoResourceFromLocationMotionKeyframe(b);if(!(b.progress<this.locationMotion.progress)&&f&&T.panoId===f.panoId){f=null;break}}if(isNil(f))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(f&&!f.active){var _=f.panoId;this.panoMeshes[_]&&(this.panoMeshes[_].setDisabled(!1),this.panoMeshes[_].setLoading(!0))}var R={};if(f){for(var S=Math.PI/6,M=Math.PI/12,B=new THREE__namespace.Vector3(0,1,0),H=f.position.clone().setY(0).sub(d.position.clone().setY(0)).normalize(),w=H.clone().applyAxisAngle(B,S),C=H.clone().applyAxisAngle(B,-S),F=[],I=[],L=[],k=0,N=f.accessibleIds;k<N.length;k++){var h=N[k],D=panoParse(h);if(!(panoEqual(D,this.currentPano)||panoEqual(D,f.pano))){var U=this.works.getResolvedObserver(h);if(U){var z=U.position.clone().sub(f.position).setY(0);H.angleTo(z)<S?L.push(z):w.angleTo(z)<S?F.push(z):C.angleTo(z)<S&&I.push(z)}}}var q=L.length>0?L:__spreadArray(__spreadArray([],F,!0),I,!0),G=q.slice().sort(function(X,j){return X.angleTo(H)-j.angleTo(H)})[0];G&&G.angleTo(c)>M&&(R.longitude=Math.atan2(-G.x,-G.z))}this.cameraMotion.value.latitude<-Math.PI/4&&(R.latitude=clamp$1(0,this.minLatitude,this.maxLatitude)),this.cameraMotion.value.fov<60&&(R.fov=this.defaultFov);var J={workCode:f.pano.workCode,panoIndex:f.pano.panoIndex,mode:this.mode,longitude:(s=R.longitude)!==null&&s!==void 0?s:this.camera.pose.longitude,latitude:(u=R.latitude)!==null&&u!==void 0?u:this.camera.pose.latitude,fov:(l=R.fov)!==null&&l!==void 0?l:this.camera.pose.fov,distance:0,offset:f?f.position.clone():new THREE__namespace.Vector3};return this.emit("pano.select",createEvent("pano.select",{prevPano:this.currentPano,state:J,userAction:!0,options:R,progress:0,error:null})),f&&f.active?(this.emit("pano.request",createEvent("pano.request",{userAction:!0,prevPano:this.currentPano,progress:0,state:J,options:R,error:null})),f.pano):null},t.prototype.destroy=function(){n.prototype.destroy.call(this)},t.prototype.isReady=function(){return!1},t.prototype.updateCamera=function(e,r,o){return Promise.resolve()},t.prototype.updateCameraWithKeyframes=function(e,r,o){return Promise.resolve()},t.prototype.updateTime=function(e,r){for(var o=this,s,u,l,c,f,d,p,v,g=[],h=2;h<arguments.length;h++)g[h-2]=arguments[h];this.userAction=!0;var m={},y={},A=this.panoResourceFromLocationMotionKeyframe(this.locationMotion.keyframes[0]),E=this.panoResourceFromLocationMotionKeyframe(this.locationMotion.keyframes[this.locationMotion.keyframes.length-1]),b=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),y.longitude=this.cameraMotion.value.longitude,y.latitude=this.cameraMotion.value.latitude,y.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),m.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);var T=this.locationMotion.getKeyFrameSegment(e),_=T[0],R=T[1],S=this.panoResourceFromLocationMotionKeyframe(_),M=this.panoResourceFromLocationMotionKeyframe(R),B=new THREE__namespace.Vector3().copy(S.position),H=new THREE__namespace.Vector3().copy(M.position),w=this.locationMotion.value.count-R.value.count+1;m.progress=w,M.leftPanoPicture&&(w<1?S.leftPanoPicture&&(m.pano0=S.leftPanoPicture):m.pano0=M.leftPanoPicture,m.pano1=M.leftPanoPicture),M.effect==="montage"?m.transition="BLACK":M.effect==="spread"?m.transition="SPREAD":m.transition="FADE",(M.effect==="zoomin"||M.effect==="zoomout")&&(m.progress=Math.pow(w,3)),w<1&&M.effect!=="fly"&&(m.pano0&&S.leftPanoPicture&&(m.pano0={map:m.pano0.map,zoom:m.pano0.zoom,luminanceMap:m.pano0.luminanceMap,matrix:S.leftPanoPicture.matrix.clone().setPosition(M.position)}),B.copy(H),b=!0),y.distance=this.locationMotion.value.distance,y.offset=new THREE__namespace.Vector3(B.x+(H.x-B.x)*w,B.y+(H.y-B.y)*w,B.z+(H.z-B.z)*w);for(var C=[],F=[],I=0,L=this.locationMotion.keyframes;I<L.length;I++){var k=L[I],N=k.key,D=k.progress;N!==void 0&&(C.push(N),D>this.locationMotion.progress&&F.push(N))}for(var U=0,z=Object.keys(this.panoResources);U<z.length;U++){var q=z[U];if(!(F.indexOf(q)>=0)){var G=this.panoResources[q];if(G.leftPanoPicture){var J=G.leftPanoPicture.map;if(J){if(J===((s=m.pano0)===null||s===void 0?void 0:s.map)||J===((u=m.pano1)===null||u===void 0?void 0:u.map))continue;J instanceof TileCubeTextureTarget&&J.cubeRenderTarget&&this.colorCubeRenderTargetPool.push(J.cubeRenderTarget),J.dispose(),G.leftPanoPicture=null}}C.indexOf(q)>=0||delete this.panoResources[q]}}this.currentPano=panoParse(M.panoId),this.emit("pano.moving",createEvent("pano.moving",{userAction:this.userAction,prevPano:panoParse(A.panoId),state:__assign(__assign(__assign(__assign({},panoParse(E.panoId)),{mode:this.mode}),clonePose(this.camera.pose)),y),options:{},progress:this.locationMotion.progress,error:null}))}isEmptyObject(m)===!1&&(!((l=m.pano0)===null||l===void 0)&&l.map&&m.pano0.map instanceof TileCubeTextureTarget&&!m.pano0.map.cubeRenderTarget&&(m.pano0.map.cubeRenderTarget=this.colorCubeRenderTargetPool.pop()),!((c=m.pano1)===null||c===void 0)&&c.map&&m.pano1.map instanceof TileCubeTextureTarget&&!m.pano1.map.cubeRenderTarget&&(m.pano1.map.cubeRenderTarget=this.colorCubeRenderTargetPool.pop()),this.models.setMaterial(m)),isEmptyObject(y)===!1&&this.setCamera(y);var X=this.works.getResolvedObserver(this.currentPano),j=g[1];if(!j){console.error("xrFrame丢失,请重试");return}if(!this.xrManager.session){console.error("session丢失,请重试");return}var Y=this.xrManager.referenceSpace;if(Y){var Z=this.xrManager.cameraVR,W=this.xrManager.cameraL,ae=this.xrManager.cameraR,re=[W,ae],se=j.getViewerPose(Y),ie=new THREE__namespace.Vector3(0,0,0);if(se){var fe;fe=this.xrManager.session.renderState.baseLayer;var ne=se.views;if(!fe){console.error("no layer found");return}this.renderer.setFramebuffer(fe.framebuffer);var pe=!1;ne.length!==Z.cameras.length&&(Z.cameras.length=0,pe=!0),this.parallaxCameraMatrixs=[];var _e=new THREE__namespace.Vector3,me=new THREE__namespace.Vector3;new THREE__namespace.Matrix4().fromArray(ne[0].transform.matrix).decompose(_e,new THREE__namespace.Quaternion,new THREE__namespace.Vector3),new THREE__namespace.Matrix4().fromArray(ne[1].transform.matrix).decompose(me,new THREE__namespace.Quaternion,new THREE__namespace.Vector3),me.clone().sub(_e).normalize();var xe=new THREE__namespace.Vector3,$=new THREE__namespace.Quaternion,te=new THREE__namespace.Vector3;this.camera.matrix.decompose(xe,$,te);for(var Q=0;Q<ne.length;Q++){var be=ne[Q],ye=fe.getViewport(be),Ae=re[Q];Ae.matrix.fromArray(be.transform.matrix);var Me=new THREE__namespace.Vector3,ge=new THREE__namespace.Quaternion,he=new THREE__namespace.Vector3;Ae.matrix.decompose(Me,ge,he),ie.copy(xe),Ae.position.copy(xe),Ae.quaternion.copy(ge),Ae.scale.copy(he),Ae.updateMatrix(),Ae.projectionMatrix.fromArray(be.projectionMatrix),Ae.viewport.set(ye.x,ye.y,ye.width,ye.height),pe===!0&&Z.cameras.push(Ae)}if(this.xrManager.session&&this.xrManager.session.inputSources){for(var Q=0;Q<this.xrManager.session.inputSources.length;Q++)if(this.xrManager.session.inputSources[Q]&&this.xrManager.session.inputSources[Q].targetRayMode==="transient-pointer"){var de=j.getPose(this.xrManager.session.inputSources[Q].targetRaySpace,Y);if(de){var ce=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(de.transform.orientation),le=new THREE__namespace.Raycaster(this.camera.position,ce);this.gazeRay=le}}}if(this.xrManager.machineType==="Oculus"||this.xrManager.machineType==="Pico"){for(var we=this.xrManager.session.inputSources,Q=0;Q<we.length;Q++){var ue=this.xrManager.controllers[Q],ve=we[Q];if(ve){ue&&ue.update(ve,j,Y);var le=this.xrManager.getController(Q),qe=new THREE__namespace.Vector3(0,1.2,0),Ee=le.position.clone().add(ie).sub(qe);ve.handedness==="left"?this.xrControllerRay.left.set(Ee,new THREE__namespace.Vector3(0,0,-1).applyEuler(le.rotation)):ve.handedness==="right"&&this.xrControllerRay.right.set(Ee,new THREE__namespace.Vector3(0,0,-1).applyEuler(le.rotation)),this.controllerWrappers[Q].position.copy(new THREE__namespace.Vector3(0,0,0).add(ie).sub(qe));var Ie=this.models.intersectRaycaster(this.xrControllerRay.right);if(Ie.length===0&&(Ie=this.xrControllerRay.right.intersectObject(this.boundingMesh,!0).map(function(vt){var At;return __assign({floor:(At=X==null?void 0:X.floorIndex)!==null&&At!==void 0?At:0},vt)})),Ie.length>=1&&Ie[0].face)if(ve.handedness==="right"){var Oe=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),$e=Ie[0].face.normal,pt=$e.clone(),tt=Ie[0].point.clone();this.intersectMesh.position.copy(tt);var Ne=tt.clone().add(pt);if(this.intersectMesh.lookAt(Ne),Math.abs($e.y)>.99){var Ge=this.camera.position.clone().sub(tt);this.intersectMesh.rotation.z=-Math.atan2(Ge.z,Ge.x)}this.intersectMesh.visible=!0,this.needsRender=!0,Oe.length>0?(this.pointerLines.right.setPoints(Ee,Oe[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(Ee,Ie[0].point));var Ve=Ie[0],Ke=createEvent("intersect.update",{raycaster:(f=this.xrControllerRay.right)!==null&&f!==void 0?f:null,intersection:Ve!=null?Ve:null,object:this.intersectMesh});if(this.emit("intersect.update",Ke),Ke.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(Ee,Ie[0].point)}}this.updateControllerHelper(we,e,r)}if(this.camera.pose.distance>.1||b)for(var Je=0,Xe=Object.keys(this.panoMeshes);Je<Xe.length;Je++){var Pe=Xe[Je],Se=this.panoMeshes[Pe];Se.setOpacity(0),Se.setCurrent(!1),Se.updateTime&&Se.updateTime(e,r),Se.visible=!1}else if(X){var Be=arrayMin(X.visibleIds,function(je){var at=o.works.getResolvedObserver(je);return at?X.standingPosition.distanceTo(at.standingPosition):1/0},!0),De=Be[1];De=clamp$1(De,2.5,1/0);for(var He=X.visibleIds.concat(panoStringify(this.currentPano)),Ue=this.getForwardObserverOrNot(),Ye=this.camera.getDirection(new THREE__namespace.Vector3),ze=0,rt=Object.keys(this.panoMeshes);ze<rt.length;ze++){var Pe=rt[ze],Se=this.panoMeshes[Pe],ot=this.works.getResolvedObserver(Pe);if(He.indexOf(Pe)===-1)Se.setCurrent(!1),Se.setOpacity(0);else if(!ot)Se.setCurrent(!1),Se.setOpacity(0);else if(!ot.loadable&&!ot.active)Se.setCurrent(!1),Se.setOpacity(0);else{var ht=Se.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);Se.setCurrent(!Se.loading&&Se.progress===0&&Ue!==null&&Ue.panoId===Pe),Se.setOpacity(ht<.01?0:clamp$1(De/ht*1.2,.65,.98));var st=this.camera.position.clone().setY(Se.position.y),ce=new THREE__namespace.Vector3().copy(Se.position).sub(st).normalize();if(Pe===panoStringify(this.currentPano)){var ct=clamp$1((.5-st.distanceTo(Se.position))/.5,0,1);ce.multiplyScalar(1-ct).add(Ye.clone().multiplyScalar(ct))}ce.length()>0&&Se.quaternion.setFromEuler(new THREE__namespace.Euler(0,Math.atan2(ce.x,ce.z),0))}Se.updateTime&&Se.updateTime(e,r)}}var We=function(){return 4}(),Ce=function(){var je=new THREE__namespace.PerspectiveCamera;je.applyMatrix4(Z.matrix),je.position.set(0,0,0);var at=o.works.getResolvedObserver(E.panoId),vt=at!=null?at:X;vt&&je.quaternion.premultiply(vt.quaternion.clone().inverse()),je.updateProjectionMatrix(),je.updateMatrixWorld(!0);var At=new THREE__namespace.Frustum().setFromProjectionMatrix(new THREE__namespace.Matrix4().multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse));return At}();E.panoId===panoStringify(this.currentPano)&&((d=E.leftPanoPicture)===null||d===void 0?void 0:d.map)instanceof TileCubeTextureTarget&&(E.leftPanoPicture.map.maxRequest=this.tileMaxRequest,E.leftPanoPicture.map.update(Ce,We),E.leftPanoPicture.map.needsRender===!0&&(this.needsRender=!0,this.modelSceneNeedsRender=!0));{var Re=this.tiling.object.visible;if(this.initAnimationed){var Le=E.panoId,Qe=this.works.getResolvedObserver(Le);Qe?isSimilarVector3(this.camera.position,Qe.position)&&this.locationMotion.ended?(this.tiling.object.visible=!0,this.tiling.panoId!==Le&&this.tiling.cleanup(),this.tiling.panoId=Le,this.tiling.setResource((v=(p=Qe.images)===null||p===void 0?void 0:p.tiles)!==null&&v!==void 0?v:[],this.enableIOSEDR&&Qe.images.luminance?Qe.images.luminance:null),this.tiling.setFetcher(getFetcher(Qe.work)),this.tiling.setRotation(Qe.quaternion),this.tiling.setPosition(Qe.position),this.tiling.maxRequest=this.tileMaxRequest,We>this.TILED_CUBE_TEXTURE_LEVEL?this.tiling.update(Ce,We,e):this.tiling.update(Ce,0,e)):this.tiling.object.visible=!1:this.tiling.object.visible=!1}else this.tiling.object.visible=!1;Re!==this.tiling.object.visible&&(this.tiling.object.needsRender=!0,this.modelSceneNeedsRender=!0)}this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e)}}},t.prototype.render=function(){var e=this.xrManager.getCamera(this.camera);this.renderer.render(this.modelScene,e),this.renderer.autoClearColor=!1,this.renderer.autoClearDepth=!1,this.renderer.render(this.scene,e),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0},t.prototype.onPanGesture=function(){},t.prototype.onTapGesture=function(){},t.prototype.onPinchGesture=function(){},t.prototype.onMouseMove=function(){},t.prototype.onMouseOut=function(){},t.prototype.panoResourceFromLocationMotionKeyframe=function(e){return this.panoResources[e.key]},t.prototype.updateControllerHelper=function(e,r,o){var s=this.xrControllerRay.left,u=this.xrControllerRay.right;if(!(!e||e.length===0)){for(var l={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}},c=0;c<e.length;c++){var f=e[c].handedness,d=e[c].gamepad;switch(f){case"left":d.axes&&(this.emitHandleEvent(d.axes[2]===-1,"LeftAxesLeft",r),this.emitHandleEvent(d.axes[2]===1,"LeftAxesRight",r),this.emitHandleEvent(d.axes[3]===-1,"LeftAxesUp",r),this.emitHandleEvent(d.axes[3]===1,"LeftAxesDown",r)),d!=null&&d.buttons&&(d.buttons[4]&&this.emitHandleEvent(d.buttons[4].pressed,"X",r),d.buttons[5]&&this.emitHandleEvent(d.buttons[5].pressed,"Y",r),d.buttons[0]&&this.emitHandleEvent(d.buttons[0].pressed,"LeftTrigger",r),d.buttons[1]&&this.emitHandleEvent(d.buttons[1].pressed,"LeftPinch",r));var p={raycaster:s,axes:{up:d.axes&&d.axes[3]<0?Math.abs(d.axes[3]):0,down:d.axes&&d.axes[3]<0?0:Math.abs(d.axes[3]),left:d.axes&&d.axes[2]<0?Math.abs(d.axes[2]):0,right:d.axes&&d.axes[2]<0?0:Math.abs(d.axes[2])},deltaTime:o};l.buttons.X=d.buttons&&d.buttons[4]?d.buttons[4].pressed:!1,l.buttons.Y=d.buttons&&d.buttons[5]?d==null?void 0:d.buttons[5].pressed:!1,l.buttons.LeftTrigger=d.buttons&&d.buttons[0]?d==null?void 0:d.buttons[0].pressed:!1,l.buttons.LeftPinch=d.buttons&&d.buttons[1]?d==null?void 0:d.buttons[1].pressed:!1,l.left=p;break;case"right":d.axes&&(this.emitHandleEvent(d.axes[2]===-1,"RightAxesLeft",r),this.emitHandleEvent(d.axes[2]===1,"RightAxesRight",r),this.emitHandleEvent(d.axes[3]===-1,"RightAxesUp",r),this.emitHandleEvent(d.axes[3]===1,"RightAxesDown",r)),d.buttons&&(d.buttons[4]&&this.emitHandleEvent(d.buttons[4].pressed,"A",r),d.buttons[5]&&this.emitHandleEvent(d.buttons[5].pressed,"B",r),d.buttons[0]&&this.emitHandleEvent(d.buttons[0].pressed,"RightTrigger",r),d.buttons[1]&&this.emitHandleEvent(d.buttons[1].pressed,"RightPinch",r));var v={raycaster:u,axes:{up:d.axes&&d.axes[3]<0?Math.abs(d.axes[3]):0,down:d.axes&&d.axes[3]<0?0:Math.abs(d.axes[3]),left:d.axes&&d.axes[2]<0?Math.abs(d.axes[2]):0,right:d.axes&&d.axes[2]<0?0:Math.abs(d.axes[2])},deltaTime:o};l.right=v,l.buttons.A=d.buttons&&d.buttons[4]?d==null?void 0:d.buttons[4].pressed:!1,l.buttons.B=d.buttons&&d.buttons[5]?d==null?void 0:d.buttons[5].pressed:!1,l.buttons.RightTrigger=d.buttons&&d.buttons[0]?d==null?void 0:d.buttons[0].pressed:!1,l.buttons.RightPinch=d.buttons&&d.buttons[1]?d==null?void 0:d.buttons[1].pressed:!1;break}}this.emit("xr.controller.update",createEvent("xr.controller.update",l))}},t.prototype.emitHandleEvent=function(e,r,o){var s=this.xrControllerRay.left,u=this.xrControllerRay.right;if(e)if(this.xrHandleState[r].touchStart===!1)this.xrHandleState[r].touchStartTime=o,this.xrHandleState[r].touchStart=!0,this.emit("xr.gesture.buttonDown",createEvent("xr.gesture.buttonDown",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:s,rightRay:u}}}));else{var l=o-this.xrHandleState[r].touchStartTime;l>CONTROLLER_EVNET_DELTA_TIME&&this.emit("xr.gesture.press",createEvent("xr.gesture.tap",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:s,rightRay:u}}}))}else if(this.xrHandleState[r].touchStart===!0){this.emit("xr.gesture.buttonUp",createEvent("xr.gesture.buttonUp",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:s,rightRay:u}}}));var l=o-this.xrHandleState[r].touchStartTime;if(l<=CONTROLLER_EVNET_DELTA_TIME){var c=createEvent("xr.gesture.tap",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:s,rightRay:u}}}),f=this.emit("xr.gesture.tap",c);!f&&!c.defaultPrevented&&r==="RightTrigger"&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[r].touchStart=!1,this.xrHandleState[r].touchStartTime=0}},t.prototype.initHandEvent=function(){var e=this;if(!this.xrManager.session)throw new Error("初始化失败");this.xrManager.session.addEventListener("select",function(r){e.gazeRay&&e.checkSelectedPano(e.gazeRay)})},t}(PanoramaController),Controllers={Floorplan:FloorplanController,Topview:TopviewController,Panorama:PanoramaController,VRPanorama:VRPanoramaController,Model:ModelController,Mapview:MapviewController,XRPanorama:XRPanoramaController},PROXY_CONTROLLER_EVENT_NAMES=["gesture.pan","gesture.tap","gesture.dbltap","gesture.press","gesture.pinch","gesture.mousewheel","gesture.mousemove","gesture.momentum","initAnimation.start","initAnimation.end","camera.update","intersect.update","pano.select","pano.moveTo","pano.moving","pano.arrived","pano.cancel","pano.error","pano.texture.load","pano.texture.progress","pano.texture.success","pano.texture.error","pano.texture.abort","xr.session.start","xr.session.end","xr.gesture.tap","xr.gesture.press","xr.gesture.buttonUp","xr.gesture.buttonDown","xr.controller.update"];function initLegacyEvent(n){n.on("initAnimation.start",function(t){n.emit("initAnimationWillStart",t.state.panoIndex,t.state,t.userAction)}),n.on("initAnimation.end",function(t){n.emit("initAnimationEnded",t.state.panoIndex,t.state,t.userAction)}),n.on("gesture.pan",function(t){var e=!1;e=n.emit("wantsGesture","pan",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPanGesture",t.state,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","pan",t.pointers,t.isFinal),n.emit("panGesture",t.state,t.isFinal))}),n.on("gesture.tap",function(t){var e=!1;e=n.emit("wantsGesture","tap",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsTapGesture",t.center.raycaster,t.center.coords,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","tap",t.pointers,t.isFinal),n.emit("tapGesture",t.center.raycaster,t.center.coords,t.isFinal))}),n.on("gesture.dbltap",function(t){var e=!1;e=n.emit("wantsGesture","dbltap",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsDblTapGesture",t.center.raycaster,t.center.coords,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","dbltap",t.pointers,t.isFinal),n.emit("dblTapGesture",t.center.raycaster,t.center.coords,t.isFinal))}),n.on("gesture.press",function(t){var e=!1;e=n.emit("wantsGesture","press",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPressGesture",t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","press",t.pointers,t.isFinal),n.emit("pressGesture",t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),n.on("gesture.pinch",function(t){var e=!1;e=n.emit("wantsGesture","pinch",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPinchGesture",t.scale,t.state.fov,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","pinch",t.pointers,t.isFinal),n.emit("pinchGesture",t.scale,t.state.fov,t.isFinal))}),n.on("gesture.mousewheel",function(t){var e=!1;e=n.emit("wantsGesture","mouseWheel",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsMouseWheel",t.center.delta,t.state.fov,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","mouseWheel",t.pointers,t.isFinal),n.emit("mouseWheel",t.center.delta,t.state.fov,t.isFinal))}),n.on("gesture.mousemove",function(t){var e=!1;e=n.emit("wantsGesture","mouseMove",t.pointers,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","mouseMove",t.pointers,t.isFinal),e=n.emit("wantsChangeCameraFov",t.state.fov),e&&t.preventDefault())}),n.on("gesture.momentum",function(t){var e=!1;e=n.emit("wantsInteriaPan",t.state),e&&t.preventDefault(),t.defaultPrevented||n.emit("interiaPan",t.state,t.isFinal)}),n.on("camera.update",function(t){n.emit("cameraFovUpdate",t.state.fov,t.userAction),n.emit("cameraDirectionUpdate",t.state,t.userAction);var e=coordinatesToVector(t.state);e.setLength(t.state.distance);var r=t.state.offset.clone().sub(e);n.emit("cameraPositionUpdate",r,t.userAction),n.emit("cameraUpdate",t.state,t.userAction)}),n.on("intersect.update",function(t){if(t.intersection){var e=!1;e=n.emit("wantsShowIntersectionOnModel",t.raycaster),e&&t.preventDefault(),t.defaultPrevented||n.emit("intersectionOnModelUpdate",t.intersection,t.object)}else n.emit("intersectionHidden")}),n.on("pano.request",function(t){var e=n.emit("wantsMoveToPano",t.state.panoIndex,t.options,t.userAction);e||(e=n.emit("wantsToMoveToPano",t.state.panoIndex,t.options,t.userAction)),e&&t.preventDefault(),t.defaultPrevented||n.emit("panoWillLoad",t.state.panoIndex)}),n.on("pano.select",function(t){n.emit("panoSelected",t.state.panoIndex)}),n.on("pano.moveTo",function(t){n.emit("panoLoaded",t.state.panoIndex),n.emit("moveToPano",t.state.panoIndex,t.userAction),n.emit("panoWillArrive",t.state.panoIndex,t.state,t.userAction)}),n.on("pano.moving",function(t){n.emit("movingToPano",t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),n.on("pano.arrived",function(t){n.emit("panoArrived",t.state.panoIndex,t.state,t.userAction)}),n.on("pano.cancel",function(t){n.emit("moveToPanoCanceled",t.state.panoIndex)}),n.on("pano.error",function(t){n.emit("panoLoadError",t.error,t.state.panoIndex)}),n.on("pano.texture.load",function(t){n.emit("textureStartLoad",t.pano.panoIndex)}),n.on("pano.texture.success",function(t){n.emit("textureLoaded",t.pano.panoIndex,t.meta)}),n.on("pano.texture.error",function(t){n.emit("textureError",t.error,t.pano.panoIndex)}),n.on("pano.texture.abort",function(t){n.emit("textureAbort",t.pano.panoIndex)}),n.on("pano.texture.progress",function(t){n.emit("textureLoading",t.progress,t.pano.panoIndex)}),n.on("xr.session.start",function(t){n.emit("webXRSessionStart")}),n.on("xr.session.end",function(t){n.emit("webXRSessionEnd")}),n.on("xr.gesture.tap",function(t){n.emit("webXRControllerEvent","tap",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.press",function(t){n.emit("webXRControllerEvent","press",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.buttonUp",function(t){n.emit("webXRControllerEvent","buttonUp",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.buttonDown",function(t){n.emit("webXRControllerEvent","buttonDown",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.controller.update",function(t){n.emit("webXRControllerRayUpdate",{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&n.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&&n.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})}),n.on("works.request",function(t){n.emit("willLoad",t.input,t.works[0],t.state)}),n.on("works.load",function(t){n.emit("load",t.input,t.works[0],t.state)}),n.on("works.ready",function(t){n.emit("loaded",t.input,t.works[0])}),n.on("state.change",function(t){n.emit("stateChange",t.state,t.userAction)}),n.on("currentState.change",function(t){n.emit("currentStateChange",t.state,t.userAction)}),n.on("state.set",function(t){n.emit("setState",t.state)}),n.on("state.synced",function(t){n.emit("stateSynced",t.state)}),n.on("model.request",function(t){n.emit("modelWillLoad",t.work.model)}),n.on("model.error",function(t){n.emit("modelLoadError",t.error,t.model)}),n.on("model.load",function(t){n.emit("modelLoaded",t.model)}),n.on("model.changeShownFloor",function(t){n.emit("modelShownFloorChange",t.model.shownFloor,t.model.floorLength)}),n.on("render",function(t){n.emit("renderFrame",t.needsRender)}),n.on("mode.change.request",function(t){n.emit("wantsChangeMode",t.mode,t.prevMode)}),n.on("mode.change",function(t){n.emit("modeChange",t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),n.on("helpers.visible",function(t){n.emit("helpersVisibleChange",t.object.visible)}),n.on("network.resource",function(t){n.emit("network",t.source,t.requestType,t.requestState,t.detail)})}function generateDefaultVideoElement(){if(typeof window!="undefined"){var n=document.createElement("video");n.loop=!0,n.autoplay=!0,n.playsInline=!0,n.muted=!0,n.crossOrigin="";var t=function(){document.removeEventListener("touchstart",t,!1),document.removeEventListener("mousedown",t,!1),n.muted=!1};return document.addEventListener("touchstart",t,!1),document.addEventListener("mousedown",t,!1),n}else return{}}function initLights(n){var t=new THREE__namespace.Group;t.name="internalLights";{var e=new THREE__namespace.DirectionalLight(16777215,.3);e.position.copy(new THREE__namespace.Vector3(1,1,1)),t.add(e)}{var e=new THREE__namespace.DirectionalLight(16777215,.1);e.position.copy(new THREE__namespace.Vector3(-1,-1,-1)),t.add(e)}{var e=new THREE__namespace.DirectionalLight(16777215,.1);t.add(e)}{var e=new THREE__namespace.AmbientLight(16777215,.6);t.add(e)}n.add(t)}function parseKeyValue(n){for(var t,e,r={},o=n.split(/(\;|\,)/),s=0,u=o;s<u.length;s++){var l=u[s],c=l.split("="),f=(t=c[0])===null||t===void 0?void 0:t.trim(),d=(e=c[1])===null||e===void 0?void 0:e.trim();f&&d&&(r[f]=d)}return r}function getViewportScale(){var n;if(typeof document!="undefined")for(var t=document.getElementsByTagName("meta"),e=0;e<t.length;e++){var r=t[e];if(r.getAttribute("name")==="viewport"){var o=parseKeyValue((n=r.getAttribute("content"))!==null&&n!==void 0?n:""),s=Number(o["initial-scale"]);if(!isNaN(s))return s}}return 1}const textureURL="data:image/png;base64,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";var imageSize=[351,63],imageOffset=[20,20],vertices=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),uvs=new Float32Array([0,0,1,0,0,1,1,1]),index=new Uint8Array([0,1,2,1,3,2]),geometry=new THREE__namespace.BufferGeometry;geometry.setAttribute("position",new THREE__namespace.BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE__namespace.BufferAttribute(uvs,2)),geometry.setIndex(new THREE__namespace.BufferAttribute(index,1));var material=new THREE__namespace.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),mesh=new THREE__namespace.Mesh(geometry,material);mesh.matrixAutoUpdate=!1;var scene=new THREE__namespace.Scene;scene.add(mesh),scene.matrixAutoUpdate=!1;var camera=new THREE__namespace.OrthographicCamera(-.5,.5,.5,-.5,.1,1);camera.position.set(0,0,.5),camera.lookAt(0,0,0),camera.updateMatrixWorld(!0),camera.matrixAutoUpdate=!1;var prevViewport=new THREE__namespace.Vector4,prevScissor=new THREE__namespace.Vector4;function renderPoweredByRealsee(n){if(material.map){var r=n.getViewport(prevViewport),o=n.getScissor(prevScissor),s=n.getScissorTest(),u=n.autoClear,l=o.x+imageOffset[0]/3,c=o.y+imageOffset[1]/3,f=imageSize[0]/3,d=imageSize[1]/3;n.setViewport(l,c,f,d),n.setScissor(l,c,f,d),n.setScissorTest(!0),n.autoClear=!1,n.render(scene,camera),n.setViewport(r),n.setScissor(o),n.setScissorTest(s),n.autoClear=u}else{var t=new THREE__namespace.Texture,e=new Image;e.onload=function(){t.image=e,t.wrapS=THREE__namespace.ClampToEdgeWrapping,t.wrapT=THREE__namespace.ClampToEdgeWrapping,t.minFilter=THREE__namespace.LinearFilter,t.needsUpdate=!0,t.generateMipmaps=!1,material.needsUpdate=!0,e.onload=noop$1},e.src=textureURL,material.map=t}}var DEFAULT_MODE_CHANGE_DURATION=800,DEFAULT_CAMERA_FOV=90,DEFAULT_REQUEST_PROXY=function(n){return n.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/")},sharedVector2=new THREE__namespace.Vector2,sharedSphere=new THREE__namespace.Sphere,sharedFrustum=new THREE__namespace.Frustum,sharedProjScreenMatrix=new THREE__namespace.Matrix4,clockForMixer=new WeakMap,worksMap=new WeakMap,emptyWorks=createWorks([]),Five=function(n){__extends(t,n);function t(e){e===void 0&&(e={});var r,o,s,u,l,c,f,d,p,v,g,h=n.call(this)||this;if(h.ident=createUuid(),typeof window!="undefined"&&(__FIVE_DEBUG__.instances[h.ident]=h),h.renderSwitch01=0,h.currentMode="Panorama",h.pano={workCode:"",panoIndex:0},h.needsRender=!1,h.modelSceneNeedsRender=!1,h.onlyRenderIfNeeds=(r=e.onlyRenderIfNeeds)!==null&&r!==void 0?r:!0,h.imageOptions=__assign({},(o=e.imageOptions)!==null&&o!==void 0?o:{}),h.textureOptions=__assign({},(s=e.textureOptions)!==null&&s!==void 0?s:{}),h.poweredByRealsee=(u=e.poweredByRealsee)!==null&&u!==void 0?u:!0,h.extraElements=[],h.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)},h.fps={testCount:0,testTime:now()},h.info=null,h.modeChangeDuration=(l=e.modeChangeDuration)!==null&&l!==void 0?l:DEFAULT_MODE_CHANGE_DURATION,h.enableWheel=(c=e.enableWheel)!==null&&c!==void 0?c:!0,typeof window!="undefined")if("renderer"in e)e.renderer instanceof InternalWebGLRenderer&&h.throwError(new Error("cannot render a internal renderer")),h.renderer=e.renderer;else try{h.renderer=new InternalWebGLRenderer({preserveDrawingBuffer:e.preserveDrawingBuffer,backgroundColor:e.backgroundColor,backgroundAlpha:e.backgroundAlpha,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});var m=getViewportScale();h.renderer.setPixelRatio(m===1?window.devicePixelRatio:1),h.renderer.setSize(512,512)}catch(H){H instanceof Error&&h.throwError(H)}h.getPixelsRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{encoding:(d=(f=h.renderer)===null||f===void 0?void 0:f.outputEncoding)!==null&&d!==void 0?d:THREE__namespace.sRGBEncoding,generateMipmaps:!1});var y=new THREE__namespace.DepthTexture(1,1);y.generateMipmaps=!1,y.format=THREE__namespace.DepthStencilFormat,y.type=THREE__namespace.UnsignedInt248Type,h.modelRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{encoding:(v=(p=h.renderer)===null||p===void 0?void 0:p.outputEncoding)!==null&&v!==void 0?v:THREE__namespace.sRGBEncoding,depthTexture:y,generateMipmaps:!1,depthBuffer:!0,stencilBuffer:!0}),h.scissor=Object.assign({left:0,bottom:0,width:1,height:1},e.scissor),h.camera=new Camera(DEFAULT_CAMERA_FOV),h.scene=new Scene,h.xrCustomObjectsScene=new THREE__namespace.Scene,h.scene.add(h.xrCustomObjectsScene),h.scene.matrixAutoUpdate=!1,h.lastLoadWorkTask=Promise.resolve(),h.requestProxy=(g=e.requestProxy)!==null&&g!==void 0?g:DEFAULT_REQUEST_PROXY,h.networkSubscribe=new NetworkSubscribe,h.networkSubscribe.on("network",function(H,w,C,F){var I;h.emit("network.resource",createEvent("network.resource",{source:H,requestType:w,requestState:C,detail:F})),(I=h.analysis)===null||I===void 0||I.network(h.works,H,w,C,F)}),h.boundingMesh=generateBoundingMesh(new THREE__namespace.Box3(new THREE__namespace.Vector3(-.5,-.5,-.5),new THREE__namespace.Vector3(.5,.5,.5))),h.boundingMesh.name="bounding",h.models=createModels(),h.models.push(new Model),h.lastModels=createModels(),h.lastWorks=createWorks([]),h.readyCallbacks=[],h.syncingState=!1,h.helperGroup=new THREE__namespace.Group,h.helperGroup.name="helper",h.helperGroup.matrixAutoUpdate=!1,h.scene.add(h.helperGroup),h.modelGroup=new THREE__namespace.Group,h.modelGroup.visible=!1,h.modelGroup.name="model",h.modelGroup.matrixAutoUpdate=!1,h.modelScene=new THREE__namespace.Scene,h.modelScene.add(h.modelGroup),h.modelScene.add(h.boundingMesh),h.modelScene.matrixAutoUpdate=!1,h.videoTexture=new THREE__namespace.VideoTexture(e.videoInstance||generateDefaultVideoElement()),initLights(h.scene),initLights(h.modelScene),h.state={mode:h.currentMode,workCode:h.pano.workCode,panoIndex:h.pano.panoIndex,longitude:h.camera.pose.longitude,latitude:h.camera.pose.latitude,fov:h.camera.pose.fov,offset:h.camera.pose.offset.clone(),distance:h.camera.pose.distance},h.stateSynced=!1,h._enablePostProcessing=!1,h._enableIOSEDR=!1,h._enableEDL=!1,h._enableHQ=!1,h.destroyed=!1,h.paused=!0,typeof window!="undefined"&&(e.play!==!1&&h.play(),h.stopAnimationLoop=AnimationFrameLoop.shared.add(function(H,w){for(var C=[],F=2;F<arguments.length;F++)C[F-2]=arguments[F];h.updateTime.apply(h,__spreadArray([H,w],C,!1))},!1,0,10));var A=function(){typeof document!="undefined"&&document.fullscreenElement===null&&h.currentMode==="VRPanorama"&&h.controller.emit("vr.requestExit",createEvent("vr.requestExit",{}))},E=function(){h.needsRender=!0,h.modelSceneNeedsRender=!0};if(typeof document!="undefined"&&document.addEventListener("fullscreenchange",A,!1),h.renderer&&h.renderer.domElement.addEventListener("webglcontextrestored",E,!1),h.removeEventListeners=function(){typeof document!="undefined"&&document.removeEventListener("fullscreenchange",A,!1),h.renderer&&h.renderer.domElement.removeEventListener("webglcontextrestored",E,!1)},h.plugins={},e.plugins&&e.plugins.length)for(var b=0,T=e.plugins;b<T.length;b++){var _=T[b];if(typeof _=="function")_(h);else if(Array.isArray(_)){var R=_[0],S=_[1],M=_[2];if(typeof R=="function"){var B=R(h,M);typeof S=="string"&&(h.plugins[S]?h.throwError(new Error("plugin name ".concat(S," is exists."))):h.plugins[S]=B)}}}return h.gpuPickingRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{generateMipmaps:!1}),h.meshReplaceMaterialMap=new Map,h.meshOriginMaterialMap=new Map,initLegacyEvent(h),h}return Object.defineProperty(t,"version",{get:function(){return"6.4.0-alpha.13"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"dracoPath",{get:function(){return draco.decoderPath},set:function(e){draco.setDecoderPath(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ktx2Path",{get:function(){return ktx2.transcoderPath},set:function(e){ktx2.setTranscoderPath(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"panoIndex",{get:function(){return this.pano.panoIndex},enumerable:!1,configurable:!0}),t.prototype.getGPUPicking=function(e,r,o,s,u){var l=this;if(s===void 0&&(s=1),u===void 0&&(u=new THREE__namespace.Vector3(0,0,0)),!this.renderer)throw new Error("renderer is not initialized.");var c=this.models.getMaterial(),f=c.constantColor,d=c.colorStyle;this.models.setMaterial({colorStyle:"CONSTANT",constantColor:u}),this.scene.traverse(function(h){if(!(!(h instanceof THREE__namespace.Mesh)||h instanceof PBMMesh)){var m=Object.keys(o).filter(function(A){return A===h.uuid})[0];if(m)if(l.meshOriginMaterialMap.set(m,h.material),l.meshReplaceMaterialMap.get(m))h.material=l.meshReplaceMaterialMap.get(m);else{var y=new THREE__namespace.ShaderMaterial({uniforms:{color:{value:o[m]}},vertexShader:`
2169
+ `},LineMaterial=function(n){__extends(t,n);function t(e){var r=n.call(this,{uniforms:THREE__namespace.UniformsUtils.clone(lineShader.uniforms),vertexShader:lineShader.vertexShader,fragmentShader:lineShader.fragmentShader,clipping:!0})||this;return r.type="LineMaterial",r.dashed=!1,Object.defineProperties(r,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(o){this.uniforms.diffuse.value=o}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(o){this.uniforms.linewidth.value=o}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(o){this.uniforms.dashScale.value=o}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(o){this.uniforms.dashSize.value=o}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(o){this.uniforms.gapSize.value=o}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(o){this.uniforms.opacity.value=o}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(o){this.uniforms.resolution.value.copy(o)}}}),r.setValues(e),r}return t}(THREE__namespace.ShaderMaterial);Object.assign(LineMaterial.prototype,{isLineMaterial:!0});var LineSegments2=function(n){__extends(t,n);function t(e,r){var o=n.call(this)||this;return o.type="LineSegments2",o.geometry=e!==void 0?e:new LineSegmentsGeometry,o.material=r!==void 0?r:new LineMaterial({color:Math.random()*16777215}),o}return t.prototype.computeLineDistances=function(){for(var e=this.geometry,r=e.attributes.instanceStart,o=e.attributes.instanceEnd,s=new Float32Array(2*r.count),u=new THREE__namespace.Vector3,l=new THREE__namespace.Vector3,c=0,f=0,d=r.count;c<d;c++,f+=2)u.fromBufferAttribute(r,c),l.fromBufferAttribute(o,c),s[f]=f===0?0:s[f-1],s[f+1]=s[f]+u.distanceTo(l);var p=new THREE__namespace.InstancedInterleavedBuffer(s,2,1);return e.setAttribute("instanceDistanceStart",new THREE__namespace.InterleavedBufferAttribute(p,1,0)),e.setAttribute("instanceDistanceEnd",new THREE__namespace.InterleavedBufferAttribute(p,1,1)),this},t.prototype.raycast=function(e,r){e.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');var o=e.ray,s=e.camera,u=s.projectionMatrix,l=this.geometry,c=this.material,f=c.resolution,d=c.linewidth,p=l.attributes.instanceStart,v=l.attributes.instanceEnd,g=new THREE__namespace.Vector4,h=new THREE__namespace.Vector4,m=new THREE__namespace.Vector4,y=new THREE__namespace.Vector3,A=new THREE__namespace.Matrix4,E=new THREE__namespace.Line3,b=new THREE__namespace.Vector3;o.at(1,m),m.w=1,m.applyMatrix4(s.matrixWorldInverse),m.applyMatrix4(u),m.multiplyScalar(1/m.w),m.x*=f.x/2,m.y*=f.y/2,m.z=0,y.copy(m);var T=this.matrixWorld;A.multiplyMatrices(s.matrixWorldInverse,T);for(var _=0,R=p.count;_<R;_++){g.fromBufferAttribute(p,_),h.fromBufferAttribute(v,_),g.w=1,h.w=1,g.applyMatrix4(A),h.applyMatrix4(A),g.applyMatrix4(u),h.applyMatrix4(u),g.multiplyScalar(1/g.w),h.multiplyScalar(1/h.w);var S=g.z<-1&&h.z<-1,M=g.z>1&&h.z>1;if(!(S||M)){g.x*=f.x/2,g.y*=f.y/2,h.x*=f.x/2,h.y*=f.y/2,E.start.copy(g),E.start.z=0,E.end.copy(h),E.end.z=0;var B=E.closestPointToPointParameter(y,!0);E.at(B,b);var H=THREE__namespace.MathUtils.lerp(g.z,h.z,B),w=H>=-1&&H<=1,C=y.distanceTo(b)<d*.5;if(w&&C){E.start.fromBufferAttribute(p,_),E.end.fromBufferAttribute(v,_),E.start.applyMatrix4(T),E.end.applyMatrix4(T);var F=new THREE__namespace.Vector3,I=new THREE__namespace.Vector3;o.distanceSqToSegment(E.start,E.end,I,F),r.push({point:I,pointOnLine:F,distance:o.origin.distanceTo(I),object:this,faceIndex:_})}}}},t}(THREE__namespace.Mesh);Object.assign(LineSegments2.prototype,{isLineSegments2:!0});var Line2=function(n){__extends(t,n);function t(e,r){var o=n.call(this,e,r)||this;return o.type="Line2",o}return t}(LineSegments2);Object.assign(Line2.prototype,{isLine2:!0});var LineGeometry=function(n){__extends(t,n);function t(){var e=n.call(this)||this;return e.type="LineGeometry",e}return t.prototype.setPositions=function(e){for(var r=e.length-3,o=new Float32Array(2*r),s=0;s<r;s+=3)o[2*s]=e[s],o[2*s+1]=e[s+1],o[2*s+2]=e[s+2],o[2*s+3]=e[s+3],o[2*s+4]=e[s+4],o[2*s+5]=e[s+5];return n.prototype.setPositions.call(this,o),this},t.prototype.setColors=function(e){for(var r=e.length-3,o=new Float32Array(2*r),s=0;s<r;s+=3)o[2*s]=e[s],o[2*s+1]=e[s+1],o[2*s+2]=e[s+2],o[2*s+3]=e[s+3],o[2*s+4]=e[s+4],o[2*s+5]=e[s+5];return n.prototype.setColors.call(this,o),this},t.prototype.fromLine=function(e){var r=e.geometry;if(r instanceof THREE__namespace.Geometry){var o=new THREE__namespace.BufferGeometry().fromGeometry(r);this.setPositions(o.attributes.position.array)}else r instanceof THREE__namespace.BufferGeometry&&this.setPositions(r.attributes.position.array);return this},t.prototype.copy=function(){return this},t}(LineSegmentsGeometry);Object.assign(LineGeometry.prototype,{isLineGeometry:!0});var circleImageURL="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==",DEFAULT_COLOR=14467195,POINT_SIZE=8,DEFAULT_LINEWIDTH=2,DEFAULT_DASHSCALE=20,sharedCircleTexture=null,FiveLine=function(n){__extends(t,n);function t(e,r){e===void 0&&(e=new THREE__namespace.Vector3),r===void 0&&(r=new THREE__namespace.Vector3);var o=n.call(this)||this;o.type="FiveLine",o.needsRender=!0;var s=new LineGeometry,u=new LineMaterial({color:DEFAULT_COLOR,linewidth:DEFAULT_LINEWIDTH,dashScale:DEFAULT_DASHSCALE,dashed:!1});o.line=new Line2(s,u);var l=new THREE__namespace.BufferGeometry,c=new THREE__namespace.PointsMaterial({color:DEFAULT_COLOR,size:POINT_SIZE,map:sharedCircleTexture||(sharedCircleTexture=new THREE__namespace.TextureLoader().load(circleImageURL)),sizeAttenuation:!1,transparent:!0});return o.points=new THREE__namespace.Points(l,c),o.points.renderOrder=11,o.points.frustumCulled=!1,o.setPoints(e,r),o.add(o.line,o.points),o}return Object.defineProperty(t,"version",{get:function(){return"6.4.0-alpha.14"},enumerable:!1,configurable:!0}),t.prototype.setPoints=function(e,r){var o=[].concat(e.toArray(),r.toArray());this.points.geometry.setAttribute("position",new THREE__namespace.BufferAttribute(new Float32Array(o),3)),this.line.geometry.setPositions(o),this.line.computeLineDistances(),this.needsRender=!0},t.prototype.getPoints=function(){var e=this.points.geometry.attributes.position.array;return[new THREE__namespace.Vector3(e[0],e[1],e[2]),new THREE__namespace.Vector3(e[3],e[4],e[5])]},t.prototype.setMaterial=function(e){var r=this.line.material;for(var o in e)if(e.hasOwnProperty(o)){var s=e[o];o==="dashed"?(r.dashed=s,s?r.defines.USE_DASH="":delete r.defines.USE_DASH,r.needsUpdate=!0):r[o]=e[o]}this.needsRender=!0},t.prototype.setResolution=function(e,r){var o=this.line.material.resolution;(o.x!==e||o.y!==r)&&(o.set(e,r),this.needsRender=!0)},t}(THREE__namespace.Object3D);Object.assign(FiveLine.prototype,{isFiveLine:!0});var Constants={Handedness:Object.freeze({NONE:"none",LEFT:"left",RIGHT:"right"}),ComponentState:Object.freeze({DEFAULT:"default",TOUCHED:"touched",PRESSED:"pressed"}),ComponentProperty:Object.freeze({BUTTON:"button",X_AXIS:"xAxis",Y_AXIS:"yAxis",STATE:"state"}),ComponentType:Object.freeze({TRIGGER:"trigger",SQUEEZE:"squeeze",TOUCHPAD:"touchpad",THUMBSTICK:"thumbstick",BUTTON:"button"}),ButtonTouchThreshold:.05,AxisTouchThreshold:.1,VisualResponseProperty:Object.freeze({TRANSFORM:"transform",VISIBILITY:"visibility"})};function fetchJsonFile(n){return __awaiter(this,void 0,void 0,function(){var t;return __generator(this,function(e){switch(e.label){case 0:return[4,fetch(n)];case 1:if(t=e.sent(),t.ok)return[2,t.json()];throw new Error(t.statusText)}})})}function fetchProfilesList(n){return __awaiter(this,void 0,void 0,function(){var t,e;return __generator(this,function(r){switch(r.label){case 0:if(!n)throw new Error("No basePath supplied");return t="profilesList.json",[4,fetchJsonFile("".concat(n,"/").concat(t))];case 1:return e=r.sent(),[2,e]}})})}function fetchProfile(n,t){return __awaiter(this,arguments,void 0,function(e,r,o,s){var u,l,c,f,d,p;return o===void 0&&(o=null),s===void 0&&(s=!0),__generator(this,function(v){switch(v.label){case 0:if(!e)throw new Error("No xrInputSource supplied");if(!r)throw new Error("No basePath supplied");return[4,fetchProfilesList(r)];case 1:if(u=v.sent(),e.profiles.some(function(g){var h=u[g];return h&&(l={profileId:g,profilePath:"".concat(r,"/").concat(h.path),deprecated:!!h.deprecated}),!!l}),!l){if(!o)throw new Error("No matching profile name found");if(c=u[o],!c)throw new Error('No matching profile name found and default profile "'.concat(o,'" missing.'));l={profileId:o,profilePath:"".concat(r,"/").concat(c.path),deprecated:!!c.deprecated}}return[4,fetchJsonFile(l.profilePath)];case 2:if(f=v.sent(),s){if(p=void 0,p=f.layouts[e.handedness],!p)throw new Error("No matching handedness, ".concat(e.handedness,", in profile ").concat(l.profileId));p.assetPath&&(d=l.profilePath.replace("profile.json",p.assetPath))}return[2,{profile:f,assetPath:d}]}})})}var defaultComponentValues={xAxis:0,yAxis:0,button:0,state:Constants.ComponentState.DEFAULT};function normalizeAxes(n,t){n===void 0&&(n=0),t===void 0&&(t=0);var e=n,r=t,o=Math.sqrt(n*n+t*t);if(o>1){var s=Math.atan2(t,n);e=Math.cos(s),r=Math.sin(s)}var u={normalizedXAxis:e*.5+.5,normalizedYAxis:r*.5+.5};return u}var VisualResponse=function(){function n(t){this.componentProperty=t.componentProperty,this.states=t.states,this.valueNodeName=t.valueNodeName,this.valueNodeProperty=t.valueNodeProperty,this.valueNodeProperty===Constants.VisualResponseProperty.TRANSFORM&&(this.minNodeName=t.minNodeName,this.maxNodeName=t.maxNodeName),this.value=0,this.updateFromComponent(defaultComponentValues)}return n.prototype.updateFromComponent=function(t){var e=t.xAxis,r=t.yAxis,o=t.button,s=t.state,u=normalizeAxes(e,r),l=u.normalizedXAxis,c=u.normalizedYAxis;switch(this.componentProperty){case Constants.ComponentProperty.X_AXIS:this.value=this.states.includes(s)?l:.5;break;case Constants.ComponentProperty.Y_AXIS:this.value=this.states.includes(s)?c:.5;break;case Constants.ComponentProperty.BUTTON:this.value=this.states.includes(s)?o:0;break;case Constants.ComponentProperty.STATE:this.valueNodeProperty===Constants.VisualResponseProperty.VISIBILITY?this.value=this.states.includes(s):this.value=this.states.includes(s)?1:0;break;default:throw new Error("Unexpected visualResponse componentProperty ".concat(this.componentProperty))}},n}(),Component=function(){function n(t,e){var r=this;if(!t||!e||!e.visualResponses||!e.gamepadIndices||Object.keys(e.gamepadIndices).length===0)throw new Error("Invalid arguments supplied");this.id=t,this.type=e.type,this.rootNodeName=e.rootNodeName,this.touchPointNodeName=e.touchPointNodeName,this.visualResponses={},Object.keys(e.visualResponses).forEach(function(o){var s=new VisualResponse(e.visualResponses[o]);r.visualResponses[o]=s}),this.gamepadIndices=Object.assign({},e.gamepadIndices),this.values={state:Constants.ComponentState.DEFAULT,button:this.gamepadIndices.button!==void 0?0:void 0,xAxis:this.gamepadIndices.xAxis!==void 0?0:void 0,yAxis:this.gamepadIndices.yAxis!==void 0?0:void 0}}return Object.defineProperty(n.prototype,"data",{get:function(){var t=__assign({id:this.id},this.values);return t},enumerable:!1,configurable:!0}),n.prototype.updateFromGamepad=function(t){var e=this;if(this.values.state=Constants.ComponentState.DEFAULT,this.gamepadIndices.button!==void 0&&t.buttons.length>this.gamepadIndices.button){var r=t.buttons[this.gamepadIndices.button];this.values.button=r.value,this.values.button=this.values.button<0?0:this.values.button,this.values.button=this.values.button>1?1:this.values.button,r.pressed||this.values.button===1?this.values.state=Constants.ComponentState.PRESSED:(r.touched||this.values.button>Constants.ButtonTouchThreshold)&&(this.values.state=Constants.ComponentState.TOUCHED)}this.gamepadIndices.xAxis!==void 0&&t.axes.length>this.gamepadIndices.xAxis&&(this.values.xAxis=t.axes[this.gamepadIndices.xAxis],this.values.xAxis=this.values.xAxis<-1?-1:this.values.xAxis,this.values.xAxis=this.values.xAxis>1?1:this.values.xAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.xAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),this.gamepadIndices.yAxis!==void 0&&t.axes.length>this.gamepadIndices.yAxis&&(this.values.yAxis=t.axes[this.gamepadIndices.yAxis],this.values.yAxis=this.values.yAxis<-1?-1:this.values.yAxis,this.values.yAxis=this.values.yAxis>1?1:this.values.yAxis,this.values.state===Constants.ComponentState.DEFAULT&&Math.abs(this.values.yAxis)>Constants.AxisTouchThreshold&&(this.values.state=Constants.ComponentState.TOUCHED)),Object.values(this.visualResponses).forEach(function(o){o.updateFromComponent(e.values)})},n}(),MotionController=function(){function n(t,e,r){var o=this;if(!t)throw new Error("No xrInputSource supplied");if(!e)throw new Error("No profile supplied");this.xrInputSource=t,this.assetUrl=r,this.id=e.profileId,this.layoutDescription=e.layouts[t.handedness],this.components={},Object.keys(this.layoutDescription.components).forEach(function(s){var u=o.layoutDescription.components[s];o.components[s]=new Component(s,u)}),this.updateFromGamepad()}return Object.defineProperty(n.prototype,"gripSpace",{get:function(){return this.xrInputSource.gripSpace},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"targetRaySpace",{get:function(){return this.xrInputSource.targetRaySpace},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"data",{get:function(){var t=[];return Object.values(this.components).forEach(function(e){t.push(e.data)}),t},enumerable:!1,configurable:!0}),n.prototype.updateFromGamepad=function(){var t=this;Object.values(this.components).forEach(function(e){e.updateFromGamepad(t.xrInputSource.gamepad)})},n}(),DEFAULT_PROFILES_PATH="https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles",DEFAULT_PROFILE="generic-trigger",XRControllerModel=function(n){__extends(t,n);function t(){var e=n.call(this)||this;return e.motionController=null,e.envMap=null,e}return t.prototype.setEnvironmentMap=function(e){var r=this;return this.envMap==e?this:(this.envMap=e,this.traverse(function(o){o instanceof THREE__namespace.Mesh&&o.isMesh&&(o.material.envMap=r.envMap,o.material.needsUpdate=!0)}),this)},t.prototype.updateMatrixWorld=function(e){n.prototype.updateMatrixWorld.call(this,e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(function(r){Object.values(r.visualResponses).forEach(function(o){var s=o.valueNode,u=o.minNode,l=o.maxNode,c=o.value,f=o.valueNodeProperty;s&&(f===Constants.VisualResponseProperty.VISIBILITY?s.visible=c:f===Constants.VisualResponseProperty.TRANSFORM&&(s.quaternion.copy(u.quaternion).slerp(l.quaternion,c),s.position.lerpVectors(u.position,l.position,c)))})}))},t}(THREE.Object3D);function findNodes(n,t){Object.values(n.components).forEach(function(e){var r=e.type,o=e.touchPointNodeName,s=e.visualResponses;if(r===Constants.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(o),e.touchPointNode){var u=new THREE.SphereGeometry(.001),l=new THREE.MeshBasicMaterial({color:255}),c=new THREE.Mesh(u,l);e.touchPointNode.add(c)}else console.warn("Could not find touch dot, ".concat(e.touchPointNodeName,", in touchpad component ").concat(e.id));Object.values(s).forEach(function(f){var d=f.valueNodeName,p=f.minNodeName,v=f.maxNodeName,g=f.valueNodeProperty;if(g===Constants.VisualResponseProperty.TRANSFORM){if(f.minNode=t.getObjectByName(p),f.maxNode=t.getObjectByName(v),!f.minNode){console.warn("Could not find ".concat(p," in the model"));return}if(!f.maxNode){console.warn("Could not find ".concat(v," in the model"));return}}f.valueNode=t.getObjectByName(d),f.valueNode||console.warn("Could not find ".concat(d," in the model"))})})}function addAssetSceneToControllerModel(n,t){findNodes(n.motionController,t),n.envMap&&t.traverse(function(e){e instanceof THREE__namespace.Mesh&&e.isMesh&&(e.material.envMap=n.envMap,e.material.needsUpdate=!0)}),n.add(t)}var XRControllerModelFactory=function(){function n(t){t===void 0&&(t=null),this.gltfLoader=t,this.path=DEFAULT_PROFILES_PATH,this._assetCache={}}return n.prototype.createControllerModel=function(t){var e=this,r=new XRControllerModel,o=null;return t.addEventListener("connected",function(s){var u=s.data;u.targetRayMode!=="tracked-pointer"||!u.gamepad||fetchProfile(u,e.path,DEFAULT_PROFILE).then(function(l){var c=l.profile,f=l.assetPath;r.motionController=new MotionController(u,c,f);var d=e._assetCache[r.motionController.assetUrl];if(d)o=d.scene.clone(),addAssetSceneToControllerModel(r,o);else{if(!e.gltfLoader)throw new Error("GLTFLoader not set.");e.gltfLoader.load(r.motionController.assetUrl,function(p){e._assetCache[r.motionController.assetUrl]=p,o=p.scene.clone(),addAssetSceneToControllerModel(r,o)})}}).catch(function(l){console.warn(l)})}),t.addEventListener("disconnected",function(){r.motionController=null,r.remove(o),o=null}),r},n}();function mapPanoResource(n,t){return n}var CONTROLLER_EVNET_DELTA_TIME=300,ROTATE_Y_PI_MATRIX=new THREE__namespace.Matrix4().makeRotationAxis(new THREE__namespace.Vector3(0,1,0),Math.PI),PANO_TEXTURE_SCALE=new THREE__namespace.Vector3(-1,1,1),XRPanoramaController=function(n){__extends(t,n);function t(e){var r=n.call(this,e)||this;r.xrManager=new XRManager(r.renderer,r.renderer.getContext(),{onSessionStart:function(c){r.emit("xr.session.start",createEvent("xr.session.start",{session:c,machineType:r.xrManager.machineType}))},onSessionEnd:function(){r.emit("xr.session.end",createEvent("xr.session.end",{session:null,machineType:r.xrManager.machineType}))}}),r.xrControllerRay={left:new THREE__namespace.Raycaster,right:new THREE__namespace.Raycaster},r.xrControllerRay.left.params.Points={threshold:.1},r.xrControllerRay.right.params.Points={threshold:.1},r.gazeRay=null,r.pointerLines={left:new FiveLine,right:new FiveLine},r.pointerLines.left.visible=!1,r.pointerLines.right.visible=!0,r.pointerLines.left.setMaterial({color:new THREE__namespace.Vector3(1,1,1)}),r.pointerLines.left.points.material.depthTest=!1,r.pointerLines.right.setMaterial({color:new THREE__namespace.Vector3(1,1,1)}),r.pointerLines.right.points.material.depthTest=!1,r.controllerWrappers=[new THREE__namespace.Group,new THREE__namespace.Group];var o=r.xrManager.getController(0);r.controllerWrappers[0].add(o);var s=r.xrManager.getController(1);r.controllerWrappers[1].add(s);var u=new XRControllerModelFactory;u.gltfLoader={load:function(c,f){internalFetcher.ajax(c,{responseType:"arraybuffer"}).then(function(d){var p;return parseGltf(d.body,{resourcePath:c.slice(0,c.lastIndexOf("/")+1),search:(p=c.split("?")[1])!==null&&p!==void 0?p:"",fetcher:internalFetcher})}).then(function(d){return f(d)})}},(r.xrManager.machineType==="Oculus"||r.xrManager.machineType==="Pico")&&r.scene.add(r.pointerLines.left,r.pointerLines.right,r.controllerWrappers[0],r.controllerWrappers[1]),r.panoResources={},r.panoResources[r.locationMotion.keyframes[0].key=r.locationMotion.keyframes[1].key=createUuid()]={panoId:panoStringify(r.currentPano),leftPanoPicture:null,position:r.camera.pose.offset.clone(),effect:"fade",fixCameraTransform:new THREE__namespace.Matrix4},r.parallaxCameraMatrixs=[];var l=AnimationFrameLoop.shared.getContext();return l?(r.on("xr.session.end",function(){r.scene.remove(r.pointerLines.left,r.pointerLines.right)}),r.xrManager.setSession(l),r.on("xr.session.start",function(){var c=r.xrManager.getControllerGrip(0);c.add(u.createControllerModel(c)),r.controllerWrappers[0].add(c);var f=r.xrManager.getControllerGrip(1);f.add(u.createControllerModel(f)),r.controllerWrappers[1].add(f)}),r.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}},r.xrManager.machineType==="VP"&&r.initHandEvent(),r):(console.error("获取session失败,请退出重试"),r)}return t.parseArgs=function(e){if(e instanceof t)return e;var r=__assign(__assign({},e),{maxLatitude:Math.PI/2,minLatitude:-Math.PI/2});return n.parseArgs.call(this,r)},t.initAnimationEndState=function(e){var r=this.parseArgs(e),o=n.initAnimationEndState.call(this,r);return __assign(__assign({},o),{mode:"XRPanorama"})},t.prototype.moveToPano=function(e,r,o){var s=this,u,l,c,f,d=(u=r.effect)!==null&&u!==void 0?u:"fade";this.userAction=o,this.stopMomentumMovement();var p=this.works.getResolvedObserver(e);if(!p)throw new Error("Invalid PanoIndex");var v=getImageSizeFromURL(p.images.up),g=this.imageOptions.size;typeof g=="undefined"&&p&&v&&(g=Number(v)),typeof g=="undefined"&&(g=2048);var h=this.imageOptions.transform,m=function(w,C){return mapPanoResource(applyImageURLOptions(w,h,C))},y=__assign({key:"pano.".concat(p.panoId)},pick(this.imageOptions,["format","size","quality"])),A=p.images,E=(c=(l=p.images.tiles)===null||l===void 0?void 0:l.filter(function(w){return w.size>g}))!==null&&c!==void 0?c:null,b="pano:"+jsonHash([A,y,h]);if(this.pendingTextureTask){if(this.pendingTextureTask.hash===b)return;var T=this.pendingTextureTask.panoId;(f=this.panoMeshes[T])===null||f===void 0||f.setProgress(0),this.emit("pano.texture.abort",createEvent("pano.texture.abort",{error:null,progress:0,meta:null,pano:p.pano}))}var _=this.models.getMaterial()||{},R=_.pano0,S=_.pano1,M;if((R==null?void 0:R.map.name)===b?M=R:(S==null?void 0:S.map.name)===b&&(M=S),M){var B={panoId:p.panoId,effect:d,leftPanoPicture:{zoom:1,map:M.map,luminanceMap:M.luminanceMap,matrix:new THREE__namespace.Matrix4().compose(p.position,p.quaternion,PANO_TEXTURE_SCALE)},position:p.position.clone(),fixCameraTransform:new THREE__namespace.Matrix4};this.doMoveToPano(p.pano,B,r);return}var H="move-to-pano-"+p.panoId;this.pending.add(H),this.pendingTextureTask={panoId:p.panoId,hash:b,onLoad:function(w){if(s.pending.delete(H),s.destroyed)w.body.dispose();else{w.body.name=b;var C={panoId:p.panoId,effect:d,leftPanoPicture:{zoom:1,map:w.body,luminanceMap:null,matrix:new THREE__namespace.Matrix4().compose(p.position,p.quaternion,PANO_TEXTURE_SCALE)},position:p.position.clone(),fixCameraTransform:new THREE__namespace.Matrix4};s.doMoveToPano(p.pano,C,r)}},onError:function(w){s.pending.delete(H);var C=__assign(__assign(__assign({},p.pano),{mode:s.mode}),clonePose(s.camera.pose));s.emit("pano.error",createEvent("pano.error",{error:w,userAction:s.userAction,options:r,prevPano:s.currentPano,progress:0,state:C})),s.emit("pano.cancel",createEvent("pano.cancel",{error:null,userAction:s.userAction,options:r,prevPano:s.currentPano,progress:0,state:C})),r.moveCancelCallback&&r.moveCancelCallback()}},Promise.all([this.tileLevelForFov&&E&&E.length?this.textureLoader.loadTiledCubeTexture(A,E,{tileMaxLevel:this.TILED_CUBE_TEXTURE_LEVEL,imageURL:{transform:m,options:y},format:THREE__namespace.RGBAFormat,minFilter:THREE__namespace.LinearFilter,magFilter:THREE__namespace.LinearFilter,generateMipmaps:!1,viaAjax:!0,fetcher:getFetcher(p.work)},void 0,void 0,function(w){var C,F;s.emit("pano.texture.progress",createEvent("pano.texture.progress",{error:null,progress:w,meta:null,pano:p.pano})),((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&((F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(w))},this.renderer):this.textureLoader.loadCubeTexture(A,{imageURL:{transform:m,options:y},format:THREE__namespace.RGBAFormat,fetcher:getFetcher(p.work)},void 0,void 0,function(w){var C,F;((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&((F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(w)),s.emit("pano.texture.progress",createEvent("pano.texture.progress",{error:null,progress:w,meta:null,pano:p.pano}))},this.renderer)]).then(function(w){var C,F,I=w[0];((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b?(s.pendingTextureTask.onLoad(I),(F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(0),delete s.pendingTextureTask,s.emit("pano.texture.success",createEvent("pano.texture.success",{error:null,progress:1,meta:I.meta,pano:p.pano}))):I.body.dispose()}).catch(function(w){var C,F;((C=s.pendingTextureTask)===null||C===void 0?void 0:C.hash)===b&&(s.pendingTextureTask.onError(w),(F=s.panoMeshes[p.panoId])===null||F===void 0||F.setProgress(0),delete s.pendingTextureTask,s.emit("pano.texture.error",createEvent("pano.texture.error",{error:w,progress:0,meta:null,pano:p.pano})),s.emit("error",w))}),this.emit("pano.texture.load",createEvent("pano.texture.load",{error:null,progress:0,meta:null,pano:p.pano}))},t.prototype.doMoveToPano=function(e,r,o){var s=this,u,l,c,f,d,p,v,g,h,m;o===void 0&&(o={});var y=now(),A=createUuid();this.panoResources[A]=r;var E=1,b,T,_;if(this.locationMotion.ended){var R=this.locationMotion.getKeyFrameSegment(y);R[0];var S=R[1],M=this.locationMotion.value,B=this.panoResourceFromLocationMotionKeyframe(S).position,H=r.position;b=Math.max(B.distanceTo(H),E),T=[{key:S.key,progress:0,value:__assign(__assign({},M),{count:0})},{key:A,progress:1,value:{distance:0,count:1}}],_=0}else{var w=this.locationMotion.getKeyFrameSegment(y),C=w[0],S=w[1],M=this.locationMotion.value,F=this.panoResourceFromLocationMotionKeyframe(C).position,B=this.panoResourceFromLocationMotionKeyframe(S).position,H=r.position,I=S.value.count-M.count,L=Math.max(F.distanceTo(B),E)*I,k=Math.max(B.distanceTo(H),E);b=L+k,T=[{key:C.key,progress:0,value:__assign({},M)},{key:S.key,progress:L/b,value:S.value},{key:A,progress:1,value:{count:S.value.count+1,distance:0}}];var N=this.locationMotionKeyframesLength(this.locationMotion.keyframes),D=this.locationMotionKeyframesLength(T);_=this.locationMotion.getProgressVelocity(y)*N/D}var U=r.effect==="instant"?0:this.calculateMovingDuration(o.duration,r.effect==="fly"?b:0),z={longitude:o.longitude,latitude:o.latitude,fov:o.fov},q=__assign(__assign({},e),{mode:this.mode,longitude:(u=z.longitude)!==null&&u!==void 0?u:this.camera.pose.longitude,latitude:(l=z.latitude)!==null&&l!==void 0?l:this.camera.pose.latitude,fov:(c=z.fov)!==null&&c!==void 0?c:this.camera.pose.fov,offset:r.position.clone(),distance:0}),G=this.currentPano;if(this.emit("pano.moveTo",createEvent("pano.moveTo",{options:o,prevPano:G,progress:0,state:q,userAction:this.userAction,error:null})),o.moveStartCallback&&o.moveStartCallback(q),this.videoTexture&&this.videoTexture.image instanceof HTMLVideoElement&&this.videoTexture.image.getAttribute("src")&&(this.videoTexture.image.pause(),this.videoTexture.image.removeAttribute("uuid"),this.videoTexture.image.removeAttribute("src"),this.videoTexture.image.oncanplay=noop$1,this.videoTexture.needsUpdate=!0),this.panoVideo.setMaterial(null),r.effect==="fly")this.cameraMotion.set(z,U).catch(noop$1);else{var J=coordinatesToVector({longitude:this.cameraMotion.value.longitude,latitude:this.cameraMotion.value.latitude}),X=coordinatesToVector({longitude:(f=z.longitude)!==null&&f!==void 0?f:this.cameraMotion.value.longitude,latitude:(d=z.latitude)!==null&&d!==void 0?d:this.cameraMotion.value.latitude}),j=new THREE__namespace.Object3D;j.lookAt(J);var Y=new THREE__namespace.Matrix4().makeRotationFromQuaternion(j.quaternion);j.lookAt(X);var Z=new THREE__namespace.Matrix4().makeRotationFromQuaternion(j.quaternion),W=new THREE__namespace.Matrix4().getInverse(Y).premultiply(Z),ae=this.cameraMotion.value.fov,re=(p=z.fov)!==null&&p!==void 0?p:this.cameraMotion.value.fov,se=1;r.effect==="zoomin"?se=1.5:r.effect==="zoomout"&&(se=.4);for(var ie=re*se,fe=0;fe<T.length-1;fe++){var ne=T[fe].key;if(ne){var pe=this.panoResources[ne];pe&&(pe.fixCameraTransform.copy(W),pe.leftPanoPicture&&(pe.leftPanoPicture.zoom=Math.tan(ae/2/180*Math.PI)/Math.tan(ie/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:(v=z.longitude)!==null&&v!==void 0?v:this.cameraMotion.value.longitude,latitude:(g=z.latitude)!==null&&g!==void 0?g:this.cameraMotion.value.latitude,fov:ie}},{progress:1,value:{longitude:(h=z.longitude)!==null&&h!==void 0?h:this.cameraMotion.value.longitude,latitude:(m=z.latitude)!==null&&m!==void 0?m:this.cameraMotion.value.latitude,fov:re}}],U).catch(noop$1)}var _e=this.locationMotion.setKeyframes(T,U,_);_e.then(function(){for(var me,xe,$,te=0,Q=s.models;te<Q.length;te++){var be=Q[te];be.show()}var ye=__assign(__assign({},e),{mode:s.mode,longitude:s.camera.pose.longitude,latitude:s.camera.pose.latitude,fov:s.camera.pose.fov,offset:s.camera.pose.offset.clone(),distance:0});s.emit("pano.arrived",createEvent("pano.arrived",{options:o,prevPano:G,progress:1,state:ye,userAction:s.userAction,error:null})),o.moveEndCallback&&o.moveEndCallback(ye);var Ae=s.works.getResolvedObserver(s.currentPano);if(Ae&&Ae.video&&s.videoTexture&&s.videoTexture.image instanceof HTMLVideoElement){var Me=ROTATE_Y_PI_MATRIX.clone().multiply(($=(xe=(me=s.models.getMaterial())===null||me===void 0?void 0:me.pano1)===null||xe===void 0?void 0:xe.matrix)!==null&&$!==void 0?$:new THREE__namespace.Matrix4).multiply(Ae.video.matrix),ge={map:s.videoTexture,size:Ae.video.size,matrix:Me,alpha:1},he=createUuid(),de=s.videoTexture.image;de.setAttribute("uuid",he),canplayVideo().then(function(ce){ce&&Ae.video&&de.getAttribute("uuid")===he&&(de.oncanplay=function(){de.oncanplay=noop$1,de.play()},de.ontimeupdate=function(){de.currentTime>.5&&(de.ontimeupdate=noop$1,s.panoVideo.setMaterial(ge))},de.src=Ae.video.source)}).catch(function(){de.removeAttribute("uuid")})}},function(){s.emit("pano.cancel",createEvent("pano.cancel",{options:o,prevPano:G,progress:0,state:q,userAction:s.userAction,error:null})),o.moveCancelCallback&&o.moveCancelCallback()})},t.prototype.checkSelectedPano=function(e){var r=this,o,s,u,l;this.stopMomentumMovement();var c=this.camera.getDirection(new THREE__namespace.Vector3).setY(0),f=null,d=this.works.getResolvedObserver(this.currentPano);if(!d)return null;var p=d.accessibleIds.filter(function(X){var j=panoParse(X);if(panoEqual(j,r.currentPano))return!1;var Y=r.works.getResolvedObserver(j);return!Y||Y.position.distanceTo(r.camera.position)>r.maxAccessibleDistance?!1:Y.loadable||Y.active}),v=this.models.intersectRaycaster(e)[0];if(v){var g=arrayMin(p,function(X){var j=r.works.getResolvedObserver(X);if(!j)return 1/0;var Y=j.standingPosition.clone();return Y.distanceTo(v.point)},!0),h=g[0],m=g[1];h&&m<this.panoTapTriggerRadius&&(f=(o=this.works.getResolvedObserver(h))!==null&&o!==void 0?o:null)}if(isNil(f)){var y=this.getForwardObserverOrNot(e);y&&(f=y)}for(var A=0,E=this.locationMotion.keyframes;A<E.length;A++){var b=E[A],T=this.panoResourceFromLocationMotionKeyframe(b);if(!(b.progress<this.locationMotion.progress)&&f&&T.panoId===f.panoId){f=null;break}}if(isNil(f))return this.locationMotion.ended===!0&&this.cameraBounce(),null;if(f&&!f.active){var _=f.panoId;this.panoMeshes[_]&&(this.panoMeshes[_].setDisabled(!1),this.panoMeshes[_].setLoading(!0))}var R={};if(f){for(var S=Math.PI/6,M=Math.PI/12,B=new THREE__namespace.Vector3(0,1,0),H=f.position.clone().setY(0).sub(d.position.clone().setY(0)).normalize(),w=H.clone().applyAxisAngle(B,S),C=H.clone().applyAxisAngle(B,-S),F=[],I=[],L=[],k=0,N=f.accessibleIds;k<N.length;k++){var h=N[k],D=panoParse(h);if(!(panoEqual(D,this.currentPano)||panoEqual(D,f.pano))){var U=this.works.getResolvedObserver(h);if(U){var z=U.position.clone().sub(f.position).setY(0);H.angleTo(z)<S?L.push(z):w.angleTo(z)<S?F.push(z):C.angleTo(z)<S&&I.push(z)}}}var q=L.length>0?L:__spreadArray(__spreadArray([],F,!0),I,!0),G=q.slice().sort(function(X,j){return X.angleTo(H)-j.angleTo(H)})[0];G&&G.angleTo(c)>M&&(R.longitude=Math.atan2(-G.x,-G.z))}this.cameraMotion.value.latitude<-Math.PI/4&&(R.latitude=clamp$1(0,this.minLatitude,this.maxLatitude)),this.cameraMotion.value.fov<60&&(R.fov=this.defaultFov);var J={workCode:f.pano.workCode,panoIndex:f.pano.panoIndex,mode:this.mode,longitude:(s=R.longitude)!==null&&s!==void 0?s:this.camera.pose.longitude,latitude:(u=R.latitude)!==null&&u!==void 0?u:this.camera.pose.latitude,fov:(l=R.fov)!==null&&l!==void 0?l:this.camera.pose.fov,distance:0,offset:f?f.position.clone():new THREE__namespace.Vector3};return this.emit("pano.select",createEvent("pano.select",{prevPano:this.currentPano,state:J,userAction:!0,options:R,progress:0,error:null})),f&&f.active?(this.emit("pano.request",createEvent("pano.request",{userAction:!0,prevPano:this.currentPano,progress:0,state:J,options:R,error:null})),f.pano):null},t.prototype.destroy=function(){n.prototype.destroy.call(this)},t.prototype.isReady=function(){return!1},t.prototype.updateCamera=function(e,r,o){return Promise.resolve()},t.prototype.updateCameraWithKeyframes=function(e,r,o){return Promise.resolve()},t.prototype.updateTime=function(e,r){for(var o=this,s,u,l,c,f,d,p,v,g=[],h=2;h<arguments.length;h++)g[h-2]=arguments[h];this.userAction=!0;var m={},y={},A=this.panoResourceFromLocationMotionKeyframe(this.locationMotion.keyframes[0]),E=this.panoResourceFromLocationMotionKeyframe(this.locationMotion.keyframes[this.locationMotion.keyframes.length-1]),b=!1;if(this.cameraMotion.ended===!1&&(this.cameraMotion.update(e),y.longitude=this.cameraMotion.value.longitude,y.latitude=this.cameraMotion.value.latitude,y.fov=this.cameraMotion.value.fov),this.modelAlphaMotion.ended===!1&&(this.modelAlphaMotion.update(e),m.modelAlpha=this.modelAlphaMotion.value.modelAlpha),this.perspToOrthoMotion.ended===!1&&(this.perspToOrthoMotion.update(e),this.camera.perspToOrtho.setScalar(clamp$1(this.perspToOrthoMotion.value.perspToOrtho,0,1))),this.locationMotion.ended===!1){this.locationMotion.update(e);var T=this.locationMotion.getKeyFrameSegment(e),_=T[0],R=T[1],S=this.panoResourceFromLocationMotionKeyframe(_),M=this.panoResourceFromLocationMotionKeyframe(R),B=new THREE__namespace.Vector3().copy(S.position),H=new THREE__namespace.Vector3().copy(M.position),w=this.locationMotion.value.count-R.value.count+1;m.progress=w,M.leftPanoPicture&&(w<1?S.leftPanoPicture&&(m.pano0=S.leftPanoPicture):m.pano0=M.leftPanoPicture,m.pano1=M.leftPanoPicture),M.effect==="montage"?m.transition="BLACK":M.effect==="spread"?m.transition="SPREAD":m.transition="FADE",(M.effect==="zoomin"||M.effect==="zoomout")&&(m.progress=Math.pow(w,3)),w<1&&M.effect!=="fly"&&(m.pano0&&S.leftPanoPicture&&(m.pano0={map:m.pano0.map,zoom:m.pano0.zoom,luminanceMap:m.pano0.luminanceMap,matrix:S.leftPanoPicture.matrix.clone().setPosition(M.position)}),B.copy(H),b=!0),y.distance=this.locationMotion.value.distance,y.offset=new THREE__namespace.Vector3(B.x+(H.x-B.x)*w,B.y+(H.y-B.y)*w,B.z+(H.z-B.z)*w);for(var C=[],F=[],I=0,L=this.locationMotion.keyframes;I<L.length;I++){var k=L[I],N=k.key,D=k.progress;N!==void 0&&(C.push(N),D>this.locationMotion.progress&&F.push(N))}for(var U=0,z=Object.keys(this.panoResources);U<z.length;U++){var q=z[U];if(!(F.indexOf(q)>=0)){var G=this.panoResources[q];if(G.leftPanoPicture){var J=G.leftPanoPicture.map;if(J){if(J===((s=m.pano0)===null||s===void 0?void 0:s.map)||J===((u=m.pano1)===null||u===void 0?void 0:u.map))continue;J instanceof TileCubeTextureTarget&&J.cubeRenderTarget&&this.colorCubeRenderTargetPool.push(J.cubeRenderTarget),J.dispose(),G.leftPanoPicture=null}}C.indexOf(q)>=0||delete this.panoResources[q]}}this.currentPano=panoParse(M.panoId),this.emit("pano.moving",createEvent("pano.moving",{userAction:this.userAction,prevPano:panoParse(A.panoId),state:__assign(__assign(__assign(__assign({},panoParse(E.panoId)),{mode:this.mode}),clonePose(this.camera.pose)),y),options:{},progress:this.locationMotion.progress,error:null}))}isEmptyObject(m)===!1&&(!((l=m.pano0)===null||l===void 0)&&l.map&&m.pano0.map instanceof TileCubeTextureTarget&&!m.pano0.map.cubeRenderTarget&&(m.pano0.map.cubeRenderTarget=this.colorCubeRenderTargetPool.pop()),!((c=m.pano1)===null||c===void 0)&&c.map&&m.pano1.map instanceof TileCubeTextureTarget&&!m.pano1.map.cubeRenderTarget&&(m.pano1.map.cubeRenderTarget=this.colorCubeRenderTargetPool.pop()),this.models.setMaterial(m)),isEmptyObject(y)===!1&&this.setCamera(y);var X=this.works.getResolvedObserver(this.currentPano),j=g[1];if(!j){console.error("xrFrame丢失,请重试");return}if(!this.xrManager.session){console.error("session丢失,请重试");return}var Y=this.xrManager.referenceSpace;if(Y){var Z=this.xrManager.cameraVR,W=this.xrManager.cameraL,ae=this.xrManager.cameraR,re=[W,ae],se=j.getViewerPose(Y),ie=new THREE__namespace.Vector3(0,0,0);if(se){var fe;fe=this.xrManager.session.renderState.baseLayer;var ne=se.views;if(!fe){console.error("no layer found");return}this.renderer.setFramebuffer(fe.framebuffer);var pe=!1;ne.length!==Z.cameras.length&&(Z.cameras.length=0,pe=!0),this.parallaxCameraMatrixs=[];var _e=new THREE__namespace.Vector3,me=new THREE__namespace.Vector3;new THREE__namespace.Matrix4().fromArray(ne[0].transform.matrix).decompose(_e,new THREE__namespace.Quaternion,new THREE__namespace.Vector3),new THREE__namespace.Matrix4().fromArray(ne[1].transform.matrix).decompose(me,new THREE__namespace.Quaternion,new THREE__namespace.Vector3),me.clone().sub(_e).normalize();var xe=new THREE__namespace.Vector3,$=new THREE__namespace.Quaternion,te=new THREE__namespace.Vector3;this.camera.matrix.decompose(xe,$,te);for(var Q=0;Q<ne.length;Q++){var be=ne[Q],ye=fe.getViewport(be),Ae=re[Q];Ae.matrix.fromArray(be.transform.matrix);var Me=new THREE__namespace.Vector3,ge=new THREE__namespace.Quaternion,he=new THREE__namespace.Vector3;Ae.matrix.decompose(Me,ge,he),ie.copy(xe),Ae.position.copy(xe),Ae.quaternion.copy(ge),Ae.scale.copy(he),Ae.updateMatrix(),Ae.projectionMatrix.fromArray(be.projectionMatrix),Ae.viewport.set(ye.x,ye.y,ye.width,ye.height),pe===!0&&Z.cameras.push(Ae)}if(this.xrManager.session&&this.xrManager.session.inputSources){for(var Q=0;Q<this.xrManager.session.inputSources.length;Q++)if(this.xrManager.session.inputSources[Q]&&this.xrManager.session.inputSources[Q].targetRayMode==="transient-pointer"){var de=j.getPose(this.xrManager.session.inputSources[Q].targetRaySpace,Y);if(de){var ce=new THREE__namespace.Vector3(0,0,-1).applyQuaternion(de.transform.orientation),le=new THREE__namespace.Raycaster(this.camera.position,ce);this.gazeRay=le}}}if(this.xrManager.machineType==="Oculus"||this.xrManager.machineType==="Pico"){for(var we=this.xrManager.session.inputSources,Q=0;Q<we.length;Q++){var ue=this.xrManager.controllers[Q],ve=we[Q];if(ve){ue&&ue.update(ve,j,Y);var le=this.xrManager.getController(Q),qe=new THREE__namespace.Vector3(0,1.2,0),Ee=le.position.clone().add(ie).sub(qe);ve.handedness==="left"?this.xrControllerRay.left.set(Ee,new THREE__namespace.Vector3(0,0,-1).applyEuler(le.rotation)):ve.handedness==="right"&&this.xrControllerRay.right.set(Ee,new THREE__namespace.Vector3(0,0,-1).applyEuler(le.rotation)),this.controllerWrappers[Q].position.copy(new THREE__namespace.Vector3(0,0,0).add(ie).sub(qe));var Ie=this.models.intersectRaycaster(this.xrControllerRay.right);if(Ie.length===0&&(Ie=this.xrControllerRay.right.intersectObject(this.boundingMesh,!0).map(function(vt){var At;return __assign({floor:(At=X==null?void 0:X.floorIndex)!==null&&At!==void 0?At:0},vt)})),Ie.length>=1&&Ie[0].face)if(ve.handedness==="right"){var Oe=this.xrControllerRay.right.intersectObject(this.xrCustomObjectsScene,!0),$e=Ie[0].face.normal,pt=$e.clone(),tt=Ie[0].point.clone();this.intersectMesh.position.copy(tt);var Ne=tt.clone().add(pt);if(this.intersectMesh.lookAt(Ne),Math.abs($e.y)>.99){var Ge=this.camera.position.clone().sub(tt);this.intersectMesh.rotation.z=-Math.atan2(Ge.z,Ge.x)}this.intersectMesh.visible=!0,this.needsRender=!0,Oe.length>0?(this.pointerLines.right.setPoints(Ee,Oe[0].point),this.pointerLines.right.points.visible=!0,this.intersectMesh.visible=!1):(this.pointerLines.right.points.visible=!1,this.pointerLines.right.setPoints(Ee,Ie[0].point));var Ve=Ie[0],Ke=createEvent("intersect.update",{raycaster:(f=this.xrControllerRay.right)!==null&&f!==void 0?f:null,intersection:Ve!=null?Ve:null,object:this.intersectMesh});if(this.emit("intersect.update",Ke),Ke.defaultPrevented){this.hideIntersectMesh();return}}else this.pointerLines.left.setPoints(Ee,Ie[0].point)}}this.updateControllerHelper(we,e,r)}if(this.camera.pose.distance>.1||b)for(var Je=0,Xe=Object.keys(this.panoMeshes);Je<Xe.length;Je++){var Pe=Xe[Je],Se=this.panoMeshes[Pe];Se.setOpacity(0),Se.setCurrent(!1),Se.updateTime&&Se.updateTime(e,r),Se.visible=!1}else if(X){var Be=arrayMin(X.visibleIds,function(je){var at=o.works.getResolvedObserver(je);return at?X.standingPosition.distanceTo(at.standingPosition):1/0},!0),De=Be[1];De=clamp$1(De,2.5,1/0);for(var He=X.visibleIds.concat(panoStringify(this.currentPano)),Ue=this.getForwardObserverOrNot(),Ye=this.camera.getDirection(new THREE__namespace.Vector3),ze=0,rt=Object.keys(this.panoMeshes);ze<rt.length;ze++){var Pe=rt[ze],Se=this.panoMeshes[Pe],ot=this.works.getResolvedObserver(Pe);if(He.indexOf(Pe)===-1)Se.setCurrent(!1),Se.setOpacity(0);else if(!ot)Se.setCurrent(!1),Se.setOpacity(0);else if(!ot.loadable&&!ot.active)Se.setCurrent(!1),Se.setOpacity(0);else{var ht=Se.position.clone().setY(this.camera.position.y).distanceTo(this.camera.position);Se.setCurrent(!Se.loading&&Se.progress===0&&Ue!==null&&Ue.panoId===Pe),Se.setOpacity(ht<.01?0:clamp$1(De/ht*1.2,.65,.98));var st=this.camera.position.clone().setY(Se.position.y),ce=new THREE__namespace.Vector3().copy(Se.position).sub(st).normalize();if(Pe===panoStringify(this.currentPano)){var ct=clamp$1((.5-st.distanceTo(Se.position))/.5,0,1);ce.multiplyScalar(1-ct).add(Ye.clone().multiplyScalar(ct))}ce.length()>0&&Se.quaternion.setFromEuler(new THREE__namespace.Euler(0,Math.atan2(ce.x,ce.z),0))}Se.updateTime&&Se.updateTime(e,r)}}var We=function(){return 4}(),Ce=function(){var je=new THREE__namespace.PerspectiveCamera;je.applyMatrix4(Z.matrix),je.position.set(0,0,0);var at=o.works.getResolvedObserver(E.panoId),vt=at!=null?at:X;vt&&je.quaternion.premultiply(vt.quaternion.clone().inverse()),je.updateProjectionMatrix(),je.updateMatrixWorld(!0);var At=new THREE__namespace.Frustum().setFromProjectionMatrix(new THREE__namespace.Matrix4().multiplyMatrices(je.projectionMatrix,je.matrixWorldInverse));return At}();E.panoId===panoStringify(this.currentPano)&&((d=E.leftPanoPicture)===null||d===void 0?void 0:d.map)instanceof TileCubeTextureTarget&&(E.leftPanoPicture.map.maxRequest=this.tileMaxRequest,E.leftPanoPicture.map.update(Ce,We),E.leftPanoPicture.map.needsRender===!0&&(this.needsRender=!0,this.modelSceneNeedsRender=!0));{var Re=this.tiling.object.visible;if(this.initAnimationed){var Le=E.panoId,Qe=this.works.getResolvedObserver(Le);Qe?isSimilarVector3(this.camera.position,Qe.position)&&this.locationMotion.ended?(this.tiling.object.visible=!0,this.tiling.panoId!==Le&&this.tiling.cleanup(),this.tiling.panoId=Le,this.tiling.setResource((v=(p=Qe.images)===null||p===void 0?void 0:p.tiles)!==null&&v!==void 0?v:[],this.enableIOSEDR&&Qe.images.luminance?Qe.images.luminance:null),this.tiling.setFetcher(getFetcher(Qe.work)),this.tiling.setRotation(Qe.quaternion),this.tiling.setPosition(Qe.position),this.tiling.maxRequest=this.tileMaxRequest,We>this.TILED_CUBE_TEXTURE_LEVEL?this.tiling.update(Ce,We,e):this.tiling.update(Ce,0,e)):this.tiling.object.visible=!1:this.tiling.object.visible=!1}else this.tiling.object.visible=!1;Re!==this.tiling.object.visible&&(this.tiling.object.needsRender=!0,this.modelSceneNeedsRender=!0)}this.panoVideo.object.position.copy(this.camera.position),this.panoVideo.updateTime(e)}}},t.prototype.render=function(){var e=this.xrManager.getCamera(this.camera);this.renderer.render(this.modelScene,e),this.renderer.autoClearColor=!1,this.renderer.autoClearDepth=!1,this.renderer.render(this.scene,e),this.renderer.autoClearColor=!0,this.renderer.autoClearDepth=!0},t.prototype.onPanGesture=function(){},t.prototype.onTapGesture=function(){},t.prototype.onPinchGesture=function(){},t.prototype.onMouseMove=function(){},t.prototype.onMouseOut=function(){},t.prototype.panoResourceFromLocationMotionKeyframe=function(e){return this.panoResources[e.key]},t.prototype.updateControllerHelper=function(e,r,o){var s=this.xrControllerRay.left,u=this.xrControllerRay.right;if(!(!e||e.length===0)){for(var l={buttons:{X:!1,Y:!1,LeftTrigger:!1,LeftPinch:!1,A:!1,B:!1,RightTrigger:!1,RightPinch:!1}},c=0;c<e.length;c++){var f=e[c].handedness,d=e[c].gamepad;switch(f){case"left":d.axes&&(this.emitHandleEvent(d.axes[2]===-1,"LeftAxesLeft",r),this.emitHandleEvent(d.axes[2]===1,"LeftAxesRight",r),this.emitHandleEvent(d.axes[3]===-1,"LeftAxesUp",r),this.emitHandleEvent(d.axes[3]===1,"LeftAxesDown",r)),d!=null&&d.buttons&&(d.buttons[4]&&this.emitHandleEvent(d.buttons[4].pressed,"X",r),d.buttons[5]&&this.emitHandleEvent(d.buttons[5].pressed,"Y",r),d.buttons[0]&&this.emitHandleEvent(d.buttons[0].pressed,"LeftTrigger",r),d.buttons[1]&&this.emitHandleEvent(d.buttons[1].pressed,"LeftPinch",r));var p={raycaster:s,axes:{up:d.axes&&d.axes[3]<0?Math.abs(d.axes[3]):0,down:d.axes&&d.axes[3]<0?0:Math.abs(d.axes[3]),left:d.axes&&d.axes[2]<0?Math.abs(d.axes[2]):0,right:d.axes&&d.axes[2]<0?0:Math.abs(d.axes[2])},deltaTime:o};l.buttons.X=d.buttons&&d.buttons[4]?d.buttons[4].pressed:!1,l.buttons.Y=d.buttons&&d.buttons[5]?d==null?void 0:d.buttons[5].pressed:!1,l.buttons.LeftTrigger=d.buttons&&d.buttons[0]?d==null?void 0:d.buttons[0].pressed:!1,l.buttons.LeftPinch=d.buttons&&d.buttons[1]?d==null?void 0:d.buttons[1].pressed:!1,l.left=p;break;case"right":d.axes&&(this.emitHandleEvent(d.axes[2]===-1,"RightAxesLeft",r),this.emitHandleEvent(d.axes[2]===1,"RightAxesRight",r),this.emitHandleEvent(d.axes[3]===-1,"RightAxesUp",r),this.emitHandleEvent(d.axes[3]===1,"RightAxesDown",r)),d.buttons&&(d.buttons[4]&&this.emitHandleEvent(d.buttons[4].pressed,"A",r),d.buttons[5]&&this.emitHandleEvent(d.buttons[5].pressed,"B",r),d.buttons[0]&&this.emitHandleEvent(d.buttons[0].pressed,"RightTrigger",r),d.buttons[1]&&this.emitHandleEvent(d.buttons[1].pressed,"RightPinch",r));var v={raycaster:u,axes:{up:d.axes&&d.axes[3]<0?Math.abs(d.axes[3]):0,down:d.axes&&d.axes[3]<0?0:Math.abs(d.axes[3]),left:d.axes&&d.axes[2]<0?Math.abs(d.axes[2]):0,right:d.axes&&d.axes[2]<0?0:Math.abs(d.axes[2])},deltaTime:o};l.right=v,l.buttons.A=d.buttons&&d.buttons[4]?d==null?void 0:d.buttons[4].pressed:!1,l.buttons.B=d.buttons&&d.buttons[5]?d==null?void 0:d.buttons[5].pressed:!1,l.buttons.RightTrigger=d.buttons&&d.buttons[0]?d==null?void 0:d.buttons[0].pressed:!1,l.buttons.RightPinch=d.buttons&&d.buttons[1]?d==null?void 0:d.buttons[1].pressed:!1;break}}this.emit("xr.controller.update",createEvent("xr.controller.update",l))}},t.prototype.emitHandleEvent=function(e,r,o){var s=this.xrControllerRay.left,u=this.xrControllerRay.right;if(e)if(this.xrHandleState[r].touchStart===!1)this.xrHandleState[r].touchStartTime=o,this.xrHandleState[r].touchStart=!0,this.emit("xr.gesture.buttonDown",createEvent("xr.gesture.buttonDown",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!1,isFirst:!0,controllers:{raycaster:{leftRay:s,rightRay:u}}}));else{var l=o-this.xrHandleState[r].touchStartTime;l>CONTROLLER_EVNET_DELTA_TIME&&this.emit("xr.gesture.press",createEvent("xr.gesture.tap",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!0,controllers:{raycaster:{leftRay:s,rightRay:u}}}))}else if(this.xrHandleState[r].touchStart===!0){this.emit("xr.gesture.buttonUp",createEvent("xr.gesture.buttonUp",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:s,rightRay:u}}}));var l=o-this.xrHandleState[r].touchStartTime;if(l<=CONTROLLER_EVNET_DELTA_TIME){var c=createEvent("xr.gesture.tap",{session:this.xrManager.session,machineType:this.xrManager.machineType,buttons:r,isFinal:!0,isFirst:!1,controllers:{raycaster:{leftRay:s,rightRay:u}}}),f=this.emit("xr.gesture.tap",c);!f&&!c.defaultPrevented&&r==="RightTrigger"&&this.checkSelectedPano(this.xrControllerRay.right)}this.xrHandleState[r].touchStart=!1,this.xrHandleState[r].touchStartTime=0}},t.prototype.initHandEvent=function(){var e=this;if(!this.xrManager.session)throw new Error("初始化失败");this.xrManager.session.addEventListener("select",function(r){e.gazeRay&&e.checkSelectedPano(e.gazeRay)})},t}(PanoramaController),Controllers={Floorplan:FloorplanController,Topview:TopviewController,Panorama:PanoramaController,VRPanorama:VRPanoramaController,Model:ModelController,Mapview:MapviewController,XRPanorama:XRPanoramaController},PROXY_CONTROLLER_EVENT_NAMES=["gesture.pan","gesture.tap","gesture.dbltap","gesture.press","gesture.pinch","gesture.mousewheel","gesture.mousemove","gesture.momentum","initAnimation.start","initAnimation.end","camera.update","intersect.update","pano.select","pano.moveTo","pano.moving","pano.arrived","pano.cancel","pano.error","pano.texture.load","pano.texture.progress","pano.texture.success","pano.texture.error","pano.texture.abort","xr.session.start","xr.session.end","xr.gesture.tap","xr.gesture.press","xr.gesture.buttonUp","xr.gesture.buttonDown","xr.controller.update"];function initLegacyEvent(n){n.on("initAnimation.start",function(t){n.emit("initAnimationWillStart",t.state.panoIndex,t.state,t.userAction)}),n.on("initAnimation.end",function(t){n.emit("initAnimationEnded",t.state.panoIndex,t.state,t.userAction)}),n.on("gesture.pan",function(t){var e=!1;e=n.emit("wantsGesture","pan",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPanGesture",t.state,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","pan",t.pointers,t.isFinal),n.emit("panGesture",t.state,t.isFinal))}),n.on("gesture.tap",function(t){var e=!1;e=n.emit("wantsGesture","tap",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsTapGesture",t.center.raycaster,t.center.coords,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","tap",t.pointers,t.isFinal),n.emit("tapGesture",t.center.raycaster,t.center.coords,t.isFinal))}),n.on("gesture.dbltap",function(t){var e=!1;e=n.emit("wantsGesture","dbltap",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsDblTapGesture",t.center.raycaster,t.center.coords,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","dbltap",t.pointers,t.isFinal),n.emit("dblTapGesture",t.center.raycaster,t.center.coords,t.isFinal))}),n.on("gesture.press",function(t){var e=!1;e=n.emit("wantsGesture","press",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPressGesture",t.center.raycaster,t.center.coords,t.center.delta,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","press",t.pointers,t.isFinal),n.emit("pressGesture",t.center.raycaster,t.center.coords,t.center.delta,t.isFinal))}),n.on("gesture.pinch",function(t){var e=!1;e=n.emit("wantsGesture","pinch",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsPinchGesture",t.scale,t.state.fov,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","pinch",t.pointers,t.isFinal),n.emit("pinchGesture",t.scale,t.state.fov,t.isFinal))}),n.on("gesture.mousewheel",function(t){var e=!1;e=n.emit("wantsGesture","mouseWheel",t.pointers,t.isFinal),e&&t.preventDefault(),e=n.emit("wantsMouseWheel",t.center.delta,t.state.fov,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","mouseWheel",t.pointers,t.isFinal),n.emit("mouseWheel",t.center.delta,t.state.fov,t.isFinal))}),n.on("gesture.mousemove",function(t){var e=!1;e=n.emit("wantsGesture","mouseMove",t.pointers,t.isFinal),e&&t.preventDefault(),t.defaultPrevented||(n.emit("gesture","mouseMove",t.pointers,t.isFinal),e=n.emit("wantsChangeCameraFov",t.state.fov),e&&t.preventDefault())}),n.on("gesture.momentum",function(t){var e=!1;e=n.emit("wantsInteriaPan",t.state),e&&t.preventDefault(),t.defaultPrevented||n.emit("interiaPan",t.state,t.isFinal)}),n.on("camera.update",function(t){n.emit("cameraFovUpdate",t.state.fov,t.userAction),n.emit("cameraDirectionUpdate",t.state,t.userAction);var e=coordinatesToVector(t.state);e.setLength(t.state.distance);var r=t.state.offset.clone().sub(e);n.emit("cameraPositionUpdate",r,t.userAction),n.emit("cameraUpdate",t.state,t.userAction)}),n.on("intersect.update",function(t){if(t.intersection){var e=!1;e=n.emit("wantsShowIntersectionOnModel",t.raycaster),e&&t.preventDefault(),t.defaultPrevented||n.emit("intersectionOnModelUpdate",t.intersection,t.object)}else n.emit("intersectionHidden")}),n.on("pano.request",function(t){var e=n.emit("wantsMoveToPano",t.state.panoIndex,t.options,t.userAction);e||(e=n.emit("wantsToMoveToPano",t.state.panoIndex,t.options,t.userAction)),e&&t.preventDefault(),t.defaultPrevented||n.emit("panoWillLoad",t.state.panoIndex)}),n.on("pano.select",function(t){n.emit("panoSelected",t.state.panoIndex)}),n.on("pano.moveTo",function(t){n.emit("panoLoaded",t.state.panoIndex),n.emit("moveToPano",t.state.panoIndex,t.userAction),n.emit("panoWillArrive",t.state.panoIndex,t.state,t.userAction)}),n.on("pano.moving",function(t){n.emit("movingToPano",t.state.panoIndex,t.prevPano.panoIndex,t.progress)}),n.on("pano.arrived",function(t){n.emit("panoArrived",t.state.panoIndex,t.state,t.userAction)}),n.on("pano.cancel",function(t){n.emit("moveToPanoCanceled",t.state.panoIndex)}),n.on("pano.error",function(t){n.emit("panoLoadError",t.error,t.state.panoIndex)}),n.on("pano.texture.load",function(t){n.emit("textureStartLoad",t.pano.panoIndex)}),n.on("pano.texture.success",function(t){n.emit("textureLoaded",t.pano.panoIndex,t.meta)}),n.on("pano.texture.error",function(t){n.emit("textureError",t.error,t.pano.panoIndex)}),n.on("pano.texture.abort",function(t){n.emit("textureAbort",t.pano.panoIndex)}),n.on("pano.texture.progress",function(t){n.emit("textureLoading",t.progress,t.pano.panoIndex)}),n.on("xr.session.start",function(t){n.emit("webXRSessionStart")}),n.on("xr.session.end",function(t){n.emit("webXRSessionEnd")}),n.on("xr.gesture.tap",function(t){n.emit("webXRControllerEvent","tap",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.press",function(t){n.emit("webXRControllerEvent","press",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.buttonUp",function(t){n.emit("webXRControllerEvent","buttonUp",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.gesture.buttonDown",function(t){n.emit("webXRControllerEvent","buttonDown",t.buttons,{raycaster:t.controllers.raycaster})}),n.on("xr.controller.update",function(t){n.emit("webXRControllerRayUpdate",{leftRay:t.left?t.left.raycaster:void 0,rightRay:t.right?t.right.raycaster:void 0}),t.left&&n.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&&n.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})}),n.on("works.request",function(t){n.emit("willLoad",t.input,t.works[0],t.state)}),n.on("works.load",function(t){n.emit("load",t.input,t.works[0],t.state)}),n.on("works.ready",function(t){n.emit("loaded",t.input,t.works[0])}),n.on("state.change",function(t){n.emit("stateChange",t.state,t.userAction)}),n.on("currentState.change",function(t){n.emit("currentStateChange",t.state,t.userAction)}),n.on("state.set",function(t){n.emit("setState",t.state)}),n.on("state.synced",function(t){n.emit("stateSynced",t.state)}),n.on("model.request",function(t){n.emit("modelWillLoad",t.work.model)}),n.on("model.error",function(t){n.emit("modelLoadError",t.error,t.model)}),n.on("model.load",function(t){n.emit("modelLoaded",t.model)}),n.on("model.changeShownFloor",function(t){n.emit("modelShownFloorChange",t.model.shownFloor,t.model.floorLength)}),n.on("render",function(t){n.emit("renderFrame",t.needsRender)}),n.on("mode.change.request",function(t){n.emit("wantsChangeMode",t.mode,t.prevMode)}),n.on("mode.change",function(t){n.emit("modeChange",t.mode,t.prevMode,t.state.panoIndex,t.state,t.userAction)}),n.on("helpers.visible",function(t){n.emit("helpersVisibleChange",t.object.visible)}),n.on("network.resource",function(t){n.emit("network",t.source,t.requestType,t.requestState,t.detail)})}function generateDefaultVideoElement(){if(typeof window!="undefined"){var n=document.createElement("video");n.loop=!0,n.autoplay=!0,n.playsInline=!0,n.muted=!0,n.crossOrigin="";var t=function(){document.removeEventListener("touchstart",t,!1),document.removeEventListener("mousedown",t,!1),n.muted=!1};return document.addEventListener("touchstart",t,!1),document.addEventListener("mousedown",t,!1),n}else return{}}function initLights(n){var t=new THREE__namespace.Group;t.name="internalLights";{var e=new THREE__namespace.DirectionalLight(16777215,.3);e.position.copy(new THREE__namespace.Vector3(1,1,1)),t.add(e)}{var e=new THREE__namespace.DirectionalLight(16777215,.1);e.position.copy(new THREE__namespace.Vector3(-1,-1,-1)),t.add(e)}{var e=new THREE__namespace.DirectionalLight(16777215,.1);t.add(e)}{var e=new THREE__namespace.AmbientLight(16777215,.6);t.add(e)}n.add(t)}function parseKeyValue(n){for(var t,e,r={},o=n.split(/(\;|\,)/),s=0,u=o;s<u.length;s++){var l=u[s],c=l.split("="),f=(t=c[0])===null||t===void 0?void 0:t.trim(),d=(e=c[1])===null||e===void 0?void 0:e.trim();f&&d&&(r[f]=d)}return r}function getViewportScale(){var n;if(typeof document!="undefined")for(var t=document.getElementsByTagName("meta"),e=0;e<t.length;e++){var r=t[e];if(r.getAttribute("name")==="viewport"){var o=parseKeyValue((n=r.getAttribute("content"))!==null&&n!==void 0?n:""),s=Number(o["initial-scale"]);if(!isNaN(s))return s}}return 1}const textureURL="data:image/png;base64,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";var imageSize=[351,63],imageOffset=[20,20],vertices=new Float32Array([-.5,-.5,0,.5,-.5,0,-.5,.5,0,.5,.5,0]),uvs=new Float32Array([0,0,1,0,0,1,1,1]),index=new Uint8Array([0,1,2,1,3,2]),geometry=new THREE__namespace.BufferGeometry;geometry.setAttribute("position",new THREE__namespace.BufferAttribute(vertices,3)),geometry.setAttribute("uv",new THREE__namespace.BufferAttribute(uvs,2)),geometry.setIndex(new THREE__namespace.BufferAttribute(index,1));var material=new THREE__namespace.MeshBasicMaterial({transparent:!0,depthTest:!1,depthWrite:!1,stencilWrite:!1,fog:!1}),mesh=new THREE__namespace.Mesh(geometry,material);mesh.matrixAutoUpdate=!1;var scene=new THREE__namespace.Scene;scene.add(mesh),scene.matrixAutoUpdate=!1;var camera=new THREE__namespace.OrthographicCamera(-.5,.5,.5,-.5,.1,1);camera.position.set(0,0,.5),camera.lookAt(0,0,0),camera.updateMatrixWorld(!0),camera.matrixAutoUpdate=!1;var prevViewport=new THREE__namespace.Vector4,prevScissor=new THREE__namespace.Vector4;function renderPoweredByRealsee(n){if(material.map){var r=n.getViewport(prevViewport),o=n.getScissor(prevScissor),s=n.getScissorTest(),u=n.autoClear,l=o.x+imageOffset[0]/3,c=o.y+imageOffset[1]/3,f=imageSize[0]/3,d=imageSize[1]/3;n.setViewport(l,c,f,d),n.setScissor(l,c,f,d),n.setScissorTest(!0),n.autoClear=!1,n.render(scene,camera),n.setViewport(r),n.setScissor(o),n.setScissorTest(s),n.autoClear=u}else{var t=new THREE__namespace.Texture,e=new Image;e.onload=function(){t.image=e,t.wrapS=THREE__namespace.ClampToEdgeWrapping,t.wrapT=THREE__namespace.ClampToEdgeWrapping,t.minFilter=THREE__namespace.LinearFilter,t.needsUpdate=!0,t.generateMipmaps=!1,material.needsUpdate=!0,e.onload=noop$1},e.src=textureURL,material.map=t}}var DEFAULT_MODE_CHANGE_DURATION=800,DEFAULT_CAMERA_FOV=90,DEFAULT_REQUEST_PROXY=function(n){return n.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/")},sharedVector2=new THREE__namespace.Vector2,sharedSphere=new THREE__namespace.Sphere,sharedFrustum=new THREE__namespace.Frustum,sharedProjScreenMatrix=new THREE__namespace.Matrix4,clockForMixer=new WeakMap,worksMap=new WeakMap,emptyWorks=createWorks([]),Five=function(n){__extends(t,n);function t(e){e===void 0&&(e={});var r,o,s,u,l,c,f,d,p,v,g,h=n.call(this)||this;if(h.ident=createUuid(),typeof window!="undefined"&&(__FIVE_DEBUG__.instances[h.ident]=h),h.renderSwitch01=0,h.currentMode="Panorama",h.pano={workCode:"",panoIndex:0},h.needsRender=!1,h.modelSceneNeedsRender=!1,h.onlyRenderIfNeeds=(r=e.onlyRenderIfNeeds)!==null&&r!==void 0?r:!0,h.imageOptions=__assign({},(o=e.imageOptions)!==null&&o!==void 0?o:{}),h.textureOptions=__assign({},(s=e.textureOptions)!==null&&s!==void 0?s:{}),h.poweredByRealsee=(u=e.poweredByRealsee)!==null&&u!==void 0?u:!0,h.extraElements=[],h.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)},h.fps={testCount:0,testTime:now()},h.info=null,h.modeChangeDuration=(l=e.modeChangeDuration)!==null&&l!==void 0?l:DEFAULT_MODE_CHANGE_DURATION,h.enableWheel=(c=e.enableWheel)!==null&&c!==void 0?c:!0,typeof window!="undefined")if("renderer"in e)e.renderer instanceof InternalWebGLRenderer&&h.throwError(new Error("cannot render a internal renderer")),h.renderer=e.renderer;else try{h.renderer=new InternalWebGLRenderer({preserveDrawingBuffer:e.preserveDrawingBuffer,backgroundColor:e.backgroundColor,backgroundAlpha:e.backgroundAlpha,antialias:e.antialias,webgl2:e.webgl2,logarithmicDepthBuffer:e.logarithmicDepthBuffer,precision:e.precision,powerPreference:e.powerPreference});var m=getViewportScale();h.renderer.setPixelRatio(m===1?window.devicePixelRatio:1),h.renderer.setSize(512,512)}catch(H){H instanceof Error&&h.throwError(H)}h.getPixelsRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{encoding:(d=(f=h.renderer)===null||f===void 0?void 0:f.outputEncoding)!==null&&d!==void 0?d:THREE__namespace.sRGBEncoding,generateMipmaps:!1});var y=new THREE__namespace.DepthTexture(1,1);y.generateMipmaps=!1,y.format=THREE__namespace.DepthStencilFormat,y.type=THREE__namespace.UnsignedInt248Type,h.modelRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{encoding:(v=(p=h.renderer)===null||p===void 0?void 0:p.outputEncoding)!==null&&v!==void 0?v:THREE__namespace.sRGBEncoding,depthTexture:y,generateMipmaps:!1,depthBuffer:!0,stencilBuffer:!0}),h.scissor=Object.assign({left:0,bottom:0,width:1,height:1},e.scissor),h.camera=new Camera(DEFAULT_CAMERA_FOV),h.scene=new Scene,h.xrCustomObjectsScene=new THREE__namespace.Scene,h.scene.add(h.xrCustomObjectsScene),h.scene.matrixAutoUpdate=!1,h.lastLoadWorkTask=Promise.resolve(),h.requestProxy=(g=e.requestProxy)!==null&&g!==void 0?g:DEFAULT_REQUEST_PROXY,h.networkSubscribe=new NetworkSubscribe,h.networkSubscribe.on("network",function(H,w,C,F){var I;h.emit("network.resource",createEvent("network.resource",{source:H,requestType:w,requestState:C,detail:F})),(I=h.analysis)===null||I===void 0||I.network(h.works,H,w,C,F)}),h.boundingMesh=generateBoundingMesh(new THREE__namespace.Box3(new THREE__namespace.Vector3(-.5,-.5,-.5),new THREE__namespace.Vector3(.5,.5,.5))),h.boundingMesh.name="bounding",h.models=createModels(),h.models.push(new Model),h.lastModels=createModels(),h.lastWorks=createWorks([]),h.readyCallbacks=[],h.syncingState=!1,h.helperGroup=new THREE__namespace.Group,h.helperGroup.name="helper",h.helperGroup.matrixAutoUpdate=!1,h.scene.add(h.helperGroup),h.modelGroup=new THREE__namespace.Group,h.modelGroup.visible=!1,h.modelGroup.name="model",h.modelGroup.matrixAutoUpdate=!1,h.modelScene=new THREE__namespace.Scene,h.modelScene.add(h.modelGroup),h.modelScene.add(h.boundingMesh),h.modelScene.matrixAutoUpdate=!1,h.videoTexture=new THREE__namespace.VideoTexture(e.videoInstance||generateDefaultVideoElement()),initLights(h.scene),initLights(h.modelScene),h.state={mode:h.currentMode,workCode:h.pano.workCode,panoIndex:h.pano.panoIndex,longitude:h.camera.pose.longitude,latitude:h.camera.pose.latitude,fov:h.camera.pose.fov,offset:h.camera.pose.offset.clone(),distance:h.camera.pose.distance},h.stateSynced=!1,h._enablePostProcessing=!1,h._enableIOSEDR=!1,h._enableEDL=!1,h._enableHQ=!1,h.destroyed=!1,h.paused=!0,typeof window!="undefined"&&(e.play!==!1&&h.play(),h.stopAnimationLoop=AnimationFrameLoop.shared.add(function(H,w){for(var C=[],F=2;F<arguments.length;F++)C[F-2]=arguments[F];h.updateTime.apply(h,__spreadArray([H,w],C,!1))},!1,0,10));var A=function(){typeof document!="undefined"&&document.fullscreenElement===null&&h.currentMode==="VRPanorama"&&h.controller.emit("vr.requestExit",createEvent("vr.requestExit",{}))},E=function(){h.needsRender=!0,h.modelSceneNeedsRender=!0};if(typeof document!="undefined"&&document.addEventListener("fullscreenchange",A,!1),h.renderer&&h.renderer.domElement.addEventListener("webglcontextrestored",E,!1),h.removeEventListeners=function(){typeof document!="undefined"&&document.removeEventListener("fullscreenchange",A,!1),h.renderer&&h.renderer.domElement.removeEventListener("webglcontextrestored",E,!1)},h.plugins={},e.plugins&&e.plugins.length)for(var b=0,T=e.plugins;b<T.length;b++){var _=T[b];if(typeof _=="function")_(h);else if(Array.isArray(_)){var R=_[0],S=_[1],M=_[2];if(typeof R=="function"){var B=R(h,M);typeof S=="string"&&(h.plugins[S]?h.throwError(new Error("plugin name ".concat(S," is exists."))):h.plugins[S]=B)}}}return h.gpuPickingRenderTarget=new THREE__namespace.WebGLRenderTarget(1,1,{generateMipmaps:!1}),h.meshReplaceMaterialMap=new Map,h.meshOriginMaterialMap=new Map,initLegacyEvent(h),h}return Object.defineProperty(t,"version",{get:function(){return"6.4.0-alpha.14"},enumerable:!1,configurable:!0}),Object.defineProperty(t,"dracoPath",{get:function(){return draco.decoderPath},set:function(e){draco.setDecoderPath(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ktx2Path",{get:function(){return ktx2.transcoderPath},set:function(e){ktx2.setTranscoderPath(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"panoIndex",{get:function(){return this.pano.panoIndex},enumerable:!1,configurable:!0}),t.prototype.getGPUPicking=function(e,r,o,s,u){var l=this;if(s===void 0&&(s=1),u===void 0&&(u=new THREE__namespace.Vector3(0,0,0)),!this.renderer)throw new Error("renderer is not initialized.");var c=this.models.getMaterial(),f=c.constantColor,d=c.colorStyle;this.models.setMaterial({colorStyle:"CONSTANT",constantColor:u}),this.scene.traverse(function(h){if(!(!(h instanceof THREE__namespace.Mesh)||h instanceof PBMMesh)){var m=Object.keys(o).filter(function(A){return A===h.uuid})[0];if(m)if(l.meshOriginMaterialMap.set(m,h.material),l.meshReplaceMaterialMap.get(m))h.material=l.meshReplaceMaterialMap.get(m);else{var y=new THREE__namespace.ShaderMaterial({uniforms:{color:{value:o[m]}},vertexShader:`
2170
2170
  void main() {
2171
2171
  vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
2172
2172
  gl_Position = projectionMatrix * mvPosition;