fluidcad 0.0.19 → 0.0.21
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/lib/dist/features/2d/rect.d.ts +1 -0
- package/lib/dist/features/2d/rect.js +13 -9
- package/lib/dist/filters/edge/edge-filter.d.ts +0 -14
- package/lib/dist/filters/edge/edge-filter.js +2 -0
- package/lib/dist/filters/face/face-filter.d.ts +0 -14
- package/lib/dist/filters/face/face-filter.js +2 -0
- package/lib/dist/oc/wire-ops.js +4 -1
- package/lib/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/server/dist/code-editor.js +7 -4
- package/ui/dist/assets/{index-Bz0YoaQD.js → index-B1LkrBga.js} +7 -7
- package/ui/dist/index.html +1 -1
|
@@ -3829,7 +3829,7 @@ void main() {
|
|
|
3829
3829
|
|
|
3830
3830
|
}
|
|
3831
3831
|
|
|
3832
|
-
}`,fl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Xi(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new qr({vertexShader:ul,fragmentShader:dl,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new G(new aa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pl=class extends He{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,u=null,d=null,f=null,p=null,h=null,g=typeof XRWebGLBinding<`u`,_=new fl,v={},b=t.getContextAttributes(),x=null,S=null,C=[],D=[],ee=new z,O=null,k=new Qr;k.viewport=new Lt;let te=new Qr;te.viewport=new Lt;let ne=[k,te],A=new za,re=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getHandSpace()};function M(e){let t=D.indexOf(e.inputSource);if(t===-1)return;let n=C[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function ie(){r.removeEventListener(`select`,M),r.removeEventListener(`selectstart`,M),r.removeEventListener(`selectend`,M),r.removeEventListener(`squeeze`,M),r.removeEventListener(`squeezestart`,M),r.removeEventListener(`squeezeend`,M),r.removeEventListener(`end`,ie),r.removeEventListener(`inputsourceschange`,ae);for(let e=0;e<C.length;e++){let t=D[e];t!==null&&(D[e]=null,C[e].disconnect(t))}re=null,j=null,_.reset();for(let e in v)delete v[e];e.setRenderTarget(x),p=null,f=null,d=null,r=null,S=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(O),e.setSize(ee.width,ee.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return f===null?p:f},this.getBinding=function(){return d===null&&g&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(u){if(r=u,r!==null){if(x=e.getRenderTarget(),r.addEventListener(`select`,M),r.addEventListener(`selectstart`,M),r.addEventListener(`selectend`,M),r.addEventListener(`squeeze`,M),r.addEventListener(`squeezestart`,M),r.addEventListener(`squeezeend`,M),r.addEventListener(`end`,ie),r.addEventListener(`inputsourceschange`,ae),b.xrCompatible!==!0&&await t.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(ee),g&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;b.depth&&(o=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=b.stencil?E:T,a=b.stencil?y:m);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};d=this.getBinding(),f=d.createProjectionLayer(s),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),S=new zt(f.textureWidth,f.textureHeight,{format:w,type:l,depthTexture:new Yi(f.textureWidth,f.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let n={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:i};p=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new zt(p.framebufferWidth,p.framebufferHeight,{format:w,type:l,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),pe.setContext(r),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function ae(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=D.indexOf(n);r>=0&&(D[r]=null,C[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=D.indexOf(n);if(r===-1){for(let e=0;e<C.length;e++)if(e>=D.length){D.push(n),r=e;break}else if(D[e]===null){D[e]=n,r=e;break}if(r===-1)break}let i=C[r];i&&i.connect(n)}}let oe=new B,se=new B;function ce(e,t,n){oe.setFromMatrixPosition(t.matrixWorld),se.setFromMatrixPosition(n.matrixWorld);let r=oe.distanceTo(se),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function le(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;_.texture!==null&&(_.depthNear>0&&(t=_.depthNear),_.depthFar>0&&(n=_.depthFar)),A.near=te.near=k.near=t,A.far=te.far=k.far=n,(re!==A.near||j!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),re=A.near,j=A.far),A.layers.mask=e.layers.mask|6,k.layers.mask=A.layers.mask&3,te.layers.mask=A.layers.mask&5;let i=e.parent,a=A.cameras;le(A,i);for(let e=0;e<a.length;e++)le(a[e],i);a.length===2?ce(A,k,te):A.projectionMatrix.copy(k.projectionMatrix),ue(e,A,i)};function ue(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Ke*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&p===null))return s},this.setFoveation=function(e){s=e,f!==null&&(f.fixedFoveation=e),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=e)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(A)},this.getCameraTexture=function(e){return v[e]};let de=null;function fe(t,i){if(u=i.getViewerPose(c||a),h=i,u!==null){let t=u.views;p!==null&&(e.setRenderTargetFramebuffer(S,p.framebuffer),e.setRenderTarget(S));let i=!1;t.length!==A.cameras.length&&(A.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(p!==null)a=p.getViewport(r);else{let t=d.getViewSubImage(f,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let o=ne[n];o===void 0&&(o=new Qr,o.layers.enable(n),o.viewport=new Lt,ne[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(A.matrix.copy(o.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),i===!0&&A.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&g){d=n.getBinding();let e=d.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&_.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&g){e.state.unbindTexture(),d=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=v[n];e||(e=new Xi,v[n]=e);let t=d.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<C.length;e++){let t=D[e],n=C[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}de&&de(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),h=null}let pe=new _o;pe.setAnimationLoop(fe),this.setAnimationLoop=function(e){de=e},this.dispose=function(){}}},ml=new En,hl=new gn;function gl(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,Ur(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial||t.isMeshLambertMaterial?a(e,t):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ml.copy(o),ml.x*=-1,ml.y*=-1,ml.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ml.y*=-1,ml.z*=-1),e.envMapRotation.value.setFromMatrix4(hl.makeRotationFromEuler(ml)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function _l(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return console.error(`THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var vl=class{constructor(e={}){let{canvas:t=bt(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:u=!1,powerPreference:d=`default`,failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);m=n.getContextAttributes().alpha}else m=a;let h=new Uint32Array(4),_=new Int32Array(4),v=null,y=null,b=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,C=!1;this._outputColorSpace=Fe;let w=0,T=0,E=null,D=-1,ee=null,O=new Lt,k=new Lt,te=null,ne=new U(0),A=0,re=t.width,j=t.height,M=1,ie=null,ae=null,oe=new Lt(0,0,re,j),se=new Lt(0,0,re,j),ce=!1,le=new Pi,ue=!1,de=!1,fe=new gn,pe=new B,me=new Lt,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ge=!1;function _e(){return E===null?M:1}let N=n;function ve(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r180`),t.addEventListener(`webglcontextlost`,Ge,!1),t.addEventListener(`webglcontextrestored`,Ke,!1),t.addEventListener(`webglcontextcreationerror`,qe,!1),N===null){let t=`webgl2`;if(N=ve(t,e),N===null)throw ve(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw console.error(`THREE.WebGLRenderer: `+e.message),e}let ye,be,P,xe,F,I,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Le,Re,ze,Be,He;function Ue(){ye=new Zo(N),ye.init(),ze=new ll(N,ye),be=new Eo(N,ye,e,ze),P=new sl(N,ye),be.reversedDepthBuffer&&p&&P.buffers.depth.setReversed(!0),xe=new es(N),F=new Gc,I=new cl(N,ye,P,F,be,ze,xe),Se=new Oo(S),Ce=new Xo(S),we=new vo(N),Be=new wo(N,we),Te=new Qo(N,we,xe,Be),Ee=new ns(N,Te,we,xe),Pe=new ts(N,be,I),je=new Do(F),De=new Wc(S,Se,Ce,ye,be,Be,je),Oe=new gl(S,F),ke=new Yc,Ae=new nl(ye),Ne=new Co(S,Se,Ce,P,Ee,m,s),Me=new al(S,Ee,be),He=new _l(N,xe,be,P),Le=new To(N,ye,xe),Re=new $o(N,ye,xe),xe.programs=De.programs,S.capabilities=be,S.extensions=ye,S.properties=F,S.renderLists=ke,S.shadowMap=Me,S.state=P,S.info=xe}Ue();let We=new pl(S,N);this.xr=We,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let e=ye.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=ye.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return M},this.setPixelRatio=function(e){e!==void 0&&(M=e,this.setSize(re,j,!1))},this.getSize=function(e){return e.set(re,j)},this.setSize=function(e,n,r=!0){if(We.isPresenting){console.warn(`THREE.WebGLRenderer: Can't change size while VR device is presenting.`);return}re=e,j=n,t.width=Math.floor(e*M),t.height=Math.floor(n*M),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(re*M,j*M).floor()},this.setDrawingBufferSize=function(e,n,r){re=e,j=n,M=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(oe)},this.setViewport=function(e,t,n,r){e.isVector4?oe.set(e.x,e.y,e.z,e.w):oe.set(e,t,n,r),P.viewport(O.copy(oe).multiplyScalar(M).round())},this.getScissor=function(e){return e.copy(se)},this.setScissor=function(e,t,n,r){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,n,r),P.scissor(k.copy(se).multiplyScalar(M).round())},this.getScissorTest=function(){return ce},this.setScissorTest=function(e){P.setScissorTest(ce=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor(...arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(E!==null){let t=E.texture.format;e=t===1033||t===1031||t===1029}if(e){let e=E.texture.type,t=e===1009||e===1014||e===1012||e===1020||e===1017||e===1018,n=Ne.getClearColor(),r=Ne.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(h[0]=i,h[1]=a,h[2]=o,h[3]=r,N.clearBufferuiv(N.COLOR,0,h)):(_[0]=i,_[1]=a,_[2]=o,_[3]=r,N.clearBufferiv(N.COLOR,0,_))}else r|=N.COLOR_BUFFER_BIT}t&&(r|=N.DEPTH_BUFFER_BIT),n&&(r|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Ge,!1),t.removeEventListener(`webglcontextrestored`,Ke,!1),t.removeEventListener(`webglcontextcreationerror`,qe,!1),Ne.dispose(),ke.dispose(),Ae.dispose(),F.dispose(),Se.dispose(),Ce.dispose(),Ee.dispose(),Be.dispose(),He.dispose(),De.dispose(),We.dispose(),We.removeEventListener(`sessionstart`,$e),We.removeEventListener(`sessionend`,et),tt.stop()};function Ge(e){e.preventDefault(),console.log(`THREE.WebGLRenderer: Context Lost.`),C=!0}function Ke(){console.log(`THREE.WebGLRenderer: Context Restored.`),C=!1;let e=xe.autoReset,t=Me.enabled,n=Me.autoUpdate,r=Me.needsUpdate,i=Me.type;Ue(),xe.autoReset=e,Me.enabled=t,Me.autoUpdate=n,Me.needsUpdate=r,Me.type=i}function qe(e){console.error(`THREE.WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function L(e){let t=e.target;t.removeEventListener(`dispose`,L),Je(t)}function Je(e){Ye(e),F.remove(e)}function Ye(e){let t=F.get(e).programs;t!==void 0&&(t.forEach(function(e){De.releaseProgram(e)}),e.isShaderMaterial&&De.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=he);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=ut(e,t,n,r,i);P.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=Te.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Be.setup(i,r,s,n,c);let h,g=Le;if(c!==null&&(h=we.get(c),g=Re,g.setIndex(h)),i.isMesh)r.wireframe===!0?(P.setLineWidth(r.wireframeLinewidth*_e()),g.setMode(N.LINES)):g.setMode(N.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),P.setLineWidth(e*_e()),i.isLineSegments?g.setMode(N.LINES):i.isLineLoop?g.setMode(N.LINE_LOOP):g.setMode(N.LINE_STRIP)}else i.isPoints?g.setMode(N.POINTS):i.isSprite&&g.setMode(N.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)St(`THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(ye.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?we.get(c).bytesPerElement:1,o=F.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(N,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Xe(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,st(e,t,n),e.side=0,e.needsUpdate=!0,st(e,t,n),e.side=2):st(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),y=Ae.get(n),y.init(t),x.push(y),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(y.pushLight(e),e.castShadow&&y.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(y.pushLight(e),e.castShadow&&y.pushShadow(e))}),y.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Xe(a,n,e),r.add(a)}else Xe(t,n,e),r.add(t)}),y=x.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){F.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}ye.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ze=null;function Qe(e){Ze&&Ze(e)}function $e(){tt.stop()}function et(){tt.start()}let tt=new _o;tt.setAnimationLoop(Qe),typeof self<`u`&&tt.setContext(self),this.setAnimationLoop=function(e){Ze=e,We.setAnimationLoop(e),e===null?tt.stop():tt.start()},We.addEventListener(`sessionstart`,$e),We.addEventListener(`sessionend`,et),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(C===!0)return;if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(t),t=We.getCamera()),e.isScene===!0&&e.onBeforeRender(S,e,t,E),y=Ae.get(e,x.length),y.init(t),x.push(y),fe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),le.setFromProjectionMatrix(fe,Ve,t.reversedDepth),de=this.localClippingEnabled,ue=je.init(this.clippingPlanes,de),v=ke.get(e,b.length),v.init(),b.push(v),We.enabled===!0&&We.isPresenting===!0){let e=S.xr.getDepthSensingMesh();e!==null&&nt(e,t,-1/0,S.sortObjects)}nt(e,t,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ie,ae),ge=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,ge&&Ne.addToRenderList(v,e),this.info.render.frame++,ue===!0&&je.beginShadows();let n=y.state.shadowsArray;Me.render(n,e,t),ue===!0&&je.endShadows(),this.info.autoReset===!0&&this.info.reset();let r=v.opaque,i=v.transmissive;if(y.setupLights(),t.isArrayCamera){let n=t.cameras;if(i.length>0)for(let t=0,a=n.length;t<a;t++){let a=n[t];it(r,i,e,a)}ge&&Ne.render(e);for(let t=0,r=n.length;t<r;t++){let r=n[t];rt(v,e,r,r.viewport)}}else i.length>0&&it(r,i,e,t),ge&&Ne.render(e),rt(v,e,t);E!==null&&T===0&&(I.updateMultisampleRenderTarget(E),I.updateRenderTargetMipmap(E)),e.isScene===!0&&e.onAfterRender(S,e,t),Be.resetDefaultState(),D=-1,ee=null,x.pop(),x.length>0?(y=x[x.length-1],ue===!0&&je.setGlobalState(S.clippingPlanes,y.state.camera)):y=null,b.pop(),v=b.length>0?b[b.length-1]:null};function nt(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)y.pushLight(e),e.castShadow&&y.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||le.intersectsSprite(e)){r&&me.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe);let t=Ee.update(e),i=e.material;i.visible&&v.push(e,t,i,n,me.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||le.intersectsObject(e))){let t=Ee.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),me.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),me.copy(e.boundingSphere.center)),me.applyMatrix4(e.matrixWorld).applyMatrix4(fe)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&v.push(e,t,s,n,me.z,o)}}else i.visible&&v.push(e,t,i,n,me.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)nt(i[e],t,n,r)}function rt(e,t,n,r){let i=e.opaque,a=e.transmissive,o=e.transparent;y.setupLightsView(n),ue===!0&&je.setGlobalState(S.clippingPlanes,n),r&&P.viewport(O.copy(r)),i.length>0&&at(i,t,n),a.length>0&&at(a,t,n),o.length>0&&at(o,t,n),P.buffers.depth.setTest(!0),P.buffers.depth.setMask(!0),P.buffers.color.setMask(!0),P.setPolygonOffset(!1)}function it(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[r.id]===void 0&&(y.state.transmissionRenderTarget[r.id]=new zt(1,1,{generateMipmaps:!0,type:ye.has(`EXT_color_buffer_half_float`)||ye.has(`EXT_color_buffer_float`)?g:l,minFilter:c,samples:4,stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:H.workingColorSpace}));let a=y.state.transmissionRenderTarget[r.id],o=r.viewport||O;a.setSize(o.z*S.transmissionResolutionScale,o.w*S.transmissionResolutionScale);let s=S.getRenderTarget(),u=S.getActiveCubeFace(),d=S.getActiveMipmapLevel();S.setRenderTarget(a),S.getClearColor(ne),A=S.getClearAlpha(),A<1&&S.setClearColor(16777215,.5),S.clear(),ge&&Ne.render(n);let f=S.toneMapping;S.toneMapping=0;let p=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),y.setupLightsView(r),ue===!0&&je.setGlobalState(S.clippingPlanes,r),at(e,n,r),I.updateMultisampleRenderTarget(a),I.updateRenderTargetMipmap(a),ye.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=a.object,s=a.geometry,c=a.material,l=a.group;if(c.side===2&&o.layers.test(r.layers)){let t=c.side;c.side=1,c.needsUpdate=!0,ot(o,n,r,s,c,l),c.side=t,c.needsUpdate=!0,e=!0}}e===!0&&(I.updateMultisampleRenderTarget(a),I.updateRenderTargetMipmap(a))}S.setRenderTarget(s,u,d),S.setClearColor(ne,A),p!==void 0&&(r.viewport=p),S.toneMapping=f}function at(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=a.object,s=a.geometry,c=a.group,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&ot(o,t,n,s,l,c)}}function ot(e,t,n,r,i,a){e.onBeforeRender(S,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(S,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,S.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,S.renderBufferDirect(n,t,r,i,e,a),i.side=2):S.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(S,t,n,r,i,a)}function st(e,t,n){t.isScene!==!0&&(t=he);let r=F.get(e),i=y.state.lights,a=y.state.shadowsArray,o=i.state.version,s=De.getParameters(e,i.state,a,t,n),c=De.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?Ce:Se).get(e.envMap||r.environment),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,L),l=new Map,r.programs=l);let u=l.get(c);if(u!==void 0){if(r.currentProgram===u&&r.lightsStateVersion===o)return lt(e,s),u}else s.uniforms=De.getUniforms(e),e.onBeforeCompile(s,S),u=De.acquireProgram(s,c),l.set(c,u),r.uniforms=s.uniforms;let d=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(d.clippingPlanes=je.uniform),lt(e,s),r.needsLights=ft(e),r.lightsStateVersion=o,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotLightMatrix.value=i.state.spotLightMatrix,d.spotLightMap.value=i.state.spotLightMap,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=u,r.uniformsList=null,u}function ct(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=lc.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function lt(e,t){let n=F.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function ut(e,t,n,r,i){t.isScene!==!0&&(t=he),I.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=E===null?S.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Ie,c=(r.isMeshStandardMaterial?Ce:Se).get(r.envMap||o),l=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,u=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(m=S.toneMapping);let h=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=h===void 0?0:h.length,_=F.get(r),v=y.state.lights;if(ue===!0&&(de===!0||e!==ee)){let t=e===ee&&r.id===D;je.setState(r,e,t)}let b=!1;r.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version?b=!0:_.outputColorSpace===s?i.isBatchedMesh&&_.batching===!1||!i.isBatchedMesh&&_.batching===!0||i.isBatchedMesh&&_.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&_.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&_.instancing===!1||!i.isInstancedMesh&&_.instancing===!0||i.isSkinnedMesh&&_.skinning===!1||!i.isSkinnedMesh&&_.skinning===!0||i.isInstancedMesh&&_.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&_.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&_.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&_.instancingMorph===!1&&i.morphTexture!==null?b=!0:_.envMap===c?r.fog===!0&&_.fog!==a||_.numClippingPlanes!==void 0&&(_.numClippingPlanes!==je.numPlanes||_.numIntersection!==je.numIntersection)?b=!0:_.vertexAlphas===l&&_.vertexTangents===u&&_.morphTargets===d&&_.morphNormals===f&&_.morphColors===p&&_.toneMapping===m?_.morphTargetsCount!==g&&(b=!0):b=!0:b=!0:b=!0:(b=!0,_.__version=r.version);let x=_.currentProgram;b===!0&&(x=st(r,t,i));let C=!1,w=!1,T=!1,O=x.getUniforms(),k=_.uniforms;if(P.useProgram(x.program)&&(C=!0,w=!0,T=!0),r.id!==D&&(D=r.id,w=!0),C||ee!==e){P.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(N,`projectionMatrix`,e.projectionMatrix),O.setValue(N,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(N,pe.setFromMatrixPosition(e.matrixWorld)),be.logarithmicDepthBuffer&&O.setValue(N,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(N,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,T=!0)}if(i.isSkinnedMesh){O.setOptional(N,i,`bindMatrix`),O.setOptional(N,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(N,`boneTexture`,e.boneTexture,I))}i.isBatchedMesh&&(O.setOptional(N,i,`batchingTexture`),O.setValue(N,`batchingTexture`,i._matricesTexture,I),O.setOptional(N,i,`batchingIdTexture`),O.setValue(N,`batchingIdTexture`,i._indirectTexture,I),O.setOptional(N,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(N,`batchingColorTexture`,i._colorsTexture,I));let te=n.morphAttributes;if((te.position!==void 0||te.normal!==void 0||te.color!==void 0)&&Pe.update(i,n,x),(w||_.receiveShadow!==i.receiveShadow)&&(_.receiveShadow=i.receiveShadow,O.setValue(N,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(k.envMap.value=c,k.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),r.isMeshStandardMaterial&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),w&&(O.setValue(N,`toneMappingExposure`,S.toneMappingExposure),_.needsLights&&dt(k,T),a&&r.fog===!0&&Oe.refreshFogUniforms(k,a),Oe.refreshMaterialUniforms(k,r,M,j,y.state.transmissionRenderTarget[e.id]),lc.upload(N,ct(_),k,I)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(lc.upload(N,ct(_),k,I),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(N,`center`,i.center),O.setValue(N,`modelViewMatrix`,i.modelViewMatrix),O.setValue(N,`normalMatrix`,i.normalMatrix),O.setValue(N,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];He.update(n,x),He.bind(n,x)}}return x}function dt(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function ft(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(e,t,n){let r=F.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),F.get(e.texture).__webglTexture=t,F.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=F.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let R=N.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){E=e,w=t,T=n;let r=!0,i=null,a=!1,o=!1;if(e){let s=F.get(e);if(s.__useDefaultFramebuffer!==void 0)P.bindFramebuffer(N.FRAMEBUFFER,null),r=!1;else if(s.__webglFramebuffer===void 0)I.setupRenderTarget(e);else if(s.__hasExternalTextures)I.rebindTextures(e,F.get(e.texture).__webglTexture,F.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(s.__boundDepthTexture!==t){if(t!==null&&F.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);I.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(o=!0);let l=F.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],a=!0):i=e.samples>0&&I.useMultisampledRTT(e)===!1?F.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),k.copy(e.scissor),te=e.scissorTest}else O.copy(oe).multiplyScalar(M).floor(),k.copy(se).multiplyScalar(M).floor(),te=ce;if(n!==0&&(i=R),P.bindFramebuffer(N.FRAMEBUFFER,i)&&r&&P.drawBuffers(e,i),P.viewport(O),P.scissor(k),P.setScissorTest(te),a){let r=F.get(e.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=t;for(let t=0;t<e.textures.length;t++){let i=F.get(e.textures[t]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=F.get(e.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,t.__webglTexture,n)}D=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=F.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){P.bindFramebuffer(N.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(!be.textureFormatReadable(c)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!be.textureTypeReadable(l)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&(e.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+s),N.readPixels(t,n,r,i,ze.convert(c),ze.convert(l),a))}finally{let e=E===null?null:F.get(E).__webglFramebuffer;P.bindFramebuffer(N.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=F.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){P.bindFramebuffer(N.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(!be.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!be.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,d),N.bufferData(N.PIXEL_PACK_BUFFER,a.byteLength,N.STREAM_READ),e.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+s),N.readPixels(t,n,r,i,ze.convert(l),ze.convert(u),0);let f=E===null?null:F.get(E).__webglFramebuffer;P.bindFramebuffer(N.FRAMEBUFFER,f);let p=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Ct(N,p,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,d),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,a),N.deleteBuffer(d),N.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;I.setTexture2D(e,0),N.copyTexSubImage2D(N.TEXTURE_2D,n,0,0,o,s,i,a),P.unbindTexture()};let pt=N.createFramebuffer(),z=N.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=null){a===null&&(i===0?a=0:(St(`WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.`),a=i,i=0));let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=ze.convert(t.format),_=ze.convert(t.type),v;t.isData3DTexture?(I.setTexture3D(t,0),v=N.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(I.setTexture2DArray(t,0),v=N.TEXTURE_2D_ARRAY):(I.setTexture2D(t,0),v=N.TEXTURE_2D),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,t.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,t.unpackAlignment);let y=N.getParameter(N.UNPACK_ROW_LENGTH),b=N.getParameter(N.UNPACK_IMAGE_HEIGHT),x=N.getParameter(N.UNPACK_SKIP_PIXELS),S=N.getParameter(N.UNPACK_SKIP_ROWS),C=N.getParameter(N.UNPACK_SKIP_IMAGES);N.pixelStorei(N.UNPACK_ROW_LENGTH,h.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,h.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,l),N.pixelStorei(N.UNPACK_SKIP_ROWS,u),N.pixelStorei(N.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=F.get(e),r=F.get(t),h=F.get(n.__renderTarget),g=F.get(r.__renderTarget);P.bindFramebuffer(N.READ_FRAMEBUFFER,h.__webglFramebuffer),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,F.get(e).__webglTexture,i,d+n),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,F.get(t).__webglTexture,a,m+n)),N.blitFramebuffer(l,u,o,s,f,p,o,s,N.DEPTH_BUFFER_BIT,N.NEAREST);P.bindFramebuffer(N.READ_FRAMEBUFFER,null),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||F.has(e)){let n=F.get(e),r=F.get(t);P.bindFramebuffer(N.READ_FRAMEBUFFER,pt),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,z);for(let e=0;e<c;e++)w?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,n.__webglTexture,i),T?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,r.__webglTexture,a),i===0?T?N.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):N.copyTexSubImage2D(v,a,f,p,l,u,o,s):N.blitFramebuffer(l,u,o,s,f,p,o,s,N.COLOR_BUFFER_BIT,N.NEAREST);P.bindFramebuffer(N.READ_FRAMEBUFFER,null),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?N.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?N.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):N.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):N.texSubImage2D(N.TEXTURE_2D,a,f,p,o,s,g,_,h);N.pixelStorei(N.UNPACK_ROW_LENGTH,y),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,b),N.pixelStorei(N.UNPACK_SKIP_PIXELS,x),N.pixelStorei(N.UNPACK_SKIP_ROWS,S),N.pixelStorei(N.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&N.generateMipmap(v),P.unbindTexture()},this.initRenderTarget=function(e){F.get(e).__webglFramebuffer===void 0&&I.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?I.setTextureCube(e,0):e.isData3DTexture?I.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?I.setTexture2DArray(e,0):I.setTexture2D(e,0),P.unbindTexture()},this.resetState=function(){w=0,T=0,E=null,P.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Ve}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=H._getDrawingBufferColorSpace(e),t.unpackColorSpace=H._getUnpackColorSpace()}},yl={LEFT:1,RIGHT:2,MIDDLE:4},J=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),bl={NONE:0,IN:1,OUT:-1};function xl(e){return e.isPerspectiveCamera}function Sl(e){return e.isOrthographicCamera}var Cl=Math.PI*2,wl=Math.PI/2,Tl=1e-5,El=Math.PI/180;function Dl(e,t,n){return Math.max(t,Math.min(n,e))}function Ol(e,t=Tl){return Math.abs(e)<t}function kl(e,t,n=Tl){return Ol(e-t,n)}function Al(e,t){return Math.round(e/t)*t}function jl(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Ml(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function Nl(e,t,n,r,i=1/0,a){r=Math.max(1e-4,r);let o=2/r,s=o*a,c=1/(1+s+.48*s*s+.235*s*s*s),l=e-t,u=t,d=i*r;l=Dl(l,-d,d),t=e-l;let f=(n.value+o*l)*a;n.value=(n.value-o*f)*c;let p=t+(l+f)*c;return u-e>0==p>u&&(p=u,n.value=(p-u)/a),p}function Pl(e,t,n,r,i=1/0,a,o){r=Math.max(1e-4,r);let s=2/r,c=s*a,l=1/(1+c+.48*c*c+.235*c*c*c),u=t.x,d=t.y,f=t.z,p=e.x-u,m=e.y-d,h=e.z-f,g=u,_=d,v=f,y=i*r,b=y*y,x=p*p+m*m+h*h;if(x>b){let e=Math.sqrt(x);p=p/e*y,m=m/e*y,h=h/e*y}u=e.x-p,d=e.y-m,f=e.z-h;let S=(n.x+s*p)*a,C=(n.y+s*m)*a,w=(n.z+s*h)*a;n.x=(n.x-s*S)*l,n.y=(n.y-s*C)*l,n.z=(n.z-s*w)*l,o.x=u+(p+S)*l,o.y=d+(m+C)*l,o.z=f+(h+w)*l;let T=g-e.x,E=_-e.y,D=v-e.z,ee=o.x-g,O=o.y-_,k=o.z-v;return T*ee+E*O+D*k>0&&(o.x=g,o.y=_,o.z=v,n.x=(o.x-g)/a,n.y=(o.y-_)/a,n.z=(o.z-v)/a),o}function Fl(e,t){t.set(0,0),e.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=e.length,t.y/=e.length}function Il(e,t){return Sl(e)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}var Ll=class{_listeners={};addEventListener(e,t){let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e)}}},Rl=`3.1.2`,zl=1/8,Bl=/Mac/.test(globalThis?.navigator?.platform),Y,Vl,Hl,Ul,Wl,X,Z,Gl,Kl,ql,Jl,Yl,Xl,Zl,Ql,$l,eu,tu,nu,ru,iu,au,ou,su=class e extends Ll{static install(e){Y=e.THREE,Vl=Object.freeze(new Y.Vector3(0,0,0)),Hl=Object.freeze(new Y.Vector3(0,1,0)),Ul=Object.freeze(new Y.Vector3(0,0,1)),Wl=new Y.Vector2,X=new Y.Vector3,Z=new Y.Vector3,Gl=new Y.Vector3,Kl=new Y.Vector3,ql=new Y.Vector3,Jl=new Y.Vector3,Yl=new Y.Vector3,Xl=new Y.Vector3,Zl=new Y.Vector3,Ql=new Y.Spherical,$l=new Y.Spherical,eu=new Y.Box3,tu=new Y.Box3,nu=new Y.Sphere,ru=new Y.Quaternion,iu=new Y.Quaternion,au=new Y.Matrix4,ou=new Y.Raycaster}static get ACTION(){return J}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=2**-52;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=J.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=bl.NONE;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new Y.Vector3;_focalOffsetVelocity=new Y.Vector3;_zoomVelocity={value:0};set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(t,n){super(),Y===void 0&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new Y.Quaternion().setFromUnitVectors(this._camera.up,Hl),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=J.NONE,this._target=new Y.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new Y.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new Y.Spherical().setFromVector3(X.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new Y.Vector3,new Y.Vector3,new Y.Vector3,new Y.Vector3],this._updateNearPlaneCorners(),this._boundary=new Y.Box3(new Y.Vector3(-1/0,-1/0,-1/0),new Y.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new Y.Vector2,this.mouseButtons={left:J.ROTATE,middle:J.DOLLY,right:J.TRUCK,wheel:xl(this._camera)?J.DOLLY:Sl(this._camera)?J.ZOOM:J.NONE},this.touches={one:J.TOUCH_ROTATE,two:xl(this._camera)?J.TOUCH_DOLLY_TRUCK:Sl(this._camera)?J.TOUCH_ZOOM_TRUCK:J.NONE,three:J.TOUCH_TRUCK};let r=new Y.Vector2,i=new Y.Vector2,a=new Y.Vector2,o=e=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(n<this._interactiveArea.left||n>this._interactiveArea.right||r<this._interactiveArea.top||r>this._interactiveArea.bottom)return}let t=e.pointerType===`mouse`?(e.buttons&yl.LEFT)===yl.LEFT?yl.LEFT:(e.buttons&yl.MIDDLE)===yl.MIDDLE?yl.MIDDLE:(e.buttons&yl.RIGHT)===yl.RIGHT?yl.RIGHT:null:null;if(t!==null){let e=this._findPointerByMouseButton(t);e&&this._disposePointer(e)}if((e.buttons&yl.LEFT)===yl.LEFT&&this._lockedPointer)return;let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),this._isDragging=!0,f(e)},s=e=>{e.cancelable&&e.preventDefault();let t=e.pointerId,n=this._lockedPointer||this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,this._state=0,e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else (!this._isDragging&&this._lockedPointer||this._isDragging&&(e.buttons&yl.LEFT)===yl.LEFT)&&(this._state|=this.mouseButtons.left),this._isDragging&&(e.buttons&yl.MIDDLE)===yl.MIDDLE&&(this._state|=this.mouseButtons.middle),this._isDragging&&(e.buttons&yl.RIGHT)===yl.RIGHT&&(this._state|=this.mouseButtons.right);p()}},c=e=>{let t=this._findPointerById(e.pointerId);if(!(t&&t===this._lockedPointer)){if(t&&this._disposePointer(t),e.pointerType===`touch`)switch(this._activePointers.length){case 0:this._state=J.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=J.NONE;m()}},l=-1,u=e=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===J.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(n<this._interactiveArea.left||n>this._interactiveArea.right||r<this._interactiveArea.top||r>this._interactiveArea.bottom)return}if(e.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===J.ROTATE||this.mouseButtons.wheel===J.TRUCK){let e=performance.now();l-e<1e3&&this._getClientRect(this._elementRect),l=e}let t=Bl?-1:-3,n=e.deltaMode===1&&!e.ctrlKey?e.deltaY/t:e.deltaY/(t*10),r=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,i=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(e.ctrlKey?J.ZOOM:this.mouseButtons.wheel){case J.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case J.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case J.SCREEN_PAN:this._truckInternal(e.deltaX,e.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case J.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case J.DOLLY:this._dollyInternal(-n,r,i),this._isUserControllingDolly=!0;break;case J.ZOOM:this._zoomInternal(-n,r,i),this._isUserControllingZoom=!0;break}this.dispatchEvent({type:`control`})},d=t=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===e.ACTION.NONE){let e=t instanceof PointerEvent?t.pointerId:0,n=this._findPointerById(e);n&&this._disposePointer(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c);return}t.preventDefault()}},f=e=>{if(this._enabled){if(Fl(this._activePointers,Wl),this._getClientRect(this._elementRect),r.copy(Wl),i.copy(Wl),this._activePointers.length>=2){let e=Wl.x-this._activePointers[1].clientX,t=Wl.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);a.set(0,n);let r=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,o=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(r,o)}if(this._state=0,!e)this._lockedPointer&&(this._state|=this.mouseButtons.left);else if(`pointerType`in e&&e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else !this._lockedPointer&&(e.buttons&yl.LEFT)===yl.LEFT&&(this._state|=this.mouseButtons.left),(e.buttons&yl.MIDDLE)===yl.MIDDLE&&(this._state|=this.mouseButtons.middle),(e.buttons&yl.RIGHT)===yl.RIGHT&&(this._state|=this.mouseButtons.right);((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&J.TRUCK)===J.TRUCK||(this._state&J.SCREEN_PAN)===J.SCREEN_PAN||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_SCREEN_PAN)===J.TOUCH_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&J.DOLLY)===J.DOLLY||(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&J.ZOOM)===J.ZOOM||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:`controlstart`})}},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Fl(this._activePointers,Wl);let e=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,t=e?-e.deltaX:i.x-Wl.x,n=e?-e.deltaY:i.y-Wl.y;if(i.copy(Wl),((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,n),this._isUserControllingRotate=!0),(this._state&J.DOLLY)===J.DOLLY||(this._state&J.ZOOM)===J.ZOOM){let e=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0,i=this.dollyDragInverted?-1:1;(this._state&J.DOLLY)===J.DOLLY?(this._dollyInternal(i*n*zl,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(i*n*zl,e,t),this._isUserControllingZoom=!0)}if((this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE){let e=Wl.x-this._activePointers[1].clientX,t=Wl.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),r=a.y-n;a.set(0,n);let o=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,s=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET?(this._dollyInternal(r*zl,o,s),this._isUserControllingDolly=!0):(this._zoomInternal(r*zl,o,s),this._isUserControllingZoom=!0)}((this._state&J.TRUCK)===J.TRUCK||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,n,!1,!1),this._isUserControllingTruck=!0),((this._state&J.SCREEN_PAN)===J.SCREEN_PAN||(this._state&J.TOUCH_SCREEN_PAN)===J.TOUCH_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(t,n,!1,!0),this._isUserControllingTruck=!0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,n,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:`control`})},m=()=>{Fl(this._activePointers,Wl),i.copy(Wl),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this.dispatchEvent({type:`controlend`}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.addEventListener(`pointerlockerror`,g),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),f())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener(`pointerlockchange`,h),this._domElement?.ownerDocument.removeEventListener(`pointerlockerror`,g),this.cancel()};let h=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},g=()=>{this.unlockPointer()};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`,this._domElement.addEventListener(`pointerdown`,o),this._domElement.addEventListener(`pointercancel`,c),this._domElement.addEventListener(`wheel`,u,{passive:!1}),this._domElement.addEventListener(`contextmenu`,d)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``,this._domElement.removeEventListener(`pointerdown`,o),this._domElement.removeEventListener(`pointercancel`,c),this._domElement.removeEventListener(`wheel`,u,{passive:!1}),this._domElement.removeEventListener(`contextmenu`,d),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.removeEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.removeEventListener(`pointerlockerror`,g))},this.cancel=()=>{this._state!==J.NONE&&(this._state=J.NONE,this._activePointers.length=0,m())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`):(this.cancel(),this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Dl(e.width,0,1),this._interactiveArea.height=Dl(e.height,0,1),this._interactiveArea.x=Dl(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Dl(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let r=Dl(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Dl(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||kl(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&kl(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0,this._dollyToNoClamp(Dl(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){let n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){let t=this._collisionTest(),r=kl(t,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,t)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||kl(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Kl).multiplyScalar(e)),t||this._target.copy(this._targetEnd);let n=!t||kl(this._target.x,this._targetEnd.x,this.restThreshold)&&kl(this._target.y,this._targetEnd.y,this.restThreshold)&&kl(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Dl(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||kl(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),ql.setFromMatrixColumn(this._camera.matrix,0),Jl.setFromMatrixColumn(this._camera.matrix,1),ql.multiplyScalar(e),Jl.multiplyScalar(-t);let r=X.copy(ql).add(Jl),i=Z.copy(this._targetEnd).add(r);return this.moveTo(i.x,i.y,i.z,n)}forward(e,t=!1){X.setFromMatrixColumn(this._camera.matrix,0),X.crossVectors(this._camera.up,X),X.multiplyScalar(e);let n=Z.copy(this._targetEnd).add(X);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return X.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+X.x,this._targetEnd.y+X.y,this._targetEnd.z+X.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;let i=X.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);let a=!r||kl(this._target.x,this._targetEnd.x,this.restThreshold)&&kl(this._target.y,this._targetEnd.y,this.restThreshold)&&kl(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,r=!1){let i=X.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:i=0,paddingBottom:a=0,paddingTop:o=0}={}){let s=[],c=e.isBox3?eu.copy(e):eu.setFromObject(e);c.isEmpty()&&(console.warn(`camera-controls: fitTo() cannot be used with an empty box. Aborting`),Promise.resolve());let l=Al(this._sphericalEnd.theta,wl),u=Al(this._sphericalEnd.phi,wl);s.push(this.rotateTo(l,u,t));let d=X.setFromSpherical(this._sphericalEnd).normalize(),f=ru.setFromUnitVectors(d,Ul),p=kl(Math.abs(d.y),1);p&&f.multiply(iu.setFromAxisAngle(Hl,l)),f.multiply(this._yAxisUpSpaceInverse);let m=tu.makeEmpty();Z.copy(c.min).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.min).setX(c.max.x).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.min).setY(c.max.y).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.max).setZ(c.min.z).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.min).setZ(c.max.z).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.max).setY(c.min.y).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.max).setX(c.min.x).applyQuaternion(f),m.expandByPoint(Z),Z.copy(c.max).applyQuaternion(f),m.expandByPoint(Z),m.min.x-=r,m.min.y-=a,m.max.x+=i,m.max.y+=o,f.setFromUnitVectors(Ul,d),p&&f.premultiply(iu.invert()),f.premultiply(this._yAxisUpSpace);let h=m.getSize(X),g=m.getCenter(Z).applyQuaternion(f);if(xl(this._camera)){let e=this.getDistanceToFitBox(h.x,h.y,h.z,n);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.dollyTo(e,t)),s.push(this.setFocalOffset(0,0,0,t))}else if(Sl(this._camera)){let e=this._camera,r=e.right-e.left,i=e.top-e.bottom,a=n?Math.max(r/h.x,i/h.y):Math.min(r/h.x,i/h.y);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.zoomTo(a,t)),s.push(this.setFocalOffset(0,0,0,t))}return Promise.all(s)}fitToSphere(t,n){let r=[],i=`isObject3D`in t?e.createBoundingSphere(t,nu):nu.copy(t);if(r.push(this.moveTo(i.center.x,i.center.y,i.center.z,n)),xl(this._camera)){let e=this.getDistanceToFitSphere(i.radius);r.push(this.dollyTo(e,n))}else if(Sl(this._camera)){let e=this._camera.right-this._camera.left,t=this._camera.top-this._camera.bottom,a=2*i.radius,o=Math.min(e/a,t/a);r.push(this.zoomTo(o,n))}return r.push(this.setFocalOffset(0,0,0,n)),Promise.all(r)}setLookAt(e,t,n,r,i,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0;let s=Z.set(r,i,a),c=X.set(e,t,n);this._targetEnd.copy(s),this._sphericalEnd.setFromVector3(c.sub(s).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let l=!o||kl(this._target.x,this._targetEnd.x,this.restThreshold)&&kl(this._target.y,this._targetEnd.y,this.restThreshold)&&kl(this._target.z,this._targetEnd.z,this.restThreshold)&&kl(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&kl(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&kl(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerp(e,t,n,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0;let i=X.set(...e.target);if(`spherical`in e)Ql.set(...e.spherical);else{let t=Z.set(...e.position);Ql.setFromVector3(t.sub(i).applyQuaternion(this._yAxisUpSpace))}let a=Gl.set(...t.target);if(`spherical`in t)$l.set(...t.spherical);else{let e=Z.set(...t.position);$l.setFromVector3(e.sub(a).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(i.lerp(a,n));let o=$l.theta-Ql.theta,s=$l.phi-Ql.phi,c=$l.radius-Ql.radius;this._sphericalEnd.set(Ql.radius+c*n,Ql.phi+s*n,Ql.theta+o*n),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let l=!r||kl(this._target.x,this._targetEnd.x,this.restThreshold)&&kl(this._target.y,this._targetEnd.y,this.restThreshold)&&kl(this._target.z,this._targetEnd.z,this.restThreshold)&&kl(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&kl(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&kl(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerpLookAt(e,t,n,r,i,a,o,s,c,l,u,d,f,p=!1){return this.lerp({position:[e,t,n],target:[r,i,a]},{position:[o,s,c],target:[l,u,d]},f,p)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){let i=this.getPosition(X),a=this.setLookAt(i.x,i.y,i.z,e,t,n,r);return this._sphericalEnd.phi=Dl(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);let i=!r||kl(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&kl(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&kl(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),ql.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Jl.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Yl.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let r=X.set(e,t,n),i=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);ql.multiplyScalar(a.x),Jl.multiplyScalar(a.y),Yl.multiplyScalar(a.z),X.copy(ql).add(Jl).add(Yl),X.z+=i,this.dollyTo(i,!1),this.setFocalOffset(-X.x,X.y,-X.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new Y.Vector4,typeof e==`number`?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(Il(this._camera,`getDistanceToFitBox`))return this._spherical.radius;let i=e/t,a=this._camera.getEffectiveFOV()*El,o=this._camera.aspect;return((r?i>o:i<o)?t:e/o)*.5/Math.tan(a*.5)+n*.5}getDistanceToFitSphere(e){if(Il(this._camera,`getDistanceToFitSphere`))return this._spherical.radius;let t=this._camera.getEffectiveFOV()*El,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,r=1<this._camera.aspect?t:n;return e/Math.sin(r*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new Y.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new Y.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new Y.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new Y.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%Cl+Cl)%Cl,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=Cl),this._spherical.theta+=Cl*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Cl),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!kl(this._camera.up.x,this._cameraUp0.x)||!kl(this._camera.up.y,this._cameraUp0.y)||!kl(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);let e=this.getPosition(X);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}let t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Hl),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){let e=X.subVectors(this._target,this._camera.position).normalize(),t=Z.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();let n=this.getPosition(X);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){let t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,r=this._sphericalEnd.radius-this._spherical.radius,i=Xl.subVectors(this._targetEnd,this._target),a=Zl.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(Ol(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Nl(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(Ol(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Nl(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(Ol(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{let t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Nl(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,t,this.maxSpeed,e),this._needsUpdate=!0}if(Ol(i.x)&&Ol(i.y)&&Ol(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{let t=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Pl(this._target,this._targetEnd,this._targetVelocity,t,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Ol(a.x)&&Ol(a.y)&&Ol(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{let t=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Pl(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Ol(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{let t=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Nl(this._zoom,this._zoomEnd,this._zoomVelocity,t,1/0,e)}if(this.dollyToCursor){if(xl(this._camera)&&this._changedDolly!==0){let e=this._spherical.radius-this._lastDistance,t=this._camera,n=this._getCameraDirection(Kl),r=X.copy(n).cross(t.up).normalize();r.lengthSq()===0&&(r.x=1);let i=Z.crossVectors(r,n),a=this._sphericalEnd.radius*Math.tan(t.getEffectiveFOV()*El*.5),o=(this._sphericalEnd.radius-e-this._sphericalEnd.radius)/this._sphericalEnd.radius,s=Gl.copy(this._targetEnd).add(r.multiplyScalar(this._dollyControlCoord.x*a*t.aspect)).add(i.multiplyScalar(this._dollyControlCoord.y*a)),c=X.copy(this._targetEnd).lerp(s,o),l=this._lastDollyDirection===bl.IN&&this._spherical.radius<=this.minDistance,u=this._lastDollyDirection===bl.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(l||u)){this._sphericalEnd.radius-=e,this._spherical.radius-=e;let t=Z.copy(n).multiplyScalar(-e);c.add(t)}this._boundary.clampPoint(c,c);let d=Z.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(d),this._changedDolly-=e,Ol(this._changedDolly)&&(this._changedDolly=0)}else if(Sl(this._camera)&&this._changedZoom!==0){let e=this._zoom-this._lastZoom,t=this._camera,n=X.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(t.near+t.far)/(t.near-t.far)).unproject(t),r=Z.set(0,0,-1).applyQuaternion(t.quaternion),i=Gl.copy(n).add(r.multiplyScalar(-n.dot(t.up))),a=-(this._zoom-e-this._zoom)/this._zoom,o=this._getCameraDirection(Kl),s=this._targetEnd.dot(o),c=X.copy(this._targetEnd).lerp(i,a),l=c.dot(o),u=o.multiplyScalar(l-s);c.sub(u),this._boundary.clampPoint(c,c);let d=Z.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(d),this._changedZoom-=e,Ol(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;let s=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,s),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Ol(this._focalOffset.x)||!Ol(this._focalOffset.y)||!Ol(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),ql.setFromMatrixColumn(this._camera.matrix,0),Jl.setFromMatrixColumn(this._camera.matrix,1),Yl.setFromMatrixColumn(this._camera.matrix,2),ql.multiplyScalar(this._focalOffset.x),Jl.multiplyScalar(-this._focalOffset.y),Yl.multiplyScalar(this._focalOffset.z),X.copy(ql).add(Jl).add(Yl),this._camera.position.add(X),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),X.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);let c=this._needsUpdate;return c&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:`wake`}),this.dispatchEvent({type:`update`})):c?(this.dispatchEvent({type:`update`}),Ol(t,this.restThreshold)&&Ol(n,this.restThreshold)&&Ol(r,this.restThreshold)&&Ol(i.x,this.restThreshold)&&Ol(i.y,this.restThreshold)&&Ol(i.z,this.restThreshold)&&Ol(a.x,this.restThreshold)&&Ol(a.y,this.restThreshold)&&Ol(a.z,this.restThreshold)&&Ol(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:`rest`}))):!c&&this._updatedLastTime&&this.dispatchEvent({type:`sleep`}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=c,this._needsUpdate=!1,c}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:jl(this.maxDistance),minZoom:this.minZoom,maxZoom:jl(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:jl(this.maxPolarAngle),minAzimuthAngle:jl(this.minAzimuthAngle),maxAzimuthAngle:jl(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:X.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){let n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=Ml(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=Ml(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=Ml(n.maxPolarAngle),this.minAzimuthAngle=Ml(n.minAzimuthAngle),this.maxAzimuthAngle=Ml(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Ql.setFromVector3(X.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Ql.theta,Ql.phi,t),this.dollyTo(Ql.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn(`camera-controls is already connected.`);return}e.setAttribute(`data-camera-controls-version`,Rl),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&=(this._domElement.removeAttribute(`data-camera-controls-version`),void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){let r=t.lengthSq();if(r===0)return e;let i=Z.copy(t).add(e),a=this._boundary.clampPoint(i,Gl).sub(i),o=a.lengthSq();if(o===0)return e.add(t);if(o===r)return e;if(n===0)return e.add(t).add(a);{let r=1+n*o/t.dot(a);return e.add(Z.copy(t).multiplyScalar(r)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(xl(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*El,r=Math.tan(n*.5)*t,i=r*e.aspect;this._nearPlaneCorners[0].set(-i,-r,0),this._nearPlaneCorners[1].set(i,-r,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(-i,r,0)}else if(Sl(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,i=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,i,0),this._nearPlaneCorners[1].set(r,i,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_truckInternal=(e,t,n,r)=>{let i,a;if(xl(this._camera)){let n=X.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*El,o=n.length()*Math.tan(r*.5);i=this.truckSpeed*e*o/this._elementRect.height,a=this.truckSpeed*t*o/this._elementRect.height}else if(Sl(this._camera)){let n=this._camera;i=this.truckSpeed*e*(n.right-n.left)/n.zoom/this._elementRect.width,a=this.truckSpeed*t*(n.top-n.bottom)/n.zoom/this._elementRect.height}else return;r?(n?this.setFocalOffset(this._focalOffsetEnd.x+i,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(i,0,!0),this.forward(-a,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+i,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(i,a,!0)};_rotateInternal=(e,t)=>{let n=Cl*this.azimuthRotateSpeed*e/this._elementRect.height,r=Cl*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,r,!0)};_dollyInternal=(e,t,n)=>{let r=.95**(-e*this.dollySpeed),i=this._sphericalEnd.radius,a=this._sphericalEnd.radius*r,o=Dl(a,this.minDistance,this.maxDistance),s=o-a;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(a,!0):(this.infinityDolly&&!this.dollyToCursor&&this.dollyInFixed(s,!0),this._dollyToNoClamp(o,!0)),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?a:o)-i,this._dollyControlCoord.set(t,n)),this._lastDollyDirection=Math.sign(-e)};_zoomInternal=(e,t,n)=>{let r=.95**(e*this.dollySpeed),i=this._zoom,a=this._zoom*r;this.zoomTo(a,!0),this.dollyToCursor&&(this._changedZoom+=a-i,this._dollyControlCoord.set(t,n))};_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Il(this._camera,`_collisionTest`))return e;let t=this._getTargetDirection(Kl);au.lookAt(Vl,t,this._camera.up);for(let n=0;n<4;n++){let r=Z.copy(this._nearPlaneCorners[n]);r.applyMatrix4(au);let i=Gl.addVectors(this._target,r);ou.set(i,t),ou.far=this._spherical.radius+1;let a=ou.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;let t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:`transitionstart`}),new Promise(e=>{let t=()=>{this.removeEventListener(`rest`,t),e()};this.addEventListener(`rest`,t)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`),0}set dampingFactor(e){console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`)}get draggingDampingFactor(){return console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`),0}set draggingDampingFactor(e){console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`)}static createBoundingSphere(e,t=new Y.Sphere){let n=t,r=n.center;eu.makeEmpty(),e.traverseVisible(e=>{e.isMesh&&eu.expandByObject(e)}),eu.getCenter(r);let i=0;return e.traverseVisible(e=>{if(!e.isMesh)return;let t=e;if(!t.geometry)return;let n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);let a=n.attributes.position;for(let e=0,t=a.count;e<t;e++)X.fromBufferAttribute(a,e),i=Math.max(i,r.distanceToSquared(X))}),n.radius=Math.sqrt(i),n}},cu=Object.defineProperty,lu=(e,t,n)=>t in e?cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t,n)=>lu(e,typeof t==`symbol`?t:t+``,n),uu=(e,t)=>{let[n,r]=t.split(`-`);return Object.assign(e.style,{left:r===`left`?`0`:r===`center`?`50%`:``,right:r===`right`?`0`:``,top:n===`top`?`0`:n===`bottom`?``:`50%`,bottom:n===`bottom`?`0`:``,transform:`${r===`center`?`translateX(-50%)`:``} ${n===`center`?`translateY(-50%)`:``}`}),t},du=({placement:e,size:t,offset:n,id:r,className:i})=>{let a=document.createElement(`div`),{top:o,left:s,right:c,bottom:l}=n;return Object.assign(a.style,{id:r,position:`absolute`,zIndex:`1000`,height:`${t}px`,width:`${t}px`,margin:`${o}px ${c}px ${l}px ${s}px`,borderRadius:`100%`}),uu(a,e),r&&(a.id=r),i&&(a.className=i),a},fu=e=>{let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`Invalid DOM element`);return t};function pu(e,t,n){return Math.max(t,Math.min(n,e))}var mu=[[`x`,0,3],[`y`,1,4],[`z`,2,5]],hu=new B;function gu({isSphere:e},t,n){e&&(hu.set(0,0,1).applyQuaternion(n.quaternion),mu.forEach(([e,n,r])=>{let i=hu[e],a=t[n],o=a.userData.opacity;a.material.opacity=pu(i>=0?o:o/2,0,1),a=t[r],o=a.userData.opacity,a.material.opacity=pu(i>=0?o/2:o,0,1)}))}var _u=(e,t,n=10)=>Math.abs(e.clientX-t.x)<n&&Math.abs(e.clientY-t.y)<n,vu=new to,yu=new z,bu=(e,t,n,r)=>{yu.set((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1),vu.setFromCamera(yu,n);let i=vu.intersectObjects(r,!1),a=i.length?i[0]:null;return!a||!a.object.visible?null:a},xu=1e-6,Su=2*Math.PI,Cu=[`x`,`y`,`z`],wu=[...Cu,`nx`,`ny`,`nz`],Tu=[`x`,`z`,`y`,`nx`,`nz`,`ny`],Eu=[`z`,`x`,`y`,`nz`,`nx`,`ny`],Du=`Right`,Ou=`Top`,ku=`Front`,Au=`Left`,ju=`Bottom`,Mu=`Back`,Nu=[Du,Ou,ku,Au,ju,Mu].map(e=>e.toLocaleLowerCase()),Pu=1.3,Fu=(e,t=!0)=>{let{material:n,userData:r}=e,{color:i,opacity:a}=t?r.hover:r;n.color.set(i),n.opacity=a},Iu=e=>JSON.parse(JSON.stringify(e)),Lu=e=>{let t=e.type||`sphere`,n=t===`sphere`,r=e.resolution||n?64:128,i=Un.DEFAULT_UP,a=i.z===1,o=i.x===1,{container:s}=e;e.container=void 0,e=JSON.parse(JSON.stringify(e)),e.container=s;let c=a?Tu:o?Eu:wu;Nu.forEach((t,n)=>{e[t]&&(e[c[n]]=e[t])});let l={enabled:!0,color:16777215,opacity:1,scale:.7,labelColor:2236962,line:!1,border:{size:0,color:14540253},hover:{color:n?16777215:9688043,labelColor:2236962,opacity:1,scale:.7,border:{size:0,color:14540253}}},u={line:!1,scale:n?.45:.7,hover:{scale:n?.5:.7}},d={type:t,container:document.body,size:128,placement:`top-right`,resolution:r,lineWidth:4,radius:n?1:.2,smoothness:18,animated:!0,speed:1,background:{enabled:!0,color:n?16777215:14739180,opacity:+!n,hover:{color:n?16777215:14739180,opacity:n?.2:1}},font:{family:`sans-serif`,weight:900},offset:{top:10,left:10,bottom:10,right:10},corners:{enabled:!n,color:n?15915362:16777215,opacity:1,scale:n?.15:.2,radius:1,smoothness:18,hover:{color:n?16777215:9688043,opacity:1,scale:n?.2:.225}},edges:{enabled:!n,color:n?15915362:16777215,opacity:+!!n,radius:n?1:.125,smoothness:18,scale:n?.15:1,hover:{color:n?16777215:9688043,opacity:1,scale:n?.2:1}},x:{...Iu(l),...n?{label:`X`,color:16725587,line:!0}:{label:o?Ou:Du}},y:{...Iu(l),...n?{label:`Y`,color:9100032,line:!0}:{label:a||o?ku:Ou}},z:{...Iu(l),...n?{label:`Z`,color:2920447,line:!0}:{label:a?Ou:o?Du:ku}},nx:{...Iu(u),label:n?``:o?ju:Au},ny:{...Iu(u),label:n?``:a||o?Mu:ju},nz:{...Iu(u),label:n?``:a?ju:o?Au:Mu}};return Ru(e,d),Cu.forEach(t=>Ru(e[`n${t}`],Iu(e[t]))),{...e,isSphere:n}};function Ru(e,...t){if(e instanceof HTMLElement||typeof e!=`object`||!e)return e;for(let n of t)for(let t in n)t!==`container`&&t in n&&(e[t]===void 0?e[t]=n[t]:typeof n[t]==`object`&&!Array.isArray(n[t])&&(e[t]=Ru(e[t]||{},n[t])));return e}var zu=(t,n=2)=>{let r=new U,i=n*2,{isSphere:a,resolution:o,radius:s,font:c,corners:l,edges:u}=t,d=wu.map(e=>({...t[e],radius:s}));a&&l.enabled&&d.push(l),a&&u.enabled&&d.push(u);let f=document.createElement(`canvas`),p=f.getContext(`2d`);f.width=o*2+i*2,f.height=o*d.length+i*d.length;let[m,h]=S(d,o,c);d.forEach(({radius:e,label:t,color:r,labelColor:a,border:s,hover:{color:c,labelColor:l,border:u}},d)=>{let f=o*d+d*i+n;x(n,f,n,o,e,t,s,r,a),x(o+n*3,f,n,o,e,t,u??s,c??r,l??a)});let g=d.length,_=n/(o*2),v=n/(o*6),y=1/g,b=new Ji(f);return b.repeat.set(.5-2*_,y-2*v),b.offset.set(_,1-v),Object.assign(b,{colorSpace:Fe,wrapS:e,wrapT:e,userData:{offsetX:_,offsetY:v,cellHeight:y}}),b;function x(e,t,n,i,a,o,s,c,l){if(a=i/2*a,c!=null&&c!==``&&(u(),p.fillStyle=r.set(c).getStyle(),p.fill()),s&&s.size){let n=s.size*i/2;e+=n,t+=n,i-=s.size*i,a=Math.max(0,a-n),u(),p.strokeStyle=r.set(s.color).getStyle(),p.lineWidth=s.size*i,p.stroke()}o&&C(p,e+i/2,t+(i+n)/2,o,r.set(l).getStyle());function u(){p.beginPath(),p.moveTo(e+a,t),p.lineTo(e+i-a,t),p.arcTo(e+i,t,e+i,t+a,a),p.lineTo(e+i,t+i-a),p.arcTo(e+i,t+i,e+i-a,t+i,a),p.lineTo(e+a,t+i),p.arcTo(e,t+i,e,t+i-a,a),p.lineTo(e,t+a),p.arcTo(e,t,e+a,t,a),p.closePath()}}function S(e,t,n){let r=[...e].sort((e,t)=>(e.label?.length||0)-(t.label?.length||0)).pop().label,{family:i,weight:o}=n,s=a?Math.sqrt((t*.7)**2/2):t,c=s,l=0,u=0;do{p.font=`${o} ${c}px ${i}`;let e=p.measureText(r);l=e.width,u=e.fontBoundingBoxDescent,c--}while(l>s&&c>0);let d=s/u,f=Math.min(s/l,d);return[`${o} ${Math.floor(c*f)}px ${i}`,d]}function C(e,t,n,r,i){e.font=m,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=i,e.fillText(r,t,n+(a?h:0))}},Bu=(e,t)=>e.offset.x=(t?.5:0)+e.userData.offsetX,Vu=(e,t)=>{let{offset:n,userData:{offsetY:r,cellHeight:i}}=e;n.y=1-(t+1)*i+r};function Hu(e,t,n=2,r=2){let i=n/2-e,a=r/2-e,o=e/n,s=(n-e)/n,c=e/r,l=(r-e)/r,u=[i,a,0,-i,a,0,-i,-a,0,i,-a,0],d=[s,l,o,l,o,c,s,c],f=[3*(t+1)+3,3*(t+1)+4,t+4,t+5,2*(t+1)+4,2,1,2*(t+1)+3,3,4*(t+1)+3,4,0],p=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11].map(e=>f[e]),m,h,g,_,v,y,b,x;for(let n=0;n<4;n++){_=n<1||n>2?i:-i,v=n<2?a:-a,y=n<1||n>2?s:o,b=n<2?l:c;for(let r=0;r<=t;r++)m=Math.PI/2*(n+r/t),h=Math.cos(m),g=Math.sin(m),u.push(_+e*h,v+e*g,0),d.push(y+o*h,b+c*g),r<t&&(x=(t+1)*n+r+4,p.push(n,x,x+1))}return new Tr().setIndex(new W(new Uint32Array(p),1)).setAttribute(`position`,new W(new Float32Array(u),3)).setAttribute(`uv`,new W(new Float32Array(d),2))}var Uu=(e,t)=>{let n=new B,{isSphere:r,radius:i,smoothness:a}=e,o=Hu(i,a);return wu.map((i,a)=>{let s=a<3,c=wu[a],l=a?t.clone():t;Vu(l,a);let{enabled:u,scale:d,opacity:f,hover:p}=e[c],m={map:l,opacity:f,transparent:!0},h=r?new Ti(new di(m)):new G(o,new dr(m)),g=s?c:c[1];return h.position[g]=(s?1:-1)*(r?Pu:1),r||h.lookAt(n.copy(h.position).multiplyScalar(1.7)),h.scale.setScalar(d),h.renderOrder=1,h.visible=u,h.userData={scale:d,opacity:f,hover:p},h})},Wu=(e,t)=>{let{isSphere:n,corners:r}=e;if(!r.enabled)return[];let{color:i,opacity:a,scale:o,radius:s,smoothness:c,hover:l}=r,u=n?null:Hu(s,c),d={transparent:!0,opacity:a},f=[1,1,1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,-1,-1].map(e=>e*.85),p=new B;return Array(f.length/3).fill(0).map((e,r)=>{if(n){let e=t.clone();Vu(e,6),d.map=e}else d.color=i;let s=n?new Ti(new di(d)):new G(u,new dr(d)),c=r*3;return s.position.set(f[c],f[c+1],f[c+2]),n&&s.position.normalize().multiplyScalar(1.7),s.scale.setScalar(o),s.lookAt(p.copy(s.position).multiplyScalar(2)),s.renderOrder=1,s.userData={color:i,opacity:a,scale:o,hover:l},s})},Gu=(e,t,n)=>{let{isSphere:r,edges:i}=e;if(!i.enabled)return[];let{color:a,opacity:o,scale:s,hover:c,radius:l,smoothness:u}=i,d=r?null:Hu(l,u,1.2,.25),f={transparent:!0,opacity:o},p=[0,1,1,0,-1,1,1,0,1,-1,0,1,0,1,-1,0,-1,-1,1,0,-1,-1,0,-1,1,1,0,1,-1,0,-1,1,0,-1,-1,0].map(e=>e*.925),m=new B,h=new B(0,1,0);return Array(p.length/3).fill(0).map((e,i)=>{if(r){let e=t.clone();Vu(e,n),f.map=e}else f.color=a;let l=r?new Ti(new di(f)):new G(d,new dr(f)),u=i*3;return l.position.set(p[u],p[u+1],p[u+2]),r&&l.position.normalize().multiplyScalar(1.7),l.scale.setScalar(s),l.up.copy(h),l.lookAt(m.copy(l.position).multiplyScalar(2)),!r&&!l.position.y&&(l.rotation.z=Math.PI/2),l.renderOrder=1,l.userData={color:a,opacity:o,scale:s,hover:c},l})};function Ku(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new Tr,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=qu(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=qu(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}return c}function qu(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new W(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var Ju=(e,t)=>{let{isSphere:n,background:{enabled:r,color:i,opacity:a,hover:o}}=t,s,c=new dr({color:i,side:1,opacity:a,transparent:!0,depthWrite:!1});if(!r)return null;if(n)s=new G(new oa(1.8,64,64),c);else{let t;e.forEach(e=>{let n=e.scale.x;e.scale.setScalar(.9),e.updateMatrix();let r=e.geometry.clone();r.applyMatrix4(e.matrix),t=t?Ku([t,r]):r,e.scale.setScalar(n)}),s=new G(t,c)}return s.userData={color:i,opacity:a,hover:o},s},Yu=new Ht,Xu=new B,Zu=class extends Ra{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new _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],3)),this.setAttribute(`uv`,new _r([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new $a(t,6,1);return this.setAttribute(`instanceStart`,new ui(n,3,0)),this.setAttribute(`instanceEnd`,new ui(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new $a(t,6,1);return this.setAttribute(`instanceColorStart`,new ui(n,3,0)),this.setAttribute(`instanceColorEnd`,new ui(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new sa(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Yu.setFromBufferAttribute(t),this.boundingBox.union(Yu))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new sn),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)Xu.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(Xu)),Xu.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(Xu));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}applyMatrix(e){return console.warn(`THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().`),this.applyMatrix4(e)}};q.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new z(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},yo.line={uniforms:Wr.merge([q.common,q.fog,q.line]),vertexShader:`
|
|
3832
|
+
}`,fl=class{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){let n=new Xi(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){let t=e.cameras[0].viewport,n=new qr({vertexShader:ul,fragmentShader:dl,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new G(new aa(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}},pl=class extends He{constructor(e,t){super();let n=this,r=null,i=1,a=null,o=`local-floor`,s=1,c=null,u=null,d=null,f=null,p=null,h=null,g=typeof XRWebGLBinding<`u`,_=new fl,v={},b=t.getContextAttributes(),x=null,S=null,C=[],D=[],ee=new z,O=null,k=new Qr;k.viewport=new Lt;let te=new Qr;te.viewport=new Lt;let ne=[k,te],A=new za,re=null,j=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getTargetRaySpace()},this.getControllerGrip=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getGripSpace()},this.getHand=function(e){let t=C[e];return t===void 0&&(t=new oi,C[e]=t),t.getHandSpace()};function M(e){let t=D.indexOf(e.inputSource);if(t===-1)return;let n=C[t];n!==void 0&&(n.update(e.inputSource,e.frame,c||a),n.dispatchEvent({type:e.type,data:e.inputSource}))}function ie(){r.removeEventListener(`select`,M),r.removeEventListener(`selectstart`,M),r.removeEventListener(`selectend`,M),r.removeEventListener(`squeeze`,M),r.removeEventListener(`squeezestart`,M),r.removeEventListener(`squeezeend`,M),r.removeEventListener(`end`,ie),r.removeEventListener(`inputsourceschange`,ae);for(let e=0;e<C.length;e++){let t=D[e];t!==null&&(D[e]=null,C[e].disconnect(t))}re=null,j=null,_.reset();for(let e in v)delete v[e];e.setRenderTarget(x),p=null,f=null,d=null,r=null,S=null,pe.stop(),n.isPresenting=!1,e.setPixelRatio(O),e.setSize(ee.width,ee.height,!1),n.dispatchEvent({type:`sessionend`})}this.setFramebufferScaleFactor=function(e){i=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change framebuffer scale while presenting.`)},this.setReferenceSpaceType=function(e){o=e,n.isPresenting===!0&&console.warn(`THREE.WebXRManager: Cannot change reference space type while presenting.`)},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(e){c=e},this.getBaseLayer=function(){return f===null?p:f},this.getBinding=function(){return d===null&&g&&(d=new XRWebGLBinding(r,t)),d},this.getFrame=function(){return h},this.getSession=function(){return r},this.setSession=async function(u){if(r=u,r!==null){if(x=e.getRenderTarget(),r.addEventListener(`select`,M),r.addEventListener(`selectstart`,M),r.addEventListener(`selectend`,M),r.addEventListener(`squeeze`,M),r.addEventListener(`squeezestart`,M),r.addEventListener(`squeezeend`,M),r.addEventListener(`end`,ie),r.addEventListener(`inputsourceschange`,ae),b.xrCompatible!==!0&&await t.makeXRCompatible(),O=e.getPixelRatio(),e.getSize(ee),g&&`createProjectionLayer`in XRWebGLBinding.prototype){let n=null,a=null,o=null;b.depth&&(o=b.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,n=b.stencil?E:T,a=b.stencil?y:m);let s={colorFormat:t.RGBA8,depthFormat:o,scaleFactor:i};d=this.getBinding(),f=d.createProjectionLayer(s),r.updateRenderState({layers:[f]}),e.setPixelRatio(1),e.setSize(f.textureWidth,f.textureHeight,!1),S=new zt(f.textureWidth,f.textureHeight,{format:w,type:l,depthTexture:new Yi(f.textureWidth,f.textureHeight,a,void 0,void 0,void 0,void 0,void 0,void 0,n),stencilBuffer:b.stencil,colorSpace:e.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}else{let n={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:i};p=new XRWebGLLayer(r,t,n),r.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),S=new zt(p.framebufferWidth,p.framebufferHeight,{format:w,type:l,colorSpace:e.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}S.isXRRenderTarget=!0,this.setFoveation(s),c=null,a=await r.requestReferenceSpace(o),pe.setContext(r),pe.start(),n.isPresenting=!0,n.dispatchEvent({type:`sessionstart`})}},this.getEnvironmentBlendMode=function(){if(r!==null)return r.environmentBlendMode},this.getDepthTexture=function(){return _.getDepthTexture()};function ae(e){for(let t=0;t<e.removed.length;t++){let n=e.removed[t],r=D.indexOf(n);r>=0&&(D[r]=null,C[r].disconnect(n))}for(let t=0;t<e.added.length;t++){let n=e.added[t],r=D.indexOf(n);if(r===-1){for(let e=0;e<C.length;e++)if(e>=D.length){D.push(n),r=e;break}else if(D[e]===null){D[e]=n,r=e;break}if(r===-1)break}let i=C[r];i&&i.connect(n)}}let oe=new B,se=new B;function ce(e,t,n){oe.setFromMatrixPosition(t.matrixWorld),se.setFromMatrixPosition(n.matrixWorld);let r=oe.distanceTo(se),i=t.projectionMatrix.elements,a=n.projectionMatrix.elements,o=i[14]/(i[10]-1),s=i[14]/(i[10]+1),c=(i[9]+1)/i[5],l=(i[9]-1)/i[5],u=(i[8]-1)/i[0],d=(a[8]+1)/a[0],f=o*u,p=o*d,m=r/(-u+d),h=m*-u;if(t.matrixWorld.decompose(e.position,e.quaternion,e.scale),e.translateX(h),e.translateZ(m),e.matrixWorld.compose(e.position,e.quaternion,e.scale),e.matrixWorldInverse.copy(e.matrixWorld).invert(),i[10]===-1)e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse);else{let t=o+m,n=s+m,i=f-h,a=p+(r-h),u=c*s/n*t,d=l*s/n*t;e.projectionMatrix.makePerspective(i,a,u,d,t,n),e.projectionMatrixInverse.copy(e.projectionMatrix).invert()}}function le(e,t){t===null?e.matrixWorld.copy(e.matrix):e.matrixWorld.multiplyMatrices(t.matrixWorld,e.matrix),e.matrixWorldInverse.copy(e.matrixWorld).invert()}this.updateCamera=function(e){if(r===null)return;let t=e.near,n=e.far;_.texture!==null&&(_.depthNear>0&&(t=_.depthNear),_.depthFar>0&&(n=_.depthFar)),A.near=te.near=k.near=t,A.far=te.far=k.far=n,(re!==A.near||j!==A.far)&&(r.updateRenderState({depthNear:A.near,depthFar:A.far}),re=A.near,j=A.far),A.layers.mask=e.layers.mask|6,k.layers.mask=A.layers.mask&3,te.layers.mask=A.layers.mask&5;let i=e.parent,a=A.cameras;le(A,i);for(let e=0;e<a.length;e++)le(a[e],i);a.length===2?ce(A,k,te):A.projectionMatrix.copy(k.projectionMatrix),ue(e,A,i)};function ue(e,t,n){n===null?e.matrix.copy(t.matrixWorld):(e.matrix.copy(n.matrixWorld),e.matrix.invert(),e.matrix.multiply(t.matrixWorld)),e.matrix.decompose(e.position,e.quaternion,e.scale),e.updateMatrixWorld(!0),e.projectionMatrix.copy(t.projectionMatrix),e.projectionMatrixInverse.copy(t.projectionMatrixInverse),e.isPerspectiveCamera&&(e.fov=Ke*2*Math.atan(1/e.projectionMatrix.elements[5]),e.zoom=1)}this.getCamera=function(){return A},this.getFoveation=function(){if(!(f===null&&p===null))return s},this.setFoveation=function(e){s=e,f!==null&&(f.fixedFoveation=e),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=e)},this.hasDepthSensing=function(){return _.texture!==null},this.getDepthSensingMesh=function(){return _.getMesh(A)},this.getCameraTexture=function(e){return v[e]};let de=null;function fe(t,i){if(u=i.getViewerPose(c||a),h=i,u!==null){let t=u.views;p!==null&&(e.setRenderTargetFramebuffer(S,p.framebuffer),e.setRenderTarget(S));let i=!1;t.length!==A.cameras.length&&(A.cameras.length=0,i=!0);for(let n=0;n<t.length;n++){let r=t[n],a=null;if(p!==null)a=p.getViewport(r);else{let t=d.getViewSubImage(f,r);a=t.viewport,n===0&&(e.setRenderTargetTextures(S,t.colorTexture,t.depthStencilTexture),e.setRenderTarget(S))}let o=ne[n];o===void 0&&(o=new Qr,o.layers.enable(n),o.viewport=new Lt,ne[n]=o),o.matrix.fromArray(r.transform.matrix),o.matrix.decompose(o.position,o.quaternion,o.scale),o.projectionMatrix.fromArray(r.projectionMatrix),o.projectionMatrixInverse.copy(o.projectionMatrix).invert(),o.viewport.set(a.x,a.y,a.width,a.height),n===0&&(A.matrix.copy(o.matrix),A.matrix.decompose(A.position,A.quaternion,A.scale)),i===!0&&A.cameras.push(o)}let a=r.enabledFeatures;if(a&&a.includes(`depth-sensing`)&&r.depthUsage==`gpu-optimized`&&g){d=n.getBinding();let e=d.getDepthInformation(t[0]);e&&e.isValid&&e.texture&&_.init(e,r.renderState)}if(a&&a.includes(`camera-access`)&&g){e.state.unbindTexture(),d=n.getBinding();for(let e=0;e<t.length;e++){let n=t[e].camera;if(n){let e=v[n];e||(e=new Xi,v[n]=e);let t=d.getCameraImage(n);e.sourceTexture=t}}}}for(let e=0;e<C.length;e++){let t=D[e],n=C[e];t!==null&&n!==void 0&&n.update(t,i,c||a)}de&&de(t,i),i.detectedPlanes&&n.dispatchEvent({type:`planesdetected`,data:i}),h=null}let pe=new _o;pe.setAnimationLoop(fe),this.setAnimationLoop=function(e){de=e},this.dispose=function(){}}},ml=new En,hl=new gn;function gl(e,t){function n(e,t){e.matrixAutoUpdate===!0&&e.updateMatrix(),t.value.copy(e.matrix)}function r(t,n){n.color.getRGB(t.fogColor.value,Ur(e)),n.isFog?(t.fogNear.value=n.near,t.fogFar.value=n.far):n.isFogExp2&&(t.fogDensity.value=n.density)}function i(e,t,n,r,i){t.isMeshBasicMaterial||t.isMeshLambertMaterial?a(e,t):t.isMeshToonMaterial?(a(e,t),d(e,t)):t.isMeshPhongMaterial?(a(e,t),u(e,t)):t.isMeshStandardMaterial?(a(e,t),f(e,t),t.isMeshPhysicalMaterial&&p(e,t,i)):t.isMeshMatcapMaterial?(a(e,t),m(e,t)):t.isMeshDepthMaterial?a(e,t):t.isMeshDistanceMaterial?(a(e,t),h(e,t)):t.isMeshNormalMaterial?a(e,t):t.isLineBasicMaterial?(o(e,t),t.isLineDashedMaterial&&s(e,t)):t.isPointsMaterial?c(e,t,n,r):t.isSpriteMaterial?l(e,t):t.isShadowMaterial?(e.color.value.copy(t.color),e.opacity.value=t.opacity):t.isShaderMaterial&&(t.uniformsNeedUpdate=!1)}function a(e,r){e.opacity.value=r.opacity,r.color&&e.diffuse.value.copy(r.color),r.emissive&&e.emissive.value.copy(r.emissive).multiplyScalar(r.emissiveIntensity),r.map&&(e.map.value=r.map,n(r.map,e.mapTransform)),r.alphaMap&&(e.alphaMap.value=r.alphaMap,n(r.alphaMap,e.alphaMapTransform)),r.bumpMap&&(e.bumpMap.value=r.bumpMap,n(r.bumpMap,e.bumpMapTransform),e.bumpScale.value=r.bumpScale,r.side===1&&(e.bumpScale.value*=-1)),r.normalMap&&(e.normalMap.value=r.normalMap,n(r.normalMap,e.normalMapTransform),e.normalScale.value.copy(r.normalScale),r.side===1&&e.normalScale.value.negate()),r.displacementMap&&(e.displacementMap.value=r.displacementMap,n(r.displacementMap,e.displacementMapTransform),e.displacementScale.value=r.displacementScale,e.displacementBias.value=r.displacementBias),r.emissiveMap&&(e.emissiveMap.value=r.emissiveMap,n(r.emissiveMap,e.emissiveMapTransform)),r.specularMap&&(e.specularMap.value=r.specularMap,n(r.specularMap,e.specularMapTransform)),r.alphaTest>0&&(e.alphaTest.value=r.alphaTest);let i=t.get(r),a=i.envMap,o=i.envMapRotation;a&&(e.envMap.value=a,ml.copy(o),ml.x*=-1,ml.y*=-1,ml.z*=-1,a.isCubeTexture&&a.isRenderTargetTexture===!1&&(ml.y*=-1,ml.z*=-1),e.envMapRotation.value.setFromMatrix4(hl.makeRotationFromEuler(ml)),e.flipEnvMap.value=a.isCubeTexture&&a.isRenderTargetTexture===!1?-1:1,e.reflectivity.value=r.reflectivity,e.ior.value=r.ior,e.refractionRatio.value=r.refractionRatio),r.lightMap&&(e.lightMap.value=r.lightMap,e.lightMapIntensity.value=r.lightMapIntensity,n(r.lightMap,e.lightMapTransform)),r.aoMap&&(e.aoMap.value=r.aoMap,e.aoMapIntensity.value=r.aoMapIntensity,n(r.aoMap,e.aoMapTransform))}function o(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform))}function s(e,t){e.dashSize.value=t.dashSize,e.totalSize.value=t.dashSize+t.gapSize,e.scale.value=t.scale}function c(e,t,r,i){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.size.value=t.size*r,e.scale.value=i*.5,t.map&&(e.map.value=t.map,n(t.map,e.uvTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function l(e,t){e.diffuse.value.copy(t.color),e.opacity.value=t.opacity,e.rotation.value=t.rotation,t.map&&(e.map.value=t.map,n(t.map,e.mapTransform)),t.alphaMap&&(e.alphaMap.value=t.alphaMap,n(t.alphaMap,e.alphaMapTransform)),t.alphaTest>0&&(e.alphaTest.value=t.alphaTest)}function u(e,t){e.specular.value.copy(t.specular),e.shininess.value=Math.max(t.shininess,1e-4)}function d(e,t){t.gradientMap&&(e.gradientMap.value=t.gradientMap)}function f(e,t){e.metalness.value=t.metalness,t.metalnessMap&&(e.metalnessMap.value=t.metalnessMap,n(t.metalnessMap,e.metalnessMapTransform)),e.roughness.value=t.roughness,t.roughnessMap&&(e.roughnessMap.value=t.roughnessMap,n(t.roughnessMap,e.roughnessMapTransform)),t.envMap&&(e.envMapIntensity.value=t.envMapIntensity)}function p(e,t,r){e.ior.value=t.ior,t.sheen>0&&(e.sheenColor.value.copy(t.sheenColor).multiplyScalar(t.sheen),e.sheenRoughness.value=t.sheenRoughness,t.sheenColorMap&&(e.sheenColorMap.value=t.sheenColorMap,n(t.sheenColorMap,e.sheenColorMapTransform)),t.sheenRoughnessMap&&(e.sheenRoughnessMap.value=t.sheenRoughnessMap,n(t.sheenRoughnessMap,e.sheenRoughnessMapTransform))),t.clearcoat>0&&(e.clearcoat.value=t.clearcoat,e.clearcoatRoughness.value=t.clearcoatRoughness,t.clearcoatMap&&(e.clearcoatMap.value=t.clearcoatMap,n(t.clearcoatMap,e.clearcoatMapTransform)),t.clearcoatRoughnessMap&&(e.clearcoatRoughnessMap.value=t.clearcoatRoughnessMap,n(t.clearcoatRoughnessMap,e.clearcoatRoughnessMapTransform)),t.clearcoatNormalMap&&(e.clearcoatNormalMap.value=t.clearcoatNormalMap,n(t.clearcoatNormalMap,e.clearcoatNormalMapTransform),e.clearcoatNormalScale.value.copy(t.clearcoatNormalScale),t.side===1&&e.clearcoatNormalScale.value.negate())),t.dispersion>0&&(e.dispersion.value=t.dispersion),t.iridescence>0&&(e.iridescence.value=t.iridescence,e.iridescenceIOR.value=t.iridescenceIOR,e.iridescenceThicknessMinimum.value=t.iridescenceThicknessRange[0],e.iridescenceThicknessMaximum.value=t.iridescenceThicknessRange[1],t.iridescenceMap&&(e.iridescenceMap.value=t.iridescenceMap,n(t.iridescenceMap,e.iridescenceMapTransform)),t.iridescenceThicknessMap&&(e.iridescenceThicknessMap.value=t.iridescenceThicknessMap,n(t.iridescenceThicknessMap,e.iridescenceThicknessMapTransform))),t.transmission>0&&(e.transmission.value=t.transmission,e.transmissionSamplerMap.value=r.texture,e.transmissionSamplerSize.value.set(r.width,r.height),t.transmissionMap&&(e.transmissionMap.value=t.transmissionMap,n(t.transmissionMap,e.transmissionMapTransform)),e.thickness.value=t.thickness,t.thicknessMap&&(e.thicknessMap.value=t.thicknessMap,n(t.thicknessMap,e.thicknessMapTransform)),e.attenuationDistance.value=t.attenuationDistance,e.attenuationColor.value.copy(t.attenuationColor)),t.anisotropy>0&&(e.anisotropyVector.value.set(t.anisotropy*Math.cos(t.anisotropyRotation),t.anisotropy*Math.sin(t.anisotropyRotation)),t.anisotropyMap&&(e.anisotropyMap.value=t.anisotropyMap,n(t.anisotropyMap,e.anisotropyMapTransform))),e.specularIntensity.value=t.specularIntensity,e.specularColor.value.copy(t.specularColor),t.specularColorMap&&(e.specularColorMap.value=t.specularColorMap,n(t.specularColorMap,e.specularColorMapTransform)),t.specularIntensityMap&&(e.specularIntensityMap.value=t.specularIntensityMap,n(t.specularIntensityMap,e.specularIntensityMapTransform))}function m(e,t){t.matcap&&(e.matcap.value=t.matcap)}function h(e,n){let r=t.get(n).light;e.referencePosition.value.setFromMatrixPosition(r.matrixWorld),e.nearDistance.value=r.shadow.camera.near,e.farDistance.value=r.shadow.camera.far}return{refreshFogUniforms:r,refreshMaterialUniforms:i}}function _l(e,t,n,r){let i={},a={},o=[],s=e.getParameter(e.MAX_UNIFORM_BUFFER_BINDINGS);function c(e,t){let n=t.program;r.uniformBlockBinding(e,n)}function l(e,n){let o=i[e.id];o===void 0&&(m(e),o=u(e),i[e.id]=o,e.addEventListener(`dispose`,g));let s=n.program;r.updateUBOMapping(e,s);let c=t.render.frame;a[e.id]!==c&&(f(e),a[e.id]=c)}function u(t){let n=d();t.__bindingPointIndex=n;let r=e.createBuffer(),i=t.__size,a=t.usage;return e.bindBuffer(e.UNIFORM_BUFFER,r),e.bufferData(e.UNIFORM_BUFFER,i,a),e.bindBuffer(e.UNIFORM_BUFFER,null),e.bindBufferBase(e.UNIFORM_BUFFER,n,r),r}function d(){for(let e=0;e<s;e++)if(o.indexOf(e)===-1)return o.push(e),e;return console.error(`THREE.WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached.`),0}function f(t){let n=i[t.id],r=t.uniforms,a=t.__cache;e.bindBuffer(e.UNIFORM_BUFFER,n);for(let t=0,n=r.length;t<n;t++){let n=Array.isArray(r[t])?r[t]:[r[t]];for(let r=0,i=n.length;r<i;r++){let i=n[r];if(p(i,t,r,a)===!0){let t=i.__offset,n=Array.isArray(i.value)?i.value:[i.value],r=0;for(let a=0;a<n.length;a++){let o=n[a],s=h(o);typeof o==`number`||typeof o==`boolean`?(i.__data[0]=o,e.bufferSubData(e.UNIFORM_BUFFER,t+r,i.__data)):o.isMatrix3?(i.__data[0]=o.elements[0],i.__data[1]=o.elements[1],i.__data[2]=o.elements[2],i.__data[3]=0,i.__data[4]=o.elements[3],i.__data[5]=o.elements[4],i.__data[6]=o.elements[5],i.__data[7]=0,i.__data[8]=o.elements[6],i.__data[9]=o.elements[7],i.__data[10]=o.elements[8],i.__data[11]=0):(o.toArray(i.__data,r),r+=s.storage/Float32Array.BYTES_PER_ELEMENT)}e.bufferSubData(e.UNIFORM_BUFFER,t,i.__data)}}}e.bindBuffer(e.UNIFORM_BUFFER,null)}function p(e,t,n,r){let i=e.value,a=t+`_`+n;if(r[a]===void 0)return typeof i==`number`||typeof i==`boolean`?r[a]=i:r[a]=i.clone(),!0;{let e=r[a];if(typeof i==`number`||typeof i==`boolean`){if(e!==i)return r[a]=i,!0}else if(e.equals(i)===!1)return e.copy(i),!0}return!1}function m(e){let t=e.uniforms,n=0;for(let e=0,r=t.length;e<r;e++){let r=Array.isArray(t[e])?t[e]:[t[e]];for(let e=0,t=r.length;e<t;e++){let t=r[e],i=Array.isArray(t.value)?t.value:[t.value];for(let e=0,r=i.length;e<r;e++){let r=i[e],a=h(r),o=n%16,s=o%a.boundary,c=o+s;n+=s,c!==0&&16-c<a.storage&&(n+=16-c),t.__data=new Float32Array(a.storage/Float32Array.BYTES_PER_ELEMENT),t.__offset=n,n+=a.storage}}}let r=n%16;return r>0&&(n+=16-r),e.__size=n,e.__cache={},this}function h(e){let t={boundary:0,storage:0};return typeof e==`number`||typeof e==`boolean`?(t.boundary=4,t.storage=4):e.isVector2?(t.boundary=8,t.storage=8):e.isVector3||e.isColor?(t.boundary=16,t.storage=12):e.isVector4?(t.boundary=16,t.storage=16):e.isMatrix3?(t.boundary=48,t.storage=48):e.isMatrix4?(t.boundary=64,t.storage=64):e.isTexture?console.warn(`THREE.WebGLRenderer: Texture samplers can not be part of an uniforms group.`):console.warn(`THREE.WebGLRenderer: Unsupported uniform value type.`,e),t}function g(t){let n=t.target;n.removeEventListener(`dispose`,g);let r=o.indexOf(n.__bindingPointIndex);o.splice(r,1),e.deleteBuffer(i[n.id]),delete i[n.id],delete a[n.id]}function _(){for(let t in i)e.deleteBuffer(i[t]);o=[],i={},a={}}return{bind:c,update:l,dispose:_}}var vl=class{constructor(e={}){let{canvas:t=bt(),context:n=null,depth:r=!0,stencil:i=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:s=!0,preserveDrawingBuffer:u=!1,powerPreference:d=`default`,failIfMajorPerformanceCaveat:f=!1,reversedDepthBuffer:p=!1}=e;this.isWebGLRenderer=!0;let m;if(n!==null){if(typeof WebGLRenderingContext<`u`&&n instanceof WebGLRenderingContext)throw Error(`THREE.WebGLRenderer: WebGL 1 is not supported since r163.`);m=n.getContextAttributes().alpha}else m=a;let h=new Uint32Array(4),_=new Int32Array(4),v=null,y=null,b=[],x=[];this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=0,this.toneMappingExposure=1,this.transmissionResolutionScale=1;let S=this,C=!1;this._outputColorSpace=Fe;let w=0,T=0,E=null,D=-1,ee=null,O=new Lt,k=new Lt,te=null,ne=new U(0),A=0,re=t.width,j=t.height,M=1,ie=null,ae=null,oe=new Lt(0,0,re,j),se=new Lt(0,0,re,j),ce=!1,le=new Pi,ue=!1,de=!1,fe=new gn,pe=new B,me=new Lt,he={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0},ge=!1;function _e(){return E===null?M:1}let N=n;function ve(e,n){return t.getContext(e,n)}try{let e={alpha:!0,depth:r,stencil:i,antialias:o,premultipliedAlpha:s,preserveDrawingBuffer:u,powerPreference:d,failIfMajorPerformanceCaveat:f};if(`setAttribute`in t&&t.setAttribute(`data-engine`,`three.js r180`),t.addEventListener(`webglcontextlost`,Ge,!1),t.addEventListener(`webglcontextrestored`,Ke,!1),t.addEventListener(`webglcontextcreationerror`,qe,!1),N===null){let t=`webgl2`;if(N=ve(t,e),N===null)throw ve(t)?Error(`Error creating WebGL context with your selected attributes.`):Error(`Error creating WebGL context.`)}}catch(e){throw console.error(`THREE.WebGLRenderer: `+e.message),e}let ye,be,P,xe,F,I,Se,Ce,we,Te,Ee,De,Oe,ke,Ae,je,Me,Ne,Pe,Le,Re,ze,Be,He;function Ue(){ye=new Zo(N),ye.init(),ze=new ll(N,ye),be=new Eo(N,ye,e,ze),P=new sl(N,ye),be.reversedDepthBuffer&&p&&P.buffers.depth.setReversed(!0),xe=new es(N),F=new Gc,I=new cl(N,ye,P,F,be,ze,xe),Se=new Oo(S),Ce=new Xo(S),we=new vo(N),Be=new wo(N,we),Te=new Qo(N,we,xe,Be),Ee=new ns(N,Te,we,xe),Pe=new ts(N,be,I),je=new Do(F),De=new Wc(S,Se,Ce,ye,be,Be,je),Oe=new gl(S,F),ke=new Yc,Ae=new nl(ye),Ne=new Co(S,Se,Ce,P,Ee,m,s),Me=new al(S,Ee,be),He=new _l(N,xe,be,P),Le=new To(N,ye,xe),Re=new $o(N,ye,xe),xe.programs=De.programs,S.capabilities=be,S.extensions=ye,S.properties=F,S.renderLists=ke,S.shadowMap=Me,S.state=P,S.info=xe}Ue();let We=new pl(S,N);this.xr=We,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){let e=ye.get(`WEBGL_lose_context`);e&&e.loseContext()},this.forceContextRestore=function(){let e=ye.get(`WEBGL_lose_context`);e&&e.restoreContext()},this.getPixelRatio=function(){return M},this.setPixelRatio=function(e){e!==void 0&&(M=e,this.setSize(re,j,!1))},this.getSize=function(e){return e.set(re,j)},this.setSize=function(e,n,r=!0){if(We.isPresenting){console.warn(`THREE.WebGLRenderer: Can't change size while VR device is presenting.`);return}re=e,j=n,t.width=Math.floor(e*M),t.height=Math.floor(n*M),r===!0&&(t.style.width=e+`px`,t.style.height=n+`px`),this.setViewport(0,0,e,n)},this.getDrawingBufferSize=function(e){return e.set(re*M,j*M).floor()},this.setDrawingBufferSize=function(e,n,r){re=e,j=n,M=r,t.width=Math.floor(e*r),t.height=Math.floor(n*r),this.setViewport(0,0,e,n)},this.getCurrentViewport=function(e){return e.copy(O)},this.getViewport=function(e){return e.copy(oe)},this.setViewport=function(e,t,n,r){e.isVector4?oe.set(e.x,e.y,e.z,e.w):oe.set(e,t,n,r),P.viewport(O.copy(oe).multiplyScalar(M).round())},this.getScissor=function(e){return e.copy(se)},this.setScissor=function(e,t,n,r){e.isVector4?se.set(e.x,e.y,e.z,e.w):se.set(e,t,n,r),P.scissor(k.copy(se).multiplyScalar(M).round())},this.getScissorTest=function(){return ce},this.setScissorTest=function(e){P.setScissorTest(ce=e)},this.setOpaqueSort=function(e){ie=e},this.setTransparentSort=function(e){ae=e},this.getClearColor=function(e){return e.copy(Ne.getClearColor())},this.setClearColor=function(){Ne.setClearColor(...arguments)},this.getClearAlpha=function(){return Ne.getClearAlpha()},this.setClearAlpha=function(){Ne.setClearAlpha(...arguments)},this.clear=function(e=!0,t=!0,n=!0){let r=0;if(e){let e=!1;if(E!==null){let t=E.texture.format;e=t===1033||t===1031||t===1029}if(e){let e=E.texture.type,t=e===1009||e===1014||e===1012||e===1020||e===1017||e===1018,n=Ne.getClearColor(),r=Ne.getClearAlpha(),i=n.r,a=n.g,o=n.b;t?(h[0]=i,h[1]=a,h[2]=o,h[3]=r,N.clearBufferuiv(N.COLOR,0,h)):(_[0]=i,_[1]=a,_[2]=o,_[3]=r,N.clearBufferiv(N.COLOR,0,_))}else r|=N.COLOR_BUFFER_BIT}t&&(r|=N.DEPTH_BUFFER_BIT),n&&(r|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),N.clear(r)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.dispose=function(){t.removeEventListener(`webglcontextlost`,Ge,!1),t.removeEventListener(`webglcontextrestored`,Ke,!1),t.removeEventListener(`webglcontextcreationerror`,qe,!1),Ne.dispose(),ke.dispose(),Ae.dispose(),F.dispose(),Se.dispose(),Ce.dispose(),Ee.dispose(),Be.dispose(),He.dispose(),De.dispose(),We.dispose(),We.removeEventListener(`sessionstart`,$e),We.removeEventListener(`sessionend`,et),tt.stop()};function Ge(e){e.preventDefault(),console.log(`THREE.WebGLRenderer: Context Lost.`),C=!0}function Ke(){console.log(`THREE.WebGLRenderer: Context Restored.`),C=!1;let e=xe.autoReset,t=Me.enabled,n=Me.autoUpdate,r=Me.needsUpdate,i=Me.type;Ue(),xe.autoReset=e,Me.enabled=t,Me.autoUpdate=n,Me.needsUpdate=r,Me.type=i}function qe(e){console.error(`THREE.WebGLRenderer: A WebGL context could not be created. Reason: `,e.statusMessage)}function L(e){let t=e.target;t.removeEventListener(`dispose`,L),Je(t)}function Je(e){Ye(e),F.remove(e)}function Ye(e){let t=F.get(e).programs;t!==void 0&&(t.forEach(function(e){De.releaseProgram(e)}),e.isShaderMaterial&&De.releaseShaderCache(e))}this.renderBufferDirect=function(e,t,n,r,i,a){t===null&&(t=he);let o=i.isMesh&&i.matrixWorld.determinant()<0,s=ut(e,t,n,r,i);P.setMaterial(r,o);let c=n.index,l=1;if(r.wireframe===!0){if(c=Te.getWireframeAttribute(n),c===void 0)return;l=2}let u=n.drawRange,d=n.attributes.position,f=u.start*l,p=(u.start+u.count)*l;a!==null&&(f=Math.max(f,a.start*l),p=Math.min(p,(a.start+a.count)*l)),c===null?d!=null&&(f=Math.max(f,0),p=Math.min(p,d.count)):(f=Math.max(f,0),p=Math.min(p,c.count));let m=p-f;if(m<0||m===1/0)return;Be.setup(i,r,s,n,c);let h,g=Le;if(c!==null&&(h=we.get(c),g=Re,g.setIndex(h)),i.isMesh)r.wireframe===!0?(P.setLineWidth(r.wireframeLinewidth*_e()),g.setMode(N.LINES)):g.setMode(N.TRIANGLES);else if(i.isLine){let e=r.linewidth;e===void 0&&(e=1),P.setLineWidth(e*_e()),i.isLineSegments?g.setMode(N.LINES):i.isLineLoop?g.setMode(N.LINE_LOOP):g.setMode(N.LINE_STRIP)}else i.isPoints?g.setMode(N.POINTS):i.isSprite&&g.setMode(N.TRIANGLES);if(i.isBatchedMesh)if(i._multiDrawInstances!==null)St(`THREE.WebGLRenderer: renderMultiDrawInstances has been deprecated and will be removed in r184. Append to renderMultiDraw arguments and use indirection.`),g.renderMultiDrawInstances(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount,i._multiDrawInstances);else if(ye.get(`WEBGL_multi_draw`))g.renderMultiDraw(i._multiDrawStarts,i._multiDrawCounts,i._multiDrawCount);else{let e=i._multiDrawStarts,t=i._multiDrawCounts,n=i._multiDrawCount,a=c?we.get(c).bytesPerElement:1,o=F.get(r).currentProgram.getUniforms();for(let r=0;r<n;r++)o.setValue(N,`_gl_DrawID`,r),g.render(e[r]/a,t[r])}else if(i.isInstancedMesh)g.renderInstances(f,m,i.count);else if(n.isInstancedBufferGeometry){let e=n._maxInstanceCount===void 0?1/0:n._maxInstanceCount,t=Math.min(n.instanceCount,e);g.renderInstances(f,m,t)}else g.render(f,m)};function Xe(e,t,n){e.transparent===!0&&e.side===2&&e.forceSinglePass===!1?(e.side=1,e.needsUpdate=!0,st(e,t,n),e.side=0,e.needsUpdate=!0,st(e,t,n),e.side=2):st(e,t,n)}this.compile=function(e,t,n=null){n===null&&(n=e),y=Ae.get(n),y.init(t),x.push(y),n.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(y.pushLight(e),e.castShadow&&y.pushShadow(e))}),e!==n&&e.traverseVisible(function(e){e.isLight&&e.layers.test(t.layers)&&(y.pushLight(e),e.castShadow&&y.pushShadow(e))}),y.setupLights();let r=new Set;return e.traverse(function(e){if(!(e.isMesh||e.isPoints||e.isLine||e.isSprite))return;let t=e.material;if(t)if(Array.isArray(t))for(let i=0;i<t.length;i++){let a=t[i];Xe(a,n,e),r.add(a)}else Xe(t,n,e),r.add(t)}),y=x.pop(),r},this.compileAsync=function(e,t,n=null){let r=this.compile(e,t,n);return new Promise(t=>{function n(){if(r.forEach(function(e){F.get(e).currentProgram.isReady()&&r.delete(e)}),r.size===0){t(e);return}setTimeout(n,10)}ye.get(`KHR_parallel_shader_compile`)===null?setTimeout(n,10):n()})};let Ze=null;function Qe(e){Ze&&Ze(e)}function $e(){tt.stop()}function et(){tt.start()}let tt=new _o;tt.setAnimationLoop(Qe),typeof self<`u`&&tt.setContext(self),this.setAnimationLoop=function(e){Ze=e,We.setAnimationLoop(e),e===null?tt.stop():tt.start()},We.addEventListener(`sessionstart`,$e),We.addEventListener(`sessionend`,et),this.render=function(e,t){if(t!==void 0&&t.isCamera!==!0){console.error(`THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.`);return}if(C===!0)return;if(e.matrixWorldAutoUpdate===!0&&e.updateMatrixWorld(),t.parent===null&&t.matrixWorldAutoUpdate===!0&&t.updateMatrixWorld(),We.enabled===!0&&We.isPresenting===!0&&(We.cameraAutoUpdate===!0&&We.updateCamera(t),t=We.getCamera()),e.isScene===!0&&e.onBeforeRender(S,e,t,E),y=Ae.get(e,x.length),y.init(t),x.push(y),fe.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),le.setFromProjectionMatrix(fe,Ve,t.reversedDepth),de=this.localClippingEnabled,ue=je.init(this.clippingPlanes,de),v=ke.get(e,b.length),v.init(),b.push(v),We.enabled===!0&&We.isPresenting===!0){let e=S.xr.getDepthSensingMesh();e!==null&&nt(e,t,-1/0,S.sortObjects)}nt(e,t,0,S.sortObjects),v.finish(),S.sortObjects===!0&&v.sort(ie,ae),ge=We.enabled===!1||We.isPresenting===!1||We.hasDepthSensing()===!1,ge&&Ne.addToRenderList(v,e),this.info.render.frame++,ue===!0&&je.beginShadows();let n=y.state.shadowsArray;Me.render(n,e,t),ue===!0&&je.endShadows(),this.info.autoReset===!0&&this.info.reset();let r=v.opaque,i=v.transmissive;if(y.setupLights(),t.isArrayCamera){let n=t.cameras;if(i.length>0)for(let t=0,a=n.length;t<a;t++){let a=n[t];it(r,i,e,a)}ge&&Ne.render(e);for(let t=0,r=n.length;t<r;t++){let r=n[t];rt(v,e,r,r.viewport)}}else i.length>0&&it(r,i,e,t),ge&&Ne.render(e),rt(v,e,t);E!==null&&T===0&&(I.updateMultisampleRenderTarget(E),I.updateRenderTargetMipmap(E)),e.isScene===!0&&e.onAfterRender(S,e,t),Be.resetDefaultState(),D=-1,ee=null,x.pop(),x.length>0?(y=x[x.length-1],ue===!0&&je.setGlobalState(S.clippingPlanes,y.state.camera)):y=null,b.pop(),v=b.length>0?b[b.length-1]:null};function nt(e,t,n,r){if(e.visible===!1)return;if(e.layers.test(t.layers)){if(e.isGroup)n=e.renderOrder;else if(e.isLOD)e.autoUpdate===!0&&e.update(t);else if(e.isLight)y.pushLight(e),e.castShadow&&y.pushShadow(e);else if(e.isSprite){if(!e.frustumCulled||le.intersectsSprite(e)){r&&me.setFromMatrixPosition(e.matrixWorld).applyMatrix4(fe);let t=Ee.update(e),i=e.material;i.visible&&v.push(e,t,i,n,me.z,null)}}else if((e.isMesh||e.isLine||e.isPoints)&&(!e.frustumCulled||le.intersectsObject(e))){let t=Ee.update(e),i=e.material;if(r&&(e.boundingSphere===void 0?(t.boundingSphere===null&&t.computeBoundingSphere(),me.copy(t.boundingSphere.center)):(e.boundingSphere===null&&e.computeBoundingSphere(),me.copy(e.boundingSphere.center)),me.applyMatrix4(e.matrixWorld).applyMatrix4(fe)),Array.isArray(i)){let r=t.groups;for(let a=0,o=r.length;a<o;a++){let o=r[a],s=i[o.materialIndex];s&&s.visible&&v.push(e,t,s,n,me.z,o)}}else i.visible&&v.push(e,t,i,n,me.z,null)}}let i=e.children;for(let e=0,a=i.length;e<a;e++)nt(i[e],t,n,r)}function rt(e,t,n,r){let i=e.opaque,a=e.transmissive,o=e.transparent;y.setupLightsView(n),ue===!0&&je.setGlobalState(S.clippingPlanes,n),r&&P.viewport(O.copy(r)),i.length>0&&at(i,t,n),a.length>0&&at(a,t,n),o.length>0&&at(o,t,n),P.buffers.depth.setTest(!0),P.buffers.depth.setMask(!0),P.buffers.color.setMask(!0),P.setPolygonOffset(!1)}function it(e,t,n,r){if((n.isScene===!0?n.overrideMaterial:null)!==null)return;y.state.transmissionRenderTarget[r.id]===void 0&&(y.state.transmissionRenderTarget[r.id]=new zt(1,1,{generateMipmaps:!0,type:ye.has(`EXT_color_buffer_half_float`)||ye.has(`EXT_color_buffer_float`)?g:l,minFilter:c,samples:4,stencilBuffer:i,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:H.workingColorSpace}));let a=y.state.transmissionRenderTarget[r.id],o=r.viewport||O;a.setSize(o.z*S.transmissionResolutionScale,o.w*S.transmissionResolutionScale);let s=S.getRenderTarget(),u=S.getActiveCubeFace(),d=S.getActiveMipmapLevel();S.setRenderTarget(a),S.getClearColor(ne),A=S.getClearAlpha(),A<1&&S.setClearColor(16777215,.5),S.clear(),ge&&Ne.render(n);let f=S.toneMapping;S.toneMapping=0;let p=r.viewport;if(r.viewport!==void 0&&(r.viewport=void 0),y.setupLightsView(r),ue===!0&&je.setGlobalState(S.clippingPlanes,r),at(e,n,r),I.updateMultisampleRenderTarget(a),I.updateRenderTargetMipmap(a),ye.has(`WEBGL_multisampled_render_to_texture`)===!1){let e=!1;for(let i=0,a=t.length;i<a;i++){let a=t[i],o=a.object,s=a.geometry,c=a.material,l=a.group;if(c.side===2&&o.layers.test(r.layers)){let t=c.side;c.side=1,c.needsUpdate=!0,ot(o,n,r,s,c,l),c.side=t,c.needsUpdate=!0,e=!0}}e===!0&&(I.updateMultisampleRenderTarget(a),I.updateRenderTargetMipmap(a))}S.setRenderTarget(s,u,d),S.setClearColor(ne,A),p!==void 0&&(r.viewport=p),S.toneMapping=f}function at(e,t,n){let r=t.isScene===!0?t.overrideMaterial:null;for(let i=0,a=e.length;i<a;i++){let a=e[i],o=a.object,s=a.geometry,c=a.group,l=a.material;l.allowOverride===!0&&r!==null&&(l=r),o.layers.test(n.layers)&&ot(o,t,n,s,l,c)}}function ot(e,t,n,r,i,a){e.onBeforeRender(S,t,n,r,i,a),e.modelViewMatrix.multiplyMatrices(n.matrixWorldInverse,e.matrixWorld),e.normalMatrix.getNormalMatrix(e.modelViewMatrix),i.onBeforeRender(S,t,n,r,e,a),i.transparent===!0&&i.side===2&&i.forceSinglePass===!1?(i.side=1,i.needsUpdate=!0,S.renderBufferDirect(n,t,r,i,e,a),i.side=0,i.needsUpdate=!0,S.renderBufferDirect(n,t,r,i,e,a),i.side=2):S.renderBufferDirect(n,t,r,i,e,a),e.onAfterRender(S,t,n,r,i,a)}function st(e,t,n){t.isScene!==!0&&(t=he);let r=F.get(e),i=y.state.lights,a=y.state.shadowsArray,o=i.state.version,s=De.getParameters(e,i.state,a,t,n),c=De.getProgramCacheKey(s),l=r.programs;r.environment=e.isMeshStandardMaterial?t.environment:null,r.fog=t.fog,r.envMap=(e.isMeshStandardMaterial?Ce:Se).get(e.envMap||r.environment),r.envMapRotation=r.environment!==null&&e.envMap===null?t.environmentRotation:e.envMapRotation,l===void 0&&(e.addEventListener(`dispose`,L),l=new Map,r.programs=l);let u=l.get(c);if(u!==void 0){if(r.currentProgram===u&&r.lightsStateVersion===o)return lt(e,s),u}else s.uniforms=De.getUniforms(e),e.onBeforeCompile(s,S),u=De.acquireProgram(s,c),l.set(c,u),r.uniforms=s.uniforms;let d=r.uniforms;return(!e.isShaderMaterial&&!e.isRawShaderMaterial||e.clipping===!0)&&(d.clippingPlanes=je.uniform),lt(e,s),r.needsLights=ft(e),r.lightsStateVersion=o,r.needsLights&&(d.ambientLightColor.value=i.state.ambient,d.lightProbe.value=i.state.probe,d.directionalLights.value=i.state.directional,d.directionalLightShadows.value=i.state.directionalShadow,d.spotLights.value=i.state.spot,d.spotLightShadows.value=i.state.spotShadow,d.rectAreaLights.value=i.state.rectArea,d.ltc_1.value=i.state.rectAreaLTC1,d.ltc_2.value=i.state.rectAreaLTC2,d.pointLights.value=i.state.point,d.pointLightShadows.value=i.state.pointShadow,d.hemisphereLights.value=i.state.hemi,d.directionalShadowMap.value=i.state.directionalShadowMap,d.directionalShadowMatrix.value=i.state.directionalShadowMatrix,d.spotShadowMap.value=i.state.spotShadowMap,d.spotLightMatrix.value=i.state.spotLightMatrix,d.spotLightMap.value=i.state.spotLightMap,d.pointShadowMap.value=i.state.pointShadowMap,d.pointShadowMatrix.value=i.state.pointShadowMatrix),r.currentProgram=u,r.uniformsList=null,u}function ct(e){if(e.uniformsList===null){let t=e.currentProgram.getUniforms();e.uniformsList=lc.seqWithValue(t.seq,e.uniforms)}return e.uniformsList}function lt(e,t){let n=F.get(e);n.outputColorSpace=t.outputColorSpace,n.batching=t.batching,n.batchingColor=t.batchingColor,n.instancing=t.instancing,n.instancingColor=t.instancingColor,n.instancingMorph=t.instancingMorph,n.skinning=t.skinning,n.morphTargets=t.morphTargets,n.morphNormals=t.morphNormals,n.morphColors=t.morphColors,n.morphTargetsCount=t.morphTargetsCount,n.numClippingPlanes=t.numClippingPlanes,n.numIntersection=t.numClipIntersection,n.vertexAlphas=t.vertexAlphas,n.vertexTangents=t.vertexTangents,n.toneMapping=t.toneMapping}function ut(e,t,n,r,i){t.isScene!==!0&&(t=he),I.resetTextureUnits();let a=t.fog,o=r.isMeshStandardMaterial?t.environment:null,s=E===null?S.outputColorSpace:E.isXRRenderTarget===!0?E.texture.colorSpace:Ie,c=(r.isMeshStandardMaterial?Ce:Se).get(r.envMap||o),l=r.vertexColors===!0&&!!n.attributes.color&&n.attributes.color.itemSize===4,u=!!n.attributes.tangent&&(!!r.normalMap||r.anisotropy>0),d=!!n.morphAttributes.position,f=!!n.morphAttributes.normal,p=!!n.morphAttributes.color,m=0;r.toneMapped&&(E===null||E.isXRRenderTarget===!0)&&(m=S.toneMapping);let h=n.morphAttributes.position||n.morphAttributes.normal||n.morphAttributes.color,g=h===void 0?0:h.length,_=F.get(r),v=y.state.lights;if(ue===!0&&(de===!0||e!==ee)){let t=e===ee&&r.id===D;je.setState(r,e,t)}let b=!1;r.version===_.__version?_.needsLights&&_.lightsStateVersion!==v.state.version?b=!0:_.outputColorSpace===s?i.isBatchedMesh&&_.batching===!1||!i.isBatchedMesh&&_.batching===!0||i.isBatchedMesh&&_.batchingColor===!0&&i.colorTexture===null||i.isBatchedMesh&&_.batchingColor===!1&&i.colorTexture!==null||i.isInstancedMesh&&_.instancing===!1||!i.isInstancedMesh&&_.instancing===!0||i.isSkinnedMesh&&_.skinning===!1||!i.isSkinnedMesh&&_.skinning===!0||i.isInstancedMesh&&_.instancingColor===!0&&i.instanceColor===null||i.isInstancedMesh&&_.instancingColor===!1&&i.instanceColor!==null||i.isInstancedMesh&&_.instancingMorph===!0&&i.morphTexture===null||i.isInstancedMesh&&_.instancingMorph===!1&&i.morphTexture!==null?b=!0:_.envMap===c?r.fog===!0&&_.fog!==a||_.numClippingPlanes!==void 0&&(_.numClippingPlanes!==je.numPlanes||_.numIntersection!==je.numIntersection)?b=!0:_.vertexAlphas===l&&_.vertexTangents===u&&_.morphTargets===d&&_.morphNormals===f&&_.morphColors===p&&_.toneMapping===m?_.morphTargetsCount!==g&&(b=!0):b=!0:b=!0:b=!0:(b=!0,_.__version=r.version);let x=_.currentProgram;b===!0&&(x=st(r,t,i));let C=!1,w=!1,T=!1,O=x.getUniforms(),k=_.uniforms;if(P.useProgram(x.program)&&(C=!0,w=!0,T=!0),r.id!==D&&(D=r.id,w=!0),C||ee!==e){P.buffers.depth.getReversed()&&e.reversedDepth!==!0&&(e._reversedDepth=!0,e.updateProjectionMatrix()),O.setValue(N,`projectionMatrix`,e.projectionMatrix),O.setValue(N,`viewMatrix`,e.matrixWorldInverse);let t=O.map.cameraPosition;t!==void 0&&t.setValue(N,pe.setFromMatrixPosition(e.matrixWorld)),be.logarithmicDepthBuffer&&O.setValue(N,`logDepthBufFC`,2/(Math.log(e.far+1)/Math.LN2)),(r.isMeshPhongMaterial||r.isMeshToonMaterial||r.isMeshLambertMaterial||r.isMeshBasicMaterial||r.isMeshStandardMaterial||r.isShaderMaterial)&&O.setValue(N,`isOrthographic`,e.isOrthographicCamera===!0),ee!==e&&(ee=e,w=!0,T=!0)}if(i.isSkinnedMesh){O.setOptional(N,i,`bindMatrix`),O.setOptional(N,i,`bindMatrixInverse`);let e=i.skeleton;e&&(e.boneTexture===null&&e.computeBoneTexture(),O.setValue(N,`boneTexture`,e.boneTexture,I))}i.isBatchedMesh&&(O.setOptional(N,i,`batchingTexture`),O.setValue(N,`batchingTexture`,i._matricesTexture,I),O.setOptional(N,i,`batchingIdTexture`),O.setValue(N,`batchingIdTexture`,i._indirectTexture,I),O.setOptional(N,i,`batchingColorTexture`),i._colorsTexture!==null&&O.setValue(N,`batchingColorTexture`,i._colorsTexture,I));let te=n.morphAttributes;if((te.position!==void 0||te.normal!==void 0||te.color!==void 0)&&Pe.update(i,n,x),(w||_.receiveShadow!==i.receiveShadow)&&(_.receiveShadow=i.receiveShadow,O.setValue(N,`receiveShadow`,i.receiveShadow)),r.isMeshGouraudMaterial&&r.envMap!==null&&(k.envMap.value=c,k.flipEnvMap.value=c.isCubeTexture&&c.isRenderTargetTexture===!1?-1:1),r.isMeshStandardMaterial&&r.envMap===null&&t.environment!==null&&(k.envMapIntensity.value=t.environmentIntensity),w&&(O.setValue(N,`toneMappingExposure`,S.toneMappingExposure),_.needsLights&&dt(k,T),a&&r.fog===!0&&Oe.refreshFogUniforms(k,a),Oe.refreshMaterialUniforms(k,r,M,j,y.state.transmissionRenderTarget[e.id]),lc.upload(N,ct(_),k,I)),r.isShaderMaterial&&r.uniformsNeedUpdate===!0&&(lc.upload(N,ct(_),k,I),r.uniformsNeedUpdate=!1),r.isSpriteMaterial&&O.setValue(N,`center`,i.center),O.setValue(N,`modelViewMatrix`,i.modelViewMatrix),O.setValue(N,`normalMatrix`,i.normalMatrix),O.setValue(N,`modelMatrix`,i.matrixWorld),r.isShaderMaterial||r.isRawShaderMaterial){let e=r.uniformsGroups;for(let t=0,n=e.length;t<n;t++){let n=e[t];He.update(n,x),He.bind(n,x)}}return x}function dt(e,t){e.ambientLightColor.needsUpdate=t,e.lightProbe.needsUpdate=t,e.directionalLights.needsUpdate=t,e.directionalLightShadows.needsUpdate=t,e.pointLights.needsUpdate=t,e.pointLightShadows.needsUpdate=t,e.spotLights.needsUpdate=t,e.spotLightShadows.needsUpdate=t,e.rectAreaLights.needsUpdate=t,e.hemisphereLights.needsUpdate=t}function ft(e){return e.isMeshLambertMaterial||e.isMeshToonMaterial||e.isMeshPhongMaterial||e.isMeshStandardMaterial||e.isShadowMaterial||e.isShaderMaterial&&e.lights===!0}this.getActiveCubeFace=function(){return w},this.getActiveMipmapLevel=function(){return T},this.getRenderTarget=function(){return E},this.setRenderTargetTextures=function(e,t,n){let r=F.get(e);r.__autoAllocateDepthBuffer=e.resolveDepthBuffer===!1,r.__autoAllocateDepthBuffer===!1&&(r.__useRenderToTexture=!1),F.get(e.texture).__webglTexture=t,F.get(e.depthTexture).__webglTexture=r.__autoAllocateDepthBuffer?void 0:n,r.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(e,t){let n=F.get(e);n.__webglFramebuffer=t,n.__useDefaultFramebuffer=t===void 0};let R=N.createFramebuffer();this.setRenderTarget=function(e,t=0,n=0){E=e,w=t,T=n;let r=!0,i=null,a=!1,o=!1;if(e){let s=F.get(e);if(s.__useDefaultFramebuffer!==void 0)P.bindFramebuffer(N.FRAMEBUFFER,null),r=!1;else if(s.__webglFramebuffer===void 0)I.setupRenderTarget(e);else if(s.__hasExternalTextures)I.rebindTextures(e,F.get(e.texture).__webglTexture,F.get(e.depthTexture).__webglTexture);else if(e.depthBuffer){let t=e.depthTexture;if(s.__boundDepthTexture!==t){if(t!==null&&F.has(t)&&(e.width!==t.image.width||e.height!==t.image.height))throw Error(`WebGLRenderTarget: Attached DepthTexture is initialized to the incorrect size.`);I.setupDepthRenderbuffer(e)}}let c=e.texture;(c.isData3DTexture||c.isDataArrayTexture||c.isCompressedArrayTexture)&&(o=!0);let l=F.get(e).__webglFramebuffer;e.isWebGLCubeRenderTarget?(i=Array.isArray(l[t])?l[t][n]:l[t],a=!0):i=e.samples>0&&I.useMultisampledRTT(e)===!1?F.get(e).__webglMultisampledFramebuffer:Array.isArray(l)?l[n]:l,O.copy(e.viewport),k.copy(e.scissor),te=e.scissorTest}else O.copy(oe).multiplyScalar(M).floor(),k.copy(se).multiplyScalar(M).floor(),te=ce;if(n!==0&&(i=R),P.bindFramebuffer(N.FRAMEBUFFER,i)&&r&&P.drawBuffers(e,i),P.viewport(O),P.scissor(k),P.setScissorTest(te),a){let r=F.get(e.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+t,r.__webglTexture,n)}else if(o){let r=t;for(let t=0;t<e.textures.length;t++){let i=F.get(e.textures[t]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+t,i.__webglTexture,n,r)}}else if(e!==null&&n!==0){let t=F.get(e.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,t.__webglTexture,n)}D=-1},this.readRenderTargetPixels=function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);return}let c=F.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c){P.bindFramebuffer(N.FRAMEBUFFER,c);try{let o=e.textures[s],c=o.format,l=o.type;if(!be.textureFormatReadable(c)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.`);return}if(!be.textureTypeReadable(l)){console.error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.`);return}t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i&&(e.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+s),N.readPixels(t,n,r,i,ze.convert(c),ze.convert(l),a))}finally{let e=E===null?null:F.get(E).__webglFramebuffer;P.bindFramebuffer(N.FRAMEBUFFER,e)}}},this.readRenderTargetPixelsAsync=async function(e,t,n,r,i,a,o,s=0){if(!(e&&e.isWebGLRenderTarget))throw Error(`THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.`);let c=F.get(e).__webglFramebuffer;if(e.isWebGLCubeRenderTarget&&o!==void 0&&(c=c[o]),c)if(t>=0&&t<=e.width-r&&n>=0&&n<=e.height-i){P.bindFramebuffer(N.FRAMEBUFFER,c);let o=e.textures[s],l=o.format,u=o.type;if(!be.textureFormatReadable(l))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.`);if(!be.textureTypeReadable(u))throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.`);let d=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,d),N.bufferData(N.PIXEL_PACK_BUFFER,a.byteLength,N.STREAM_READ),e.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+s),N.readPixels(t,n,r,i,ze.convert(l),ze.convert(u),0);let f=E===null?null:F.get(E).__webglFramebuffer;P.bindFramebuffer(N.FRAMEBUFFER,f);let p=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await Ct(N,p,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,d),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,a),N.deleteBuffer(d),N.deleteSync(p),a}else throw Error(`THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.`)},this.copyFramebufferToTexture=function(e,t=null,n=0){let r=2**-n,i=Math.floor(e.image.width*r),a=Math.floor(e.image.height*r),o=t===null?0:t.x,s=t===null?0:t.y;I.setTexture2D(e,0),N.copyTexSubImage2D(N.TEXTURE_2D,n,0,0,o,s,i,a),P.unbindTexture()};let pt=N.createFramebuffer(),z=N.createFramebuffer();this.copyTextureToTexture=function(e,t,n=null,r=null,i=0,a=null){a===null&&(i===0?a=0:(St(`WebGLRenderer: copyTextureToTexture function signature has changed to support src and dst mipmap levels.`),a=i,i=0));let o,s,c,l,u,d,f,p,m,h=e.isCompressedTexture?e.mipmaps[a]:e.image;if(n!==null)o=n.max.x-n.min.x,s=n.max.y-n.min.y,c=n.isBox3?n.max.z-n.min.z:1,l=n.min.x,u=n.min.y,d=n.isBox3?n.min.z:0;else{let t=2**-i;o=Math.floor(h.width*t),s=Math.floor(h.height*t),c=e.isDataArrayTexture?h.depth:e.isData3DTexture?Math.floor(h.depth*t):1,l=0,u=0,d=0}r===null?(f=0,p=0,m=0):(f=r.x,p=r.y,m=r.z);let g=ze.convert(t.format),_=ze.convert(t.type),v;t.isData3DTexture?(I.setTexture3D(t,0),v=N.TEXTURE_3D):t.isDataArrayTexture||t.isCompressedArrayTexture?(I.setTexture2DArray(t,0),v=N.TEXTURE_2D_ARRAY):(I.setTexture2D(t,0),v=N.TEXTURE_2D),N.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,t.flipY),N.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t.premultiplyAlpha),N.pixelStorei(N.UNPACK_ALIGNMENT,t.unpackAlignment);let y=N.getParameter(N.UNPACK_ROW_LENGTH),b=N.getParameter(N.UNPACK_IMAGE_HEIGHT),x=N.getParameter(N.UNPACK_SKIP_PIXELS),S=N.getParameter(N.UNPACK_SKIP_ROWS),C=N.getParameter(N.UNPACK_SKIP_IMAGES);N.pixelStorei(N.UNPACK_ROW_LENGTH,h.width),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,h.height),N.pixelStorei(N.UNPACK_SKIP_PIXELS,l),N.pixelStorei(N.UNPACK_SKIP_ROWS,u),N.pixelStorei(N.UNPACK_SKIP_IMAGES,d);let w=e.isDataArrayTexture||e.isData3DTexture,T=t.isDataArrayTexture||t.isData3DTexture;if(e.isDepthTexture){let n=F.get(e),r=F.get(t),h=F.get(n.__renderTarget),g=F.get(r.__renderTarget);P.bindFramebuffer(N.READ_FRAMEBUFFER,h.__webglFramebuffer),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,g.__webglFramebuffer);for(let n=0;n<c;n++)w&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,F.get(e).__webglTexture,i,d+n),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,F.get(t).__webglTexture,a,m+n)),N.blitFramebuffer(l,u,o,s,f,p,o,s,N.DEPTH_BUFFER_BIT,N.NEAREST);P.bindFramebuffer(N.READ_FRAMEBUFFER,null),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(i!==0||e.isRenderTargetTexture||F.has(e)){let n=F.get(e),r=F.get(t);P.bindFramebuffer(N.READ_FRAMEBUFFER,pt),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,z);for(let e=0;e<c;e++)w?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,n.__webglTexture,i,d+e):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,n.__webglTexture,i),T?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,r.__webglTexture,a,m+e):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,r.__webglTexture,a),i===0?T?N.copyTexSubImage3D(v,a,f,p,m+e,l,u,o,s):N.copyTexSubImage2D(v,a,f,p,l,u,o,s):N.blitFramebuffer(l,u,o,s,f,p,o,s,N.COLOR_BUFFER_BIT,N.NEAREST);P.bindFramebuffer(N.READ_FRAMEBUFFER,null),P.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else T?e.isDataTexture||e.isData3DTexture?N.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h.data):t.isCompressedArrayTexture?N.compressedTexSubImage3D(v,a,f,p,m,o,s,c,g,h.data):N.texSubImage3D(v,a,f,p,m,o,s,c,g,_,h):e.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,a,f,p,o,s,g,_,h.data):e.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,a,f,p,h.width,h.height,g,h.data):N.texSubImage2D(N.TEXTURE_2D,a,f,p,o,s,g,_,h);N.pixelStorei(N.UNPACK_ROW_LENGTH,y),N.pixelStorei(N.UNPACK_IMAGE_HEIGHT,b),N.pixelStorei(N.UNPACK_SKIP_PIXELS,x),N.pixelStorei(N.UNPACK_SKIP_ROWS,S),N.pixelStorei(N.UNPACK_SKIP_IMAGES,C),a===0&&t.generateMipmaps&&N.generateMipmap(v),P.unbindTexture()},this.initRenderTarget=function(e){F.get(e).__webglFramebuffer===void 0&&I.setupRenderTarget(e)},this.initTexture=function(e){e.isCubeTexture?I.setTextureCube(e,0):e.isData3DTexture?I.setTexture3D(e,0):e.isDataArrayTexture||e.isCompressedArrayTexture?I.setTexture2DArray(e,0):I.setTexture2D(e,0),P.unbindTexture()},this.resetState=function(){w=0,T=0,E=null,P.reset(),Be.reset()},typeof __THREE_DEVTOOLS__<`u`&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent(`observe`,{detail:this}))}get coordinateSystem(){return Ve}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;let t=this.getContext();t.drawingBufferColorSpace=H._getDrawingBufferColorSpace(e),t.unpackColorSpace=H._getUnpackColorSpace()}},yl={LEFT:1,RIGHT:2,MIDDLE:4},J=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288}),bl={NONE:0,IN:1,OUT:-1};function xl(e){return e.isPerspectiveCamera}function Sl(e){return e.isOrthographicCamera}var Cl=Math.PI*2,wl=Math.PI/2,Tl=1e-5,El=Math.PI/180;function Dl(e,t,n){return Math.max(t,Math.min(n,e))}function Ol(e,t=Tl){return Math.abs(e)<t}function Y(e,t,n=Tl){return Ol(e-t,n)}function kl(e,t){return Math.round(e/t)*t}function Al(e){return isFinite(e)?e:e<0?-Number.MAX_VALUE:Number.MAX_VALUE}function jl(e){return Math.abs(e)<Number.MAX_VALUE?e:e*(1/0)}function Ml(e,t,n,r,i=1/0,a){r=Math.max(1e-4,r);let o=2/r,s=o*a,c=1/(1+s+.48*s*s+.235*s*s*s),l=e-t,u=t,d=i*r;l=Dl(l,-d,d),t=e-l;let f=(n.value+o*l)*a;n.value=(n.value-o*f)*c;let p=t+(l+f)*c;return u-e>0==p>u&&(p=u,n.value=(p-u)/a),p}function Nl(e,t,n,r,i=1/0,a,o){r=Math.max(1e-4,r);let s=2/r,c=s*a,l=1/(1+c+.48*c*c+.235*c*c*c),u=t.x,d=t.y,f=t.z,p=e.x-u,m=e.y-d,h=e.z-f,g=u,_=d,v=f,y=i*r,b=y*y,x=p*p+m*m+h*h;if(x>b){let e=Math.sqrt(x);p=p/e*y,m=m/e*y,h=h/e*y}u=e.x-p,d=e.y-m,f=e.z-h;let S=(n.x+s*p)*a,C=(n.y+s*m)*a,w=(n.z+s*h)*a;n.x=(n.x-s*S)*l,n.y=(n.y-s*C)*l,n.z=(n.z-s*w)*l,o.x=u+(p+S)*l,o.y=d+(m+C)*l,o.z=f+(h+w)*l;let T=g-e.x,E=_-e.y,D=v-e.z,ee=o.x-g,O=o.y-_,k=o.z-v;return T*ee+E*O+D*k>0&&(o.x=g,o.y=_,o.z=v,n.x=(o.x-g)/a,n.y=(o.y-_)/a,n.z=(o.z-v)/a),o}function Pl(e,t){t.set(0,0),e.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=e.length,t.y/=e.length}function Fl(e,t){return Sl(e)?(console.warn(`${t} is not supported in OrthographicCamera`),!0):!1}var Il=class{_listeners={};addEventListener(e,t){let n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){let n=this._listeners;return n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){let n=this._listeners[e];if(n!==void 0){let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}removeAllEventListeners(e){if(!e){this._listeners={};return}Array.isArray(this._listeners[e])&&(this._listeners[e].length=0)}dispatchEvent(e){let t=this._listeners[e.type];if(t!==void 0){e.target=this;let n=t.slice(0);for(let t=0,r=n.length;t<r;t++)n[t].call(this,e)}}},Ll=`3.1.2`,Rl=1/8,zl=/Mac/.test(globalThis?.navigator?.platform),X,Bl,Vl,Hl,Ul,Z,Q,Wl,Gl,Kl,ql,Jl,Yl,Xl,Zl,Ql,$l,eu,tu,nu,ru,iu,au,ou=class e extends Il{static install(e){X=e.THREE,Bl=Object.freeze(new X.Vector3(0,0,0)),Vl=Object.freeze(new X.Vector3(0,1,0)),Hl=Object.freeze(new X.Vector3(0,0,1)),Ul=new X.Vector2,Z=new X.Vector3,Q=new X.Vector3,Wl=new X.Vector3,Gl=new X.Vector3,Kl=new X.Vector3,ql=new X.Vector3,Jl=new X.Vector3,Yl=new X.Vector3,Xl=new X.Vector3,Zl=new X.Spherical,Ql=new X.Spherical,$l=new X.Box3,eu=new X.Box3,tu=new X.Sphere,nu=new X.Quaternion,ru=new X.Quaternion,iu=new X.Matrix4,au=new X.Raycaster}static get ACTION(){return J}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=2**-52;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=J.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=bl.NONE;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new X.Vector3;_focalOffsetVelocity=new X.Vector3;_zoomVelocity={value:0};set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(t,n){super(),X===void 0&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=new X.Quaternion().setFromUnitVectors(this._camera.up,Vl),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=J.NONE,this._target=new X.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new X.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=new X.Spherical().setFromVector3(Z.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new X.Vector3,new X.Vector3,new X.Vector3,new X.Vector3],this._updateNearPlaneCorners(),this._boundary=new X.Box3(new X.Vector3(-1/0,-1/0,-1/0),new X.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new X.Vector2,this.mouseButtons={left:J.ROTATE,middle:J.DOLLY,right:J.TRUCK,wheel:xl(this._camera)?J.DOLLY:Sl(this._camera)?J.ZOOM:J.NONE},this.touches={one:J.TOUCH_ROTATE,two:xl(this._camera)?J.TOUCH_DOLLY_TRUCK:Sl(this._camera)?J.TOUCH_ZOOM_TRUCK:J.NONE,three:J.TOUCH_TRUCK};let r=new X.Vector2,i=new X.Vector2,a=new X.Vector2,o=e=>{if(!this._enabled||!this._domElement)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(n<this._interactiveArea.left||n>this._interactiveArea.right||r<this._interactiveArea.top||r>this._interactiveArea.bottom)return}let t=e.pointerType===`mouse`?(e.buttons&yl.LEFT)===yl.LEFT?yl.LEFT:(e.buttons&yl.MIDDLE)===yl.MIDDLE?yl.MIDDLE:(e.buttons&yl.RIGHT)===yl.RIGHT?yl.RIGHT:null:null;if(t!==null){let e=this._findPointerByMouseButton(t);e&&this._disposePointer(e)}if((e.buttons&yl.LEFT)===yl.LEFT&&this._lockedPointer)return;let n={pointerId:e.pointerId,clientX:e.clientX,clientY:e.clientY,deltaX:0,deltaY:0,mouseButton:t};this._activePointers.push(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),this._isDragging=!0,f(e)},s=e=>{e.cancelable&&e.preventDefault();let t=e.pointerId,n=this._lockedPointer||this._findPointerById(t);if(n){if(n.clientX=e.clientX,n.clientY=e.clientY,n.deltaX=e.movementX,n.deltaY=e.movementY,this._state=0,e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else (!this._isDragging&&this._lockedPointer||this._isDragging&&(e.buttons&yl.LEFT)===yl.LEFT)&&(this._state|=this.mouseButtons.left),this._isDragging&&(e.buttons&yl.MIDDLE)===yl.MIDDLE&&(this._state|=this.mouseButtons.middle),this._isDragging&&(e.buttons&yl.RIGHT)===yl.RIGHT&&(this._state|=this.mouseButtons.right);p()}},c=e=>{let t=this._findPointerById(e.pointerId);if(!(t&&t===this._lockedPointer)){if(t&&this._disposePointer(t),e.pointerType===`touch`)switch(this._activePointers.length){case 0:this._state=J.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else this._state=J.NONE;m()}},l=-1,u=e=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===J.NONE)return;if(this._interactiveArea.left!==0||this._interactiveArea.top!==0||this._interactiveArea.width!==1||this._interactiveArea.height!==1){let t=this._domElement.getBoundingClientRect(),n=e.clientX/t.width,r=e.clientY/t.height;if(n<this._interactiveArea.left||n>this._interactiveArea.right||r<this._interactiveArea.top||r>this._interactiveArea.bottom)return}if(e.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===J.ROTATE||this.mouseButtons.wheel===J.TRUCK){let e=performance.now();l-e<1e3&&this._getClientRect(this._elementRect),l=e}let t=zl?-1:-3,n=e.deltaMode===1&&!e.ctrlKey?e.deltaY/t:e.deltaY/(t*10),r=this.dollyToCursor?(e.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,i=this.dollyToCursor?(e.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(e.ctrlKey?J.ZOOM:this.mouseButtons.wheel){case J.ROTATE:this._rotateInternal(e.deltaX,e.deltaY),this._isUserControllingRotate=!0;break;case J.TRUCK:this._truckInternal(e.deltaX,e.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case J.SCREEN_PAN:this._truckInternal(e.deltaX,e.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case J.OFFSET:this._truckInternal(e.deltaX,e.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case J.DOLLY:this._dollyInternal(-n,r,i),this._isUserControllingDolly=!0;break;case J.ZOOM:this._zoomInternal(-n,r,i),this._isUserControllingZoom=!0;break}this.dispatchEvent({type:`control`})},d=t=>{if(!(!this._domElement||!this._enabled)){if(this.mouseButtons.right===e.ACTION.NONE){let e=t instanceof PointerEvent?t.pointerId:0,n=this._findPointerById(e);n&&this._disposePointer(n),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c);return}t.preventDefault()}},f=e=>{if(this._enabled){if(Pl(this._activePointers,Ul),this._getClientRect(this._elementRect),r.copy(Ul),i.copy(Ul),this._activePointers.length>=2){let e=Ul.x-this._activePointers[1].clientX,t=Ul.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t);a.set(0,n);let r=(this._activePointers[0].clientX+this._activePointers[1].clientX)*.5,o=(this._activePointers[0].clientY+this._activePointers[1].clientY)*.5;i.set(r,o)}if(this._state=0,!e)this._lockedPointer&&(this._state|=this.mouseButtons.left);else if(`pointerType`in e&&e.pointerType===`touch`)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three;break}else !this._lockedPointer&&(e.buttons&yl.LEFT)===yl.LEFT&&(this._state|=this.mouseButtons.left),(e.buttons&yl.MIDDLE)===yl.MIDDLE&&(this._state|=this.mouseButtons.middle),(e.buttons&yl.RIGHT)===yl.RIGHT&&(this._state|=this.mouseButtons.right);((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&J.TRUCK)===J.TRUCK||(this._state&J.SCREEN_PAN)===J.SCREEN_PAN||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_SCREEN_PAN)===J.TOUCH_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&J.DOLLY)===J.DOLLY||(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&J.ZOOM)===J.ZOOM||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:`controlstart`})}},p=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,Pl(this._activePointers,Ul);let e=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,t=e?-e.deltaX:i.x-Ul.x,n=e?-e.deltaY:i.y-Ul.y;if(i.copy(Ul),((this._state&J.ROTATE)===J.ROTATE||(this._state&J.TOUCH_ROTATE)===J.TOUCH_ROTATE||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(t,n),this._isUserControllingRotate=!0),(this._state&J.DOLLY)===J.DOLLY||(this._state&J.ZOOM)===J.ZOOM){let e=this.dollyToCursor?(r.x-this._elementRect.x)/this._elementRect.width*2-1:0,t=this.dollyToCursor?(r.y-this._elementRect.y)/this._elementRect.height*-2+1:0,i=this.dollyDragInverted?-1:1;(this._state&J.DOLLY)===J.DOLLY?(this._dollyInternal(i*n*Rl,e,t),this._isUserControllingDolly=!0):(this._zoomInternal(i*n*Rl,e,t),this._isUserControllingZoom=!0)}if((this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_ZOOM)===J.TOUCH_ZOOM||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_ZOOM_ROTATE)===J.TOUCH_ZOOM_ROTATE){let e=Ul.x-this._activePointers[1].clientX,t=Ul.y-this._activePointers[1].clientY,n=Math.sqrt(e*e+t*t),r=a.y-n;a.set(0,n);let o=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,s=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&J.TOUCH_DOLLY)===J.TOUCH_DOLLY||(this._state&J.TOUCH_DOLLY_ROTATE)===J.TOUCH_DOLLY_ROTATE||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET?(this._dollyInternal(r*Rl,o,s),this._isUserControllingDolly=!0):(this._zoomInternal(r*Rl,o,s),this._isUserControllingZoom=!0)}((this._state&J.TRUCK)===J.TRUCK||(this._state&J.TOUCH_TRUCK)===J.TOUCH_TRUCK||(this._state&J.TOUCH_DOLLY_TRUCK)===J.TOUCH_DOLLY_TRUCK||(this._state&J.TOUCH_ZOOM_TRUCK)===J.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(t,n,!1,!1),this._isUserControllingTruck=!0),((this._state&J.SCREEN_PAN)===J.SCREEN_PAN||(this._state&J.TOUCH_SCREEN_PAN)===J.TOUCH_SCREEN_PAN||(this._state&J.TOUCH_DOLLY_SCREEN_PAN)===J.TOUCH_DOLLY_SCREEN_PAN||(this._state&J.TOUCH_ZOOM_SCREEN_PAN)===J.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(t,n,!1,!0),this._isUserControllingTruck=!0),((this._state&J.OFFSET)===J.OFFSET||(this._state&J.TOUCH_OFFSET)===J.TOUCH_OFFSET||(this._state&J.TOUCH_DOLLY_OFFSET)===J.TOUCH_DOLLY_OFFSET||(this._state&J.TOUCH_ZOOM_OFFSET)===J.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(t,n,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:`control`})},m=()=>{Pl(this._activePointers,Ul),i.copy(Ul),this._dragNeedsUpdate=!1,(this._activePointers.length===0||this._activePointers.length===1&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),this._activePointers.length===0&&this._domElement&&(this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this.dispatchEvent({type:`controlend`}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.addEventListener(`pointerlockerror`,g),this._domElement.ownerDocument.addEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.addEventListener(`pointerup`,c),f())},this.unlockPointer=()=>{this._lockedPointer!==null&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener(`pointerlockchange`,h),this._domElement?.ownerDocument.removeEventListener(`pointerlockerror`,g),this.cancel()};let h=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},g=()=>{this.unlockPointer()};this._addAllEventListeners=e=>{this._domElement=e,this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`,this._domElement.addEventListener(`pointerdown`,o),this._domElement.addEventListener(`pointercancel`,c),this._domElement.addEventListener(`wheel`,u,{passive:!1}),this._domElement.addEventListener(`contextmenu`,d)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``,this._domElement.removeEventListener(`pointerdown`,o),this._domElement.removeEventListener(`pointercancel`,c),this._domElement.removeEventListener(`wheel`,u,{passive:!1}),this._domElement.removeEventListener(`contextmenu`,d),this._domElement.ownerDocument.removeEventListener(`pointermove`,s,{passive:!1}),this._domElement.ownerDocument.removeEventListener(`pointerup`,c),this._domElement.ownerDocument.removeEventListener(`pointerlockchange`,h),this._domElement.ownerDocument.removeEventListener(`pointerlockerror`,g))},this.cancel=()=>{this._state!==J.NONE&&(this._state=J.NONE,this._activePointers.length=0,m())},n&&this.connect(n),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(this._domElement.style.touchAction=`none`,this._domElement.style.userSelect=`none`,this._domElement.style.webkitUserSelect=`none`):(this.cancel(),this._domElement.style.touchAction=``,this._domElement.style.userSelect=``,this._domElement.style.webkitUserSelect=``))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=Dl(e.width,0,1),this._interactiveArea.height=Dl(e.height,0,1),this._interactiveArea.x=Dl(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=Dl(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,n=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,n)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,n=!1){this._isUserControllingRotate=!1;let r=Dl(e,this.minAzimuthAngle,this.maxAzimuthAngle),i=Dl(t,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=r,this._sphericalEnd.phi=i,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,n||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);let a=!n||Y(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Y(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(a)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0,this._dollyToNoClamp(Dl(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){let n=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){let t=this._collisionTest(),r=Y(t,this._spherical.radius);if(!(n>e)&&r)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,t)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);let r=!t||Y(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(r)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Gl).multiplyScalar(e)),t||this._target.copy(this._targetEnd);let n=!t||Y(this._target.x,this._targetEnd.x,this.restThreshold)&&Y(this._target.y,this._targetEnd.y,this.restThreshold)&&Y(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=Dl(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);let n=!t||Y(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(n)}pan(e,t,n=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,n)}truck(e,t,n=!1){this._camera.updateMatrix(),Kl.setFromMatrixColumn(this._camera.matrix,0),ql.setFromMatrixColumn(this._camera.matrix,1),Kl.multiplyScalar(e),ql.multiplyScalar(-t);let r=Z.copy(Kl).add(ql),i=Q.copy(this._targetEnd).add(r);return this.moveTo(i.x,i.y,i.z,n)}forward(e,t=!1){Z.setFromMatrixColumn(this._camera.matrix,0),Z.crossVectors(this._camera.up,Z),Z.multiplyScalar(e);let n=Q.copy(this._targetEnd).add(Z);return this.moveTo(n.x,n.y,n.z,t)}elevate(e,t=!1){return Z.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+Z.x,this._targetEnd.y+Z.y,this._targetEnd.z+Z.z,t)}moveTo(e,t,n,r=!1){this._isUserControllingTruck=!1;let i=Z.set(e,t,n).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,i,this.boundaryFriction),this._needsUpdate=!0,r||this._target.copy(this._targetEnd);let a=!r||Y(this._target.x,this._targetEnd.x,this.restThreshold)&&Y(this._target.y,this._targetEnd.y,this.restThreshold)&&Y(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(a)}lookInDirectionOf(e,t,n,r=!1){let i=Z.set(e,t,n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(i.x,i.y,i.z,r)}fitToBox(e,t,{cover:n=!1,paddingLeft:r=0,paddingRight:i=0,paddingBottom:a=0,paddingTop:o=0}={}){let s=[],c=e.isBox3?$l.copy(e):$l.setFromObject(e);c.isEmpty()&&(console.warn(`camera-controls: fitTo() cannot be used with an empty box. Aborting`),Promise.resolve());let l=kl(this._sphericalEnd.theta,wl),u=kl(this._sphericalEnd.phi,wl);s.push(this.rotateTo(l,u,t));let d=Z.setFromSpherical(this._sphericalEnd).normalize(),f=nu.setFromUnitVectors(d,Hl),p=Y(Math.abs(d.y),1);p&&f.multiply(ru.setFromAxisAngle(Vl,l)),f.multiply(this._yAxisUpSpaceInverse);let m=eu.makeEmpty();Q.copy(c.min).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.min).setX(c.max.x).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.min).setY(c.max.y).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.max).setZ(c.min.z).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.min).setZ(c.max.z).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.max).setY(c.min.y).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.max).setX(c.min.x).applyQuaternion(f),m.expandByPoint(Q),Q.copy(c.max).applyQuaternion(f),m.expandByPoint(Q),m.min.x-=r,m.min.y-=a,m.max.x+=i,m.max.y+=o,f.setFromUnitVectors(Hl,d),p&&f.premultiply(ru.invert()),f.premultiply(this._yAxisUpSpace);let h=m.getSize(Z),g=m.getCenter(Q).applyQuaternion(f);if(xl(this._camera)){let e=this.getDistanceToFitBox(h.x,h.y,h.z,n);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.dollyTo(e,t)),s.push(this.setFocalOffset(0,0,0,t))}else if(Sl(this._camera)){let e=this._camera,r=e.right-e.left,i=e.top-e.bottom,a=n?Math.max(r/h.x,i/h.y):Math.min(r/h.x,i/h.y);s.push(this.moveTo(g.x,g.y,g.z,t)),s.push(this.zoomTo(a,t)),s.push(this.setFocalOffset(0,0,0,t))}return Promise.all(s)}fitToSphere(t,n){let r=[],i=`isObject3D`in t?e.createBoundingSphere(t,tu):tu.copy(t);if(r.push(this.moveTo(i.center.x,i.center.y,i.center.z,n)),xl(this._camera)){let e=this.getDistanceToFitSphere(i.radius);r.push(this.dollyTo(e,n))}else if(Sl(this._camera)){let e=this._camera.right-this._camera.left,t=this._camera.top-this._camera.bottom,a=2*i.radius,o=Math.min(e/a,t/a);r.push(this.zoomTo(o,n))}return r.push(this.setFocalOffset(0,0,0,n)),Promise.all(r)}setLookAt(e,t,n,r,i,a,o=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0;let s=Q.set(r,i,a),c=Z.set(e,t,n);this._targetEnd.copy(s),this._sphericalEnd.setFromVector3(c.sub(s).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,o||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let l=!o||Y(this._target.x,this._targetEnd.x,this.restThreshold)&&Y(this._target.y,this._targetEnd.y,this.restThreshold)&&Y(this._target.z,this._targetEnd.z,this.restThreshold)&&Y(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Y(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Y(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerp(e,t,n,r=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=bl.NONE,this._changedDolly=0;let i=Z.set(...e.target);if(`spherical`in e)Zl.set(...e.spherical);else{let t=Q.set(...e.position);Zl.setFromVector3(t.sub(i).applyQuaternion(this._yAxisUpSpace))}let a=Wl.set(...t.target);if(`spherical`in t)Ql.set(...t.spherical);else{let e=Q.set(...t.position);Ql.setFromVector3(e.sub(a).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(i.lerp(a,n));let o=Ql.theta-Zl.theta,s=Ql.phi-Zl.phi,c=Ql.radius-Zl.radius;this._sphericalEnd.set(Zl.radius+c*n,Zl.phi+s*n,Zl.theta+o*n),this._needsUpdate=!0,r||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));let l=!r||Y(this._target.x,this._targetEnd.x,this.restThreshold)&&Y(this._target.y,this._targetEnd.y,this.restThreshold)&&Y(this._target.z,this._targetEnd.z,this.restThreshold)&&Y(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Y(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Y(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(l)}lerpLookAt(e,t,n,r,i,a,o,s,c,l,u,d,f,p=!1){return this.lerp({position:[e,t,n],target:[r,i,a]},{position:[o,s,c],target:[l,u,d]},f,p)}setPosition(e,t,n,r=!1){return this.setLookAt(e,t,n,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,r)}setTarget(e,t,n,r=!1){let i=this.getPosition(Z),a=this.setLookAt(i.x,i.y,i.z,e,t,n,r);return this._sphericalEnd.phi=Dl(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),a}setFocalOffset(e,t,n,r=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,n),this._needsUpdate=!0,r||this._focalOffset.copy(this._focalOffsetEnd);let i=!r||Y(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Y(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Y(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}setOrbitPoint(e,t,n){this._camera.updateMatrixWorld(),Kl.setFromMatrixColumn(this._camera.matrixWorldInverse,0),ql.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Jl.setFromMatrixColumn(this._camera.matrixWorldInverse,2);let r=Z.set(e,t,n),i=r.distanceTo(this._camera.position),a=r.sub(this._camera.position);Kl.multiplyScalar(a.x),ql.multiplyScalar(a.y),Jl.multiplyScalar(a.z),Z.copy(Kl).add(ql).add(Jl),Z.z+=i,this.dollyTo(i,!1),this.setFocalOffset(-Z.x,Z.y,-Z.z,!1),this.moveTo(e,t,n,!1)}setBoundary(e){if(!e){this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),this._needsUpdate=!0;return}this._boundary.copy(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,n,r){if(e===null){this._viewport=null;return}this._viewport=this._viewport||new X.Vector4,typeof e==`number`?this._viewport.set(e,t,n,r):this._viewport.copy(e)}getDistanceToFitBox(e,t,n,r=!1){if(Fl(this._camera,`getDistanceToFitBox`))return this._spherical.radius;let i=e/t,a=this._camera.getEffectiveFOV()*El,o=this._camera.aspect;return((r?i>o:i<o)?t:e/o)*.5/Math.tan(a*.5)+n*.5}getDistanceToFitSphere(e){if(Fl(this._camera,`getDistanceToFitSphere`))return this._spherical.radius;let t=this._camera.getEffectiveFOV()*El,n=Math.atan(Math.tan(t*.5)*this._camera.aspect)*2,r=1<this._camera.aspect?t:n;return e/Math.sin(r*.5)}getTarget(e,t=!0){return(e&&e.isVector3?e:new X.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new X.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new X.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new X.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%Cl+Cl)%Cl,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=Cl),this._spherical.theta+=Cl*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Cl),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!Y(this._camera.up.x,this._cameraUp0.x)||!Y(this._camera.up.y,this._cameraUp0.y)||!Y(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);let e=this.getPosition(Z);this.updateCameraUp(),this.setPosition(e.x,e.y,e.z)}let t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,Vl),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){let e=Z.subVectors(this._target,this._camera.position).normalize(),t=Q.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();let n=this.getPosition(Z);this.updateCameraUp(),this.setPosition(n.x,n.y,n.z)}update(e){let t=this._sphericalEnd.theta-this._spherical.theta,n=this._sphericalEnd.phi-this._spherical.phi,r=this._sphericalEnd.radius-this._spherical.radius,i=Yl.subVectors(this._targetEnd,this._target),a=Xl.subVectors(this._focalOffsetEnd,this._focalOffset),o=this._zoomEnd-this._zoom;if(Ol(t))this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.theta=Ml(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,t,1/0,e),this._needsUpdate=!0}if(Ol(n))this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi;else{let t=this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime;this._spherical.phi=Ml(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,t,1/0,e),this._needsUpdate=!0}if(Ol(r))this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius;else{let t=this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime;this._spherical.radius=Ml(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,t,this.maxSpeed,e),this._needsUpdate=!0}if(Ol(i.x)&&Ol(i.y)&&Ol(i.z))this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd);else{let t=this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime;Nl(this._target,this._targetEnd,this._targetVelocity,t,this.maxSpeed,e,this._target),this._needsUpdate=!0}if(Ol(a.x)&&Ol(a.y)&&Ol(a.z))this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd);else{let t=this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime;Nl(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,t,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0}if(Ol(o))this._zoomVelocity.value=0,this._zoom=this._zoomEnd;else{let t=this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime;this._zoom=Ml(this._zoom,this._zoomEnd,this._zoomVelocity,t,1/0,e)}if(this.dollyToCursor){if(xl(this._camera)&&this._changedDolly!==0){let e=this._spherical.radius-this._lastDistance,t=this._camera,n=this._getCameraDirection(Gl),r=Z.copy(n).cross(t.up).normalize();r.lengthSq()===0&&(r.x=1);let i=Q.crossVectors(r,n),a=this._sphericalEnd.radius*Math.tan(t.getEffectiveFOV()*El*.5),o=(this._sphericalEnd.radius-e-this._sphericalEnd.radius)/this._sphericalEnd.radius,s=Wl.copy(this._targetEnd).add(r.multiplyScalar(this._dollyControlCoord.x*a*t.aspect)).add(i.multiplyScalar(this._dollyControlCoord.y*a)),c=Z.copy(this._targetEnd).lerp(s,o),l=this._lastDollyDirection===bl.IN&&this._spherical.radius<=this.minDistance,u=this._lastDollyDirection===bl.OUT&&this.maxDistance<=this._spherical.radius;if(this.infinityDolly&&(l||u)){this._sphericalEnd.radius-=e,this._spherical.radius-=e;let t=Q.copy(n).multiplyScalar(-e);c.add(t)}this._boundary.clampPoint(c,c);let d=Q.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(d),this._changedDolly-=e,Ol(this._changedDolly)&&(this._changedDolly=0)}else if(Sl(this._camera)&&this._changedZoom!==0){let e=this._zoom-this._lastZoom,t=this._camera,n=Z.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(t.near+t.far)/(t.near-t.far)).unproject(t),r=Q.set(0,0,-1).applyQuaternion(t.quaternion),i=Wl.copy(n).add(r.multiplyScalar(-n.dot(t.up))),a=-(this._zoom-e-this._zoom)/this._zoom,o=this._getCameraDirection(Gl),s=this._targetEnd.dot(o),c=Z.copy(this._targetEnd).lerp(i,a),l=c.dot(o),u=o.multiplyScalar(l-s);c.sub(u),this._boundary.clampPoint(c,c);let d=Q.subVectors(c,this._targetEnd);this._targetEnd.copy(c),this._target.add(d),this._changedZoom-=e,Ol(this._changedZoom)&&(this._changedZoom=0)}}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;let s=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,s),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!Ol(this._focalOffset.x)||!Ol(this._focalOffset.y)||!Ol(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),Kl.setFromMatrixColumn(this._camera.matrix,0),ql.setFromMatrixColumn(this._camera.matrix,1),Jl.setFromMatrixColumn(this._camera.matrix,2),Kl.multiplyScalar(this._focalOffset.x),ql.multiplyScalar(-this._focalOffset.y),Jl.multiplyScalar(this._focalOffset.z),Z.copy(Kl).add(ql).add(Jl),this._camera.position.add(Z),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),Z.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);let c=this._needsUpdate;return c&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:`wake`}),this.dispatchEvent({type:`update`})):c?(this.dispatchEvent({type:`update`}),Ol(t,this.restThreshold)&&Ol(n,this.restThreshold)&&Ol(r,this.restThreshold)&&Ol(i.x,this.restThreshold)&&Ol(i.y,this.restThreshold)&&Ol(i.z,this.restThreshold)&&Ol(a.x,this.restThreshold)&&Ol(a.y,this.restThreshold)&&Ol(a.z,this.restThreshold)&&Ol(o,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:`rest`}))):!c&&this._updatedLastTime&&this.dispatchEvent({type:`sleep`}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=c,this._needsUpdate=!1,c}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Al(this.maxDistance),minZoom:this.minZoom,maxZoom:Al(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Al(this.maxPolarAngle),minAzimuthAngle:Al(this.minAzimuthAngle),maxAzimuthAngle:Al(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:Z.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(e,t=!1){let n=JSON.parse(e);this.enabled=n.enabled,this.minDistance=n.minDistance,this.maxDistance=jl(n.maxDistance),this.minZoom=n.minZoom,this.maxZoom=jl(n.maxZoom),this.minPolarAngle=n.minPolarAngle,this.maxPolarAngle=jl(n.maxPolarAngle),this.minAzimuthAngle=jl(n.minAzimuthAngle),this.maxAzimuthAngle=jl(n.maxAzimuthAngle),this.smoothTime=n.smoothTime,this.draggingSmoothTime=n.draggingSmoothTime,this.dollySpeed=n.dollySpeed,this.truckSpeed=n.truckSpeed,this.dollyToCursor=n.dollyToCursor,this._target0.fromArray(n.target0),this._position0.fromArray(n.position0),this._zoom0=n.zoom0,this._focalOffset0.fromArray(n.focalOffset0),this.moveTo(n.target[0],n.target[1],n.target[2],t),Zl.setFromVector3(Z.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Zl.theta,Zl.phi,t),this.dollyTo(Zl.radius,t),this.zoomTo(n.zoom,t),this.setFocalOffset(n.focalOffset[0],n.focalOffset[1],n.focalOffset[2],t),this._needsUpdate=!0}connect(e){if(this._domElement){console.warn(`camera-controls is already connected.`);return}e.setAttribute(`data-camera-controls-version`,Ll),this._addAllEventListeners(e),this._getClientRect(this._elementRect)}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&=(this._domElement.removeAttribute(`data-camera-controls-version`),void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,n){let r=t.lengthSq();if(r===0)return e;let i=Q.copy(t).add(e),a=this._boundary.clampPoint(i,Wl).sub(i),o=a.lengthSq();if(o===0)return e.add(t);if(o===r)return e;if(n===0)return e.add(t).add(a);{let r=1+n*o/t.dot(a);return e.add(Q.copy(t).multiplyScalar(r)).add(a.multiplyScalar(1-n))}}_updateNearPlaneCorners(){if(xl(this._camera)){let e=this._camera,t=e.near,n=e.getEffectiveFOV()*El,r=Math.tan(n*.5)*t,i=r*e.aspect;this._nearPlaneCorners[0].set(-i,-r,0),this._nearPlaneCorners[1].set(i,-r,0),this._nearPlaneCorners[2].set(i,r,0),this._nearPlaneCorners[3].set(-i,r,0)}else if(Sl(this._camera)){let e=this._camera,t=1/e.zoom,n=e.left*t,r=e.right*t,i=e.top*t,a=e.bottom*t;this._nearPlaneCorners[0].set(n,i,0),this._nearPlaneCorners[1].set(r,i,0),this._nearPlaneCorners[2].set(r,a,0),this._nearPlaneCorners[3].set(n,a,0)}}_truckInternal=(e,t,n,r)=>{let i,a;if(xl(this._camera)){let n=Z.copy(this._camera.position).sub(this._target),r=this._camera.getEffectiveFOV()*El,o=n.length()*Math.tan(r*.5);i=this.truckSpeed*e*o/this._elementRect.height,a=this.truckSpeed*t*o/this._elementRect.height}else if(Sl(this._camera)){let n=this._camera;i=this.truckSpeed*e*(n.right-n.left)/n.zoom/this._elementRect.width,a=this.truckSpeed*t*(n.top-n.bottom)/n.zoom/this._elementRect.height}else return;r?(n?this.setFocalOffset(this._focalOffsetEnd.x+i,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(i,0,!0),this.forward(-a,!0)):n?this.setFocalOffset(this._focalOffsetEnd.x+i,this._focalOffsetEnd.y+a,this._focalOffsetEnd.z,!0):this.truck(i,a,!0)};_rotateInternal=(e,t)=>{let n=Cl*this.azimuthRotateSpeed*e/this._elementRect.height,r=Cl*this.polarRotateSpeed*t/this._elementRect.height;this.rotate(n,r,!0)};_dollyInternal=(e,t,n)=>{let r=.95**(-e*this.dollySpeed),i=this._sphericalEnd.radius,a=this._sphericalEnd.radius*r,o=Dl(a,this.minDistance,this.maxDistance),s=o-a;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(a,!0):(this.infinityDolly&&!this.dollyToCursor&&this.dollyInFixed(s,!0),this._dollyToNoClamp(o,!0)),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?a:o)-i,this._dollyControlCoord.set(t,n)),this._lastDollyDirection=Math.sign(-e)};_zoomInternal=(e,t,n)=>{let r=.95**(e*this.dollySpeed),i=this._zoom,a=this._zoom*r;this.zoomTo(a,!0),this.dollyToCursor&&(this._changedZoom+=a-i,this._dollyControlCoord.set(t,n))};_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||Fl(this._camera,`_collisionTest`))return e;let t=this._getTargetDirection(Gl);iu.lookAt(Bl,t,this._camera.up);for(let n=0;n<4;n++){let r=Q.copy(this._nearPlaneCorners[n]);r.applyMatrix4(iu);let i=Wl.addVectors(this._target,r);au.set(i,t),au.far=this._spherical.radius+1;let a=au.intersectObjects(this.colliderMeshes);a.length!==0&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;let t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:`transitionstart`}),new Promise(e=>{let t=()=>{this.removeEventListener(`rest`,t),e()};this.addEventListener(`rest`,t)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`),0}set dampingFactor(e){console.warn(`.dampingFactor has been deprecated. use smoothTime (in seconds) instead.`)}get draggingDampingFactor(){return console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`),0}set draggingDampingFactor(e){console.warn(`.draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.`)}static createBoundingSphere(e,t=new X.Sphere){let n=t,r=n.center;$l.makeEmpty(),e.traverseVisible(e=>{e.isMesh&&$l.expandByObject(e)}),$l.getCenter(r);let i=0;return e.traverseVisible(e=>{if(!e.isMesh)return;let t=e;if(!t.geometry)return;let n=t.geometry.clone();n.applyMatrix4(t.matrixWorld);let a=n.attributes.position;for(let e=0,t=a.count;e<t;e++)Z.fromBufferAttribute(a,e),i=Math.max(i,r.distanceToSquared(Z))}),n.radius=Math.sqrt(i),n}},su=Object.defineProperty,cu=(e,t,n)=>t in e?su(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,lu=(e,t,n)=>cu(e,typeof t==`symbol`?t:t+``,n),uu=(e,t)=>{let[n,r]=t.split(`-`);return Object.assign(e.style,{left:r===`left`?`0`:r===`center`?`50%`:``,right:r===`right`?`0`:``,top:n===`top`?`0`:n===`bottom`?``:`50%`,bottom:n===`bottom`?`0`:``,transform:`${r===`center`?`translateX(-50%)`:``} ${n===`center`?`translateY(-50%)`:``}`}),t},du=({placement:e,size:t,offset:n,id:r,className:i})=>{let a=document.createElement(`div`),{top:o,left:s,right:c,bottom:l}=n;return Object.assign(a.style,{id:r,position:`absolute`,zIndex:`1000`,height:`${t}px`,width:`${t}px`,margin:`${o}px ${c}px ${l}px ${s}px`,borderRadius:`100%`}),uu(a,e),r&&(a.id=r),i&&(a.className=i),a},fu=e=>{let t=typeof e==`string`?document.querySelector(e):e;if(!t)throw Error(`Invalid DOM element`);return t};function pu(e,t,n){return Math.max(t,Math.min(n,e))}var mu=[[`x`,0,3],[`y`,1,4],[`z`,2,5]],hu=new B;function gu({isSphere:e},t,n){e&&(hu.set(0,0,1).applyQuaternion(n.quaternion),mu.forEach(([e,n,r])=>{let i=hu[e],a=t[n],o=a.userData.opacity;a.material.opacity=pu(i>=0?o:o/2,0,1),a=t[r],o=a.userData.opacity,a.material.opacity=pu(i>=0?o/2:o,0,1)}))}var _u=(e,t,n=10)=>Math.abs(e.clientX-t.x)<n&&Math.abs(e.clientY-t.y)<n,vu=new to,yu=new z,bu=(e,t,n,r)=>{yu.set((e.clientX-t.left)/t.width*2-1,-((e.clientY-t.top)/t.height)*2+1),vu.setFromCamera(yu,n);let i=vu.intersectObjects(r,!1),a=i.length?i[0]:null;return!a||!a.object.visible?null:a},xu=1e-6,Su=2*Math.PI,Cu=[`x`,`y`,`z`],wu=[...Cu,`nx`,`ny`,`nz`],Tu=[`x`,`z`,`y`,`nx`,`nz`,`ny`],Eu=[`z`,`x`,`y`,`nz`,`nx`,`ny`],Du=`Right`,Ou=`Top`,ku=`Front`,Au=`Left`,ju=`Bottom`,Mu=`Back`,Nu=[Du,Ou,ku,Au,ju,Mu].map(e=>e.toLocaleLowerCase()),Pu=1.3,Fu=(e,t=!0)=>{let{material:n,userData:r}=e,{color:i,opacity:a}=t?r.hover:r;n.color.set(i),n.opacity=a},Iu=e=>JSON.parse(JSON.stringify(e)),Lu=e=>{let t=e.type||`sphere`,n=t===`sphere`,r=e.resolution||n?64:128,i=Un.DEFAULT_UP,a=i.z===1,o=i.x===1,{container:s}=e;e.container=void 0,e=JSON.parse(JSON.stringify(e)),e.container=s;let c=a?Tu:o?Eu:wu;Nu.forEach((t,n)=>{e[t]&&(e[c[n]]=e[t])});let l={enabled:!0,color:16777215,opacity:1,scale:.7,labelColor:2236962,line:!1,border:{size:0,color:14540253},hover:{color:n?16777215:9688043,labelColor:2236962,opacity:1,scale:.7,border:{size:0,color:14540253}}},u={line:!1,scale:n?.45:.7,hover:{scale:n?.5:.7}},d={type:t,container:document.body,size:128,placement:`top-right`,resolution:r,lineWidth:4,radius:n?1:.2,smoothness:18,animated:!0,speed:1,background:{enabled:!0,color:n?16777215:14739180,opacity:+!n,hover:{color:n?16777215:14739180,opacity:n?.2:1}},font:{family:`sans-serif`,weight:900},offset:{top:10,left:10,bottom:10,right:10},corners:{enabled:!n,color:n?15915362:16777215,opacity:1,scale:n?.15:.2,radius:1,smoothness:18,hover:{color:n?16777215:9688043,opacity:1,scale:n?.2:.225}},edges:{enabled:!n,color:n?15915362:16777215,opacity:+!!n,radius:n?1:.125,smoothness:18,scale:n?.15:1,hover:{color:n?16777215:9688043,opacity:1,scale:n?.2:1}},x:{...Iu(l),...n?{label:`X`,color:16725587,line:!0}:{label:o?Ou:Du}},y:{...Iu(l),...n?{label:`Y`,color:9100032,line:!0}:{label:a||o?ku:Ou}},z:{...Iu(l),...n?{label:`Z`,color:2920447,line:!0}:{label:a?Ou:o?Du:ku}},nx:{...Iu(u),label:n?``:o?ju:Au},ny:{...Iu(u),label:n?``:a||o?Mu:ju},nz:{...Iu(u),label:n?``:a?ju:o?Au:Mu}};return Ru(e,d),Cu.forEach(t=>Ru(e[`n${t}`],Iu(e[t]))),{...e,isSphere:n}};function Ru(e,...t){if(e instanceof HTMLElement||typeof e!=`object`||!e)return e;for(let n of t)for(let t in n)t!==`container`&&t in n&&(e[t]===void 0?e[t]=n[t]:typeof n[t]==`object`&&!Array.isArray(n[t])&&(e[t]=Ru(e[t]||{},n[t])));return e}var zu=(t,n=2)=>{let r=new U,i=n*2,{isSphere:a,resolution:o,radius:s,font:c,corners:l,edges:u}=t,d=wu.map(e=>({...t[e],radius:s}));a&&l.enabled&&d.push(l),a&&u.enabled&&d.push(u);let f=document.createElement(`canvas`),p=f.getContext(`2d`);f.width=o*2+i*2,f.height=o*d.length+i*d.length;let[m,h]=S(d,o,c);d.forEach(({radius:e,label:t,color:r,labelColor:a,border:s,hover:{color:c,labelColor:l,border:u}},d)=>{let f=o*d+d*i+n;x(n,f,n,o,e,t,s,r,a),x(o+n*3,f,n,o,e,t,u??s,c??r,l??a)});let g=d.length,_=n/(o*2),v=n/(o*6),y=1/g,b=new Ji(f);return b.repeat.set(.5-2*_,y-2*v),b.offset.set(_,1-v),Object.assign(b,{colorSpace:Fe,wrapS:e,wrapT:e,userData:{offsetX:_,offsetY:v,cellHeight:y}}),b;function x(e,t,n,i,a,o,s,c,l){if(a=i/2*a,c!=null&&c!==``&&(u(),p.fillStyle=r.set(c).getStyle(),p.fill()),s&&s.size){let n=s.size*i/2;e+=n,t+=n,i-=s.size*i,a=Math.max(0,a-n),u(),p.strokeStyle=r.set(s.color).getStyle(),p.lineWidth=s.size*i,p.stroke()}o&&C(p,e+i/2,t+(i+n)/2,o,r.set(l).getStyle());function u(){p.beginPath(),p.moveTo(e+a,t),p.lineTo(e+i-a,t),p.arcTo(e+i,t,e+i,t+a,a),p.lineTo(e+i,t+i-a),p.arcTo(e+i,t+i,e+i-a,t+i,a),p.lineTo(e+a,t+i),p.arcTo(e,t+i,e,t+i-a,a),p.lineTo(e,t+a),p.arcTo(e,t,e+a,t,a),p.closePath()}}function S(e,t,n){let r=[...e].sort((e,t)=>(e.label?.length||0)-(t.label?.length||0)).pop().label,{family:i,weight:o}=n,s=a?Math.sqrt((t*.7)**2/2):t,c=s,l=0,u=0;do{p.font=`${o} ${c}px ${i}`;let e=p.measureText(r);l=e.width,u=e.fontBoundingBoxDescent,c--}while(l>s&&c>0);let d=s/u,f=Math.min(s/l,d);return[`${o} ${Math.floor(c*f)}px ${i}`,d]}function C(e,t,n,r,i){e.font=m,e.textAlign=`center`,e.textBaseline=`middle`,e.fillStyle=i,e.fillText(r,t,n+(a?h:0))}},Bu=(e,t)=>e.offset.x=(t?.5:0)+e.userData.offsetX,Vu=(e,t)=>{let{offset:n,userData:{offsetY:r,cellHeight:i}}=e;n.y=1-(t+1)*i+r};function Hu(e,t,n=2,r=2){let i=n/2-e,a=r/2-e,o=e/n,s=(n-e)/n,c=e/r,l=(r-e)/r,u=[i,a,0,-i,a,0,-i,-a,0,i,-a,0],d=[s,l,o,l,o,c,s,c],f=[3*(t+1)+3,3*(t+1)+4,t+4,t+5,2*(t+1)+4,2,1,2*(t+1)+3,3,4*(t+1)+3,4,0],p=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11].map(e=>f[e]),m,h,g,_,v,y,b,x;for(let n=0;n<4;n++){_=n<1||n>2?i:-i,v=n<2?a:-a,y=n<1||n>2?s:o,b=n<2?l:c;for(let r=0;r<=t;r++)m=Math.PI/2*(n+r/t),h=Math.cos(m),g=Math.sin(m),u.push(_+e*h,v+e*g,0),d.push(y+o*h,b+c*g),r<t&&(x=(t+1)*n+r+4,p.push(n,x,x+1))}return new Tr().setIndex(new W(new Uint32Array(p),1)).setAttribute(`position`,new W(new Float32Array(u),3)).setAttribute(`uv`,new W(new Float32Array(d),2))}var Uu=(e,t)=>{let n=new B,{isSphere:r,radius:i,smoothness:a}=e,o=Hu(i,a);return wu.map((i,a)=>{let s=a<3,c=wu[a],l=a?t.clone():t;Vu(l,a);let{enabled:u,scale:d,opacity:f,hover:p}=e[c],m={map:l,opacity:f,transparent:!0},h=r?new Ti(new di(m)):new G(o,new dr(m)),g=s?c:c[1];return h.position[g]=(s?1:-1)*(r?Pu:1),r||h.lookAt(n.copy(h.position).multiplyScalar(1.7)),h.scale.setScalar(d),h.renderOrder=1,h.visible=u,h.userData={scale:d,opacity:f,hover:p},h})},Wu=(e,t)=>{let{isSphere:n,corners:r}=e;if(!r.enabled)return[];let{color:i,opacity:a,scale:o,radius:s,smoothness:c,hover:l}=r,u=n?null:Hu(s,c),d={transparent:!0,opacity:a},f=[1,1,1,-1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,-1,-1,-1,-1,-1].map(e=>e*.85),p=new B;return Array(f.length/3).fill(0).map((e,r)=>{if(n){let e=t.clone();Vu(e,6),d.map=e}else d.color=i;let s=n?new Ti(new di(d)):new G(u,new dr(d)),c=r*3;return s.position.set(f[c],f[c+1],f[c+2]),n&&s.position.normalize().multiplyScalar(1.7),s.scale.setScalar(o),s.lookAt(p.copy(s.position).multiplyScalar(2)),s.renderOrder=1,s.userData={color:i,opacity:a,scale:o,hover:l},s})},Gu=(e,t,n)=>{let{isSphere:r,edges:i}=e;if(!i.enabled)return[];let{color:a,opacity:o,scale:s,hover:c,radius:l,smoothness:u}=i,d=r?null:Hu(l,u,1.2,.25),f={transparent:!0,opacity:o},p=[0,1,1,0,-1,1,1,0,1,-1,0,1,0,1,-1,0,-1,-1,1,0,-1,-1,0,-1,1,1,0,1,-1,0,-1,1,0,-1,-1,0].map(e=>e*.925),m=new B,h=new B(0,1,0);return Array(p.length/3).fill(0).map((e,i)=>{if(r){let e=t.clone();Vu(e,n),f.map=e}else f.color=a;let l=r?new Ti(new di(f)):new G(d,new dr(f)),u=i*3;return l.position.set(p[u],p[u+1],p[u+2]),r&&l.position.normalize().multiplyScalar(1.7),l.scale.setScalar(s),l.up.copy(h),l.lookAt(m.copy(l.position).multiplyScalar(2)),!r&&!l.position.y&&(l.rotation.z=Math.PI/2),l.renderOrder=1,l.userData={color:a,opacity:o,scale:s,hover:c},l})};function Ku(e,t=!1){let n=e[0].index!==null,r=new Set(Object.keys(e[0].attributes)),i=new Set(Object.keys(e[0].morphAttributes)),a={},o={},s=e[0].morphTargetsRelative,c=new Tr,l=0;for(let u=0;u<e.length;++u){let d=e[u],f=0;if(n!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let e in d.attributes){if(!r.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. All geometries must have compatible attributes; make sure "`+e+`" attribute exists among all geometries, or in none of them.`),null;a[e]===void 0&&(a[e]=[]),a[e].push(d.attributes[e]),f++}if(f!==r.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. Make sure all geometries have the same number of attributes.`),null;if(s!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let e in d.morphAttributes){if(!i.has(e))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. .morphAttributes must be consistent throughout all geometries.`),null;o[e]===void 0&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(n)e=d.index.count;else if(d.attributes.position!==void 0)e=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+u+`. The geometry must have either an index or a position attribute`),null;c.addGroup(l,e,u),l+=e}}if(n){let t=0,n=[];for(let r=0;r<e.length;++r){let i=e[r].index;for(let e=0;e<i.count;++e)n.push(i.getX(e)+t);t+=e[r].attributes.position.count}c.setIndex(n)}for(let e in a){let t=qu(a[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;c.setAttribute(e,t)}for(let e in o){let t=o[e][0].length;if(t===0)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<o[e].length;++r)t.push(o[e][r][n]);let r=qu(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;c.morphAttributes[e].push(r)}}return c}function qu(e){let t,n,r,i=-1,a=0;for(let o=0;o<e.length;++o){let s=e[o];if(t===void 0&&(t=s.array.constructor),t!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(n===void 0&&(n=s.itemSize),n!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(r===void 0&&(r=s.normalized),r!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(i===-1&&(i=s.gpuType),i!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;a+=s.count*n}let o=new t(a),s=new W(o,n,r),c=0;for(let t=0;t<e.length;++t){let r=e[t];if(r.isInterleavedBufferAttribute){let e=c/n;for(let t=0,i=r.count;t<i;t++)for(let i=0;i<n;i++){let n=r.getComponent(t,i);s.setComponent(t+e,i,n)}}else o.set(r.array,c);c+=r.count*n}return i!==void 0&&(s.gpuType=i),s}var Ju=(e,t)=>{let{isSphere:n,background:{enabled:r,color:i,opacity:a,hover:o}}=t,s,c=new dr({color:i,side:1,opacity:a,transparent:!0,depthWrite:!1});if(!r)return null;if(n)s=new G(new oa(1.8,64,64),c);else{let t;e.forEach(e=>{let n=e.scale.x;e.scale.setScalar(.9),e.updateMatrix();let r=e.geometry.clone();r.applyMatrix4(e.matrix),t=t?Ku([t,r]):r,e.scale.setScalar(n)}),s=new G(t,c)}return s.userData={color:i,opacity:a,hover:o},s},Yu=new Ht,Xu=new B,Zu=class extends Ra{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new _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],3)),this.setAttribute(`uv`,new _r([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new $a(t,6,1);return this.setAttribute(`instanceStart`,new ui(n,3,0)),this.setAttribute(`instanceEnd`,new ui(n,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new $a(t,6,1);return this.setAttribute(`instanceColorStart`,new ui(n,3,0)),this.setAttribute(`instanceColorEnd`,new ui(n,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new sa(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Ht);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),Yu.setFromBufferAttribute(t),this.boundingBox.union(Yu))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new sn),this.boundingBox===null&&this.computeBoundingBox();let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){let n=this.boundingSphere.center;this.boundingBox.getCenter(n);let r=0;for(let i=0,a=e.count;i<a;i++)Xu.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(Xu)),Xu.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(Xu));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}applyMatrix(e){return console.warn(`THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().`),this.applyMatrix4(e)}};q.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new z(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},yo.line={uniforms:Wr.merge([q.common,q.fog,q.line]),vertexShader:`
|
|
3833
3833
|
#include <common>
|
|
3834
3834
|
#include <color_pars_vertex>
|
|
3835
3835
|
#include <fog_pars_vertex>
|
|
@@ -4199,7 +4199,7 @@ void main() {
|
|
|
4199
4199
|
#include <premultiplied_alpha_fragment>
|
|
4200
4200
|
|
|
4201
4201
|
}
|
|
4202
|
-
`};var Qu=class extends qr{constructor(e){super({type:`LineMaterial`,uniforms:Wr.clone(yo.line.uniforms),vertexShader:yo.line.vertexShader,fragmentShader:yo.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},$u=new Lt,ed=new B,td=new B,nd=new Lt,rd=new Lt,id=new Lt,ad=new B,od=new gn,sd=new po,cd=new B,ld=new Ht,ud=new sn,dd=new Lt,fd,pd;function md(e,t,n){return dd.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),dd.multiplyScalar(1/dd.w),dd.x=pd/n.width,dd.y=pd/n.height,dd.applyMatrix4(e.projectionMatrixInverse),dd.multiplyScalar(1/dd.w),Math.abs(Math.max(dd.x,dd.y))}function hd(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){sd.start.fromBufferAttribute(i,r),sd.end.fromBufferAttribute(a,r),sd.applyMatrix4(n);let o=new B,s=new B;fd.distanceSqToSegment(sd.start,sd.end,s,o),s.distanceTo(o)<pd*.5&&t.push({point:s,pointOnLine:o,distance:fd.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function gd(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;fd.at(1,id),id.w=1,id.applyMatrix4(t.matrixWorldInverse),id.applyMatrix4(r),id.multiplyScalar(1/id.w),id.x*=i.x/2,id.y*=i.y/2,id.z=0,ad.copy(id),od.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(nd.fromBufferAttribute(s,t),rd.fromBufferAttribute(c,t),nd.w=1,rd.w=1,nd.applyMatrix4(od),rd.applyMatrix4(od),nd.z>u&&rd.z>u)continue;if(nd.z>u){let e=nd.z-rd.z,t=(nd.z-u)/e;nd.lerp(rd,t)}else if(rd.z>u){let e=rd.z-nd.z,t=(rd.z-u)/e;rd.lerp(nd,t)}nd.applyMatrix4(r),rd.applyMatrix4(r),nd.multiplyScalar(1/nd.w),rd.multiplyScalar(1/rd.w),nd.x*=i.x/2,nd.y*=i.y/2,rd.x*=i.x/2,rd.y*=i.y/2,sd.start.copy(nd),sd.start.z=0,sd.end.copy(rd),sd.end.z=0;let o=sd.closestPointToPointParameter(ad,!0);sd.at(o,cd);let l=pt.lerp(nd.z,rd.z,o),d=l>=-1&&l<=1,f=ad.distanceTo(cd)<pd*.5;if(d&&f){sd.start.fromBufferAttribute(s,t),sd.end.fromBufferAttribute(c,t),sd.start.applyMatrix4(a),sd.end.applyMatrix4(a);let r=new B,i=new B;fd.distanceSqToSegment(sd.start,sd.end,i,r),n.push({point:i,pointOnLine:r,distance:fd.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var _d=class extends G{constructor(e=new Zu,t=new Qu({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)ed.fromBufferAttribute(t,e),td.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+ed.distanceTo(td);let i=new $a(r,2,1);return e.setAttribute(`instanceDistanceStart`,new ui(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new ui(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`);let i=e.params.Line2!==void 0&&e.params.Line2.threshold||0;fd=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;pd=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),ud.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?pd*.5:md(r,Math.max(r.near,ud.distanceToPoint(fd.origin)),s.resolution),ud.radius+=c,fd.intersectsSphere(ud)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),ld.copy(o.boundingBox).applyMatrix4(a);let l;l=n?pd*.5:md(r,Math.max(r.near,ld.distanceToPoint(fd.origin)),s.resolution),ld.expandByScalar(l),fd.intersectsBox(ld)!==!1&&(n?hd(this,t):gd(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport($u),this.material.uniforms.resolution.value.set($u.z,$u.w))}},vd=class extends Zu{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},yd=class extends _d{constructor(e=new vd,t=new Qu({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},bd=e=>{let t=new U,n=[],r=[],{isSphere:i}=e;return wu.forEach((a,o)=>{let{enabled:s,line:c,scale:l,color:u}=e[a];if(!s||!c)return;let d=o<3?1:-1,f=(i?Pu-l/2:.975)*d;n.push(a.includes(`x`)?f:0,a.includes(`y`)?f:0,a.includes(`z`)?f:0,0,0,0);let p=t.set(u).toArray();r.push(...p,...p)}),n.length?new yd(new vd().setPositions(n).setColors(r),new Qu({linewidth:e.lineWidth,vertexColors:!0,resolution:new z(window.innerWidth,window.innerHeight)})).computeLineDistances():null},xd=e=>{let{corners:t,edges:n}=e,r=[],i=zu(e),a=Uu(e,i);return r.push(...a),t.enabled&&r.push(...Wu(e,i)),n.enabled&&r.push(...Gu(e,i,t.enabled?7:6)),[r,Ju(a,e),bd(e)]},Sd=(e,t=!0)=>{let{material:n,userData:r}=e,{opacity:i,color:a,scale:o}=t?r.hover:r;e.scale.setScalar(o),n.opacity=i,n.map?Bu(n.map,t):n.color.set(a)},Cd=new gn,wd=new io,Td=new z,Ed=new B,Dd=new Lt,Od=class extends Un{constructor(e,t,n={}){super(),Q(this,`enabled`,!0),Q(this,`camera`),Q(this,`renderer`),Q(this,`options`),Q(this,`target`,new B),Q(this,`animated`,!0),Q(this,`speed`,1),Q(this,`animating`,!1),Q(this,`_options`),Q(this,`_intersections`),Q(this,`_background`,null),Q(this,`_viewport`,[0,0,0,0]),Q(this,`_originalViewport`,[0,0,0,0]),Q(this,`_originalScissor`,[0,0,0,0]),Q(this,`_scene`),Q(this,`_camera`),Q(this,`_container`),Q(this,`_domElement`),Q(this,`_domRect`),Q(this,`_dragging`,!1),Q(this,`_distance`,0),Q(this,`_clock`,new Ba),Q(this,`_targetQuaternion`,new mt),Q(this,`_quaternionStart`,new mt),Q(this,`_quaternionEnd`,new mt),Q(this,`_pointerStart`,new z),Q(this,`_focus`,null),Q(this,`_placement`),Q(this,`_controls`),Q(this,`_controlsListeners`),this.camera=e,this.renderer=t,this._scene=new si().add(this),this.set(n)}get placement(){return this._placement}set placement(e){this._placement=uu(this._domElement,e),this.domUpdate()}set(e={}){this.dispose(),this.options=e,this._options=Lu(e),this._camera=this._options.isSphere?new Pa(-1.8,1.8,1.8,-1.8,5,10):new Qr(26,1,5,10),this._camera.position.set(0,0,7);let[t,n,r]=xd(this._options);n&&this.add(n),r&&this.add(r),this.add(...t),this._background=n,this._intersections=t;let{container:i,animated:a,speed:o}=this._options;return this.animated=a,this.speed=o,this._container=i?fu(i):document.body,this._domElement=du(this._options),this._domElement.onpointerdown=e=>this._onPointerDown(e),this._domElement.onpointermove=e=>this._onPointerMove(e),this._domElement.onpointerleave=()=>this._onPointerLeave(),this._container.appendChild(this._domElement),this._controls&&this.attachControls(this._controls),this.update(),this._updateOrientation(!0),this}render(){this.animating&&this._animate();let{renderer:e,_viewport:t}=this,n=e.getScissorTest(),r=e.autoClear;return e.autoClear=!1,e.setViewport(...t),n&&e.setScissor(...t),e.clear(!1,!0,!1),e.render(this._scene,this._camera),e.setViewport(...this._originalViewport),n&&e.setScissor(...this._originalScissor),e.autoClear=r,this}domUpdate(){this._domRect=this._domElement.getBoundingClientRect();let e=this.renderer,t=this._domRect,n=e.domElement.getBoundingClientRect();return this._viewport.splice(0,4,t.left-n.left,e.domElement.clientHeight-(t.top-n.top+t.height),t.width,t.height),e.getViewport(Dd).toArray(this._originalViewport),e.getScissorTest()&&e.getScissor(Dd).toArray(this._originalScissor),this}cameraUpdate(){return this._updateOrientation(),this}update(e=!0){return e&&this._controls&&this._controls.update(),this.domUpdate().cameraUpdate()}attachControls(e){return this.detachControls(),this.target=e.target,this._controlsListeners={start:()=>e.enabled=!1,end:()=>e.enabled=!0,change:()=>this.update(!1)},this.addEventListener(`start`,this._controlsListeners.start),this.addEventListener(`end`,this._controlsListeners.end),e.addEventListener(`change`,this._controlsListeners.change),this._controls=e,this}detachControls(){if(!(!this._controlsListeners||!this._controls))return this.target=new B().copy(this._controls.target),this.removeEventListener(`start`,this._controlsListeners.start),this.removeEventListener(`end`,this._controlsListeners.end),this._controls.removeEventListener(`change`,this._controlsListeners.change),this._controlsListeners=void 0,this._controls=void 0,this}dispose(){var e;this.detachControls(),this.children.forEach(e=>{var t,n,r;this.remove(e);let i=e;(t=i.material)==null||t.dispose(),(n=i.material?.map)==null||n.dispose(),(r=i.geometry)==null||r.dispose()}),(e=this._domElement)==null||e.remove()}_updateOrientation(e=!0){e&&(this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()),gu(this._options,this._intersections,this.camera)}_animate(){let{position:e,quaternion:t}=this.camera;if(e.set(0,0,1),!this.animated){e.applyQuaternion(this._quaternionEnd).multiplyScalar(this._distance).add(this.target),t.copy(this._targetQuaternion),this._updateOrientation(),this.animating=!1,this.dispatchEvent({type:`change`}),this.dispatchEvent({type:`end`});return}this._controls&&(this._controls.enabled=!1);let n=this._clock.getDelta()*Su*this.speed;this._quaternionStart.rotateTowards(this._quaternionEnd,n),e.applyQuaternion(this._quaternionStart).multiplyScalar(this._distance).add(this.target),t.rotateTowards(this._targetQuaternion,n),this._updateOrientation(),requestAnimationFrame(()=>this.dispatchEvent({type:`change`})),this._quaternionStart.angleTo(this._quaternionEnd)<xu&&(this._controls&&(this._controls.enabled=!0),this.animating=!1,this.dispatchEvent({type:`end`}))}_setOrientation(e){let t=this.camera,n=this.target;Ed.copy(e).multiplyScalar(this._distance),Cd.setPosition(Ed).lookAt(Ed,this.position,this.up),this._targetQuaternion.setFromRotationMatrix(Cd),Ed.add(n),Cd.lookAt(Ed,n,this.up),this._quaternionEnd.setFromRotationMatrix(Cd),Cd.setPosition(t.position).lookAt(t.position,n,this.up),this._quaternionStart.setFromRotationMatrix(Cd),this.animating=!0,this._clock.start(),this.dispatchEvent({type:`start`})}_onPointerDown(e){if(!this.enabled)return;let t=e=>{if(!this._dragging){if(_u(e,this._pointerStart))return;this._dragging=!0}let t=Td.set(e.clientX,e.clientY).sub(this._pointerStart).multiplyScalar(1/this._domRect.width*Math.PI),n=this.coordinateConversion(Ed.subVectors(this.camera.position,this.target)),r=wd.setFromVector3(n);r.theta=a-t.x,r.phi=pu(o-t.y,xu,Math.PI-xu),this.coordinateConversion(this.camera.position.setFromSpherical(r),!0).add(this.target),this.camera.lookAt(this.target),this.quaternion.copy(this.camera.quaternion).invert(),this._updateOrientation(!1),this.dispatchEvent({type:`change`})},n=()=>{if(document.removeEventListener(`pointermove`,t,!1),document.removeEventListener(`pointerup`,n,!1),!this._dragging)return this._handleClick(e);this._focus&&=(Sd(this._focus,!1),null),this._dragging=!1,this.dispatchEvent({type:`end`})};if(this.animating)return;e.preventDefault(),this._pointerStart.set(e.clientX,e.clientY);let r=this.coordinateConversion(Ed.subVectors(this.camera.position,this.target)),i=wd.setFromVector3(r),a=i.theta,o=i.phi;this._distance=i.radius,document.addEventListener(`pointermove`,t,!1),document.addEventListener(`pointerup`,n,!1),this.dispatchEvent({type:`start`})}coordinateConversion(e,t=!1){let{x:n,y:r,z:i}=e,a=Un.DEFAULT_UP;return a.x===1?t?e.set(r,i,n):e.set(i,n,r):a.z===1?t?e.set(i,n,r):e.set(r,i,n):e}_onPointerMove(e){!this.enabled||this._dragging||(this._background&&Fu(this._background,!0),this._handleHover(e))}_onPointerLeave(){!this.enabled||this._dragging||(this._background&&Fu(this._background,!1),this._focus&&Sd(this._focus,!1),this._domElement.style.cursor=``)}_handleClick(e){let t=bu(e,this._domRect,this._camera,this._intersections);this._focus&&=(Sd(this._focus,!1),null),t&&(this._setOrientation(t.object.position),this.dispatchEvent({type:`change`}))}_handleHover(e){let t=bu(e,this._domRect,this._camera,this._intersections)?.object||null;this._focus!==t&&(this._domElement.style.cursor=t?`pointer`:``,this._focus&&Sd(this._focus,!1),(this._focus=t)?Sd(t,!0):gu(this._options,this._intersections,this.camera))}},kd=class extends He{target=new B;constructor(e){super(),this.cc=e,e.addEventListener(`update`,()=>{e.getTarget(this.target),this.dispatchEvent({type:`change`})})}get enabled(){return this.cc.enabled}set enabled(e){this.cc.enabled=e}update(){let e=this.cc.camera.position,t=this.target;this.cc.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1)}},Ad=new Set;function jd(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Md(){Nd.faceColor.set(jd(`--scene-face-color`,`#969696`)),Nd.edgeColor.set(jd(`--scene-edge-color`,`#000000`)),Nd.gridColor.set(jd(`--scene-grid-color`,`#6f6f6f`)),Nd.metaEdgeColor.set(jd(`--scene-meta-edge-color`,`#b0b0b0`)),Nd.backgroundColor.set(jd(`--color-base-100`,`#1e1e1e`))}var Nd={faceColor:new U(`#969696`),edgeColor:new U(`#000000`),gridColor:new U(`#6f6f6f`),metaEdgeColor:new U(`#b0b0b0`),backgroundColor:new U(`#1e1e1e`)};Md(),new MutationObserver(()=>{Md();for(let e of Ad)e()}).observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]});function Pd(e){return Ad.add(e),()=>Ad.delete(e)}su.install({THREE:{Vector2:z,Vector3:B,Vector4:Lt,Quaternion:mt,Matrix4:gn,Spherical:io,Box3:Ht,Sphere:sn,Raycaster:to,MathUtils:{DEG2RAD:pt.DEG2RAD,clamp:pt.clamp}}});var Fd=new B(0,0,1),Id=120,Ld=1.1,Rd=class{scene;renderer;gizmo;orthoCamera;perspCamera;activeCamera=`orthographic`;_cc;_adapter;dirLight;renderRequested=!1;resizeObserver;clock=new Ba;animFrameId=0;gizmoWasActive=!1;constructor(e){this.container=e,Un.DEFAULT_UP=Fd.clone();let t=e.clientWidth||window.innerWidth,n=e.clientHeight||window.innerHeight;this.renderer=new vl({antialias:!0,alpha:!0}),this.renderer.setSize(t,n),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.toneMapping=4,this.renderer.outputColorSpace=Fe,this.renderer.localClippingEnabled=!0,e.appendChild(this.renderer.domElement),this.scene=new si,this.scene.background=Nd.backgroundColor.clone();let r=t/n;this.orthoCamera=new Pa(-r*Id/2,r*Id/2,Id/2,-Id/2,-1e4,1e4),this.orthoCamera.position.set(50,-50,40),this.orthoCamera.up.copy(Fd),this.orthoCamera.lookAt(0,0,0),this.perspCamera=new Qr(50,r,.5,1e4),this.perspCamera.position.set(50,-50,40),this.perspCamera.up.copy(Fd),this.perspCamera.lookAt(0,0,0),this.dirLight=new Ia(16777215,1),this.scene.add(this.dirLight),this.scene.add(new La(14544639,2.5)),this._cc=new su(this.orthoCamera,this.renderer.domElement),this._cc.dollyToCursor=!0,this._cc.smoothTime=.1,this._cc.draggingSmoothTime=.05,this.configureTouchForMode(`orthographic`),this._cc.updateCameraUp(),this._adapter=new kd(this._cc),this.gizmo=new Od(this.camera,this.renderer,{size:80,type:`sphere`}),this._cc.setLookAt(50,-50,40,0,0,0,!1),this._cc.getTarget(this._adapter.target),this.gizmo.target=this._adapter.target,this.gizmo.attachControls(this._adapter),this.gizmo.addEventListener(`change`,()=>this.requestRender()),this.resizeObserver=new ResizeObserver(()=>this.handleResize()),this.resizeObserver.observe(e),Pd(()=>{this.scene.background=Nd.backgroundColor.clone(),this.requestRender()}),this.tick()}get camera(){return this.activeCamera===`orthographic`?this.orthoCamera:this.perspCamera}get cameraControls(){return this._cc}get controls(){return this._adapter}requestRender(){this.renderRequested=!0}fitToBox(e,t){let n=e.getCenter(new B),r=e.getSize(new B).length()/2;if(r===0)return;let i=new sn(n,r*Ld);this._cc.fitToSphere(i,t)}switchCamera(e){if(e===this.activeCamera)return;let t=new B,n=new B;this._cc.getPosition(t),this._cc.getTarget(n);let r=this.camera.up.clone();if(this.activeCamera===`orthographic`&&e===`perspective`){let e=(this.orthoCamera.top-this.orthoCamera.bottom)/this.orthoCamera.zoom,r=pt.DEG2RAD*this.perspCamera.fov*.5,i=e*.5/Math.tan(r),a=t.clone().sub(n).normalize();t.copy(n).add(a.multiplyScalar(i))}this.activeCamera=e;let i=this.camera;i.position.copy(t),i.up.copy(r),i.lookAt(n),this._cc.dispose(),this._cc=new su(i,this.renderer.domElement),this._cc.dollyToCursor=!0,this._cc.smoothTime=.1,this._cc.draggingSmoothTime=.05,this._cc.setLookAt(t.x,t.y,t.z,n.x,n.y,n.z,!1),this._cc.updateCameraUp(),this.configureTouchForMode(e),this._adapter=new kd(this._cc),this._cc.getTarget(this._adapter.target),this.gizmo.camera=i,this.gizmo.target=this._adapter.target,this.gizmo.attachControls(this._adapter),this.gizmo.update(),this.requestRender()}render(){this.updateLightPositions(),this.renderer.render(this.scene,this.camera),this.gizmo.render()}dispose(){cancelAnimationFrame(this.animFrameId),this.resizeObserver.disconnect(),this._cc.dispose(),this.scene.clear(),this.renderer.dispose()}tick=()=>{let e=this.clock.getDelta(),t=!1;if(this._cc.enabled){if(this.gizmoWasActive){this._cc.updateCameraUp();let e=this.camera.position,t=this._adapter.target;this._cc.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1),this.gizmoWasActive=!1}t=this._cc.update(e)}else this.gizmoWasActive=!0;(t||this.renderRequested||!this._cc.enabled)&&(this.render(),this.renderRequested=!1),this.animFrameId=requestAnimationFrame(this.tick)};configureTouchForMode(e){e===`orthographic`?(this._cc.touches.one=su.ACTION.TOUCH_ROTATE,this._cc.touches.two=su.ACTION.TOUCH_ZOOM_TRUCK):(this._cc.touches.one=su.ACTION.TOUCH_ROTATE,this._cc.touches.two=su.ACTION.TOUCH_DOLLY_TRUCK)}handleResize(){let e=this.container.clientWidth,t=this.container.clientHeight||window.innerHeight;if(e===0||t===0)return;let n=e/t;this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.orthoCamera.left=-n*Id/2,this.orthoCamera.right=n*Id/2,this.orthoCamera.top=Id/2,this.orthoCamera.bottom=-Id/2,this.orthoCamera.updateProjectionMatrix(),this.perspCamera.aspect=n,this.perspCamera.updateProjectionMatrix(),this.gizmo.update(),this.requestRender()}updateLightPositions(){let e=new B;this.camera.getWorldDirection(e),this.dirLight.position.copy(e.multiplyScalar(-10)),this.dirLight.target.position.set(0,0,0),this.dirLight.target.updateMatrixWorld()}},zd=class extends G{constructor(e=10,t=100,n=new U(`white`),r=8e3,i=new B(0,1,0)){let a=new aa(2,2,1,1),o=new qr({side:0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:2,uniforms:{uSize1:{value:e},uSize2:{value:t},uColor:{value:n},uDistance:{value:r},uNormal:{value:i.normalize()}},transparent:!0,vertexShader:`
|
|
4202
|
+
`};var Qu=class extends qr{constructor(e){super({type:`LineMaterial`,uniforms:Wr.clone(yo.line.uniforms),vertexShader:yo.line.vertexShader,fragmentShader:yo.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(e)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},$u=new Lt,ed=new B,td=new B,nd=new Lt,rd=new Lt,id=new Lt,ad=new B,od=new gn,sd=new po,cd=new B,ld=new Ht,ud=new sn,dd=new Lt,fd,pd;function md(e,t,n){return dd.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),dd.multiplyScalar(1/dd.w),dd.x=pd/n.width,dd.y=pd/n.height,dd.applyMatrix4(e.projectionMatrixInverse),dd.multiplyScalar(1/dd.w),Math.abs(Math.max(dd.x,dd.y))}function hd(e,t){let n=e.matrixWorld,r=e.geometry,i=r.attributes.instanceStart,a=r.attributes.instanceEnd,o=Math.min(r.instanceCount,i.count);for(let r=0,s=o;r<s;r++){sd.start.fromBufferAttribute(i,r),sd.end.fromBufferAttribute(a,r),sd.applyMatrix4(n);let o=new B,s=new B;fd.distanceSqToSegment(sd.start,sd.end,s,o),s.distanceTo(o)<pd*.5&&t.push({point:s,pointOnLine:o,distance:fd.origin.distanceTo(s),object:e,face:null,faceIndex:r,uv:null,uv1:null})}}function gd(e,t,n){let r=t.projectionMatrix,i=e.material.resolution,a=e.matrixWorld,o=e.geometry,s=o.attributes.instanceStart,c=o.attributes.instanceEnd,l=Math.min(o.instanceCount,s.count),u=-t.near;fd.at(1,id),id.w=1,id.applyMatrix4(t.matrixWorldInverse),id.applyMatrix4(r),id.multiplyScalar(1/id.w),id.x*=i.x/2,id.y*=i.y/2,id.z=0,ad.copy(id),od.multiplyMatrices(t.matrixWorldInverse,a);for(let t=0,o=l;t<o;t++){if(nd.fromBufferAttribute(s,t),rd.fromBufferAttribute(c,t),nd.w=1,rd.w=1,nd.applyMatrix4(od),rd.applyMatrix4(od),nd.z>u&&rd.z>u)continue;if(nd.z>u){let e=nd.z-rd.z,t=(nd.z-u)/e;nd.lerp(rd,t)}else if(rd.z>u){let e=rd.z-nd.z,t=(rd.z-u)/e;rd.lerp(nd,t)}nd.applyMatrix4(r),rd.applyMatrix4(r),nd.multiplyScalar(1/nd.w),rd.multiplyScalar(1/rd.w),nd.x*=i.x/2,nd.y*=i.y/2,rd.x*=i.x/2,rd.y*=i.y/2,sd.start.copy(nd),sd.start.z=0,sd.end.copy(rd),sd.end.z=0;let o=sd.closestPointToPointParameter(ad,!0);sd.at(o,cd);let l=pt.lerp(nd.z,rd.z,o),d=l>=-1&&l<=1,f=ad.distanceTo(cd)<pd*.5;if(d&&f){sd.start.fromBufferAttribute(s,t),sd.end.fromBufferAttribute(c,t),sd.start.applyMatrix4(a),sd.end.applyMatrix4(a);let r=new B,i=new B;fd.distanceSqToSegment(sd.start,sd.end,i,r),n.push({point:i,pointOnLine:r,distance:fd.origin.distanceTo(i),object:e,face:null,faceIndex:t,uv:null,uv1:null})}}}var _d=class extends G{constructor(e=new Zu,t=new Qu({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let e=this.geometry,t=e.attributes.instanceStart,n=e.attributes.instanceEnd,r=new Float32Array(2*t.count);for(let e=0,i=0,a=t.count;e<a;e++,i+=2)ed.fromBufferAttribute(t,e),td.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+ed.distanceTo(td);let i=new $a(r,2,1);return e.setAttribute(`instanceDistanceStart`,new ui(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new ui(i,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`);let i=e.params.Line2!==void 0&&e.params.Line2.threshold||0;fd=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;pd=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),ud.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?pd*.5:md(r,Math.max(r.near,ud.distanceToPoint(fd.origin)),s.resolution),ud.radius+=c,fd.intersectsSphere(ud)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),ld.copy(o.boundingBox).applyMatrix4(a);let l;l=n?pd*.5:md(r,Math.max(r.near,ld.distanceToPoint(fd.origin)),s.resolution),ld.expandByScalar(l),fd.intersectsBox(ld)!==!1&&(n?hd(this,t):gd(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport($u),this.material.uniforms.resolution.value.set($u.z,$u.w))}},vd=class extends Zu{constructor(){super(),this.isLineGeometry=!0,this.type=`LineGeometry`}setPositions(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setPositions(n),this}setColors(e){let t=e.length-3,n=new Float32Array(2*t);for(let r=0;r<t;r+=3)n[2*r]=e[r],n[2*r+1]=e[r+1],n[2*r+2]=e[r+2],n[2*r+3]=e[r+3],n[2*r+4]=e[r+4],n[2*r+5]=e[r+5];return super.setColors(n),this}setFromPoints(e){let t=e.length-1,n=new Float32Array(6*t);for(let r=0;r<t;r++)n[6*r]=e[r].x,n[6*r+1]=e[r].y,n[6*r+2]=e[r].z||0,n[6*r+3]=e[r+1].x,n[6*r+4]=e[r+1].y,n[6*r+5]=e[r+1].z||0;return super.setPositions(n),this}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},yd=class extends _d{constructor(e=new vd,t=new Qu({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},bd=e=>{let t=new U,n=[],r=[],{isSphere:i}=e;return wu.forEach((a,o)=>{let{enabled:s,line:c,scale:l,color:u}=e[a];if(!s||!c)return;let d=o<3?1:-1,f=(i?Pu-l/2:.975)*d;n.push(a.includes(`x`)?f:0,a.includes(`y`)?f:0,a.includes(`z`)?f:0,0,0,0);let p=t.set(u).toArray();r.push(...p,...p)}),n.length?new yd(new vd().setPositions(n).setColors(r),new Qu({linewidth:e.lineWidth,vertexColors:!0,resolution:new z(window.innerWidth,window.innerHeight)})).computeLineDistances():null},xd=e=>{let{corners:t,edges:n}=e,r=[],i=zu(e),a=Uu(e,i);return r.push(...a),t.enabled&&r.push(...Wu(e,i)),n.enabled&&r.push(...Gu(e,i,t.enabled?7:6)),[r,Ju(a,e),bd(e)]},Sd=(e,t=!0)=>{let{material:n,userData:r}=e,{opacity:i,color:a,scale:o}=t?r.hover:r;e.scale.setScalar(o),n.opacity=i,n.map?Bu(n.map,t):n.color.set(a)},Cd=new gn,wd=new io,Td=new z,Ed=new B,Dd=new Lt,Od=class extends Un{constructor(e,t,n={}){super(),lu(this,`enabled`,!0),lu(this,`camera`),lu(this,`renderer`),lu(this,`options`),lu(this,`target`,new B),lu(this,`animated`,!0),lu(this,`speed`,1),lu(this,`animating`,!1),lu(this,`_options`),lu(this,`_intersections`),lu(this,`_background`,null),lu(this,`_viewport`,[0,0,0,0]),lu(this,`_originalViewport`,[0,0,0,0]),lu(this,`_originalScissor`,[0,0,0,0]),lu(this,`_scene`),lu(this,`_camera`),lu(this,`_container`),lu(this,`_domElement`),lu(this,`_domRect`),lu(this,`_dragging`,!1),lu(this,`_distance`,0),lu(this,`_clock`,new Ba),lu(this,`_targetQuaternion`,new mt),lu(this,`_quaternionStart`,new mt),lu(this,`_quaternionEnd`,new mt),lu(this,`_pointerStart`,new z),lu(this,`_focus`,null),lu(this,`_placement`),lu(this,`_controls`),lu(this,`_controlsListeners`),this.camera=e,this.renderer=t,this._scene=new si().add(this),this.set(n)}get placement(){return this._placement}set placement(e){this._placement=uu(this._domElement,e),this.domUpdate()}set(e={}){this.dispose(),this.options=e,this._options=Lu(e),this._camera=this._options.isSphere?new Pa(-1.8,1.8,1.8,-1.8,5,10):new Qr(26,1,5,10),this._camera.position.set(0,0,7);let[t,n,r]=xd(this._options);n&&this.add(n),r&&this.add(r),this.add(...t),this._background=n,this._intersections=t;let{container:i,animated:a,speed:o}=this._options;return this.animated=a,this.speed=o,this._container=i?fu(i):document.body,this._domElement=du(this._options),this._domElement.onpointerdown=e=>this._onPointerDown(e),this._domElement.onpointermove=e=>this._onPointerMove(e),this._domElement.onpointerleave=()=>this._onPointerLeave(),this._container.appendChild(this._domElement),this._controls&&this.attachControls(this._controls),this.update(),this._updateOrientation(!0),this}render(){this.animating&&this._animate();let{renderer:e,_viewport:t}=this,n=e.getScissorTest(),r=e.autoClear;return e.autoClear=!1,e.setViewport(...t),n&&e.setScissor(...t),e.clear(!1,!0,!1),e.render(this._scene,this._camera),e.setViewport(...this._originalViewport),n&&e.setScissor(...this._originalScissor),e.autoClear=r,this}domUpdate(){this._domRect=this._domElement.getBoundingClientRect();let e=this.renderer,t=this._domRect,n=e.domElement.getBoundingClientRect();return this._viewport.splice(0,4,t.left-n.left,e.domElement.clientHeight-(t.top-n.top+t.height),t.width,t.height),e.getViewport(Dd).toArray(this._originalViewport),e.getScissorTest()&&e.getScissor(Dd).toArray(this._originalScissor),this}cameraUpdate(){return this._updateOrientation(),this}update(e=!0){return e&&this._controls&&this._controls.update(),this.domUpdate().cameraUpdate()}attachControls(e){return this.detachControls(),this.target=e.target,this._controlsListeners={start:()=>e.enabled=!1,end:()=>e.enabled=!0,change:()=>this.update(!1)},this.addEventListener(`start`,this._controlsListeners.start),this.addEventListener(`end`,this._controlsListeners.end),e.addEventListener(`change`,this._controlsListeners.change),this._controls=e,this}detachControls(){if(!(!this._controlsListeners||!this._controls))return this.target=new B().copy(this._controls.target),this.removeEventListener(`start`,this._controlsListeners.start),this.removeEventListener(`end`,this._controlsListeners.end),this._controls.removeEventListener(`change`,this._controlsListeners.change),this._controlsListeners=void 0,this._controls=void 0,this}dispose(){var e;this.detachControls(),this.children.forEach(e=>{var t,n,r;this.remove(e);let i=e;(t=i.material)==null||t.dispose(),(n=i.material?.map)==null||n.dispose(),(r=i.geometry)==null||r.dispose()}),(e=this._domElement)==null||e.remove()}_updateOrientation(e=!0){e&&(this.quaternion.copy(this.camera.quaternion).invert(),this.updateMatrixWorld()),gu(this._options,this._intersections,this.camera)}_animate(){let{position:e,quaternion:t}=this.camera;if(e.set(0,0,1),!this.animated){e.applyQuaternion(this._quaternionEnd).multiplyScalar(this._distance).add(this.target),t.copy(this._targetQuaternion),this._updateOrientation(),this.animating=!1,this.dispatchEvent({type:`change`}),this.dispatchEvent({type:`end`});return}this._controls&&(this._controls.enabled=!1);let n=this._clock.getDelta()*Su*this.speed;this._quaternionStart.rotateTowards(this._quaternionEnd,n),e.applyQuaternion(this._quaternionStart).multiplyScalar(this._distance).add(this.target),t.rotateTowards(this._targetQuaternion,n),this._updateOrientation(),requestAnimationFrame(()=>this.dispatchEvent({type:`change`})),this._quaternionStart.angleTo(this._quaternionEnd)<xu&&(this._controls&&(this._controls.enabled=!0),this.animating=!1,this.dispatchEvent({type:`end`}))}_setOrientation(e){let t=this.camera,n=this.target;Ed.copy(e).multiplyScalar(this._distance),Cd.setPosition(Ed).lookAt(Ed,this.position,this.up),this._targetQuaternion.setFromRotationMatrix(Cd),Ed.add(n),Cd.lookAt(Ed,n,this.up),this._quaternionEnd.setFromRotationMatrix(Cd),Cd.setPosition(t.position).lookAt(t.position,n,this.up),this._quaternionStart.setFromRotationMatrix(Cd),this.animating=!0,this._clock.start(),this.dispatchEvent({type:`start`})}_onPointerDown(e){if(!this.enabled)return;let t=e=>{if(!this._dragging){if(_u(e,this._pointerStart))return;this._dragging=!0}let t=Td.set(e.clientX,e.clientY).sub(this._pointerStart).multiplyScalar(1/this._domRect.width*Math.PI),n=this.coordinateConversion(Ed.subVectors(this.camera.position,this.target)),r=wd.setFromVector3(n);r.theta=a-t.x,r.phi=pu(o-t.y,xu,Math.PI-xu),this.coordinateConversion(this.camera.position.setFromSpherical(r),!0).add(this.target),this.camera.lookAt(this.target),this.quaternion.copy(this.camera.quaternion).invert(),this._updateOrientation(!1),this.dispatchEvent({type:`change`})},n=()=>{if(document.removeEventListener(`pointermove`,t,!1),document.removeEventListener(`pointerup`,n,!1),!this._dragging)return this._handleClick(e);this._focus&&=(Sd(this._focus,!1),null),this._dragging=!1,this.dispatchEvent({type:`end`})};if(this.animating)return;e.preventDefault(),this._pointerStart.set(e.clientX,e.clientY);let r=this.coordinateConversion(Ed.subVectors(this.camera.position,this.target)),i=wd.setFromVector3(r),a=i.theta,o=i.phi;this._distance=i.radius,document.addEventListener(`pointermove`,t,!1),document.addEventListener(`pointerup`,n,!1),this.dispatchEvent({type:`start`})}coordinateConversion(e,t=!1){let{x:n,y:r,z:i}=e,a=Un.DEFAULT_UP;return a.x===1?t?e.set(r,i,n):e.set(i,n,r):a.z===1?t?e.set(i,n,r):e.set(r,i,n):e}_onPointerMove(e){!this.enabled||this._dragging||(this._background&&Fu(this._background,!0),this._handleHover(e))}_onPointerLeave(){!this.enabled||this._dragging||(this._background&&Fu(this._background,!1),this._focus&&Sd(this._focus,!1),this._domElement.style.cursor=``)}_handleClick(e){let t=bu(e,this._domRect,this._camera,this._intersections);this._focus&&=(Sd(this._focus,!1),null),t&&(this._setOrientation(t.object.position),this.dispatchEvent({type:`change`}))}_handleHover(e){let t=bu(e,this._domRect,this._camera,this._intersections)?.object||null;this._focus!==t&&(this._domElement.style.cursor=t?`pointer`:``,this._focus&&Sd(this._focus,!1),(this._focus=t)?Sd(t,!0):gu(this._options,this._intersections,this.camera))}},kd=class extends He{target=new B;constructor(e){super(),this.cc=e,e.addEventListener(`update`,()=>{e.getTarget(this.target),this.dispatchEvent({type:`change`})})}get enabled(){return this.cc.enabled}set enabled(e){this.cc.enabled=e}update(){let e=this.cc.camera.position,t=this.target;this.cc.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1)}},Ad=new Set;function jd(e,t){return getComputedStyle(document.documentElement).getPropertyValue(e).trim()||t}function Md(){Nd.faceColor.set(jd(`--scene-face-color`,`#969696`)),Nd.edgeColor.set(jd(`--scene-edge-color`,`#000000`)),Nd.gridColor.set(jd(`--scene-grid-color`,`#6f6f6f`)),Nd.metaEdgeColor.set(jd(`--scene-meta-edge-color`,`#b0b0b0`)),Nd.backgroundColor.set(jd(`--color-base-100`,`#1e1e1e`))}var Nd={faceColor:new U(`#969696`),edgeColor:new U(`#000000`),gridColor:new U(`#6f6f6f`),metaEdgeColor:new U(`#b0b0b0`),backgroundColor:new U(`#1e1e1e`)};Md(),new MutationObserver(()=>{Md();for(let e of Ad)e()}).observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]});function Pd(e){return Ad.add(e),()=>Ad.delete(e)}ou.install({THREE:{Vector2:z,Vector3:B,Vector4:Lt,Quaternion:mt,Matrix4:gn,Spherical:io,Box3:Ht,Sphere:sn,Raycaster:to,MathUtils:{DEG2RAD:pt.DEG2RAD,clamp:pt.clamp}}});var Fd=new B(0,0,1),Id=120,Ld=1.1,Rd=class{scene;renderer;gizmo;orthoCamera;perspCamera;activeCamera=`orthographic`;_cc;_adapter;dirLight;renderRequested=!1;resizeObserver;clock=new Ba;animFrameId=0;gizmoWasActive=!1;constructor(e){this.container=e,Un.DEFAULT_UP=Fd.clone();let t=e.clientWidth||window.innerWidth,n=e.clientHeight||window.innerHeight;this.renderer=new vl({antialias:!0,alpha:!0}),this.renderer.setSize(t,n),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.toneMapping=4,this.renderer.outputColorSpace=Fe,this.renderer.localClippingEnabled=!0,e.appendChild(this.renderer.domElement),this.scene=new si,this.scene.background=Nd.backgroundColor.clone();let r=t/n;this.orthoCamera=new Pa(-r*Id/2,r*Id/2,Id/2,-Id/2,-1e4,1e4),this.orthoCamera.position.set(50,-50,40),this.orthoCamera.up.copy(Fd),this.orthoCamera.lookAt(0,0,0),this.perspCamera=new Qr(50,r,.5,1e4),this.perspCamera.position.set(50,-50,40),this.perspCamera.up.copy(Fd),this.perspCamera.lookAt(0,0,0),this.dirLight=new Ia(16777215,1),this.scene.add(this.dirLight),this.scene.add(new La(14544639,2.5)),this._cc=new ou(this.orthoCamera,this.renderer.domElement),this._cc.dollyToCursor=!0,this._cc.smoothTime=.1,this._cc.draggingSmoothTime=.05,this.configureTouchForMode(`orthographic`),this._cc.updateCameraUp(),this._adapter=new kd(this._cc),this.gizmo=new Od(this.camera,this.renderer,{size:80,type:`sphere`}),this._cc.setLookAt(50,-50,40,0,0,0,!1),this._cc.getTarget(this._adapter.target),this.gizmo.target=this._adapter.target,this.gizmo.attachControls(this._adapter),this.gizmo.addEventListener(`change`,()=>this.requestRender()),this.resizeObserver=new ResizeObserver(()=>this.handleResize()),this.resizeObserver.observe(e),Pd(()=>{this.scene.background=Nd.backgroundColor.clone(),this.requestRender()}),this.tick()}get camera(){return this.activeCamera===`orthographic`?this.orthoCamera:this.perspCamera}get cameraControls(){return this._cc}get controls(){return this._adapter}requestRender(){this.renderRequested=!0}fitToBox(e,t){let n=e.getCenter(new B),r=e.getSize(new B).length()/2;if(r===0)return;let i=new sn(n,r*Ld);this._cc.fitToSphere(i,t)}switchCamera(e){if(e===this.activeCamera)return;let t=new B,n=new B;this._cc.getPosition(t),this._cc.getTarget(n);let r=this.camera.up.clone();if(this.activeCamera===`orthographic`&&e===`perspective`){let e=(this.orthoCamera.top-this.orthoCamera.bottom)/this.orthoCamera.zoom,r=pt.DEG2RAD*this.perspCamera.fov*.5,i=e*.5/Math.tan(r),a=t.clone().sub(n).normalize();t.copy(n).add(a.multiplyScalar(i))}this.activeCamera=e;let i=this.camera;i.position.copy(t),i.up.copy(r),i.lookAt(n),this._cc.dispose(),this._cc=new ou(i,this.renderer.domElement),this._cc.dollyToCursor=!0,this._cc.smoothTime=.1,this._cc.draggingSmoothTime=.05,this._cc.setLookAt(t.x,t.y,t.z,n.x,n.y,n.z,!1),this._cc.updateCameraUp(),this.configureTouchForMode(e),this._adapter=new kd(this._cc),this._cc.getTarget(this._adapter.target),this.gizmo.camera=i,this.gizmo.target=this._adapter.target,this.gizmo.attachControls(this._adapter),this.gizmo.update(),this.requestRender()}render(){this.updateLightPositions(),this.renderer.render(this.scene,this.camera),this.gizmo.render()}dispose(){cancelAnimationFrame(this.animFrameId),this.resizeObserver.disconnect(),this._cc.dispose(),this.scene.clear(),this.renderer.dispose()}tick=()=>{let e=this.clock.getDelta(),t=!1;if(this._cc.enabled){if(this.gizmoWasActive){this._cc.updateCameraUp();let e=this.camera.position,t=this._adapter.target;this._cc.setLookAt(e.x,e.y,e.z,t.x,t.y,t.z,!1),this.gizmoWasActive=!1}t=this._cc.update(e)}else this.gizmoWasActive=!0;(t||this.renderRequested||!this._cc.enabled)&&(this.render(),this.renderRequested=!1),this.animFrameId=requestAnimationFrame(this.tick)};configureTouchForMode(e){e===`orthographic`?(this._cc.touches.one=ou.ACTION.TOUCH_ROTATE,this._cc.touches.two=ou.ACTION.TOUCH_ZOOM_TRUCK):(this._cc.touches.one=ou.ACTION.TOUCH_ROTATE,this._cc.touches.two=ou.ACTION.TOUCH_DOLLY_TRUCK)}handleResize(){let e=this.container.clientWidth,t=this.container.clientHeight||window.innerHeight;if(e===0||t===0)return;let n=e/t;this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.orthoCamera.left=-n*Id/2,this.orthoCamera.right=n*Id/2,this.orthoCamera.top=Id/2,this.orthoCamera.bottom=-Id/2,this.orthoCamera.updateProjectionMatrix(),this.perspCamera.aspect=n,this.perspCamera.updateProjectionMatrix(),this.gizmo.update(),this.requestRender()}updateLightPositions(){let e=new B;this.camera.getWorldDirection(e),this.dirLight.position.copy(e.multiplyScalar(-10)),this.dirLight.target.position.set(0,0,0),this.dirLight.target.updateMatrixWorld()}},zd=class extends G{constructor(e=10,t=100,n=new U(`white`),r=8e3,i=new B(0,1,0)){let a=new aa(2,2,1,1),o=new qr({side:0,polygonOffset:!0,polygonOffsetFactor:2,polygonOffsetUnits:2,uniforms:{uSize1:{value:e},uSize2:{value:t},uColor:{value:n},uDistance:{value:r},uNormal:{value:i.normalize()}},transparent:!0,vertexShader:`
|
|
4203
4203
|
|
|
4204
4204
|
varying vec3 worldPosition;
|
|
4205
4205
|
|
|
@@ -4660,7 +4660,7 @@ void main() {
|
|
|
4660
4660
|
`,this.panel.appendChild(l),this.historyTotalLabel=l.querySelector(`[data-ref="history-total"]`);let u=l.querySelector(`[data-ref="history-dots"]`);u.addEventListener(`click`,e=>{e.stopPropagation(),this.showHistoryDropdown(u)}),this.timelineBody=document.createElement(`div`),this.timelineBody.className=`py-1 overflow-y-auto min-h-0 flex-[2]`,this.panel.appendChild(this.timelineBody);let d=document.createElement(`div`);d.className=_m,d.innerHTML=`
|
|
4661
4661
|
<span class="flex items-center justify-center w-5 h-5 opacity-50 transition-transform rotate-90">${vm}</span>
|
|
4662
4662
|
<span class="text-sm font-medium text-base-content/70">Shapes</span>
|
|
4663
|
-
`,this.panel.appendChild(d),this.shapesBody=document.createElement(`div`),this.shapesBody.className=`py-1 overflow-y-auto min-h-[120px] flex-1`,this.panel.appendChild(this.shapesBody),l.addEventListener(`click`,()=>{this.timelineExpanded=!this.timelineExpanded,this.timelineBody.classList.toggle(`hidden`,!this.timelineExpanded),l.querySelector(`[data-ref="chevron"]`).classList.toggle(`rotate-90`,this.timelineExpanded)}),d.addEventListener(`click`,()=>{this.shapesExpanded=!this.shapesExpanded,this.shapesBody.classList.toggle(`hidden`,!this.shapesExpanded),d.querySelector(`span`).classList.toggle(`rotate-90`,this.shapesExpanded)})}update(e,t,n){if(this.sceneObjects=e,this.rollbackStop=t,n){let e=n.split(`/`).pop()||n;this.fileLabel.textContent=e}this.loaded||(this.loaded=!0,this.panel.classList.remove(`hidden`)),this.renderTimeline(!0),this.renderShapes(),this.updateHistoryTotal()}updateHistoryTotal(){if(!this.showBuildTimings){this.historyTotalLabel.classList.add(`hidden`);return}let e=0,t=!1;for(let n of this.sceneObjects)n.parentId||n.fromCache||n.buildDurationMs==null||(e+=n.buildDurationMs,t=!0);if(!t){this.historyTotalLabel.classList.add(`hidden`);return}this.historyTotalLabel.textContent=`· ${Sm(e)}`,this.historyTotalLabel.classList.remove(`hidden`)}renderTimeline(e=!1){let t=this.sceneObjects,n=this.rollbackStop,r=new Set;for(let e of t)e.parentId&&r.add(e.parentId);let i=``;for(let e=0;e<t.length;e++){let a=t[e];if(a.parentId)continue;let o=a.id!=null&&r.has(a.id),s=a.id!=null&&this.collapsedIds.has(a.id);if(i+=this.renderTimelineItem(a,e,n,!1,o,s),o&&!s)for(let e=0;e<t.length;e++)t[e].parentId===a.id&&(i+=this.renderTimelineItem(t[e],e,n,!0,!1,!1))}if(this.timelineBody.innerHTML=i,this.timelineBody.querySelectorAll(`[data-index]`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.target.closest(`[data-toggle]`))return;let n=parseInt(e.dataset.index,10);this.rollbackTo(n),this.gotoSource(this.sceneObjects[n])}),e.addEventListener(`dblclick`,t=>{if(t.target.closest(`[data-toggle]`))return;let n=parseInt(e.dataset.index,10);this.addBreakpointAfter(n),this.gotoSource(this.sceneObjects[n])})}),this.timelineBody.querySelectorAll(`[data-toggle]`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.toggle;this.collapsedIds.has(n)?this.collapsedIds.delete(n):this.collapsedIds.add(n),this.renderTimeline()})}),e){let e=this.timelineBody.querySelector(`[data-current="true"]`);e&&e.scrollIntoView({block:`nearest`})}}renderTimelineItem(e,t,n,r,i,a){let o=t===n,s=t>n,c=e.visible===!1,l=e.hasError===!0,u=e.name?e.name.charAt(0).toUpperCase()+e.name.slice(1):e.type||`Unknown`,d=e.type===`part`?`/icons/box.png`:`/icons/${gm(e.uniqueType,e.type)}.png`,f=`flex items-center gap-1 px-3 py-1.5 cursor-pointer hover:bg-base-content/[0.06] text-sm`;r&&(f+=` pl-7`),o?f+=` border-l-2 border-primary bg-primary/10 text-primary`:l?f+=` text-error`:s||c?f+=` text-base-content/60`:f+=` text-base-content/80`;let p=c?`w-4 h-4 object-contain grayscale opacity-60`:`w-4 h-4 object-contain`,m=``;if(i){let t=a?``:`rotate-90`;m=`<span data-toggle="${e.id}" class="flex items-center justify-center w-5 h-5 opacity-50 hover:opacity-100 transition-transform ${t}">
|
|
4663
|
+
`,this.panel.appendChild(d),this.shapesBody=document.createElement(`div`),this.shapesBody.className=`py-1 overflow-y-auto min-h-[120px] flex-1`,this.panel.appendChild(this.shapesBody),l.addEventListener(`click`,()=>{this.timelineExpanded=!this.timelineExpanded,this.timelineBody.classList.toggle(`hidden`,!this.timelineExpanded),l.querySelector(`[data-ref="chevron"]`).classList.toggle(`rotate-90`,this.timelineExpanded)}),d.addEventListener(`click`,()=>{this.shapesExpanded=!this.shapesExpanded,this.shapesBody.classList.toggle(`hidden`,!this.shapesExpanded),d.querySelector(`span`).classList.toggle(`rotate-90`,this.shapesExpanded)})}update(e,t,n){if(this.sceneObjects=e,this.rollbackStop=t,n){let e=n.split(`/`).pop()||n;this.fileLabel.textContent=e}this.loaded||(this.loaded=!0,this.panel.classList.remove(`hidden`)),this.renderTimeline(!0),this.renderShapes(),this.updateHistoryTotal()}updateHistoryTotal(){if(!this.showBuildTimings){this.historyTotalLabel.classList.add(`hidden`);return}let e=0,t=!1;for(let n of this.sceneObjects)n.parentId||n.fromCache||n.buildDurationMs==null||(e+=n.buildDurationMs,t=!0);if(!t){this.historyTotalLabel.classList.add(`hidden`);return}this.historyTotalLabel.textContent=`· ${Sm(e)}`,this.historyTotalLabel.classList.remove(`hidden`)}renderTimeline(e=!1){let t=this.sceneObjects,n=this.rollbackStop,r=new Set;for(let e of t)e.uniqueType!==`lazy-select`&&e.parentId&&r.add(e.parentId);let i=``;for(let e=0;e<t.length;e++){let a=t[e];if(a.parentId||a.uniqueType===`lazy-select`)continue;let o=a.id!=null&&r.has(a.id),s=a.id!=null&&this.collapsedIds.has(a.id);if(i+=this.renderTimelineItem(a,e,n,!1,o,s),o&&!s)for(let e=0;e<t.length;e++)t[e].uniqueType!==`lazy-select`&&t[e].parentId===a.id&&(i+=this.renderTimelineItem(t[e],e,n,!0,!1,!1))}if(this.timelineBody.innerHTML=i,this.timelineBody.querySelectorAll(`[data-index]`).forEach(e=>{e.addEventListener(`click`,t=>{if(t.target.closest(`[data-toggle]`))return;let n=parseInt(e.dataset.index,10);this.rollbackTo(n),this.gotoSource(this.sceneObjects[n])}),e.addEventListener(`dblclick`,t=>{if(t.target.closest(`[data-toggle]`))return;let n=parseInt(e.dataset.index,10);this.addBreakpointAfter(n),this.gotoSource(this.sceneObjects[n])})}),this.timelineBody.querySelectorAll(`[data-toggle]`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=e.dataset.toggle;this.collapsedIds.has(n)?this.collapsedIds.delete(n):this.collapsedIds.add(n),this.renderTimeline()})}),e){let e=this.timelineBody.querySelector(`[data-current="true"]`);e&&e.scrollIntoView({block:`nearest`})}}renderTimelineItem(e,t,n,r,i,a){let o=t===n,s=t>n,c=e.visible===!1,l=e.hasError===!0,u=e.name?e.name.charAt(0).toUpperCase()+e.name.slice(1):e.type||`Unknown`,d=e.type===`part`?`/icons/box.png`:`/icons/${gm(e.uniqueType,e.type)}.png`,f=`flex items-center gap-1 px-3 py-1.5 cursor-pointer hover:bg-base-content/[0.06] text-sm`;r&&(f+=` pl-7`),o?f+=` border-l-2 border-primary bg-primary/10 text-primary`:l?f+=` text-error`:s||c?f+=` text-base-content/60`:f+=` text-base-content/80`;let p=c?`w-4 h-4 object-contain grayscale opacity-60`:`w-4 h-4 object-contain`,m=``;if(i){let t=a?``:`rotate-90`;m=`<span data-toggle="${e.id}" class="flex items-center justify-center w-5 h-5 opacity-50 hover:opacity-100 transition-transform ${t}">
|
|
4664
4664
|
${vm}
|
|
4665
4665
|
</span>`}else m=`<span class="w-4"></span>`;let h=this.showBuildTimings&&!e.fromCache&&e.buildDurationMs!=null,g=h?`<span class="ml-auto shrink-0 text-xs text-base-content/40 tabular-nums">${Sm(e.buildDurationMs)}</span>`:``,_=h?`shrink-0 text-base-content/40 [&>svg]:w-4 [&>svg]:h-4`:`ml-auto shrink-0 text-base-content/40 [&>svg]:w-4 [&>svg]:h-4`,v=e.fromCache?`<span class="${_}">${Lp}</span>`:`<span class="${_}">${Rp}</span>`;return`
|
|
4666
4666
|
<div class="${f}" data-index="${t}" data-container="${e.isContainer??!1}" data-current="${o}">
|
|
@@ -4797,7 +4797,7 @@ void main() {
|
|
|
4797
4797
|
<button data-ref="export-btn" class="btn btn-primary btn-sm">Export</button>
|
|
4798
4798
|
</div>
|
|
4799
4799
|
</div>
|
|
4800
|
-
`}setFormat(e){this.selectedFormat=e,this.stepSection.classList.toggle(`hidden`,e!==`step`),this.stlSection.classList.toggle(`hidden`,e!==`stl`),this.pngSection.classList.toggle(`hidden`,e!==`png`)}bindEvents(){this.overlay.querySelector(`[data-ref="close-btn"]`).addEventListener(`click`,()=>this.hide()),this.overlay.querySelector(`[data-ref="cancel-btn"]`).addEventListener(`click`,()=>this.hide()),this.overlay.addEventListener(`click`,e=>{e.target===this.overlay&&this.hide()}),this.pillsContainer.querySelectorAll(`[data-format]`).forEach(e=>{e.addEventListener(`change`,()=>this.setFormat(e.dataset.format))}),this.resolutionSelect.addEventListener(`change`,()=>{this.customSection.classList.toggle(`hidden`,this.resolutionSelect.value!==`custom`)}),this.autoCropToggle.addEventListener(`change`,()=>{this.marginSection.classList.toggle(`hidden`,!this.autoCropToggle.checked)}),this.exportBtn.addEventListener(`click`,()=>this.onExport())}async onExport(){if(this.selectedFormat===`png`)return this.exportPng();let e=this.selectedFormat,t={format:e,shapeIds:this.shapeIds};e===`step`?t.includeColors=this.includeColorsToggle.checked:(t.resolution=this.resolutionSelect.value,t.resolution===`custom`&&(t.customAngularDeflectionDeg=parseFloat(this.angularInput.value),t.customLinearDeflection=parseFloat(this.linearInput.value))),this.exportBtn.disabled=!0,this.statusEl.classList.remove(`hidden`),this.statusEl.innerHTML=`<span class="loading loading-spinner loading-xs"></span><span>Exporting...</span>`;try{let n=await fetch(`/api/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Export failed`)}let r=await n.blob(),i=e===`step`?`.step`:`.stl`,a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`export${i}`,o.click(),URL.revokeObjectURL(a),this.hide()}catch(e){this.statusEl.innerHTML=`<span class="text-error text-xs">${e.message}</span>`}finally{this.exportBtn.disabled=!1}}async exportPng(){this.exportBtn.disabled=!0;try{let e=await Tm(this.sceneCtx,{width:Math.max(1,Math.min(8192,parseInt(this.widthInput.value)||800)),height:Math.max(1,Math.min(8192,parseInt(this.heightInput.value)||800)),showGrid:this.showGridToggle.checked,showAxes:this.showAxesToggle.checked,transparent:this.transparentToggle.checked,autoCrop:this.autoCropToggle.checked,margin:this.autoCropToggle.checked?Math.max(0,parseInt(this.marginInput.value)||0):0}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`export.png`,n.click(),URL.revokeObjectURL(t),this.hide()}catch(e){this.statusEl.classList.remove(`hidden`),this.statusEl.innerHTML=`<span class="text-error text-xs">${e.message}</span>`}finally{this.exportBtn.disabled=!1}}},Am=class{element;constructor(e){this.element=document.createElement(`div`),this.element.id=`fluidcad-breakpoint-indicator`,this.element.className=`absolute bottom-6 left-1/2 -translate-x-1/2 z-[999] pointer-events-auto hidden`,this.element.innerHTML=`
|
|
4800
|
+
`}setFormat(e){this.selectedFormat=e,this.stepSection.classList.toggle(`hidden`,e!==`step`),this.stlSection.classList.toggle(`hidden`,e!==`stl`),this.pngSection.classList.toggle(`hidden`,e!==`png`)}bindEvents(){this.overlay.querySelector(`[data-ref="close-btn"]`).addEventListener(`click`,()=>this.hide()),this.overlay.querySelector(`[data-ref="cancel-btn"]`).addEventListener(`click`,()=>this.hide()),this.overlay.addEventListener(`click`,e=>{e.target===this.overlay&&this.hide()}),this.pillsContainer.querySelectorAll(`[data-format]`).forEach(e=>{e.addEventListener(`change`,()=>this.setFormat(e.dataset.format))}),this.resolutionSelect.addEventListener(`change`,()=>{this.customSection.classList.toggle(`hidden`,this.resolutionSelect.value!==`custom`)}),this.autoCropToggle.addEventListener(`change`,()=>{this.marginSection.classList.toggle(`hidden`,!this.autoCropToggle.checked)}),this.exportBtn.addEventListener(`click`,()=>this.onExport())}async onExport(){if(this.selectedFormat===`png`)return this.exportPng();let e=this.selectedFormat,t={format:e,shapeIds:this.shapeIds};e===`step`?t.includeColors=this.includeColorsToggle.checked:(t.resolution=this.resolutionSelect.value,t.resolution===`custom`&&(t.customAngularDeflectionDeg=parseFloat(this.angularInput.value),t.customLinearDeflection=parseFloat(this.linearInput.value))),this.exportBtn.disabled=!0,this.statusEl.classList.remove(`hidden`),this.statusEl.innerHTML=`<span class="loading loading-spinner loading-xs"></span><span>Exporting...</span>`;try{let n=await fetch(`/api/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json();throw Error(e.error||`Export failed`)}let r=await n.blob(),i=e===`step`?`.step`:`.stl`,a=URL.createObjectURL(r),o=document.createElement(`a`);o.href=a,o.download=`export${i}`,o.click(),URL.revokeObjectURL(a),this.hide()}catch(e){this.statusEl.innerHTML=`<span class="text-error text-xs">${e.message}</span>`}finally{this.exportBtn.disabled=!1}}async exportPng(){this.exportBtn.disabled=!0;try{let e=await Tm(this.sceneCtx,{width:Math.max(1,Math.min(8192,parseInt(this.widthInput.value)||800)),height:Math.max(1,Math.min(8192,parseInt(this.heightInput.value)||800)),showGrid:this.showGridToggle.checked,showAxes:this.showAxesToggle.checked,transparent:this.transparentToggle.checked,autoCrop:this.autoCropToggle.checked,margin:this.autoCropToggle.checked?Math.max(0,parseInt(this.marginInput.value)||0):0}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`export.png`,n.click(),URL.revokeObjectURL(t),this.hide()}catch(e){this.statusEl.classList.remove(`hidden`),this.statusEl.innerHTML=`<span class="text-error text-xs">${e.message}</span>`}finally{this.exportBtn.disabled=!1}}},Am=class{element;constructor(e,t){this.element=document.createElement(`div`),this.element.id=`fluidcad-breakpoint-indicator`,this.element.className=`absolute bottom-6 left-1/2 -translate-x-1/2 z-[999] pointer-events-auto hidden`,this.element.innerHTML=`
|
|
4801
4801
|
<div class="flex items-center gap-3 panel-bg border border-warning/40 rounded-lg px-5 py-2.5 text-sm leading-none select-none">
|
|
4802
4802
|
<span class="text-warning [&>svg]:size-5">${Gp}</span>
|
|
4803
4803
|
<span class="text-base-content/80">Breakpoint Active</span>
|
|
@@ -4806,7 +4806,7 @@ void main() {
|
|
|
4806
4806
|
Continue
|
|
4807
4807
|
</button>
|
|
4808
4808
|
</div>
|
|
4809
|
-
`,e.appendChild(this.element),this.element.querySelector(`.fluidcad-breakpoint-continue`).addEventListener(`click`,async()=>{try{await fetch(`/api/clear-breakpoints`,{method:`POST`})}catch(e){console.error(`Clear breakpoints failed:`,e)}})}setActive(e){this.element.classList.toggle(`hidden`,!e)}},jm=12,Mm=class{canvas;ctx;plane;snapManager;onPick;onHighlight;edges=[];highlightedShapeId=null;downX=0;downY=0;boundMouseDown;boundMouseUp;boundMouseMove;constructor(e,t,n,r,i,a,o){this.canvas=e.renderer.domElement,this.ctx=e,this.plane=t,this.snapManager=n,this.onPick=a,this.onHighlight=o,this.edges=Nm(r,i,t),this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this)}updateEdges(e,t){this.edges=Nm(e,t,this.plane),this.highlightedShapeId&&(this.edges.some(e=>e.shapeId===this.highlightedShapeId)||(this.onHighlight(null),this.highlightedShapeId=null))}activate(){this.canvas.addEventListener(`mousedown`,this.boundMouseDown),this.canvas.addEventListener(`mouseup`,this.boundMouseUp),this.canvas.addEventListener(`mousemove`,this.boundMouseMove)}deactivate(){this.canvas.removeEventListener(`mousedown`,this.boundMouseDown),this.canvas.removeEventListener(`mouseup`,this.boundMouseUp),this.canvas.removeEventListener(`mousemove`,this.boundMouseMove),this.highlightedShapeId&&=(this.onHighlight(null),null)}getEdgeEntry(e){return this.edges.find(t=>t.shapeId===e)}handleMouseDown(e){this.downX=e.clientX,this.downY=e.clientY}handleMouseUp(e){let t=e.clientX-this.downX,n=e.clientY-this.downY;if(t*t+n*n>64||!this.highlightedShapeId)return;let r=this.projectToSketch(e.clientX,e.clientY);if(!r)return;let i=this.projectOntoEdge(r,this.highlightedShapeId)??r,a=[Math.round(i[0]*100)/100,Math.round(i[1]*100)/100];this.onPick(a)}handleMouseMove(e){let t=this.projectToSketch(e.clientX,e.clientY);if(!t){this.highlightedShapeId&&=(this.onHighlight(null),null);return}let n=this.computeSketchThreshold(),r=this.findNearestEdge(t,n);if(r!==this.highlightedShapeId){if(r){let e=this.getEdgeEntry(r);this.onHighlight({shapeId:r,endpoints:e?.endpoints??[]})}else this.onHighlight(null);this.highlightedShapeId=r}}computeSketchThreshold(){let e=this.ctx.camera,t=this.ctx.renderer.domElement.getBoundingClientRect().height||1,n,r=e;if(r.isOrthographicCamera)n=(r.top-r.bottom)/(r.zoom||1);else{let t=new B;this.ctx.cameraControls.getTarget(t);let i=e.position.distanceTo(t),a=r.fov*Math.PI/180;n=2*i*Math.tan(a/2)}return n/t*jm}findNearestEdge(e,t){let n=1/0,r=null;for(let t of this.edges)for(let i of t.segments){let a=Pm(e[0],e[1],i.ax,i.ay,i.bx,i.by);a<n&&(n=a,r=t.shapeId)}return n<=t?r:null}projectOntoEdge(e,t){let n=this.edges.find(e=>e.shapeId===t);if(!n)return null;let r=1/0,i=null;for(let t of n.segments){let n=Fm(e[0],e[1],t.ax,t.ay,t.bx,t.by);n.dist<r&&(r=n.dist,i=[n.x,n.y])}return i}projectToSketch(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=s.ray.origin,l=s.ray.direction,u=new B(this.plane.origin.x,this.plane.origin.y,this.plane.origin.z),d=new B(this.plane.normal.x,this.plane.normal.y,this.plane.normal.z),f=l.dot(d);if(Math.abs(f)<1e-6)return null;let p=u.clone().sub(c).dot(d)/f;if(p<0)return null;let m=c.clone().add(l.clone().multiplyScalar(p)).clone().sub(u),h=new B(this.plane.xDirection.x,this.plane.xDirection.y,this.plane.xDirection.z),g=new B(this.plane.yDirection.x,this.plane.yDirection.y,this.plane.yDirection.z);return[m.dot(h),m.dot(g)]}};function Nm(e,t,n){let r=[],i=n.origin.x,a=n.origin.y,o=n.origin.z,s=n.xDirection.x,c=n.xDirection.y,l=n.xDirection.z,u=n.yDirection.x,d=n.yDirection.y,f=n.yDirection.z,p=e.some(e=>e.parentId===t&&e.sceneShapes.some(e=>e.metaType===`trim`));for(let n of e)if(n.parentId===t)for(let e of n.sceneShapes){if(!e.shapeId)continue;if(p){if(e.metaType!==`trim`)continue}else if(e.isMetaShape||e.isGuide)continue;let t=[],n=[];for(let r of e.meshes){let e=r.vertices,p=r.indices;if(!p.length)continue;let m=new Map;for(let e of p)m.set(e,(m.get(e)||0)+1);for(let[t,r]of m)r===1&&n.push([e[t*3],e[t*3+1],e[t*3+2]]);for(let n=0;n<p.length;n+=2){let r=p[n]*3,m=p[n+1]*3,h=e[r]-i,g=e[r+1]-a,_=e[r+2]-o,v=h*s+g*c+_*l,y=h*u+g*d+_*f,b=e[m]-i,x=e[m+1]-a,S=e[m+2]-o,C=b*s+x*c+S*l,w=b*u+x*d+S*f;t.push({ax:v,ay:y,bx:C,by:w})}}t.length>0&&r.push({shapeId:e.shapeId,segments:t,endpoints:n})}return r}function Pm(e,t,n,r,i,a){return Fm(e,t,n,r,i,a).dist}function Fm(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l,u;if(c===0)l=n,u=r;else{let i=((e-n)*o+(t-r)*s)/c;i<0?i=0:i>1&&(i=1),l=n+i*o,u=r+i*s}let d=l-e,f=u-t;return{x:l,y:u,dist:Math.sqrt(d*d+f*f)}}var Im=`#64B5F6`,Lm=.35,Rm=class{canvas;ctx;plane;onPick;onRemove;onHighlight;highlightedMesh=null;highlightedOriginalColor=null;highlightedOriginalOpacity=null;downX=0;downY=0;boundMouseDown;boundMouseUp;boundMouseMove;constructor(e,t,n,r,i){this.canvas=e.renderer.domElement,this.ctx=e,this.plane=t,this.onPick=n,this.onRemove=r,this.onHighlight=i,this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this)}activate(){this.canvas.addEventListener(`mousedown`,this.boundMouseDown),this.canvas.addEventListener(`mouseup`,this.boundMouseUp),this.canvas.addEventListener(`mousemove`,this.boundMouseMove)}deactivate(){this.canvas.removeEventListener(`mousedown`,this.boundMouseDown),this.canvas.removeEventListener(`mouseup`,this.boundMouseUp),this.canvas.removeEventListener(`mousemove`,this.boundMouseMove),this.restoreHighlight()}handleMouseDown(e){this.downX=e.clientX,this.downY=e.clientY}handleMouseUp(e){let t=e.clientX-this.downX,n=e.clientY-this.downY;if(t*t+n*n>64)return;let r=this.projectToSketch(e.clientX,e.clientY);if(!r)return;let i=this.raycastRegions(e.clientX,e.clientY);if(!i)return;let a=i.mesh.parent;if(a?.userData.isPickRegionSelected===!0){let e=this.collectSelectedPickPoints(a);this.onRemove(e)}else{let e=[Math.round(r[0]*100)/100,Math.round(r[1]*100)/100];this.onPick(e)}}collectSelectedPickPoints(e){let t=[];return this.ctx.scene.traverse(n=>{n!==e&&n.userData.isPickRegion&&n.userData.isPickRegionSelected&&n.userData.metaData?.pickPoint&&t.push(n.userData.metaData.pickPoint)}),t}handleMouseMove(e){let t=this.raycastRegions(e.clientX,e.clientY)?.mesh??null;if(t!==this.highlightedMesh)if(this.restoreHighlight(),t){let e=t.material;this.highlightedOriginalColor=e.color.getHex(),this.highlightedOriginalOpacity=e.opacity,e.color.set(Im),e.opacity=Lm,this.highlightedMesh=t;let n=null,r=t;for(;r;){if(r.userData.shapeId){n=r.userData.shapeId;break}r=r.parent}this.onHighlight(n),this.ctx.requestRender()}else this.highlightedMesh=null,this.onHighlight(null),this.ctx.requestRender()}restoreHighlight(){if(this.highlightedMesh){let e=this.highlightedMesh.material;this.highlightedOriginalColor!==null&&e.color.setHex(this.highlightedOriginalColor),this.highlightedOriginalOpacity!==null&&(e.opacity=this.highlightedOriginalOpacity),this.highlightedMesh=null,this.highlightedOriginalColor=null,this.highlightedOriginalOpacity=null}}raycastRegions(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=[];if(this.ctx.scene.traverse(e=>{if(e.userData.isPickRegion&&e.children)for(let t of e.children)t.isMesh&&c.push(t)}),c.length===0)return null;let l=s.intersectObjects(c,!1);return l.length===0?null:{mesh:l[0].object,point:l[0].point}}projectToSketch(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=s.ray.origin,l=s.ray.direction,u=new B(this.plane.origin.x,this.plane.origin.y,this.plane.origin.z),d=new B(this.plane.normal.x,this.plane.normal.y,this.plane.normal.z),f=l.dot(d);if(Math.abs(f)<1e-6)return null;let p=u.clone().sub(c).dot(d)/f;if(p<0)return null;let m=c.clone().add(l.clone().multiplyScalar(p)).clone().sub(u),h=new B(this.plane.xDirection.x,this.plane.xDirection.y,this.plane.xDirection.z),g=new B(this.plane.yDirection.x,this.plane.yDirection.y,this.plane.yDirection.z);return[m.dot(h),m.dot(g)]}},zm=64,Bm={r:.69,g:.69,b:.69},Vm=11579568,Hm=.35,Um=11579568,Wm=15954511,Gm=16737792,Km=2280550,qm=4,Jm=1.5,Ym=.6,Xm=qm+Jm+Ym+Jm,Zm=`
|
|
4809
|
+
`,e.appendChild(this.element),this.element.querySelector(`.fluidcad-breakpoint-continue`).addEventListener(`click`,async()=>{t?.();try{await fetch(`/api/clear-breakpoints`,{method:`POST`})}catch(e){console.error(`Clear breakpoints failed:`,e)}})}setActive(e){this.element.classList.toggle(`hidden`,!e)}},jm=12,Mm=class{canvas;ctx;plane;snapManager;onPick;onHighlight;edges=[];highlightedShapeId=null;downX=0;downY=0;boundMouseDown;boundMouseUp;boundMouseMove;constructor(e,t,n,r,i,a,o){this.canvas=e.renderer.domElement,this.ctx=e,this.plane=t,this.snapManager=n,this.onPick=a,this.onHighlight=o,this.edges=Nm(r,i,t),this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this)}updateEdges(e,t){this.edges=Nm(e,t,this.plane),this.highlightedShapeId&&(this.edges.some(e=>e.shapeId===this.highlightedShapeId)||(this.onHighlight(null),this.highlightedShapeId=null))}activate(){this.canvas.addEventListener(`mousedown`,this.boundMouseDown),this.canvas.addEventListener(`mouseup`,this.boundMouseUp),this.canvas.addEventListener(`mousemove`,this.boundMouseMove)}deactivate(){this.canvas.removeEventListener(`mousedown`,this.boundMouseDown),this.canvas.removeEventListener(`mouseup`,this.boundMouseUp),this.canvas.removeEventListener(`mousemove`,this.boundMouseMove),this.highlightedShapeId&&=(this.onHighlight(null),null)}getEdgeEntry(e){return this.edges.find(t=>t.shapeId===e)}handleMouseDown(e){this.downX=e.clientX,this.downY=e.clientY}handleMouseUp(e){let t=e.clientX-this.downX,n=e.clientY-this.downY;if(t*t+n*n>64||!this.highlightedShapeId)return;let r=this.projectToSketch(e.clientX,e.clientY);if(!r)return;let i=this.projectOntoEdge(r,this.highlightedShapeId)??r,a=[Math.round(i[0]*100)/100,Math.round(i[1]*100)/100];this.onPick(a)}handleMouseMove(e){let t=this.projectToSketch(e.clientX,e.clientY);if(!t){this.highlightedShapeId&&=(this.onHighlight(null),null);return}let n=this.computeSketchThreshold(),r=this.findNearestEdge(t,n);if(r!==this.highlightedShapeId){if(r){let e=this.getEdgeEntry(r);this.onHighlight({shapeId:r,endpoints:e?.endpoints??[]})}else this.onHighlight(null);this.highlightedShapeId=r}}computeSketchThreshold(){let e=this.ctx.camera,t=this.ctx.renderer.domElement.getBoundingClientRect().height||1,n,r=e;if(r.isOrthographicCamera)n=(r.top-r.bottom)/(r.zoom||1);else{let t=new B;this.ctx.cameraControls.getTarget(t);let i=e.position.distanceTo(t),a=r.fov*Math.PI/180;n=2*i*Math.tan(a/2)}return n/t*jm}findNearestEdge(e,t){let n=1/0,r=null;for(let t of this.edges)for(let i of t.segments){let a=Pm(e[0],e[1],i.ax,i.ay,i.bx,i.by);a<n&&(n=a,r=t.shapeId)}return n<=t?r:null}projectOntoEdge(e,t){let n=this.edges.find(e=>e.shapeId===t);if(!n)return null;let r=1/0,i=null;for(let t of n.segments){let n=Fm(e[0],e[1],t.ax,t.ay,t.bx,t.by);n.dist<r&&(r=n.dist,i=[n.x,n.y])}return i}projectToSketch(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=s.ray.origin,l=s.ray.direction,u=new B(this.plane.origin.x,this.plane.origin.y,this.plane.origin.z),d=new B(this.plane.normal.x,this.plane.normal.y,this.plane.normal.z),f=l.dot(d);if(Math.abs(f)<1e-6)return null;let p=u.clone().sub(c).dot(d)/f;if(p<0)return null;let m=c.clone().add(l.clone().multiplyScalar(p)).clone().sub(u),h=new B(this.plane.xDirection.x,this.plane.xDirection.y,this.plane.xDirection.z),g=new B(this.plane.yDirection.x,this.plane.yDirection.y,this.plane.yDirection.z);return[m.dot(h),m.dot(g)]}};function Nm(e,t,n){let r=[],i=n.origin.x,a=n.origin.y,o=n.origin.z,s=n.xDirection.x,c=n.xDirection.y,l=n.xDirection.z,u=n.yDirection.x,d=n.yDirection.y,f=n.yDirection.z,p=e.some(e=>e.parentId===t&&e.sceneShapes.some(e=>e.metaType===`trim`));for(let n of e)if(n.parentId===t)for(let e of n.sceneShapes){if(!e.shapeId)continue;if(p){if(e.metaType!==`trim`)continue}else if(e.isMetaShape||e.isGuide)continue;let t=[],n=[];for(let r of e.meshes){let e=r.vertices,p=r.indices;if(!p.length)continue;let m=new Map;for(let e of p)m.set(e,(m.get(e)||0)+1);for(let[t,r]of m)r===1&&n.push([e[t*3],e[t*3+1],e[t*3+2]]);for(let n=0;n<p.length;n+=2){let r=p[n]*3,m=p[n+1]*3,h=e[r]-i,g=e[r+1]-a,_=e[r+2]-o,v=h*s+g*c+_*l,y=h*u+g*d+_*f,b=e[m]-i,x=e[m+1]-a,S=e[m+2]-o,C=b*s+x*c+S*l,w=b*u+x*d+S*f;t.push({ax:v,ay:y,bx:C,by:w})}}t.length>0&&r.push({shapeId:e.shapeId,segments:t,endpoints:n})}return r}function Pm(e,t,n,r,i,a){return Fm(e,t,n,r,i,a).dist}function Fm(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l,u;if(c===0)l=n,u=r;else{let i=((e-n)*o+(t-r)*s)/c;i<0?i=0:i>1&&(i=1),l=n+i*o,u=r+i*s}let d=l-e,f=u-t;return{x:l,y:u,dist:Math.sqrt(d*d+f*f)}}var Im=`#64B5F6`,Lm=.35,Rm=class{canvas;ctx;plane;onPick;onRemove;onHighlight;highlightedMesh=null;highlightedOriginalColor=null;highlightedOriginalOpacity=null;downX=0;downY=0;boundMouseDown;boundMouseUp;boundMouseMove;constructor(e,t,n,r,i){this.canvas=e.renderer.domElement,this.ctx=e,this.plane=t,this.onPick=n,this.onRemove=r,this.onHighlight=i,this.boundMouseDown=this.handleMouseDown.bind(this),this.boundMouseUp=this.handleMouseUp.bind(this),this.boundMouseMove=this.handleMouseMove.bind(this)}activate(){this.canvas.addEventListener(`mousedown`,this.boundMouseDown),this.canvas.addEventListener(`mouseup`,this.boundMouseUp),this.canvas.addEventListener(`mousemove`,this.boundMouseMove)}deactivate(){this.canvas.removeEventListener(`mousedown`,this.boundMouseDown),this.canvas.removeEventListener(`mouseup`,this.boundMouseUp),this.canvas.removeEventListener(`mousemove`,this.boundMouseMove),this.restoreHighlight()}handleMouseDown(e){this.downX=e.clientX,this.downY=e.clientY}handleMouseUp(e){let t=e.clientX-this.downX,n=e.clientY-this.downY;if(t*t+n*n>64)return;let r=this.projectToSketch(e.clientX,e.clientY);if(!r)return;let i=this.raycastRegions(e.clientX,e.clientY);if(!i)return;let a=i.mesh.parent;if(a?.userData.isPickRegionSelected===!0){let e=this.collectSelectedPickPoints(a);this.onRemove(e)}else{let e=[Math.round(r[0]*100)/100,Math.round(r[1]*100)/100];this.onPick(e)}}collectSelectedPickPoints(e){let t=[];return this.ctx.scene.traverse(n=>{n!==e&&n.userData.isPickRegion&&n.userData.isPickRegionSelected&&n.userData.metaData?.pickPoint&&t.push(n.userData.metaData.pickPoint)}),t}handleMouseMove(e){let t=this.raycastRegions(e.clientX,e.clientY)?.mesh??null;if(t!==this.highlightedMesh)if(this.restoreHighlight(),t){let e=t.material;this.highlightedOriginalColor=e.color.getHex(),this.highlightedOriginalOpacity=e.opacity,e.color.set(Im),e.opacity=Lm,this.highlightedMesh=t;let n=null,r=t;for(;r;){if(r.userData.shapeId){n=r.userData.shapeId;break}r=r.parent}this.onHighlight(n),this.ctx.requestRender()}else this.highlightedMesh=null,this.onHighlight(null),this.ctx.requestRender()}restoreHighlight(){if(this.highlightedMesh){let e=this.highlightedMesh.material;this.highlightedOriginalColor!==null&&e.color.setHex(this.highlightedOriginalColor),this.highlightedOriginalOpacity!==null&&(e.opacity=this.highlightedOriginalOpacity),this.highlightedMesh=null,this.highlightedOriginalColor=null,this.highlightedOriginalOpacity=null}}raycastRegions(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=[];if(this.ctx.scene.traverse(e=>{if(e.userData.isPickRegion&&e.children)for(let t of e.children)t.isMesh&&c.push(t)}),c.length===0)return null;let l=s.intersectObjects(c,!1);return l.length===0?null:{mesh:l[0].object,point:l[0].point}}projectToSketch(e,t){let n=this.ctx.renderer,r=this.ctx.camera,i=n.domElement.getBoundingClientRect(),a=(e-i.left)/i.width*2-1,o=-((t-i.top)/i.height)*2+1,s=new to;s.setFromCamera(new z(a,o),r);let c=s.ray.origin,l=s.ray.direction,u=new B(this.plane.origin.x,this.plane.origin.y,this.plane.origin.z),d=new B(this.plane.normal.x,this.plane.normal.y,this.plane.normal.z),f=l.dot(d);if(Math.abs(f)<1e-6)return null;let p=u.clone().sub(c).dot(d)/f;if(p<0)return null;let m=c.clone().add(l.clone().multiplyScalar(p)).clone().sub(u),h=new B(this.plane.xDirection.x,this.plane.xDirection.y,this.plane.xDirection.z),g=new B(this.plane.yDirection.x,this.plane.yDirection.y,this.plane.yDirection.z);return[m.dot(h),m.dot(g)]}},zm=64,Bm={r:.69,g:.69,b:.69},Vm=11579568,Hm=.35,Um=11579568,Wm=15954511,Gm=16737792,Km=2280550,qm=4,Jm=1.5,Ym=.6,Xm=qm+Jm+Ym+Jm,Zm=`
|
|
4810
4810
|
attribute float lineDistance;
|
|
4811
4811
|
varying float vLineDistance;
|
|
4812
4812
|
void main() {
|
|
@@ -4838,7 +4838,7 @@ void main() {
|
|
|
4838
4838
|
<span class="loading loading-spinner loading-sm"></span>
|
|
4839
4839
|
<span class="loading-text">Loading FluidCAD...</span>
|
|
4840
4840
|
</div>
|
|
4841
|
-
`,yh.appendChild(xh);var Sh=xh.querySelector(`.loading-text`);function Ch(e){Sh.textContent=e,xh.classList.remove(`hidden`)}function wh(){xh.classList.add(`hidden`)}var $=new im(`fluidcad-viewer`);Pd(()=>$.rebuildSceneMesh());var Th=new dm(yh),Eh=new mm(yh),Dh=new km(yh,$.sceneContext),Oh=new Am(yh),kh=new Cm(yh,e=>$.highlightShape(e),e=>Dh.show(e),(e,t)=>$.setShapeVisibility(e,t),e=>$.isShapeHidden(e),(e,t)=>$.setShapeTransparency(e,t),e=>$.getShapeTransparency(e));Th.setOpenHandler(()=>{$.clearHighlight(),Eh.hide()}),Th.setCentroidHandler(e=>{e?$.showCentroid(e):$.clearCentroid()}),$.setSelectionHandler((e,t)=>{e?Th.isOpen?$.highlightShape(e):t?.type===`face`?$.highlightFace(e,t.index):t?.type===`edge`?$.highlightEdge(e,t.index):$.clearHighlight():$.clearHighlight(),Th.setSelectedShape(e),e!==null&&t!==null?t.type===`face`?Eh.showForFace(e,t.index):Eh.showForEdge(e,t.index):Eh.hide()});var Ah=document.createElement(`div`);Ah.id=`fluidcad-trim-indicator`,Ah.className=`absolute top-4 left-1/2 -translate-x-1/2 z-[999] pointer-events-none hidden`,Ah.innerHTML=`
|
|
4841
|
+
`,yh.appendChild(xh);var Sh=xh.querySelector(`.loading-text`);function Ch(e){Sh.textContent=e,xh.classList.remove(`hidden`)}function wh(){xh.classList.add(`hidden`)}var $=new im(`fluidcad-viewer`);Pd(()=>$.rebuildSceneMesh());var Th=new dm(yh),Eh=new mm(yh),Dh=new km(yh,$.sceneContext),Oh=new Am(yh,()=>{Uh===`picking-active`&&Zh()}),kh=new Cm(yh,e=>$.highlightShape(e),e=>Dh.show(e),(e,t)=>$.setShapeVisibility(e,t),e=>$.isShapeHidden(e),(e,t)=>$.setShapeTransparency(e,t),e=>$.getShapeTransparency(e));Th.setOpenHandler(()=>{$.clearHighlight(),Eh.hide()}),Th.setCentroidHandler(e=>{e?$.showCentroid(e):$.clearCentroid()}),$.setSelectionHandler((e,t)=>{e?Th.isOpen?$.highlightShape(e):t?.type===`face`?$.highlightFace(e,t.index):t?.type===`edge`?$.highlightEdge(e,t.index):$.clearHighlight():$.clearHighlight(),Th.setSelectedShape(e),e!==null&&t!==null?t.type===`face`?Eh.showForFace(e,t.index):Eh.showForEdge(e,t.index):Eh.hide()});var Ah=document.createElement(`div`);Ah.id=`fluidcad-trim-indicator`,Ah.className=`absolute top-4 left-1/2 -translate-x-1/2 z-[999] pointer-events-none hidden`,Ah.innerHTML=`
|
|
4842
4842
|
<div class="flex items-center gap-3 panel-bg border border-base-content/10 rounded-lg px-6 py-3 text-base-content/70 text-sm leading-none select-none">
|
|
4843
4843
|
<span class="[&>svg]:size-5">${Pp}</span>
|
|
4844
4844
|
<span>Trimming Mode</span>
|
|
@@ -4878,4 +4878,4 @@ void main() {
|
|
|
4878
4878
|
<span class="[&>svg]:size-3.5">${Ip}</span>
|
|
4879
4879
|
</button>
|
|
4880
4880
|
</div>
|
|
4881
|
-
`,lg.querySelector(`.import-toast-copy`).addEventListener(`click`,()=>{navigator.clipboard.writeText(t);let e=lg.querySelector(`.import-toast-copy`);e.setAttribute(`title`,`Copied!`),setTimeout(()=>e.setAttribute(`title`,`Copy`),1500)})):lg.textContent=e,lg.classList.remove(`hidden`),ug&&clearTimeout(ug),ug=setTimeout(()=>{lg.classList.add(`hidden`),ug=null},6e3)}var fg=document.createElement(`input`);fg.type=`file`,fg.accept=`.step,.stp`,fg.style.display=`none`,yh.appendChild(fg),cg.querySelector(`button`).addEventListener(`click`,()=>{fg.click()}),fg.addEventListener(`change`,async()=>{let e=fg.files?.[0];if(e){fg.value=``,Ch(`Importing file...`);try{let t=await e.arrayBuffer(),n=new Uint8Array(t),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);let i=btoa(r),a=await fetch(`/api/import-file`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:e.name,data:i})}),o=await a.json();!a.ok||!o.success?dg(`Import failed: ${o.error||`Unknown error`}`):dg(`Imported! Use:`,`load('${o.fileName}')`)}catch{dg(`Import failed: network error`)}finally{wh()}}});async function pg(e,t,n){try{let r=await(await Tm($.sceneContext,n)).arrayBuffer(),i=new Uint8Array(r),a=``;for(let e=0;e<i.length;e++)a+=String.fromCharCode(i[e]);e.send(JSON.stringify({type:`screenshot-result`,requestId:t,success:!0,data:btoa(a)}))}catch(n){e.send(JSON.stringify({type:`screenshot-result`,requestId:t,success:!1,error:n.message||String(n)}))}}function mg(){let e=`ws://${window.location.host}`,t=new WebSocket(e);t.addEventListener(`message`,e=>{let n=JSON.parse(e.data);switch(n.type){case`init-complete`:Ch(`Loading model...`);break;case`processing-file`:Ch(`Loading model...`);break;case`scene-rendered`:{wh();let e=n.rollbackStop!=null&&n.rollbackStop<n.result.length-1;$.isTrimming
|
|
4881
|
+
`,lg.querySelector(`.import-toast-copy`).addEventListener(`click`,()=>{navigator.clipboard.writeText(t);let e=lg.querySelector(`.import-toast-copy`);e.setAttribute(`title`,`Copied!`),setTimeout(()=>e.setAttribute(`title`,`Copy`),1500)})):lg.textContent=e,lg.classList.remove(`hidden`),ug&&clearTimeout(ug),ug=setTimeout(()=>{lg.classList.add(`hidden`),ug=null},6e3)}var fg=document.createElement(`input`);fg.type=`file`,fg.accept=`.step,.stp`,fg.style.display=`none`,yh.appendChild(fg),cg.querySelector(`button`).addEventListener(`click`,()=>{fg.click()}),fg.addEventListener(`change`,async()=>{let e=fg.files?.[0];if(e){fg.value=``,Ch(`Importing file...`);try{let t=await e.arrayBuffer(),n=new Uint8Array(t),r=``;for(let e=0;e<n.length;e++)r+=String.fromCharCode(n[e]);let i=btoa(r),a=await fetch(`/api/import-file`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({fileName:e.name,data:i})}),o=await a.json();!a.ok||!o.success?dg(`Import failed: ${o.error||`Unknown error`}`):dg(`Imported! Use:`,`load('${o.fileName}')`)}catch{dg(`Import failed: network error`)}finally{wh()}}});async function pg(e,t,n){try{let r=await(await Tm($.sceneContext,n)).arrayBuffer(),i=new Uint8Array(r),a=``;for(let e=0;e<i.length;e++)a+=String.fromCharCode(i[e]);e.send(JSON.stringify({type:`screenshot-result`,requestId:t,success:!0,data:btoa(a)}))}catch(n){e.send(JSON.stringify({type:`screenshot-result`,requestId:t,success:!1,error:n.message||String(n)}))}}function mg(){let e=`ws://${window.location.host}`,t=new WebSocket(e);t.addEventListener(`message`,e=>{let n=JSON.parse(e.data);switch(n.type){case`init-complete`:Ch(`Loading model...`);break;case`processing-file`:Ch(`Loading model...`);break;case`scene-rendered`:{wh();let e=n.rollbackStop!=null&&n.rollbackStop<n.result.length-1;$.isTrimming=!e&&Nh(n.result),$.isBezierDrawing=!e&&ig(n.result),$.updateView(n.result,e),n.absPath&&$.setFileName(n.absPath),e?(Fh(),$h(),sg()):(Ph(n.result),eg(n.result),og(n.result)),kh.update(n.result,n.rollbackStop??n.result.length-1,n.absPath),n.breakpointHit!==void 0&&Oh.setActive(n.breakpointHit);break}case`highlight-shape`:$.highlightShape(n.shapeId),Th.setSelectedShape(n.shapeId);break;case`clear-highlight`:$.clearHighlight(),Th.setSelectedShape(null),Eh.hide();break;case`show-shape-properties`:$.clearHighlight(),Eh.hide(),Th.show(n.shapeId);break;case`take-screenshot`:pg(t,n.requestId,n.options);break}}),t.addEventListener(`close`,()=>{setTimeout(mg,1e3)})}mg();
|