Files
AR-Menu/Needle/SampleScene/dist/assets/three-examples.extras@0.169.19.js
pelpanagiotis 6947303755 Commit Needle production dist and nginx-only Docker image
- Track Needle/MenuScene/dist and Needle/SampleScene/dist for container deploys
- Dockerfile copies pre-built dist (no npm in image); rebuild with npm run build before commit
- Fix Needle .gitignore: /assets/ so dist/assets is not ignored
- Git LFS: track *.wasm; relax .dockerignore so dist is sent as build context

Made-with: Cursor
2026-04-19 23:39:59 +03:00

388 lines
102 KiB
JavaScript

import{A as e,Ar as t,B as n,Cn as r,Cr as i,E as a,En as o,F as s,Gn as c,I as l,Ir as u,It as d,Jn as f,Jt as p,Kn as m,Kt as h,Lr as g,Mt as _,Nt as v,O as y,Qn as ee,Qt as te,Rt as ne,S as re,Sr as ie,St as b,Tt as ae,Xt as x,Zn as oe,Zt as S,_ as se,_n as ce,an as le,at as C,cn as w,cr as ue,dr as de,dt as fe,er as pe,fn as me,gn as he,hr as T,jr as ge,jt as E,kr as D,ln as _e,lr as ve,mn as ye,on as be,pn as xe,tr as Se,tt as Ce,ur as we,vn as Te,vr as Ee,vt as De,wn as O,x as k,xr as Oe,y as A,yt as ke,zt as Ae}from"./three@0.169.19.js";import{S as je,a as Me,i as Ne,o as Pe}from"./three-examples@0.169.19.js";var Fe=class extends S{constructor(e,n,r,i=128){if(n<=0||r<=0||i<=0)throw Error(`GroundedSkybox height, radius, and resolution must be positive.`);let a=new we(r,2*i,i);a.scale(1,1,-1);let o=a.getAttribute(`position`),s=new t;for(let e=0;e<o.count;++e)if(s.fromBufferAttribute(o,e),s.y<0){let t=-n*3/2,r=s.y<t?-n/s.y:1-s.y*s.y/(3*t*t);s.multiplyScalar(r),s.toArray(o.array,3*e)}o.needsUpdate=!0,super(a,new te({map:e,depthWrite:!1}))}},j=new m,M=new t,N=new t,P=new O,Ie={X:new t(1,0,0),Y:new t(0,1,0),Z:new t(0,0,1)},Le={type:`change`},Re={type:`mouseDown`,mode:null},ze={type:`mouseUp`,mode:null},Be={type:`objectChange`},Ve=class extends l{constructor(e,n=null){super(void 0,n);let r=new rt(this);this._root=r;let i=new it;this._gizmo=i,r.add(i);let a=new at;this._plane=a,r.add(a);let o=this;function s(e,t){let n=t;Object.defineProperty(o,e,{get:function(){return n===void 0?t:n},set:function(t){n!==t&&(n=t,a[e]=t,i[e]=t,o.dispatchEvent({type:e+`-changed`,value:t}),o.dispatchEvent(Le))}}),o[e]=t,a[e]=t,i[e]=t}s(`camera`,e),s(`object`,void 0),s(`enabled`,!0),s(`axis`,null),s(`mode`,`translate`),s(`translationSnap`,null),s(`rotationSnap`,null),s(`scaleSnap`,null),s(`space`,`world`),s(`size`,1),s(`dragging`,!1),s(`showX`,!0),s(`showY`,!0),s(`showZ`,!0);let c=new t,l=new t,u=new O,d=new O,f=new t,p=new O,m=new t,h=new t,g=new t,_=new t;s(`worldPosition`,c),s(`worldPositionStart`,l),s(`worldQuaternion`,u),s(`worldQuaternionStart`,d),s(`cameraPosition`,f),s(`cameraQuaternion`,p),s(`pointStart`,m),s(`pointEnd`,h),s(`rotationAxis`,g),s(`rotationAngle`,0),s(`eye`,_),this._offset=new t,this._startNorm=new t,this._endNorm=new t,this._cameraScale=new t,this._parentPosition=new t,this._parentQuaternion=new O,this._parentQuaternionInv=new O,this._parentScale=new t,this._worldScaleStart=new t,this._worldQuaternionInv=new O,this._worldScale=new t,this._positionStart=new t,this._quaternionStart=new O,this._scaleStart=new t,this._getPointer=He.bind(this),this._onPointerDown=We.bind(this),this._onPointerHover=Ue.bind(this),this._onPointerMove=Ge.bind(this),this._onPointerUp=Ke.bind(this),n!==null&&this.connect()}connect(){this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointermove`,this._onPointerHover),this.domElement.addEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerHover),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.style.touchAction=`auto`}getHelper(){return this._root}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&j.setFromCamera(e,this.camera);let t=qe(this._gizmo.picker[this.mode],j);t?this.axis=t.object.name:this.axis=null}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null){e!==null&&j.setFromCamera(e,this.camera);let t=qe(this._plane,j,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Re.mode=this.mode,this.dispatchEvent(Re)}}pointerMove(e){let t=this.axis,n=this.mode,r=this.object,i=this.space;if(n===`scale`?i=`local`:(t===`E`||t===`XYZE`||t===`XYZ`)&&(i=`world`),r===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1)return;e!==null&&j.setFromCamera(e,this.camera);let a=qe(this._plane,j,!0);if(a){if(this.pointEnd.copy(a.point).sub(this.worldPositionStart),n===`translate`)this._offset.copy(this.pointEnd).sub(this.pointStart),i===`local`&&t!==`XYZ`&&this._offset.applyQuaternion(this._worldQuaternionInv),t.indexOf(`X`)===-1&&(this._offset.x=0),t.indexOf(`Y`)===-1&&(this._offset.y=0),t.indexOf(`Z`)===-1&&(this._offset.z=0),i===`local`&&t!==`XYZ`?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),r.position.copy(this._offset).add(this._positionStart),this.translationSnap&&(i===`local`&&(r.position.applyQuaternion(P.copy(this._quaternionStart).invert()),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.position.applyQuaternion(this._quaternionStart)),i===`world`&&(r.parent&&r.position.add(M.setFromMatrixPosition(r.parent.matrixWorld)),t.search(`X`)!==-1&&(r.position.x=Math.round(r.position.x/this.translationSnap)*this.translationSnap),t.search(`Y`)!==-1&&(r.position.y=Math.round(r.position.y/this.translationSnap)*this.translationSnap),t.search(`Z`)!==-1&&(r.position.z=Math.round(r.position.z/this.translationSnap)*this.translationSnap),r.parent&&r.position.sub(M.setFromMatrixPosition(r.parent.matrixWorld))));else if(n===`scale`){if(t.search(`XYZ`)!==-1){let e=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(e*=-1),N.set(e,e,e)}else M.copy(this.pointStart),N.copy(this.pointEnd),M.applyQuaternion(this._worldQuaternionInv),N.applyQuaternion(this._worldQuaternionInv),N.divide(M),t.search(`X`)===-1&&(N.x=1),t.search(`Y`)===-1&&(N.y=1),t.search(`Z`)===-1&&(N.z=1);r.scale.copy(this._scaleStart).multiply(N),this.scaleSnap&&(t.search(`X`)!==-1&&(r.scale.x=Math.round(r.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Y`)!==-1&&(r.scale.y=Math.round(r.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),t.search(`Z`)!==-1&&(r.scale.z=Math.round(r.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if(n===`rotate`){this._offset.copy(this.pointEnd).sub(this.pointStart);let e=20/this.worldPosition.distanceTo(M.setFromMatrixPosition(this.camera.matrixWorld)),n=!1;t===`XYZE`?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(M.copy(this.rotationAxis).cross(this.eye))*e):(t===`X`||t===`Y`||t===`Z`)&&(this.rotationAxis.copy(Ie[t]),M.copy(Ie[t]),i===`local`&&M.applyQuaternion(this.worldQuaternion),M.cross(this.eye),M.length()===0?n=!0:this.rotationAngle=this._offset.dot(M.normalize())*e),(t===`E`||n)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),i===`local`&&t!==`E`&&t!==`XYZE`?(r.quaternion.copy(this._quaternionStart),r.quaternion.multiply(P.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),r.quaternion.copy(P.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),r.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Le),this.dispatchEvent(Be)}}pointerUp(e){e!==null&&e.button!==0||(this.dragging&&this.axis!==null&&(ze.mode=this.mode,this.dispatchEvent(ze)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Le),this.dispatchEvent(Be),this.pointStart.copy(this.pointEnd))}getRaycaster(){return j}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}};function He(e){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:e.button};{let t=this.domElement.getBoundingClientRect();return{x:(e.clientX-t.left)/t.width*2-1,y:-(e.clientY-t.top)/t.height*2+1,button:e.button}}}function Ue(e){if(this.enabled)switch(e.pointerType){case`mouse`:case`pen`:this.pointerHover(this._getPointer(e));break}}function We(e){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),this.pointerHover(this._getPointer(e)),this.pointerDown(this._getPointer(e)))}function Ge(e){this.enabled&&this.pointerMove(this._getPointer(e))}function Ke(e){this.enabled&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.pointerUp(this._getPointer(e)))}function qe(e,t,n){let r=t.intersectObject(e,!0);for(let e=0;e<r.length;e++)if(r[e].object.visible||n)return r[e];return!1}var Je=new Ce,F=new t(0,1,0),Ye=new t(0,0,0),Xe=new x,Ze=new O,Qe=new O,I=new t,$e=new x,L=new t(1,0,0),R=new t(0,1,0),z=new t(0,0,1),et=new t,tt=new t,nt=new t,rt=class extends me{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){let t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error(`TransformControls: The attached 3D object must be a part of the scene graph.`):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}},it=class extends me{constructor(){super(),this.isTransformControlsGizmo=!0,this.type=`TransformControlsGizmo`;let e=new te({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new v({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),r=e.clone();r.opacity=.15;let i=t.clone();i.opacity=.5;let a=e.clone();a.color.setHex(16711680);let o=e.clone();o.color.setHex(65280);let s=e.clone();s.color.setHex(255);let c=e.clone();c.color.setHex(16711680),c.opacity=.5;let l=e.clone();l.color.setHex(65280),l.opacity=.5;let u=e.clone();u.color.setHex(255),u.opacity=.5;let d=e.clone();d.opacity=.25;let f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);let p=e.clone();p.color.setHex(7895160);let m=new n(0,.04,.1,12);m.translate(0,.05,0);let h=new A(.08,.08,.08);h.translate(0,.04,0);let g=new re;g.setAttribute(`position`,new C([0,0,0,1,0,0],3));let _=new n(.0075,.0075,.5,3);_.translate(0,.25,0);function y(e,t){let n=new Ee(e,.0075,3,64,t*Math.PI*2);return n.rotateY(Math.PI/2),n.rotateX(Math.PI/2),n}function ee(){let e=new re;return e.setAttribute(`position`,new C([0,0,0,1,1,1],3)),e}let ne={X:[[new S(m,a),[.5,0,0],[0,0,-Math.PI/2]],[new S(m,a),[-.5,0,0],[0,0,Math.PI/2]],[new S(_,a),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new S(m,o),[0,.5,0]],[new S(m,o),[0,-.5,0],[Math.PI,0,0]],[new S(_,o)]],Z:[[new S(m,s),[0,0,.5],[Math.PI/2,0,0]],[new S(m,s),[0,0,-.5],[-Math.PI/2,0,0]],[new S(_,s),null,[Math.PI/2,0,0]]],XYZ:[[new S(new xe(.1,0),d.clone()),[0,0,0]]],XY:[[new S(new A(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new S(new A(.15,.15,.01),c.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new S(new A(.15,.15,.01),l.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},ie={X:[[new S(new n(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new S(new n(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new S(new n(.2,0,.6,4),r),[0,.3,0]],[new S(new n(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new S(new n(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new S(new n(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new S(new xe(.2,0),r)]],XY:[[new S(new A(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new S(new A(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new S(new A(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]]},b={START:[[new S(new xe(.01,2),i),null,null,null,`helper`]],END:[[new S(new xe(.01,2),i),null,null,null,`helper`]],DELTA:[[new E(ee(),i),null,null,null,`helper`]],X:[[new E(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new E(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new E(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]},ae={XYZE:[[new S(y(.5,1),p),null,[0,Math.PI/2,0]]],X:[[new S(y(.5,.5),a)]],Y:[[new S(y(.5,.5),o),null,[0,0,-Math.PI/2]]],Z:[[new S(y(.5,.5),s),null,[0,Math.PI/2,0]]],E:[[new S(y(.75,1),f),null,[0,Math.PI/2,0]]]},x={AXIS:[[new E(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]]},oe={XYZE:[[new S(new we(.25,10,8),r)]],X:[[new S(new Ee(.5,.1,4,24),r),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new S(new Ee(.5,.1,4,24),r),[0,0,0],[Math.PI/2,0,0]]],Z:[[new S(new Ee(.5,.1,4,24),r),[0,0,0],[0,0,-Math.PI/2]]],E:[[new S(new Ee(.75,.1,2,24),r)]]},se={X:[[new S(h,a),[.5,0,0],[0,0,-Math.PI/2]],[new S(_,a),[0,0,0],[0,0,-Math.PI/2]],[new S(h,a),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new S(h,o),[0,.5,0]],[new S(_,o)],[new S(h,o),[0,-.5,0],[0,0,Math.PI]]],Z:[[new S(h,s),[0,0,.5],[Math.PI/2,0,0]],[new S(_,s),[0,0,0],[Math.PI/2,0,0]],[new S(h,s),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new S(new A(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new S(new A(.15,.15,.01),c),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new S(new A(.15,.15,.01),l),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new S(new A(.1,.1,.1),d.clone())]]},ce={X:[[new S(new n(.2,0,.6,4),r),[.3,0,0],[0,0,-Math.PI/2]],[new S(new n(.2,0,.6,4),r),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new S(new n(.2,0,.6,4),r),[0,.3,0]],[new S(new n(.2,0,.6,4),r),[0,-.3,0],[0,0,Math.PI]]],Z:[[new S(new n(.2,0,.6,4),r),[0,0,.3],[Math.PI/2,0,0]],[new S(new n(.2,0,.6,4),r),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new S(new A(.2,.2,.01),r),[.15,.15,0]]],YZ:[[new S(new A(.2,.2,.01),r),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new S(new A(.2,.2,.01),r),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new S(new A(.2,.2,.2),r),[0,0,0]]]},le={X:[[new E(g,i.clone()),[-1e3,0,0],null,[1e6,1,1],`helper`]],Y:[[new E(g,i.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],`helper`]],Z:[[new E(g,i.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],`helper`]]};function w(e){let t=new me;for(let n in e)for(let r=e[n].length;r--;){let i=e[n][r][0].clone(),a=e[n][r][1],o=e[n][r][2],s=e[n][r][3],c=e[n][r][4];i.name=n,i.tag=c,a&&i.position.set(a[0],a[1],a[2]),o&&i.rotation.set(o[0],o[1],o[2]),s&&i.scale.set(s[0],s[1],s[2]),i.updateMatrix();let l=i.geometry.clone();l.applyMatrix4(i.matrix),i.geometry=l,i.renderOrder=1/0,i.position.set(0,0,0),i.rotation.set(0,0,0),i.scale.set(1,1,1),t.add(i)}return t}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=w(ne)),this.add(this.gizmo.rotate=w(ae)),this.add(this.gizmo.scale=w(se)),this.add(this.picker.translate=w(ie)),this.add(this.picker.rotate=w(oe)),this.add(this.picker.scale=w(ce)),this.add(this.helper.translate=w(b)),this.add(this.helper.rotate=w(x)),this.add(this.helper.scale=w(le)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){let t=(this.mode===`scale`?`local`:this.space)===`local`?this.worldQuaternion:Qe;this.gizmo.translate.visible=this.mode===`translate`,this.gizmo.rotate.visible=this.mode===`rotate`,this.gizmo.scale.visible=this.mode===`scale`,this.helper.translate.visible=this.mode===`translate`,this.helper.rotate.visible=this.mode===`rotate`,this.helper.scale.visible=this.mode===`scale`;let n=[];n=n.concat(this.picker[this.mode].children),n=n.concat(this.gizmo[this.mode].children),n=n.concat(this.helper[this.mode].children);for(let e=0;e<n.length;e++){let r=n[e];r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition);let i;if(i=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(i*this.size/4),r.tag===`helper`){r.visible=!1,r.name===`AXIS`?(r.visible=!!this.axis,this.axis===`X`&&(P.setFromEuler(Je.set(0,0,0)),r.quaternion.copy(t).multiply(P),Math.abs(F.copy(L).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Y`&&(P.setFromEuler(Je.set(0,0,Math.PI/2)),r.quaternion.copy(t).multiply(P),Math.abs(F.copy(R).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`Z`&&(P.setFromEuler(Je.set(0,Math.PI/2,0)),r.quaternion.copy(t).multiply(P),Math.abs(F.copy(z).applyQuaternion(t).dot(this.eye))>.9&&(r.visible=!1)),this.axis===`XYZE`&&(P.setFromEuler(Je.set(0,Math.PI/2,0)),F.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(Xe.lookAt(Ye,F,R)),r.quaternion.multiply(P),r.visible=this.dragging),this.axis===`E`&&(r.visible=!1)):r.name===`START`?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):r.name===`END`?(r.position.copy(this.worldPosition),r.visible=this.dragging):r.name===`DELTA`?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),M.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),M.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(M),r.visible=this.dragging):(r.quaternion.copy(t),this.dragging?r.position.copy(this.worldPositionStart):r.position.copy(this.worldPosition),this.axis&&(r.visible=this.axis.search(r.name)!==-1));continue}if(r.quaternion.copy(t),this.mode===`translate`||this.mode===`scale`){let e=.99,n=.2;r.name===`X`&&Math.abs(F.copy(L).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Y`&&Math.abs(F.copy(R).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`Z`&&Math.abs(F.copy(z).applyQuaternion(t).dot(this.eye))>e&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XY`&&Math.abs(F.copy(z).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`YZ`&&Math.abs(F.copy(L).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),r.name===`XZ`&&Math.abs(F.copy(R).applyQuaternion(t).dot(this.eye))<n&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)}else this.mode===`rotate`&&(Ze.copy(t),F.copy(this.eye).applyQuaternion(P.copy(t).invert()),r.name.search(`E`)!==-1&&r.quaternion.setFromRotationMatrix(Xe.lookAt(this.eye,Ye,R)),r.name===`X`&&(P.setFromAxisAngle(L,Math.atan2(-F.y,F.z)),P.multiplyQuaternions(Ze,P),r.quaternion.copy(P)),r.name===`Y`&&(P.setFromAxisAngle(R,Math.atan2(F.x,F.z)),P.multiplyQuaternions(Ze,P),r.quaternion.copy(P)),r.name===`Z`&&(P.setFromAxisAngle(z,Math.atan2(F.y,F.x)),P.multiplyQuaternions(Ze,P),r.quaternion.copy(P)));r.visible=r.visible&&(r.name.indexOf(`X`)===-1||this.showX),r.visible=r.visible&&(r.name.indexOf(`Y`)===-1||this.showY),r.visible=r.visible&&(r.name.indexOf(`Z`)===-1||this.showZ),r.visible=r.visible&&(r.name.indexOf(`E`)===-1||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split(``).some(function(e){return r.name===e}))&&(r.material.color.setHex(16776960),r.material.opacity=1)}super.updateMatrixWorld(e)}},at=class extends S{constructor(){super(new Te(1e5,1e5,2,2),new te({visible:!1,wireframe:!0,side:2,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type=`TransformControlsPlane`}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),this.mode===`scale`&&(t=`local`),et.copy(L).applyQuaternion(t===`local`?this.worldQuaternion:Qe),tt.copy(R).applyQuaternion(t===`local`?this.worldQuaternion:Qe),nt.copy(z).applyQuaternion(t===`local`?this.worldQuaternion:Qe),F.copy(tt),this.mode){case`translate`:case`scale`:switch(this.axis){case`X`:F.copy(this.eye).cross(et),I.copy(et).cross(F);break;case`Y`:F.copy(this.eye).cross(tt),I.copy(tt).cross(F);break;case`Z`:F.copy(this.eye).cross(nt),I.copy(nt).cross(F);break;case`XY`:I.copy(nt);break;case`YZ`:I.copy(et);break;case`XZ`:F.copy(nt),I.copy(tt);break;case`XYZ`:case`E`:I.set(0,0,0);break}break;default:I.set(0,0,0)}I.length()===0?this.quaternion.copy(this.cameraQuaternion):($e.lookAt(M.set(0,0,0),I,F),this.quaternion.setFromRotationMatrix($e)),super.updateMatrixWorld(e)}},ot={type:`change`},st={type:`start`},ct={type:`end`},lt={type:`endMovement`},ut=new c,dt=new ce,ft=Math.cos(70*p.DEG2RAD),B=new t;new t;var V=2*Math.PI,H={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},U=1e-6,pt=class extends l{constructor(e,n=null){super(e,n),this.state=H.NONE,this.enabled=!0,this.target=new t,this.cursor=new t,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:`ArrowLeft`,UP:`ArrowUp`,RIGHT:`ArrowRight`,BOTTOM:`ArrowDown`},this.mouseButtons={LEFT:h.ROTATE,MIDDLE:h.DOLLY,RIGHT:h.PAN},this.touches={ONE:T.ROTATE,TWO:T.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new t,this._lastQuaternion=new O,this._lastTargetPosition=new t,this._quat=new O().setFromUnitVectors(e.up,new t(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new de,this._sphericalDelta=new de,this._scale=1,this._currentScale=1,this._panOffset=new t,this._rotateStart=new D,this._rotateEnd=new D,this._rotateDelta=new D,this._panStart=new D,this._panEnd=new D,this._panDelta=new D,this._dollyStart=new D,this._dollyEnd=new D,this._dollyDelta=new D,this._dollyDirection=new t,this._mouse=new D,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._lastIsDamping=!1,this._isDamping=!1,this._onPointerMove=ht.bind(this),this._onPointerDown=mt.bind(this),this._onPointerUp=gt.bind(this),this._onContextMenu=Ct.bind(this),this._onMouseWheel=yt.bind(this),this._onKeyDown=bt.bind(this),this._onTouchStart=xt.bind(this),this._onTouchMove=St.bind(this),this._onMouseDown=_t.bind(this),this._onMouseMove=vt.bind(this),this._interceptControlDown=wt.bind(this),this._interceptControlUp=Tt.bind(this),this.domElement!==null&&this.connect(),this.update()}connect(){this.domElement.addEventListener(`pointerdown`,this._onPointerDown),this.domElement.addEventListener(`pointercancel`,this._onPointerUp),this.domElement.addEventListener(`contextmenu`,this._onContextMenu),this.domElement.addEventListener(`wheel`,this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener(`keydown`,this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction=`none`}disconnect(){this.domElement.removeEventListener(`pointerdown`,this._onPointerDown),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),this.domElement.removeEventListener(`pointerup`,this._onPointerUp),this.domElement.removeEventListener(`pointercancel`,this._onPointerUp),this.domElement.removeEventListener(`wheel`,this._onMouseWheel),this.domElement.removeEventListener(`contextmenu`,this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener(`keydown`,this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction=`auto`}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener(`keydown`,this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ot),this.update(),this.state=H.NONE,this._isDamping=!1}update(e=null){if(this.enableDamping&&e===null)return;let n=this.object.getWorldPosition(this.object.position);B.copy(n).sub(this.target),B.applyQuaternion(this._quat),this._spherical.setFromVector3(B),this.autoRotate&&this.state===H.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let r=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(r)&&isFinite(i)&&(r<-Math.PI?r+=V:r>Math.PI&&(r-=V),i<-Math.PI?i+=V:i>Math.PI&&(i-=V),r<=i?this._spherical.theta=Math.max(r,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(r+i)/2?Math.max(r,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let a=!1;if(this.enableDamping?this._currentScale=p.lerp(this._currentScale,this._scale,this.dampingFactor):this._currentScale=this._scale,this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{let e=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._currentScale),a=Math.abs(e-this._spherical.radius)>U*100}if(B.setFromSpherical(this._spherical),B.applyQuaternion(this._quatInverse),n.copy(this.target).add(B),this.object.parent?this.object.parent.worldToLocal(n):this.object.position.copy(n),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let e=null;if(this.object.isPerspectiveCamera){let t=B.length();e=this._clampDistance(t*this._currentScale);let n=t-e;this.object.position.addScaledVector(this._dollyDirection,n),this.object.updateMatrixWorld(),a=Math.abs(n)>U}else if(this.object.isOrthographicCamera){let n=new t(this._mouse.x,this._mouse.y,0);n.unproject(this.object);let r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._currentScale)),this.object.updateProjectionMatrix(),a=Math.abs(r-this.object.zoom)>U;let i=new t(this._mouse.x,this._mouse.y,0);i.unproject(this.object),this.object.position.sub(i).add(n),this.object.updateMatrixWorld(),e=B.length()}else console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled.`),this.zoomToCursor=!1;e!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(e).add(this.object.position):(ut.origin.copy(this.object.position),ut.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ut.direction))<ft?this.object.lookAt(this.target):(dt.setFromNormalAndCoplanarPoint(this.object.up,this.target),ut.intersectPlane(dt,this.target))))}else if(this.object.isOrthographicCamera){let e=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),Math.abs(e-this.object.zoom)>U&&(this.object.updateProjectionMatrix(),a=!0)}return this._scale=1,a||this._lastPosition.distanceToSquared(this.object.position)>U||8*(1-this._lastQuaternion.dot(this.object.quaternion))>U||this._lastTargetPosition.distanceToSquared(this.target)>U?(this.dispatchEvent(ot),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),this._lastIsDamping=!0,this._isDamping=!0,!0):(this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),this.state===H.NONE&&(this._lastIsDamping=this._isDamping,this._isDamping=!1),this._lastIsDamping&&!this._isDamping&&this.state===H.NONE&&(this._isDamping=!1,this._lastIsDamping=!1,this.dispatchEvent(lt)),this._performCursorZoom=!1,!1)}_getAutoRotationAngle(e){return e===null?V/60/60*this.autoRotateSpeed:V/60*this.autoRotateSpeed*e}_getZoomScale(e){let t=Math.abs(e*.01);return .95**(this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){B.setFromMatrixColumn(t,0),B.multiplyScalar(-e),this._panOffset.add(B)}_panUp(e,t){this.screenSpacePanning===!0?B.setFromMatrixColumn(t,1):(B.setFromMatrixColumn(t,0),B.crossVectors(this.object.up,B)),B.multiplyScalar(e),this._panOffset.add(B)}_pan(e,t){let n=this.domElement;if(this.object.isPerspectiveCamera){this.object.getWorldPosition(B).sub(this.target);let r=B.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/n.clientHeight,this.object.matrixWorld),this._panUp(2*t*r/n.clientHeight,this.object.matrixWorld)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrixWorld),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrixWorld)):(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.`),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn(`WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled.`),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;let n=this.domElement.getBoundingClientRect(),r=e-n.left,i=t-n.top,a=n.width,o=n.height;this._mouse.x=r/a*2-1,this._mouse.y=-(i/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(V*this._rotateDelta.x/t.clientHeight),this._rotateUp(V*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(V*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateUp(-V*this.rotateSpeed/this.domElement.clientHeight):this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(V*this.rotateSpeed/this.domElement.clientHeight):this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this._rotateLeft(-V*this.rotateSpeed/this.domElement.clientHeight):this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateStart.set(n,r)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panStart.set(n,r)}}_handleTouchStartDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._rotateEnd.set(n,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);let t=this.domElement;this._rotateLeft(V*this._rotateDelta.x/t.clientHeight),this._rotateUp(V*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{let t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),r=.5*(e.pageY+t.y);this._panEnd.set(n,r)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){let t=this._getSecondPointerPosition(e),n=e.pageX-t.x,r=e.pageY-t.y,i=Math.sqrt(n*n+r*r);this._dollyEnd.set(0,i),this._dollyDelta.set(0,(this._dollyEnd.y/this._dollyStart.y)**+this.zoomSpeed),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);let a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new D,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){let t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){let t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}};function mt(e){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener(`pointermove`,this._onPointerMove),window.addEventListener(`pointerup`,this._onPointerUp)),!this._isTrackingPointer(e)&&(this._addPointer(e),e.pointerType===`touch`?this._onTouchStart(e):this._onMouseDown(e)))}function ht(e){this.enabled!==!1&&(e.pointerType===`touch`?this._onTouchMove(e):this._onMouseMove(e))}function gt(e){switch(this._removePointer(e),this._pointers.length){case 0:this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener(`pointermove`,this._onPointerMove),window.removeEventListener(`pointerup`,this._onPointerUp),this.dispatchEvent(ct),this.state=H.NONE;break;case 1:let t=this._pointers[0],n=this._pointerPositions[t];this._onTouchStart({pointerId:t,pageX:n.x,pageY:n.y});break}}function _t(e){let t;switch(e.button){case 0:t=this.mouseButtons.LEFT;break;case 1:t=this.mouseButtons.MIDDLE;break;case 2:t=this.mouseButtons.RIGHT;break;default:t=-1}switch(t){case h.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(e),this.state=H.DOLLY;break;case h.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=H.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=H.ROTATE}break;case h.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(e),this.state=H.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(e),this.state=H.PAN}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(st)}function vt(e){switch(this.state){case H.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(e);break;case H.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(e);break;case H.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(e);break}}function yt(e){this.enabled===!1||this.enableZoom===!1||this.state!==H.NONE||(e.preventDefault(),this.dispatchEvent(st),this._handleMouseWheel(this._customWheelEvent(e)),this.dispatchEvent(ct))}function bt(e){this.enabled===!1||this.enablePan===!1||this._handleKeyDown(e)}function xt(e){switch(this._trackPointer(e),this._pointers.length){case 1:switch(this.touches.ONE){case T.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(e),this.state=H.TOUCH_ROTATE;break;case T.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(e),this.state=H.TOUCH_PAN;break;default:this.state=H.NONE}break;case 2:switch(this.touches.TWO){case T.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(e),this.state=H.TOUCH_DOLLY_PAN;break;case T.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(e),this.state=H.TOUCH_DOLLY_ROTATE;break;default:this.state=H.NONE}break;default:this.state=H.NONE}this.state!==H.NONE&&this.dispatchEvent(st)}function St(e){switch(this._trackPointer(e),this.state){case H.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(e),this.update();break;case H.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(e),this.update();break;case H.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(e),this.update();break;case H.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(e),this.update();break;default:this.state=H.NONE}}function Ct(e){this.enabled!==!1&&e.preventDefault()}function wt(e){e.key===`Control`&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}function Tt(e){e.key===`Control`&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener(`keyup`,this._interceptControlUp,{passive:!0,capture:!0}))}var Et,Dt,Ot,kt;function At(e,t=1/0,n=null){Dt||=new Te(2,2,1,1),Ot||=new Se({uniforms:{blitTexture:new Oe(e)},vertexShader:`
varying vec2 vUv;
void main(){
vUv = uv;
gl_Position = vec4(position.xy * 1.0,0.,.999999);
}`,fragmentShader:`
uniform sampler2D blitTexture;
varying vec2 vUv;
void main(){
gl_FragColor = vec4(vUv.xy, 0, 1);
#ifdef IS_SRGB
gl_FragColor = sRGBTransferOETF( texture2D( blitTexture, vUv) );
#else
gl_FragColor = texture2D( blitTexture, vUv);
#endif
}`}),Ot.uniforms.blitTexture.value=e,Ot.defines.IS_SRGB=e.colorSpace==oe,Ot.needsUpdate=!0,kt||(kt=new S(Dt,Ot),kt.frustumCulled=!1);let r=new he,i=new ee;i.add(kt),n===null&&(n=Et=new u({antialias:!1}));let o=Math.min(e.image.width,t),s=Math.min(e.image.height,t);n.setSize(o,s),n.clear(),n.render(i,r);let c=document.createElement(`canvas`),l=c.getContext(`2d`);c.width=o,c.height=s,l.drawImage(n.domElement,0,0,o,s);let d=new a(c);return d.minFilter=e.minFilter,d.magFilter=e.magFilter,d.wrapS=e.wrapS,d.wrapT=e.wrapT,d.colorSpace=e.colorSpace,d.name=e.name,Et&&=(Et.forceContextLoss(),Et.dispose(),null),d}var jt={POSITION:[`byte`,`byte normalized`,`unsigned byte`,`unsigned byte normalized`,`short`,`short normalized`,`unsigned short`,`unsigned short normalized`],NORMAL:[`byte normalized`,`short normalized`],TANGENT:[`byte normalized`,`short normalized`],TEXCOORD:[`byte`,`byte normalized`,`unsigned byte`,`short`,`short normalized`,`unsigned short`]},Mt=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Zt(e)}),this.register(function(e){return new Qt(e)}),this.register(function(e){return new nn(e)}),this.register(function(e){return new rn(e)}),this.register(function(e){return new an(e)}),this.register(function(e){return new on(e)}),this.register(function(e){return new $t(e)}),this.register(function(e){return new en(e)}),this.register(function(e){return new tn(e)}),this.register(function(e){return new sn(e)}),this.register(function(e){return new cn(e)}),this.register(function(e){return new ln(e)}),this.register(function(e){return new un(e)}),this.register(function(e){return new dn(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i=new Xt,a=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)a.push(this.pluginCallbacks[e](i));i.setPlugins(a),i.write(e,t,r).catch(n)}parseAsync(e,t){let n=this;return new Promise(function(r,i){n.parse(e,r,i,t)})}},W={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Nt=`KHR_mesh_quantization`,G={};G[be]=W.NEAREST,G[_e]=W.NEAREST_MIPMAP_NEAREST,G[w]=W.NEAREST_MIPMAP_LINEAR,G[d]=W.LINEAR,G[Ae]=W.LINEAR_MIPMAP_NEAREST,G[ne]=W.LINEAR_MIPMAP_LINEAR,G[y]=W.CLAMP_TO_EDGE,G[f]=W.REPEAT,G[le]=W.MIRRORED_REPEAT;var Pt={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},Ft=new e,It=12,Lt=1179937895,Rt=2,zt=8,Bt=1313821514,Vt=5130562;function Ht(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function Ut(e){return new TextEncoder().encode(e).buffer}function Wt(e){return Ht(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Gt(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:(t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),e.normalized===!0&&(n=p.normalize(n,e.array))),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function Kt(e){return Math.ceil(e/4)*4}function qt(e,t=0){let n=Kt(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}function Jt(){return typeof document>`u`&&typeof OffscreenCanvas<`u`?new OffscreenCanvas(1,1):document.createElement(`canvas`)}function Yt(e,t){if(e.toBlob!==void 0)return new Promise(n=>e.toBlob(n,t));let n;return t===`image/jpeg`?n=.92:t===`image/webp`&&(n=.8),e.convertToBlob({type:t,quality:n})}var Xt=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.extensionsRequired={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter r`+o}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,n={}){this.options=Object.assign({binary:!1,trs:!1,onlyVisible:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e),await Promise.all(this.pending);let r=this,i=r.buffers,a=r.json;n=r.options;let o=r.extensionsUsed,s=r.extensionsRequired,c=new Blob(i,{type:`application/octet-stream`}),l=Object.keys(o),u=Object.keys(s);if(l.length>0&&(a.extensionsUsed=l),u.length>0&&(a.extensionsRequired=u),a.buffers&&a.buffers.length>0&&(a.buffers[0].byteLength=c.size),n.binary===!0){let e=new FileReader;e.readAsArrayBuffer(c),e.onloadend=function(){let n=qt(e.result),r=new DataView(new ArrayBuffer(zt));r.setUint32(0,n.byteLength,!0),r.setUint32(4,Vt,!0);let i=qt(Ut(JSON.stringify(a)),32),o=new DataView(new ArrayBuffer(zt));o.setUint32(0,i.byteLength,!0),o.setUint32(4,Bt,!0);let s=new ArrayBuffer(It),c=new DataView(s);c.setUint32(0,Lt,!0),c.setUint32(4,Rt,!0);let l=It+o.byteLength+i.byteLength+r.byteLength+n.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,i,r,n],{type:`application/octet-stream`}),d=new FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(a.buffers&&a.buffers.length>0){let e=new FileReader;e.readAsDataURL(c),e.onloadend=function(){let n=e.result;a.buffers[0].uri=n,t(a)}}else t(a)}serializeUserData(e,t){if(Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e,t=!1){if(this.uids.has(e)===!1){let t=new Map;t.set(!0,this.uid++),t.set(!1,this.uid++),this.uids.set(e,t)}return this.uids.get(e).get(t)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;let n=new t;for(let t=0,r=e.count;t<r;t++)if(Math.abs(n.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){let n=this.cache;if(n.attributesNormalized.has(e))return n.attributesNormalized.get(e);let r=e.clone(),i=new t;for(let e=0,t=r.count;e<t;e++)i.fromBufferAttribute(r,e),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),r.setXYZ(e,i.x,i.y,i.z);return n.attributesNormalized.set(e,r),r}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}buildMetalRoughTexture(e,t){if(e===t)return e;function n(e){return e.colorSpace===`srgb`?function(e){return e<.04045?e*.0773993808:(e*.9478672986+.0521327014)**2.4}:function(e){return e}}console.warn(`THREE.GLTFExporter: Merged metalnessMap and roughnessMap textures.`),e instanceof s&&(e=At(e)),t instanceof s&&(t=At(t));let r=e?e.image:null,i=t?t.image:null,a=Math.max(r?r.width:0,i?i.width:0),o=Math.max(r?r.height:0,i?i.height:0),c=Jt();c.width=a,c.height=o;let l=c.getContext(`2d`,{willReadFrequently:!0});l.fillStyle=`#00ffff`,l.fillRect(0,0,a,o);let u=l.getImageData(0,0,a,o);if(r){l.drawImage(r,0,0,a,o);let t=n(e),i=l.getImageData(0,0,a,o).data;for(let e=2;e<i.length;e+=4)u.data[e]=t(i[e]/256)*256}if(i){l.drawImage(i,0,0,a,o);let e=n(t),r=l.getImageData(0,0,a,o).data;for(let t=1;t<r.length;t+=4)u.data[t]=e(r[t]/256)*256}l.putImageData(u,0,0);let d=(e||t).clone();return d.source=new ue(c),d.colorSpace=``,d.channel=(e||t).channel,e&&t&&e.channel!==t.channel&&console.warn(`THREE.GLTFExporter: UV channels for metalnessMap and roughnessMap textures must match.`),d}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;switch(t){case W.BYTE:case W.UNSIGNED_BYTE:o=1;break;case W.SHORT:case W.UNSIGNED_SHORT:o=2;break;default:o=4}let s=e.itemSize*o;i===W.ARRAY_BUFFER&&(s=Math.ceil(s/4)*4);let c=Kt(r*s),l=new DataView(new ArrayBuffer(c)),u=0;for(let i=n;i<n+r;i++){for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:(n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),e.normalized===!0&&(r=p.normalize(r,e.array))),t===W.FLOAT?l.setFloat32(u,r,!0):t===W.INT?l.setInt32(u,r,!0):t===W.UNSIGNED_INT?l.setUint32(u,r,!0):t===W.SHORT?l.setInt16(u,r,!0):t===W.UNSIGNED_SHORT?l.setUint16(u,r,!0):t===W.BYTE?l.setInt8(u,r):t===W.UNSIGNED_BYTE&&l.setUint8(u,r),u+=o}u%s!==0&&(u+=s-u%s)}let d={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:c};return i!==void 0&&(d.target=i),i===W.ARRAY_BUFFER&&(d.byteStride=s),this.byteOffset+=c,a.bufferViews.push(d),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=qt(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.json,a={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,9:`MAT3`,16:`MAT4`},o;if(e.array.constructor===Float32Array)o=W.FLOAT;else if(e.array.constructor===Int32Array)o=W.INT;else if(e.array.constructor===Uint32Array)o=W.UNSIGNED_INT;else if(e.array.constructor===Int16Array)o=W.SHORT;else if(e.array.constructor===Uint16Array)o=W.UNSIGNED_SHORT;else if(e.array.constructor===Int8Array)o=W.BYTE;else if(e.array.constructor===Uint8Array)o=W.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type: `+e.array.constructor.name);if(n===void 0&&(n=0),(r===void 0||r===1/0)&&(r=e.count),r===0)return null;let s=Gt(e,n,r),c;t!==void 0&&(c=e===t.index?W.ELEMENT_ARRAY_BUFFER:W.ARRAY_BUFFER);let l=this.processBufferView(e,o,n,r,c),u={bufferView:l.id,byteOffset:l.byteOffset,componentType:o,count:r,max:s.max,min:s.min,type:a[e.itemSize]};return e.normalized===!0&&(u.normalized=!0),i.accessors||=[],i.accessors.push(u)-1}processImage(e,t,n,r=`image/png`){if(e!==null){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(e)||a.images.set(e,{});let l=a.images.get(e),u=r+`:flipY/`+n.toString();if(l[u]!==void 0)return l[u];o.images||=[];let d={mimeType:r},f=Jt();f.width=Math.min(e.width,s.maxTextureSize),f.height=Math.min(e.height,s.maxTextureSize);let p=f.getContext(`2d`,{willReadFrequently:!0});if(n===!0&&(p.translate(0,f.height),p.scale(1,-1)),e.data!==void 0){t!==1023&&console.error(`GLTFExporter: Only RGBAFormat is supported.`,t),(e.width>s.maxTextureSize||e.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,e);let n=new Uint8ClampedArray(e.height*e.width*4);for(let t=0;t<n.length;t+=4)n[t+0]=e.data[t+0],n[t+1]=e.data[t+1],n[t+2]=e.data[t+2],n[t+3]=e.data[t+3];p.putImageData(new ImageData(n,e.width,e.height),0,0)}else if(typeof HTMLImageElement<`u`&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas)p.drawImage(e,0,0,f.width,f.height);else throw Error(`THREE.GLTFExporter: Invalid image type. Use HTMLImageElement, HTMLCanvasElement, ImageBitmap or OffscreenCanvas.`);s.binary===!0?c.push(Yt(f,r).then(e=>i.processBufferViewImage(e)).then(e=>{d.bufferView=e})):f.toDataURL===void 0?c.push(Yt(f,r).then(e=>new FileReader().readAsDataURL(e)).then(e=>{d.uri=e})):d.uri=f.toDataURL(r);let m=o.images.push(d)-1;return l[u]=m,m}else throw Error(`THREE.GLTFExporter: No valid image data found. Unable to process texture.`)}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:G[e.magFilter],minFilter:G[e.minFilter],wrapS:G[e.wrapS],wrapT:G[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.options,n=this.cache,r=this.json;if(n.textures.has(e))return n.textures.get(e);let i={keep:!0,newTexture:null};if(this._invokeAll(function(t){t.beforeWriteTexture&&t.beforeWriteTexture(e,i)}),i.keep===!1)return null;i.newTexture!=null&&(e=i.newTexture),r.textures||=[],e instanceof s&&(e=At(e,t.maxTextureSize));let a=e.userData.mimeType;a===`image/webp`&&(a=`image/png`);let o={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY,a)};e.name&&(o.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,o)});let c=r.textures.push(o)-1;return n.textures.set(e,c),c}processMaterial(e){let t=this.cache,n=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;n.materials||=[];let r={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let i=e.color.toArray().concat([e.opacity]);Ht(i,[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=i),e.isMeshStandardMaterial?(r.pbrMetallicRoughness.metallicFactor=e.metalness,r.pbrMetallicRoughness.roughnessFactor=e.roughness):(r.pbrMetallicRoughness.metallicFactor=.5,r.pbrMetallicRoughness.roughnessFactor=.5);let a=e.metalnessMap?.image?e.metalnessMap:void 0,o=e.roughnessMap?.image?e.roughnessMap:void 0;if(a||o){let e=this.buildMetalRoughTexture(a,o),t={index:this.processTexture(e),channel:e.channel};this.applyTextureTransform(t,e),r.pbrMetallicRoughness.metallicRoughnessTexture=t}if(e.map){let t={index:this.processTexture(e.map),texCoord:e.map.channel};this.applyTextureTransform(t,e.map),r.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){let t=e.emissive;if(Math.max(t.r,t.g,t.b)>0&&(r.emissiveFactor=e.emissive.toArray()),e.emissiveMap?.image){let t={index:this.processTexture(e.emissiveMap),texCoord:e.emissiveMap.channel};this.applyTextureTransform(t,e.emissiveMap),r.emissiveTexture=t}}if(e.normalMap?.image){let t={index:this.processTexture(e.normalMap),texCoord:e.normalMap.channel};e.normalScale&&e.normalScale.x!==1&&(t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),r.normalTexture=t}if(e.aoMap?.image){let t={index:this.processTexture(e.aoMap),texCoord:e.aoMap.channel};e.aoMapIntensity!==1&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),r.occlusionTexture=t}e.transparent?r.alphaMode=`BLEND`:e.alphaTest>0&&(r.alphaMode=`MASK`,r.alphaCutoff=e.alphaTest),e.side===2&&(r.doubleSided=!0),e.name!==``&&(r.name=e.name),this.serializeUserData(e,r),this._invokeAll(function(t){t.writeMaterial&&t.writeMaterial(e,r)});let s=n.materials.push(r)-1;return t.materials.set(e,s),s}processMesh(e){let t={keep:!0};if(this._invokeAll(function(n){n.beforeWriteMesh&&n.beforeWriteMesh(e,t)}),t.keep!=1)return null;let n=this.cache,r=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,n=e.material.length;t<n;t++)i.push(e.material[t].uuid);else i.push(e.material.uuid);let a=i.join(`:`);if(n.meshes.has(a))return n.meshes.get(a);let o=e.geometry,s;s=e.isLineSegments?W.LINES:e.isLineLoop?W.LINE_LOOP:e.isLine?W.LINE_STRIP:e.isPoints?W.POINTS:e.material.wireframe?W.LINES:W.TRIANGLES;let c={},l={},u=[],d=[],f={uv:`TEXCOORD_0`,uv1:`TEXCOORD_1`,uv2:`TEXCOORD_2`,uv3:`TEXCOORD_3`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},p=o.getAttribute(`normal`);p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),o.setAttribute(`normal`,this.createNormalizedNormalAttribute(p)));let m=null;for(let e in o.attributes){if(e.slice(0,5)===`morph`)continue;let t=o.attributes[e];if(e=f[e]||e.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e=`_`+e),n.attributes.has(this.getUID(t))){l[e]=n.attributes.get(this.getUID(t));continue}m=null;let r=t.array;e===`JOINTS_0`&&!(r instanceof Uint16Array)&&!(r instanceof Uint8Array)&&(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),m=new k(new Uint16Array(r),t.itemSize,t.normalized));let i=this.processAccessor(m||t,o);i!==null&&(e.startsWith(`_`)||this.detectMeshQuantization(e,t),l[e]=i,n.attributes.set(this.getUID(t),i))}if(p!==void 0&&o.setAttribute(`normal`,p),Object.keys(l).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){let t=[],r=[],i={};if(e.morphTargetDictionary!==void 0)for(let t in e.morphTargetDictionary)i[e.morphTargetDictionary[t]]=t;for(let a=0;a<e.morphTargetInfluences.length;++a){let s={},c=!1;for(let e in o.morphAttributes){if(e!==`position`&&e!==`normal`&&e!==`color`){c||=(console.warn(`GLTFExporter: Only POSITION, NORMAL and COLOR morph are supported.`),!0);continue}let t=o.morphAttributes[e][a],r=e.toUpperCase()+(e===`color`?`_0`:``),i=o.attributes[e];if(n.attributes.has(this.getUID(t,!0))){s[r]=n.attributes.get(this.getUID(t,!0));continue}let l=t.clone();if(!o.morphTargetsRelative)for(let e=0,n=t.count;e<n;e++)for(let n=0;n<t.itemSize;n++)n===0&&l.setX(e,t.getX(e)-i.getX(e)),n===1&&l.setY(e,t.getY(e)-i.getY(e)),n===2&&l.setZ(e,t.getZ(e)-i.getZ(e)),n===3&&l.setW(e,t.getW(e)-i.getW(e));s[r]=this.processAccessor(l,o),n.attributes.set(this.getUID(i,!0),s[r])}d.push(s),t.push(e.morphTargetInfluences[a]),e.morphTargetDictionary!==void 0&&r.push(i[a])}c.weights=t,r.length>0&&(c.extras={},c.extras.targetNames=r)}let h=Array.isArray(e.material);if(h&&o.groups.length===0)return null;let g=!1;if(h&&o.index===null){let e=[];for(let t=0,n=o.attributes.position.count;t<n;t++)e[t]=t;o.setIndex(e),g=!0}let _=h?e.material:[e.material],v=h?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,t=v.length;e<t;e++){let t={mode:s,attributes:l};if(this.serializeUserData(o,t),d.length>0&&(t.targets=d),o.index!==null){let r=this.getUID(o.index);(v[e].start!==void 0||v[e].count!==void 0)&&(r+=`:`+v[e].start+`:`+v[e].count),n.attributes.has(r)?t.indices=n.attributes.get(r):(t.indices=this.processAccessor(o.index,o,v[e].start,v[e].count),n.attributes.set(r,t.indices)),t.indices===null&&delete t.indices}let r=this.processMaterial(_[v[e].materialIndex]);r!==null&&(t.material=r),u.push(t)}g===!0&&o.setIndex(null),c.primitives=u,r.meshes||=[],this._invokeAll(function(t){t.writeMesh&&t.writeMesh(e,c)});let y=r.meshes.push(c)-1;return n.meshes.set(a,y),y}detectMeshQuantization(e,t){if(this.extensionsUsed[Nt])return;let n;switch(t.array.constructor){case Int8Array:n=`byte`;break;case Uint8Array:n=`unsigned byte`;break;case Int16Array:n=`short`;break;case Uint16Array:n=`unsigned short`;break;default:return}t.normalized&&(n+=` normalized`);let r=e.split(`_`,1)[0];jt[r]&&jt[r].includes(n)&&(this.extensionsUsed[Nt]=!0,this.extensionsRequired[Nt]=!0)}processCamera(e){let t=this.json;t.cameras||=[];let n=e.isOrthographicCamera,r={type:n?`orthographic`:`perspective`};return n?r.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:r.perspective={aspectRatio:e.aspect,yfov:p.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==``&&(r.name=e.type),t.cameras.push(r)-1}processAnimation(e,t){let n=this.json,i=this.nodeMap;n.animations||=[],e=Mt.Utils.mergeMorphTargetTracks(e.clone(),t);let a=e.tracks,o=[],s=[];for(let e=0;e<a.length;++e){let n=a[e],c=r.parseTrackName(n.name),l=r.findNode(t,c.nodeName),u=Pt[c.propertyName];if(c.objectName===`bones`&&(l=l.isSkinnedMesh===!0?l.skeleton.getBoneByName(c.objectIndex):void 0),!l||!u){console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,n.name);continue}let d=n.values.length/n.times.length;u===Pt.morphTargetInfluences&&(d/=l.morphTargetInfluences.length);let f;n.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(f=`CUBICSPLINE`,d/=3):f=n.getInterpolation()===2300?`STEP`:`LINEAR`,s.push({input:this.processAccessor(new k(n.times,1)),output:this.processAccessor(new k(n.values,d)),interpolation:f}),o.push({sampler:s.length-1,target:{node:i.get(l),path:u}})}return n.animations.push({name:e.name||`clip_`+n.animations.length,samplers:s,channels:o}),n.animations.length-1}processSkin(e){let t=this.json,n=this.nodeMap,r=t.nodes[n.get(e)],i=e.skeleton;if(i===void 0)return null;let a=e.skeleton.bones[0];if(a===void 0)return null;let o=[],s=new Float32Array(i.bones.length*16),c=new x;for(let t=0;t<i.bones.length;++t)o.push(n.get(i.bones[t])),c.copy(i.boneInverses[t]),c.multiply(e.bindMatrix).toArray(s,t*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new k(s,16)),joints:o,skeleton:n.get(a)}),r.skin=t.skins.length-1}processNode(e){let t={keep:!0};if(this._invokeAll(function(n){n.beforeWriteNode&&n.beforeWriteNode(e,t)}),t.keep!=1)return null;let n=this.json,r=this.options,i=this.nodeMap;n.nodes||=[];let a={};if(r.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();Ht(t,[0,0,0,1])||(a.rotation=t),Ht(n,[0,0,0])||(a.translation=n),Ht(r,[1,1,1])||(a.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),Wt(e.matrix)===!1&&(a.matrix=e.matrix.elements);if(e.name!==``&&(a.name=String(e.name)),this.serializeUserData(e,a),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);t!==null&&(a.mesh=t)}else e.isCamera&&(a.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let n=0,i=e.children.length;n<i;n++){let i=e.children[n];if(i.visible||r.onlyVisible===!1){let e=this.processNode(i);e!==null&&t.push(e)}}t.length>0&&(a.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,a)});let o=n.nodes.push(a)-1;return i.set(e,o),o}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=this.processNode(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(e){let t=new ee;t.name=`AuxScene`;for(let n=0;n<e.length;n++)t.children.push(e[n]);this.processScene(t)}processInput(e){let t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(t){t.beforeParse&&t.beforeParse(e)});let n=[];for(let t=0;t<e.length;t++)e[t]instanceof ee?this.processScene(e[t]):n.push(e[t]);n.length>0&&this.processObjects(n);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let n=0;n<t.animations.length;++n)this.processAnimation(t.animations[n],e[0]);this._invokeAll(function(t){t.afterParse&&t.afterParse(e)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},Zt=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(1-e.penumbra)*e.angle,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},Qt=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},$t=class{constructor(e){this.writer=e,this.name=`KHR_materials_clearcoat`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.clearcoat===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.clearcoatFactor=e.clearcoat,e.clearcoatMap){let t={index:n.processTexture(e.clearcoatMap),texCoord:e.clearcoatMap.channel};n.applyTextureTransform(t,e.clearcoatMap),i.clearcoatTexture=t}if(i.clearcoatRoughnessFactor=e.clearcoatRoughness,e.clearcoatRoughnessMap){let t={index:n.processTexture(e.clearcoatRoughnessMap),texCoord:e.clearcoatRoughnessMap.channel};n.applyTextureTransform(t,e.clearcoatRoughnessMap),i.clearcoatRoughnessTexture=t}if(e.clearcoatNormalMap){let t={index:n.processTexture(e.clearcoatNormalMap),texCoord:e.clearcoatNormalMap.channel};e.clearcoatNormalScale.x!==1&&(t.scale=e.clearcoatNormalScale.x),n.applyTextureTransform(t,e.clearcoatNormalMap),i.clearcoatNormalTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},en=class{constructor(e){this.writer=e,this.name=`KHR_materials_dispersion`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.dispersion===0)return;let n=this.writer.extensionsUsed,r={};r.dispersion=e.dispersion,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},tn=class{constructor(e){this.writer=e,this.name=`KHR_materials_iridescence`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.iridescence===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.iridescenceFactor=e.iridescence,e.iridescenceMap){let t={index:n.processTexture(e.iridescenceMap),texCoord:e.iridescenceMap.channel};n.applyTextureTransform(t,e.iridescenceMap),i.iridescenceTexture=t}if(i.iridescenceIor=e.iridescenceIOR,i.iridescenceThicknessMinimum=e.iridescenceThicknessRange[0],i.iridescenceThicknessMaximum=e.iridescenceThicknessRange[1],e.iridescenceThicknessMap){let t={index:n.processTexture(e.iridescenceThicknessMap),texCoord:e.iridescenceThicknessMap.channel};n.applyTextureTransform(t,e.iridescenceThicknessMap),i.iridescenceThicknessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},nn=class{constructor(e){this.writer=e,this.name=`KHR_materials_transmission`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.transmissionFactor=e.transmission,e.transmissionMap){let t={index:n.processTexture(e.transmissionMap),texCoord:e.transmissionMap.channel};n.applyTextureTransform(t,e.transmissionMap),i.transmissionTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},rn=class{constructor(e){this.writer=e,this.name=`KHR_materials_volume`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.transmission===0)return;let n=this.writer,r=n.extensionsUsed,i={};if(i.thicknessFactor=e.thickness,e.thicknessMap){let t={index:n.processTexture(e.thicknessMap),texCoord:e.thicknessMap.channel};n.applyTextureTransform(t,e.thicknessMap),i.thicknessTexture=t}e.attenuationDistance!==1/0&&(i.attenuationDistance=e.attenuationDistance),i.attenuationColor=e.attenuationColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},an=class{constructor(e){this.writer=e,this.name=`KHR_materials_ior`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.ior===1.5)return;let n=this.writer.extensionsUsed,r={};r.ior=e.ior,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},on=class{constructor(e){this.writer=e,this.name=`KHR_materials_specular`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.specularIntensity===1&&e.specularColor.equals(Ft)&&!e.specularIntensityMap&&!e.specularColorMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.specularIntensityMap){let t={index:n.processTexture(e.specularIntensityMap),texCoord:e.specularIntensityMap.channel};n.applyTextureTransform(t,e.specularIntensityMap),i.specularTexture=t}if(e.specularColorMap){let t={index:n.processTexture(e.specularColorMap),texCoord:e.specularColorMap.channel};n.applyTextureTransform(t,e.specularColorMap),i.specularColorTexture=t}i.specularFactor=e.specularIntensity,i.specularColorFactor=e.specularColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},sn=class{constructor(e){this.writer=e,this.name=`KHR_materials_sheen`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.sheen==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.sheenRoughnessMap){let t={index:n.processTexture(e.sheenRoughnessMap),texCoord:e.sheenRoughnessMap.channel};n.applyTextureTransform(t,e.sheenRoughnessMap),i.sheenRoughnessTexture=t}if(e.sheenColorMap){let t={index:n.processTexture(e.sheenColorMap),texCoord:e.sheenColorMap.channel};n.applyTextureTransform(t,e.sheenColorMap),i.sheenColorTexture=t}i.sheenRoughnessFactor=e.sheenRoughness,i.sheenColorFactor=e.sheenColor.toArray(),t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},cn=class{constructor(e){this.writer=e,this.name=`KHR_materials_anisotropy`}writeMaterial(e,t){if(!e.isMeshPhysicalMaterial||e.anisotropy==0)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.anisotropyMap){let t={index:n.processTexture(e.anisotropyMap)};n.applyTextureTransform(t,e.anisotropyMap),i.anisotropyTexture=t}i.anisotropyStrength=e.anisotropy,i.anisotropyRotation=e.anisotropyRotation,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},ln=class{constructor(e){this.writer=e,this.name=`KHR_materials_emissive_strength`}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.emissiveIntensity===1)return;let n=this.writer.extensionsUsed,r={};r.emissiveStrength=e.emissiveIntensity,t.extensions=t.extensions||{},t.extensions[this.name]=r,n[this.name]=!0}},un=class{constructor(e){this.writer=e,this.name=`EXT_materials_bump`}writeMaterial(e,t){if(!e.isMeshStandardMaterial||e.bumpScale===1&&!e.bumpMap)return;let n=this.writer,r=n.extensionsUsed,i={};if(e.bumpMap){let t={index:n.processTexture(e.bumpMap),texCoord:e.bumpMap.channel};n.applyTextureTransform(t,e.bumpMap),i.bumpTexture=t}i.bumpFactor=e.bumpScale,t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}},dn=class{constructor(e){this.writer=e,this.name=`EXT_mesh_gpu_instancing`}writeNode(e,n){if(!e.isInstancedMesh)return;let r=this.writer,i=e,a=new Float32Array(i.count*3),o=new Float32Array(i.count*4),s=new Float32Array(i.count*3),c=new x,l=new t,u=new O,d=new t;for(let e=0;e<i.count;e++)i.getMatrixAt(e,c),c.decompose(l,u,d),l.toArray(a,e*3),u.toArray(o,e*4),d.toArray(s,e*3);let f={TRANSLATION:r.processAccessor(new k(a,3)),ROTATION:r.processAccessor(new k(o,4)),SCALE:r.processAccessor(new k(s,3))};i.instanceColor&&(f._COLOR_0=r.processAccessor(i.instanceColor)),n.extensions=n.extensions||{},n.extensions[this.name]={attributes:f},r.extensionsUsed[this.name]=!0,r.extensionsRequired[this.name]=!0}};Mt.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(e,t){let n=[],i={},a=e.tracks;for(let e=0;e<a.length;++e){let o=a[e],s=r.parseTrackName(o.name),c=r.findNode(t,s.nodeName);if(s.propertyName!==`morphTargetInfluences`||s.propertyIndex===void 0){n.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),o=o.clone(),o.setInterpolation(ae)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[s.propertyIndex];if(u===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+s.propertyIndex);let d;if(i[c.uuid]===void 0){d=o.clone();let e=new d.ValueBufferType(l*d.times.length);for(let t=0;t<d.times.length;t++)e[t*l+u]=d.values[t];d.name=(s.nodeName||``)+`.morphTargetInfluences`,d.values=e,i[c.uuid]=d,n.push(d);continue}let f=o.createInterpolant(new o.ValueBufferType(1));d=i[c.uuid];for(let e=0;e<d.times.length;e++)d.values[e*l+u]=f.evaluate(d.times[e]);for(let e=0;e<o.times.length;e++){let t=this.insertKeyframe(d,o.times[e]);d.values[t*l+u]=o.values[e]}}return e.tracks=n,e}};var fn=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles`,pn=`generic-trigger`,mn=class extends me{constructor(){super(),this.motionController=null,this.envMap=null}setEnvironmentMap(e){return this.envMap==e?this:(this.envMap=e,this.traverse(e=>{e.isMesh&&(e.material.envMap=this.envMap,e.material.needsUpdate=!0)}),this)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.motionController&&(this.motionController.updateFromGamepad(),Object.values(this.motionController.components).forEach(e=>{Object.values(e.visualResponses).forEach(e=>{let{valueNode:t,minNode:n,maxNode:r,value:i,valueNodeProperty:a}=e;t&&(a===Ne.VisualResponseProperty.VISIBILITY?t.visible=i:a===Ne.VisualResponseProperty.TRANSFORM&&(t.quaternion.slerpQuaternions(n.quaternion,r.quaternion,i),t.position.lerpVectors(n.position,r.position,i)))})}))}};function hn(e,t){Object.values(e.components).forEach(e=>{let{type:n,touchPointNodeName:r,visualResponses:i}=e;if(n===Ne.ComponentType.TOUCHPAD)if(e.touchPointNode=t.getObjectByName(r),e.touchPointNode){let t=new S(new we(.001),new te({color:255}));e.touchPointNode.add(t)}else console.warn(`Could not find touch dot, ${e.touchPointNodeName}, in touchpad component ${e.id}`);Object.values(i).forEach(e=>{let{valueNodeName:n,minNodeName:r,maxNodeName:i,valueNodeProperty:a}=e;if(a===Ne.VisualResponseProperty.TRANSFORM){if(e.minNode=t.getObjectByName(r),e.maxNode=t.getObjectByName(i),!e.minNode){console.warn(`Could not find ${r} in the model`);return}if(!e.maxNode){console.warn(`Could not find ${i} in the model`);return}}e.valueNode=t.getObjectByName(n),e.valueNode||console.warn(`Could not find ${n} in the model`)})})}function gn(e,t){hn(e.motionController,t),e.envMap&&t.traverse(t=>{t.isMesh&&(t.material.envMap=e.envMap,t.material.needsUpdate=!0)}),e.layers.mask!=0&&t.traverse(t=>{t.layers.mask=e.layers.mask}),e.add(t)}var _n=class{constructor(e=null,t=null){this.gltfLoader=e,this.path=fn,this._assetCache={},this.onLoad=t,this.gltfLoader||=new je}setPath(e){return this.path=e,this}createControllerModel(e){let t=new mn,n=null;return e.addEventListener(`connected`,e=>{let r=e.data;r.targetRayMode!==`tracked-pointer`||!r.gamepad||r.hand||Pe(r,this.path,pn).then(({profile:e,assetPath:i})=>{t.motionController=new Me(r,e,i);let a=this._assetCache[t.motionController.assetUrl];if(a)n=a.scene.clone(),gn(t,n),this.onLoad&&this.onLoad(n);else{if(!this.gltfLoader)throw Error(`GLTFLoader not set.`);this.gltfLoader.setPath(``),this.gltfLoader.load(t.motionController.assetUrl,e=>{this._assetCache[t.motionController.assetUrl]=e,n=e.scene.clone(),gn(t,n),this.onLoad&&this.onLoad(n)},null,()=>{throw Error(`Asset ${t.motionController.assetUrl} missing or malformed.`)})}}).catch(e=>{console.warn(e)})}),e.addEventListener(`disconnected`,()=>{t.motionController=null,t.remove(n),n=null}),t}},vn=`https://cdn.jsdelivr.net/npm/@webxr-input-profiles/assets@1.0/dist/profiles/generic-hand/`,yn=class{constructor(e,t,n,r,i=null,a=null){this.controller=t,this.handModel=e,this.bones=[],i===null&&(i=new je,i.setPath(n||vn)),i.load(`${r}.glb`,e=>{let t=e.scene.children[0];this.handModel.add(t),t.layers.mask=this.handModel.layers.mask;let n=t.getObjectByProperty(`type`,`SkinnedMesh`);n.frustumCulled=!1,n.castShadow=!0,n.receiveShadow=!0,[`wrist`,`thumb-metacarpal`,`thumb-phalanx-proximal`,`thumb-phalanx-distal`,`thumb-tip`,`index-finger-metacarpal`,`index-finger-phalanx-proximal`,`index-finger-phalanx-intermediate`,`index-finger-phalanx-distal`,`index-finger-tip`,`middle-finger-metacarpal`,`middle-finger-phalanx-proximal`,`middle-finger-phalanx-intermediate`,`middle-finger-phalanx-distal`,`middle-finger-tip`,`ring-finger-metacarpal`,`ring-finger-phalanx-proximal`,`ring-finger-phalanx-intermediate`,`ring-finger-phalanx-distal`,`ring-finger-tip`,`pinky-finger-metacarpal`,`pinky-finger-phalanx-proximal`,`pinky-finger-phalanx-intermediate`,`pinky-finger-phalanx-distal`,`pinky-finger-tip`].forEach(e=>{let n=t.getObjectByName(e);n===void 0?console.warn(`Couldn't find ${e} in ${r} hand mesh`):n.jointName=e,this.bones.push(n)}),a&&a(t)})}updateMesh(){let e=this.controller.joints;for(let t=0;t<this.bones.length;t++){let n=this.bones[t];if(n){let t=e[n.jointName];if(t.visible){let e=t.position;n.position.copy(e),n.quaternion.copy(t.quaternion)}}}}},bn=new se,xn=new t,Sn=class extends De{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 C([-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 C([-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 ke(t,6,1);return this.setAttribute(`instanceStart`,new b(n,3,0)),this.setAttribute(`instanceEnd`,new b(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));let n=new ke(t,6,1);return this.setAttribute(`instanceColorStart`,new b(n,3,0)),this.setAttribute(`instanceColorEnd`,new b(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 g(e.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new se);let e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),bn.setFromBufferAttribute(t),this.boundingBox.union(bn))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new ve),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++)xn.fromBufferAttribute(e,i),r=Math.max(r,n.distanceToSquared(xn)),xn.fromBufferAttribute(t,i),r=Math.max(r,n.distanceToSquared(xn));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)}};ie.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new D(1,1)},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},pe.line={uniforms:i.merge([ie.common,ie.fog,ie.line]),vertexShader:`
#include <common>
#include <color_pars_vertex>
#include <fog_pars_vertex>
#include <logdepthbuf_pars_vertex>
#include <clipping_planes_pars_vertex>
uniform float linewidth;
uniform vec2 resolution;
attribute vec3 instanceStart;
attribute vec3 instanceEnd;
attribute vec3 instanceColorStart;
attribute vec3 instanceColorEnd;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#ifdef USE_DASH
uniform float dashScale;
attribute float instanceDistanceStart;
attribute float instanceDistanceEnd;
varying float vLineDistance;
#endif
void trimSegment( const in vec4 start, inout vec4 end ) {
// trim end segment so it terminates between the camera plane and the near plane
// conservative estimate of the near plane
float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
float nearEstimate = - 0.5 * b / a;
float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );
end.xyz = mix( start.xyz, end.xyz, alpha );
}
void main() {
#ifdef USE_COLOR
vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;
#endif
#ifdef USE_DASH
vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;
vUv = uv;
#endif
float aspect = resolution.x / resolution.y;
// camera space
vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );
#ifdef WORLD_UNITS
worldStart = start.xyz;
worldEnd = end.xyz;
#else
vUv = uv;
#endif
// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
// perhaps there is a more elegant solution -- WestLangley
bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column
if ( perspective ) {
if ( start.z < 0.0 && end.z >= 0.0 ) {
trimSegment( start, end );
} else if ( end.z < 0.0 && start.z >= 0.0 ) {
trimSegment( end, start );
}
}
// clip space
vec4 clipStart = projectionMatrix * start;
vec4 clipEnd = projectionMatrix * end;
// ndc space
vec3 ndcStart = clipStart.xyz / clipStart.w;
vec3 ndcEnd = clipEnd.xyz / clipEnd.w;
// direction
vec2 dir = ndcEnd.xy - ndcStart.xy;
// account for clip-space aspect ratio
dir.x *= aspect;
dir = normalize( dir );
#ifdef WORLD_UNITS
vec3 worldDir = normalize( end.xyz - start.xyz );
vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );
vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );
vec3 worldFwd = cross( worldDir, worldUp );
worldPos = position.y < 0.5 ? start: end;
// height offset
float hw = linewidth * 0.5;
worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;
// don't extend the line if we're rendering dashes because we
// won't be rendering the endcaps
#ifndef USE_DASH
// cap extension
worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;
// add width to the box
worldPos.xyz += worldFwd * hw;
// endcaps
if ( position.y > 1.0 || position.y < 0.0 ) {
worldPos.xyz -= worldFwd * 2.0 * hw;
}
#endif
// project the worldpos
vec4 clip = projectionMatrix * worldPos;
// shift the depth of the projected points so the line
// segments overlap neatly
vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;
clip.z = clipPose.z * clip.w;
#else
vec2 offset = vec2( dir.y, - dir.x );
// undo aspect ratio adjustment
dir.x /= aspect;
offset.x /= aspect;
// sign flip
if ( position.x < 0.0 ) offset *= - 1.0;
// endcaps
if ( position.y < 0.0 ) {
offset += - dir;
} else if ( position.y > 1.0 ) {
offset += dir;
}
// adjust for linewidth
offset *= linewidth;
// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
offset /= resolution.y;
// select end
vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;
// back to clip space
offset *= clip.w;
clip.xy += offset;
#endif
gl_Position = clip;
vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation
#include <logdepthbuf_vertex>
#include <clipping_planes_vertex>
#include <fog_vertex>
}
`,fragmentShader:`
uniform vec3 diffuse;
uniform float opacity;
uniform float linewidth;
#ifdef USE_DASH
uniform float dashOffset;
uniform float dashSize;
uniform float gapSize;
#endif
varying float vLineDistance;
#ifdef WORLD_UNITS
varying vec4 worldPos;
varying vec3 worldStart;
varying vec3 worldEnd;
#ifdef USE_DASH
varying vec2 vUv;
#endif
#else
varying vec2 vUv;
#endif
#include <common>
#include <color_pars_fragment>
#include <fog_pars_fragment>
#include <logdepthbuf_pars_fragment>
#include <clipping_planes_pars_fragment>
vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {
float mua;
float mub;
vec3 p13 = p1 - p3;
vec3 p43 = p4 - p3;
vec3 p21 = p2 - p1;
float d1343 = dot( p13, p43 );
float d4321 = dot( p43, p21 );
float d1321 = dot( p13, p21 );
float d4343 = dot( p43, p43 );
float d2121 = dot( p21, p21 );
float denom = d2121 * d4343 - d4321 * d4321;
float numer = d1343 * d4321 - d1321 * d4343;
mua = numer / denom;
mua = clamp( mua, 0.0, 1.0 );
mub = ( d1343 + d4321 * ( mua ) ) / d4343;
mub = clamp( mub, 0.0, 1.0 );
return vec2( mua, mub );
}
void main() {
#include <clipping_planes_fragment>
#ifdef USE_DASH
if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps
if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX
#endif
float alpha = opacity;
#ifdef WORLD_UNITS
// Find the closest points on the view ray and the line segment
vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;
vec3 lineDir = worldEnd - worldStart;
vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );
vec3 p1 = worldStart + lineDir * params.x;
vec3 p2 = rayEnd * params.y;
vec3 delta = p1 - p2;
float len = length( delta );
float norm = len / linewidth;
#ifndef USE_DASH
#ifdef USE_ALPHA_TO_COVERAGE
float dnorm = fwidth( norm );
alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );
#else
if ( norm > 0.5 ) {
discard;
}
#endif
#endif
#else
#ifdef USE_ALPHA_TO_COVERAGE
// artifacts appear on some hardware if a derivative is taken within a conditional
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
float dlen = fwidth( len2 );
if ( abs( vUv.y ) > 1.0 ) {
alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );
}
#else
if ( abs( vUv.y ) > 1.0 ) {
float a = vUv.x;
float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
float len2 = a * a + b * b;
if ( len2 > 1.0 ) discard;
}
#endif
#endif
vec4 diffuseColor = vec4( diffuse, alpha );
#include <logdepthbuf_fragment>
#include <color_fragment>
gl_FragColor = vec4( diffuseColor.rgb, alpha );
#include <tonemapping_fragment>
#include <colorspace_fragment>
#include <fog_fragment>
#include <premultiplied_alpha_fragment>
}
`};var Cn=class extends Se{constructor(e){super({type:`LineMaterial`,uniforms:i.clone(pe.line.uniforms),vertexShader:pe.line.vertexShader,fragmentShader:pe.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)}},wn=new ge,Tn=new t,En=new t,K=new ge,q=new ge,J=new ge,Dn=new t,On=new x,Y=new _,kn=new t,An=new se,jn=new ve,X=new ge,Z,Q;function Mn(e,t,n){return X.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),X.multiplyScalar(1/X.w),X.x=Q/n.width,X.y=Q/n.height,X.applyMatrix4(e.projectionMatrixInverse),X.multiplyScalar(1/X.w),Math.abs(Math.max(X.x,X.y))}function Nn(e,n){let r=e.matrixWorld,i=e.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=Math.min(i.instanceCount,a.count);for(let i=0,c=s;i<c;i++){Y.start.fromBufferAttribute(a,i),Y.end.fromBufferAttribute(o,i),Y.applyMatrix4(r);let s=new t,c=new t;Z.distanceSqToSegment(Y.start,Y.end,c,s),c.distanceTo(s)<Q*.5&&n.push({point:c,pointOnLine:s,distance:Z.origin.distanceTo(c),object:e,face:null,faceIndex:i,uv:null,uv1:null})}}function Pn(e,n,r){let i=n.projectionMatrix,a=e.material.resolution,o=e.matrixWorld,s=e.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;Z.at(1,J),J.w=1,J.applyMatrix4(n.matrixWorldInverse),J.applyMatrix4(i),J.multiplyScalar(1/J.w),J.x*=a.x/2,J.y*=a.y/2,J.z=0,Dn.copy(J),On.multiplyMatrices(n.matrixWorldInverse,o);for(let n=0,s=u;n<s;n++){if(K.fromBufferAttribute(c,n),q.fromBufferAttribute(l,n),K.w=1,q.w=1,K.applyMatrix4(On),q.applyMatrix4(On),K.z>d&&q.z>d)continue;if(K.z>d){let e=K.z-q.z,t=(K.z-d)/e;K.lerp(q,t)}else if(q.z>d){let e=q.z-K.z,t=(q.z-d)/e;q.lerp(K,t)}K.applyMatrix4(i),q.applyMatrix4(i),K.multiplyScalar(1/K.w),q.multiplyScalar(1/q.w),K.x*=a.x/2,K.y*=a.y/2,q.x*=a.x/2,q.y*=a.y/2,Y.start.copy(K),Y.start.z=0,Y.end.copy(q),Y.end.z=0;let s=Y.closestPointToPointParameter(Dn,!0);Y.at(s,kn);let u=p.lerp(K.z,q.z,s),f=u>=-1&&u<=1,m=Dn.distanceTo(kn)<Q*.5;if(f&&m){Y.start.fromBufferAttribute(c,n),Y.end.fromBufferAttribute(l,n),Y.start.applyMatrix4(o),Y.end.applyMatrix4(o);let i=new t,a=new t;Z.distanceSqToSegment(Y.start,Y.end,a,i),r.push({point:a,pointOnLine:i,distance:Z.origin.distanceTo(a),object:e,face:null,faceIndex:n,uv:null,uv1:null})}}}var Fn=class extends S{constructor(e=new Sn,t=new Cn({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)Tn.fromBufferAttribute(t,e),En.fromBufferAttribute(n,e),r[i]=i===0?0:r[i-1],r[i+1]=r[i]+Tn.distanceTo(En);let i=new ke(r,2,1);return e.setAttribute(`instanceDistanceStart`,new b(i,1,0)),e.setAttribute(`instanceDistanceEnd`,new b(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?0:e.params.Line2.threshold||0;Z=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;Q=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),jn.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?Q*.5:Mn(r,Math.max(r.near,jn.distanceToPoint(Z.origin)),s.resolution),jn.radius+=c,Z.intersectsSphere(jn)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),An.copy(o.boundingBox).applyMatrix4(a);let l;l=n?Q*.5:Mn(r,Math.max(r.near,An.distanceToPoint(Z.origin)),s.resolution),An.expandByScalar(l),Z.intersectsBox(An)!==!1&&(n?Nn(this,t):Pn(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(wn),this.material.uniforms.resolution.value.set(wn.z,wn.w))}},In=class extends Sn{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}fromLine(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}},Ln=class extends Fn{constructor(e=new In,t=new Cn({color:Math.random()*16777215})){super(e,t),this.isLine2=!0,this.type=`Line2`}},Rn=class extends S{constructor(e){let t=new zn(e),n=new Te(t.image.width*.001,t.image.height*.001),r=new te({map:t,toneMapped:!1,transparent:!0});super(n,r);function i(e){r.map.dispatchDOMEvent(e)}this.addEventListener(`mousedown`,i),this.addEventListener(`mousemove`,i),this.addEventListener(`mouseup`,i),this.addEventListener(`click`,i),this.dispose=function(){n.dispose(),r.dispose(),r.map.dispose(),Bn.delete(e),this.removeEventListener(`mousedown`,i),this.removeEventListener(`mousemove`,i),this.removeEventListener(`mouseup`,i),this.removeEventListener(`click`,i)}}},zn=class extends a{constructor(e){super(Vn(e)),this.dom=e,this.anisotropy=16,this.colorSpace=oe,this.minFilter=d,this.magFilter=d;let t=new MutationObserver(()=>{this.scheduleUpdate||=setTimeout(()=>this.update(),16)});t.observe(e,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),this.observer=t}dispatchDOMEvent(e){e.data&&Hn(this.dom,e.type,e.data.x,e.data.y)}update(){this.image=Vn(this.dom),this.needsUpdate=!0,this.scheduleUpdate=null}dispose(){this.observer&&this.observer.disconnect(),this.scheduleUpdate=clearTimeout(this.scheduleUpdate),super.dispose()}},Bn=new WeakMap;function Vn(t){let n=document.createRange(),r=new e;function i(e){let t=[],n=!1;function r(){if(n&&(n=!1,e.restore()),t.length===0)return;let r=-1/0,i=-1/0,a=1/0,o=1/0;for(let e=0;e<t.length;e++){let n=t[e];r=Math.max(r,n.x),i=Math.max(i,n.y),a=Math.min(a,n.x+n.width),o=Math.min(o,n.y+n.height)}e.save(),e.beginPath(),e.rect(r,i,a-r,o-i),e.clip(),n=!0}return{add:function(e){t.push(e),r()},remove:function(){t.pop(),r()}}}function a(e,t,n,r){r!==``&&(e.textTransform===`uppercase`&&(r=r.toUpperCase()),d.font=e.fontWeight+` `+e.fontSize+` `+e.fontFamily,d.textBaseline=`top`,d.fillStyle=e.color,d.fillText(r,t,n+parseFloat(e.fontSize)*.1))}function o(e,t,n,r,i){n<2*i&&(i=n/2),r<2*i&&(i=r/2),d.beginPath(),d.moveTo(e+i,t),d.arcTo(e+n,t,e+n,t+r,i),d.arcTo(e+n,t+r,e,t+r,i),d.arcTo(e,t+r,e,t,i),d.arcTo(e,t,e+n,t,i),d.closePath()}function s(e,t,n,r,i,a){let o=e[t+`Width`],s=e[t+`Style`],c=e[t+`Color`];o!==`0px`&&s!==`none`&&c!==`transparent`&&c!==`rgba(0, 0, 0, 0)`&&(d.strokeStyle=c,d.lineWidth=parseFloat(o),d.beginPath(),d.moveTo(n,r),d.lineTo(n+i,r+a),d.stroke())}function c(e,t){if(e.nodeType===Node.COMMENT_NODE||e.nodeName===`SCRIPT`||e.style&&e.style.display===`none`)return;let i=0,u=0,p=0,m=0;if(e.nodeType===Node.TEXT_NODE){n.selectNode(e);let r=n.getBoundingClientRect();i=r.left-l.left-.5,u=r.top-l.top-.5,p=r.width,m=r.height,a(t,i,u,e.nodeValue.trim())}else if(e instanceof HTMLCanvasElement){let t=e.getBoundingClientRect();i=t.left-l.left-.5,u=t.top-l.top-.5,d.save();let n=window.devicePixelRatio;d.scale(1/n,1/n),d.drawImage(e,i,u),d.restore()}else if(e instanceof HTMLImageElement){let t=e.getBoundingClientRect();i=t.left-l.left-.5,u=t.top-l.top-.5,p=t.width,m=t.height,d.drawImage(e,i,u,p,m)}else{let n=e.getBoundingClientRect();i=n.left-l.left-.5,u=n.top-l.top-.5,p=n.width,m=n.height,t=window.getComputedStyle(e),o(i,u,p,m,parseFloat(t.borderRadius));let c=t.backgroundColor;c!==`transparent`&&c!==`rgba(0, 0, 0, 0)`&&(d.fillStyle=c,d.fill());let h=[`borderTop`,`borderLeft`,`borderBottom`,`borderRight`],g=!0,_=null;for(let e of h){if(_!==null&&(g=t[e+`Width`]===t[_+`Width`]&&t[e+`Color`]===t[_+`Color`]&&t[e+`Style`]===t[_+`Style`]),g===!1)break;_=e}if(g===!0){let e=parseFloat(t.borderTopWidth);t.borderTopWidth!==`0px`&&t.borderTopStyle!==`none`&&t.borderTopColor!==`transparent`&&t.borderTopColor!==`rgba(0, 0, 0, 0)`&&(d.strokeStyle=t.borderTopColor,d.lineWidth=e,d.stroke())}else s(t,`borderTop`,i,u,p,0),s(t,`borderLeft`,i,u,0,m),s(t,`borderBottom`,i,u+m,p,0),s(t,`borderRight`,i+p,u,0,m);if(e instanceof HTMLInputElement){let n=t.accentColor;(n===void 0||n===`auto`)&&(n=t.color),r.set(n);let s=Math.sqrt(.299*r.r**2+.587*r.g**2+.114*r.b**2)<.5?`white`:`#111111`;if(e.type===`radio`&&(o(i,u,p,m,m),d.fillStyle=`white`,d.strokeStyle=n,d.lineWidth=1,d.fill(),d.stroke(),e.checked&&(o(i+2,u+2,p-4,m-4,m),d.fillStyle=n,d.strokeStyle=s,d.lineWidth=2,d.fill(),d.stroke())),e.type===`checkbox`&&(o(i,u,p,m,2),d.fillStyle=e.checked?n:`white`,d.strokeStyle=e.checked?s:n,d.lineWidth=1,d.stroke(),d.fill(),e.checked)){let e=d.textAlign;d.textAlign=`center`,a({color:s,fontFamily:t.fontFamily,fontSize:m+`px`,fontWeight:`bold`},i+p/2,u,``),d.textAlign=e}if(e.type===`range`){let[t,r,a]=[`min`,`max`,`value`].map(t=>parseFloat(e[t])),c=(a-t)/(r-t)*(p-m);o(i,u+m/4,p,m/2,m/4),d.fillStyle=s,d.strokeStyle=n,d.lineWidth=1,d.fill(),d.stroke(),o(i,u+m/4,c+m/2,m/2,m/4),d.fillStyle=n,d.fill(),o(i+c,u,m,m,m/2),d.fillStyle=n,d.fill()}(e.type===`color`||e.type===`text`||e.type===`number`)&&(f.add({x:i,y:u,width:p,height:m}),a(t,i+parseInt(t.paddingLeft),u+parseInt(t.paddingTop),e.value),f.remove())}}let h=t.overflow===`auto`||t.overflow===`hidden`;h&&f.add({x:i,y:u,width:p,height:m});for(let n=0;n<e.childNodes.length;n++)c(e.childNodes[n],t);h&&f.remove()}let l=t.getBoundingClientRect(),u=Bn.get(t);u===void 0&&(u=document.createElement(`canvas`),u.width=l.width,u.height=l.height,Bn.set(t,u));let d=u.getContext(`2d`),f=new i(d);return d.clearRect(0,0,u.width,u.height),c(t),u}function Hn(e,t,n,r){let i={clientX:n*e.offsetWidth+e.offsetLeft,clientY:r*e.offsetHeight+e.offsetTop,view:e.ownerDocument.defaultView};window.dispatchEvent(new MouseEvent(t,i));let a=e.getBoundingClientRect();n=n*a.width+a.left,r=r*a.height+a.top;function o(e){if(e.nodeType!==Node.TEXT_NODE&&e.nodeType!==Node.COMMENT_NODE){let a=e.getBoundingClientRect();if(n>a.left&&n<a.right&&r>a.top&&r<a.bottom&&(e.dispatchEvent(new MouseEvent(t,i)),e instanceof HTMLInputElement&&e.type===`range`&&(t===`mousedown`||t===`click`))){let[t,r]=[`min`,`max`].map(t=>parseFloat(e[t])),i=a.width,o=(n-a.x)/i;e.value=t+(r-t)*o,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0}))}for(let t=0;t<e.childNodes.length;t++)o(e.childNodes[t])}}o(e)}var Un=new D,$={type:``,data:Un},Wn=new m,Gn=class extends fe{listenToPointerEvents(e,t){let n=this,r=new m,i=e.domElement;function a(i){i.stopPropagation();let a=e.domElement.getBoundingClientRect();Un.x=(i.clientX-a.left)/a.width*2-1,Un.y=-(i.clientY-a.top)/a.height*2+1,r.setFromCamera(Un,t);let o=r.intersectObjects(n.children,!1);if(o.length>0){let e=o[0],t=e.object,n=e.uv;$.type=i.type,$.data.set(n.x,1-n.y),t.dispatchEvent($)}}i.addEventListener(`pointerdown`,a),i.addEventListener(`pointerup`,a),i.addEventListener(`pointermove`,a),i.addEventListener(`mousedown`,a),i.addEventListener(`mouseup`,a),i.addEventListener(`mousemove`,a),i.addEventListener(`click`,a)}listenToXRControllerEvents(e){let t=this,n={move:`mousemove`,select:`click`,selectstart:`mousedown`,selectend:`mouseup`};function r(e){let r=e.target;Wn.setFromXRController(r);let i=Wn.intersectObjects(t.children,!1);if(i.length>0){let t=i[0],r=t.object,a=t.uv;$.type=n[e.type],$.data.set(a.x,1-a.y),r.dispatchEvent($)}}e.addEventListener(`move`,r),e.addEventListener(`select`,r),e.addEventListener(`selectstart`,r),e.addEventListener(`selectend`,r)}},Kn=class{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error(`THREE.Pass: .render() must be implemented in derived pass.`)}dispose(){}};new ye(-1,1,1,-1,0,1),new class extends re{constructor(){super(),this.setAttribute(`position`,new C([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute(`uv`,new C([0,2,0,0,2,0],2))}};export{In as a,_n as c,Ve as d,it as f,Ln as i,Mt as l,Gn as n,Cn as o,Fe as p,Rn as r,yn as s,Kn as t,pt as u};