shop-components 0.4.28 → 0.4.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dev/src/amr.d.ts +2 -0
- package/dist/dev/src/scene.d.ts +1 -0
- package/dist/shop-components.cjs +4 -4
- package/dist/shop-components.mjs +726 -700
- package/package.json +1 -1
package/dist/shop-components.cjs
CHANGED
|
@@ -3703,7 +3703,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};le=new WeakMap,Ce=new WeakMap,Ti=new
|
|
|
3703
3703
|
* goldfirestudios.com
|
|
3704
3704
|
*
|
|
3705
3705
|
* MIT License
|
|
3706
|
-
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var r=this;if(!r.ctx||!r.ctx.listener)return r;if(i=typeof i!="number"?r._pos[1]:i,s=typeof s!="number"?r._pos[2]:s,typeof t=="number")r._pos=[t,i,s],typeof r.ctx.listener.positionX<"u"?(r.ctx.listener.positionX.setTargetAtTime(r._pos[0],Howler.ctx.currentTime,.1),r.ctx.listener.positionY.setTargetAtTime(r._pos[1],Howler.ctx.currentTime,.1),r.ctx.listener.positionZ.setTargetAtTime(r._pos[2],Howler.ctx.currentTime,.1)):r.ctx.listener.setPosition(r._pos[0],r._pos[1],r._pos[2]);else return r._pos;return r},HowlerGlobal.prototype.orientation=function(t,i,s,r,o,c){var h=this;if(!h.ctx||!h.ctx.listener)return h;var u=h._orientation;if(i=typeof i!="number"?u[1]:i,s=typeof s!="number"?u[2]:s,r=typeof r!="number"?u[3]:r,o=typeof o!="number"?u[4]:o,c=typeof c!="number"?u[5]:c,typeof t=="number")h._orientation=[t,i,s,r,o,c],typeof h.ctx.listener.forwardX<"u"?(h.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),h.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),h.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),h.ctx.listener.upX.setTargetAtTime(r,Howler.ctx.currentTime,.1),h.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),h.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):h.ctx.listener.setOrientation(t,i,s,r,o,c);else return u;return h},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var r=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var h=s._soundById(o[c]);if(h)if(typeof t=="number")h._stereo=t,h._pos=[t,0,0],h._node&&(h._pannerAttr.panningModel="equalpower",(!h._panner||!h._panner.pan)&&e(h,r),r==="spatial"?typeof h._panner.positionX<"u"?(h._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),h._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):h._panner.setPosition(t,0,0):h._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",h._id);else return h._stereo}return s},Howl.prototype.pos=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,r)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof r>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._pos=[t,i,s],u._node&&((!u._panner||u._panner.pan)&&e(u,"spatial"),typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setPosition(t,i,s)),o._emit("pos",u._id);else return u._pos}return o},Howl.prototype.orientation=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,r)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof r>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._orientation=[t,i,s],u._node&&(u._panner||(u._pos||(u._pos=o._pos||[0,0,-.5]),e(u,"spatial")),typeof u._panner.orientationX<"u"?(u._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setOrientation(t,i,s)),o._emit("orientation",u._id);else return u._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,r,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof r>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],r=parseInt(i[1],10));for(var c=t._getSoundIds(r),h=0;h<c.length;h++)if(o=t._soundById(c[h]),o){var u=o._pannerAttr;u={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:u.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:u.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:u.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:u.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:u.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:u.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:u.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=u.coneInnerAngle,p.coneOuterAngle=u.coneOuterAngle,p.coneOuterGain=u.coneOuterGain,p.distanceModel=u.distanceModel,p.maxDistance=u.maxDistance,p.refDistance=u.refDistance,p.rolloffFactor=u.rolloffFactor,p.panningModel=u.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(rn);const Ja="data:audio/mpeg;base64,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";let $a=class{constructor(){this.sound=new rn.Howl({src:[Ja]})}play(){this.sound.play()}};function el(a,e,t=new f.Box3){if(t.makeEmpty(),!a||!e)return t;a.updateWorldMatrix(!0,!0),e.updateWorldMatrix(!0,!0);const i=new f.Matrix4().copy(e.matrixWorld).invert(),s=new f.Matrix4,r=new f.Vector3;let o=!1;return a.traverseVisible(c=>{var l,d,g;if(!(c!=null&&c.geometry)||!(c!=null&&c.isMesh)||(l=c==null?void 0:c.userData)!=null&&l.ignoreSize)return;const h=c.material;if((d=h==null?void 0:h.userData)!=null&&d.isLOGO)return;const u=c.geometry,p=(g=u==null?void 0:u.getAttribute)==null?void 0:g.call(u,"position");if(!p||p.count<=0)return;s.multiplyMatrices(i,c.matrixWorld);const n=typeof c.getVertexPosition=="function"?c.getVertexPosition.bind(c):void 0;for(let v=0,m=p.count;v<m;v++)n?n(v,r):r.fromBufferAttribute(p,v),r.applyMatrix4(s),t.expandByPoint(r),o=!0}),(!o||t.isEmpty())&&(t.min.set(0,0,0),t.max.set(0,0,0)),t}function tl(a,e,t=new f.Vector3){return el(a,e).getSize(t)}const Re=a=>{var e,t;if(typeof a.destroy=="function"){a.destroy();return}for(;a.children.length>0;)Re(a.children[0]),(e=a.children[0])==null||e.removeFromParent();if(a instanceof f.Mesh)try{(t=a.geometry)==null||t.dispose()}catch{}};function il(a){return new f.Vector3(a[0],a[1],a[2])}function sl(){let a=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(a=4,e=1/window.devicePixelRatio),{tiles:a,renderScale:e}}function rl(a){let e=!1,t=!1,i=!1,s=1/0,r=1/0,o=1/0,c=-1/0,h=-1/0,u=-1/0,p=0,n=0;return a.traverse(d=>{var R,C,P;const g=d;if(!(g!=null&&g.isMesh)||!g.geometry||g.userData.ignoreSize)return;const v=g.material;if((R=v==null?void 0:v.userData)!=null&&R.isLOGO)return;const m=g.geometry,_=(C=m==null?void 0:m.attributes)==null?void 0:C.position;if(!_||_.count<=0)return;const y=g.morphTargetDictionary;y&&(y.width!==void 0&&(t=!0),y.length!==void 0&&(e=!0),y.height!==void 0&&(i=!0));const x=(P=m==null?void 0:m.morphAttributes)==null?void 0:P.position,w=g.morphTargetInfluences,b=[];if(x&&w&&x.length>0){const D=Math.min(x.length,w.length);for(let A=0;A<D;A++){const S=w[A]||0;if(S===0)continue;const L=x[A];b.push({attr:L,weight:S,array:L.array,itemSize:L.itemSize??3})}}const T=_.array,M=_.itemSize??3;if(T&&M>=3){const D=_.count,A=b.length>0;for(let S=0;S<D;S++){const L=S*M;let I=T[L],k=T[L+1],F=T[L+2];if(A)for(let B=0;B<b.length;B++){const N=b[B],W=N.weight;if(N.array&&N.itemSize>=3){const O=S*N.itemSize;I+=N.array[O]*W,k+=N.array[O+1]*W,F+=N.array[O+2]*W}else I+=N.attr.getX(S)*W,k+=N.attr.getY(S)*W,F+=N.attr.getZ(S)*W}I<s&&(s=I),k<r&&(r=k),F<o&&(o=F),I>c&&(c=I),k>h&&(h=k),F>u&&(u=F),k>n&&(n=k);const z=I*I+k*k;z>p&&(p=z)}return}for(let D=0;D<_.count;D++){let A=_.getX(D),S=_.getY(D),L=_.getZ(D);if(b.length>0)for(let k=0;k<b.length;k++){const F=b[k],z=F.weight;A+=F.attr.getX(D)*z,S+=F.attr.getY(D)*z,L+=F.attr.getZ(D)*z}A<s&&(s=A),S<r&&(r=S),L<o&&(o=L),A>c&&(c=A),S>h&&(h=S),L>u&&(u=L),S>n&&(n=S);const I=A*A+S*S;I>p&&(p=I)}}),s===1/0?{box:new f.Box3(new f.Vector3(0,0,0),new f.Vector3(0,0,0)),maxRadius:0,height:0,hasWidth:t,hasLength:e,hasHeight:i}:{box:new f.Box3(new f.Vector3(s,r,o),new f.Vector3(c,h,u)),maxRadius:Math.sqrt(p),height:n,hasWidth:t,hasLength:e,hasHeight:i}}function nl(a,e,t=null){let i=0;return function(){let s=t||this,r=arguments;clearTimeout(i),i=window.setTimeout(function(){a.apply(s,r)},e)}}class ol{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const ar=a=>{var i;let e=0,t=0;if(a.geometry){a.geometry.computeBoundingBox();const s=new f.Vector3;(i=a.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function Ds(){var e;if(typeof navigator>"u")return!1;if(al())return!0;const a=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(a)}function al(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}function te(a){return typeof a=="string"?a.trim():""}const nn=new Pn.GLTFExporter,qe=new Dn.GLTFLoader,Mi=new Rn.DRACOLoader;let gt="./draco/";try{gt=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:yt&&yt.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{gt="./draco/"}typeof window<"u"&&window.dracoPath&&(gt=window.dracoPath);Mi.setDecoderConfig({type:"wasm"});Mi.setDecoderPath(gt.endsWith("/")?gt:`${gt}/`);Mi.preload();qe.setDRACOLoader(Mi);const ll=new Ln.DRACOExporter,lr=[115,103,108,98];function cl(a,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),r=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const h=new Uint8Array(a),u=r.length+o.length+c.length+s.length+h.length,p=new Uint8Array(u);let n=0;return p.set(r,n),n+=r.length,p.set(o,n),n+=o.length,p.set(c,n),n+=c.length,p.set(s,n),n+=s.length,p.set(h,n),p.buffer}function hl(a){const e=new Uint8Array(a.slice(0,4));let t=!0;for(let n=0;n<lr.length;n++)if(e[n]!==lr[n]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(a,4,2).getUint16(0,!1),o=new DataView(a,6,4).getUint32(0,!1),c=new Uint8Array(a.slice(10,10+o)),h=new TextDecoder().decode(c),u=JSON.parse(h),p=a.slice(10+o);return{version:s,jsonDescription:u,glbContent:p}}class Ht{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const r=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=r.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const h=os(c.glbContent,"model/gltf-binary"),u=await qe.loadAsync(h);URL.revokeObjectURL(h),c.glbContent=void 0,c.glb=u.scene,c.scene=u.scene,c.animations=u.animations,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const r=os(s.glbContent,"model/gltf-binary");console.log(r);const o=await qe.loadAsync(r);return URL.revokeObjectURL(r),s.glbContent=void 0,s.glb=o.scene,s.scene=o.scene,s.animations=o.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return hl(e)}clear(){[...this.cache.values()]}}const ul=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px;background:#0066ff1a;border-color:#06f}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,fl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",cr={name:"",isMobile:!1},dl={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ct(a){return a==null?"":String(a).replace(/[&<>"']/g,e=>dl[e])}function hr(...a){return a.filter(Boolean).join(" ")}class on extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...cr,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...cr,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("can-install"):i.classList.remove("can-install");return}this._canInstall!==t&&(this._canInstall=t,this.scheduleRender())}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){e?i.classList.add("filled"):i.classList.remove("filled");return}this._filled!==t&&(this._filled=t,this.scheduleRender())}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12,i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");if(i){i.style.width=i.style.height=`${e}px`;return}this._size!==t&&(this._size=t,this.scheduleRender())}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=hr("slot-item-container",this._props.isMobile&&"is-mobile"),t=hr("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(n=>{const l=Ct(n);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(n=>!this._functions.includes(n)),r=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3706
|
+
*/(function(){HowlerGlobal.prototype._pos=[0,0,0],HowlerGlobal.prototype._orientation=[0,0,-1,0,1,0],HowlerGlobal.prototype.stereo=function(t){var i=this;if(!i.ctx||!i.ctx.listener)return i;for(var s=i._howls.length-1;s>=0;s--)i._howls[s].stereo(t);return i},HowlerGlobal.prototype.pos=function(t,i,s){var r=this;if(!r.ctx||!r.ctx.listener)return r;if(i=typeof i!="number"?r._pos[1]:i,s=typeof s!="number"?r._pos[2]:s,typeof t=="number")r._pos=[t,i,s],typeof r.ctx.listener.positionX<"u"?(r.ctx.listener.positionX.setTargetAtTime(r._pos[0],Howler.ctx.currentTime,.1),r.ctx.listener.positionY.setTargetAtTime(r._pos[1],Howler.ctx.currentTime,.1),r.ctx.listener.positionZ.setTargetAtTime(r._pos[2],Howler.ctx.currentTime,.1)):r.ctx.listener.setPosition(r._pos[0],r._pos[1],r._pos[2]);else return r._pos;return r},HowlerGlobal.prototype.orientation=function(t,i,s,r,o,c){var h=this;if(!h.ctx||!h.ctx.listener)return h;var u=h._orientation;if(i=typeof i!="number"?u[1]:i,s=typeof s!="number"?u[2]:s,r=typeof r!="number"?u[3]:r,o=typeof o!="number"?u[4]:o,c=typeof c!="number"?u[5]:c,typeof t=="number")h._orientation=[t,i,s,r,o,c],typeof h.ctx.listener.forwardX<"u"?(h.ctx.listener.forwardX.setTargetAtTime(t,Howler.ctx.currentTime,.1),h.ctx.listener.forwardY.setTargetAtTime(i,Howler.ctx.currentTime,.1),h.ctx.listener.forwardZ.setTargetAtTime(s,Howler.ctx.currentTime,.1),h.ctx.listener.upX.setTargetAtTime(r,Howler.ctx.currentTime,.1),h.ctx.listener.upY.setTargetAtTime(o,Howler.ctx.currentTime,.1),h.ctx.listener.upZ.setTargetAtTime(c,Howler.ctx.currentTime,.1)):h.ctx.listener.setOrientation(t,i,s,r,o,c);else return u;return h},Howl.prototype.init=function(t){return function(i){var s=this;return s._orientation=i.orientation||[1,0,0],s._stereo=i.stereo||null,s._pos=i.pos||null,s._pannerAttr={coneInnerAngle:typeof i.coneInnerAngle<"u"?i.coneInnerAngle:360,coneOuterAngle:typeof i.coneOuterAngle<"u"?i.coneOuterAngle:360,coneOuterGain:typeof i.coneOuterGain<"u"?i.coneOuterGain:0,distanceModel:typeof i.distanceModel<"u"?i.distanceModel:"inverse",maxDistance:typeof i.maxDistance<"u"?i.maxDistance:1e4,panningModel:typeof i.panningModel<"u"?i.panningModel:"HRTF",refDistance:typeof i.refDistance<"u"?i.refDistance:1,rolloffFactor:typeof i.rolloffFactor<"u"?i.rolloffFactor:1},s._onstereo=i.onstereo?[{fn:i.onstereo}]:[],s._onpos=i.onpos?[{fn:i.onpos}]:[],s._onorientation=i.onorientation?[{fn:i.onorientation}]:[],t.call(this,i)}}(Howl.prototype.init),Howl.prototype.stereo=function(t,i){var s=this;if(!s._webAudio)return s;if(s._state!=="loaded")return s._queue.push({event:"stereo",action:function(){s.stereo(t,i)}}),s;var r=typeof Howler.ctx.createStereoPanner>"u"?"spatial":"stereo";if(typeof i>"u")if(typeof t=="number")s._stereo=t,s._pos=[t,0,0];else return s._stereo;for(var o=s._getSoundIds(i),c=0;c<o.length;c++){var h=s._soundById(o[c]);if(h)if(typeof t=="number")h._stereo=t,h._pos=[t,0,0],h._node&&(h._pannerAttr.panningModel="equalpower",(!h._panner||!h._panner.pan)&&e(h,r),r==="spatial"?typeof h._panner.positionX<"u"?(h._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),h._panner.positionY.setValueAtTime(0,Howler.ctx.currentTime),h._panner.positionZ.setValueAtTime(0,Howler.ctx.currentTime)):h._panner.setPosition(t,0,0):h._panner.pan.setValueAtTime(t,Howler.ctx.currentTime)),s._emit("stereo",h._id);else return h._stereo}return s},Howl.prototype.pos=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"pos",action:function(){o.pos(t,i,s,r)}}),o;if(i=typeof i!="number"?0:i,s=typeof s!="number"?-.5:s,typeof r>"u")if(typeof t=="number")o._pos=[t,i,s];else return o._pos;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._pos=[t,i,s],u._node&&((!u._panner||u._panner.pan)&&e(u,"spatial"),typeof u._panner.positionX<"u"?(u._panner.positionX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.positionY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.positionZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setPosition(t,i,s)),o._emit("pos",u._id);else return u._pos}return o},Howl.prototype.orientation=function(t,i,s,r){var o=this;if(!o._webAudio)return o;if(o._state!=="loaded")return o._queue.push({event:"orientation",action:function(){o.orientation(t,i,s,r)}}),o;if(i=typeof i!="number"?o._orientation[1]:i,s=typeof s!="number"?o._orientation[2]:s,typeof r>"u")if(typeof t=="number")o._orientation=[t,i,s];else return o._orientation;for(var c=o._getSoundIds(r),h=0;h<c.length;h++){var u=o._soundById(c[h]);if(u)if(typeof t=="number")u._orientation=[t,i,s],u._node&&(u._panner||(u._pos||(u._pos=o._pos||[0,0,-.5]),e(u,"spatial")),typeof u._panner.orientationX<"u"?(u._panner.orientationX.setValueAtTime(t,Howler.ctx.currentTime),u._panner.orientationY.setValueAtTime(i,Howler.ctx.currentTime),u._panner.orientationZ.setValueAtTime(s,Howler.ctx.currentTime)):u._panner.setOrientation(t,i,s)),o._emit("orientation",u._id);else return u._orientation}return o},Howl.prototype.pannerAttr=function(){var t=this,i=arguments,s,r,o;if(!t._webAudio)return t;if(i.length===0)return t._pannerAttr;if(i.length===1)if(typeof i[0]=="object")s=i[0],typeof r>"u"&&(s.pannerAttr||(s.pannerAttr={coneInnerAngle:s.coneInnerAngle,coneOuterAngle:s.coneOuterAngle,coneOuterGain:s.coneOuterGain,distanceModel:s.distanceModel,maxDistance:s.maxDistance,refDistance:s.refDistance,rolloffFactor:s.rolloffFactor,panningModel:s.panningModel}),t._pannerAttr={coneInnerAngle:typeof s.pannerAttr.coneInnerAngle<"u"?s.pannerAttr.coneInnerAngle:t._coneInnerAngle,coneOuterAngle:typeof s.pannerAttr.coneOuterAngle<"u"?s.pannerAttr.coneOuterAngle:t._coneOuterAngle,coneOuterGain:typeof s.pannerAttr.coneOuterGain<"u"?s.pannerAttr.coneOuterGain:t._coneOuterGain,distanceModel:typeof s.pannerAttr.distanceModel<"u"?s.pannerAttr.distanceModel:t._distanceModel,maxDistance:typeof s.pannerAttr.maxDistance<"u"?s.pannerAttr.maxDistance:t._maxDistance,refDistance:typeof s.pannerAttr.refDistance<"u"?s.pannerAttr.refDistance:t._refDistance,rolloffFactor:typeof s.pannerAttr.rolloffFactor<"u"?s.pannerAttr.rolloffFactor:t._rolloffFactor,panningModel:typeof s.pannerAttr.panningModel<"u"?s.pannerAttr.panningModel:t._panningModel});else return o=t._soundById(parseInt(i[0],10)),o?o._pannerAttr:t._pannerAttr;else i.length===2&&(s=i[0],r=parseInt(i[1],10));for(var c=t._getSoundIds(r),h=0;h<c.length;h++)if(o=t._soundById(c[h]),o){var u=o._pannerAttr;u={coneInnerAngle:typeof s.coneInnerAngle<"u"?s.coneInnerAngle:u.coneInnerAngle,coneOuterAngle:typeof s.coneOuterAngle<"u"?s.coneOuterAngle:u.coneOuterAngle,coneOuterGain:typeof s.coneOuterGain<"u"?s.coneOuterGain:u.coneOuterGain,distanceModel:typeof s.distanceModel<"u"?s.distanceModel:u.distanceModel,maxDistance:typeof s.maxDistance<"u"?s.maxDistance:u.maxDistance,refDistance:typeof s.refDistance<"u"?s.refDistance:u.refDistance,rolloffFactor:typeof s.rolloffFactor<"u"?s.rolloffFactor:u.rolloffFactor,panningModel:typeof s.panningModel<"u"?s.panningModel:u.panningModel};var p=o._panner;p||(o._pos||(o._pos=t._pos||[0,0,-.5]),e(o,"spatial"),p=o._panner),p.coneInnerAngle=u.coneInnerAngle,p.coneOuterAngle=u.coneOuterAngle,p.coneOuterGain=u.coneOuterGain,p.distanceModel=u.distanceModel,p.maxDistance=u.maxDistance,p.refDistance=u.refDistance,p.rolloffFactor=u.rolloffFactor,p.panningModel=u.panningModel}return t},Sound.prototype.init=function(t){return function(){var i=this,s=i._parent;i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,t.call(this),i._stereo?s.stereo(i._stereo):i._pos&&s.pos(i._pos[0],i._pos[1],i._pos[2],i._id)}}(Sound.prototype.init),Sound.prototype.reset=function(t){return function(){var i=this,s=i._parent;return i._orientation=s._orientation,i._stereo=s._stereo,i._pos=s._pos,i._pannerAttr=s._pannerAttr,i._stereo?s.stereo(i._stereo):i._pos?s.pos(i._pos[0],i._pos[1],i._pos[2],i._id):i._panner&&(i._panner.disconnect(0),i._panner=void 0,s._refreshBuffer(i)),t.call(this)}}(Sound.prototype.reset);var e=function(t,i){i=i||"spatial",i==="spatial"?(t._panner=Howler.ctx.createPanner(),t._panner.coneInnerAngle=t._pannerAttr.coneInnerAngle,t._panner.coneOuterAngle=t._pannerAttr.coneOuterAngle,t._panner.coneOuterGain=t._pannerAttr.coneOuterGain,t._panner.distanceModel=t._pannerAttr.distanceModel,t._panner.maxDistance=t._pannerAttr.maxDistance,t._panner.refDistance=t._pannerAttr.refDistance,t._panner.rolloffFactor=t._pannerAttr.rolloffFactor,t._panner.panningModel=t._pannerAttr.panningModel,typeof t._panner.positionX<"u"?(t._panner.positionX.setValueAtTime(t._pos[0],Howler.ctx.currentTime),t._panner.positionY.setValueAtTime(t._pos[1],Howler.ctx.currentTime),t._panner.positionZ.setValueAtTime(t._pos[2],Howler.ctx.currentTime)):t._panner.setPosition(t._pos[0],t._pos[1],t._pos[2]),typeof t._panner.orientationX<"u"?(t._panner.orientationX.setValueAtTime(t._orientation[0],Howler.ctx.currentTime),t._panner.orientationY.setValueAtTime(t._orientation[1],Howler.ctx.currentTime),t._panner.orientationZ.setValueAtTime(t._orientation[2],Howler.ctx.currentTime)):t._panner.setOrientation(t._orientation[0],t._orientation[1],t._orientation[2])):(t._panner=Howler.ctx.createStereoPanner(),t._panner.pan.setValueAtTime(t._stereo,Howler.ctx.currentTime)),t._panner.connect(t._node),t._paused||t._parent.pause(t._id,!0).play(t._id,!0)}})()})(rn);const Ja="data:audio/mpeg;base64,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";let $a=class{constructor(){this.sound=new rn.Howl({src:[Ja]})}play(){this.sound.play()}};function el(a,e,t=new f.Box3){if(t.makeEmpty(),!a||!e)return t;a.updateWorldMatrix(!0,!0),e.updateWorldMatrix(!0,!0);const i=new f.Matrix4().copy(e.matrixWorld).invert(),s=new f.Matrix4,r=new f.Vector3;let o=!1;return a.traverseVisible(c=>{var l,d,g;if(!(c!=null&&c.geometry)||!(c!=null&&c.isMesh)||(l=c==null?void 0:c.userData)!=null&&l.ignoreSize)return;const h=c.material;if((d=h==null?void 0:h.userData)!=null&&d.isLOGO)return;const u=c.geometry,p=(g=u==null?void 0:u.getAttribute)==null?void 0:g.call(u,"position");if(!p||p.count<=0)return;s.multiplyMatrices(i,c.matrixWorld);const n=typeof c.getVertexPosition=="function"?c.getVertexPosition.bind(c):void 0;for(let v=0,m=p.count;v<m;v++)n?n(v,r):r.fromBufferAttribute(p,v),r.applyMatrix4(s),t.expandByPoint(r),o=!0}),(!o||t.isEmpty())&&(t.min.set(0,0,0),t.max.set(0,0,0)),t}function tl(a,e,t=new f.Vector3){return el(a,e).getSize(t)}const Re=a=>{var e,t;if(typeof a.destroy=="function"){a.destroy();return}for(;a.children.length>0;)Re(a.children[0]),(e=a.children[0])==null||e.removeFromParent();if(a instanceof f.Mesh)try{(t=a.geometry)==null||t.dispose()}catch{}};function il(a){return new f.Vector3(a[0],a[1],a[2])}function sl(){let a=3,e=Math.max(1/window.devicePixelRatio,.5);return window.innerWidth/window.innerHeight<.65&&(a=4,e=1/window.devicePixelRatio),{tiles:a,renderScale:e}}function rl(a){let e=!1,t=!1,i=!1,s=1/0,r=1/0,o=1/0,c=-1/0,h=-1/0,u=-1/0,p=0,n=0;return a.traverse(d=>{var R,C,P;const g=d;if(!(g!=null&&g.isMesh)||!g.geometry||g.userData.ignoreSize)return;const v=g.material;if((R=v==null?void 0:v.userData)!=null&&R.isLOGO)return;const m=g.geometry,_=(C=m==null?void 0:m.attributes)==null?void 0:C.position;if(!_||_.count<=0)return;const y=g.morphTargetDictionary;y&&(y.width!==void 0&&(t=!0),y.length!==void 0&&(e=!0),y.height!==void 0&&(i=!0));const x=(P=m==null?void 0:m.morphAttributes)==null?void 0:P.position,w=g.morphTargetInfluences,b=[];if(x&&w&&x.length>0){const D=Math.min(x.length,w.length);for(let A=0;A<D;A++){const S=w[A]||0;if(S===0)continue;const L=x[A];b.push({attr:L,weight:S,array:L.array,itemSize:L.itemSize??3})}}const T=_.array,M=_.itemSize??3;if(T&&M>=3){const D=_.count,A=b.length>0;for(let S=0;S<D;S++){const L=S*M;let I=T[L],k=T[L+1],F=T[L+2];if(A)for(let B=0;B<b.length;B++){const N=b[B],W=N.weight;if(N.array&&N.itemSize>=3){const O=S*N.itemSize;I+=N.array[O]*W,k+=N.array[O+1]*W,F+=N.array[O+2]*W}else I+=N.attr.getX(S)*W,k+=N.attr.getY(S)*W,F+=N.attr.getZ(S)*W}I<s&&(s=I),k<r&&(r=k),F<o&&(o=F),I>c&&(c=I),k>h&&(h=k),F>u&&(u=F),k>n&&(n=k);const z=I*I+k*k;z>p&&(p=z)}return}for(let D=0;D<_.count;D++){let A=_.getX(D),S=_.getY(D),L=_.getZ(D);if(b.length>0)for(let k=0;k<b.length;k++){const F=b[k],z=F.weight;A+=F.attr.getX(D)*z,S+=F.attr.getY(D)*z,L+=F.attr.getZ(D)*z}A<s&&(s=A),S<r&&(r=S),L<o&&(o=L),A>c&&(c=A),S>h&&(h=S),L>u&&(u=L),S>n&&(n=S);const I=A*A+S*S;I>p&&(p=I)}}),s===1/0?{box:new f.Box3(new f.Vector3(0,0,0),new f.Vector3(0,0,0)),maxRadius:0,height:0,hasWidth:t,hasLength:e,hasHeight:i}:{box:new f.Box3(new f.Vector3(s,r,o),new f.Vector3(c,h,u)),maxRadius:Math.sqrt(p),height:n,hasWidth:t,hasLength:e,hasHeight:i}}function nl(a,e,t=null){let i=0;return function(){let s=t||this,r=arguments;clearTimeout(i),i=window.setTimeout(function(){a.apply(s,r)},e)}}class ol{constructor(e,t,i){this.length=e,this.width=t,this.height=i}}const ar=a=>{var i;let e=0,t=0;if(a.geometry){a.geometry.computeBoundingBox();const s=new f.Vector3;(i=a.geometry.boundingBox)==null||i.getSize(s),s.y?(t=s.y,!s.x&&s.z?e=s.z:s.x&&!s.z?e=s.x:s.x&&s.z&&(e=s.z)):(e=s.z,t=s.x)}return{width:e,height:t}};function Ds(){var e;if(typeof navigator>"u")return!1;if(al())return!0;const a=(e=navigator.userAgent)==null?void 0:e.toLowerCase();return/iphone|ipad|ipod|android|mobile|blackberry|iemobile|opera mini/.test(a)}function al(){try{if(typeof wx<"u"&&wx.getSystemInfo||typeof my<"u"&&my.alert||typeof tt<"u"&&tt.getSystemInfo||typeof swan<"u"&&swan.getSystemInfo)return!0}catch{}return!1}function te(a){return typeof a=="string"?a.trim():""}const nn=new Pn.GLTFExporter,qe=new Dn.GLTFLoader,Mi=new Rn.DRACOLoader;let gt="./draco/";try{gt=new URL("./draco/",typeof document>"u"?require("url").pathToFileURL(__filename).href:yt&&yt.src||new URL("shop-components.cjs",document.baseURI).href).href}catch{gt="./draco/"}typeof window<"u"&&window.dracoPath&&(gt=window.dracoPath);Mi.setDecoderConfig({type:"wasm"});Mi.setDecoderPath(gt.endsWith("/")?gt:`${gt}/`);Mi.preload();qe.setDRACOLoader(Mi);const ll=new Ln.DRACOExporter,lr=[115,103,108,98];function cl(a,e,t){const i=JSON.stringify(e),s=new TextEncoder().encode(i),r=new Uint8Array([115,103,108,98]),o=new Uint8Array(2);o[0]=t>>8,o[1]=t&255;const c=new Uint8Array(4);c[0]=s.length>>24,c[1]=s.length>>16&255,c[2]=s.length>>8&255,c[3]=s.length&255;const h=new Uint8Array(a),u=r.length+o.length+c.length+s.length+h.length,p=new Uint8Array(u);let n=0;return p.set(r,n),n+=r.length,p.set(o,n),n+=o.length,p.set(c,n),n+=c.length,p.set(s,n),n+=s.length,p.set(h,n),p.buffer}function hl(a){const e=new Uint8Array(a.slice(0,4));let t=!0;for(let n=0;n<lr.length;n++)if(e[n]!==lr[n]){t=!1;break}if(!t)throw new Error("Invalid file format");const s=new DataView(a,4,2).getUint16(0,!1),o=new DataView(a,6,4).getUint32(0,!1),c=new Uint8Array(a.slice(10,10+o)),h=new TextDecoder().decode(c),u=JSON.parse(h),p=a.slice(10+o);return{version:s,jsonDescription:u,glbContent:p}}class Ht{constructor(e){this.props=e,this.cache=new Map}load(e,t,i,s){if(this.props.useCache&&this.cache.has(e)){t(this.cache.get(e));return}const r=this;fetch(e).then(o=>{if(!o.ok){s==null||s(new ErrorEvent("NetworkError",{message:"NetworkError for "+e+": "+o.statusText}));return}return o.arrayBuffer()}).then(async o=>{o||s==null||s(new ErrorEvent("Error",{message:"Not a valid sglb file."}));try{const c=r.parse(o);if(!c.glbContent){s==null||s(new ErrorEvent("Error",{message:"No glb content."}));return}const h=os(c.glbContent,"model/gltf-binary"),u=await qe.loadAsync(h);URL.revokeObjectURL(h),c.glbContent=void 0,c.glb=u.scene,c.scene=u.scene,c.animations=u.animations,o=void 0,this.cache.set(e,c),t(c)}catch(c){s==null||s(new ErrorEvent("Error",{message:c==null?void 0:c.message}))}}).catch(o=>{s==null||s(new ErrorEvent("Error",{message:o.message}))})}async loadAsync(e){if(this.props.useCache&&this.cache.has(e))return this.cache.get(e);try{const t=await fetch(e);if(!t.ok)throw new Error(`NetworkError for ${e}: ${t.statusText}`);const i=await t.arrayBuffer();if(!i)throw new Error("Not a valid sglb file.");const s=this.parse(i);if(!s.glbContent)throw new Error("No GLB content.");const r=os(s.glbContent,"model/gltf-binary");console.log(r);const o=await qe.loadAsync(r);return URL.revokeObjectURL(r),s.glbContent=void 0,s.glb=o.scene,s.scene=o.scene,s.animations=o.animations,this.cache.set(e,s),s}catch(t){throw t}}parse(e){return hl(e)}clear(){[...this.cache.values()]}}const ul=`*{box-sizing:border-box}.slot-item-container.is-mobile .main{pointer-events:none;border-width:1px;opacity:.8}.slot-item-container.is-mobile .main.focus{width:18px!important;height:18px!important;border-width:2px;opacity:1}.slot-item-container.is-mobile .main.focus.filled{border-color:#00ff95;border-radius:50%}.slot-item-container.is-mobile .main.filled{opacity:1;border-width:1px;width:14px!important;height:14px!important;background-image:none;border-radius:50%}.slot-item-container.is-mobile .main.to-be-installed{opacity:1;pointer-events:auto;width:38px!important;height:38px!important;border-color:#000;border-width:1px;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cg%3e%3cg%3e%3cpath%20d='M20,10.75L0,10.75L0,9.25L20,9.25L20,10.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%20transform='matrix(0,1,1,0,10,-10)'%3e%3cpath%20d='M30,0.75L10,0.75L10,-0.75L30,-0.75L30,0.75Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:20px auto;background-repeat:no-repeat;background-position:center;background-color:#fff9}.slot-item-container.is-mobile .main.to-be-installed+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container.is-mobile .main.to-be-installed.filled{opacity:1;border-width:2px;width:18px!important;height:18px!important;background-image:none;border-radius:50%;border-color:#00ff95}.slot-item-container.is-mobile .main.to-be-installed.to-be-replaced{opacity:1;border-width:1px;pointer-events:auto;width:38px!important;height:38px!important;border-radius:50%;background-image:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='40'%20height='40'%20viewBox='0%200%2040%2040'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_014299'%3e%3crect%20x='0'%20y='0'%20width='40'%20height='40'%20rx='20'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_014299)'%3e%3cg%3e%3cg%3e%3cpath%20d='M31.695414,17L26.009501,10.74549544L24.899591,11.75450456L28.304586,15.5L8.75,15.5L8.75,17L31.695414,17Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.3045862,23L13.9904997,29.2545042L15.10041,28.2454953L11.6954139,24.5L31.25,24.5L31.25,23L8.3045862,23Z'%20fill-rule='evenodd'%20fill='%23000000'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e");background-size:38px auto;border-color:#000}.slot-item-container.is-mobile .info{left:100%;margin-top:0;margin-left:4px}.slot-item-container.is-mobile .info .name-wrapper{margin-top:0;border-radius:0;background:#000;color:#fff}.slot-item-container.is-mobile .info>img{display:none}.slot-item-container .main{pointer-events:auto;cursor:pointer;font-size:12px;color:#fff;width:22px;height:22px;background:#fff0;border:1.5px solid #fff;border-radius:0;transition:background .2s,width .14s,height .14s,border .14s}.slot-item-container .main.disable{cursor:not-allowed}.slot-item-container .main.drag-over{border-color:red}.slot-item-container .main.can-install{position:relative;width:44px;height:44px}.slot-item-container .main.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.selected{border-width:4px}.slot-item-container .main.selected+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus{border-color:#000}.slot-item-container .main.focus+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .main.focus.filled{border-color:#00ff95;border-radius:50%}.slot-item-container .main.has-error{border-color:red}.slot-item-container .main.hidden{display:none}.slot-item-container .main.hidden+.info{display:none}.slot-item-container .main:after{pointer-events:none;content:attr(data-name);transition:all .2s .3s;opacity:0;position:absolute;left:50%;bottom:100%;transform:translate3d(-50%,5px,0);white-space:nowrap;font-size:12px;color:#000;padding:2px 8px;border-radius:2px;background:#fff}.slot-item-container .main:hover{background:#ffffff80}.slot-item-container .main:hover+.info{pointer-events:auto;overflow:visible;width:auto}.slot-item-container .name{position:relative}.slot-item-container .name-wrapper{margin-top:-10px;white-space:nowrap;font-size:12px;color:#fff;padding:2px 8px;background:#000}.slot-item-container .functions-wrapper{z-index:20000;position:absolute;left:0;top:100%}.slot-item-container .functions-wrapper>.functions{display:inline-block;min-width:100px;padding:6px 0;border-left:1px solid #00ff95;border-radius:0 2px 2px 0;background:#0003;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px)}.slot-item-container .functions-wrapper>.functions .btn-add{cursor:pointer;padding:2px 0;margin:0 8px;display:flex;justify-content:center;align-content:center;align-items:center;border:1px dashed #eee;font-size:12px;color:#eee;border-radius:2px;-webkit-backdrop-filter:none;backdrop-filter:none;background:#00050a80}.slot-item-container .functions-wrapper>.functions .btn-add.btn-not-allowed{cursor:not-allowed}.slot-item-container .functions-wrapper>.functions .function{display:flex;justify-content:space-between;white-space:nowrap;margin-bottom:6px;padding:0 8px;font-size:12px;color:#fff}.slot-item-container .functions-wrapper>.functions .function span{margin-right:4px}.slot-item-container .functions-wrapper>.functions .function .btn-remove{pointer-events:none;opacity:0;cursor:pointer;align-self:center;margin-right:0;height:14px;width:14px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAACnSURBVEiJxZaxFcMgDETPTuUtWCWTM4pZAq5RojRpnOfEyEKxSnh3HySeBEhNjZJJTRgUG89GyZWilbKOgJCaKmWtFG2UvFnwQr56jYAcengg3dozELPGIjh96x6hu26/DIa9vD0jq/nUA3nikQEkAOW9nACUGbf7skxlX2mIj1Ob0jK76QdxbYpGFNlk3rPnNndDQltFaLMLbdehAyd8ZP5l6Ed+W17xG7oN9QkytAAAAABJRU5ErkJggg==) center no-repeat;background-size:10px 10px}.slot-item-container .functions-wrapper>.functions .function:hover .btn-remove{pointer-events:auto;opacity:1;transform:scale(1.2)}.slot-item-container .device-name{position:relative;margin:2px 0;display:flex;min-width:120px;align-items:center;align-content:center;justify-content:space-between;white-space:nowrap;height:30px;padding:0 8px;font-size:14px;font-weight:700;color:#000;background:#fff}.slot-item-container .device-name .device-logo{margin-left:-8px;margin-right:4px;width:30px;height:30px;object-fit:contain}.slot-item-container .device-name span{display:block;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;max-width:250px}.slot-item-container .device-name .btn-close{margin-left:8px;cursor:pointer;height:20px;width:20px;background:url("data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%3e%3cdefs%3e%3cclipPath%20id='master_svg0_504_017509'%3e%3crect%20x='0'%20y='0'%20width='20'%20height='20'%20rx='0'/%3e%3c/clipPath%3e%3c/defs%3e%3cg%20clip-path='url(%23master_svg0_504_017509)'%3e%3cg%3e%3cpath%20d='M4.375,16.875L4.375,4.375L15.625,4.375L15.625,16.875L4.375,16.875ZM14.375,5.625L5.625,5.625L5.625,15.625L14.375,15.625L14.375,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M8.125,12.1875L8.125,8.125L9.375,8.125L9.375,12.1875L8.125,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M10.625,12.1875L10.625,8.125L11.875,8.125L11.875,12.1875L10.625,12.1875Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M16.875,5.625L3.125,5.625L3.125,4.375L16.875,4.375L16.875,5.625Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3cg%3e%3cpath%20d='M6.4446528999999995,5.625L13.545177899999999,5.625L11.8665838,2.5L8.15767372,2.5L6.4446528999999995,5.625ZM11.4548223,4.3749999L8.5553472,4.3749999L8.8979512,3.75L11.1191032,3.75L11.4548223,4.3749999Z'%20fill-rule='evenodd'%20fill='%23999999'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/svg%3e") center no-repeat;background-size:100% auto}.slot-item-container .device-name.empty{color:#000c;font-weight:400}.slot-item-container .device-name.empty .btn-close{display:none}.slot-item-container .device-name.empty:before{height:0}.slot-item-container .all-functions{opacity:0;pointer-events:none;min-width:80px;position:absolute;left:-10px;margin-left:100%;bottom:0;padding:6px 0;background:#fff;transition:all .3s}.slot-item-container .all-functions.show{opacity:1;pointer-events:auto;left:16px}.slot-item-container .all-functions label{margin-left:8px;margin-bottom:20px;color:#444e69;font-size:14px}.slot-item-container .all-functions .btn-close{cursor:pointer;position:absolute;right:7px;top:7px;height:16px;width:16px;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAB4SURBVDiNpZPLEYAgDAUXe6MuoK4UpwdBwQkQJDcyb9+QnxORCOC9jyxE4Y78DiWxAIcmISKnxaSrtZhMNSOB+ZeacAS7ngl3k1JOBSBpk1INPib0YHjH+Du2S1DhlSZOYbPJ1iLtrLKrG2a9yJopYzTD8Jx+ArgAylOzjm1WpDwAAAAASUVORK5CYII=) center no-repeat;background-size:10px 10px}.slot-item-container .all-functions .functions{display:inline-block;max-height:200px;overflow-x:hidden;overflow-y:auto}.slot-item-container .all-functions .functions::-webkit-scrollbar{width:4px}.slot-item-container .all-functions .functions::-webkit-scrollbar-track{background-color:#fff}.slot-item-container .all-functions .functions::-webkit-scrollbar-thumb{background:#787878;border-radius:25px}.slot-item-container .all-functions .function{display:flex;justify-content:space-between;white-space:nowrap;padding:5px 10px;font-size:12px;color:#787878}.slot-item-container .all-functions .function span{display:flex;align-content:center;align-items:center;margin-right:4px}.slot-item-container .all-functions .function:hover{background:#444e6933}.slot-item-container .all-functions .btn-add{cursor:pointer;width:16px;font-size:16px;text-align:center;font-style:normal}.slot-item-container .info{overflow:hidden;margin-left:-2px;margin-top:-19px;position:absolute;left:100%;top:50%;transform:translateY(-50%);width:0;display:flex;align-items:flex-start;transition:all .3s}.slot-item-container .info>img{flex:0 0 auto;width:53px;height:29px}`,fl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGsAAAA7CAYAAAB8MXT7AAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAGTSURBVHic7dxLbQNBEIThnigADGEhxAwcBoZgCIZgBoZgCIZgCIaQMIgZVC4daw/xXPLoqdX/3fbW0milUtfutMCdpCkiLhEx1U6CLkkvkt4k7atnQYekfR7US/Us6JB0yIOaqmfBA5JWks6SrhzUwCRN+TYdq2dBx+ygDtWzoEPSNg9qVz0LOmZBgsQ3sqUkvufqAf6SpFVEnCPiFhHr1tqteCR8hyBhYrY6OlTPgo5cHX1I2lbPgo6lBInFk3Rc+uroqXqAn8ogcc3H19bae+U8eIDEZ0LSJoMEZeHIWB2ZIPEZoCw0QVlogsRnYlYWsjoaGUHCRK6OOKiRfa2OMvWtqufBAwQJE5SFJmZl4aZ6FnSQ+Azk6mjxZeFv+/fycfbDWrTW1pSFgyLxmcjVEWXh6CgLTZD4DMzKwguro4ERJEywOjIhaUdZaIAgYYKy0ABloQkSnwlxKZUHcSmVBxKfgVwdnSgLB8d35iZIfCYoC01QFpog8Y3rftFWrotO+cilVKMiSJigLDSS30hQFhr4BEcKZN0LNhDxAAAAAElFTkSuQmCC",cr={name:"",isMobile:!1},dl={"&":"&","<":"<",">":">",'"':""","'":"'"};function Ct(a){return a==null?"":String(a).replace(/[&<>"']/g,e=>dl[e])}function hr(...a){return a.filter(Boolean).join(" ")}class on extends HTMLElement{constructor(e){super(),this._size=12,this._showDialog=!1,this._selected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._hasError=!1,this._canInstall=!1,this._hide=!1,this._disable=!1,this._filled=!1,this._allFunctions=[],this._functions=[],this._deviceName="",this._deviceLogo="",this._renderQueued=!1,this._needsRender=!0,this.attachShadow({mode:"open"}),this._props={...cr,...e??{}},this.handleShadowClick=this.handleShadowClick.bind(this),this.shadowRoot.addEventListener("click",this.handleShadowClick),this.render()}connectedCallback(){this._needsRender&&(this._needsRender=!1,this.render())}get props(){return this._props}set props(e){this._props={...cr,...e},this.scheduleRender()}get slot(){return this._slot}set slot(e){this._slot=e,this.scheduleRender()}get selected(){return this._selected}set selected(e){const t=!!e;this._selected!==t&&(this._selected=t,this.scheduleRender())}get focused(){return this._focused}set focused(e){const t=!!e;this._focused!==t&&(this._focused=t,this.scheduleRender())}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){const t=!!e;this._toBeInstalled!==t&&(this._toBeInstalled=t,this.scheduleRender())}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){const t=!!e;this._toBeReplaced!==t&&(this._toBeReplaced=t,this.scheduleRender())}get hasError(){return this._hasError}set hasError(e){const t=!!e;this._hasError!==t&&(this._hasError=t,this.scheduleRender())}get canInstall(){return this._canInstall}set canInstall(e){var s;const t=!!e;if(this._canInstall===t)return;this._canInstall=t;const i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");i?i.classList.toggle("can-install",t):this.scheduleRender()}get hide(){return this._hide}set hide(e){const t=!!e;this._hide!==t&&(this._hide=t,this.scheduleRender())}get disable(){return this._disable}set disable(e){const t=!!e;this._disable!==t&&(this._disable=t,this.scheduleRender())}get filled(){return this._filled}set filled(e){var s;const t=!!e;if(this._filled===t)return;this._filled=t;const i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");i?i.classList.toggle("filled",t):this.scheduleRender()}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._allFunctions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get functions(){return[...this._functions]}set functions(e){this._functions=Array.isArray(e)?[...e]:[],this.hasMoreFunctions||(this._showDialog=!1),this.scheduleRender()}get deviceName(){return this._deviceName}set deviceName(e){this._deviceName=e??"",this.scheduleRender()}get deviceLogo(){return this._deviceLogo}set deviceLogo(e){this._deviceLogo=e??"",this.scheduleRender()}get hasMoreFunctions(){return this._allFunctions.some(e=>!this._functions.includes(e))}setSize(e=12){var s;const t=Number.isFinite(e)?Number(e):12;this._size=t;const i=(s=this.shadowRoot)==null?void 0:s.querySelector(".main");i?i.style.width=i.style.height=`${t}px`:this.scheduleRender()}removeDevice(){var e,t;this._showDialog=!1,this.scheduleRender(),(t=(e=this._props).onRemove)==null||t.call(e)}addFunction(e){this.dispatchEvent(new CustomEvent("function-added",{detail:e}))}scheduleRender(){if(!this.isConnected){this._needsRender=!0;return}this._renderQueued||(this._renderQueued=!0,queueMicrotask(()=>{this._renderQueued=!1,this.render()}))}render(){var p;if(!this.shadowRoot)return;const e=hr("slot-item-container",this._props.isMobile&&"is-mobile"),t=hr("main",this._selected&&"selected",this._focused&&"focus",this._toBeInstalled&&"to-be-installed",this._toBeReplaced&&"to-be-replaced",this._hasError&&"has-error",this._canInstall&&"can-install",this._hide&&"hidden",this._disable&&"disable",this._filled&&"filled"),i=this._functions.map(n=>{const l=Ct(n);return`<div class="function" data-function="${l}"><span>${l}</span><i class="btn btn-remove" data-action="remove-function" data-function="${l}"></i></div>`}).join(""),s=this._allFunctions.filter(n=>!this._functions.includes(n)),r=this._allFunctions.length?`<div class="functions">${i}${`<div class="btn btn-add ${this.hasMoreFunctions?"":"btn-not-allowed"}" data-action="toggle-dialog">+添加</div>`}</div>`:"",o=s.length?`<div class="all-functions ${this._showDialog?"show":""}">
|
|
3707
3707
|
<label>添加功能<i class="btn btn-close" data-action="toggle-dialog"></i></label>
|
|
3708
3708
|
<div class="functions">
|
|
3709
3709
|
${s.map(n=>{const l=Ct(n);return`<div class="function"><span>${l}</span><i class="btn btn-add" data-action="add-function" data-function="${l}">+</i></div>`}).join("")}
|
|
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else r.texture_lod=0}};le=new WeakMap,Ce=new WeakMap,Ti=new
|
|
|
3728
3728
|
</div>
|
|
3729
3729
|
</div>
|
|
3730
3730
|
</div>
|
|
3731
|
-
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const r=i.getAttribute("data-function");r&&this.dispatchEvent(new CustomEvent("function-removed",{detail:r}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const r=i.getAttribute("data-function");r&&(this.dispatchEvent(new CustomEvent("function-added",{detail:r})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",on);const J={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class ls extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new Ke,this._slotContainer=new f.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new f.Vector3,this._wrapper=new f.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),t.setAttribute("data-ui-type","slot"),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new on({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot()}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(J.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var r;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(r=i.dataTransfer)==null?void 0:r.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(J.ON_DROP,this)}catch(c){this._emitter.emit(J.ON_DROP_ERROR,c)}}else this._emitter.emit(J.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const r=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*r}}}async loadGlb(e){const i=await new Ht({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Ht({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(r=>{r.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),s.traverse(r=>{r.name.startsWith("Slot")&&this._bracketSlots.push(r),r.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(r=>{r.add(i)})}else this.clearSlot(),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._currentDeivceLoaded=i,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1),this._emitter.emit(J.ON_DEVICE_REPLACED,i)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._emitter.emit(J.ON_DEVICE_DELETED,this._currentDeivceLoaded),this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),Re(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._currentDeivceLoaded=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(J.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(J.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(J.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(J.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),Re(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new f.Vector2(parseFloat(i[1]),parseFloat(i[2])),r=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(o=34,c=60,h=60),r<h){let u=(h-r)*1+o;r<20&&(u=c),u>c&&(u=c),this._slotUI.setSize(u)}else this._slotUI.setSize(o)}clone(e){return new f.Group}}class pl extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=Ds(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const r="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(h=this.onPointMove)==null||h.call(this)}),this._text.addEventListener("pointerleave",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(h=this.onPointLeave)==null||h.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class yi extends f.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new pl(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e,t;(e=this._line.geometry)==null||e.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line.computeLineDistances(),(t=this._line2.geometry)==null||t.dispose(),this._line2.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line2.computeLineDistances()}update(e,t,i=0){var d,g;(d=this._line.geometry)==null||d.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,r=new f.Vector3().subVectors(t,e).normalize();let o;Math.abs(r.z)>Math.abs(r.x)&&Math.abs(r.z)>Math.abs(r.y)?o=new f.Vector3(-r.y,r.x,0):Math.abs(r.y)>Math.abs(r.x)?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0),o.length()<.001&&(Math.abs(r.x)<.9?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0)),o.normalize();const c=new f.Vector3().addVectors(e,o.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),u=new f.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,u,p]),this._line2.computeLineDistances();const n=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(n*1e3).toFixed(0)} mm`:this._text.text=`${(n*1e3).toFixed(0)} mm`;const l=new f.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>Re(e)),this.removeFromParent()}}class an extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new ml(""),this._line=new yi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new Er.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new f.RingGeometry(e,e+.003,128),this._box.material=new f.MeshBasicMaterial({color:"#666",side:f.DoubleSide}),this._arc.geometry=new es.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new kr.LineMaterial({color:"#eee",linewidth:2,resolution:new f.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new f.RingGeometry(e,e+.003,128),this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new f.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let h=i-this._lastAngle;h>Math.PI?h-=2*Math.PI:h<-Math.PI&&(h+=2*Math.PI),this._accumulatedAngle+=h}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),r=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,r,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],r=t-e,o=Math.max(128,Math.floor(Math.abs(r)/(Math.PI/128))),c=r/o;for(let u=0;u<=o;u++){const p=e+u*c,n=Math.cos(p),l=Math.sin(p);s.push(i*n,0,i*l)}const h=new es.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class ml extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=Ds();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const gl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",_l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",ur="data:image/png;base64,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",vl="data:image/png;base64,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";class fr extends Ae.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this.isController=!0,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let n=(Date.now()-this._startAt)/200;n>4&&(n=4);let l=this._initial+.005*n*this._direction;if(l>this.props.max||l<this.props.min){this.mechanism&&(l<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):l>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=l,!this.mechanism)return;this.mechanism.position.setZ(l),this._emitter.emit("change",l)}},i.setAttribute("data-ui-type","mechanism");const s=Ds();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(n=>{n.name===e.userData.target.name&&(this.mechanism=n)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const r=n=>{n.stopPropagation()},o=n=>{n.preventDefault(),n.stopPropagation()},c={capture:!1,passive:!0},h={capture:!1,passive:!1};["pointerdown","pointerup","pointermove","pointercancel","click","dblclick","contextmenu","mousemove"].forEach(n=>{i.addEventListener(n,r,c)}),["wheel","dragenter","dragover","dragleave","drop"].forEach(n=>{i.addEventListener(n,o,h)});const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.transform="translateX(-50%) rotate(-180deg)",u.style.marginBottom="5px",u.style.width=u.style.height=s?"34px":"44px",u.style.background=`url(${ur}) center no-repeat`,u.style.backgroundSize="100% auto",u.setAttribute("data-direction","up"),u.style.transition="all .2s";const p=document.createElement("div");if(p.style.position="absolute",p.style.left="0",p.style.transform="translateX(-50%)",u.style.bottom=p.style.top="8px",p.style.width=p.style.height=u.style.width,p.style.background=`url(${ur}) center no-repeat`,p.style.backgroundSize="100% auto",p.style.transition="all .2s",p.setAttribute("data-direction","down"),Array.from([u,p]).forEach(n=>{s||n.addEventListener("mousemove",()=>{n.style.filter="invert(100%)"}),n.addEventListener("mouseleave",()=>{n.style.filter=""}),n.addEventListener("pointerdown",()=>{this.mechanism&&(n.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=n.getAttribute("data-direction")==="up"?1:-1,this._update())}),n.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""}),n.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:n,rotateDuration:l,rotateStep:d,rotateMax:g,rotateMin:v}=e.userData;let m;if(n&&(t.traverse(_=>{_.name===n.name&&(m=_)}),m)){const _=document.createElement("div");_.style.background=`url(${vl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.position="absolute",_.style.top="-50%",_.style.left="-50%",_.style.width=s?"140px":"160px",_.style.height=s?"70px":"80px",_.style.transform="translateX(-50%) translateY(-50%)",i.append(_);const y=document.createElement("div");y.style.background=`url(${_l}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","left"),i.append(y);const x=document.createElement("div");x.style.background=`url(${gl}) center no-repeat`,x.style.backgroundSize="100% auto",x.style.width=x.style.height=s?"20px":"26px",x.style.position="absolute",y.style.left=x.style.right=s?"62px":"69px",x.style.top="0",x.style.transform="translateY(-50%)",x.style.marginBottom="5px",x.setAttribute("data-direction","right"),i.append(x),Array.from([y,x]).forEach(w=>{s||w.addEventListener("mousemove",()=>{w.style.filter="invert(100%)"}),w.addEventListener("mouseleave",()=>{w.style.filter=""}),w.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;w.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=w.getAttribute("data-direction")==="left"?1:-1;let b=d/180*Math.PI*this._direction+m.rotation.z;b>g/180*Math.PI?b=g/180*Math.PI:b<v/180*Math.PI&&(b=v/180*Math.PI),this._timer=new bi(m.rotation).to({z:b}).duration(l).start(),this._update()}),w.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),w.style.filter=""}),w.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),w.style.filter=""})})}}i.append(u,p),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof Ae.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof Ae.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class yl extends En.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new Ke,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new f.Vector2,this._targetSize=new f.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=h=>{const{pageX:u,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(u,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=h=>{if(!this._mouseStart.x)return;const{pageX:u,pageY:p}=h;let n=u-this._mouseStart.x,l=n+this._targetSize.x;this._sizeFlag==="height"&&(n=p-this._mouseStart.y,l=n*this._direction+this._targetSize.y);const d=l%10;l=l-d,n=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(n=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=h=>{this.endNode.releasePointerCapture(h.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,r=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=r*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class xl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new yi("长:"),this._line12=new yi("宽:"),this._line13=new yi("高:"),this._outline=new an(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof Ae.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof Ae.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:r,hasHeight:o,hasWidth:c}=rl(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=r,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const h=this._box3.min.x,u=this._box3.max.x,p=this._box3.min.z,n=this._box3.max.z,l=this._box3.min.y,d=this._box3.max.y;let g=.2;const v=new f.Vector3(h,d,0),m=new f.Vector3(u,d,0);this._line11.update(v.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const _=new f.Vector3(u,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),_.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(h,d,p),x=new f.Vector3(h,d,n),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class we extends f.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var t,i,s,r,o;(t=this.lineSegments)==null||t.removeFromParent(),(s=(i=this.lineSegments)==null?void 0:i.geometry)==null||s.dispose(),this.lineSegments=void 0,(r=this.geometry)==null||r.dispose();const e=this.material;Array.isArray(e)?e.forEach(c=>{var h;return(h=c==null?void 0:c.dispose)==null?void 0:h.call(c)}):(o=e==null?void 0:e.dispose)==null||o.call(e),this._lineMaterial.dispose(),this.clear()}clearAll(){this.dispose()}clone(e){return new we(this._currentLength,this._currentWidth,this._currentHeight)}_generate(e,t,i){Re(this),this.clear(),this.geometry.dispose(),this.geometry=new f.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new f.EdgesGeometry(this.geometry);this.lineSegments=new f.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const wl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class cs{constructor(e){this._props=e,this.name="",this.transparentTexture=Rs.load(wl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new f.Vector2(1,1),i=new f.Vector2){this.imageUrl=e;let s;if(e){const r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=async()=>{var u;let o=window.devicePixelRatio*2;this._offscreen.width=r.width+o,this._offscreen.height=r.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(r,o/2,o/2,r.width,r.height),s=new f.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=f.SRGBColorSpace,s.wrapS=s.wrapT=f.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const h=this._props.target;h.material&&((u=h.material.map)==null||u.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const r=this._props.target;r.material&&(r.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function Wi(a){return a.type?a.type==="Mesh":a.isMesh}class dr{constructor(e,t){this.links=[],this.target=new f.Vector3,this.targetQuaternion=new f.Quaternion,this.iterations=15,this.minDistance=.001,this.maxStep=.35,this.damping=.35,this.maxAngleDelta=.8,this._restQuaternions=[],this._initialRestQuaternions=[],this._axesLocal=[],this._axisMins=[],this._axisMaxs=[],this._jointStates=[],this._frameAppliedAbsDelta=[],this._jointWeights=[],this._stableFrameCount=0,this._lastFramePosErrSq=1/0,this._lastFrameOriErr=1/0,this._tmpEffectorPos=new f.Vector3,this._tmpTargetPos=new f.Vector3,this._tmpLinkPos=new f.Vector3,this._tmpAxisWorld=new f.Vector3,this._tmpVToEff=new f.Vector3,this._tmpVToTar=new f.Vector3,this._tmpProjE=new f.Vector3,this._tmpProjT=new f.Vector3,this._tmpCross=new f.Vector3,this._tmpEffWorldQ=new f.Quaternion,this._tmpTarWorldQ=new f.Quaternion,this._tmpDirCurP=new f.Vector3,this._tmpDirTarP=new f.Vector3,this._tmpDirCurS=new f.Vector3,this._tmpDirTarS=new f.Vector3,this._tmpAxisQ=new f.Quaternion,this._tmpParentWorldQ=new f.Quaternion,this._tmpLocalBeforeQ=new f.Quaternion,this._tmpWorldBeforeQ=new f.Quaternion,t&&(typeof t.iterations=="number"&&(this.iterations=t.iterations),typeof t.minDistance=="number"&&(this.minDistance=t.minDistance),typeof t.maxStep=="number"&&(this.maxStep=t.maxStep),typeof t.damping=="number"&&(this.damping=t.damping),typeof t.maxAngleDelta=="number"&&(this.maxAngleDelta=t.maxAngleDelta),t.orientation&&(this.orientation=Object.assign({enabled:!1},t.orientation))),this.links=(Array.isArray(e)?e:[]).map(s=>{const r=Array.isArray(s.axes)&&s.axes.length>0?s.axes.map(o=>({axis:o.axis.clone(),min:o.min,max:o.max,value:o.value})):void 0;return{object:s.object,ikTcp:!!s.ikTcp,weight:typeof s.weight=="number"?s.weight:void 0,axes:r}});const i=this.links.map(s=>s.object);this._axesLocal=i.map((s,r)=>this._normalizeAxesForLink(r)),this._axisMins=i.map((s,r)=>this._getAxisMinsForLink(r)),this._axisMaxs=i.map((s,r)=>this._getAxisMaxsForLink(r)),this._restQuaternions=i.map((s,r)=>{var u;const o=s.quaternion.clone(),c=this._axesLocal[r],h=this.links[r];if(c&&c.length>0&&h.axes)for(let p=c.length-1;p>=0;p--){const n=c[p],l=((u=h.axes[p])==null?void 0:u.value)??0;Math.abs(l)>1e-6&&(this._tmpAxisQ.setFromAxisAngle(n,l).invert(),o.multiply(this._tmpAxisQ))}return o}),this._initialRestQuaternions=this._restQuaternions.map(s=>s.clone()),this._jointStates=i.map((s,r)=>{var u;const o=((u=this._axesLocal[r])==null?void 0:u.length)??0,c=this.links[r],h=new Array(o).fill(0);if(c.axes&&c.axes.length>0)for(let p=0;p<o;p++)h[p]=c.axes[p].value??0;return{currentAngle:h[0]??0,prevAngle:h[0]??0,currentAngles:h,prevAngles:[...h]}}),this._frameAppliedAbsDelta=i.map((s,r)=>{var o;return new Array(((o=this._axesLocal[r])==null?void 0:o.length)??0).fill(0)}),this._jointWeights=this._buildJointWeights(t==null?void 0:t.weightProfile)}_buildJointWeights(e){var u;const t=(e==null?void 0:e.root)??.3,i=(e==null?void 0:e.middle)??.68,s=(e==null?void 0:e.end)??1,r=Math.max(1,(e==null?void 0:e.curve)??1),o=this.links.length,c=this.links.some(p=>typeof p.weight=="number"),h=[];for(let p=0;p<o;p++){const n=(u=this.links[p])==null?void 0:u.weight;if(c&&typeof n=="number"&&Number.isFinite(n)){h[p]=Math.max(0,n);continue}if(o<=1){h[p]=Math.max(0,s);continue}const l=p/(o-1),d=l<=.5?Math.pow(l/.5,r):Math.pow((l-.5)/.5,r),g=l<=.5?t+(i-t)*d:i+(s-i)*d;h[p]=Math.max(0,g)}return h}_normalizeAxesForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>{const s=i.axis.clone();return s.lengthSq()>0&&s.normalize(),s}):[]:[]}_getAxisMinsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.min):[]:[]}_getAxisMaxsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.max):[]:[]}_applyLinkAngles(e){var o;const t=(o=this.links[e])==null?void 0:o.object;if(!t)return;const i=this._axesLocal[e],r=this._jointStates[e].currentAngles??[];t.quaternion.copy(this._restQuaternions[e]);for(let c=0;c<i.length;c++){const h=i[c],u=r[c]??0;!h||h.lengthSq()<1e-12||Math.abs(u)<1e-12||(this._tmpAxisQ.setFromAxisAngle(h,u),t.quaternion.multiply(this._tmpAxisQ))}}_getAxisWorld(e,t,i){var u;const s=(u=this.links[e])==null?void 0:u.object;if(!s)return i.set(0,0,0);const r=this._axesLocal[e],o=r==null?void 0:r[t];if(!o||o.lengthSq()<1e-12)return i.set(0,0,0);s.parent?s.parent.getWorldQuaternion(this._tmpParentWorldQ):this._tmpParentWorldQ.identity(),this._tmpLocalBeforeQ.copy(this._restQuaternions[e]);const h=this._jointStates[e].currentAngles??[];for(let p=0;p<t;p++){const n=r[p],l=h[p]??0;!n||n.lengthSq()<1e-12||Math.abs(l)<1e-12||(this._tmpAxisQ.setFromAxisAngle(n,l),this._tmpLocalBeforeQ.multiply(this._tmpAxisQ))}return this._tmpWorldBeforeQ.copy(this._tmpParentWorldQ).multiply(this._tmpLocalBeforeQ),i.copy(o).applyQuaternion(this._tmpWorldBeforeQ).normalize()}resetToInitialPose(){for(let e=0;e<this.links.length;e++){const t=this._initialRestQuaternions[e];t&&(this._restQuaternions[e].copy(t),this.links[e].object.quaternion.copy(t));const i=this._jointStates[e];i.currentAngles&&i.currentAngles.fill(0),i.prevAngles&&i.prevAngles.fill(0),this._frameAppliedAbsDelta[e]&&this._frameAppliedAbsDelta[e].fill(0)}this.links.length>0&&this.links[0].object.updateMatrixWorld(!0)}get restQuaternions(){return this._restQuaternions}_isOrientationEnabled(){var e;return!!((e=this.orientation)!=null&&e.enabled)}_getEndIndices(){var o,c;let e=-1;for(let h=0;h<this.links.length;h++)(o=this.links[h])!=null&&o.ikTcp&&(e=h);e<0&&(e=this.links.length-1);const t=!!((c=this.links[e])!=null&&c.ikTcp),i=t?e:this.links.length-1;let s=-1;for(let h=i;h>=0;h--){const u=this._axesLocal[h];if(u&&u.length>0){s=h;break}}return s<0&&(s=Math.max(0,Math.min(this.links.length-1,i))),{ikTcpIndex:e,effectorJointIndex:s,orientationEvalIndex:t?e:s}}_getOrientationDefaults(){var l,d,g,v,m,_,y;const{effectorJointIndex:e,orientationEvalIndex:t}=this._getEndIndices(),i=e,s=this._getOrientationChainStartIndex(i),r=(((l=this.orientation)==null?void 0:l.forwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),o=(((d=this.orientation)==null?void 0:d.upAxis)??new f.Vector3(0,0,1)).clone().normalize(),c=(((g=this.orientation)==null?void 0:g.targetForwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),h=(((v=this.orientation)==null?void 0:v.targetUpAxis)??new f.Vector3(0,0,1)).clone().normalize(),u=((m=this.orientation)==null?void 0:m.forwardWeight)??1,p=((_=this.orientation)==null?void 0:_.upWeight)??.15,n=((y=this.orientation)==null?void 0:y.minAngle)??Math.PI/180;return{effectorIndex:i,orientationEvalIndex:t,orientationStartIndex:s,effectorForwardAxis:r,effectorUpAxis:o,targetForwardAxis:c,targetUpAxis:h,forwardWeight:u,upWeight:p,minAngle:n}}_orientationErrorAngle(){if(!this._isOrientationEnabled()||this.links.length<1)return 0;const{orientationEvalIndex:e,effectorForwardAxis:t,effectorUpAxis:i,targetForwardAxis:s,targetUpAxis:r,forwardWeight:o,upWeight:c}=this._getOrientationDefaults();this.links[Math.max(0,Math.min(this.links.length-1,e))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(t).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(s).applyQuaternion(this._tmpTarWorldQ).normalize();let u=o*this._angleBetweenNormalized(this._tmpDirCurP,this._tmpDirTarP);return c>0&&(this._tmpDirCurS.copy(i).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(r).applyQuaternion(this._tmpTarWorldQ).normalize(),u+=c*this._angleBetweenNormalized(this._tmpDirCurS,this._tmpDirTarS)),u}_angleBetweenNormalized(e,t){const i=Math.max(-1,Math.min(1,e.dot(t)));this._tmpCross.crossVectors(e,t);const s=this._tmpCross.length();return Math.atan2(s,i)}_getOrientationChainStartIndex(e){let t=0;for(let i=e;i>=0;i--){const s=this._axesLocal[i];if(s&&s.length>0&&(t+=s.length),t>=3)return i}return 0}bindRestPose(){for(let e=0;e<this.links.length;e++){this._restQuaternions[e].copy(this.links[e].object.quaternion);const t=this._jointStates[e];t.currentAngle=0,t.prevAngle=0,t.currentAngles&&t.currentAngles.fill(0),t.prevAngles&&t.prevAngles.fill(0)}}updateJointStateFromCurrentPose(){var e;for(let t=0;t<this.links.length;t++){const i=(e=this.links[t])==null?void 0:e.object;if(!i)continue;const s=this._restQuaternions[t],r=i.quaternion;this._updateLinkAnglesFromQuaternion(t,r,s),this._frameAppliedAbsDelta[t]&&this._frameAppliedAbsDelta[t].fill(0)}}rebindRestPoseWithBase(e){var t;for(let i=0;i<this.links.length;i++){const s=(t=this.links[i])==null?void 0:t.object;if(!s)continue;const r=e[i]??s.quaternion,o=s.quaternion;this._restQuaternions[i].copy(r),this._initialRestQuaternions[i]&&this._initialRestQuaternions[i].copy(r),this._updateLinkAnglesFromQuaternion(i,o,r),this._frameAppliedAbsDelta[i]&&this._frameAppliedAbsDelta[i].fill(0)}}_updateLinkAnglesFromQuaternion(e,t,i){const s=this._axesLocal[e]??[],r=this._jointStates[e];r.currentAngles||(r.currentAngles=new Array(s.length).fill(0)),r.prevAngles||(r.prevAngles=new Array(s.length).fill(0));const o=this._tmpLocalBeforeQ.copy(i).invert().multiply(t),c=this._tmpWorldBeforeQ.copy(o);for(let h=0;h<s.length;h++){const u=s[h];if(!u||u.lengthSq()<1e-12){r.currentAngles[h]=0,r.prevAngles[h]=0;continue}const p=this._tmpVToEff.set(c.x,c.y,c.z).dot(u);this._tmpAxisQ.set(u.x*p,u.y*p,u.z*p,c.w).normalize();const n=2*Math.atan2(p,this._tmpAxisQ.w);r.currentAngles[h]=n,r.prevAngles[h]=n,this._tmpParentWorldQ.copy(this._tmpAxisQ).invert(),c.premultiply(this._tmpParentWorldQ)}r.currentAngle=r.currentAngles[0]??0,r.prevAngle=r.currentAngle}get jointStates(){return this._jointStates}_clamp(e,t,i){return t!==void 0&&e<t&&(e=t),i!==void 0&&e>i&&(e=i),e}_signedAngleAroundAxis(e,t,i){const s=e.dot(i),r=t.dot(i);this._tmpProjE.copy(e).addScaledVector(i,-s),this._tmpProjT.copy(t).addScaledVector(i,-r);const o=this._tmpProjE.lengthSq(),c=this._tmpProjT.lengthSq(),h=1e-10;if(o<h||c<h)return 0;const u=Math.sqrt(o),p=Math.sqrt(c);this._tmpProjE.multiplyScalar(1/u),this._tmpProjT.multiplyScalar(1/p);const n=this._tmpProjE.dot(this._tmpProjT);this._tmpCross.crossVectors(this._tmpProjE,this._tmpProjT);const l=i.dot(this._tmpCross),d=Math.max(-1,Math.min(1,n));let g=Math.atan2(l,d);const v=Math.min(u,p),m=Math.sin(Math.PI/180*4.6),_=Math.sin(Math.PI/180*30);if(v<=m)return 0;if(v<_){const y=(v-m)/(_-m);g*=Math.max(0,Math.min(1,y))}return g}update(){var C,P,D;if(this.links.length<2)return;const{ikTcpIndex:e,effectorJointIndex:t}=this._getEndIndices(),i=this.links[Math.max(0,Math.min(this.links.length-1,e))].object,s=this._tmpEffectorPos,r=this._tmpTargetPos.copy(this.target),o=this._tmpLinkPos,c=this._tmpAxisWorld,h=this._tmpVToEff,u=this._tmpVToTar;let p=this._isOrientationEnabled();const n=p?this._getOrientationDefaults():void 0;i.getWorldPosition(s);const l=this.minDistance*this.minDistance,d=(n==null?void 0:n.minAngle)??Math.PI/180,g=s.distanceToSquared(r),v=p?this._orientationErrorAngle():0,m=g<=l,_=!p||v<=d,y=this.minDistance*2,x=y*y,w=d*2,b=g<=this._lastFramePosErrSq*1.5&&(!p||v<=this._lastFrameOriErr*1.5);if(m&&_||g<=x&&(!p||v<=w))if(b){if(this._stableFrameCount++,this._stableFrameCount>=2){this._lastFramePosErrSq=g,this._lastFrameOriErr=v;return}}else this._stableFrameCount=0;else this._stableFrameCount=0;this._lastFramePosErrSq=g,this._lastFrameOriErr=v;for(let A=0;A<this._frameAppliedAbsDelta.length;A++)this._frameAppliedAbsDelta[A]&&this._frameAppliedAbsDelta[A].fill(0);for(let A=0;A<this._jointStates.length;A++){const S=this._jointStates[A];if(S.prevAngle=S.currentAngle,S.prevAngles&&S.currentAngles)for(let L=0;L<S.currentAngles.length;L++)S.prevAngles[L]=S.currentAngles[L]}let T=g,M=v,R=0;for(let A=0;A<this.iterations;A++){i.getWorldPosition(s);const S=s.distanceToSquared(r),L=S<l,I=p?this._orientationErrorAngle():0,k=!p||I<=d;if(L&&k)break;if(S>=T*.9&&(!p||I>=M*.5)){if(R++,R>=2)break}else R=0;T=S,M=I;let F=0,z=p?t:e===t?t-1:t;z=Math.max(0,Math.min(this.links.length-1,z));for(let B=z;B>=0;B--){const N=this.links[B].object,W=this._axesLocal[B];if(!(!W||W.length===0))for(let O=0;O<W.length;O++){const Q=W[O];if(!Q||Q.lengthSq()<1e-12||(i.getWorldPosition(s),N.getWorldPosition(o),this._getAxisWorld(B,O,c),c.lengthSq()<1e-12))continue;let U=0;if(!(B===t&&e===t)){h.subVectors(s,o),u.subVectors(r,o);const X=h.lengthSq(),ee=u.lengthSq();X>=1e-12&&ee>=1e-12&&(h.multiplyScalar(1/Math.sqrt(X)),u.multiplyScalar(1/Math.sqrt(ee)),U+=this._signedAngleAroundAxis(h,u,c))}if(p&&B>=n.orientationStartIndex&&B<=n.effectorIndex){this.links[Math.max(0,Math.min(this.links.length-1,n.orientationEvalIndex))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(n.effectorForwardAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(n.targetForwardAxis).applyQuaternion(this._tmpTarWorldQ).normalize();const ee=this._signedAngleAroundAxis(this._tmpDirCurP,this._tmpDirTarP,c);let Es=0;n.upWeight>0&&(this._tmpDirCurS.copy(n.effectorUpAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(n.targetUpAxis).applyQuaternion(this._tmpTarWorldQ).normalize(),Es=this._signedAngleAroundAxis(this._tmpDirCurS,this._tmpDirTarS,c)),U+=n.forwardWeight*ee+n.upWeight*Es}if(Math.abs(U)<1e-6)continue;const Ze=Math.max(0,this._jointWeights[B]??1);if(Ze<=0)continue;if(U*=Math.max(0,Math.min(1,this.damping))*Ze,this.maxStep>0){const X=this.maxStep*Ze;if(X<=0)continue;U>X?U=X:U<-X&&(U=-X)}if(this.maxAngleDelta>0){const X=((C=this._frameAppliedAbsDelta[B])==null?void 0:C[O])??0,ee=Math.max(0,this.maxAngleDelta-X);if(ee<=0)continue;U>ee?U=ee:U<-ee&&(U=-ee)}const ve=this._jointStates[B];ve.currentAngles||(ve.currentAngles=new Array(W.length).fill(0));const Nt=(ve.currentAngles[O]??0)+U,jt=(P=this._axisMins[B])==null?void 0:P[O],ye=(D=this._axisMaxs[B])==null?void 0:D[O];U=this._clamp(Nt,jt,ye)-(ve.currentAngles[O]??0),!(Math.abs(U)<1e-9)&&(ve.currentAngles[O]=(ve.currentAngles[O]??0)+U,ve.currentAngle=ve.currentAngles[0]??0,Math.abs(U)>F&&(F=Math.abs(U)),this._frameAppliedAbsDelta[B]&&(this._frameAppliedAbsDelta[B][O]=(this._frameAppliedAbsDelta[B][O]??0)+Math.abs(U)),this._applyLinkAngles(B),N.updateMatrixWorld(!0))}}if(F<1e-5&&S<=l*4&&(!p||I<=d*2))break}}}const Ee=new f.Raycaster,Dt=new f.Vector3,bl=new f.Quaternion,pr=new f.Vector3,mr=new f.Vector3,Ui={type:"change"},gr={type:"mouseDown",mode:null},_r={type:"mouseUp",mode:null},Al={type:"objectChange"},ti=new WeakMap,ii=new WeakMap,Rt=new WeakMap;function Tl(a){if(!this.domElement)return{x:0,y:0,button:a.button};if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-((a.clientY-e.top)/e.height)*2+1,button:a.button}}function si(a,e,t){const i=e.intersectObject(a,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}function Hi(a){return a==="E"?"rotate":a==="XYZ"?"translate":null}class Sl extends f.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("FreeTransformControls: 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)}dispose(){this.traverse(e=>{const t=e;t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}const $=class $ extends f.Object3D{constructor(e){super(),this.picker=new f.Object3D,this.gizmo=new f.Object3D,this.helper=new f.Object3D,this._matMove=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matRing=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matInvisible=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:0}),this._matHelper=new f.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.6}),this._arcSegments=96,this._arcStartAngleOffset=.05,this._moveColorDefault=new f.Color(16777215),this._moveColorActive=new f.Color(0),this._moveOpacityDefault=1,this._moveOpacityRingActive=.5,this._ringColorDefault=new f.Color(16777215),this._ringColorActive=new f.Color(0),this._ringOpacityDefault=1,this._ringOpacityActive=.6,this._ringScale=1,this._ringTargetScale=1.5,this._ringScaleTweening=!1,this._isMoveActive=!1,this._isRingActive=!1,this._isMoveHover=!1,this._isDragging=!1,this._isExpanded=!1,this.controls=e,this._moveMesh=new f.Mesh(new f.CircleGeometry($.MOVE_RADIUS,96),this._matMove),this._moveMesh.rotateX(-Math.PI/2),this._moveMesh.name="XYZ",this._moveMesh.renderOrder=1/0,this._ringMesh=new f.Mesh(new f.TorusGeometry($.RING_RADIUS,$.RING_TUBE,48,96),this._matRing),this._ringMesh.name="E",this._ringMesh.renderOrder=1e3,this._arcGeom=new es.LineGeometry,this._arcPositions=new Float32Array((this._arcSegments+1)*3),this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=0;const t=new kr.LineMaterial({color:16777215,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1});t.resolution.set(window.innerWidth,window.innerHeight),this._arcLine=new Er.Line2(this._arcGeom,t),this._arcLine.renderOrder=1001,this._arcLine.visible=!1,this.gizmo.add(this._ringMesh),this.gizmo.add(this._moveMesh),this.gizmo.add(this._arcLine);const i=new f.Mesh(new f.CircleGeometry($.PICKER_MOVE_RADIUS,32),this._matInvisible);i.name="XYZ",i.renderOrder=1/0;const s=new f.Mesh(new f.TorusGeometry($.RING_RADIUS+.005,$.PICKER_RING_TUBE,8,48),this._matInvisible);s.name="E",s.renderOrder=1/0,this.picker.add(s),this.picker.add(i),this.picker.visible=!1;const r=new f.OctahedronGeometry(.01,2),o=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.7});this._startMarker=new f.Mesh(r,o),this._startMarker.renderOrder=1/0,this._startMarker.visible=!1,this._endMarker=new f.Mesh(r,o),this._endMarker.renderOrder=1/0,this._endMarker.visible=!1,this._deltaGeom=new f.BufferGeometry,this._deltaGeom.setAttribute("position",new f.Float32BufferAttribute(new Float32Array(2*3),3)),this._deltaLine=new f.Line(this._deltaGeom,this._matHelper),this._deltaLine.renderOrder=1/0,this._deltaLine.visible=!1,this.helper.add(this._startMarker),this.helper.add(this._endMarker),this.helper.add(this._deltaLine),this.add(this.gizmo),this.add(this.picker),this.add(this.helper)}get isExpanded(){return this._isExpanded}set isExpanded(e){var s;if(this._isExpanded===e)return;this._isExpanded=e;const t=e?this._ringTargetScale:1;this._ringScaleTweening=!0,(s=this._ringScaleTween)==null||s.stop();const i={scale:this._ringScale};this._ringScaleTween=new oe.Tween(i).to({scale:t},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._ringScale=i.scale}).onStop(()=>{this._ringScaleTweening=!1}).onComplete(()=>{this._ringScaleTweening=!1}).start()}get isRingScaleTweening(){return this._ringScaleTweening}updateMatrixWorld(e){var y,x;const t=this.controls,i=t.axis,s=t.mode,r=t.worldPosition,o=t.size;this._arcLine.material.resolution.set(window.innerWidth,window.innerHeight);const h=(w,b=1)=>{w.position.copy(r),w.scale.set(1,1,1).multiplyScalar(o*b),w.visible=!0};h(this._moveMesh),h(this._ringMesh,this._ringScale),h(this._arcLine,this._ringScale),this.picker.position.copy(r),this.picker.scale.set(1,1,1).multiplyScalar(o);for(const w of this.picker.children)w.quaternion.copy(t.cameraQuaternion),w.scale.set(1,1,1).multiplyScalar(this._ringScale);this._ringMesh.quaternion.copy(t.cameraQuaternion),this._arcLine.quaternion.copy(t.cameraQuaternion),this._moveMesh.lookAt(t.cameraPosition);const u=s==="default"||s==="translate",p=s==="default"||s==="rotate";this._moveMesh.visible=u,this._ringMesh.visible=p;for(const w of this.picker.children)w.name==="XYZ"&&(w.visible=u),w.name==="E"&&(w.visible=p);const n=t.dragging,l=!n&&i==="XYZ",d=!n&&i==="E",g=l||n&&i==="XYZ",v=d||n&&i==="E";if(g!==this._isMoveActive){this._isMoveActive=g;const w=g?this._moveColorActive:this._moveColorDefault;(y=this._moveColorTween)==null||y.stop();const b={r:this._matMove.color.r,g:this._matMove.color.g,b:this._matMove.color.b};this._moveColorTween=new oe.Tween(b).to({r:w.r,g:w.g,b:w.b},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._matMove.color.setRGB(b.r,b.g,b.b)}).start()}if(v!==this._isRingActive){this._isRingActive=v;const w=v?this._ringColorActive:this._ringColorDefault,b=v?this._ringOpacityActive:this._ringOpacityDefault,T=v?this._moveOpacityRingActive:this._moveOpacityDefault;this._matMove.opacity=T,(x=this._ringColorTween)==null||x.stop();const M={r:this._matRing.color.r,g:this._matRing.color.g,b:this._matRing.color.b,opacity:this._matRing.opacity};this._ringColorTween=new oe.Tween(M).to({r:w.r,g:w.g,b:w.b,opacity:b},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._matRing.color.setRGB(M.r,M.g,M.b),this._matRing.opacity=M.opacity}).start()}const m=n;if(this._startMarker.visible=m,this._endMarker.visible=m,this._deltaLine.visible=m,m){this._startMarker.position.copy(t.worldPositionStart),this._endMarker.position.copy(t.worldPosition),this._startMarker.scale.set(1,1,1).multiplyScalar(o),this._endMarker.scale.set(1,1,1).multiplyScalar(o);const w=this._deltaGeom.getAttribute("position");w.setXYZ(0,t.worldPositionStart.x,t.worldPositionStart.y,t.worldPositionStart.z),w.setXYZ(1,t.worldPosition.x,t.worldPosition.y,t.worldPosition.z),w.needsUpdate=!0,this._deltaGeom.computeBoundingSphere()}const _=m&&p&&i==="E";if(this._arcLine.visible=_,_){const w=t.pointStart,b=t.pointEnd;if(w.lengthSq()>1e-12&&b.lengthSq()>1e-12){pr.set(1,0,0).applyQuaternion(t.cameraQuaternion),mr.set(0,1,0).applyQuaternion(t.cameraQuaternion);const T=w.dot(pr),M=w.dot(mr),R=Math.atan2(M,T),C=t.rotationAngle;if(Math.abs(C)<1e-4)this._arcLine.visible=!1,this._arcGeom.instanceCount=0;else{const P=this._arcSegments,D=Math.max(2,Math.min(P,Math.ceil(Math.abs(C)/(Math.PI*2)*P))),A=C/D,S=$.RING_RADIUS,L=Math.sign(C)*this._arcStartAngleOffset;for(let F=0;F<=D;F++){const z=R+L+A*F,B=Math.cos(z)*S,N=Math.sin(z)*S,W=F*3;this._arcPositions[W]=B,this._arcPositions[W+1]=N,this._arcPositions[W+2]=0}for(let F=D+1;F<=P;F++){const z=F*3;this._arcPositions[z]=0,this._arcPositions[z+1]=0,this._arcPositions[z+2]=0}this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=D,this._arcLine.computeLineDistances(),this._arcGeom.computeBoundingSphere();const I=Math.cos(R)*$.RING_RADIUS*this._ringScale,k=Math.sin(R)*$.RING_RADIUS*this._ringScale;Dt.set(I,k,0),Dt.applyQuaternion(t.cameraQuaternion),Dt.multiplyScalar(o),Dt.add(r),this._startMarker.position.copy(Dt)}}else this._arcLine.visible=!1,this._arcGeom.instanceCount=0}else this._arcGeom.instanceCount=0;super.updateMatrixWorld(e)}};$.RING_RADIUS=.18,$.RING_TUBE=.003,$.PICKER_RING_TUBE=.025,$.MOVE_RADIUS=.04,$.PICKER_MOVE_RADIUS=.2;let hs=$;class Ml extends f.Mesh{constructor(){super(new f.PlaneGeometry(1e5,1e5,2,2),new f.MeshBasicMaterial({visible:!1,wireframe:!0,transparent:!0,opacity:.1,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),this.isTransformControlsPlane=!0}updateMatrixWorld(e){const t=this,i=t.dragging?t.worldPositionStart:t.worldPosition;this.position.copy(i),this.quaternion.copy(t.cameraQuaternion),super.updateMatrixWorld(e)}}class Cl extends f.EventDispatcher{constructor(e,t=null){super(),this.domElement=null,this._offset=new f.Vector3,this._startNorm=new f.Vector3,this._endNorm=new f.Vector3,this._cameraScale=new f.Vector3,this._parentPosition=new f.Vector3,this._parentQuaternion=new f.Quaternion,this._parentQuaternionInv=new f.Quaternion,this._parentScale=new f.Vector3,this._worldScaleStart=new f.Vector3,this._worldQuaternionInv=new f.Quaternion,this._worldScale=new f.Vector3,this._positionStart=new f.Vector3,this._quaternionStart=new f.Quaternion,this._scaleStart=new f.Vector3,this._capturePointerId=null,this._captureDocument=null,this._hoverShieldActive=!1;const i=new Sl(this);this._root=i;const s=new hs(this);this._gizmo=s,i.add(s);const r=new Ml;this._plane=r,i.add(r);const o=this;function c(h,u){let p=u;Object.defineProperty(o,h,{get(){return p!==void 0?p:u},set(n){p!==n&&(p=n,r[h]=n,s[h]=n,o.dispatchEvent({type:h+"-changed",value:n}),o.dispatchEvent(Ui))}}),o[h]=u,r[h]=u,s[h]=u}c("camera",e),c("object",void 0),c("enabled",!0),c("depthTest",!0),c("axis",null),c("mode","default"),c("space","world"),c("size",.25),c("dragging",!1),c("gizmoPriority",!0),c("worldPosition",new f.Vector3),c("worldPositionStart",new f.Vector3),c("worldQuaternion",new f.Quaternion),c("worldQuaternionStart",new f.Quaternion),c("cameraPosition",new f.Vector3),c("cameraQuaternion",new f.Quaternion),c("pointStart",new f.Vector3),c("pointEnd",new f.Vector3),c("rotationAxis",new f.Vector3),c("rotationAngle",0),c("eye",new f.Vector3),this._getPointer=Tl.bind(this),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerHover=this._handlePointerHover.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this._onPointerDownCapture=this._handlePointerDownCapture.bind(this),this._onPointerMoveCapture=this._handlePointerMoveCapture.bind(this),this._onPointerUpCapture=this._handlePointerUpCapture.bind(this),this._onMouseMoveCapture=this._handleMouseMoveCapture.bind(this),t!==null&&this.connect(t)}connect(e){this.domElement=e,this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none";const t=this.domElement.ownerDocument;this._captureDocument=t,t.addEventListener("pointerdown",this._onPointerDownCapture,!0),t.addEventListener("pointermove",this._onPointerMoveCapture,!0),t.addEventListener("pointerup",this._onPointerUpCapture,!0),t.addEventListener("mousemove",this._onMouseMoveCapture,!0)}disconnect(){this.domElement&&(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",this._captureDocument&&(this._captureDocument.removeEventListener("pointerdown",this._onPointerDownCapture,!0),this._captureDocument.removeEventListener("pointermove",this._onPointerMoveCapture,!0),this._captureDocument.removeEventListener("pointerup",this._onPointerUpCapture,!0),this._captureDocument.removeEventListener("mousemove",this._onMouseMoveCapture,!0),this._captureDocument=null))}getHelper(){return this._root}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this.dragging=!1,this._setHoverShieldActive(!1),this._root.visible=!1,this}getMode(){return this.mode}setMode(e){this.mode=e,this.axis=null,this.dispatchEvent(Ui)}setSize(e){this.size=e}getRaycaster(){return Ee}_handlePointerHover(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e));break}}_handlePointerDown(e){if(!this.enabled||!this.domElement)return;document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove);const t=this._getPointer(e);this.pointerHover(t),this.pointerDown(t)}_handlePointerMove(e){this.enabled&&this.pointerMove(this._getPointer(e))}_handlePointerUp(e){this.enabled&&this.domElement&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}_setHoverShieldActive(e){if(!this.domElement)return;const t=this.domElement.ownerDocument;if(e){if(this._hoverShieldActive)return;this._hoverShieldActive=!0;const r=Rt.get(t)??0;Rt.set(t,r+1);let o=ii.get(t);o||(o=t.createElement("div"),o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.right="0",o.style.bottom="0",o.style.cursor="grab",o.style.pointerEvents="auto",o.style.background="transparent",o.style.zIndex="2147483647",ii.set(t,o)),o.parentElement||t.body.appendChild(o);return}if(!this._hoverShieldActive)return;this._hoverShieldActive=!1;const i=Rt.get(t)??0,s=Math.max(0,i-1);if(s===0){Rt.delete(t);const r=ii.get(t);r!=null&&r.parentElement&&r.parentElement.removeChild(r),ii.delete(t)}else Rt.set(t,s)}_handlePointerDownCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=e.target;if(t&&(t===this.domElement||this.domElement.contains(t)))return;const i=this._getPointer(e);this.pointerHover(i),!(!this.axis||!this._isAxisAllowed(this.axis))&&i.button===0&&(this._capturePointerId=e.pointerId,document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerDown(i))}_handlePointerMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this._capturePointerId===e.pointerId&&this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerMove(t);return}this.dragging||(this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()))}_handleMouseMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}_handlePointerUpCapture(e){!this.enabled||!this.domElement||!this.gizmoPriority||this._capturePointerId===e.pointerId&&(this._capturePointerId=null,this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerUp(this._getPointer(e)))}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Ee.setFromCamera(e,this.camera);const t=this._gizmo.picker.children.find(h=>h.name==="XYZ"),i=this._gizmo.picker.children.find(h=>h.name==="E"),s=t?si(t,Ee):!1,r=i?si(i,Ee):!1;let o=this._gizmo.isExpanded,c=null;o?r&&!this._gizmo.isRingScaleTweening?c="E":s?c="XYZ":(o=!1,c=null):s&&(o=!0,c="XYZ"),this._gizmo.isExpanded!==o&&(this._gizmo.isExpanded=o),c&&this._isAxisAllowed(c)?this.axis=c:this.axis=null,this._setHoverShieldActive(!!this.axis||this.dragging),this._updateCursor()}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null&&this._isAxisAllowed(this.axis)){e!==null&&Ee.setFromCamera(e,this.camera);const t=si(this._plane,Ee,!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,this._setHoverShieldActive(!0);const i=Hi(this.axis);gr.mode=i,this.dispatchEvent(gr),this._updateCursor()}}pointerMove(e){const t=this.axis,i=this.object;if(i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1||!this._isAxisAllowed(t))return;const s=Hi(t);if(!s)return;e!==null&&Ee.setFromCamera(e,this.camera);const r=si(this._plane,Ee,!0);r&&(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate"?(this._offset.copy(this.pointEnd).sub(this.pointStart),this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart)):s==="rotate"&&(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.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(bl.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize()),this.dispatchEvent(Ui),this.dispatchEvent(Al))}pointerUp(e){if(!(e!==null&&e.button!==0)){if(this.dragging&&this.axis!==null){const t=Hi(this.axis);_r.mode=t,this.dispatchEvent(_r)}this.dragging=!1,this.axis=null,this._setHoverShieldActive(!1),this._updateCursor()}}_updateCursor(){if(!this.domElement)return;const e=ti.get(this.domElement);if(this.dragging){this.domElement.style.cursor="grabbing",ti.set(this.domElement,this);return}if(this.axis){this.domElement.style.cursor="grab",ti.set(this.domElement,this);return}e===this&&(this.domElement.style.cursor="",ti.delete(this.domElement))}_isAxisAllowed(e){return this.mode==="default"?e==="XYZ"||e==="E":this.mode==="translate"?e==="XYZ":this.mode==="rotate"?e==="E":!1}}class Dl{constructor(e,t){var n;this.isController=!0,this._enabled=!0,this._tmpQ=new f.Quaternion,this._tmpContainerQ=new f.Quaternion,this._tmpV=new f.Vector3,this._resetHierarchy=!1,this._defaultPoseQuats=new Map,this._zeroPoseQuats=new Map,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._initialTargetPos=new f.Vector3,this._initialTargetQuat=new f.Quaternion,this._axesHelpers=[],this._showAxes=!1;const{joints:i,container:s,context:r,resetHierarchy:o}=e,c=(Array.isArray(i)?i:[]).map(l=>l.object);this._container=s,this._context=r,this._resetHierarchy=!!o;let h;if(Array.isArray(i))for(let l=0;l<i.length;l++)(n=i[l])!=null&&n.ikTcp&&(h=i[l].object);this._effector=h??c[c.length-1],this._resetHierarchy&&this.setupHierarchy(c),c.forEach(l=>{l&&(this._defaultPoseQuats.has(l.uuid)||this._defaultPoseQuats.set(l.uuid,l.quaternion.clone()))}),this.transformControls=new Cl(t.camera,t.domElement),this.transformControls.addEventListener("dragging-changed",({value:l})=>{this._emitter.emit("dragging-changed",l),l||this.syncTargetToEffector()}),this.transformControls.addEventListener("axis-changed",({value:l})=>{this.transformControls.dragging||(this.targetObject.visible=l==="E")}),this.targetObject=new f.Object3D,this.targetObject.name="ikTarget",this.targetObject.visible=!1,this.targetObject.userData.isIKTarget=!0,this.transformControls.attach(this.targetObject);const u=new f.AxesHelper(.0675);u.material.depthTest=!1,u.material.depthWrite=!1,u.renderOrder=1e3,this.targetObject.add(u),this.syncTargetToEffector(),this._initialTargetPos.copy(this.targetObject.position),this._initialTargetQuat.copy(this.targetObject.quaternion);const p=this.transformControls.getHelper();this._container.add(this.targetObject),this._container.add(p),this.solver=new dr(i,r),this.solver.links.forEach((l,d)=>{const g=l.object;if(g){const v=this.solver.restQuaternions[d];v&&this._zeroPoseQuats.set(g.uuid,v.clone())}}),c.forEach(l=>{const d=new f.AxesHelper(.2);d.visible=!1,l.add(d),this._axesHelpers.push(d)})}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.transformControls.enabled=e,this.transformControls.getHelper().visible=e}get showAxes(){return this._showAxes}set showAxes(e){this._showAxes=e,this._axesHelpers.forEach(t=>t.visible=e)}getEffectorLocalPos(){var t;const e=new f.Vector3;return this._effector&&(this._effector.getWorldPosition(e),(t=this._container)==null||t.worldToLocal(e)),e}getEffectorLocalQuat(){const e=new f.Quaternion;return this._effector&&(this._effector.getWorldQuaternion(e),this._container&&(this._container.getWorldQuaternion(this._tmpContainerQ),this._tmpContainerQ.invert(),e.premultiply(this._tmpContainerQ))),e}setupHierarchy(e){for(let t=0;t<e.length-1;t++){const i=e[t],s=e[t+1];s.parent!==i&&i.attach(s)}}syncTargetToEffector(){this.targetObject.position.copy(this.getEffectorLocalPos()),this.targetObject.quaternion.copy(this.getEffectorLocalQuat()),this.targetObject.updateMatrixWorld(!0)}syncTargetToSolver(){this.solver&&(this.targetObject.getWorldPosition(this._tmpV),this.solver.target.copy(this._tmpV),this.targetObject.getWorldQuaternion(this._tmpQ),this.solver.targetQuaternion.copy(this._tmpQ))}setControlMode(e){this.transformControls.setMode(e)}setOrientation(e){this.solver&&(this.solver.orientation.forwardAxis=e.forwardAxis,this.solver.orientation.upAxis=e.upAxis)}updateJointChain(e){var h;const t=(Array.isArray(e)?e:[]).filter(u=>!!(u!=null&&u.object));if(t.length<2||!this._container)return;const i=t.map(u=>u.object);i.forEach(u=>{u&&(this._defaultPoseQuats.has(u.uuid)||this._defaultPoseQuats.set(u.uuid,u.quaternion.clone()),this._zeroPoseQuats.has(u.uuid)||this._zeroPoseQuats.set(u.uuid,u.quaternion.clone()))});let s;for(let u=0;u<t.length;u++)(h=t[u])!=null&&h.ikTcp&&(s=t[u].object);this._effector=s??i[i.length-1],this._resetHierarchy&&this.setupHierarchy(i);const r=this.solver,o=new dr(t,this._context);r&&(o.iterations=r.iterations,o.minDistance=r.minDistance,o.maxStep=r.maxStep,o.damping=r.damping,o.maxAngleDelta=r.maxAngleDelta,r.orientation&&o.orientation&&Object.assign(o.orientation,r.orientation));const c=o.links.map(u=>this._zeroPoseQuats.get(u.object.uuid));o.rebindRestPoseWithBase(c),this.solver=o,this._axesHelpers.forEach(u=>u.removeFromParent()),this._axesHelpers=[],i.forEach(u=>{const p=new f.AxesHelper(.2);p.visible=this._showAxes,u.add(p),this._axesHelpers.push(p)}),this.syncTargetToEffector(),this.syncTargetToSolver()}update(){!this._enabled||!this.solver||(this.syncTargetToSolver(),this.solver.update())}toggleOrientation(e){this.solver&&(this.solver.orientation.enabled=e)}setSolverContext(e){this.solver&&(typeof e.iterations=="number"&&(this.solver.iterations=e.iterations),typeof e.damping=="number"&&(this.solver.damping=e.damping))}reset(){if(!(!this.solver||!this._container)){for(const e of this.solver.links){const t=e==null?void 0:e.object;if(!t)continue;const i=this._defaultPoseQuats.get(t.uuid);i&&t.quaternion.copy(i)}this._container.updateMatrixWorld(!0),this.solver.updateJointStateFromCurrentPose(),this.syncTargetToEffector(),this.syncTargetToSolver()}}dispose(){this.transformControls.detach(),this.transformControls.dispose(),this.targetObject.removeFromParent(),this._axesHelpers.forEach(e=>e.removeFromParent()),this._axesHelpers=[]}}const Rl=(a,e,t,i={})=>{const s=[],{resetHierarchy:r,onDraggingChanged:o}=i;return a.forEach(c=>{if(!(c!=null&&c.joints)||c.joints.length<2)return;const h=new Dl({joints:c.joints,container:e,context:{orientation:c.orientation},resetHierarchy:r},t);o&&h.addListener("dragging-changed",u=>{o(h,u)}),s.push(h)}),s},Rs=new f.TextureLoader;Rs.crossOrigin="anonymous";class ln extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new Ke,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new f.Clock,this.sizeBox=new xl,this._goodsSize=new ol(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._ikChains=[],this.ikControllers=[],this._ikDraggingControllers=new Set,this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._columnGap=.03,this._rowCount=1,this._rowGap=.01,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new f.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new f.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta();this.ikControllers.forEach(t=>t.update())},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof f.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof ls&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new f.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i;this._goodsSize.length=this._layoutLengthToItemLength(s),this._applyDerivedSizesFromLayoutGoodsLength(s),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}t==="goodsWidth"&&(this._goodsSize.width=i,this._applyDerivedSizesFromGoodsWidth(i),this._columnCount>1&&this.setColumns(this._columnCount,!1),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize())})}_syncRollerGoodsBoxesFromGoodsSize(){const e=h=>{var n;const u=[],p=[...h.children];for(;p.length;){const l=p.pop();if((n=l.userData)!=null&&n.isRollerLevelBox){u.push(l);continue}l.children&&l.children.length&&p.push(...l.children)}return u},t=Math.max(1,this._rowCount||1),i=t>1?this._rowGap:0,s=this._goodsSize.length||0,r=this._getLayoutGoodsLength(s),o=s+i,c=t>0?-r/2+s/2:0;this._rollerLevel.forEach(h=>{e(h).forEach(p=>{const n=p.children.filter(l=>l instanceof we);for(n.forEach(l=>{l.userData.__amrRollerGoodsBox=!0,this.goods.includes(l)||this.goods.push(l)});n.length<t;){const l=new we(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);l.userData.__amrRollerGoodsBox=!0,p.add(l),this.goods.push(l),n.push(l)}for(let l=t;l<n.length;l++){const d=n[l];this.goods=this.goods.filter(g=>g!==d),d.dispose(),d.removeFromParent()}for(let l=0;l<t;l++){const d=n[l];d.updateSize(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height),d.position.y=c+o*l}})})}_syncShelvesFromGoodsSize(){const e=this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"),t=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.forEach(i=>{let s=this._shelfSyncCache.get(i);s||(s={container:void 0,morphMeshes:[],goodsBoxes:[]},i.traverse(c=>{var h;if((h=c.userData)!=null&&h.isShelfContainer&&(s.container=c),c instanceof we&&s.goodsBoxes.push(c),Wi(c)){const u=c,p=u.morphTargetDictionary||{};(Object.prototype.hasOwnProperty.call(p,"goodsWidth")||Object.prototype.hasOwnProperty.call(p,"goodsLength"))&&s.morphMeshes.push(u)}}),this._shelfSyncCache.set(i,s)),s.goodsBoxes.forEach(c=>{c.updateSize(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height)}),s.morphMeshes.forEach(c=>{this.setShapeKeyToMesh(c,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(c,"goodsLength",t)});const r=s.container;if(!r)return;typeof r.userData.__goodsBaseX!="number"&&(r.userData.__goodsBaseX=r.position.x);const o=r.userData.__goodsBaseX;r.position.x=e?o+t/2:o})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const h=await qe.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const u=await new Ht({useCache:!0}).loadAsync(e);i=u.animations||[],s=u.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const r=this._findFirstSkinnedMesh(s),o=this._findFirstSkinnedMesh(this._modelRoot);(!r||!o)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof Li.retargetClip=="function";i.forEach(h=>{let u=h;if(c&&r&&o)try{u=Li.retargetClip(o,r,h)}catch(n){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,n)}this._clips=this._clips.filter(n=>n.name!==u.name),this._clips.push(u);const p=this._mixer.clipAction(u);this._actionsMap.set(u.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await qe.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new Ht({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const r=Li.clone(i);this._generateAmr(r,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new f.Vector2(t.scaleX,t.scaleY),new f.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(r=>{var h;performance.now();let o=t;r.userData[`origin_${e}`]&&(o-=r.userData[`origin_${e}`]);const c=(h=r.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){var i,s;this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(r=>{const o=this._mixer.clipAction(r);this._actionsMap.set(r.name,o)}),this.actions=t.map(r=>r.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shapekeyRules=void 0,e.traverse(r=>{if(r.userData.isShelf&&(this._shelf=r),r.userData.isFork&&(this._fork=r),r.userData.isMast&&r.userData.mastLevel&&this._masts.set(r.userData.mastLevel,r),r.userData.isJack&&(this._jack=r),r.userData.isLift&&(this._lift=r),r.userData.isRollerLevel&&this._rollerLevel.set(r.userData.level||0,r),r.userData.isCenterModel&&(r.visible=this.useCenterModel),r.userData.isSwitch&&r.userData.switchName==="top"&&(this._rollerTop=r),r.userData.isLiftBracket&&(this._liftBrackets.push(r),r.visible=this._useLift),r.userData.isBaffle&&(this._rollerBaffle=r,r.visible=!this._useLift),r.userData.isRoller&&(this._roller=r,this._roller.visible=!1,this._generateRollers()),r.userData.isRollerLevelBox){this._rollerGoodsBox=r;const o=new we(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);r.add(o),this.goods.push(o)}if(Object.keys(r.morphTargetDictionary||{}).forEach(o=>{let c=r.morphTargetInfluences[r.morphTargetDictionary[o]];r.userData[`origin_${o}`]&&(c+=r.userData[`origin_${o}`]),this._shapeKeys.has(o)||this._shapeKeys.set(o,c);const h=this._shapeKeyTargets.get(o);h?h.push(r):this._shapeKeyTargets.set(o,[r])}),r.userData.shapekeyRules&&!this._shapekeyRules)try{typeof r.userData.shapekeyRules=="string"?this._shapekeyRules=JSON.parse(r.userData.shapekeyRules):Array.isArray(r.userData.shapekeyRules)&&(this._shapekeyRules=r.userData.shapekeyRules)}catch(o){console.error(o)}}),e.traverse(r=>{if(r instanceof f.Mesh){if(r.castShadow=!0,r.receiveShadow=!0,r.material)if(Array.isArray(r.material))r.material.forEach(c=>{c.userData.changeColor&&(this.skins.find(h=>h.name===c.userData.name)||this.skins.push(new xs({name:c.userData.name,target:c})))});else{if(r.material.userData.isVideo&&r.material.userData.video){const c=r.material.userData.video;let h=this._videoCache.get(c);h||(h=document.createElement("video"),h.src=c,h.crossOrigin="anonymous",h.loop=!0,h.muted=!0,h.playsInline=!0,h.autoplay=!0,h.preload="auto",this._videoCache.set(c,h)),h.play().catch(()=>{}),r.material.map&&r.material.map.dispose(),r.material.emissiveMap&&r.material.emissiveMap.dispose();const u=new f.VideoTexture(h);u.colorSpace=f.SRGBColorSpace,r.material.map=u,r.material.emissiveMap=u,r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=1,r.material.needsUpdate=!0}if(r.material.userData.isBreathLight&&r.material.emissiveIntensity){r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=2,r.material.toneMapped=!1;const c=1e3,h=new oe.Tween(r.material).to({emissiveIntensity:.2}).easing(oe.Easing.Quintic.InOut).duration(c),u=new oe.Tween(r.material).to({emissiveIntensity:2}).easing(oe.Easing.Quintic.InOut).duration(c);h.onComplete(()=>u.start()),u.onComplete(()=>h.start()),h.start(),this._breathLights.push(h,u)}r.material.userData.changeColor&&(this.skins.find(c=>c.name===r.material.userData.name)||this.skins.push(new xs({name:r.material.userData.name,target:r.material})))}if(r.material)if(Array.isArray(r.material))r.material.forEach(h=>{if(h.userData.isLOGO){r.material.transparent=!0;let u;const p={width:0,height:0};r.material.map&&r.material.map.image&&(p.width=r.material.map.image.width,p.height=r.material.map.image.height,u=as(r.material.map.image)),r.material.needsUpdate=!0;const n=new cs({name:h.userData.name,target:r,size:ar(r),imageSize:p,imageUrl:u});this._logos.push(n)}h.userData.isTransparent&&(h.transparent=!0),this._materialsCache.set(h.uuid,{opacity:h.opacity,transparent:h.transparent,roughness:h.roughness,metalness:h.metalness,color:h.color,mat:h})});else{const c=r.material;if(c.userData.isLOGO){r.material.transparent=!0;let h;const u={width:0,height:0};r.material.map&&r.material.map.image&&(u.width=r.material.map.image.width,u.height=r.material.map.image.height,h=as(r.material.map.image));const p=new cs({name:c.userData.name,target:r,size:ar(r),imageSize:u,imageUrl:h});this._logos.push(p)}c.userData.isTransparent&&(c.transparent=!0),this._materialsCache.set(c.uuid,{opacity:c.opacity,transparent:c.transparent,roughness:c.roughness,metalness:c.metalness,color:c.color,mat:c})}}this.generateController(r,e),this.generateDimension(r,e);const o=this.generateSlot(r,e);o&&this._slots.push(o),r.userData.isOrigin&&Object.keys(r.userData).forEach(h=>{if(h.startsWith("follow_")){const u=h.replace("follow_","");this.shapeKeys.has(u)&&(this.sizeBox.follow=u,this.sizeBox.followOrigin=this._shapeKeys.get(u)||0,this.sizeBox.followScale=r.userData[h])}})}),this.slots.forEach(r=>{r.props.mirrorTarget&&(r.mirrorTarget=this.slots.find(o=>o.props.slot.name===r.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this._buildJointChain(e),this._disposeIkControllers(),this._ikChains.length&&(this.ikControllers=Rl(this._ikChains,this,{camera:(i=this._app)==null?void 0:i.camera,domElement:(s=this._app)==null?void 0:s.renderer.domElement},{onDraggingChanged:(r,o)=>{this._onIkDraggingChanged(r,o)}}),this._ikChains.forEach((r,o)=>{r.controller=this.ikControllers[o]})),this.sizeBox.generate(e),this.sizeBox.show()}_syncIkDraggingState(){this._app&&(this._app.controls.enabled=this._ikDraggingControllers.size===0)}_onIkDraggingChanged(e,t){t?this._ikDraggingControllers.add(e):this._ikDraggingControllers.delete(e),this._syncIkDraggingState()}_disposeIkControllers(){this.ikControllers.forEach(e=>e.dispose()),this.ikControllers=[],this._ikChains.forEach(e=>{e.controller=void 0}),this._ikDraggingControllers.clear(),this._syncIkDraggingState()}_buildJointChain(e){if(this._ikChains=[],!this._ikChains.length){const t=[];e.traverse(i=>{const s=te(i==null?void 0:i.name);s&&s.startsWith("ArmatureRoot")&&t.push(i)}),t.sort((i,s)=>te(i.name).localeCompare(te(s.name))),t.forEach(i=>{const{joints:s,orientation:r}=this._buildIKChainParams(i);if(s.length<2)return;const o={enabled:!0,...r};this._ikChains.push({name:i.name,joints:s,baseLinks:s.slice(),toolLinks:[],orientation:o})})}}_findIkChainByNode(e){var t;for(const i of this._ikChains){if(!((t=i.baseLinks)!=null&&t.length))continue;const s=new Set(i.baseLinks.map(o=>o.object.uuid));let r=e;for(;r;){if(s.has(r.uuid))return i;r=r.parent}}}updateIkJointChainByTool(e,t){if(!e)return;const i=this._findIkChainByNode(e);if(console.log("chain",i),!i||!i.controller||!i.baseLinks||i.baseLinks.length<2)return;const s=(u,p)=>{if(!p.length)return!1;const n=new Set;return u.traverse(l=>n.add(l.uuid)),p.some(l=>n.has(l.uuid))};if(t==="uninstall"){if(!(!!i.toolRootUuid&&e.uuid===i.toolRootUuid||i.toolLinks.length>0&&s(e,i.toolLinks.map(p=>p.object))))return;i.toolLinks=[],i.toolRootUuid=void 0,i.joints=i.baseLinks.slice(),i.controller.updateJointChain(i.joints);return}const{joints:r,orientation:o}=this._buildIKChainParams(e);if(!r.length)return;o&&i.controller.setOrientation(o);const c=!!i.toolRootUuid&&e.uuid===i.toolRootUuid,h=i.toolLinks.length>0;if(c&&h){i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints);return}i.toolRootUuid=e.uuid,i.toolLinks=r,i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints)}_buildIKChainParams(e){var o,c,h,u;if(!e)return{joints:[],orientation:void 0};const t=[];let i;const s=p=>{const n=p.children.find(l=>{var d,g;return((d=l.userData)==null?void 0:d.isJoint)||((g=l.userData)==null?void 0:g.isTcp)});if(n)return n;for(const l of p.children){const d=s(l);if(d)return d}};let r=(o=e.userData)!=null&&o.isJoint||(c=e.userData)!=null&&c.isTcp?e:s(e);for(;r;){if(console.log("cur",r),(h=r.userData)!=null&&h.isJoint){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,axes:p})}else if((u=r.userData)!=null&&u.isTcp){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,ikTcp:!0,axes:p}),i=this._parseIkOrientation(r.userData.ikOrientation)??i;break}r=s(r)}return{joints:t,orientation:i}}_fillInitialRotationValues(e,t){if(!t||!e)return;const i=e.rotation;t.forEach(s=>{const{axis:r}=s;Math.abs(r.x)>.9?s.value=i.x*Math.sign(r.x):Math.abs(r.y)>.9?s.value=i.y*Math.sign(r.y):Math.abs(r.z)>.9&&(s.value=i.z*Math.sign(r.z))})}_axisFromLetter(e){const t=String(e).trim().toUpperCase();if(t==="X")return new f.Vector3(1,0,0);if(t==="Y")return new f.Vector3(0,1,0);if(t==="Z")return new f.Vector3(0,0,1)}_parseIkAxes(e){if(!e||typeof e!="string")return;const t=JSON.parse(e);if(!(!Array.isArray(t)||t.length===0))return t.map(i=>{const s=this._axisFromLetter(i.axis)??new f.Vector3(0,0,0),r=typeof i.min=="number"?f.MathUtils.degToRad(i.min):void 0,o=typeof i.max=="number"?f.MathUtils.degToRad(i.max):void 0;return{axis:s,min:r,max:o}})}_parseIkOrientation(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e,i=this._axisFromLetter(t.forwardAxis),s=this._axisFromLetter(t.upAxis);if(!(!i||!s))return{forwardAxis:i,upAxis:s}}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){const t=this._shapekeyRules;if(console.log(e,t),t&&Array.isArray(t)&&t.length>0){for(const i of t){let s=null,r=-1/0;for(const o of i.configs)e>o.liftHeightThreshold&&o.liftHeightThreshold>r&&(r=o.liftHeightThreshold,s=o.value);s!==null&&this.setShapeKey(i.targetKey,s)}return}this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{te(t.name).toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(r=>{te(r.name).toLowerCase().includes("lift")&&(r.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{te(t.name).toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof we&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this.goodsSize.length)))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}get rows(){return this._rowCount}setRows(e){const t=Math.max(1,Math.floor(e||1));if(t===this._rowCount)return;this._rowCount=t;const i=this._getLayoutGoodsLength(this._goodsSize.length);this.setShapeKey("goodsLength",i,!1),this._applyDerivedSizesFromLayoutGoodsLength(i),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}_getLayoutGoodsLength(e=this._goodsSize.length){const t=Math.max(1,this._rowCount||1),i=e||0;return t<=1?i:i*t+this._rowGap*(t-1)}_layoutLengthToItemLength(e){const t=Math.max(1,this._rowCount||1);if(t<=1)return Math.max(0,e||0);const i=this._rowGap*(t-1);return Math.max(0,((e||0)-i)/t)}setGoodsItemLength(e){this._goodsSize.length=e;const t=this._getLayoutGoodsLength(e);this.setShapeKey("goodsLength",t)}_applyDerivedSizesFromLayoutGoodsLength(e){const t=e+.14-.54;this.setShapeKey("boxLength",t);const i=e+.14;if(this.setShapeKey("topWidth",i),this.isTopInvert){const s=e-.259;this.setShapeKey("length",s)}else this.setShapeKey("width",i)}_applyDerivedSizesFromGoodsLength(e){const t=this._getLayoutGoodsLength(e);this._applyDerivedSizesFromLayoutGoodsLength(t)}_applyDerivedSizesFromGoodsWidth(e){const t=Math.max(1,this._columnCount||1),i=.125,s=t===1?e+i:(e+i)*t+this._columnGap*(t-1),r=s+.06;this.setShapeKey("boxWidth",r);const o=s+.085;if(this.setShapeKey("topLength",o),this.isTopInvert){const c=s+.485;this.setShapeKey("width",c)}else this.setShapeKey("length",o)}setColumns(e,t=!0){const i=Math.max(1,Math.floor(e||1));this._columnCount=i,this._rollerLevel.forEach(s=>{const r=s.children.filter(d=>{var g;return(g=d.userData)==null?void 0:g.isRollerLevelBox}),o=r.length>0?(Math.min(...r.map(d=>d.position.x))+Math.max(...r.map(d=>d.position.x)))/2:0;s.children.filter(d=>{var g,v;return((g=d.userData)==null?void 0:g.isRollerLevelBox)&&((v=d.userData)==null?void 0:v.cloned)}).forEach(d=>s.remove(d));const c=s.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned)||s.children.find(d=>d.userData.isRollerLevelBox);if(!c)return;const h=tl(c,s,new f.Vector3),u=this._columnGap,n=h.x+u,l=(i-1)*n/2;c.position.x=o-l;for(let d=1;d<i;d++){const g=c.clone(!0);g.userData.cloned=!0,this._stripRollerInstances(g),this.regenerateShapeKeyNode(g),g.position.x=o-l+d*n,s.add(g)}}),t&&this._applyDerivedSizesFromGoodsWidth(this.goodsSize.width),this._pruneShapeKeyTargets(),this.setShapeKey("goodsWidth",this._goodsSize.width,!1),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this._goodsSize.length),!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}get levels(){return this._levelCount}setLevels(e){var o;const t=Math.max(1,Math.floor(e||1));this._levelCount=t;const i=this._rollerLevel.size,s=t-i,r=this._rollerLevel.get(0);if(s>0&&r){for(let h=i;h<t;h++){const u=r.clone(!0);u.visible=!0,this._stripRollerInstances(u),u.position.z=r.position.z+.2*h,u.userData.level=h,this._rollerLevel.set(h,u),(o=r.parent)==null||o.add(u),this.regenerateShapeKeyNode(u),u.traverse(p=>{p instanceof we&&(p.updateSize(this.goodsSize.width,this.goodsSize.length,this.goodsSize.height),this.goods.push(p))})}this._columnCount>1&&this.setColumns(this._columnCount,!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}else for(let c=0;c<i;c++){const h=this._rollerLevel.get(c);h&&(h.visible=c<t)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{Wi(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);s&&s.push(t)})})}_stripRollerInstances(e){const t=[];e.traverse(i=>{var s,r;((s=i==null?void 0:i.userData)!=null&&s.__amrRollerInstance||(r=i==null?void 0:i.userData)!=null&&r.isCloned)&&t.push(i)}),t.forEach(i=>{i.parent&&i.removeFromParent()})}_isInAmrContainer(e){let t=e;for(;t;){if(t===this._container||t===this)return!0;t=t.parent}return!1}_pruneShapeKeyTargets(){this._shapeKeyTargets.forEach((e,t)=>{const i=new Set,s=[];for(const r of e)r&&this._isInAmrContainer(r)&&(i.has(r.uuid)||(i.add(r.uuid),s.push(r)));this._shapeKeyTargets.set(t,s)})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=this._getLayoutGoodsLength(this._goodsSize.length);e=e||.5;const t=.05;let i=.02;const r=e-i,o=t+i;let c=Math.floor(r/o);const h=r%o,u=l=>{var v;const d=[],g=[...l.children];for(;g.length;){const m=g.pop();if((v=m.userData)!=null&&v.isRollerLevelBox){d.push(m);continue}m.children&&m.children.length&&g.push(...m.children)}return d},p=[];this._rollerLevel.forEach(l=>{p.push(...u(l))});let n=!1;if(p.forEach(l=>{const d=[];l.traverse(g=>{var v,m;g!==l&&((v=g==null?void 0:g.userData)!=null&&v.isCloned)&&!((m=g==null?void 0:g.userData)!=null&&m.__amrRollerInstance)&&d.push(g)}),d.forEach(g=>g.removeFromParent()),d.length&&(n=!0)}),n&&this._pruneShapeKeyTargets(),c>0){c>1&&(i+=h/(c+2));const l=t+i,d=-e/2+i+t/2;p.forEach(g=>{let v=this._rollerPools.get(g);for(v||(v=[],this._rollerPools.set(g,v));v.length<c;){const m=this._roller.clone(!0);m.visible=!1,m.userData.__amrRollerInstance=!0,m.userData.isCloned=!0,g.add(m),this.regenerateShapeKeyNode(m),v.push(m)}for(let m=0;m<c;m++){const _=v[m];_.parent!==g&&g.add(_),_.visible=!0,_.position.y=d+l*m}for(let m=c;m<v.length;m++)v[m].visible=!1})}else p.forEach(l=>{const d=this._rollerPools.get(l);d&&d.forEach(g=>g.visible=!1)})}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),e.geometry.translate(0,0,1e-9)}setShelfLevel(e=3){var r;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset,i=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.delete(0),this._shelves.forEach(o=>{Re(o),o.parent&&o.removeFromParent()}),this.goods=this.goods.filter(o=>{var c;return(c=o==null?void 0:o.userData)==null?void 0:c.__amrRollerGoodsBox}),this._shelves.clear(),this._shelves.set(0,this._shelf);for(let o=1;o<e;o++){if(!this._shelf)return;this._shelf.traverse(u=>{Wi(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",i))});const c=this._shelf.clone(!0);c.position.z+=t*o,this._shelves.set(o,c),(r=this._shelf.parent)==null||r.add(c);let h;if(c.traverse(u=>{u.userData.isShelfContainer&&(h=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&h&&(typeof h.userData.__goodsBaseX!="number"&&(h.userData.__goodsBaseX=h.position.x),h.position.x=h.userData.__goodsBaseX+i/2),h){const u=new we(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(u.userData.__amrShelfGoodsBox=!0,h.add(u),this.goods.push(u),o===1){const p=new we(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);p.userData.__amrShelfGoodsBox=!0,p.position.z-=t,h.add(p),this.goods.push(p)}}}const s=this.getShelfMinHeight()||0;this._liftMaxHeight<s&&this.setLiftMaxHeight(s)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new an(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=te(e.userData.target.name),{min:s,max:r}=e.userData;let o;if(!i||(t.traverse(h=>{const u=te(h==null?void 0:h.name);u&&u===i&&(o=h)}),!o))return;const c=new fr({name:"",target:i,default:0,min:s,max:r},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=te(e.userData.target.name),{min:s,max:r}=e.userData;let o;if(!i||(t.traverse(h=>{const u=te(h==null?void 0:h.name);u&&u===i&&(o=h)}),!o))return;const c=new fr({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:r||1},o);e.add(c),this.controllers.push(c),c.addListener("change",()=>{this.ikControllers.forEach(h=>{h.enabled=!1}),clearTimeout(this._ikControllersTimer),this._ikControllersTimer=setTimeout(()=>{this.ikControllers.forEach(h=>{h.enabled=!0,h.syncTargetToEffector()})},100)}),(o.userData.isFork||o.userData.isLift||o.userData.isJack)&&(this._forkMaxHeight=r||1,this._liftMaxHeight=r||1,this._jackMaxHeight=r||1,c.addListener("change",h=>{this.setForkHeight(h),this.setLiftHeight(h),this.setJackHeight(h)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=il(e.userData.startOrigin),r=e.userData.axios;let o,c;if(r==="x"?(o=new f.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):r==="z"?(o=new f.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new f.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(n=>{var d;if(!n.startsWith("target"))return[];const l=te((d=e.userData[n])==null?void 0:d.name);return l?[l]:[]}).length)return;const p=new yl({start:o,end:c,startOrigin:s,axios:r,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const r=te(e.userData.name),o=e.userData.isMirror,c=te((i=e.userData.mirrorSlot)==null?void 0:i.name);if(r){const h=e.userData.holeTarget&&e.userData.holeTarget.name,u=te(h);let p;u&&t.traverse(g=>{const v=te(g==null?void 0:g.name);v&&v===u&&(p=g)});const n=new Map;Object.keys(e.userData).forEach(g=>{if(g.startsWith("follow_")){const v=g.split("_")[1];if(v){let m=e.userData[g];n.set(v,{scale:m,initPos:e.position.clone(),origin:this.shapeKeys.get(v)||0})}}});const l=(s=this._app)==null?void 0:s.props.isMobile,d=new ls({name:r,follows:n,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:l});return d.holeTarget=p,d.addEventListener(J.ON_DROP,g=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),d.addEventListener(J.ON_DEVICE_REPLACED,g=>{g&&this.updateIkJointChainByTool(g,"install")}),d.addEventListener(J.ON_DEVICE_DELETED,g=>{g&&this.updateIkJointChainByTool(g,"uninstall")}),d.addEventListener(J.ON_BEFORE_SELECTED,g=>{this._slots.forEach(v=>{v.selected&&(v.selected=!1)})}),d.addEventListener(J.ON_ERROR_STATE_CHANGE,g=>{var m;if(!this._app)return;const v=(m=this._app)==null?void 0:m._outlinePassError;if(v)if(v.selectedObjects=v.selectedObjects.filter(_=>!!_.parent),g){if(d.device){if(v.selectedObjects.find(y=>{var x;return y.parent===((x=d.device)==null?void 0:x.parent)}))return;v.selectedObjects=[d.device,...v.selectedObjects]}}else d.device&&(v.selectedObjects=v.selectedObjects.filter(_=>{var y;return _.parent!==((y=d.device)==null?void 0:y.parent)}))}),d}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),Re(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._disposeIkControllers(),this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const r=this._currentAction,o=r===s,c=o?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=r&&!o&&r.isRunning();this._actionsMap.forEach(n=>{n!==s&&n!==r&&(n.stopFading(),n.setEffectiveWeight(0),n.stop())});const u=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(u?f.LoopRepeat:f.LoopOnce,u?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!u,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(r.stopFading(),r.enabled=!0,r.setEffectiveWeight(1),r.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(n=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=d=>{var g;d.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,n())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}}const cn=0,Ll=1,Pl=2,vr=2,Gi=1.25,yr=1,Wt=6*4+4+4,Ci=65535,Il=Math.pow(2,-24),Ni=Symbol("SKIP_GENERATION");function El(a){return a.index?a.index.count:a.attributes.position.count}function wt(a){return El(a)/3}function kl(a,e=ArrayBuffer){return a>65535?new Uint32Array(new e(4*a)):new Uint16Array(new e(2*a))}function Fl(a,e){if(!a.index){const t=a.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=kl(t,i);a.setIndex(new f.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function hn(a){const e=wt(a),t=a.drawRange,i=t.start/3,s=(t.start+t.count)/3,r=Math.max(0,i),o=Math.min(e,s)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function un(a){if(!a.groups||!a.groups.length)return hn(a);const e=[],t=new Set,i=a.drawRange,s=i.start/3,r=(i.start+i.count)/3;for(const c of a.groups){const h=c.start/3,u=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(r,u))}const o=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<o.length-1;c++){const h=o[c],u=o[c+1];e.push({offset:Math.floor(h),count:Math.floor(u-h)})}return e}function Bl(a){if(a.groups.length===0)return!1;const e=wt(a),t=un(a).sort((r,o)=>r.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:r})=>s+=r),e!==s}function ji(a,e,t,i,s){let r=1/0,o=1/0,c=1/0,h=-1/0,u=-1/0,p=-1/0,n=1/0,l=1/0,d=1/0,g=-1/0,v=-1/0,m=-1/0;for(let _=e*6,y=(e+t)*6;_<y;_+=6){const x=a[_+0],w=a[_+1],b=x-w,T=x+w;b<r&&(r=b),T>h&&(h=T),x<n&&(n=x),x>g&&(g=x);const M=a[_+2],R=a[_+3],C=M-R,P=M+R;C<o&&(o=C),P>u&&(u=P),M<l&&(l=M),M>v&&(v=M);const D=a[_+4],A=a[_+5],S=D-A,L=D+A;S<c&&(c=S),L>p&&(p=L),D<d&&(d=D),D>m&&(m=D)}i[0]=r,i[1]=o,i[2]=c,i[3]=h,i[4]=u,i[5]=p,s[0]=n,s[1]=l,s[2]=d,s[3]=g,s[4]=v,s[5]=m}function Ol(a,e=null,t=null,i=null){const s=a.attributes.position,r=a.index?a.index.array:null,o=wt(a),c=s.normalized;let h;e===null?(h=new Float32Array(o*6*4),t=0,i=o):(h=e,t=t||0,i=i||o);const u=s.array,p=s.offset||0;let n=3;s.isInterleavedBufferAttribute&&(n=s.data.stride);const l=["getX","getY","getZ"];for(let d=t;d<t+i;d++){const g=d*3,v=d*6;let m=g+0,_=g+1,y=g+2;r&&(m=r[m],_=r[_],y=r[y]),c||(m=m*n+p,_=_*n+p,y=y*n+p);for(let x=0;x<3;x++){let w,b,T;c?(w=s[l[x]](m),b=s[l[x]](_),T=s[l[x]](y)):(w=u[m+x],b=u[_+x],T=u[y+x]);let M=w;b<M&&(M=b),T<M&&(M=T);let R=w;b>R&&(R=b),T>R&&(R=T);const C=(R-M)/2,P=x*2;h[v+P+0]=M+C,h[v+P+1]=C+(Math.abs(M)+C)*Il}}return h}function K(a,e,t){return t.min.x=e[a],t.min.y=e[a+1],t.min.z=e[a+2],t.max.x=e[a+3],t.max.y=e[a+4],t.max.z=e[a+5],t}function xr(a){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=a[i+3]-a[i];s>t&&(t=s,e=i)}return e}function wr(a,e){e.set(a)}function br(a,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=a[r],s=e[r],t[r]=i<s?i:s,i=a[o],s=e[o],t[o]=i>s?i:s}}function ri(a,e,t){for(let i=0;i<3;i++){const s=e[a+2*i],r=e[a+2*i+1],o=s-r,c=s+r;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function Lt(a){const e=a[3]-a[0],t=a[4]-a[1],i=a[5]-a[2];return 2*(e*t+t*i+i*e)}const Se=32,zl=(a,e)=>a.candidate-e.candidate,ke=new Array(Se).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ni=new Float32Array(6);function Vl(a,e,t,i,s,r){let o=-1,c=0;if(r===cn)o=xr(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(r===Ll)o=xr(a),o!==-1&&(c=Wl(t,i,s,o));else if(r===Pl){const h=Lt(a);let u=Gi*s;const p=i*6,n=(i+s)*6;for(let l=0;l<3;l++){const d=e[l],m=(e[l+3]-d)/Se;if(s<Se/4){const _=[...ke];_.length=s;let y=0;for(let w=p;w<n;w+=6,y++){const b=_[y];b.candidate=t[w+2*l],b.count=0;const{bounds:T,leftCacheBounds:M,rightCacheBounds:R}=b;for(let C=0;C<3;C++)R[C]=1/0,R[C+3]=-1/0,M[C]=1/0,M[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;ri(w,t,T)}_.sort(zl);let x=s;for(let w=0;w<x;w++){const b=_[w];for(;w+1<x&&_[w+1].candidate===b.candidate;)_.splice(w+1,1),x--}for(let w=p;w<n;w+=6){const b=t[w+2*l];for(let T=0;T<x;T++){const M=_[T];b>=M.candidate?ri(w,t,M.rightCacheBounds):(ri(w,t,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){const b=_[w],T=b.count,M=s-b.count,R=b.leftCacheBounds,C=b.rightCacheBounds;let P=0;T!==0&&(P=Lt(R)/h);let D=0;M!==0&&(D=Lt(C)/h);const A=yr+Gi*(P*T+D*M);A<u&&(o=l,u=A,c=b.candidate)}}else{for(let x=0;x<Se;x++){const w=ke[x];w.count=0,w.candidate=d+m+x*m;const b=w.bounds;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0}for(let x=p;x<n;x+=6){let T=~~((t[x+2*l]-d)/m);T>=Se&&(T=Se-1);const M=ke[T];M.count++,ri(x,t,M.bounds)}const _=ke[Se-1];wr(_.bounds,_.rightCacheBounds);for(let x=Se-2;x>=0;x--){const w=ke[x],b=ke[x+1];br(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<Se-1;x++){const w=ke[x],b=w.count,T=w.bounds,R=ke[x+1].rightCacheBounds;b!==0&&(y===0?wr(T,ni):br(T,ni,ni)),y+=b;let C=0,P=0;y!==0&&(C=Lt(ni)/h);const D=s-y;D!==0&&(P=Lt(R)/h);const A=yr+Gi*(C*y+P*D);A<u&&(o=l,u=A,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:c}}function Wl(a,e,t,i){let s=0;for(let r=e,o=e+t;r<o;r++)s+=a[r*6+i*2];return s/t}class Qi{constructor(){this.boundingData=new Float32Array(6)}}function Ul(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){for(let p=0;p<3;p++){let n=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=n}for(let p=0;p<6;p++){let n=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=n}o++,c--}else return o}}function Hl(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){let p=a[o];a[o]=a[c],a[c]=p;for(let n=0;n<6;n++){let l=t[o*6+n];t[o*6+n]=t[c*6+n],t[c*6+n]=l}o++,c--}else return o}}function ae(a,e){return e[a+15]===65535}function ce(a,e){return e[a+6]}function he(a,e){return e[a+14]}function ue(a){return a+8}function fe(a,e){return e[a+6]}function fn(a,e){return e[a+7]}let dn,Ot,xi,pn;const Gl=Math.pow(2,32);function us(a){return"count"in a?1:1+us(a.left)+us(a.right)}function Nl(a,e,t){return dn=new Float32Array(t),Ot=new Uint32Array(t),xi=new Uint16Array(t),pn=new Uint8Array(t),fs(a,e)}function fs(a,e){const t=a/4,i=a/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)dn[t+o]=r[o];if(s)if(e.buffer){const o=e.buffer;pn.set(new Uint8Array(o),a);for(let c=a,h=a+o.byteLength;c<h;c+=Wt){const u=c/2;ae(u,xi)||(Ot[c/4+6]+=t)}return a+o.byteLength}else{const o=e.offset,c=e.count;return Ot[t+6]=o,xi[i+14]=c,xi[i+15]=Ci,a+Wt}else{const o=e.left,c=e.right,h=e.splitAxis;let u;if(u=fs(a+Wt,o),u/4>Gl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Ot[t+6]=u/4,u=fs(u,c),Ot[t+7]=h,u}}function jl(a,e){const t=(a.index?a.index.count:a.attributes.position.count)/3,i=t>2**16,s=i?4:2,r=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(r):new Uint16Array(r);for(let c=0,h=o.length;c<h;c++)o[c]=c;return o}function Ql(a,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:c,strategy:h,onProgress:u,indirect:p}=s,n=a._indirectBuffer,l=a.geometry,d=l.index?l.index.array:null,g=p?Hl:Ul,v=wt(l),m=new Float32Array(6);let _=!1;const y=new Qi;return ji(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){u&&u(b/v)}function w(b,T,M,R=null,C=0){if(!_&&C>=r&&(_=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),M<=c||C>=r)return x(T+M),b.offset=T,b.count=M,b;const P=Vl(b.boundingData,R,e,T,M,h);if(P.axis===-1)return x(T+M),b.offset=T,b.count=M,b;const D=g(n,d,e,T,M,P);if(D===T||D===T+M)x(T+M),b.offset=T,b.count=M;else{b.splitAxis=P.axis;const A=new Qi,S=T,L=D-T;b.left=A,ji(e,S,L,A.boundingData,m),w(A,S,L,m,C+1);const I=new Qi,k=D,F=M-L;b.right=I,ji(e,k,F,I.boundingData,m),w(I,k,F,m,C+1)}return b}}function ql(a,e){const t=a.geometry;e.indirect&&(a._indirectBuffer=jl(t,e.useSharedArrayBuffer),Bl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),a._indirectBuffer||Fl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Ol(t),r=e.indirect?hn(t):un(t);a._roots=r.map(o=>{const c=Ql(a,s,o.offset,o.count,e),h=us(c),u=new i(Wt*h);return Nl(0,c,u),u})}class Le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const h=e[r][t];i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const c=t[r],h=e.dot(c);i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Le.prototype.setFromBox=function(){const a=new f.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let u=0;u<=1;u++)for(let p=0;p<=1;p++){a.x=s.x*h+r.x*(1-h),a.y=s.y*u+r.y*(1-u),a.z=s.z*p+r.z*(1-p);const n=t.dot(a);o=Math.min(n,o),c=Math.max(n,c)}this.min=o,this.max=c}}();const Yl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,r,o){const c=s.start,h=a,u=r.start,p=e;t.subVectors(c,u),a.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const n=t.dot(p),l=p.dot(h),d=p.dot(p),g=t.dot(h),m=h.dot(h)*d-l*l;let _,y;m!==0?_=(n*l-g*d)/m:_=0,y=(n+_*l)/d,o.x=_,o.y=y}}(),Ls=function(){const a=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,r,o,c){Yl(s,r,a);let h=a.x,u=a.y;if(h>=0&&h<=1&&u>=0&&u<=1){s.at(h,o),r.at(u,c);return}else if(h>=0&&h<=1){u<0?r.at(0,c):r.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(u>=0&&u<=1){h<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let n;u<0?n=r.start:n=r.end;const l=e,d=t;if(s.closestPointToPoint(n,!0,e),r.closestPointToPoint(p,!0,t),l.distanceToSquared(n)<=d.distanceToSquared(p)){o.copy(l),c.copy(n);return}else{o.copy(p),c.copy(d);return}}}}(),Kl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(r,o){const{radius:c,center:h}=r,{a:u,b:p,c:n}=o;if(i.start=u,i.end=p,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c||(i.start=u,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c)||(i.start=p,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c))return!0;const v=o.getPlane(t);if(Math.abs(v.distanceToPoint(h))<=c){const _=v.projectPoint(h,e);if(o.containsPoint(_))return!0}return!1}}(),Zl=1e-15;function qi(a){return Math.abs(a)<Zl}class _e extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new Le),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return Kl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,c=r[0],h=o[0];this.getNormal(c),h.setFromPoints(c,s);const u=r[1],p=o[1];u.subVectors(e,t),p.setFromPoints(u,s);const n=r[2],l=o[2];n.subVectors(t,i),l.setFromPoints(n,s);const d=r[3],g=o[3];d.subVectors(i,e),g.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}_e.prototype.closestPointToSegment=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,r=null,o=null){const{start:c,end:h}=s,u=this.points;let p,n=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;t.start.copy(u[l]),t.end.copy(u[d]),Ls(t,s,a,e),p=a.distanceToSquared(e),p<n&&(n=p,r&&r.copy(a),o&&o.copy(e))}return this.closestPointToPoint(c,a),p=c.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(c)),this.closestPointToPoint(h,a),p=h.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(h)),Math.sqrt(n)}}();_e.prototype.intersectsTriangle=function(){const a=new _e,e=new Array(3),t=new Array(3),i=new Le,s=new Le,r=new f.Vector3,o=new f.Vector3,c=new f.Vector3,h=new f.Vector3,u=new f.Vector3,p=new f.Line3,n=new f.Line3,l=new f.Line3,d=new f.Vector3;function g(v,m,_){const y=v.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:T,end:M}=p;T.copy(y[b]),M.copy(y[(b+1)%3]),p.delta(o);const R=qi(m.distanceToPoint(T));if(qi(m.normal.dot(o))&&R){_.copy(p),x=2;break}const C=m.intersectLine(p,d);if(!C&&R&&d.copy(T),(C||R)&&!qi(d.distanceTo(M))){if(x<=1)(x===1?_.start:_.end).copy(d),R&&(w=x);else if(x>=2){(w===1?_.start:_.end).copy(d),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,_=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(a.copy(m),a.update(),m=a);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,T=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const P=b[C],D=T[C];if(i.setFromPoints(D,t),P.isSeparated(i))return!1}const M=m.satBounds,R=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const P=M[C],D=R[C];if(i.setFromPoints(D,e),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=T[C];for(let D=0;D<4;D++){const A=R[D];if(r.crossVectors(P,A),i.setFromPoints(r,e),s.setFromPoints(r,t),i.isSeparated(s))return!1}}return _&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}else{const b=g(this,w,n);if(b===1&&m.containsPoint(n.end))return _&&(_.start.copy(n.end),_.end.copy(n.end)),!0;if(b!==2)return!1;const T=g(m,x,l);if(T===1&&this.containsPoint(l.end))return _&&(_.start.copy(l.end),_.end.copy(l.end)),!0;if(T!==2)return!1;if(n.delta(c),l.delta(h),c.dot(h)<0){let S=l.start;l.start=l.end,l.end=S}const M=n.start.dot(c),R=n.end.dot(c),C=l.start.dot(c),P=l.end.dot(c),D=R<C,A=M<P;return M!==P&&C!==R&&D===A?!1:(_&&(u.subVectors(n.start,l.start),u.dot(c)>0?_.start.copy(n.start):_.start.copy(l.start),u.subVectors(n.end,l.end),u.dot(c)<0?_.end.copy(n.end):_.end.copy(l.end)),!0)}}}();_e.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();_e.prototype.distanceToTriangle=function(){const a=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(o,c=null,h=null){const u=c||h?i:null;if(this.intersectsTriangle(o,u))return(c||h)&&(c&&u.getCenter(c),h&&u.getCenter(h)),0;let p=1/0;for(let n=0;n<3;n++){let l;const d=t[n],g=o[d];this.closestPointToPoint(g,a),l=g.distanceToSquared(a),l<p&&(p=l,c&&c.copy(a),h&&h.copy(g));const v=this[d];o.closestPointToPoint(v,a),l=v.distanceToSquared(a),l<p&&(p=l,c&&c.copy(v),h&&h.copy(a))}for(let n=0;n<3;n++){const l=t[n],d=t[(n+1)%3];i.set(this[l],this[d]);for(let g=0;g<3;g++){const v=t[g],m=t[(g+1)%3];s.set(o[v],o[m]),Ls(i,s,a,e);const _=a.distanceToSquared(e);_<p&&(p=_,c&&c.copy(a),h&&h.copy(e))}}return Math.sqrt(p)}}();class ie{constructor(e,t,i){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new Le),this.alignedSatBounds=new Array(3).fill().map(()=>new Le),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}ie.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let u=0;u<=1;u++)for(let p=0;p<=1;p++)for(let n=0;n<=1;n++){const l=1*u|2*p|4*n,d=s[l];d.x=u?i.x:t.x,d.y=p?i.y:t.y,d.z=n?i.z:t.z,d.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,c=s[0];for(let u=0;u<3;u++){const p=o[u],n=r[u],l=1<<u,d=s[l];p.subVectors(c,d),n.setFromPoints(p,s)}const h=this.alignedSatBounds;h[0].setFromPointsField(s,"x"),h[1].setFromPointsField(s,"y"),h[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ie.prototype.intersectsBox=function(){const a=new Le;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(a.min=i.x,a.max=s.x,c[0].isSeparated(a)||(a.min=i.y,a.max=s.y,c[1].isSeparated(a))||(a.min=i.z,a.max=s.z,c[2].isSeparated(a)))return!1;for(let h=0;h<3;h++){const u=o[h],p=r[h];if(a.setFromBox(u,t),p.isSeparated(a))return!1}return!0}}();ie.prototype.intersectsTriangle=function(){const a=new _e,e=new Array(3),t=new Le,i=new Le,s=new f.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(a.copy(o),a.update(),o=a);const c=this.satBounds,h=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const d=c[l],g=h[l];if(t.setFromPoints(g,e),d.isSeparated(t))return!1}const u=o.satBounds,p=o.satAxes,n=this.points;for(let l=0;l<3;l++){const d=u[l],g=p[l];if(t.setFromPoints(g,n),d.isSeparated(t))return!1}for(let l=0;l<3;l++){const d=h[l];for(let g=0;g<4;g++){const v=p[g];if(s.crossVectors(d,v),t.setFromPoints(s,e),i.setFromPoints(s,n),t.isSeparated(i))return!1}}return!0}}();ie.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();ie.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();ie.prototype.distanceToBox=function(){const a=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),i=new f.Vector3,s=new f.Vector3;return function(o,c=0,h=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(h||u)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),h&&h.copy(i),u&&u.copy(s)),0;const p=c*c,n=o.min,l=o.max,d=this.points;let g=1/0;for(let m=0;m<8;m++){const _=d[m];s.copy(_).clamp(n,l);const y=_.distanceToSquared(s);if(y<g&&(g=y,h&&h.copy(_),u&&u.copy(s),y<p))return Math.sqrt(y)}let v=0;for(let m=0;m<3;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=_<<x|y<<w,T=1<<m|_<<x|y<<w,M=d[b],R=d[T];e[v].set(M,R);const P=a[m],D=a[x],A=a[w],S=t[v],L=S.start,I=S.end;L[P]=n[P],L[D]=_?n[D]:l[D],L[A]=y?n[A]:l[D],I[P]=l[P],I[D]=_?n[D]:l[D],I[A]=y?n[A]:l[D],v++}for(let m=0;m<=1;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){s.x=m?l.x:n.x,s.y=_?l.y:n.y,s.z=y?l.z:n.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,h&&h.copy(i),u&&u.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const _=e[m];for(let y=0;y<12;y++){const x=t[y];Ls(_,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,h&&h.copy(i),u&&u.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class Ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Xl extends Ps{constructor(){super(()=>new _e)}}const de=new Xl;class Jl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Y=new Jl;let Ve,pt;const et=[],oi=new Ps(()=>new f.Box3);function $l(a,e,t,i,s,r){Ve=oi.getPrimitive(),pt=oi.getPrimitive(),et.push(Ve,pt),Y.setBuffer(a._roots[e]);const o=ds(0,a.geometry,t,i,s,r);Y.clearBuffer(),oi.releasePrimitive(Ve),oi.releasePrimitive(pt),et.pop(),et.pop();const c=et.length;return c>0&&(pt=et[c-1],Ve=et[c-2]),o}function ds(a,e,t,i,s=null,r=0,o=0){const{float32Array:c,uint16Array:h,uint32Array:u}=Y;let p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);return K(a,c,Ve),i(l,d,!1,o,r+a,Ve)}else{let P=function(A){const{uint16Array:S,uint32Array:L}=Y;let I=A*2;for(;!ae(I,S);)A=ue(A),I=A*2;return ce(A,L)},D=function(A){const{uint16Array:S,uint32Array:L}=Y;let I=A*2;for(;!ae(I,S);)A=fe(A,L),I=A*2;return ce(A,L)+he(I,S)};const l=ue(a),d=fe(a,u);let g=l,v=d,m,_,y,x;if(s&&(y=Ve,x=pt,K(g,c,y),K(v,c,x),m=s(y),_=s(x),_<m)){g=d,v=l;const A=m;m=_,_=A,y=x}y||(y=Ve,K(g,c,y));const w=ae(g*2,h),b=t(y,w,m,o+1,r+g);let T;if(b===vr){const A=P(g),L=D(g)-A;T=i(A,L,!0,o+1,r+g,y)}else T=b&&ds(g,e,t,i,s,r,o+1);if(T)return!0;x=pt,K(v,c,x);const M=ae(v*2,h),R=t(x,M,_,o+1,r+v);let C;if(R===vr){const A=P(v),L=D(v)-A;C=i(A,L,!0,o+1,r+v,x)}else C=R&&ds(v,e,t,i,s,r,o+1);return!!C}}const Pt=new f.Vector3,Yi=new f.Vector3;function ec(a,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let c=1/0,h=null;if(a.shapecast({boundsTraverseOrder:p=>(Pt.copy(e).clamp(p.min,p.max),Pt.distanceToSquared(e)),intersectsBounds:(p,n,l)=>l<c&&l<o,intersectsTriangle:(p,n)=>{p.closestPointToPoint(e,Pt);const l=e.distanceToSquared(Pt);return l<c&&(Yi.copy(Pt),c=l,h=n),l<r}}),c===1/0)return null;const u=Math.sqrt(c);return t.point?t.point.copy(Yi):t.point=Yi.clone(),t.distance=u,t.faceIndex=h,t}const it=new f.Vector3,st=new f.Vector3,rt=new f.Vector3,ai=new f.Vector2,li=new f.Vector2,ci=new f.Vector2,Ar=new f.Vector3,Tr=new f.Vector3,Sr=new f.Vector3,hi=new f.Vector3;function tc(a,e,t,i,s,r,o,c){let h;if(r===f.BackSide?h=a.intersectTriangle(i,t,e,!0,s):h=a.intersectTriangle(e,t,i,r!==f.DoubleSide,s),h===null)return null;const u=a.origin.distanceTo(s);return u<o||u>c?null:{distance:u,point:s.clone()}}function ic(a,e,t,i,s,r,o,c,h,u,p){it.fromBufferAttribute(e,r),st.fromBufferAttribute(e,o),rt.fromBufferAttribute(e,c);const n=tc(a,it,st,rt,hi,h,u,p);if(n){i&&(ai.fromBufferAttribute(i,r),li.fromBufferAttribute(i,o),ci.fromBufferAttribute(i,c),n.uv=f.Triangle.getInterpolation(hi,it,st,rt,ai,li,ci,new f.Vector2)),s&&(ai.fromBufferAttribute(s,r),li.fromBufferAttribute(s,o),ci.fromBufferAttribute(s,c),n.uv1=f.Triangle.getInterpolation(hi,it,st,rt,ai,li,ci,new f.Vector2)),t&&(Ar.fromBufferAttribute(t,r),Tr.fromBufferAttribute(t,o),Sr.fromBufferAttribute(t,c),n.normal=f.Triangle.getInterpolation(hi,it,st,rt,Ar,Tr,Sr,new f.Vector3),n.normal.dot(a.direction)>0&&n.normal.multiplyScalar(-1));const l={a:r,b:o,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(it,st,rt,l.normal),n.face=l,n.faceIndex=r}return n}function Di(a,e,t,i,s,r,o){const c=i*3;let h=c+0,u=c+1,p=c+2;const n=a.index;a.index&&(h=n.getX(h),u=n.getX(u),p=n.getX(p));const{position:l,normal:d,uv:g,uv1:v}=a.attributes,m=ic(t,l,d,g,v,h,u,p,e,r,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Z(a,e,t,i){const s=a.a,r=a.b,o=a.c;let c=e,h=e+1,u=e+2;t&&(c=t.getX(c),h=t.getX(h),u=t.getX(u)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h),o.x=i.getX(u),o.y=i.getY(u),o.z=i.getZ(u)}function sc(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++)Di(h,e,t,p,r,o,c)}function rc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Di(c,e,t,n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function nc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=p,Z(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function oc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Ci){const _=o[l+6],y=c[v+14];let x=1/0,w=1/0,b=1/0,T=-1/0,M=-1/0,R=-1/0;for(let C=3*_,P=3*(_+y);C<P;C++){let D=i[C];const A=s.getX(D),S=s.getY(D),L=s.getZ(D);A<x&&(x=A),A>T&&(T=A),S<w&&(w=S),S>M&&(M=S),L<b&&(b=L),L>R&&(R=L)}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==R?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=R,!0):!1}else{const _=l+8,y=o[l+6],x=_+d,w=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(x),M=e.has(w),b=!T&&!M):(T=!0,M=!0);const R=b||T,C=b||M;let P=!1;R&&(P=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=P||D;if(A)for(let S=0;S<3;S++){const L=_+S,I=y+S,k=h[L],F=h[L+3],z=h[I],B=h[I+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function We(a,e,t,i,s){let r,o,c,h,u,p;const n=1/t.direction.x,l=1/t.direction.y,d=1/t.direction.z,g=t.origin.x,v=t.origin.y,m=t.origin.z;let _=e[a],y=e[a+3],x=e[a+1],w=e[a+3+1],b=e[a+2],T=e[a+3+2];return n>=0?(r=(_-g)*n,o=(y-g)*n):(r=(y-g)*n,o=(_-g)*n),l>=0?(c=(x-v)*l,h=(w-v)*l):(c=(w-v)*l,h=(x-v)*l),r>h||c>o||((c>r||isNaN(r))&&(r=c),(h<o||isNaN(o))&&(o=h),d>=0?(u=(b-m)*d,p=(T-m)*d):(u=(T-m)*d,p=(b-m)*d),r>p||u>o)?!1:((u>r||r!==r)&&(r=u),(p<o||o!==o)&&(o=p),r<=s&&o>=i)}function ac(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++){let l=u?u[p]:p;Di(h,e,t,l,r,o,c)}}function lc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Di(c,e,t,h?h[n]:n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function cc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=t.resolveTriangleIndex(p),Z(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function hc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),ps(0,a,t,i,s,r,o),Y.clearBuffer()}function ps(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);sc(e,t,i,l,d,s,r,o)}else{const l=ue(a);We(l,c,i,r,o)&&ps(l,e,t,i,s,r,o);const d=fe(a,u);We(d,c,i,r,o)&&ps(d,e,t,i,s,r,o)}}const uc=["x","y","z"];function fc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=ms(0,a,t,i,s,r);return Y.clearBuffer(),o}function ms(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(ae(u,c)){const n=ce(a,h),l=he(u,c);return rc(e,t,i,n,l,s,r)}else{const n=fn(a,h),l=uc[n],g=i.direction[l]>=0;let v,m;g?(v=ue(a),m=fe(a,h)):(v=fe(a,h),m=ue(a));const y=We(v,o,i,s,r)?ms(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const w=We(m,o,i,s,r)?ms(m,e,t,i,s,r):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ui=new f.Box3,nt=new _e,ot=new _e,It=new f.Matrix4,Mr=new ie,fi=new ie;function dc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=gs(0,a,t,i);return Y.clearBuffer(),s}function gs(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Mr.set(t.boundingBox.min,t.boundingBox.max,i),s=Mr),ae(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=ce(a,c),m=he(h,o);if(It.copy(i).invert(),t.boundsTree)return K(a,r,fi),fi.matrix.copy(It),fi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>fi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=v*3,w=(m+v)*3;x<w;x+=3)if(Z(ot,x,n,l),ot.needsUpdate=!0,y.intersectsTriangle(ot))return!0;return!1}});for(let _=v*3,y=(m+v)*3;_<y;_+=3){Z(nt,_,n,l),nt.a.applyMatrix4(It),nt.b.applyMatrix4(It),nt.c.applyMatrix4(It),nt.needsUpdate=!0;for(let x=0,w=d.count;x<w;x+=3)if(Z(ot,x,d,g),ot.needsUpdate=!0,nt.intersectsTriangle(ot))return!0}}else{const p=a+8,n=c[a+6];return K(p,r,ui),!!(s.intersectsBox(ui)&&gs(p,e,t,i,s)||(K(n,r,ui),s.intersectsBox(ui)&&gs(n,e,t,i,s)))}}const di=new f.Matrix4,Ki=new ie,Et=new ie,pc=new f.Vector3,mc=new f.Vector3,gc=new f.Vector3,_c=new f.Vector3;function vc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Ki.set(e.boundingBox.min,e.boundingBox.max,t),Ki.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=de.getPrimitive(),d=de.getPrimitive();let g=pc,v=mc,m=null,_=null;s&&(m=gc,_=_c);let y=1/0,x=null,w=null;return di.copy(t).invert(),Et.matrix.copy(di),a.shapecast({boundsTraverseOrder:b=>Ki.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Et.min.copy(b.min),Et.max.copy(b.max),Et.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:R=>Et.distanceToBox(R),intersectsBounds:(R,C,P)=>P<y&&P<o,intersectsRange:(R,C)=>{for(let P=R,D=R+C;P<D;P++){Z(d,3*P,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=b,S=b+T;A<S;A++){Z(l,3*A,u,h),l.needsUpdate=!0;const L=l.distanceToTriangle(d,g,m);if(L<y&&(v.copy(g),_&&_.copy(m),y=L,x=A,w=P),L<r)return!0}}}});{const M=wt(e);for(let R=0,C=M;R<C;R++){Z(d,3*R,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=b,D=b+T;P<D;P++){Z(l,3*P,u,h),l.needsUpdate=!0;const A=l.distanceToTriangle(d,g,m);if(A<y&&(v.copy(g),_&&_.copy(m),y=A,x=P,w=R),A<r)return!0}}}}}),de.releasePrimitive(l),de.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(di),v.applyMatrix4(di),s.distance=v.sub(s.point).length(),s.faceIndex=w),i)}function yc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Ci){const _=o[l+6],y=c[v+14];let x=1/0,w=1/0,b=1/0,T=-1/0,M=-1/0,R=-1/0;for(let C=_,P=_+y;C<P;C++){const D=3*a.resolveTriangleIndex(C);for(let A=0;A<3;A++){let S=D+A;S=i?i[S]:S;const L=s.getX(S),I=s.getY(S),k=s.getZ(S);L<x&&(x=L),L>T&&(T=L),I<w&&(w=I),I>M&&(M=I),k<b&&(b=k),k>R&&(R=k)}}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==R?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=R,!0):!1}else{const _=l+8,y=o[l+6],x=_+d,w=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(x),M=e.has(w),b=!T&&!M):(T=!0,M=!0);const R=b||T,C=b||M;let P=!1;R&&(P=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=P||D;if(A)for(let S=0;S<3;S++){const L=_+S,I=y+S,k=h[L],F=h[L+3],z=h[I],B=h[I+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function xc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),_s(0,a,t,i,s,r,o),Y.clearBuffer()}function _s(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);ac(e,t,i,l,d,s,r,o)}else{const l=ue(a);We(l,c,i,r,o)&&_s(l,e,t,i,s,r,o);const d=fe(a,u);We(d,c,i,r,o)&&_s(d,e,t,i,s,r,o)}}const wc=["x","y","z"];function bc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=vs(0,a,t,i,s,r);return Y.clearBuffer(),o}function vs(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(ae(u,c)){const n=ce(a,h),l=he(u,c);return lc(e,t,i,n,l,s,r)}else{const n=fn(a,h),l=wc[n],g=i.direction[l]>=0;let v,m;g?(v=ue(a),m=fe(a,h)):(v=fe(a,h),m=ue(a));const y=We(v,o,i,s,r)?vs(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const w=We(m,o,i,s,r)?vs(m,e,t,i,s,r):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const pi=new f.Box3,at=new _e,lt=new _e,kt=new f.Matrix4,Cr=new ie,mi=new ie;function Ac(a,e,t,i){Y.setBuffer(a._roots[e]);const s=ys(0,a,t,i);return Y.clearBuffer(),s}function ys(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Cr.set(t.boundingBox.min,t.boundingBox.max,i),s=Cr),ae(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=ce(a,c),m=he(h,o);if(kt.copy(i).invert(),t.boundsTree)return K(a,r,mi),mi.matrix.copy(kt),mi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>mi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=v,w=m+v;x<w;x++)if(Z(lt,3*e.resolveTriangleIndex(x),n,l),lt.needsUpdate=!0,y.intersectsTriangle(lt))return!0;return!1}});for(let _=v,y=m+v;_<y;_++){const x=e.resolveTriangleIndex(_);Z(at,3*x,n,l),at.a.applyMatrix4(kt),at.b.applyMatrix4(kt),at.c.applyMatrix4(kt),at.needsUpdate=!0;for(let w=0,b=d.count;w<b;w+=3)if(Z(lt,w,d,g),lt.needsUpdate=!0,at.intersectsTriangle(lt))return!0}}else{const p=a+8,n=c[a+6];return K(p,r,pi),!!(s.intersectsBox(pi)&&ys(p,e,t,i,s)||(K(n,r,pi),s.intersectsBox(pi)&&ys(n,e,t,i,s)))}}const gi=new f.Matrix4,Zi=new ie,Ft=new ie,Tc=new f.Vector3,Sc=new f.Vector3,Mc=new f.Vector3,Cc=new f.Vector3;function Dc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Zi.set(e.boundingBox.min,e.boundingBox.max,t),Zi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=de.getPrimitive(),d=de.getPrimitive();let g=Tc,v=Sc,m=null,_=null;s&&(m=Mc,_=Cc);let y=1/0,x=null,w=null;return gi.copy(t).invert(),Ft.matrix.copy(gi),a.shapecast({boundsTraverseOrder:b=>Zi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Ft.min.copy(b.min),Ft.max.copy(b.max),Ft.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:R=>Ft.distanceToBox(R),intersectsBounds:(R,C,P)=>P<y&&P<o,intersectsRange:(R,C)=>{for(let P=R,D=R+C;P<D;P++){const A=M.resolveTriangleIndex(P);Z(d,3*A,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=b,L=b+T;S<L;S++){const I=a.resolveTriangleIndex(S);Z(l,3*I,u,h),l.needsUpdate=!0;const k=l.distanceToTriangle(d,g,m);if(k<y&&(v.copy(g),_&&_.copy(m),y=k,x=S,w=P),k<r)return!0}}}})}else{const M=wt(e);for(let R=0,C=M;R<C;R++){Z(d,3*R,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=b,D=b+T;P<D;P++){const A=a.resolveTriangleIndex(P);Z(l,3*A,u,h),l.needsUpdate=!0;const S=l.distanceToTriangle(d,g,m);if(S<y&&(v.copy(g),_&&_.copy(m),y=S,x=P,w=R),S<r)return!0}}}}}),de.releasePrimitive(l),de.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(gi),v.applyMatrix4(gi),s.distance=v.sub(s.point).length(),s.faceIndex=w),i)}function Rc(){return typeof SharedArrayBuffer<"u"}const Ut=new Y.constructor,Ai=new Y.constructor,Be=new Ps(()=>new f.Box3),ct=new f.Box3,ht=new f.Box3,Xi=new f.Box3,Ji=new f.Box3;let $i=!1;function Lc(a,e,t,i){if($i)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");$i=!0;const s=a._roots,r=e._roots;let o,c=0,h=0;const u=new f.Matrix4().copy(t).invert();for(let p=0,n=s.length;p<n;p++){Ut.setBuffer(s[p]),h=0;const l=Be.getPrimitive();K(0,Ut.float32Array,l),l.applyMatrix4(u);for(let d=0,g=r.length;d<g&&(Ai.setBuffer(r[p]),o=ge(0,0,t,u,i,c,h,0,0,l),Ai.clearBuffer(),h+=r[d].length,!o);d++);if(Be.releasePrimitive(l),Ut.clearBuffer(),c+=s[p].length,o)break}return $i=!1,o}function ge(a,e,t,i,s,r=0,o=0,c=0,h=0,u=null,p=!1){let n,l;p?(n=Ai,l=Ut):(n=Ut,l=Ai);const d=n.float32Array,g=n.uint32Array,v=n.uint16Array,m=l.float32Array,_=l.uint32Array,y=l.uint16Array,x=a*2,w=e*2,b=ae(x,v),T=ae(w,y);let M=!1;if(T&&b)p?M=s(ce(e,_),he(e*2,y),ce(a,g),he(a*2,v),h,o+e,c,r+a):M=s(ce(a,g),he(a*2,v),ce(e,_),he(e*2,y),c,r+a,h,o+e);else if(T){const R=Be.getPrimitive();K(e,m,R),R.applyMatrix4(t);const C=ue(a),P=fe(a,g);K(C,d,ct),K(P,d,ht);const D=R.intersectsBox(ct),A=R.intersectsBox(ht);M=D&&ge(e,C,i,t,s,o,r,h,c+1,R,!p)||A&&ge(e,P,i,t,s,o,r,h,c+1,R,!p),Be.releasePrimitive(R)}else{const R=ue(e),C=fe(e,_);K(R,m,Xi),K(C,m,Ji);const P=u.intersectsBox(Xi),D=u.intersectsBox(Ji);if(P&&D)M=ge(a,R,t,i,s,r,o,c,h+1,u,p)||ge(a,C,t,i,s,r,o,c,h+1,u,p);else if(P)if(b)M=ge(a,R,t,i,s,r,o,c,h+1,u,p);else{const A=Be.getPrimitive();A.copy(Xi).applyMatrix4(t);const S=ue(a),L=fe(a,g);K(S,d,ct),K(L,d,ht);const I=A.intersectsBox(ct),k=A.intersectsBox(ht);M=I&&ge(R,S,i,t,s,o,r,h,c+1,A,!p)||k&&ge(R,L,i,t,s,o,r,h,c+1,A,!p),Be.releasePrimitive(A)}else if(D)if(b)M=ge(a,C,t,i,s,r,o,c,h+1,u,p);else{const A=Be.getPrimitive();A.copy(Ji).applyMatrix4(t);const S=ue(a),L=fe(a,g);K(S,d,ct),K(L,d,ht);const I=A.intersectsBox(ct),k=A.intersectsBox(ht);M=I&&ge(C,S,i,t,s,o,r,h,c+1,A,!p)||k&&ge(C,L,i,t,s,o,r,h,c+1,A,!p),Be.releasePrimitive(A)}}return M}const _i=new ie,Dr=new f.Box3,Pc={strategy:cn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Is{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:o?o.array.slice():null,indirectBuffer:r?r.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:r},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e,c=new Is(t,{...i,[Ni]:!0});if(c._roots=r,c._indirectBuffer=o||null,i.setIndex){const h=t.getIndex();if(h===null){const u=new f.BufferAttribute(e.index,1,!1);t.setIndex(u)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Pc,[Ni]:!1},t),t.useSharedArrayBuffer&&!Rc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ni]||(ql(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?yc:oc)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(c,h=0){const u=c*2,p=r[u+15]===Ci;if(p){const n=s[c+6],l=r[u+14];e(h,p,new Float32Array(i,c*4,6),n,l)}else{const n=c+Wt/4,l=s[c+6],d=s[c+7];e(h,p,new Float32Array(i,c*4,6),d)||(o(n,h+1),o(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=[],h=t.isMaterial,u=Array.isArray(t),p=o.groups,n=h?t.side:t,l=this.indirect?xc:hc;for(let d=0,g=r.length;d<g;d++){const v=u?t[p[d].materialIndex].side:n,m=c.length;if(l(this,d,v,e,c,i,s),u){const _=p[d].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=_}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=t.isMaterial,h=Array.isArray(t);let u=null;const p=o.groups,n=c?t.side:t,l=this.indirect?bc:fc;for(let d=0,g=r.length;d<g;d++){const v=h?t[p[d].materialIndex].side:n,m=l(this,d,v,e,i,s);m!=null&&(u==null||m.distance<u.distance)&&(u=m,h&&(m.face.materialIndex=p[d].materialIndex))}return u}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?Ac:dc;for(let o=0,c=s.length;o<c&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=de.getPrimitive(),i=this.indirect?cc:nc;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const n=o;o=(l,d,g,v,m)=>n(l,d,g,v,m)?!0:i(l,d,this,c,g,v,t)}else o||(c?o=(n,l,d,g)=>i(n,l,this,c,d,g,t):o=(n,l,d)=>d);let h=!1,u=0;const p=this._roots;for(let n=0,l=p.length;n<l;n++){const d=p[n];if(h=$l(this,n,r,o,s,u),h)break;u+=d.byteLength}return de.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=de.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,u=this.indirect?g=>{const v=this.resolveTriangleIndex(g);Z(o,v*3,c,h)}:g=>{Z(o,g*3,c,h)},p=de.getPrimitive(),n=e.geometry.index,l=e.geometry.attributes.position,d=e.indirect?g=>{const v=e.resolveTriangleIndex(g);Z(p,v*3,n,l)}:g=>{Z(p,g*3,n,l)};if(r){const g=(v,m,_,y,x,w,b,T)=>{for(let M=_,R=_+y;M<R;M++){d(M),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=v,P=v+m;C<P;C++)if(u(C),o.needsUpdate=!0,r(o,p,C,M,x,w,b,T))return!0}return!1};if(s){const v=s;s=function(m,_,y,x,w,b,T,M){return v(m,_,y,x,w,b,T,M)?!0:g(m,_,y,x,w,b,T,M)}}else s=g}return Lc(this,e,t,s)}intersectsBox(e,t){return _i.set(e.min,e.max,t),_i.needsUpdate=!0,this.shapecast({intersectsBounds:i=>_i.intersectsBox(i),intersectsTriangle:i=>_i.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?Dc:vc)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return ec(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{K(0,new Float32Array(i),Dr),e.union(Dr)}),e}}class Ic{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class Ec extends Ic{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:yt&&yt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,r)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=u=>{r(new Error(`GenerateMeshBVHWorker: ${u.message}`))},e.onmessage=u=>{const{data:p}=u;if(p.error)r(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:n,position:l}=p,d=Is.deserialize(n,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,n.index)if(t.index)t.index.array=n.index;else{const v=new f.BufferAttribute(n.index,1,!1);t.setIndex(v)}g.setBoundingBox&&(t.boundingBox=d.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(d),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];o&&h.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(u=>u.buffer).filter(u=>typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer)))})}}class kc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new f.Matrix4,this.mouse=new f.Vector3,this.rotateStart=new f.Vector2,this.rotateEnd=new f.Vector2,this.rotateDelta=new f.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,r)=>s.position.z>r.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const r=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*r,(s.clientY-h)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const r=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),r!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const r=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);r.multiplyScalar(o),this.selectedAxis.axis==="z"?r.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?r.setZ(this.orbit.target.z-o):r.setZ(this.orbit.target.z);const c=500,h=performance.now(),u=1,p=this.selectedAxis.axis,n=()=>{const d=performance.now()-h,g=Math.min(d/c,u);if(this.camera.position.lerp(r,g),this.orbit.update(),g!==u){this._animator=window.requestAnimationFrame(n);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),n()},this.drawCircle=(s,r=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-r,s.y-r,r*2,r*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,r,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(r.x,r.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(r=>{const o=this.selectedAxis===r,c=r.position.z>=-.01?r.color[0]:r.color[1];if(r.line&&this.drawLine(this.center,r.position,r.line,c),this.drawCircle(r.position,r.size,o?"#0066ff":c),r.label){const h=r.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,h+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(r.label,r.position.x,r.position.y)}}))},this.setAxisPosition=s=>{const r=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(r.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-r.y*(this.center.y-o/2-this.options.padding),r.z)};const i={offset:new f.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new f.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3731
|
+
`,this._needsRender=!1}handleShadowClick(e){const t=e.target;if(!t)return;t.closest(".info")&&(e.preventDefault(),e.stopPropagation());const i=t.closest("[data-action]");if(!i)return;const s=i.getAttribute("data-action");if(s)switch(e.preventDefault(),e.stopPropagation(),s){case"remove-device":this.removeDevice();break;case"remove-function":{const r=i.getAttribute("data-function");r&&this.dispatchEvent(new CustomEvent("function-removed",{detail:r}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const r=i.getAttribute("data-function");r&&(this.dispatchEvent(new CustomEvent("function-added",{detail:r})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",on);const J={ON_DROP:"slot-on-drop",ON_DEVICE_DELETED:"slot-on-device-deleted",ON_DEVICE_REPLACED:"slot-on-device-replaced",ON_BEFORE_SELECTED:"slot-on-before-selected",ON_SELECTED:"slot-on-selected",ON_ADD_BUTTON_CLICKED:"slot-add-button-clicked",ON_DEVICE_SELECTED:"slot-on-device-selected",ON_DROP_ERROR:"slot-on-drop-error",ON_ERROR_STATE_CHANGE:"slot-on-error-state-change",ON_FUNCTION_REMOVED:"slot-on-function-removed",ON_FUNCTION_ADDED:"slot-on-function-added"};class ls extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new Ke,this._slotContainer=new f.Group,this._bracketSlots=[],this._hasError=!1,this.useBracket=!1,this.addEventListener=this._emitter.addListener.bind(this._emitter),this.removeEventListener=this._emitter.removeListener.bind(this._emitter),this._canInstall=!1,this._loading=!1,this._selected=!1,this._deviceSelected=!1,this._focused=!1,this._toBeInstalled=!1,this._toBeReplaced=!1,this._allFunctions=new Set,this._functions=new Set,this._timer=0,this._parentPos=new f.Vector3,this._wrapper=new f.Group,this._showSlot=!0,this._isMirror=!1,this.beforeInstall=void 0,this._preventDefaults=i=>{i.preventDefault(),i.stopPropagation()},this.getWP=this._slotContainer.getWorldPosition.bind(this._slotContainer),t.setAttribute("data-ui-type","slot"),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new on({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot()}}),this._slotUI.slot=this,this._slotUI.hide=!this._showSlot||this.isMirror,t.append(this._slotUI),this._parentPos.copy(this.props.slot.position),this._slotUI.addEventListener("function-removed",({detail:i})=>{this.removeFunction(i)}),this._slotUI.addEventListener("function-added",({detail:i})=>{this.addFunction(i)}),this.add(this._slotContainer),this.props.slot.add(this),setTimeout(()=>{var i;(i=this.props.slot.parent)==null||i.add(this._wrapper),this._wrapper.add(this.props.slot)},10),["dragenter","dragover","dragleave","drop"].forEach(i=>{t.addEventListener(i,this._preventDefaults,!1)}),t.addEventListener("click",i=>{i.preventDefault(),i.stopPropagation(),this.toBeInstalled?this._emitter.emit(J.ON_ADD_BUTTON_CLICKED):this.selected=!this.selected}),t.addEventListener("dragover",i=>{if(i.preventDefault(),i.dataTransfer.dropEffect="copy",!this._canInstall){i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}}),t.addEventListener("drop",async i=>{var r;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(r=i.dataTransfer)==null?void 0:r.getData("application/json");if(s){const o=JSON.parse(s);try{await this.install(o),this._emitter.emit(J.ON_DROP,this)}catch(c){this._emitter.emit(J.ON_DROP_ERROR,c)}}else this._emitter.emit(J.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){if(this.props.follows.has(e)){const i=this.props.follows.get(e);if(i){let s="x";["height","mast"].includes(e)?s="z":["width","liftOuterWidth"].includes(e)&&(s="y");const r=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*r}}}async loadGlb(e){const i=await new Ht({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Ht({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(r=>{r.userData.isBracket=!0}),this.useBracket=!0,this._slotContainer.add(s)}async install(e){var t;if(!this._loading){this._loading=!0,this.beforeInstall&&typeof this.beforeInstall=="function"&&await((t=this.beforeInstall)==null?void 0:t.call(this,e));try{const i=await this.loadGlb(e.url);if(!i)throw new Error(`Fail to load device from: ${e.url}`);if(i.traverse(s=>{s.userData.isDevice=!0}),this.isMirror&&i.scale.set(1,1,-1),e.bracketUrl){const s=await this.loadGlb(e.bracketUrl);if(s)this.clearSlot(),s.traverse(r=>{r.name.startsWith("Slot")&&this._bracketSlots.push(r),r.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(r=>{r.add(i)})}else this.clearSlot(),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._currentDeivceLoaded=i,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1),this._emitter.emit(J.ON_DEVICE_REPLACED,i)}catch(i){throw i}finally{this._loading=!1}}}get device(){return this._slotContainer.children.length?this._slotContainer.children[0]:null}get allFunctions(){return[...this._allFunctions]}set allFunctions(e){this._functions.forEach(t=>{e.includes(t)||this._functions.delete(t)}),this._allFunctions=new Set(e),this._slotUI.allFunctions=e}get functions(){return[...this._functions]}addFunction(e){this._allFunctions.has(e)&&(this._functions.add(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(J.ON_FUNCTION_REMOVED,e))}clearFunctions(){this._functions.forEach(e=>this.removeFunction(e))}addFunctions(e){e.forEach(t=>this.addFunction(t)),this._slotUI.functions=this.functions}changeName(e){var t;this.name=e,this.props.slot.userData.name=e,this.props.name=e,(t=this.element)==null||t.setAttribute("data-name",this.props.name)}clearSlot(){this._emitter.emit(J.ON_DEVICE_DELETED,this._currentDeivceLoaded),this._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),Re(e)}),this._slotUI.filled=!1,this.deviceInfo=void 0,this._currentDeivceLoaded=void 0,this._slotUI.deviceName="",this._slotUI.deviceLogo="",this.holeTarget&&(this.holeTarget.visible=!0),this.mirrorTarget&&this.mirrorTarget.clearSlot()}get disabled(){return this._slotUI.disable}enable(){this.show(),this._slotUI.disable=!1}disable(){this._slotUI.disable=!0,this.hide()}hide(){this._slotUI.hide=!0}show(){this.isMirror||this.disabled||(this._slotUI.hide=!1)}get selected(){return this._selected}get focused(){return this._focused}set focused(e){this._focused=e,this._slotUI.focused=e}get toBeInstalled(){return this._toBeInstalled}set toBeInstalled(e){this._toBeInstalled=e,this._slotUI.toBeInstalled=e}get toBeReplaced(){return this._toBeReplaced}set toBeReplaced(e){this._toBeReplaced=e,this._slotUI.toBeReplaced=e}set selected(e){this.disabled||(e&&this._emitter.emit(J.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(J.ON_SELECTED,e),this.element.style.zIndex="100",this.selected?this.renderOrder=1/0:this.renderOrder=1)}get deviceSelected(){return this._deviceSelected}set deviceSelected(e){this._deviceSelected=e,this._emitter.emit(J.ON_DEVICE_SELECTED,e)}get error(){return this._hasError}set error(e){this._loading&&setTimeout(()=>{this.error=e},100),this._hasError=e,this._slotUI.hasError=e,this._emitter.emit(J.ON_ERROR_STATE_CHANGE,e)}getCanInstall(){return this._canInstall}canInstall(e){this._canInstall=e,this._slotUI.canInstall=e}dispose(){cancelAnimationFrame(this._timer),["dragenter","dragover","dragleave","drop"].forEach(e=>{this.element.addEventListener(e,this._preventDefaults,!1)}),this.props.follows.clear(),this.clearSlot(),this._emitter.removeAllListeners(),Re(this._slotContainer),this.element.remove()}render(e){const t=this.element.style.transform,i=/translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);if(!i)return;const s=new f.Vector2(parseFloat(i[1]),parseFloat(i[2])),r=e.mousePos.distanceTo(s);let o=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(o=34,c=60,h=60),r<h){let u=(h-r)*1+o;r<20&&(u=c),u>c&&(u=c),this._slotUI.setSize(u)}else this._slotUI.setSize(o)}clone(e){return new f.Group}}class pl extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=Ds(),s=i?"#ddd":"#eee";this.element.style.pointerEvents="auto",this.element.style.padding=i?"2px 6px":"3px 12px",this.element.style.borderTop=`1px solid ${s}`,this.element.style.borderBottom=this.element.style.borderTop;const r="6px",o=document.createElement("div");o.style.pointerEvents="none",Object.assign(o.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(o);const c=document.createElement("div");c.style.pointerEvents="none",Object.assign(c.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",bottom:"0",boxSizing:"border-box",height:r,width:"100%"}),this.element.append(c),this._text.style.fontSize=i?"10px":"14px",this._text.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif",this._text.style.color="#fff",this._text.style.fontWeight="500",this._text.style.transition="all .16s",this._text.innerText=e,this.element.append(this._text),this._text.addEventListener("pointermove",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(h=this.onPointMove)==null||h.call(this)}),this._text.addEventListener("pointerleave",()=>{var h;o.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(h=this.onPointLeave)==null||h.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class yi extends f.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new f.LineSegments(new f.BufferGeometry,new f.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new pl(""),this._line.frustumCulled=!1,this.add(this._line,this._line2),this._showText&&(this.add(this._text),this._text.onPointMove=()=>{this._line.material.color.set("#000"),this._line2.material.color.set("#000")},this._text.onPointLeave=()=>{this._line.material.color.set("#666"),this._line2.material.color.set("#666")})}updateMaterial(e){this._line.material=e}reset(){var e,t;(e=this._line.geometry)==null||e.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line.computeLineDistances(),(t=this._line2.geometry)==null||t.dispose(),this._line2.geometry=new f.BufferGeometry().setFromPoints([new f.Vector3,new f.Vector3]),this._line2.computeLineDistances()}update(e,t,i=0){var d,g;(d=this._line.geometry)==null||d.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,r=new f.Vector3().subVectors(t,e).normalize();let o;Math.abs(r.z)>Math.abs(r.x)&&Math.abs(r.z)>Math.abs(r.y)?o=new f.Vector3(-r.y,r.x,0):Math.abs(r.y)>Math.abs(r.x)?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0),o.length()<.001&&(Math.abs(r.x)<.9?o=new f.Vector3(1,0,0):o=new f.Vector3(0,1,0)),o.normalize();const c=new f.Vector3().addVectors(e,o.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,o.clone().multiplyScalar(-s)),u=new f.Vector3().addVectors(t,o.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,o.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,u,p]),this._line2.computeLineDistances();const n=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(n*1e3).toFixed(0)} mm`:this._text.text=`${(n*1e3).toFixed(0)} mm`;const l=new f.Vector3;l.addVectors(e,t).multiplyScalar(.5),this._text.position.copy(l),this.useStartEnd||(this._line2.visible=!1)}destroy(){this._text.dispose(),this.children.forEach(e=>Re(e)),this.removeFromParent()}}class an extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new ml(""),this._line=new yi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new Er.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new f.RingGeometry(e,e+.003,128),this._box.material=new f.MeshBasicMaterial({color:"#666",side:f.DoubleSide}),this._arc.geometry=new es.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new kr.LineMaterial({color:"#eee",linewidth:2,resolution:new f.Vector2(window.innerWidth,window.innerHeight)}),this._arc.visible=!1,this._arc.rotateX(-Math.PI/2),this.position.y=t,this._arc.position.y=.001,this.add(this._box),this.add(this._arc),this.add(this._line),this.add(this._text)}hide(){this._text.hide(),this._line.visible=!1,this._arc.visible=!1}show(){this._text.show(),this._line.visible=!0}dispose(){this._updateTimer&&(clearTimeout(this._updateTimer),this._updateTimer=null),this._box.geometry&&this._box.geometry.dispose(),this._arc.geometry&&this._arc.geometry.dispose(),this._arc.visible=!1,this._previousPosition=null}update(e){var t;this.radius=e,(t=this._box.geometry)==null||t.dispose(),this._box.geometry=new f.RingGeometry(e,e+.003,128),this._line.updateMaterial(new f.LineDashedMaterial({color:"#555",dashSize:.06*e,gapSize:.06*e})),this._text.update((e*1e3).toFixed(0))}change(e){const t=e.clone();t.setZ(0),t.normalize().multiplyScalar(this.radius),this._text.position.set(t.x,t.y,t.z),this._text.updateColor("#eee"),this._line.update(t,new f.Vector3),this._previousPosition&&this._updateArc(this._previousPosition,t),this._updateTimer&&clearTimeout(this._updateTimer),this._updateTimer=setTimeout(()=>{this._previousPosition=null,this._accumulatedAngle=0,this._lastAngle=null,this._clearArc(),this._updateTimer=null},this._updateDelay),this._previousPosition||(this._previousPosition=t.clone(),this._lastAngle=Math.atan2(t.y,t.x),this._accumulatedAngle=0)}_updateArc(e,t){const i=Math.atan2(t.y,t.x);if(this._lastAngle!==null){let h=i-this._lastAngle;h>Math.PI?h-=2*Math.PI:h<-Math.PI&&(h+=2*Math.PI),this._accumulatedAngle+=h}if(this._lastAngle=i,Math.abs(this._accumulatedAngle)<.01){this._arc.visible=!1;return}const s=Math.atan2(e.y,e.x),r=s+this._accumulatedAngle;let o=.006*this.radius;o<.003&&(o=.003),o>.006&&(o=.006);const c=this._createArcGeometry(s,r,this.radius+o);this._arc.geometry&&this._arc.geometry.dispose(),this._arc.geometry=c,this._arc.visible=!0}_clearArc(){this._text.updateColor(),this._arc.geometry&&(this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.computeLineDistances()),this._arc.visible=!1}_createArcGeometry(e,t,i){const s=[],r=t-e,o=Math.max(128,Math.floor(Math.abs(r)/(Math.PI/128))),c=r/o;for(let u=0;u<=o;u++){const p=e+u*c,n=Math.cos(p),l=Math.sin(p);s.push(i*n,0,i*l)}const h=new es.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class ml extends Ae.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=Ds();this._wrapper.style.fontSize=i?"10px":"11px",this._wrapper.style.color="#fff",this._wrapper.style.whiteSpace="nowrap",this._wrapper.style.position="absolute",this._wrapper.style.transform="translateX(-50%)",this._wrapper.style.top="6px",this._wrapper.style.font="SF Pro SC,SF Pro Text,SF Pro Icons,PingFang SC,Helvetica Neue,Helvetica,Arial,sans-serif";const s=this._circle;s.style.position="relative",s.style.zIndex="10",s.style.width=s.style.height="5px",s.style.borderRadius="50%",s.style.background="#666",t.append(this._wrapper,s),this.update(e)}show(){this.element.style.display="block"}hide(){this.element.style.display="none"}update(e){this._wrapper.innerText="旋转半径:"+e+" mm",this.updateColor("#eee")}updateColor(e="#666"){this._circle.style.background=e}}const gl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",_l="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",ur="data:image/png;base64,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",vl="data:image/png;base64,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";class fr extends Ae.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this.isController=!0,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeListener=this._emitter.removeListener.bind(this._emitter),this._update=()=>{if(this._looper=requestAnimationFrame(this._update),this._controlling){let n=(Date.now()-this._startAt)/200;n>4&&(n=4);let l=this._initial+.005*n*this._direction;if(l>this.props.max||l<this.props.min){this.mechanism&&(l<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):l>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=l,!this.mechanism)return;this.mechanism.position.setZ(l),this._emitter.emit("change",l)}},i.setAttribute("data-ui-type","mechanism");const s=Ds();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(n=>{n.name===e.userData.target.name&&(this.mechanism=n)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const r=n=>{n.stopPropagation()},o=n=>{n.preventDefault(),n.stopPropagation()},c={capture:!1,passive:!0},h={capture:!1,passive:!1};["pointerdown","pointerup","pointermove","pointercancel","click","dblclick","contextmenu","mousemove"].forEach(n=>{i.addEventListener(n,r,c)}),["wheel","dragenter","dragover","dragleave","drop"].forEach(n=>{i.addEventListener(n,o,h)});const u=document.createElement("div");u.style.position="absolute",u.style.left="0",u.style.transform="translateX(-50%) rotate(-180deg)",u.style.marginBottom="5px",u.style.width=u.style.height=s?"34px":"44px",u.style.background=`url(${ur}) center no-repeat`,u.style.backgroundSize="100% auto",u.setAttribute("data-direction","up"),u.style.transition="all .2s";const p=document.createElement("div");if(p.style.position="absolute",p.style.left="0",p.style.transform="translateX(-50%)",u.style.bottom=p.style.top="8px",p.style.width=p.style.height=u.style.width,p.style.background=`url(${ur}) center no-repeat`,p.style.backgroundSize="100% auto",p.style.transition="all .2s",p.setAttribute("data-direction","down"),Array.from([u,p]).forEach(n=>{s||n.addEventListener("mousemove",()=>{n.style.filter="invert(100%)"}),n.addEventListener("mouseleave",()=>{n.style.filter=""}),n.addEventListener("pointerdown",()=>{this.mechanism&&(n.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=n.getAttribute("data-direction")==="up"?1:-1,this._update())}),n.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""}),n.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),n.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:n,rotateDuration:l,rotateStep:d,rotateMax:g,rotateMin:v}=e.userData;let m;if(n&&(t.traverse(_=>{_.name===n.name&&(m=_)}),m)){const _=document.createElement("div");_.style.background=`url(${vl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.position="absolute",_.style.top="-50%",_.style.left="-50%",_.style.width=s?"140px":"160px",_.style.height=s?"70px":"80px",_.style.transform="translateX(-50%) translateY(-50%)",i.append(_);const y=document.createElement("div");y.style.background=`url(${_l}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","left"),i.append(y);const x=document.createElement("div");x.style.background=`url(${gl}) center no-repeat`,x.style.backgroundSize="100% auto",x.style.width=x.style.height=s?"20px":"26px",x.style.position="absolute",y.style.left=x.style.right=s?"62px":"69px",x.style.top="0",x.style.transform="translateY(-50%)",x.style.marginBottom="5px",x.setAttribute("data-direction","right"),i.append(x),Array.from([y,x]).forEach(w=>{s||w.addEventListener("mousemove",()=>{w.style.filter="invert(100%)"}),w.addEventListener("mouseleave",()=>{w.style.filter=""}),w.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;w.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=w.getAttribute("data-direction")==="left"?1:-1;let b=d/180*Math.PI*this._direction+m.rotation.z;b>g/180*Math.PI?b=g/180*Math.PI:b<v/180*Math.PI&&(b=v/180*Math.PI),this._timer=new bi(m.rotation).to({z:b}).duration(l).start(),this._update()}),w.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),w.style.filter=""}),w.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),w.style.filter=""})})}}i.append(u,p),this.scale.set(.01,.01,.01),this.matrixAutoUpdate=!1,this.updateMatrix()}hide(){this.element.style.display="none",this.traverse(e=>{e.visible=!1,e instanceof Ae.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof Ae.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class yl extends En.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new Ke,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new f.Vector2,this._targetSize=new f.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=h=>{const{pageX:u,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(u,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=h=>{if(!this._mouseStart.x)return;const{pageX:u,pageY:p}=h;let n=u-this._mouseStart.x,l=n+this._targetSize.x;this._sizeFlag==="height"&&(n=p-this._mouseStart.y,l=n*this._direction+this._targetSize.y);const d=l%10;l=l-d,n=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(n=(l-this._targetSize.y)*this._direction),this._textNode.innerText=(l/100).toFixed(2)+" m",this.endNode.parentElement.style[this._sizeFlag]=`${l}px`},this._pointercancel=h=>{this.endNode.releasePointerCapture(h.pointerId),this._mouseStart.set(0,0)};const{start:i,end:s}=e,r=s.distanceTo(i);this.props.axios==="z"?this.props.axios="y":this.props.axios==="y"&&(this.props.axios="z"),this.props.axios==="y"&&(this._sizeFlag="height");const o=document.createElement("div");o.style.position="absolute",o.style.left="0",o.style.bottom="0",t.append(o),this._textNode=document.createElement("div"),this._textNode.innerText=r.toFixed(2)+" m",o.append(this._textNode);const c=document.createElement("div");this.endNode=c,c.style.position="absolute",c.style.left="auto",c.style.right="0",c.style.width="4px",c.style.height="4px",c.style.background="#0066FF",c.style.borderRadius="50%",c.style.margin="-2px -2px 0 0",c.style.cursor="pointer",o.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",o.style[this._sizeFlag]=r*100+"px",o.style.textAlign="center",this._sizeFlag==="height"?(o.style.borderLeft="0.1px dashed #fff",o.style.display="flex",o.style.alignItems="center",o.style.justifyContent="center",o.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):o.style.borderBottom="0.1px dashed #fff",c.addEventListener("pointerdown",this._pointerdown),c.addEventListener("pointermove",this._pointermove),c.addEventListener("pointerup",this._pointercancel),s[this.props.axios]<i[this.props.axios]?this.rotateY(Math.PI):this._direction=-1}_getIndexByAxios(){return this.props.axios==="y"?1:this.props.axios==="z"?2:0}dispose(){this._lines.forEach(e=>e.dispose()),this._emitter.removeAllListeners(),this.endNode.removeEventListener("pointerdown",this._pointerdown),this.endNode.removeEventListener("pointermove",this._pointermove),this.endNode.removeEventListener("pointerup",this._pointercancel),this.element.remove(),this._caches.forEach(e=>e.clear()),this._caches=[]}}class xl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new yi("长:"),this._line12=new yi("宽:"),this._line13=new yi("高:"),this._outline=new an(0,0),this._radius=0,this._hasWidthConfig=!1,this._hasLengthConfig=!1,this._hasHeightConfig=!1,this.follow="",this.followOrigin=0,this.followScale=1,this.originOffset=0,this.translateCache=0,this.head=0,this.tail=0,this._change=()=>{if(!this._app)return;const e=this._app.camera;e&&this._outline.change(e.position)},this.add(this._outline,this._line11,this._line12,this._line13)}get hasSizeConfig(){return{length:this._hasLengthConfig,width:this._hasWidthConfig,height:this._hasHeightConfig}}get size(){return this._box3.clone()}get radius(){return this._radius}init(e){this._app=e,this._app.controls.addEventListener("change",this._change)}reset(){this.hide(),this._line11.reset()}generate(e,t=0){e&&(this._object=e),this.update(t)}show(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!0,this._outline.visible=!0,this._outline.show(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!0,s instanceof Ae.CSS2DObject&&(s.element.style.visibility="visible")})})}hide(e=!0){const t=[this._line11,this._line12,this._line13];e&&(this.visible=!1,this._outline.visible=!1,this._outline.hide(),t.push(this._outline)),t.forEach(i=>{i.traverse(s=>{s.visible=!1,s instanceof Ae.CSS2DObject&&(s.element.style.visibility="hidden")})})}destroy(){var e;(e=this._app)==null||e.controls.removeEventListener("change",this._change),this._line11.destroy(),this._line12.destroy(),this._line13.destroy()}update(e=0){if(!this._object)return;const t=this._object,{box:i,maxRadius:s,hasLength:r,hasHeight:o,hasWidth:c}=rl(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=r,this._hasHeightConfig=o,this._box3.copy(i),this._radius=s,this.follow&&e&&(this.originOffset=(this.followOrigin-e)*this.followScale),this._outline.update(this._radius),this._change();const h=this._box3.min.x,u=this._box3.max.x,p=this._box3.min.z,n=this._box3.max.z,l=this._box3.min.y,d=this._box3.max.y;let g=.2;const v=new f.Vector3(h,d,0),m=new f.Vector3(u,d,0);this._line11.update(v.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const _=new f.Vector3(u,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),_.clone().add(new f.Vector3(g,0,0)),this._radius);const y=new f.Vector3(h,d,p),x=new f.Vector3(h,d,n),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class we extends f.Mesh{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._lineMaterial=new f.LineDashedMaterial({color:new f.Color("#000"),dashSize:.015,gapSize:.015}),this._currentLength=.6,this._currentWidth=.4,this._currentHeight=.2,this.material=new f.MeshBasicMaterial({color:new f.Color("#0f5fd5"),transparent:!0,opacity:.4}),this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._currentLength=e,this._currentWidth=t,this._currentHeight=i,this._generate(e,t,i)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}dispose(){var t,i,s,r,o;(t=this.lineSegments)==null||t.removeFromParent(),(s=(i=this.lineSegments)==null?void 0:i.geometry)==null||s.dispose(),this.lineSegments=void 0,(r=this.geometry)==null||r.dispose();const e=this.material;Array.isArray(e)?e.forEach(c=>{var h;return(h=c==null?void 0:c.dispose)==null?void 0:h.call(c)}):(o=e==null?void 0:e.dispose)==null||o.call(e),this._lineMaterial.dispose(),this.clear()}clearAll(){this.dispose()}clone(e){return new we(this._currentLength,this._currentWidth,this._currentHeight)}_generate(e,t,i){Re(this),this.clear(),this.geometry.dispose(),this.geometry=new f.BoxGeometry(e,t,i),this.geometry.translate(0,0,i/2);const s=new f.EdgesGeometry(this.geometry);this.lineSegments=new f.LineSegments(s,this._lineMaterial),this.add(this.lineSegments),this.lineSegments.geometry.dispose(),this.lineSegments.geometry=s,this.lineSegments.computeLineDistances()}}const wl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class cs{constructor(e){this._props=e,this.name="",this.transparentTexture=Rs.load(wl),this._offscreen=new OffscreenCanvas(0,0),this._defaults={...e},this.target=e.target,this.parent=this.target.parent,this.reset()}get imageSize(){return this._props.imageSize}get size(){return this._props.size}get defaultConfigs(){return{canvasWidth:200,canvasHeight:200,scaleX:1,scaleY:1,x:0,y:0,ox:0,oy:0,url:this._defaults.imageUrl}}clear(){this.change()}change(e,t=new f.Vector2(1,1),i=new f.Vector2){this.imageUrl=e;let s;if(e){const r=new Image;r.crossOrigin="anonymous",r.src=e,r.onload=async()=>{var u;let o=window.devicePixelRatio*2;this._offscreen.width=r.width+o,this._offscreen.height=r.height+o;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(r,o/2,o/2,r.width,r.height),s=new f.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=f.SRGBColorSpace,s.wrapS=s.wrapT=f.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const h=this._props.target;h.material&&((u=h.material.map)==null||u.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const r=this._props.target;r.material&&(r.material.map=this.transparentTexture)}}reset(){this._props=this._defaults,this.name=this._props.name,this.imageUrl=this._props.imageUrl,this.target=this._props.target,this.change(this.imageUrl||"")}dispose(){this._offscreen=null}}function Wi(a){return a.type?a.type==="Mesh":a.isMesh}class dr{constructor(e,t){this.links=[],this.target=new f.Vector3,this.targetQuaternion=new f.Quaternion,this.iterations=15,this.minDistance=.001,this.maxStep=.35,this.damping=.35,this.maxAngleDelta=.8,this._restQuaternions=[],this._initialRestQuaternions=[],this._axesLocal=[],this._axisMins=[],this._axisMaxs=[],this._jointStates=[],this._frameAppliedAbsDelta=[],this._jointWeights=[],this._stableFrameCount=0,this._lastFramePosErrSq=1/0,this._lastFrameOriErr=1/0,this._tmpEffectorPos=new f.Vector3,this._tmpTargetPos=new f.Vector3,this._tmpLinkPos=new f.Vector3,this._tmpAxisWorld=new f.Vector3,this._tmpVToEff=new f.Vector3,this._tmpVToTar=new f.Vector3,this._tmpProjE=new f.Vector3,this._tmpProjT=new f.Vector3,this._tmpCross=new f.Vector3,this._tmpEffWorldQ=new f.Quaternion,this._tmpTarWorldQ=new f.Quaternion,this._tmpDirCurP=new f.Vector3,this._tmpDirTarP=new f.Vector3,this._tmpDirCurS=new f.Vector3,this._tmpDirTarS=new f.Vector3,this._tmpAxisQ=new f.Quaternion,this._tmpParentWorldQ=new f.Quaternion,this._tmpLocalBeforeQ=new f.Quaternion,this._tmpWorldBeforeQ=new f.Quaternion,t&&(typeof t.iterations=="number"&&(this.iterations=t.iterations),typeof t.minDistance=="number"&&(this.minDistance=t.minDistance),typeof t.maxStep=="number"&&(this.maxStep=t.maxStep),typeof t.damping=="number"&&(this.damping=t.damping),typeof t.maxAngleDelta=="number"&&(this.maxAngleDelta=t.maxAngleDelta),t.orientation&&(this.orientation=Object.assign({enabled:!1},t.orientation))),this.links=(Array.isArray(e)?e:[]).map(s=>{const r=Array.isArray(s.axes)&&s.axes.length>0?s.axes.map(o=>({axis:o.axis.clone(),min:o.min,max:o.max,value:o.value})):void 0;return{object:s.object,ikTcp:!!s.ikTcp,weight:typeof s.weight=="number"?s.weight:void 0,axes:r}});const i=this.links.map(s=>s.object);this._axesLocal=i.map((s,r)=>this._normalizeAxesForLink(r)),this._axisMins=i.map((s,r)=>this._getAxisMinsForLink(r)),this._axisMaxs=i.map((s,r)=>this._getAxisMaxsForLink(r)),this._restQuaternions=i.map((s,r)=>{var u;const o=s.quaternion.clone(),c=this._axesLocal[r],h=this.links[r];if(c&&c.length>0&&h.axes)for(let p=c.length-1;p>=0;p--){const n=c[p],l=((u=h.axes[p])==null?void 0:u.value)??0;Math.abs(l)>1e-6&&(this._tmpAxisQ.setFromAxisAngle(n,l).invert(),o.multiply(this._tmpAxisQ))}return o}),this._initialRestQuaternions=this._restQuaternions.map(s=>s.clone()),this._jointStates=i.map((s,r)=>{var u;const o=((u=this._axesLocal[r])==null?void 0:u.length)??0,c=this.links[r],h=new Array(o).fill(0);if(c.axes&&c.axes.length>0)for(let p=0;p<o;p++)h[p]=c.axes[p].value??0;return{currentAngle:h[0]??0,prevAngle:h[0]??0,currentAngles:h,prevAngles:[...h]}}),this._frameAppliedAbsDelta=i.map((s,r)=>{var o;return new Array(((o=this._axesLocal[r])==null?void 0:o.length)??0).fill(0)}),this._jointWeights=this._buildJointWeights(t==null?void 0:t.weightProfile)}_buildJointWeights(e){var u;const t=(e==null?void 0:e.root)??.3,i=(e==null?void 0:e.middle)??.68,s=(e==null?void 0:e.end)??1,r=Math.max(1,(e==null?void 0:e.curve)??1),o=this.links.length,c=this.links.some(p=>typeof p.weight=="number"),h=[];for(let p=0;p<o;p++){const n=(u=this.links[p])==null?void 0:u.weight;if(c&&typeof n=="number"&&Number.isFinite(n)){h[p]=Math.max(0,n);continue}if(o<=1){h[p]=Math.max(0,s);continue}const l=p/(o-1),d=l<=.5?Math.pow(l/.5,r):Math.pow((l-.5)/.5,r),g=l<=.5?t+(i-t)*d:i+(s-i)*d;h[p]=Math.max(0,g)}return h}_normalizeAxesForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>{const s=i.axis.clone();return s.lengthSq()>0&&s.normalize(),s}):[]:[]}_getAxisMinsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.min):[]:[]}_getAxisMaxsForLink(e){const t=this.links[e];return t?Array.isArray(t.axes)&&t.axes.length>0?t.axes.map(i=>i.max):[]:[]}_applyLinkAngles(e){var o;const t=(o=this.links[e])==null?void 0:o.object;if(!t)return;const i=this._axesLocal[e],r=this._jointStates[e].currentAngles??[];t.quaternion.copy(this._restQuaternions[e]);for(let c=0;c<i.length;c++){const h=i[c],u=r[c]??0;!h||h.lengthSq()<1e-12||Math.abs(u)<1e-12||(this._tmpAxisQ.setFromAxisAngle(h,u),t.quaternion.multiply(this._tmpAxisQ))}}_getAxisWorld(e,t,i){var u;const s=(u=this.links[e])==null?void 0:u.object;if(!s)return i.set(0,0,0);const r=this._axesLocal[e],o=r==null?void 0:r[t];if(!o||o.lengthSq()<1e-12)return i.set(0,0,0);s.parent?s.parent.getWorldQuaternion(this._tmpParentWorldQ):this._tmpParentWorldQ.identity(),this._tmpLocalBeforeQ.copy(this._restQuaternions[e]);const h=this._jointStates[e].currentAngles??[];for(let p=0;p<t;p++){const n=r[p],l=h[p]??0;!n||n.lengthSq()<1e-12||Math.abs(l)<1e-12||(this._tmpAxisQ.setFromAxisAngle(n,l),this._tmpLocalBeforeQ.multiply(this._tmpAxisQ))}return this._tmpWorldBeforeQ.copy(this._tmpParentWorldQ).multiply(this._tmpLocalBeforeQ),i.copy(o).applyQuaternion(this._tmpWorldBeforeQ).normalize()}resetToInitialPose(){for(let e=0;e<this.links.length;e++){const t=this._initialRestQuaternions[e];t&&(this._restQuaternions[e].copy(t),this.links[e].object.quaternion.copy(t));const i=this._jointStates[e];i.currentAngles&&i.currentAngles.fill(0),i.prevAngles&&i.prevAngles.fill(0),this._frameAppliedAbsDelta[e]&&this._frameAppliedAbsDelta[e].fill(0)}this.links.length>0&&this.links[0].object.updateMatrixWorld(!0)}get restQuaternions(){return this._restQuaternions}_isOrientationEnabled(){var e;return!!((e=this.orientation)!=null&&e.enabled)}_getEndIndices(){var o,c;let e=-1;for(let h=0;h<this.links.length;h++)(o=this.links[h])!=null&&o.ikTcp&&(e=h);e<0&&(e=this.links.length-1);const t=!!((c=this.links[e])!=null&&c.ikTcp),i=t?e:this.links.length-1;let s=-1;for(let h=i;h>=0;h--){const u=this._axesLocal[h];if(u&&u.length>0){s=h;break}}return s<0&&(s=Math.max(0,Math.min(this.links.length-1,i))),{ikTcpIndex:e,effectorJointIndex:s,orientationEvalIndex:t?e:s}}_getOrientationDefaults(){var l,d,g,v,m,_,y;const{effectorJointIndex:e,orientationEvalIndex:t}=this._getEndIndices(),i=e,s=this._getOrientationChainStartIndex(i),r=(((l=this.orientation)==null?void 0:l.forwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),o=(((d=this.orientation)==null?void 0:d.upAxis)??new f.Vector3(0,0,1)).clone().normalize(),c=(((g=this.orientation)==null?void 0:g.targetForwardAxis)??new f.Vector3(1,0,0)).clone().normalize(),h=(((v=this.orientation)==null?void 0:v.targetUpAxis)??new f.Vector3(0,0,1)).clone().normalize(),u=((m=this.orientation)==null?void 0:m.forwardWeight)??1,p=((_=this.orientation)==null?void 0:_.upWeight)??.15,n=((y=this.orientation)==null?void 0:y.minAngle)??Math.PI/180;return{effectorIndex:i,orientationEvalIndex:t,orientationStartIndex:s,effectorForwardAxis:r,effectorUpAxis:o,targetForwardAxis:c,targetUpAxis:h,forwardWeight:u,upWeight:p,minAngle:n}}_orientationErrorAngle(){if(!this._isOrientationEnabled()||this.links.length<1)return 0;const{orientationEvalIndex:e,effectorForwardAxis:t,effectorUpAxis:i,targetForwardAxis:s,targetUpAxis:r,forwardWeight:o,upWeight:c}=this._getOrientationDefaults();this.links[Math.max(0,Math.min(this.links.length-1,e))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(t).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(s).applyQuaternion(this._tmpTarWorldQ).normalize();let u=o*this._angleBetweenNormalized(this._tmpDirCurP,this._tmpDirTarP);return c>0&&(this._tmpDirCurS.copy(i).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(r).applyQuaternion(this._tmpTarWorldQ).normalize(),u+=c*this._angleBetweenNormalized(this._tmpDirCurS,this._tmpDirTarS)),u}_angleBetweenNormalized(e,t){const i=Math.max(-1,Math.min(1,e.dot(t)));this._tmpCross.crossVectors(e,t);const s=this._tmpCross.length();return Math.atan2(s,i)}_getOrientationChainStartIndex(e){let t=0;for(let i=e;i>=0;i--){const s=this._axesLocal[i];if(s&&s.length>0&&(t+=s.length),t>=3)return i}return 0}bindRestPose(){for(let e=0;e<this.links.length;e++){this._restQuaternions[e].copy(this.links[e].object.quaternion);const t=this._jointStates[e];t.currentAngle=0,t.prevAngle=0,t.currentAngles&&t.currentAngles.fill(0),t.prevAngles&&t.prevAngles.fill(0)}}updateJointStateFromCurrentPose(){var e;for(let t=0;t<this.links.length;t++){const i=(e=this.links[t])==null?void 0:e.object;if(!i)continue;const s=this._restQuaternions[t],r=i.quaternion;this._updateLinkAnglesFromQuaternion(t,r,s),this._frameAppliedAbsDelta[t]&&this._frameAppliedAbsDelta[t].fill(0)}}rebindRestPoseWithBase(e){var t;for(let i=0;i<this.links.length;i++){const s=(t=this.links[i])==null?void 0:t.object;if(!s)continue;const r=e[i]??s.quaternion,o=s.quaternion;this._restQuaternions[i].copy(r),this._initialRestQuaternions[i]&&this._initialRestQuaternions[i].copy(r),this._updateLinkAnglesFromQuaternion(i,o,r),this._frameAppliedAbsDelta[i]&&this._frameAppliedAbsDelta[i].fill(0)}}_updateLinkAnglesFromQuaternion(e,t,i){const s=this._axesLocal[e]??[],r=this._jointStates[e];r.currentAngles||(r.currentAngles=new Array(s.length).fill(0)),r.prevAngles||(r.prevAngles=new Array(s.length).fill(0));const o=this._tmpLocalBeforeQ.copy(i).invert().multiply(t),c=this._tmpWorldBeforeQ.copy(o);for(let h=0;h<s.length;h++){const u=s[h];if(!u||u.lengthSq()<1e-12){r.currentAngles[h]=0,r.prevAngles[h]=0;continue}const p=this._tmpVToEff.set(c.x,c.y,c.z).dot(u);this._tmpAxisQ.set(u.x*p,u.y*p,u.z*p,c.w).normalize();const n=2*Math.atan2(p,this._tmpAxisQ.w);r.currentAngles[h]=n,r.prevAngles[h]=n,this._tmpParentWorldQ.copy(this._tmpAxisQ).invert(),c.premultiply(this._tmpParentWorldQ)}r.currentAngle=r.currentAngles[0]??0,r.prevAngle=r.currentAngle}get jointStates(){return this._jointStates}_clamp(e,t,i){return t!==void 0&&e<t&&(e=t),i!==void 0&&e>i&&(e=i),e}_signedAngleAroundAxis(e,t,i){const s=e.dot(i),r=t.dot(i);this._tmpProjE.copy(e).addScaledVector(i,-s),this._tmpProjT.copy(t).addScaledVector(i,-r);const o=this._tmpProjE.lengthSq(),c=this._tmpProjT.lengthSq(),h=1e-10;if(o<h||c<h)return 0;const u=Math.sqrt(o),p=Math.sqrt(c);this._tmpProjE.multiplyScalar(1/u),this._tmpProjT.multiplyScalar(1/p);const n=this._tmpProjE.dot(this._tmpProjT);this._tmpCross.crossVectors(this._tmpProjE,this._tmpProjT);const l=i.dot(this._tmpCross),d=Math.max(-1,Math.min(1,n));let g=Math.atan2(l,d);const v=Math.min(u,p),m=Math.sin(Math.PI/180*4.6),_=Math.sin(Math.PI/180*30);if(v<=m)return 0;if(v<_){const y=(v-m)/(_-m);g*=Math.max(0,Math.min(1,y))}return g}update(){var C,P,D;if(this.links.length<2)return;const{ikTcpIndex:e,effectorJointIndex:t}=this._getEndIndices(),i=this.links[Math.max(0,Math.min(this.links.length-1,e))].object,s=this._tmpEffectorPos,r=this._tmpTargetPos.copy(this.target),o=this._tmpLinkPos,c=this._tmpAxisWorld,h=this._tmpVToEff,u=this._tmpVToTar;let p=this._isOrientationEnabled();const n=p?this._getOrientationDefaults():void 0;i.getWorldPosition(s);const l=this.minDistance*this.minDistance,d=(n==null?void 0:n.minAngle)??Math.PI/180,g=s.distanceToSquared(r),v=p?this._orientationErrorAngle():0,m=g<=l,_=!p||v<=d,y=this.minDistance*2,x=y*y,w=d*2,b=g<=this._lastFramePosErrSq*1.5&&(!p||v<=this._lastFrameOriErr*1.5);if(m&&_||g<=x&&(!p||v<=w))if(b){if(this._stableFrameCount++,this._stableFrameCount>=2){this._lastFramePosErrSq=g,this._lastFrameOriErr=v;return}}else this._stableFrameCount=0;else this._stableFrameCount=0;this._lastFramePosErrSq=g,this._lastFrameOriErr=v;for(let A=0;A<this._frameAppliedAbsDelta.length;A++)this._frameAppliedAbsDelta[A]&&this._frameAppliedAbsDelta[A].fill(0);for(let A=0;A<this._jointStates.length;A++){const S=this._jointStates[A];if(S.prevAngle=S.currentAngle,S.prevAngles&&S.currentAngles)for(let L=0;L<S.currentAngles.length;L++)S.prevAngles[L]=S.currentAngles[L]}let T=g,M=v,R=0;for(let A=0;A<this.iterations;A++){i.getWorldPosition(s);const S=s.distanceToSquared(r),L=S<l,I=p?this._orientationErrorAngle():0,k=!p||I<=d;if(L&&k)break;if(S>=T*.9&&(!p||I>=M*.5)){if(R++,R>=2)break}else R=0;T=S,M=I;let F=0,z=p?t:e===t?t-1:t;z=Math.max(0,Math.min(this.links.length-1,z));for(let B=z;B>=0;B--){const N=this.links[B].object,W=this._axesLocal[B];if(!(!W||W.length===0))for(let O=0;O<W.length;O++){const Q=W[O];if(!Q||Q.lengthSq()<1e-12||(i.getWorldPosition(s),N.getWorldPosition(o),this._getAxisWorld(B,O,c),c.lengthSq()<1e-12))continue;let U=0;if(!(B===t&&e===t)){h.subVectors(s,o),u.subVectors(r,o);const X=h.lengthSq(),ee=u.lengthSq();X>=1e-12&&ee>=1e-12&&(h.multiplyScalar(1/Math.sqrt(X)),u.multiplyScalar(1/Math.sqrt(ee)),U+=this._signedAngleAroundAxis(h,u,c))}if(p&&B>=n.orientationStartIndex&&B<=n.effectorIndex){this.links[Math.max(0,Math.min(this.links.length-1,n.orientationEvalIndex))].object.getWorldQuaternion(this._tmpEffWorldQ),this._tmpTarWorldQ.copy(this.targetQuaternion),this._tmpDirCurP.copy(n.effectorForwardAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarP.copy(n.targetForwardAxis).applyQuaternion(this._tmpTarWorldQ).normalize();const ee=this._signedAngleAroundAxis(this._tmpDirCurP,this._tmpDirTarP,c);let Es=0;n.upWeight>0&&(this._tmpDirCurS.copy(n.effectorUpAxis).applyQuaternion(this._tmpEffWorldQ).normalize(),this._tmpDirTarS.copy(n.targetUpAxis).applyQuaternion(this._tmpTarWorldQ).normalize(),Es=this._signedAngleAroundAxis(this._tmpDirCurS,this._tmpDirTarS,c)),U+=n.forwardWeight*ee+n.upWeight*Es}if(Math.abs(U)<1e-6)continue;const Ze=Math.max(0,this._jointWeights[B]??1);if(Ze<=0)continue;if(U*=Math.max(0,Math.min(1,this.damping))*Ze,this.maxStep>0){const X=this.maxStep*Ze;if(X<=0)continue;U>X?U=X:U<-X&&(U=-X)}if(this.maxAngleDelta>0){const X=((C=this._frameAppliedAbsDelta[B])==null?void 0:C[O])??0,ee=Math.max(0,this.maxAngleDelta-X);if(ee<=0)continue;U>ee?U=ee:U<-ee&&(U=-ee)}const ve=this._jointStates[B];ve.currentAngles||(ve.currentAngles=new Array(W.length).fill(0));const Nt=(ve.currentAngles[O]??0)+U,jt=(P=this._axisMins[B])==null?void 0:P[O],ye=(D=this._axisMaxs[B])==null?void 0:D[O];U=this._clamp(Nt,jt,ye)-(ve.currentAngles[O]??0),!(Math.abs(U)<1e-9)&&(ve.currentAngles[O]=(ve.currentAngles[O]??0)+U,ve.currentAngle=ve.currentAngles[0]??0,Math.abs(U)>F&&(F=Math.abs(U)),this._frameAppliedAbsDelta[B]&&(this._frameAppliedAbsDelta[B][O]=(this._frameAppliedAbsDelta[B][O]??0)+Math.abs(U)),this._applyLinkAngles(B),N.updateMatrixWorld(!0))}}if(F<1e-5&&S<=l*4&&(!p||I<=d*2))break}}}const Ee=new f.Raycaster,Dt=new f.Vector3,bl=new f.Quaternion,pr=new f.Vector3,mr=new f.Vector3,Ui={type:"change"},gr={type:"mouseDown",mode:null},_r={type:"mouseUp",mode:null},Al={type:"objectChange"},ti=new WeakMap,ii=new WeakMap,Rt=new WeakMap;function Tl(a){if(!this.domElement)return{x:0,y:0,button:a.button};if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:a.button};const e=this.domElement.getBoundingClientRect();return{x:(a.clientX-e.left)/e.width*2-1,y:-((a.clientY-e.top)/e.height)*2+1,button:a.button}}function si(a,e,t){const i=e.intersectObject(a,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}function Hi(a){return a==="E"?"rotate":a==="XYZ"?"translate":null}class Sl extends f.Object3D{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;t.object!==void 0&&(t.object.updateMatrixWorld(),t.object.parent===null?console.error("FreeTransformControls: 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)}dispose(){this.traverse(e=>{const t=e;t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose()})}}const $=class $ extends f.Object3D{constructor(e){super(),this.picker=new f.Object3D,this.gizmo=new f.Object3D,this.helper=new f.Object3D,this._matMove=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matRing=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1}),this._matInvisible=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:0}),this._matHelper=new f.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.6}),this._arcSegments=96,this._arcStartAngleOffset=.05,this._moveColorDefault=new f.Color(16777215),this._moveColorActive=new f.Color(0),this._moveOpacityDefault=1,this._moveOpacityRingActive=.5,this._ringColorDefault=new f.Color(16777215),this._ringColorActive=new f.Color(0),this._ringOpacityDefault=1,this._ringOpacityActive=.6,this._ringScale=1,this._ringTargetScale=1.5,this._ringScaleTweening=!1,this._isMoveActive=!1,this._isRingActive=!1,this._isMoveHover=!1,this._isDragging=!1,this._isExpanded=!1,this.controls=e,this._moveMesh=new f.Mesh(new f.CircleGeometry($.MOVE_RADIUS,96),this._matMove),this._moveMesh.rotateX(-Math.PI/2),this._moveMesh.name="XYZ",this._moveMesh.renderOrder=1/0,this._ringMesh=new f.Mesh(new f.TorusGeometry($.RING_RADIUS,$.RING_TUBE,48,96),this._matRing),this._ringMesh.name="E",this._ringMesh.renderOrder=1e3,this._arcGeom=new es.LineGeometry,this._arcPositions=new Float32Array((this._arcSegments+1)*3),this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=0;const t=new kr.LineMaterial({color:16777215,linewidth:2,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:1});t.resolution.set(window.innerWidth,window.innerHeight),this._arcLine=new Er.Line2(this._arcGeom,t),this._arcLine.renderOrder=1001,this._arcLine.visible=!1,this.gizmo.add(this._ringMesh),this.gizmo.add(this._moveMesh),this.gizmo.add(this._arcLine);const i=new f.Mesh(new f.CircleGeometry($.PICKER_MOVE_RADIUS,32),this._matInvisible);i.name="XYZ",i.renderOrder=1/0;const s=new f.Mesh(new f.TorusGeometry($.RING_RADIUS+.005,$.PICKER_RING_TUBE,8,48),this._matInvisible);s.name="E",s.renderOrder=1/0,this.picker.add(s),this.picker.add(i),this.picker.visible=!1;const r=new f.OctahedronGeometry(.01,2),o=new f.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0,opacity:.7});this._startMarker=new f.Mesh(r,o),this._startMarker.renderOrder=1/0,this._startMarker.visible=!1,this._endMarker=new f.Mesh(r,o),this._endMarker.renderOrder=1/0,this._endMarker.visible=!1,this._deltaGeom=new f.BufferGeometry,this._deltaGeom.setAttribute("position",new f.Float32BufferAttribute(new Float32Array(2*3),3)),this._deltaLine=new f.Line(this._deltaGeom,this._matHelper),this._deltaLine.renderOrder=1/0,this._deltaLine.visible=!1,this.helper.add(this._startMarker),this.helper.add(this._endMarker),this.helper.add(this._deltaLine),this.add(this.gizmo),this.add(this.picker),this.add(this.helper)}get isExpanded(){return this._isExpanded}set isExpanded(e){var s;if(this._isExpanded===e)return;this._isExpanded=e;const t=e?this._ringTargetScale:1;this._ringScaleTweening=!0,(s=this._ringScaleTween)==null||s.stop();const i={scale:this._ringScale};this._ringScaleTween=new oe.Tween(i).to({scale:t},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._ringScale=i.scale}).onStop(()=>{this._ringScaleTweening=!1}).onComplete(()=>{this._ringScaleTweening=!1}).start()}get isRingScaleTweening(){return this._ringScaleTweening}updateMatrixWorld(e){var y,x;const t=this.controls,i=t.axis,s=t.mode,r=t.worldPosition,o=t.size;this._arcLine.material.resolution.set(window.innerWidth,window.innerHeight);const h=(w,b=1)=>{w.position.copy(r),w.scale.set(1,1,1).multiplyScalar(o*b),w.visible=!0};h(this._moveMesh),h(this._ringMesh,this._ringScale),h(this._arcLine,this._ringScale),this.picker.position.copy(r),this.picker.scale.set(1,1,1).multiplyScalar(o);for(const w of this.picker.children)w.quaternion.copy(t.cameraQuaternion),w.scale.set(1,1,1).multiplyScalar(this._ringScale);this._ringMesh.quaternion.copy(t.cameraQuaternion),this._arcLine.quaternion.copy(t.cameraQuaternion),this._moveMesh.lookAt(t.cameraPosition);const u=s==="default"||s==="translate",p=s==="default"||s==="rotate";this._moveMesh.visible=u,this._ringMesh.visible=p;for(const w of this.picker.children)w.name==="XYZ"&&(w.visible=u),w.name==="E"&&(w.visible=p);const n=t.dragging,l=!n&&i==="XYZ",d=!n&&i==="E",g=l||n&&i==="XYZ",v=d||n&&i==="E";if(g!==this._isMoveActive){this._isMoveActive=g;const w=g?this._moveColorActive:this._moveColorDefault;(y=this._moveColorTween)==null||y.stop();const b={r:this._matMove.color.r,g:this._matMove.color.g,b:this._matMove.color.b};this._moveColorTween=new oe.Tween(b).to({r:w.r,g:w.g,b:w.b},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._matMove.color.setRGB(b.r,b.g,b.b)}).start()}if(v!==this._isRingActive){this._isRingActive=v;const w=v?this._ringColorActive:this._ringColorDefault,b=v?this._ringOpacityActive:this._ringOpacityDefault,T=v?this._moveOpacityRingActive:this._moveOpacityDefault;this._matMove.opacity=T,(x=this._ringColorTween)==null||x.stop();const M={r:this._matRing.color.r,g:this._matRing.color.g,b:this._matRing.color.b,opacity:this._matRing.opacity};this._ringColorTween=new oe.Tween(M).to({r:w.r,g:w.g,b:w.b,opacity:b},200).easing(oe.Easing.Quadratic.Out).onUpdate(()=>{this._matRing.color.setRGB(M.r,M.g,M.b),this._matRing.opacity=M.opacity}).start()}const m=n;if(this._startMarker.visible=m,this._endMarker.visible=m,this._deltaLine.visible=m,m){this._startMarker.position.copy(t.worldPositionStart),this._endMarker.position.copy(t.worldPosition),this._startMarker.scale.set(1,1,1).multiplyScalar(o),this._endMarker.scale.set(1,1,1).multiplyScalar(o);const w=this._deltaGeom.getAttribute("position");w.setXYZ(0,t.worldPositionStart.x,t.worldPositionStart.y,t.worldPositionStart.z),w.setXYZ(1,t.worldPosition.x,t.worldPosition.y,t.worldPosition.z),w.needsUpdate=!0,this._deltaGeom.computeBoundingSphere()}const _=m&&p&&i==="E";if(this._arcLine.visible=_,_){const w=t.pointStart,b=t.pointEnd;if(w.lengthSq()>1e-12&&b.lengthSq()>1e-12){pr.set(1,0,0).applyQuaternion(t.cameraQuaternion),mr.set(0,1,0).applyQuaternion(t.cameraQuaternion);const T=w.dot(pr),M=w.dot(mr),R=Math.atan2(M,T),C=t.rotationAngle;if(Math.abs(C)<1e-4)this._arcLine.visible=!1,this._arcGeom.instanceCount=0;else{const P=this._arcSegments,D=Math.max(2,Math.min(P,Math.ceil(Math.abs(C)/(Math.PI*2)*P))),A=C/D,S=$.RING_RADIUS,L=Math.sign(C)*this._arcStartAngleOffset;for(let F=0;F<=D;F++){const z=R+L+A*F,B=Math.cos(z)*S,N=Math.sin(z)*S,W=F*3;this._arcPositions[W]=B,this._arcPositions[W+1]=N,this._arcPositions[W+2]=0}for(let F=D+1;F<=P;F++){const z=F*3;this._arcPositions[z]=0,this._arcPositions[z+1]=0,this._arcPositions[z+2]=0}this._arcGeom.setPositions(this._arcPositions),this._arcGeom.instanceCount=D,this._arcLine.computeLineDistances(),this._arcGeom.computeBoundingSphere();const I=Math.cos(R)*$.RING_RADIUS*this._ringScale,k=Math.sin(R)*$.RING_RADIUS*this._ringScale;Dt.set(I,k,0),Dt.applyQuaternion(t.cameraQuaternion),Dt.multiplyScalar(o),Dt.add(r),this._startMarker.position.copy(Dt)}}else this._arcLine.visible=!1,this._arcGeom.instanceCount=0}else this._arcGeom.instanceCount=0;super.updateMatrixWorld(e)}};$.RING_RADIUS=.18,$.RING_TUBE=.003,$.PICKER_RING_TUBE=.025,$.MOVE_RADIUS=.04,$.PICKER_MOVE_RADIUS=.2;let hs=$;class Ml extends f.Mesh{constructor(){super(new f.PlaneGeometry(1e5,1e5,2,2),new f.MeshBasicMaterial({visible:!1,wireframe:!0,transparent:!0,opacity:.1,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),this.isTransformControlsPlane=!0}updateMatrixWorld(e){const t=this,i=t.dragging?t.worldPositionStart:t.worldPosition;this.position.copy(i),this.quaternion.copy(t.cameraQuaternion),super.updateMatrixWorld(e)}}class Cl extends f.EventDispatcher{constructor(e,t=null){super(),this.domElement=null,this._offset=new f.Vector3,this._startNorm=new f.Vector3,this._endNorm=new f.Vector3,this._cameraScale=new f.Vector3,this._parentPosition=new f.Vector3,this._parentQuaternion=new f.Quaternion,this._parentQuaternionInv=new f.Quaternion,this._parentScale=new f.Vector3,this._worldScaleStart=new f.Vector3,this._worldQuaternionInv=new f.Quaternion,this._worldScale=new f.Vector3,this._positionStart=new f.Vector3,this._quaternionStart=new f.Quaternion,this._scaleStart=new f.Vector3,this._capturePointerId=null,this._captureDocument=null,this._hoverShieldActive=!1;const i=new Sl(this);this._root=i;const s=new hs(this);this._gizmo=s,i.add(s);const r=new Ml;this._plane=r,i.add(r);const o=this;function c(h,u){let p=u;Object.defineProperty(o,h,{get(){return p!==void 0?p:u},set(n){p!==n&&(p=n,r[h]=n,s[h]=n,o.dispatchEvent({type:h+"-changed",value:n}),o.dispatchEvent(Ui))}}),o[h]=u,r[h]=u,s[h]=u}c("camera",e),c("object",void 0),c("enabled",!0),c("depthTest",!0),c("axis",null),c("mode","default"),c("space","world"),c("size",.25),c("dragging",!1),c("gizmoPriority",!0),c("worldPosition",new f.Vector3),c("worldPositionStart",new f.Vector3),c("worldQuaternion",new f.Quaternion),c("worldQuaternionStart",new f.Quaternion),c("cameraPosition",new f.Vector3),c("cameraQuaternion",new f.Quaternion),c("pointStart",new f.Vector3),c("pointEnd",new f.Vector3),c("rotationAxis",new f.Vector3),c("rotationAngle",0),c("eye",new f.Vector3),this._getPointer=Tl.bind(this),this._onPointerDown=this._handlePointerDown.bind(this),this._onPointerHover=this._handlePointerHover.bind(this),this._onPointerMove=this._handlePointerMove.bind(this),this._onPointerUp=this._handlePointerUp.bind(this),this._onPointerDownCapture=this._handlePointerDownCapture.bind(this),this._onPointerMoveCapture=this._handlePointerMoveCapture.bind(this),this._onPointerUpCapture=this._handlePointerUpCapture.bind(this),this._onMouseMoveCapture=this._handleMouseMoveCapture.bind(this),t!==null&&this.connect(t)}connect(e){this.domElement=e,this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none";const t=this.domElement.ownerDocument;this._captureDocument=t,t.addEventListener("pointerdown",this._onPointerDownCapture,!0),t.addEventListener("pointermove",this._onPointerMoveCapture,!0),t.addEventListener("pointerup",this._onPointerUpCapture,!0),t.addEventListener("mousemove",this._onMouseMoveCapture,!0)}disconnect(){this.domElement&&(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",this._captureDocument&&(this._captureDocument.removeEventListener("pointerdown",this._onPointerDownCapture,!0),this._captureDocument.removeEventListener("pointermove",this._onPointerMoveCapture,!0),this._captureDocument.removeEventListener("pointerup",this._onPointerUpCapture,!0),this._captureDocument.removeEventListener("mousemove",this._onMouseMoveCapture,!0),this._captureDocument=null))}getHelper(){return this._root}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this.dragging=!1,this._setHoverShieldActive(!1),this._root.visible=!1,this}getMode(){return this.mode}setMode(e){this.mode=e,this.axis=null,this.dispatchEvent(Ui)}setSize(e){this.size=e}getRaycaster(){return Ee}_handlePointerHover(e){if(this.enabled)switch(e.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(e));break}}_handlePointerDown(e){if(!this.enabled||!this.domElement)return;document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove);const t=this._getPointer(e);this.pointerHover(t),this.pointerDown(t)}_handlePointerMove(e){this.enabled&&this.pointerMove(this._getPointer(e))}_handlePointerUp(e){this.enabled&&this.domElement&&(this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(e)))}_setHoverShieldActive(e){if(!this.domElement)return;const t=this.domElement.ownerDocument;if(e){if(this._hoverShieldActive)return;this._hoverShieldActive=!0;const r=Rt.get(t)??0;Rt.set(t,r+1);let o=ii.get(t);o||(o=t.createElement("div"),o.style.position="fixed",o.style.left="0",o.style.top="0",o.style.right="0",o.style.bottom="0",o.style.cursor="grab",o.style.pointerEvents="auto",o.style.background="transparent",o.style.zIndex="2147483647",ii.set(t,o)),o.parentElement||t.body.appendChild(o);return}if(!this._hoverShieldActive)return;this._hoverShieldActive=!1;const i=Rt.get(t)??0,s=Math.max(0,i-1);if(s===0){Rt.delete(t);const r=ii.get(t);r!=null&&r.parentElement&&r.parentElement.removeChild(r),ii.delete(t)}else Rt.set(t,s)}_handlePointerDownCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=e.target;if(t&&(t===this.domElement||this.domElement.contains(t)))return;const i=this._getPointer(e);this.pointerHover(i),!(!this.axis||!this._isAxisAllowed(this.axis))&&i.button===0&&(this._capturePointerId=e.pointerId,document.pointerLockElement||this.domElement.setPointerCapture(e.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerDown(i))}_handlePointerMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this._capturePointerId===e.pointerId&&this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerMove(t);return}this.dragging||(this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation()))}_handleMouseMoveCapture(e){if(!this.enabled||!this.domElement||!this.gizmoPriority)return;const t=this._getPointer(e);if(this.dragging){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}this.pointerHover(t),this.axis&&this._isAxisAllowed(this.axis)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())}_handlePointerUpCapture(e){!this.enabled||!this.domElement||!this.gizmoPriority||this._capturePointerId===e.pointerId&&(this._capturePointerId=null,this.domElement.releasePointerCapture(e.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),this.pointerUp(this._getPointer(e)))}pointerHover(e){if(this.object===void 0||this.dragging===!0)return;e!==null&&Ee.setFromCamera(e,this.camera);const t=this._gizmo.picker.children.find(h=>h.name==="XYZ"),i=this._gizmo.picker.children.find(h=>h.name==="E"),s=t?si(t,Ee):!1,r=i?si(i,Ee):!1;let o=this._gizmo.isExpanded,c=null;o?r&&!this._gizmo.isRingScaleTweening?c="E":s?c="XYZ":(o=!1,c=null):s&&(o=!0,c="XYZ"),this._gizmo.isExpanded!==o&&(this._gizmo.isExpanded=o),c&&this._isAxisAllowed(c)?this.axis=c:this.axis=null,this._setHoverShieldActive(!!this.axis||this.dragging),this._updateCursor()}pointerDown(e){if(!(this.object===void 0||this.dragging===!0||e!=null&&e.button!==0)&&this.axis!==null&&this._isAxisAllowed(this.axis)){e!==null&&Ee.setFromCamera(e,this.camera);const t=si(this._plane,Ee,!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,this._setHoverShieldActive(!0);const i=Hi(this.axis);gr.mode=i,this.dispatchEvent(gr),this._updateCursor()}}pointerMove(e){const t=this.axis,i=this.object;if(i===void 0||t===null||this.dragging===!1||e!==null&&e.button!==-1||!this._isAxisAllowed(t))return;const s=Hi(t);if(!s)return;e!==null&&Ee.setFromCamera(e,this.camera);const r=si(this._plane,Ee,!0);r&&(this.pointEnd.copy(r.point).sub(this.worldPositionStart),s==="translate"?(this._offset.copy(this.pointEnd).sub(this.pointStart),this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),i.position.copy(this._offset).add(this._positionStart)):s==="rotate"&&(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.rotationAxis.applyQuaternion(this._parentQuaternionInv),i.quaternion.copy(bl.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),i.quaternion.multiply(this._quaternionStart).normalize()),this.dispatchEvent(Ui),this.dispatchEvent(Al))}pointerUp(e){if(!(e!==null&&e.button!==0)){if(this.dragging&&this.axis!==null){const t=Hi(this.axis);_r.mode=t,this.dispatchEvent(_r)}this.dragging=!1,this.axis=null,this._setHoverShieldActive(!1),this._updateCursor()}}_updateCursor(){if(!this.domElement)return;const e=ti.get(this.domElement);if(this.dragging){this.domElement.style.cursor="grabbing",ti.set(this.domElement,this);return}if(this.axis){this.domElement.style.cursor="grab",ti.set(this.domElement,this);return}e===this&&(this.domElement.style.cursor="",ti.delete(this.domElement))}_isAxisAllowed(e){return this.mode==="default"?e==="XYZ"||e==="E":this.mode==="translate"?e==="XYZ":this.mode==="rotate"?e==="E":!1}}class Dl{constructor(e,t){var n;this.isController=!0,this._enabled=!0,this._tmpQ=new f.Quaternion,this._tmpContainerQ=new f.Quaternion,this._tmpV=new f.Vector3,this._resetHierarchy=!1,this._defaultPoseQuats=new Map,this._zeroPoseQuats=new Map,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._initialTargetPos=new f.Vector3,this._initialTargetQuat=new f.Quaternion,this._axesHelpers=[],this._showAxes=!1;const{joints:i,container:s,context:r,resetHierarchy:o}=e,c=(Array.isArray(i)?i:[]).map(l=>l.object);this._container=s,this._context=r,this._resetHierarchy=!!o;let h;if(Array.isArray(i))for(let l=0;l<i.length;l++)(n=i[l])!=null&&n.ikTcp&&(h=i[l].object);this._effector=h??c[c.length-1],this._resetHierarchy&&this.setupHierarchy(c),c.forEach(l=>{l&&(this._defaultPoseQuats.has(l.uuid)||this._defaultPoseQuats.set(l.uuid,l.quaternion.clone()))}),this.transformControls=new Cl(t.camera,t.domElement),this.transformControls.addEventListener("dragging-changed",({value:l})=>{this._emitter.emit("dragging-changed",l),l||this.syncTargetToEffector()}),this.transformControls.addEventListener("axis-changed",({value:l})=>{this.transformControls.dragging||(this.targetObject.visible=l==="E")}),this.targetObject=new f.Object3D,this.targetObject.name="ikTarget",this.targetObject.visible=!1,this.targetObject.userData.isIKTarget=!0,this.transformControls.attach(this.targetObject);const u=new f.AxesHelper(.0675);u.material.depthTest=!1,u.material.depthWrite=!1,u.renderOrder=1e3,this.targetObject.add(u),this.syncTargetToEffector(),this._initialTargetPos.copy(this.targetObject.position),this._initialTargetQuat.copy(this.targetObject.quaternion);const p=this.transformControls.getHelper();this._container.add(this.targetObject),this._container.add(p),this.solver=new dr(i,r),this.solver.links.forEach((l,d)=>{const g=l.object;if(g){const v=this.solver.restQuaternions[d];v&&this._zeroPoseQuats.set(g.uuid,v.clone())}}),c.forEach(l=>{const d=new f.AxesHelper(.2);d.visible=!1,l.add(d),this._axesHelpers.push(d)})}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.transformControls.enabled=e,this.transformControls.getHelper().visible=e}get showAxes(){return this._showAxes}set showAxes(e){this._showAxes=e,this._axesHelpers.forEach(t=>t.visible=e)}getEffectorLocalPos(){var t;const e=new f.Vector3;return this._effector&&(this._effector.getWorldPosition(e),(t=this._container)==null||t.worldToLocal(e)),e}getEffectorLocalQuat(){const e=new f.Quaternion;return this._effector&&(this._effector.getWorldQuaternion(e),this._container&&(this._container.getWorldQuaternion(this._tmpContainerQ),this._tmpContainerQ.invert(),e.premultiply(this._tmpContainerQ))),e}setupHierarchy(e){for(let t=0;t<e.length-1;t++){const i=e[t],s=e[t+1];s.parent!==i&&i.attach(s)}}syncTargetToEffector(){this.targetObject.position.copy(this.getEffectorLocalPos()),this.targetObject.quaternion.copy(this.getEffectorLocalQuat()),this.targetObject.updateMatrixWorld(!0)}syncTargetToSolver(){this.solver&&(this.targetObject.getWorldPosition(this._tmpV),this.solver.target.copy(this._tmpV),this.targetObject.getWorldQuaternion(this._tmpQ),this.solver.targetQuaternion.copy(this._tmpQ))}setControlMode(e){this.transformControls.setMode(e)}setOrientation(e){this.solver&&(this.solver.orientation.forwardAxis=e.forwardAxis,this.solver.orientation.upAxis=e.upAxis)}updateJointChain(e){var h;const t=(Array.isArray(e)?e:[]).filter(u=>!!(u!=null&&u.object));if(t.length<2||!this._container)return;const i=t.map(u=>u.object);i.forEach(u=>{u&&(this._defaultPoseQuats.has(u.uuid)||this._defaultPoseQuats.set(u.uuid,u.quaternion.clone()),this._zeroPoseQuats.has(u.uuid)||this._zeroPoseQuats.set(u.uuid,u.quaternion.clone()))});let s;for(let u=0;u<t.length;u++)(h=t[u])!=null&&h.ikTcp&&(s=t[u].object);this._effector=s??i[i.length-1],this._resetHierarchy&&this.setupHierarchy(i);const r=this.solver,o=new dr(t,this._context);r&&(o.iterations=r.iterations,o.minDistance=r.minDistance,o.maxStep=r.maxStep,o.damping=r.damping,o.maxAngleDelta=r.maxAngleDelta,r.orientation&&o.orientation&&Object.assign(o.orientation,r.orientation));const c=o.links.map(u=>this._zeroPoseQuats.get(u.object.uuid));o.rebindRestPoseWithBase(c),this.solver=o,this._axesHelpers.forEach(u=>u.removeFromParent()),this._axesHelpers=[],i.forEach(u=>{const p=new f.AxesHelper(.2);p.visible=this._showAxes,u.add(p),this._axesHelpers.push(p)}),this.syncTargetToEffector(),this.syncTargetToSolver()}update(){!this._enabled||!this.solver||(this.syncTargetToSolver(),this.solver.update())}toggleOrientation(e){this.solver&&(this.solver.orientation.enabled=e)}setSolverContext(e){this.solver&&(typeof e.iterations=="number"&&(this.solver.iterations=e.iterations),typeof e.damping=="number"&&(this.solver.damping=e.damping))}reset(){if(!(!this.solver||!this._container)){for(const e of this.solver.links){const t=e==null?void 0:e.object;if(!t)continue;const i=this._defaultPoseQuats.get(t.uuid);i&&t.quaternion.copy(i)}this._container.updateMatrixWorld(!0),this.solver.updateJointStateFromCurrentPose(),this.syncTargetToEffector(),this.syncTargetToSolver()}}dispose(){this.transformControls.detach(),this.transformControls.dispose(),this.targetObject.removeFromParent(),this._axesHelpers.forEach(e=>e.removeFromParent()),this._axesHelpers=[]}}const Rl=(a,e,t,i={})=>{const s=[],{resetHierarchy:r,onDraggingChanged:o}=i;return a.forEach(c=>{if(!(c!=null&&c.joints)||c.joints.length<2)return;const h=new Dl({joints:c.joints,container:e,context:{orientation:c.orientation},resetHierarchy:r},t);o&&h.addListener("dragging-changed",u=>{o(h,u)}),s.push(h)}),s},Rs=new f.TextureLoader;Rs.crossOrigin="anonymous";class ln extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new Ke,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new f.Group,this.lines=new f.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new f.Clock,this.sizeBox=new xl,this._goodsSize=new ol(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],this._ikChains=[],this.ikControllers=[],this._ikDraggingControllers=new Set,this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._videoCache=new Map,this._rollerColumns=1,this._bodyOpacity=1,this._masts=new Map,this._liftMaxHeight=0,this._jackMaxHeight=0,this._forkMaxHeight=0,this.controllers=[],this.goods=[],this._breathLights=[],this._shelves=new Map,this._shelfMaxLevel=1,this._url="",this._showController=!0,this._showSlots=!0,this._shapeKeys=new Map,this._shapeKeyTargets=new Map,this._shapeKeyTimer=0,this._shapeKeyCache="",this.shapeKeyDirty=!1,this._materialsCache=new Map,this.opacityCache=void 0,this.actions=[],this._useCenterModel=!1,this._useLift=!1,this._columnCount=1,this._columnGap=.03,this._rowCount=1,this._rowGap=.01,this._levelCount=1,this._currentAction=null,this._pendingFinishedCallback=null,this._url=e.url||"",this._url&&this.load(this._url).then(),this.add(this._container,this.lines),this._props.showSizeBox&&this.add(this.sizeBox),this.showController=typeof e.showController=="boolean"?e.showController:!0,this._showSlots=typeof e.showSlots=="boolean"?e.showSlots:!0}get shapeKeys(){return this._shapeKeys}get size(){const e=this.sizeBox.size.getSize(new f.Vector3);return{width:e.z,length:e.x,height:e.y}}get goodsSize(){return this._goodsSize}get showController(){return this._showController}set showController(e){this._showController=e,this.controllers.forEach(t=>e?t.show():t.hide())}get slots(){return this._slots}get logos(){return this._logos}get skins(){return this._skins}get bodyOpacity(){return this._bodyOpacity}get fork(){return this._fork}get forkHeight(){var e;return((e=this._fork)==null?void 0:e.position.z)||0}get liftHeight(){var e;return this._lift?this._lift instanceof Map?((e=this._lift.get(0))==null?void 0:e.position.z)||0:this._lift.position.z||0:0}get jack(){return this._jack}get jackHeight(){var e;return((e=this._jack)==null?void 0:e.position.z)||0}get lift(){return this._lift}get useCenterModel(){return this._useCenterModel}set useCenterModel(e){this._useCenterModel=e,this._rollerLevel.forEach(t=>{t.traverse(i=>{i.userData.isCenterModel&&(i.visible=e)})})}set bodyOpacity(e){this._bodyOpacity=e,e<1?this._materialsCache.forEach(t=>{t.mat.transparent=!0,t.mat.opacity=e,t.mat.metalness=0,t.mat.roughness=1,t.mat.color=new f.Color("#3859be"),t.mat.needsUpdate=!0}):this._materialsCache.forEach(t=>{t.mat.transparent=t.transparent,t.mat.opacity=t.opacity,t.mat.metalness=t.metalness,t.mat.roughness=t.roughness,t.mat.color=t.color,t.mat.needsUpdate=!0})}init(e){this._app=e,this.sizeBox.init(e),this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=()=>{if(this._mixer){const t=this._animationClock.getDelta();this._mixer.update(t)}else this._animationClock.getDelta();this.ikControllers.forEach(t=>t.update())},this._app.renderer.domElement.addEventListener("ticker",this._onTicker),this.addEventListener("shape-key-changed",(t,i)=>{if(this._slots.forEach(s=>s.shapeKeyChanged(t,i)),this.sizeBox.follow===t?(this.sizeBox.generate(this._container,i),this.sizeBox.originOffset&&(this._container.traverse(s=>{s instanceof f.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof ls&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new f.Vector3(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0))}),this.sizeBox.translateCache=this.sizeBox.originOffset,this.sizeBox.generate(this._container))):this.sizeBox.generate(this._container),["width","length","height"].includes(t)&&this._emitter.emit("size-changed",t,i),t==="goodsLength"){const s=i;this._goodsSize.length=this._layoutLengthToItemLength(s),this._applyDerivedSizesFromLayoutGoodsLength(s),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}t==="goodsWidth"&&(this._goodsSize.width=i,this._applyDerivedSizesFromGoodsWidth(i),this._columnCount>1&&this.setColumns(this._columnCount,!1),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize())})}_syncRollerGoodsBoxesFromGoodsSize(){const e=h=>{var n;const u=[],p=[...h.children];for(;p.length;){const l=p.pop();if((n=l.userData)!=null&&n.isRollerLevelBox){u.push(l);continue}l.children&&l.children.length&&p.push(...l.children)}return u},t=Math.max(1,this._rowCount||1),i=t>1?this._rowGap:0,s=this._goodsSize.length||0,r=this._getLayoutGoodsLength(s),o=s+i,c=t>0?-r/2+s/2:0;this._rollerLevel.forEach(h=>{e(h).forEach(p=>{const n=p.children.filter(l=>l instanceof we);for(n.forEach(l=>{l.userData.__amrRollerGoodsBox=!0,this.goods.includes(l)||this.goods.push(l)});n.length<t;){const l=new we(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);l.userData.__amrRollerGoodsBox=!0,p.add(l),this.goods.push(l),n.push(l)}for(let l=t;l<n.length;l++){const d=n[l];this.goods=this.goods.filter(g=>g!==d),d.dispose(),d.removeFromParent()}for(let l=0;l<t;l++){const d=n[l];d.updateSize(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height),d.position.y=c+o*l}})})}_syncShelvesFromGoodsSize(){const e=this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"),t=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.forEach(i=>{let s=this._shelfSyncCache.get(i);s||(s={container:void 0,morphMeshes:[],goodsBoxes:[]},i.traverse(c=>{var h;if((h=c.userData)!=null&&h.isShelfContainer&&(s.container=c),c instanceof we&&s.goodsBoxes.push(c),Wi(c)){const u=c,p=u.morphTargetDictionary||{};(Object.prototype.hasOwnProperty.call(p,"goodsWidth")||Object.prototype.hasOwnProperty.call(p,"goodsLength"))&&s.morphMeshes.push(u)}}),this._shelfSyncCache.set(i,s)),s.goodsBoxes.forEach(c=>{c.updateSize(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height)}),s.morphMeshes.forEach(c=>{this.setShapeKeyToMesh(c,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(c,"goodsLength",t)});const r=s.container;if(!r)return;typeof r.userData.__goodsBaseX!="number"&&(r.userData.__goodsBaseX=r.position.x);const o=r.userData.__goodsBaseX;r.position.x=e?o+t/2:o})}_findFirstSkinnedMesh(e){if(!e)return;let t;return e.traverse(i=>{!t&&i.isSkinnedMesh&&(t=i)}),t}async loadAnimation(e,t="sglb"){let i,s;if(t==="glb"||e.endsWith(".glb")){const h=await qe.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const u=await new Ht({useCache:!0}).loadAsync(e);i=u.animations||[],s=u.scene}else{console.warn("[Amr.loadAnimation] 目前仅支持 glb/sglb 动画文件",{url:e,type:t});return}if(!i||i.length===0){console.warn("[Amr.loadAnimation] 文件中未找到动画",e);return}if(!this._modelRoot){console.warn("[Amr.loadAnimation] 模型尚未加载,无法绑定动画",e);return}if(!s){console.warn("[Amr.loadAnimation] 动画文件中缺少 scene,无法执行重定向",e);return}const r=this._findFirstSkinnedMesh(s),o=this._findFirstSkinnedMesh(this._modelRoot);(!r||!o)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof Li.retargetClip=="function";i.forEach(h=>{let u=h;if(c&&r&&o)try{u=Li.retargetClip(o,r,h)}catch(n){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,n)}this._clips=this._clips.filter(n=>n.name!==u.name),this._clips.push(u);const p=this._mixer.clipAction(u);this._actionsMap.set(u.name,p)}),this.actions=Array.from(this._actionsMap.keys())}async load(e,t=""){this._url=e,this.name||(this.name=e.substring(e.lastIndexOf("/")+1,e.lastIndexOf("."))),!e.startsWith("blob")&&e.endsWith(".sglb");let i,s;if(t==="glb"||e.endsWith(".glb")){let o=await qe.loadAsync(e);i=o.scene,s=o.animations||[]}else{const c=await new Ht({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const r=Li.clone(i);this._generateAmr(r,s),i=null,this._emitter.emit("amr-loaded")}changeSkin(e,t){e&&(e.change(t),this._app&&this._app.usePathTracing&&(this._app.sampleCount=0,this._app.usePathTracing&&(this._app.pathTracer.pausePathTracing=!1,this._app.pathTracer.updateMaterials())))}changeLogo(e,t){e.change(t.url,new f.Vector2(t.scaleX,t.scaleY),new f.Vector2(t.ox,t.oy))}getShapeKeyTargets(e){return this._shapeKeyTargets.get(e)||[]}setShapeKey(e,t,i=!0){i&&this._shapeKeyTimer&&e===this._shapeKeyCache&&clearTimeout(this._shapeKeyTimer),this._shapeKeyCache=e,this._shapeKeyTimer=window.setTimeout(()=>{this.getShapeKeyTargets(e).forEach(r=>{var h;performance.now();let o=t;r.userData[`origin_${e}`]&&(o-=r.userData[`origin_${e}`]);const c=(h=r.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o)}),i&&this._emitter.emit("shape-key-changed",e,t),this.shapeKeyDirty=!0},0)}_generateAmr(e,t){var i,s;this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(r=>{const o=this._mixer.clipAction(r);this._actionsMap.set(r.name,o)}),this.actions=t.map(r=>r.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shapekeyRules=void 0,e.traverse(r=>{if(r.userData.isShelf&&(this._shelf=r),r.userData.isFork&&(this._fork=r),r.userData.isMast&&r.userData.mastLevel&&this._masts.set(r.userData.mastLevel,r),r.userData.isJack&&(this._jack=r),r.userData.isLift&&(this._lift=r),r.userData.isRollerLevel&&this._rollerLevel.set(r.userData.level||0,r),r.userData.isCenterModel&&(r.visible=this.useCenterModel),r.userData.isSwitch&&r.userData.switchName==="top"&&(this._rollerTop=r),r.userData.isLiftBracket&&(this._liftBrackets.push(r),r.visible=this._useLift),r.userData.isBaffle&&(this._rollerBaffle=r,r.visible=!this._useLift),r.userData.isRoller&&(this._roller=r,this._roller.visible=!1,this._generateRollers()),r.userData.isRollerLevelBox){this._rollerGoodsBox=r;const o=new we(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);r.add(o),this.goods.push(o)}if(Object.keys(r.morphTargetDictionary||{}).forEach(o=>{let c=r.morphTargetInfluences[r.morphTargetDictionary[o]];r.userData[`origin_${o}`]&&(c+=r.userData[`origin_${o}`]),this._shapeKeys.has(o)||this._shapeKeys.set(o,c);const h=this._shapeKeyTargets.get(o);h?h.push(r):this._shapeKeyTargets.set(o,[r])}),r.userData.shapekeyRules&&!this._shapekeyRules)try{typeof r.userData.shapekeyRules=="string"?this._shapekeyRules=JSON.parse(r.userData.shapekeyRules):Array.isArray(r.userData.shapekeyRules)&&(this._shapekeyRules=r.userData.shapekeyRules)}catch(o){console.error(o)}}),e.traverse(r=>{if(r instanceof f.Mesh){if(r.castShadow=!0,r.receiveShadow=!0,r.material)if(Array.isArray(r.material))r.material.forEach(c=>{c.userData.changeColor&&(this.skins.find(h=>h.name===c.userData.name)||this.skins.push(new xs({name:c.userData.name,target:c})))});else{if(r.material.userData.isVideo&&r.material.userData.video){const c=r.material.userData.video;let h=this._videoCache.get(c);h||(h=document.createElement("video"),h.src=c,h.crossOrigin="anonymous",h.loop=!0,h.muted=!0,h.playsInline=!0,h.autoplay=!0,h.preload="auto",this._videoCache.set(c,h)),h.play().catch(()=>{}),r.material.map&&r.material.map.dispose(),r.material.emissiveMap&&r.material.emissiveMap.dispose();const u=new f.VideoTexture(h);u.colorSpace=f.SRGBColorSpace,u.generateMipmaps=!0,u.minFilter=f.LinearMipmapLinearFilter,r.material.map=u,r.material.emissiveMap=u,r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=1,r.material.needsUpdate=!0}if(r.material.userData.isBreathLight&&r.material.emissiveIntensity){r.material.emissive||(r.material.emissive=new f.Color(16777215)),r.material.emissiveIntensity=2,r.material.toneMapped=!1;const c=1e3,h=new oe.Tween(r.material).to({emissiveIntensity:.2}).easing(oe.Easing.Quintic.InOut).duration(c),u=new oe.Tween(r.material).to({emissiveIntensity:2}).easing(oe.Easing.Quintic.InOut).duration(c);h.onComplete(()=>u.start()),u.onComplete(()=>h.start()),h.start(),this._breathLights.push(h,u)}r.material.userData.changeColor&&(this.skins.find(c=>c.name===r.material.userData.name)||this.skins.push(new xs({name:r.material.userData.name,target:r.material})))}if(r.material)if(Array.isArray(r.material))r.material.forEach(h=>{if(h.userData.isLOGO){r.material.transparent=!0;let u;const p={width:0,height:0};r.material.map&&r.material.map.image&&(p.width=r.material.map.image.width,p.height=r.material.map.image.height,u=as(r.material.map.image)),r.material.needsUpdate=!0;const n=new cs({name:h.userData.name,target:r,size:ar(r),imageSize:p,imageUrl:u});this._logos.push(n)}h.userData.isTransparent&&(h.transparent=!0),this._materialsCache.set(h.uuid,{opacity:h.opacity,transparent:h.transparent,roughness:h.roughness,metalness:h.metalness,color:h.color,mat:h})});else{const c=r.material;if(c.userData.isLOGO){r.material.transparent=!0;let h;const u={width:0,height:0};r.material.map&&r.material.map.image&&(u.width=r.material.map.image.width,u.height=r.material.map.image.height,h=as(r.material.map.image));const p=new cs({name:c.userData.name,target:r,size:ar(r),imageSize:u,imageUrl:h});this._logos.push(p)}c.userData.isTransparent&&(c.transparent=!0),this._materialsCache.set(c.uuid,{opacity:c.opacity,transparent:c.transparent,roughness:c.roughness,metalness:c.metalness,color:c.color,mat:c})}}this.generateController(r,e),this.generateDimension(r,e);const o=this.generateSlot(r,e);o&&this._slots.push(o),r.userData.isOrigin&&Object.keys(r.userData).forEach(h=>{if(h.startsWith("follow_")){const u=h.replace("follow_","");this.shapeKeys.has(u)&&(this.sizeBox.follow=u,this.sizeBox.followOrigin=this._shapeKeys.get(u)||0,this.sizeBox.followScale=r.userData[h])}})}),this.slots.forEach(r=>{r.props.mirrorTarget&&(r.mirrorTarget=this.slots.find(o=>o.props.slot.name===r.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this._buildJointChain(e),this._disposeIkControllers(),this._ikChains.length&&(this.ikControllers=Rl(this._ikChains,this,{camera:(i=this._app)==null?void 0:i.camera,domElement:(s=this._app)==null?void 0:s.renderer.domElement},{onDraggingChanged:(r,o)=>{this._onIkDraggingChanged(r,o)}}),this._ikChains.forEach((r,o)=>{r.controller=this.ikControllers[o]})),this.sizeBox.generate(e),this.sizeBox.show()}_syncIkDraggingState(){this._app&&(this._app.controls.enabled=this._ikDraggingControllers.size===0)}_onIkDraggingChanged(e,t){t?this._ikDraggingControllers.add(e):this._ikDraggingControllers.delete(e),this._syncIkDraggingState()}_disposeIkControllers(){this.ikControllers.forEach(e=>e.dispose()),this.ikControllers=[],this._ikChains.forEach(e=>{e.controller=void 0}),this._ikDraggingControllers.clear(),this._syncIkDraggingState()}_buildJointChain(e){if(this._ikChains=[],!this._ikChains.length){const t=[];e.traverse(i=>{const s=te(i==null?void 0:i.name);s&&s.startsWith("ArmatureRoot")&&t.push(i)}),t.sort((i,s)=>te(i.name).localeCompare(te(s.name))),t.forEach(i=>{const{joints:s,orientation:r}=this._buildIKChainParams(i);if(s.length<2)return;const o={enabled:!0,...r};this._ikChains.push({name:i.name,joints:s,baseLinks:s.slice(),toolLinks:[],orientation:o})})}}_findIkChainByNode(e){var t;for(const i of this._ikChains){if(!((t=i.baseLinks)!=null&&t.length))continue;const s=new Set(i.baseLinks.map(o=>o.object.uuid));let r=e;for(;r;){if(s.has(r.uuid))return i;r=r.parent}}}updateIkJointChainByTool(e,t){if(!e)return;const i=this._findIkChainByNode(e);if(console.log("chain",i),!i||!i.controller||!i.baseLinks||i.baseLinks.length<2)return;const s=(u,p)=>{if(!p.length)return!1;const n=new Set;return u.traverse(l=>n.add(l.uuid)),p.some(l=>n.has(l.uuid))};if(t==="uninstall"){if(!(!!i.toolRootUuid&&e.uuid===i.toolRootUuid||i.toolLinks.length>0&&s(e,i.toolLinks.map(p=>p.object))))return;i.toolLinks=[],i.toolRootUuid=void 0,i.joints=i.baseLinks.slice(),i.controller.updateJointChain(i.joints);return}const{joints:r,orientation:o}=this._buildIKChainParams(e);if(!r.length)return;o&&i.controller.setOrientation(o);const c=!!i.toolRootUuid&&e.uuid===i.toolRootUuid,h=i.toolLinks.length>0;if(c&&h){i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints);return}i.toolRootUuid=e.uuid,i.toolLinks=r,i.joints=[...i.baseLinks,...i.toolLinks],i.controller.updateJointChain(i.joints)}_buildIKChainParams(e){var o,c,h,u;if(!e)return{joints:[],orientation:void 0};const t=[];let i;const s=p=>{const n=p.children.find(l=>{var d,g;return((d=l.userData)==null?void 0:d.isJoint)||((g=l.userData)==null?void 0:g.isTcp)});if(n)return n;for(const l of p.children){const d=s(l);if(d)return d}};let r=(o=e.userData)!=null&&o.isJoint||(c=e.userData)!=null&&c.isTcp?e:s(e);for(;r;){if(console.log("cur",r),(h=r.userData)!=null&&h.isJoint){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,axes:p})}else if((u=r.userData)!=null&&u.isTcp){const p=this._parseIkAxes(r.userData.ikAxes);this._fillInitialRotationValues(r,p),t.push({object:r,ikTcp:!0,axes:p}),i=this._parseIkOrientation(r.userData.ikOrientation)??i;break}r=s(r)}return{joints:t,orientation:i}}_fillInitialRotationValues(e,t){if(!t||!e)return;const i=e.rotation;t.forEach(s=>{const{axis:r}=s;Math.abs(r.x)>.9?s.value=i.x*Math.sign(r.x):Math.abs(r.y)>.9?s.value=i.y*Math.sign(r.y):Math.abs(r.z)>.9&&(s.value=i.z*Math.sign(r.z))})}_axisFromLetter(e){const t=String(e).trim().toUpperCase();if(t==="X")return new f.Vector3(1,0,0);if(t==="Y")return new f.Vector3(0,1,0);if(t==="Z")return new f.Vector3(0,0,1)}_parseIkAxes(e){if(!e||typeof e!="string")return;const t=JSON.parse(e);if(!(!Array.isArray(t)||t.length===0))return t.map(i=>{const s=this._axisFromLetter(i.axis)??new f.Vector3(0,0,0),r=typeof i.min=="number"?f.MathUtils.degToRad(i.min):void 0,o=typeof i.max=="number"?f.MathUtils.degToRad(i.max):void 0;return{axis:s,min:r,max:o}})}_parseIkOrientation(e){if(!e)return;const t=typeof e=="string"?JSON.parse(e):e,i=this._axisFromLetter(t.forwardAxis),s=this._axisFromLetter(t.upAxis);if(!(!i||!s))return{forwardAxis:i,upAxis:s}}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){const t=this._shapekeyRules;if(console.log(e,t),t&&Array.isArray(t)&&t.length>0){for(const i of t){let s=null,r=-1/0;for(const o of i.configs)e>o.liftHeightThreshold&&o.liftHeightThreshold>r&&(r=o.liftHeightThreshold,s=o.value);s!==null&&this.setShapeKey(i.targetKey,s)}return}this.name==="SFL-CDD14"&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CDD20","SFL-CDD20-Y"].includes(this.name)&&(e>1.6?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),this.name==="SFL-CDD15"&&(e>2.43?this.setShapeKey("mast",1):this.setShapeKey("mast",0)),["SFL-CPD20-Y","SFL-CPD30-Y"].includes(this.name)&&(e>3.5?this.setShapeKey("mast",2):e>3?this.setShapeKey("mast",1):this.setShapeKey("mast",0))}setForkHeight(e){if(this._fork){if(e>this._forkMaxHeight&&(e=this._forkMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("forkHeight",e,!1)}),this._fork.position.z=e,this._masts.size===1){const t=this._masts.get(2),i=(t==null?void 0:t.userData.startHeight)||.1;t&&(t.position.z=(e-i)*.5)}this._emitter.emit("fork-height-change",e)}}setForkMaxHeight(e){this._fork&&(this._forkMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{te(t.name).toLowerCase().includes("fork")&&(t.props.max=e)}),this._fork&&this.forkHeight>this._forkMaxHeight&&this.setForkHeight(e))}setLiftHeight(e){if(this._lift)if(e>this._liftMaxHeight&&(e=this._liftMaxHeight),this._lift instanceof Map){const t=this._lift.get(0);t&&(t.position.z=e)}else this._lift&&(this._lift.position.z=e)}getLiftMaxHeight(){return this._liftMaxHeight}setLiftMaxHeight(e){if(!this._lift)return;this._liftMaxHeight=e,this.limitValue(e),this.controllers.forEach(r=>{te(r.name).toLowerCase().includes("lift")&&(r.props.max=e)}),this.liftHeight>this._liftMaxHeight&&this.setLiftHeight(e);let t=.46;this.levelOffset&&(t=this.levelOffset+.1);let i=e+t;const s=this.getShelfMinHeight()+t||0;i<s&&(i=s),this.setHeight(i)}setJackMaxHeight(e){this._jack&&(this._jackMaxHeight=e,this.limitValue(e),this.controllers.forEach(t=>{te(t.name).toLowerCase().includes("jack")&&(t.props.max=e)}),this.jackHeight>this._jackMaxHeight&&this.setJackHeight(e))}setJackHeight(e){this._jack&&(e>this._jackMaxHeight&&(e=this._jackMaxHeight),requestAnimationFrame(()=>{this.setShapeKey("jackHeight",e,!1)}),this._jack.position.z=e)}setLevel(e){}setGoodsSize(e){this._goodsSize.length=e.length,this._goodsSize.width=e.width,this._goodsSize.height=e.height,this.setShelfLevel(this._shelfMaxLevel),this.setRoller(),this._rollerLevel.forEach(t=>{t.traverse(i=>{i instanceof we&&i.updateSize(e.width,e.length,e.height)})})}setRoller(){}get isTopInvert(){if(this._rollerTop)return Math.abs(this._rollerTop.rotation.z)===Math.PI/2}setTopInvert(e=!0){this._rollerTop&&(this._rollerTop.rotation.z=e?Math.PI/2:0,this.setShapeKey("switch",e?1:0),this.setShapeKey("goodsWidth",this.goodsSize.width),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this.goodsSize.length)))}get useLift(){return this._useLift}set useLift(e){var t;this._lift&&(this._useLift=e,(t=this._rollerTop)==null||t.traverse(i=>{i.userData.isBaffle&&(i.visible=!e),i.userData.isLiftBracket&&(i.visible=e)}))}get columns(){return this._columnCount}get rows(){return this._rowCount}setRows(e){const t=Math.max(1,Math.floor(e||1));if(t===this._rowCount)return;this._rowCount=t;const i=this._getLayoutGoodsLength(this._goodsSize.length);this.setShapeKey("goodsLength",i,!1),this._applyDerivedSizesFromLayoutGoodsLength(i),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize(),this._syncShelvesFromGoodsSize()}_getLayoutGoodsLength(e=this._goodsSize.length){const t=Math.max(1,this._rowCount||1),i=e||0;return t<=1?i:i*t+this._rowGap*(t-1)}_layoutLengthToItemLength(e){const t=Math.max(1,this._rowCount||1);if(t<=1)return Math.max(0,e||0);const i=this._rowGap*(t-1);return Math.max(0,((e||0)-i)/t)}setGoodsItemLength(e){this._goodsSize.length=e;const t=this._getLayoutGoodsLength(e);this.setShapeKey("goodsLength",t)}_applyDerivedSizesFromLayoutGoodsLength(e){const t=e+.14-.54;this.setShapeKey("boxLength",t);const i=e+.14;if(this.setShapeKey("topWidth",i),this.isTopInvert){const s=e-.259;this.setShapeKey("length",s)}else this.setShapeKey("width",i)}_applyDerivedSizesFromGoodsLength(e){const t=this._getLayoutGoodsLength(e);this._applyDerivedSizesFromLayoutGoodsLength(t)}_applyDerivedSizesFromGoodsWidth(e){const t=Math.max(1,this._columnCount||1),i=.125,s=t===1?e+i:(e+i)*t+this._columnGap*(t-1),r=s+.06;this.setShapeKey("boxWidth",r);const o=s+.085;if(this.setShapeKey("topLength",o),this.isTopInvert){const c=s+.485;this.setShapeKey("width",c)}else this.setShapeKey("length",o)}setColumns(e,t=!0){const i=Math.max(1,Math.floor(e||1));this._columnCount=i,this._rollerLevel.forEach(s=>{const r=s.children.filter(d=>{var g;return(g=d.userData)==null?void 0:g.isRollerLevelBox}),o=r.length>0?(Math.min(...r.map(d=>d.position.x))+Math.max(...r.map(d=>d.position.x)))/2:0;s.children.filter(d=>{var g,v;return((g=d.userData)==null?void 0:g.isRollerLevelBox)&&((v=d.userData)==null?void 0:v.cloned)}).forEach(d=>s.remove(d));const c=s.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned)||s.children.find(d=>d.userData.isRollerLevelBox);if(!c)return;const h=tl(c,s,new f.Vector3),u=this._columnGap,n=h.x+u,l=(i-1)*n/2;c.position.x=o-l;for(let d=1;d<i;d++){const g=c.clone(!0);g.userData.cloned=!0,this._stripRollerInstances(g),this.regenerateShapeKeyNode(g),g.position.x=o-l+d*n,s.add(g)}}),t&&this._applyDerivedSizesFromGoodsWidth(this.goodsSize.width),this._pruneShapeKeyTargets(),this.setShapeKey("goodsWidth",this._goodsSize.width,!1),this.setShapeKey("goodsLength",this._getLayoutGoodsLength(this._goodsSize.length),!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}get levels(){return this._levelCount}setLevels(e){var o;const t=Math.max(1,Math.floor(e||1));this._levelCount=t;const i=this._rollerLevel.size,s=t-i,r=this._rollerLevel.get(0);if(s>0&&r){for(let h=i;h<t;h++){const u=r.clone(!0);u.visible=!0,this._stripRollerInstances(u),u.position.z=r.position.z+.2*h,u.userData.level=h,this._rollerLevel.set(h,u),(o=r.parent)==null||o.add(u),this.regenerateShapeKeyNode(u),u.traverse(p=>{p instanceof we&&(p.updateSize(this.goodsSize.width,this.goodsSize.length,this.goodsSize.height),this.goods.push(p))})}this._columnCount>1&&this.setColumns(this._columnCount,!1),this._generateRollers(),this._syncRollerGoodsBoxesFromGoodsSize()}else for(let c=0;c<i;c++){const h=this._rollerLevel.get(c);h&&(h.visible=c<t)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{Wi(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);s&&s.push(t)})})}_stripRollerInstances(e){const t=[];e.traverse(i=>{var s,r;((s=i==null?void 0:i.userData)!=null&&s.__amrRollerInstance||(r=i==null?void 0:i.userData)!=null&&r.isCloned)&&t.push(i)}),t.forEach(i=>{i.parent&&i.removeFromParent()})}_isInAmrContainer(e){let t=e;for(;t;){if(t===this._container||t===this)return!0;t=t.parent}return!1}_pruneShapeKeyTargets(){this._shapeKeyTargets.forEach((e,t)=>{const i=new Set,s=[];for(const r of e)r&&this._isInAmrContainer(r)&&(i.has(r.uuid)||(i.add(r.uuid),s.push(r)));this._shapeKeyTargets.set(t,s)})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=this._getLayoutGoodsLength(this._goodsSize.length);e=e||.5;const t=.05;let i=.02;const r=e-i,o=t+i;let c=Math.floor(r/o);const h=r%o,u=l=>{var v;const d=[],g=[...l.children];for(;g.length;){const m=g.pop();if((v=m.userData)!=null&&v.isRollerLevelBox){d.push(m);continue}m.children&&m.children.length&&g.push(...m.children)}return d},p=[];this._rollerLevel.forEach(l=>{p.push(...u(l))});let n=!1;if(p.forEach(l=>{const d=[];l.traverse(g=>{var v,m;g!==l&&((v=g==null?void 0:g.userData)!=null&&v.isCloned)&&!((m=g==null?void 0:g.userData)!=null&&m.__amrRollerInstance)&&d.push(g)}),d.forEach(g=>g.removeFromParent()),d.length&&(n=!0)}),n&&this._pruneShapeKeyTargets(),c>0){c>1&&(i+=h/(c+2));const l=t+i,d=-e/2+i+t/2;p.forEach(g=>{let v=this._rollerPools.get(g);for(v||(v=[],this._rollerPools.set(g,v));v.length<c;){const m=this._roller.clone(!0);m.visible=!1,m.userData.__amrRollerInstance=!0,m.userData.isCloned=!0,g.add(m),this.regenerateShapeKeyNode(m),v.push(m)}for(let m=0;m<c;m++){const _=v[m];_.parent!==g&&g.add(_),_.visible=!0,_.position.y=d+l*m}for(let m=c;m<v.length;m++)v[m].visible=!1})}else p.forEach(l=>{const d=this._rollerPools.get(l);d&&d.forEach(g=>g.visible=!1)})}getShelfMinHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);return i?i.position.z+e*t+.1:0}getShelfMaxShelfHeight(){const e=this.levelOffset,t=this._shelfMaxLevel,i=this._shelves.get(0);if(i)return i.position.z+e*(t-1)}get levelOffset(){return this._goodsSize.height+.2}setShapeKeyToMesh(e,t,i){if(!Object.keys(e.morphTargetDictionary||{}).includes(t))return;const s=e.morphTargetDictionary[t];e.morphTargetInfluences&&(e.morphTargetInfluences[s]=i),this.shapeKeyDirty=!0}setShelfLevel(e=3){var r;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset,i=this._getLayoutGoodsLength(this._goodsSize.length);this._shelves.delete(0),this._shelves.forEach(o=>{Re(o),o.parent&&o.removeFromParent()}),this.goods=this.goods.filter(o=>{var c;return(c=o==null?void 0:o.userData)==null?void 0:c.__amrRollerGoodsBox}),this._shelves.clear(),this._shelves.set(0,this._shelf);for(let o=1;o<e;o++){if(!this._shelf)return;this._shelf.traverse(u=>{Wi(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"goodsLength",i))});const c=this._shelf.clone(!0);c.position.z+=t*o,this._shelves.set(o,c),(r=this._shelf.parent)==null||r.add(c);let h;if(c.traverse(u=>{u.userData.isShelfContainer&&(h=u)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&h&&(typeof h.userData.__goodsBaseX!="number"&&(h.userData.__goodsBaseX=h.position.x),h.position.x=h.userData.__goodsBaseX+i/2),h){const u=new we(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(u.userData.__amrShelfGoodsBox=!0,h.add(u),this.goods.push(u),o===1){const p=new we(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);p.userData.__amrShelfGoodsBox=!0,p.position.z-=t,h.add(p),this.goods.push(p)}}}const s=this.getShelfMinHeight()||0;this._liftMaxHeight<s&&this.setLiftMaxHeight(s)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new an(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=te(e.userData.target.name),{min:s,max:r}=e.userData;let o;if(!i||(t.traverse(h=>{const u=te(h==null?void 0:h.name);u&&u===i&&(o=h)}),!o))return;const c=new fr({name:"",target:i,default:0,min:s,max:r},o);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=te(e.userData.target.name),{min:s,max:r}=e.userData;let o;if(!i||(t.traverse(h=>{const u=te(h==null?void 0:h.name);u&&u===i&&(o=h)}),!o))return;const c=new fr({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:r||1},o);if(e.add(c),this.controllers.push(c),c.addListener("change",()=>{this.ikControllers.forEach(h=>{h.enabled=!1}),clearTimeout(this._ikControllersTimer),this._ikControllersTimer=setTimeout(()=>{this.ikControllers.forEach(h=>{h.enabled=!0,h.syncTargetToEffector()})},100)}),o.userData.isFork||o.userData.isLift||o.userData.isJack){this._forkMaxHeight=r||1,this._liftMaxHeight=r||1,this._jackMaxHeight=r||1;const h=o.position.z;this.setForkHeight(h),this.setLiftHeight(h),this.setJackHeight(h),c.addListener("change",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)})}}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=il(e.userData.startOrigin),r=e.userData.axios;let o,c;if(r==="x"?(o=new f.Vector3(e.userData.start-e.position.x,0,0),c=o.clone().setX(e.userData.end-e.position.x)):r==="z"?(o=new f.Vector3(0,e.userData.start-e.position.y,0),c=o.clone().setY(e.userData.end-e.position.y)):(o=new f.Vector3(0,0,e.userData.start-e.position.z),c=o.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(n=>{var d;if(!n.startsWith("target"))return[];const l=te((d=e.userData[n])==null?void 0:d.name);return l?[l]:[]}).length)return;const p=new yl({start:o,end:c,startOrigin:s,axios:r,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const r=te(e.userData.name),o=e.userData.isMirror,c=te((i=e.userData.mirrorSlot)==null?void 0:i.name);if(r){const h=e.userData.holeTarget&&e.userData.holeTarget.name,u=te(h);let p;u&&t.traverse(g=>{const v=te(g==null?void 0:g.name);v&&v===u&&(p=g)});const n=new Map;Object.keys(e.userData).forEach(g=>{if(g.startsWith("follow_")){const v=g.split("_")[1];if(v){let m=e.userData[g];n.set(v,{scale:m,initPos:e.position.clone(),origin:this.shapeKeys.get(v)||0})}}});const l=(s=this._app)==null?void 0:s.props.isMobile,d=new ls({name:r,follows:n,slot:e,show:this._showSlots,isMirror:o,mirrorTarget:c,isMobile:l});return d.holeTarget=p,d.addEventListener(J.ON_DROP,g=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),d.addEventListener(J.ON_DEVICE_REPLACED,g=>{g&&this.updateIkJointChainByTool(g,"install")}),d.addEventListener(J.ON_DEVICE_DELETED,g=>{g&&this.updateIkJointChainByTool(g,"uninstall")}),d.addEventListener(J.ON_BEFORE_SELECTED,g=>{this._slots.forEach(v=>{v.selected&&(v.selected=!1)})}),d.addEventListener(J.ON_ERROR_STATE_CHANGE,g=>{var m;if(!this._app)return;const v=(m=this._app)==null?void 0:m._outlinePassError;if(v)if(v.selectedObjects=v.selectedObjects.filter(_=>!!_.parent),g){if(d.device){if(v.selectedObjects.find(y=>{var x;return y.parent===((x=d.device)==null?void 0:x.parent)}))return;v.selectedObjects=[d.device,...v.selectedObjects]}}else d.device&&(v.selectedObjects=v.selectedObjects.filter(_=>{var y;return _.parent!==((y=d.device)==null?void 0:y.parent)}))}),d}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),Re(this._container),this._slots=[],this._logos=[],this._skins=[],this._materialsCache.clear(),this.opacityCache=void 0,this._breathLights.forEach(e=>e.stop()),this._breathLights=[],this.sizeBox.reset(),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),this._shelfSyncCache=new WeakMap,this._rollerPools=new WeakMap,this._shapeKeyTimer&&(clearTimeout(this._shapeKeyTimer),this._shapeKeyTimer=0),this._currentAction=null,this._pendingFinishedCallback&&this._mixer&&(this._mixer.removeEventListener("finished",this._pendingFinishedCallback),this._pendingFinishedCallback=null),this._mixer&&(this._mixer.stopAllAction(),this._modelRoot&&this._mixer.uncacheRoot(this._modelRoot)),this._mixer=void 0,this._clips=[],this._actionsMap.clear(),this.actions=[],this._disposeIkControllers(),this._lift=void 0,this._fork=void 0,this._jack=void 0,this._roller=void 0,this._rollerBaffle=void 0,this._rollerTop=void 0,this._shelf=void 0,this._rollerGoodsBox=void 0,this._modelRoot=void 0,this.goods.forEach(e=>{e.dispose(),e.parent&&e.removeFromParent()}),this.goods=[],this._liftBrackets=[],this._videoCache.forEach(e=>{e.pause(),e.removeAttribute("src"),e.load(),e.remove()}),this._videoCache.clear(),this._masts.clear(),this._shelves.clear(),this._outline&&(this._outline.removeFromParent(),this._outline=void 0),this._app&&this._onTicker&&this._app.renderer.domElement.removeEventListener("ticker",this._onTicker),this._onTicker=void 0}destroy(){this.clean(),this.sizeBox.destroy()}playAction(e,t){const i=Object.keys(t||{}).includes("reset")?t==null?void 0:t.reset:!0,s=this._actionsMap.get(e);if(!s||!this._mixer)return Promise.reject(new Error(`Action "${e}" not found or mixer not initialized.`));if(s.isRunning()&&s===this._currentAction)return Promise.resolve();const r=this._currentAction,o=r===s,c=o?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=r&&!o&&r.isRunning();this._actionsMap.forEach(n=>{n!==s&&n!==r&&(n.stopFading(),n.setEffectiveWeight(0),n.stop())});const u=(t==null?void 0:t.loop)??!1;(i||!s.isRunning())&&s.reset(),s.enabled=!0,s.setEffectiveTimeScale((t==null?void 0:t.timeScale)??1),s.setEffectiveWeight(1),s.paused=!1,s.setLoop(u?f.LoopRepeat:f.LoopOnce,u?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!u,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(r.stopFading(),r.enabled=!0,r.setEffectiveWeight(1),r.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(n=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=d=>{var g;d.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,n())};this._pendingFinishedCallback=l,this._mixer.addEventListener("finished",l)})}pauseAction(e){const t=this._actionsMap.get(e);t&&(t.paused=!0)}stopAction(e,t=.3){const i=this._actionsMap.get(e);return!i||!i.isRunning()?Promise.resolve():(this._currentAction===i&&(this._currentAction=null),t>0?(i.fadeOut(t),new Promise(s=>{setTimeout(()=>{i.stop(),s()},t*1e3)})):(i.stop(),Promise.resolve()))}stopAllActions(e=.3){return this._mixer?(this._currentAction=null,e>0?(this._actionsMap.forEach(t=>{t.isRunning()&&t.fadeOut(e)}),new Promise(t=>{setTimeout(()=>{var i;(i=this._mixer)==null||i.stopAllAction(),t()},e*1e3)})):(this._mixer.stopAllAction(),Promise.resolve())):Promise.resolve()}playVideos(){this._videoCache.forEach(e=>{e.play().catch(()=>{})})}}const cn=0,Ll=1,Pl=2,vr=2,Gi=1.25,yr=1,Wt=6*4+4+4,Ci=65535,Il=Math.pow(2,-24),Ni=Symbol("SKIP_GENERATION");function El(a){return a.index?a.index.count:a.attributes.position.count}function wt(a){return El(a)/3}function kl(a,e=ArrayBuffer){return a>65535?new Uint32Array(new e(4*a)):new Uint16Array(new e(2*a))}function Fl(a,e){if(!a.index){const t=a.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=kl(t,i);a.setIndex(new f.BufferAttribute(s,1));for(let r=0;r<t;r++)s[r]=r}}function hn(a){const e=wt(a),t=a.drawRange,i=t.start/3,s=(t.start+t.count)/3,r=Math.max(0,i),o=Math.min(e,s)-r;return[{offset:Math.floor(r),count:Math.floor(o)}]}function un(a){if(!a.groups||!a.groups.length)return hn(a);const e=[],t=new Set,i=a.drawRange,s=i.start/3,r=(i.start+i.count)/3;for(const c of a.groups){const h=c.start/3,u=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(r,u))}const o=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<o.length-1;c++){const h=o[c],u=o[c+1];e.push({offset:Math.floor(h),count:Math.floor(u-h)})}return e}function Bl(a){if(a.groups.length===0)return!1;const e=wt(a),t=un(a).sort((r,o)=>r.offset-o.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:r})=>s+=r),e!==s}function ji(a,e,t,i,s){let r=1/0,o=1/0,c=1/0,h=-1/0,u=-1/0,p=-1/0,n=1/0,l=1/0,d=1/0,g=-1/0,v=-1/0,m=-1/0;for(let _=e*6,y=(e+t)*6;_<y;_+=6){const x=a[_+0],w=a[_+1],b=x-w,T=x+w;b<r&&(r=b),T>h&&(h=T),x<n&&(n=x),x>g&&(g=x);const M=a[_+2],R=a[_+3],C=M-R,P=M+R;C<o&&(o=C),P>u&&(u=P),M<l&&(l=M),M>v&&(v=M);const D=a[_+4],A=a[_+5],S=D-A,L=D+A;S<c&&(c=S),L>p&&(p=L),D<d&&(d=D),D>m&&(m=D)}i[0]=r,i[1]=o,i[2]=c,i[3]=h,i[4]=u,i[5]=p,s[0]=n,s[1]=l,s[2]=d,s[3]=g,s[4]=v,s[5]=m}function Ol(a,e=null,t=null,i=null){const s=a.attributes.position,r=a.index?a.index.array:null,o=wt(a),c=s.normalized;let h;e===null?(h=new Float32Array(o*6*4),t=0,i=o):(h=e,t=t||0,i=i||o);const u=s.array,p=s.offset||0;let n=3;s.isInterleavedBufferAttribute&&(n=s.data.stride);const l=["getX","getY","getZ"];for(let d=t;d<t+i;d++){const g=d*3,v=d*6;let m=g+0,_=g+1,y=g+2;r&&(m=r[m],_=r[_],y=r[y]),c||(m=m*n+p,_=_*n+p,y=y*n+p);for(let x=0;x<3;x++){let w,b,T;c?(w=s[l[x]](m),b=s[l[x]](_),T=s[l[x]](y)):(w=u[m+x],b=u[_+x],T=u[y+x]);let M=w;b<M&&(M=b),T<M&&(M=T);let R=w;b>R&&(R=b),T>R&&(R=T);const C=(R-M)/2,P=x*2;h[v+P+0]=M+C,h[v+P+1]=C+(Math.abs(M)+C)*Il}}return h}function K(a,e,t){return t.min.x=e[a],t.min.y=e[a+1],t.min.z=e[a+2],t.max.x=e[a+3],t.max.y=e[a+4],t.max.z=e[a+5],t}function xr(a){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=a[i+3]-a[i];s>t&&(t=s,e=i)}return e}function wr(a,e){e.set(a)}function br(a,e,t){let i,s;for(let r=0;r<3;r++){const o=r+3;i=a[r],s=e[r],t[r]=i<s?i:s,i=a[o],s=e[o],t[o]=i>s?i:s}}function ri(a,e,t){for(let i=0;i<3;i++){const s=e[a+2*i],r=e[a+2*i+1],o=s-r,c=s+r;o<t[i]&&(t[i]=o),c>t[i+3]&&(t[i+3]=c)}}function Lt(a){const e=a[3]-a[0],t=a[4]-a[1],i=a[5]-a[2];return 2*(e*t+t*i+i*e)}const Se=32,zl=(a,e)=>a.candidate-e.candidate,ke=new Array(Se).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ni=new Float32Array(6);function Vl(a,e,t,i,s,r){let o=-1,c=0;if(r===cn)o=xr(e),o!==-1&&(c=(e[o]+e[o+3])/2);else if(r===Ll)o=xr(a),o!==-1&&(c=Wl(t,i,s,o));else if(r===Pl){const h=Lt(a);let u=Gi*s;const p=i*6,n=(i+s)*6;for(let l=0;l<3;l++){const d=e[l],m=(e[l+3]-d)/Se;if(s<Se/4){const _=[...ke];_.length=s;let y=0;for(let w=p;w<n;w+=6,y++){const b=_[y];b.candidate=t[w+2*l],b.count=0;const{bounds:T,leftCacheBounds:M,rightCacheBounds:R}=b;for(let C=0;C<3;C++)R[C]=1/0,R[C+3]=-1/0,M[C]=1/0,M[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;ri(w,t,T)}_.sort(zl);let x=s;for(let w=0;w<x;w++){const b=_[w];for(;w+1<x&&_[w+1].candidate===b.candidate;)_.splice(w+1,1),x--}for(let w=p;w<n;w+=6){const b=t[w+2*l];for(let T=0;T<x;T++){const M=_[T];b>=M.candidate?ri(w,t,M.rightCacheBounds):(ri(w,t,M.leftCacheBounds),M.count++)}}for(let w=0;w<x;w++){const b=_[w],T=b.count,M=s-b.count,R=b.leftCacheBounds,C=b.rightCacheBounds;let P=0;T!==0&&(P=Lt(R)/h);let D=0;M!==0&&(D=Lt(C)/h);const A=yr+Gi*(P*T+D*M);A<u&&(o=l,u=A,c=b.candidate)}}else{for(let x=0;x<Se;x++){const w=ke[x];w.count=0,w.candidate=d+m+x*m;const b=w.bounds;for(let T=0;T<3;T++)b[T]=1/0,b[T+3]=-1/0}for(let x=p;x<n;x+=6){let T=~~((t[x+2*l]-d)/m);T>=Se&&(T=Se-1);const M=ke[T];M.count++,ri(x,t,M.bounds)}const _=ke[Se-1];wr(_.bounds,_.rightCacheBounds);for(let x=Se-2;x>=0;x--){const w=ke[x],b=ke[x+1];br(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<Se-1;x++){const w=ke[x],b=w.count,T=w.bounds,R=ke[x+1].rightCacheBounds;b!==0&&(y===0?wr(T,ni):br(T,ni,ni)),y+=b;let C=0,P=0;y!==0&&(C=Lt(ni)/h);const D=s-y;D!==0&&(P=Lt(R)/h);const A=yr+Gi*(C*y+P*D);A<u&&(o=l,u=A,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${r} used.`);return{axis:o,pos:c}}function Wl(a,e,t,i){let s=0;for(let r=e,o=e+t;r<o;r++)s+=a[r*6+i*2];return s/t}class Qi{constructor(){this.boundingData=new Float32Array(6)}}function Ul(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){for(let p=0;p<3;p++){let n=e[o*3+p];e[o*3+p]=e[c*3+p],e[c*3+p]=n}for(let p=0;p<6;p++){let n=t[o*6+p];t[o*6+p]=t[c*6+p],t[c*6+p]=n}o++,c--}else return o}}function Hl(a,e,t,i,s,r){let o=i,c=i+s-1;const h=r.pos,u=r.axis*2;for(;;){for(;o<=c&&t[o*6+u]<h;)o++;for(;o<=c&&t[c*6+u]>=h;)c--;if(o<c){let p=a[o];a[o]=a[c],a[c]=p;for(let n=0;n<6;n++){let l=t[o*6+n];t[o*6+n]=t[c*6+n],t[c*6+n]=l}o++,c--}else return o}}function ae(a,e){return e[a+15]===65535}function ce(a,e){return e[a+6]}function he(a,e){return e[a+14]}function ue(a){return a+8}function fe(a,e){return e[a+6]}function fn(a,e){return e[a+7]}let dn,Ot,xi,pn;const Gl=Math.pow(2,32);function us(a){return"count"in a?1:1+us(a.left)+us(a.right)}function Nl(a,e,t){return dn=new Float32Array(t),Ot=new Uint32Array(t),xi=new Uint16Array(t),pn=new Uint8Array(t),fs(a,e)}function fs(a,e){const t=a/4,i=a/2,s="count"in e,r=e.boundingData;for(let o=0;o<6;o++)dn[t+o]=r[o];if(s)if(e.buffer){const o=e.buffer;pn.set(new Uint8Array(o),a);for(let c=a,h=a+o.byteLength;c<h;c+=Wt){const u=c/2;ae(u,xi)||(Ot[c/4+6]+=t)}return a+o.byteLength}else{const o=e.offset,c=e.count;return Ot[t+6]=o,xi[i+14]=c,xi[i+15]=Ci,a+Wt}else{const o=e.left,c=e.right,h=e.splitAxis;let u;if(u=fs(a+Wt,o),u/4>Gl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Ot[t+6]=u/4,u=fs(u,c),Ot[t+7]=h,u}}function jl(a,e){const t=(a.index?a.index.count:a.attributes.position.count)/3,i=t>2**16,s=i?4:2,r=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),o=i?new Uint32Array(r):new Uint16Array(r);for(let c=0,h=o.length;c<h;c++)o[c]=c;return o}function Ql(a,e,t,i,s){const{maxDepth:r,verbose:o,maxLeafTris:c,strategy:h,onProgress:u,indirect:p}=s,n=a._indirectBuffer,l=a.geometry,d=l.index?l.index.array:null,g=p?Hl:Ul,v=wt(l),m=new Float32Array(6);let _=!1;const y=new Qi;return ji(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){u&&u(b/v)}function w(b,T,M,R=null,C=0){if(!_&&C>=r&&(_=!0,o&&(console.warn(`MeshBVH: Max depth of ${r} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),M<=c||C>=r)return x(T+M),b.offset=T,b.count=M,b;const P=Vl(b.boundingData,R,e,T,M,h);if(P.axis===-1)return x(T+M),b.offset=T,b.count=M,b;const D=g(n,d,e,T,M,P);if(D===T||D===T+M)x(T+M),b.offset=T,b.count=M;else{b.splitAxis=P.axis;const A=new Qi,S=T,L=D-T;b.left=A,ji(e,S,L,A.boundingData,m),w(A,S,L,m,C+1);const I=new Qi,k=D,F=M-L;b.right=I,ji(e,k,F,I.boundingData,m),w(I,k,F,m,C+1)}return b}}function ql(a,e){const t=a.geometry;e.indirect&&(a._indirectBuffer=jl(t,e.useSharedArrayBuffer),Bl(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),a._indirectBuffer||Fl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=Ol(t),r=e.indirect?hn(t):un(t);a._roots=r.map(o=>{const c=Ql(a,s,o.offset,o.count,e),h=us(c),u=new i(Wt*h);return Nl(0,c,u),u})}class Le{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let r=0,o=e.length;r<o;r++){const h=e[r][t];i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let r=0,o=t.length;r<o;r++){const c=t[r],h=e.dot(c);i=h<i?h:i,s=h>s?h:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Le.prototype.setFromBox=function(){const a=new f.Vector3;return function(t,i){const s=i.min,r=i.max;let o=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let u=0;u<=1;u++)for(let p=0;p<=1;p++){a.x=s.x*h+r.x*(1-h),a.y=s.y*u+r.y*(1-u),a.z=s.z*p+r.z*(1-p);const n=t.dot(a);o=Math.min(n,o),c=Math.max(n,c)}this.min=o,this.max=c}}();const Yl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,r,o){const c=s.start,h=a,u=r.start,p=e;t.subVectors(c,u),a.subVectors(s.end,s.start),e.subVectors(r.end,r.start);const n=t.dot(p),l=p.dot(h),d=p.dot(p),g=t.dot(h),m=h.dot(h)*d-l*l;let _,y;m!==0?_=(n*l-g*d)/m:_=0,y=(n+_*l)/d,o.x=_,o.y=y}}(),Ls=function(){const a=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,r,o,c){Yl(s,r,a);let h=a.x,u=a.y;if(h>=0&&h<=1&&u>=0&&u<=1){s.at(h,o),r.at(u,c);return}else if(h>=0&&h<=1){u<0?r.at(0,c):r.at(1,c),s.closestPointToPoint(c,!0,o);return}else if(u>=0&&u<=1){h<0?s.at(0,o):s.at(1,o),r.closestPointToPoint(o,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let n;u<0?n=r.start:n=r.end;const l=e,d=t;if(s.closestPointToPoint(n,!0,e),r.closestPointToPoint(p,!0,t),l.distanceToSquared(n)<=d.distanceToSquared(p)){o.copy(l),c.copy(n);return}else{o.copy(p),c.copy(d);return}}}}(),Kl=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(r,o){const{radius:c,center:h}=r,{a:u,b:p,c:n}=o;if(i.start=u,i.end=p,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c||(i.start=u,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c)||(i.start=p,i.end=n,i.closestPointToPoint(h,!0,a).distanceTo(h)<=c))return!0;const v=o.getPlane(t);if(Math.abs(v.distanceToPoint(h))<=c){const _=v.projectPoint(h,e);if(o.containsPoint(_))return!0}return!1}}(),Zl=1e-15;function qi(a){return Math.abs(a)<Zl}class _e extends f.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new f.Vector3),this.satBounds=new Array(4).fill().map(()=>new Le),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return Kl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,r=this.satAxes,o=this.satBounds,c=r[0],h=o[0];this.getNormal(c),h.setFromPoints(c,s);const u=r[1],p=o[1];u.subVectors(e,t),p.setFromPoints(u,s);const n=r[2],l=o[2];n.subVectors(t,i),l.setFromPoints(n,s);const d=r[3],g=o[3];d.subVectors(i,e),g.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}_e.prototype.closestPointToSegment=function(){const a=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,r=null,o=null){const{start:c,end:h}=s,u=this.points;let p,n=1/0;for(let l=0;l<3;l++){const d=(l+1)%3;t.start.copy(u[l]),t.end.copy(u[d]),Ls(t,s,a,e),p=a.distanceToSquared(e),p<n&&(n=p,r&&r.copy(a),o&&o.copy(e))}return this.closestPointToPoint(c,a),p=c.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(c)),this.closestPointToPoint(h,a),p=h.distanceToSquared(a),p<n&&(n=p,r&&r.copy(a),o&&o.copy(h)),Math.sqrt(n)}}();_e.prototype.intersectsTriangle=function(){const a=new _e,e=new Array(3),t=new Array(3),i=new Le,s=new Le,r=new f.Vector3,o=new f.Vector3,c=new f.Vector3,h=new f.Vector3,u=new f.Vector3,p=new f.Line3,n=new f.Line3,l=new f.Line3,d=new f.Vector3;function g(v,m,_){const y=v.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:T,end:M}=p;T.copy(y[b]),M.copy(y[(b+1)%3]),p.delta(o);const R=qi(m.distanceToPoint(T));if(qi(m.normal.dot(o))&&R){_.copy(p),x=2;break}const C=m.intersectLine(p,d);if(!C&&R&&d.copy(T),(C||R)&&!qi(d.distanceTo(M))){if(x<=1)(x===1?_.start:_.end).copy(d),R&&(w=x);else if(x>=2){(w===1?_.start:_.end).copy(d),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,_=null,y=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(a.copy(m),a.update(),m=a);const x=this.plane,w=m.plane;if(Math.abs(x.normal.dot(w.normal))>1-1e-10){const b=this.satBounds,T=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let C=0;C<4;C++){const P=b[C],D=T[C];if(i.setFromPoints(D,t),P.isSeparated(i))return!1}const M=m.satBounds,R=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const P=M[C],D=R[C];if(i.setFromPoints(D,e),P.isSeparated(i))return!1}for(let C=0;C<4;C++){const P=T[C];for(let D=0;D<4;D++){const A=R[D];if(r.crossVectors(P,A),i.setFromPoints(r,e),s.setFromPoints(r,t),i.isSeparated(s))return!1}}return _&&(y||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),_.start.set(0,0,0),_.end.set(0,0,0)),!0}else{const b=g(this,w,n);if(b===1&&m.containsPoint(n.end))return _&&(_.start.copy(n.end),_.end.copy(n.end)),!0;if(b!==2)return!1;const T=g(m,x,l);if(T===1&&this.containsPoint(l.end))return _&&(_.start.copy(l.end),_.end.copy(l.end)),!0;if(T!==2)return!1;if(n.delta(c),l.delta(h),c.dot(h)<0){let S=l.start;l.start=l.end,l.end=S}const M=n.start.dot(c),R=n.end.dot(c),C=l.start.dot(c),P=l.end.dot(c),D=R<C,A=M<P;return M!==P&&C!==R&&D===A?!1:(_&&(u.subVectors(n.start,l.start),u.dot(c)>0?_.start.copy(n.start):_.start.copy(l.start),u.subVectors(n.end,l.end),u.dot(c)<0?_.end.copy(n.end):_.end.copy(l.end)),!0)}}}();_e.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();_e.prototype.distanceToTriangle=function(){const a=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(o,c=null,h=null){const u=c||h?i:null;if(this.intersectsTriangle(o,u))return(c||h)&&(c&&u.getCenter(c),h&&u.getCenter(h)),0;let p=1/0;for(let n=0;n<3;n++){let l;const d=t[n],g=o[d];this.closestPointToPoint(g,a),l=g.distanceToSquared(a),l<p&&(p=l,c&&c.copy(a),h&&h.copy(g));const v=this[d];o.closestPointToPoint(v,a),l=v.distanceToSquared(a),l<p&&(p=l,c&&c.copy(v),h&&h.copy(a))}for(let n=0;n<3;n++){const l=t[n],d=t[(n+1)%3];i.set(this[l],this[d]);for(let g=0;g<3;g++){const v=t[g],m=t[(g+1)%3];s.set(o[v],o[m]),Ls(i,s,a,e);const _=a.distanceToSquared(e);_<p&&(p=_,c&&c.copy(a),h&&h.copy(e))}}return Math.sqrt(p)}}();class ie{constructor(e,t,i){this.isOrientedBox=!0,this.min=new f.Vector3,this.max=new f.Vector3,this.matrix=new f.Matrix4,this.invMatrix=new f.Matrix4,this.points=new Array(8).fill().map(()=>new f.Vector3),this.satAxes=new Array(3).fill().map(()=>new f.Vector3),this.satBounds=new Array(3).fill().map(()=>new Le),this.alignedSatBounds=new Array(3).fill().map(()=>new Le),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}ie.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let u=0;u<=1;u++)for(let p=0;p<=1;p++)for(let n=0;n<=1;n++){const l=1*u|2*p|4*n,d=s[l];d.x=u?i.x:t.x,d.y=p?i.y:t.y,d.z=n?i.z:t.z,d.applyMatrix4(e)}const r=this.satBounds,o=this.satAxes,c=s[0];for(let u=0;u<3;u++){const p=o[u],n=r[u],l=1<<u,d=s[l];p.subVectors(c,d),n.setFromPoints(p,s)}const h=this.alignedSatBounds;h[0].setFromPointsField(s,"x"),h[1].setFromPointsField(s,"y"),h[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();ie.prototype.intersectsBox=function(){const a=new Le;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,r=this.satBounds,o=this.satAxes,c=this.alignedSatBounds;if(a.min=i.x,a.max=s.x,c[0].isSeparated(a)||(a.min=i.y,a.max=s.y,c[1].isSeparated(a))||(a.min=i.z,a.max=s.z,c[2].isSeparated(a)))return!1;for(let h=0;h<3;h++){const u=o[h],p=r[h];if(a.setFromBox(u,t),p.isSeparated(a))return!1}return!0}}();ie.prototype.intersectsTriangle=function(){const a=new _e,e=new Array(3),t=new Le,i=new Le,s=new f.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(a.copy(o),a.update(),o=a);const c=this.satBounds,h=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let l=0;l<3;l++){const d=c[l],g=h[l];if(t.setFromPoints(g,e),d.isSeparated(t))return!1}const u=o.satBounds,p=o.satAxes,n=this.points;for(let l=0;l<3;l++){const d=u[l],g=p[l];if(t.setFromPoints(g,n),d.isSeparated(t))return!1}for(let l=0;l<3;l++){const d=h[l];for(let g=0;g<4;g++){const v=p[g];if(s.crossVectors(d,v),t.setFromPoints(s,e),i.setFromPoints(s,n),t.isSeparated(i))return!1}}return!0}}();ie.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}();ie.prototype.distanceToPoint=function(){const a=new f.Vector3;return function(t){return this.closestPointToPoint(t,a),t.distanceTo(a)}}();ie.prototype.distanceToBox=function(){const a=["x","y","z"],e=new Array(12).fill().map(()=>new f.Line3),t=new Array(12).fill().map(()=>new f.Line3),i=new f.Vector3,s=new f.Vector3;return function(o,c=0,h=null,u=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(h||u)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),h&&h.copy(i),u&&u.copy(s)),0;const p=c*c,n=o.min,l=o.max,d=this.points;let g=1/0;for(let m=0;m<8;m++){const _=d[m];s.copy(_).clamp(n,l);const y=_.distanceToSquared(s);if(y<g&&(g=y,h&&h.copy(_),u&&u.copy(s),y<p))return Math.sqrt(y)}let v=0;for(let m=0;m<3;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=_<<x|y<<w,T=1<<m|_<<x|y<<w,M=d[b],R=d[T];e[v].set(M,R);const P=a[m],D=a[x],A=a[w],S=t[v],L=S.start,I=S.end;L[P]=n[P],L[D]=_?n[D]:l[D],L[A]=y?n[A]:l[D],I[P]=l[P],I[D]=_?n[D]:l[D],I[A]=y?n[A]:l[D],v++}for(let m=0;m<=1;m++)for(let _=0;_<=1;_++)for(let y=0;y<=1;y++){s.x=m?l.x:n.x,s.y=_?l.y:n.y,s.z=y?l.z:n.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,h&&h.copy(i),u&&u.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const _=e[m];for(let y=0;y<12;y++){const x=t[y];Ls(_,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,h&&h.copy(i),u&&u.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class Ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Xl extends Ps{constructor(){super(()=>new _e)}}const de=new Xl;class Jl{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const Y=new Jl;let Ve,pt;const et=[],oi=new Ps(()=>new f.Box3);function $l(a,e,t,i,s,r){Ve=oi.getPrimitive(),pt=oi.getPrimitive(),et.push(Ve,pt),Y.setBuffer(a._roots[e]);const o=ds(0,a.geometry,t,i,s,r);Y.clearBuffer(),oi.releasePrimitive(Ve),oi.releasePrimitive(pt),et.pop(),et.pop();const c=et.length;return c>0&&(pt=et[c-1],Ve=et[c-2]),o}function ds(a,e,t,i,s=null,r=0,o=0){const{float32Array:c,uint16Array:h,uint32Array:u}=Y;let p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);return K(a,c,Ve),i(l,d,!1,o,r+a,Ve)}else{let P=function(A){const{uint16Array:S,uint32Array:L}=Y;let I=A*2;for(;!ae(I,S);)A=ue(A),I=A*2;return ce(A,L)},D=function(A){const{uint16Array:S,uint32Array:L}=Y;let I=A*2;for(;!ae(I,S);)A=fe(A,L),I=A*2;return ce(A,L)+he(I,S)};const l=ue(a),d=fe(a,u);let g=l,v=d,m,_,y,x;if(s&&(y=Ve,x=pt,K(g,c,y),K(v,c,x),m=s(y),_=s(x),_<m)){g=d,v=l;const A=m;m=_,_=A,y=x}y||(y=Ve,K(g,c,y));const w=ae(g*2,h),b=t(y,w,m,o+1,r+g);let T;if(b===vr){const A=P(g),L=D(g)-A;T=i(A,L,!0,o+1,r+g,y)}else T=b&&ds(g,e,t,i,s,r,o+1);if(T)return!0;x=pt,K(v,c,x);const M=ae(v*2,h),R=t(x,M,_,o+1,r+v);let C;if(R===vr){const A=P(v),L=D(v)-A;C=i(A,L,!0,o+1,r+v,x)}else C=R&&ds(v,e,t,i,s,r,o+1);return!!C}}const Pt=new f.Vector3,Yi=new f.Vector3;function ec(a,e,t={},i=0,s=1/0){const r=i*i,o=s*s;let c=1/0,h=null;if(a.shapecast({boundsTraverseOrder:p=>(Pt.copy(e).clamp(p.min,p.max),Pt.distanceToSquared(e)),intersectsBounds:(p,n,l)=>l<c&&l<o,intersectsTriangle:(p,n)=>{p.closestPointToPoint(e,Pt);const l=e.distanceToSquared(Pt);return l<c&&(Yi.copy(Pt),c=l,h=n),l<r}}),c===1/0)return null;const u=Math.sqrt(c);return t.point?t.point.copy(Yi):t.point=Yi.clone(),t.distance=u,t.faceIndex=h,t}const it=new f.Vector3,st=new f.Vector3,rt=new f.Vector3,ai=new f.Vector2,li=new f.Vector2,ci=new f.Vector2,Ar=new f.Vector3,Tr=new f.Vector3,Sr=new f.Vector3,hi=new f.Vector3;function tc(a,e,t,i,s,r,o,c){let h;if(r===f.BackSide?h=a.intersectTriangle(i,t,e,!0,s):h=a.intersectTriangle(e,t,i,r!==f.DoubleSide,s),h===null)return null;const u=a.origin.distanceTo(s);return u<o||u>c?null:{distance:u,point:s.clone()}}function ic(a,e,t,i,s,r,o,c,h,u,p){it.fromBufferAttribute(e,r),st.fromBufferAttribute(e,o),rt.fromBufferAttribute(e,c);const n=tc(a,it,st,rt,hi,h,u,p);if(n){i&&(ai.fromBufferAttribute(i,r),li.fromBufferAttribute(i,o),ci.fromBufferAttribute(i,c),n.uv=f.Triangle.getInterpolation(hi,it,st,rt,ai,li,ci,new f.Vector2)),s&&(ai.fromBufferAttribute(s,r),li.fromBufferAttribute(s,o),ci.fromBufferAttribute(s,c),n.uv1=f.Triangle.getInterpolation(hi,it,st,rt,ai,li,ci,new f.Vector2)),t&&(Ar.fromBufferAttribute(t,r),Tr.fromBufferAttribute(t,o),Sr.fromBufferAttribute(t,c),n.normal=f.Triangle.getInterpolation(hi,it,st,rt,Ar,Tr,Sr,new f.Vector3),n.normal.dot(a.direction)>0&&n.normal.multiplyScalar(-1));const l={a:r,b:o,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(it,st,rt,l.normal),n.face=l,n.faceIndex=r}return n}function Di(a,e,t,i,s,r,o){const c=i*3;let h=c+0,u=c+1,p=c+2;const n=a.index;a.index&&(h=n.getX(h),u=n.getX(u),p=n.getX(p));const{position:l,normal:d,uv:g,uv1:v}=a.attributes,m=ic(t,l,d,g,v,h,u,p,e,r,o);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Z(a,e,t,i){const s=a.a,r=a.b,o=a.c;let c=e,h=e+1,u=e+2;t&&(c=t.getX(c),h=t.getX(h),u=t.getX(u)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),r.x=i.getX(h),r.y=i.getY(h),r.z=i.getZ(h),o.x=i.getX(u),o.y=i.getY(u),o.z=i.getZ(u)}function sc(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++)Di(h,e,t,p,r,o,c)}function rc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Di(c,e,t,n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function nc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=p,Z(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function oc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Ci){const _=o[l+6],y=c[v+14];let x=1/0,w=1/0,b=1/0,T=-1/0,M=-1/0,R=-1/0;for(let C=3*_,P=3*(_+y);C<P;C++){let D=i[C];const A=s.getX(D),S=s.getY(D),L=s.getZ(D);A<x&&(x=A),A>T&&(T=A),S<w&&(w=S),S>M&&(M=S),L<b&&(b=L),L>R&&(R=L)}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==R?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=R,!0):!1}else{const _=l+8,y=o[l+6],x=_+d,w=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(x),M=e.has(w),b=!T&&!M):(T=!0,M=!0);const R=b||T,C=b||M;let P=!1;R&&(P=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=P||D;if(A)for(let S=0;S<3;S++){const L=_+S,I=y+S,k=h[L],F=h[L+3],z=h[I],B=h[I+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function We(a,e,t,i,s){let r,o,c,h,u,p;const n=1/t.direction.x,l=1/t.direction.y,d=1/t.direction.z,g=t.origin.x,v=t.origin.y,m=t.origin.z;let _=e[a],y=e[a+3],x=e[a+1],w=e[a+3+1],b=e[a+2],T=e[a+3+2];return n>=0?(r=(_-g)*n,o=(y-g)*n):(r=(y-g)*n,o=(_-g)*n),l>=0?(c=(x-v)*l,h=(w-v)*l):(c=(w-v)*l,h=(x-v)*l),r>h||c>o||((c>r||isNaN(r))&&(r=c),(h<o||isNaN(o))&&(o=h),d>=0?(u=(b-m)*d,p=(T-m)*d):(u=(T-m)*d,p=(b-m)*d),r>p||u>o)?!1:((u>r||r!==r)&&(r=u),(p<o||o!==o)&&(o=p),r<=s&&o>=i)}function ac(a,e,t,i,s,r,o,c){const{geometry:h,_indirectBuffer:u}=a;for(let p=i,n=i+s;p<n;p++){let l=u?u[p]:p;Di(h,e,t,l,r,o,c)}}function lc(a,e,t,i,s,r,o){const{geometry:c,_indirectBuffer:h}=a;let u=1/0,p=null;for(let n=i,l=i+s;n<l;n++){let d;d=Di(c,e,t,h?h[n]:n,null,r,o),d&&d.distance<u&&(p=d,u=d.distance)}return p}function cc(a,e,t,i,s,r,o){const{geometry:c}=t,{index:h}=c,u=c.attributes.position;for(let p=a,n=e+a;p<n;p++){let l;if(l=t.resolveTriangleIndex(p),Z(o,l*3,h,u),o.needsUpdate=!0,i(o,l,s,r))return!0}return!1}function hc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),ps(0,a,t,i,s,r,o),Y.clearBuffer()}function ps(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);sc(e,t,i,l,d,s,r,o)}else{const l=ue(a);We(l,c,i,r,o)&&ps(l,e,t,i,s,r,o);const d=fe(a,u);We(d,c,i,r,o)&&ps(d,e,t,i,s,r,o)}}const uc=["x","y","z"];function fc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=ms(0,a,t,i,s,r);return Y.clearBuffer(),o}function ms(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(ae(u,c)){const n=ce(a,h),l=he(u,c);return rc(e,t,i,n,l,s,r)}else{const n=fn(a,h),l=uc[n],g=i.direction[l]>=0;let v,m;g?(v=ue(a),m=fe(a,h)):(v=fe(a,h),m=ue(a));const y=We(v,o,i,s,r)?ms(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const w=We(m,o,i,s,r)?ms(m,e,t,i,s,r):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ui=new f.Box3,nt=new _e,ot=new _e,It=new f.Matrix4,Mr=new ie,fi=new ie;function dc(a,e,t,i){Y.setBuffer(a._roots[e]);const s=gs(0,a,t,i);return Y.clearBuffer(),s}function gs(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Mr.set(t.boundingBox.min,t.boundingBox.max,i),s=Mr),ae(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=ce(a,c),m=he(h,o);if(It.copy(i).invert(),t.boundsTree)return K(a,r,fi),fi.matrix.copy(It),fi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>fi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=v*3,w=(m+v)*3;x<w;x+=3)if(Z(ot,x,n,l),ot.needsUpdate=!0,y.intersectsTriangle(ot))return!0;return!1}});for(let _=v*3,y=(m+v)*3;_<y;_+=3){Z(nt,_,n,l),nt.a.applyMatrix4(It),nt.b.applyMatrix4(It),nt.c.applyMatrix4(It),nt.needsUpdate=!0;for(let x=0,w=d.count;x<w;x+=3)if(Z(ot,x,d,g),ot.needsUpdate=!0,nt.intersectsTriangle(ot))return!0}}else{const p=a+8,n=c[a+6];return K(p,r,ui),!!(s.intersectsBox(ui)&&gs(p,e,t,i,s)||(K(n,r,ui),s.intersectsBox(ui)&&gs(n,e,t,i,s)))}}const di=new f.Matrix4,Ki=new ie,Et=new ie,pc=new f.Vector3,mc=new f.Vector3,gc=new f.Vector3,_c=new f.Vector3;function vc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Ki.set(e.boundingBox.min,e.boundingBox.max,t),Ki.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=de.getPrimitive(),d=de.getPrimitive();let g=pc,v=mc,m=null,_=null;s&&(m=gc,_=_c);let y=1/0,x=null,w=null;return di.copy(t).invert(),Et.matrix.copy(di),a.shapecast({boundsTraverseOrder:b=>Ki.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Et.min.copy(b.min),Et.max.copy(b.max),Et.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:R=>Et.distanceToBox(R),intersectsBounds:(R,C,P)=>P<y&&P<o,intersectsRange:(R,C)=>{for(let P=R,D=R+C;P<D;P++){Z(d,3*P,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let A=b,S=b+T;A<S;A++){Z(l,3*A,u,h),l.needsUpdate=!0;const L=l.distanceToTriangle(d,g,m);if(L<y&&(v.copy(g),_&&_.copy(m),y=L,x=A,w=P),L<r)return!0}}}});{const M=wt(e);for(let R=0,C=M;R<C;R++){Z(d,3*R,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=b,D=b+T;P<D;P++){Z(l,3*P,u,h),l.needsUpdate=!0;const A=l.distanceToTriangle(d,g,m);if(A<y&&(v.copy(g),_&&_.copy(m),y=A,x=P,w=R),A<r)return!0}}}}}),de.releasePrimitive(l),de.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(di),v.applyMatrix4(di),s.distance=v.sub(s.point).length(),s.faceIndex=w),i)}function yc(a,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=a.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let r,o,c,h,u=0;const p=a._roots;for(let l=0,d=p.length;l<d;l++)r=p[l],o=new Uint32Array(r),c=new Uint16Array(r),h=new Float32Array(r),n(0,u),u+=r.byteLength;function n(l,d,g=!1){const v=l*2;if(c[v+15]===Ci){const _=o[l+6],y=c[v+14];let x=1/0,w=1/0,b=1/0,T=-1/0,M=-1/0,R=-1/0;for(let C=_,P=_+y;C<P;C++){const D=3*a.resolveTriangleIndex(C);for(let A=0;A<3;A++){let S=D+A;S=i?i[S]:S;const L=s.getX(S),I=s.getY(S),k=s.getZ(S);L<x&&(x=L),L>T&&(T=L),I<w&&(w=I),I>M&&(M=I),k<b&&(b=k),k>R&&(R=k)}}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==M||h[l+5]!==R?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=M,h[l+5]=R,!0):!1}else{const _=l+8,y=o[l+6],x=_+d,w=y+d;let b=g,T=!1,M=!1;e?b||(T=e.has(x),M=e.has(w),b=!T&&!M):(T=!0,M=!0);const R=b||T,C=b||M;let P=!1;R&&(P=n(_,d,b));let D=!1;C&&(D=n(y,d,b));const A=P||D;if(A)for(let S=0;S<3;S++){const L=_+S,I=y+S,k=h[L],F=h[L+3],z=h[I],B=h[I+3];h[l+S]=k<z?k:z,h[l+S+3]=F>B?F:B}return A}}}function xc(a,e,t,i,s,r,o){Y.setBuffer(a._roots[e]),_s(0,a,t,i,s,r,o),Y.clearBuffer()}function _s(a,e,t,i,s,r,o){const{float32Array:c,uint16Array:h,uint32Array:u}=Y,p=a*2;if(ae(p,h)){const l=ce(a,u),d=he(p,h);ac(e,t,i,l,d,s,r,o)}else{const l=ue(a);We(l,c,i,r,o)&&_s(l,e,t,i,s,r,o);const d=fe(a,u);We(d,c,i,r,o)&&_s(d,e,t,i,s,r,o)}}const wc=["x","y","z"];function bc(a,e,t,i,s,r){Y.setBuffer(a._roots[e]);const o=vs(0,a,t,i,s,r);return Y.clearBuffer(),o}function vs(a,e,t,i,s,r){const{float32Array:o,uint16Array:c,uint32Array:h}=Y;let u=a*2;if(ae(u,c)){const n=ce(a,h),l=he(u,c);return lc(e,t,i,n,l,s,r)}else{const n=fn(a,h),l=wc[n],g=i.direction[l]>=0;let v,m;g?(v=ue(a),m=fe(a,h)):(v=fe(a,h),m=ue(a));const y=We(v,o,i,s,r)?vs(v,e,t,i,s,r):null;if(y){const b=y.point[l];if(g?b<=o[m+n]:b>=o[m+n+3])return y}const w=We(m,o,i,s,r)?vs(m,e,t,i,s,r):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const pi=new f.Box3,at=new _e,lt=new _e,kt=new f.Matrix4,Cr=new ie,mi=new ie;function Ac(a,e,t,i){Y.setBuffer(a._roots[e]);const s=ys(0,a,t,i);return Y.clearBuffer(),s}function ys(a,e,t,i,s=null){const{float32Array:r,uint16Array:o,uint32Array:c}=Y;let h=a*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),Cr.set(t.boundingBox.min,t.boundingBox.max,i),s=Cr),ae(h,o)){const p=e.geometry,n=p.index,l=p.attributes.position,d=t.index,g=t.attributes.position,v=ce(a,c),m=he(h,o);if(kt.copy(i).invert(),t.boundsTree)return K(a,r,mi),mi.matrix.copy(kt),mi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>mi.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=v,w=m+v;x<w;x++)if(Z(lt,3*e.resolveTriangleIndex(x),n,l),lt.needsUpdate=!0,y.intersectsTriangle(lt))return!0;return!1}});for(let _=v,y=m+v;_<y;_++){const x=e.resolveTriangleIndex(_);Z(at,3*x,n,l),at.a.applyMatrix4(kt),at.b.applyMatrix4(kt),at.c.applyMatrix4(kt),at.needsUpdate=!0;for(let w=0,b=d.count;w<b;w+=3)if(Z(lt,w,d,g),lt.needsUpdate=!0,at.intersectsTriangle(lt))return!0}}else{const p=a+8,n=c[a+6];return K(p,r,pi),!!(s.intersectsBox(pi)&&ys(p,e,t,i,s)||(K(n,r,pi),s.intersectsBox(pi)&&ys(n,e,t,i,s)))}}const gi=new f.Matrix4,Zi=new ie,Ft=new ie,Tc=new f.Vector3,Sc=new f.Vector3,Mc=new f.Vector3,Cc=new f.Vector3;function Dc(a,e,t,i={},s={},r=0,o=1/0){e.boundingBox||e.computeBoundingBox(),Zi.set(e.boundingBox.min,e.boundingBox.max,t),Zi.needsUpdate=!0;const c=a.geometry,h=c.attributes.position,u=c.index,p=e.attributes.position,n=e.index,l=de.getPrimitive(),d=de.getPrimitive();let g=Tc,v=Sc,m=null,_=null;s&&(m=Mc,_=Cc);let y=1/0,x=null,w=null;return gi.copy(t).invert(),Ft.matrix.copy(gi),a.shapecast({boundsTraverseOrder:b=>Zi.distanceToBox(b),intersectsBounds:(b,T,M)=>M<y&&M<o?(T&&(Ft.min.copy(b.min),Ft.max.copy(b.max),Ft.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const M=e.boundsTree;return M.shapecast({boundsTraverseOrder:R=>Ft.distanceToBox(R),intersectsBounds:(R,C,P)=>P<y&&P<o,intersectsRange:(R,C)=>{for(let P=R,D=R+C;P<D;P++){const A=M.resolveTriangleIndex(P);Z(d,3*A,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let S=b,L=b+T;S<L;S++){const I=a.resolveTriangleIndex(S);Z(l,3*I,u,h),l.needsUpdate=!0;const k=l.distanceToTriangle(d,g,m);if(k<y&&(v.copy(g),_&&_.copy(m),y=k,x=S,w=P),k<r)return!0}}}})}else{const M=wt(e);for(let R=0,C=M;R<C;R++){Z(d,3*R,n,p),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=b,D=b+T;P<D;P++){const A=a.resolveTriangleIndex(P);Z(l,3*A,u,h),l.needsUpdate=!0;const S=l.distanceToTriangle(d,g,m);if(S<y&&(v.copy(g),_&&_.copy(m),y=S,x=P,w=R),S<r)return!0}}}}}),de.releasePrimitive(l),de.releasePrimitive(d),y===1/0?null:(i.point?i.point.copy(v):i.point=v.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(_):s.point=_.clone(),s.point.applyMatrix4(gi),v.applyMatrix4(gi),s.distance=v.sub(s.point).length(),s.faceIndex=w),i)}function Rc(){return typeof SharedArrayBuffer<"u"}const Ut=new Y.constructor,Ai=new Y.constructor,Be=new Ps(()=>new f.Box3),ct=new f.Box3,ht=new f.Box3,Xi=new f.Box3,Ji=new f.Box3;let $i=!1;function Lc(a,e,t,i){if($i)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");$i=!0;const s=a._roots,r=e._roots;let o,c=0,h=0;const u=new f.Matrix4().copy(t).invert();for(let p=0,n=s.length;p<n;p++){Ut.setBuffer(s[p]),h=0;const l=Be.getPrimitive();K(0,Ut.float32Array,l),l.applyMatrix4(u);for(let d=0,g=r.length;d<g&&(Ai.setBuffer(r[p]),o=ge(0,0,t,u,i,c,h,0,0,l),Ai.clearBuffer(),h+=r[d].length,!o);d++);if(Be.releasePrimitive(l),Ut.clearBuffer(),c+=s[p].length,o)break}return $i=!1,o}function ge(a,e,t,i,s,r=0,o=0,c=0,h=0,u=null,p=!1){let n,l;p?(n=Ai,l=Ut):(n=Ut,l=Ai);const d=n.float32Array,g=n.uint32Array,v=n.uint16Array,m=l.float32Array,_=l.uint32Array,y=l.uint16Array,x=a*2,w=e*2,b=ae(x,v),T=ae(w,y);let M=!1;if(T&&b)p?M=s(ce(e,_),he(e*2,y),ce(a,g),he(a*2,v),h,o+e,c,r+a):M=s(ce(a,g),he(a*2,v),ce(e,_),he(e*2,y),c,r+a,h,o+e);else if(T){const R=Be.getPrimitive();K(e,m,R),R.applyMatrix4(t);const C=ue(a),P=fe(a,g);K(C,d,ct),K(P,d,ht);const D=R.intersectsBox(ct),A=R.intersectsBox(ht);M=D&&ge(e,C,i,t,s,o,r,h,c+1,R,!p)||A&&ge(e,P,i,t,s,o,r,h,c+1,R,!p),Be.releasePrimitive(R)}else{const R=ue(e),C=fe(e,_);K(R,m,Xi),K(C,m,Ji);const P=u.intersectsBox(Xi),D=u.intersectsBox(Ji);if(P&&D)M=ge(a,R,t,i,s,r,o,c,h+1,u,p)||ge(a,C,t,i,s,r,o,c,h+1,u,p);else if(P)if(b)M=ge(a,R,t,i,s,r,o,c,h+1,u,p);else{const A=Be.getPrimitive();A.copy(Xi).applyMatrix4(t);const S=ue(a),L=fe(a,g);K(S,d,ct),K(L,d,ht);const I=A.intersectsBox(ct),k=A.intersectsBox(ht);M=I&&ge(R,S,i,t,s,o,r,h,c+1,A,!p)||k&&ge(R,L,i,t,s,o,r,h,c+1,A,!p),Be.releasePrimitive(A)}else if(D)if(b)M=ge(a,C,t,i,s,r,o,c,h+1,u,p);else{const A=Be.getPrimitive();A.copy(Ji).applyMatrix4(t);const S=ue(a),L=fe(a,g);K(S,d,ct),K(L,d,ht);const I=A.intersectsBox(ct),k=A.intersectsBox(ht);M=I&&ge(C,S,i,t,s,o,r,h,c+1,A,!p)||k&&ge(C,L,i,t,s,o,r,h,c+1,A,!p),Be.releasePrimitive(A)}}return M}const _i=new ie,Dr=new f.Box3,Pc={strategy:cn,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class Is{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,r=e._indirectBuffer,o=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:o?o.array.slice():null,indirectBuffer:r?r.slice():null}:c={roots:s,index:o?o.array:null,indirectBuffer:r},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:r,indirectBuffer:o}=e,c=new Is(t,{...i,[Ni]:!0});if(c._roots=r,c._indirectBuffer=o||null,i.setIndex){const h=t.getIndex();if(h===null){const u=new f.BufferAttribute(e.index,1,!1);t.setIndex(u)}else h.array!==s&&(h.array.set(s),h.needsUpdate=!0)}return c}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Pc,[Ni]:!1},t),t.useSharedArrayBuffer&&!Rc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ni]||(ql(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new f.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?yc:oc)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),r=new Uint16Array(i);o(0);function o(c,h=0){const u=c*2,p=r[u+15]===Ci;if(p){const n=s[c+6],l=r[u+14];e(h,p,new Float32Array(i,c*4,6),n,l)}else{const n=c+Wt/4,l=s[c+6],d=s[c+7];e(h,p,new Float32Array(i,c*4,6),d)||(o(n,h+1),o(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=[],h=t.isMaterial,u=Array.isArray(t),p=o.groups,n=h?t.side:t,l=this.indirect?xc:hc;for(let d=0,g=r.length;d<g;d++){const v=u?t[p[d].materialIndex].side:n,m=c.length;if(l(this,d,v,e,c,i,s),u){const _=p[d].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=_}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const r=this._roots,o=this.geometry,c=t.isMaterial,h=Array.isArray(t);let u=null;const p=o.groups,n=c?t.side:t,l=this.indirect?bc:fc;for(let d=0,g=r.length;d<g;d++){const v=h?t[p[d].materialIndex].side:n,m=l(this,d,v,e,i,s);m!=null&&(u==null||m.distance<u.distance)&&(u=m,h&&(m.face.materialIndex=p[d].materialIndex))}return u}intersectsGeometry(e,t){let i=!1;const s=this._roots,r=this.indirect?Ac:dc;for(let o=0,c=s.length;o<c&&(i=r(this,o,e,t),!i);o++);return i}shapecast(e){const t=de.getPrimitive(),i=this.indirect?cc:nc;let{boundsTraverseOrder:s,intersectsBounds:r,intersectsRange:o,intersectsTriangle:c}=e;if(o&&c){const n=o;o=(l,d,g,v,m)=>n(l,d,g,v,m)?!0:i(l,d,this,c,g,v,t)}else o||(c?o=(n,l,d,g)=>i(n,l,this,c,d,g,t):o=(n,l,d)=>d);let h=!1,u=0;const p=this._roots;for(let n=0,l=p.length;n<l;n++){const d=p[n];if(h=$l(this,n,r,o,s,u),h)break;u+=d.byteLength}return de.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:r}=i;const o=de.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,u=this.indirect?g=>{const v=this.resolveTriangleIndex(g);Z(o,v*3,c,h)}:g=>{Z(o,g*3,c,h)},p=de.getPrimitive(),n=e.geometry.index,l=e.geometry.attributes.position,d=e.indirect?g=>{const v=e.resolveTriangleIndex(g);Z(p,v*3,n,l)}:g=>{Z(p,g*3,n,l)};if(r){const g=(v,m,_,y,x,w,b,T)=>{for(let M=_,R=_+y;M<R;M++){d(M),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=v,P=v+m;C<P;C++)if(u(C),o.needsUpdate=!0,r(o,p,C,M,x,w,b,T))return!0}return!1};if(s){const v=s;s=function(m,_,y,x,w,b,T,M){return v(m,_,y,x,w,b,T,M)?!0:g(m,_,y,x,w,b,T,M)}}else s=g}return Lc(this,e,t,s)}intersectsBox(e,t){return _i.set(e.min,e.max,t),_i.needsUpdate=!0,this.shapecast({intersectsBounds:i=>_i.intersectsBox(i),intersectsTriangle:i=>_i.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},r=0,o=1/0){return(this.indirect?Dc:vc)(this,e,t,i,s,r,o)}closestPointToPoint(e,t={},i=0,s=1/0){return ec(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{K(0,new Float32Array(i),Dr),e.union(Dr)}),e}}class Ic{constructor(e){this.name="WorkerBase",this.running=!1,this.worker=e,this.worker.onerror=t=>{throw t.message?new Error(`${this.name}: Could not create Web Worker with error "${t.message}"`):new Error(`${this.name}: Could not create Web Worker.`)}}runTask(){}generate(...e){if(this.running)throw new Error("GenerateMeshBVHWorker: Already running job.");if(this.worker===null)throw new Error("GenerateMeshBVHWorker: Worker has been disposed.");this.running=!0;const t=this.runTask(this.worker,...e);return t.finally(()=>{this.running=!1}),t}dispose(){this.worker.terminate(),this.worker=null}}class Ec extends Ic{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:yt&&yt.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,r)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=u=>{r(new Error(`GenerateMeshBVHWorker: ${u.message}`))},e.onmessage=u=>{const{data:p}=u;if(p.error)r(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:n,position:l}=p,d=Is.deserialize(n,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,n.index)if(t.index)t.index.array=n.index;else{const v=new f.BufferAttribute(n.index,1,!1);t.setIndex(v)}g.setBoundingBox&&(t.boundingBox=d.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(d),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const o=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];o&&h.push(o),e.postMessage({index:o,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(u=>u.buffer).filter(u=>typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer)))})}}class kc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new f.Matrix4,this.mouse=new f.Vector3,this.rotateStart=new f.Vector2,this.rotateEnd=new f.Vector2,this.rotateDelta=new f.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new Ke,this.addListener=this._emitter.addListener.bind(this._emitter),this.removeAllListeners=this._emitter.removeAllListeners.bind(this._emitter),this._text=document.createElement("div"),this._textTimer=0,this._update=()=>{this.lock||(this._textTimer&&(window.clearTimeout(this._textTimer),this._textTimer=0),this._textTimer=window.setTimeout(()=>{this._text.style.opacity="0"},800),this.camera.updateMatrix(),this.invRotMat.extractRotation(this.camera.matrix).invert(),this.axes.forEach(s=>{this.setAxisPosition(s)}),this.axes.sort((s,r)=>s.position.z>r.position.z?1:-1),this.drawLayers(!0),this._text.style.opacity="1",this._text.innerText=this.camera.position.distanceTo(this.orbit.target).toFixed(2)+" m")},this.updateMouseFromEvent=s=>{this.rect=this.domElement.getBoundingClientRect();const r=this.domElement.width/this.domElement.clientWidth,o=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*r,(s.clientY-h)*o,0)},this.updateSelectedAxisUnderMouse=()=>{this.selectedAxis=null,this.axes.forEach(s=>{this.mouse.distanceTo(s.position)<s.size&&(this.selectedAxis=s)})},this.onPointerDown=s=>{this.rotateStart.set(s.clientX,s.clientY),this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.orbitState=this.orbit.enabled,this.orbit.enabled=!1,window.addEventListener("pointermove",this.onDrag,!1),window.addEventListener("pointerup",this.onPointerUp,!1)},this.onPointerUp=()=>{this.domElement.style.backgroundColor="#FFF0",setTimeout(()=>this.isDragging=!1,0),this.domElement.classList.remove("dragging"),this.orbit.enabled=this.orbitState,window.removeEventListener("pointermove",this.onDrag,!1),window.removeEventListener("pointerup",this.onPointerUp,!1)},this.onPointerEnter=()=>{this.domElement.style.backgroundColor="#FFF3",this.rect=this.domElement.getBoundingClientRect()},this.onPointerMove=s=>{if(this.lock||this.isDragging)return;const r=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),r!==this.selectedAxis&&this.drawLayers()},this.onDrag=s=>{this.lock||(this.isDragging||this.domElement.classList.add("dragging"),this.isDragging=!0,this.selectedAxis=null,this.rotateEnd.set(s.clientX,s.clientY),this.rotateDelta.subVectors(this.rotateEnd,this.rotateStart).multiplyScalar(.5),this.rotateStart.copy(this.rotateEnd),this.orbit.update())},this.onMouseClick=s=>{if(this.lock||(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse(),this.isDragging||!this.selectedAxis))return;this._animator&&cancelAnimationFrame(this._animator);const r=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const o=this.camera.position.distanceTo(this.orbit.target);r.multiplyScalar(o),this.selectedAxis.axis==="z"?r.setZ(this.orbit.target.z+o):this.selectedAxis.axis==="-z"?r.setZ(this.orbit.target.z-o):r.setZ(this.orbit.target.z);const c=500,h=performance.now(),u=1,p=this.selectedAxis.axis,n=()=>{const d=performance.now()-h,g=Math.min(d/c,u);if(this.camera.position.lerp(r,g),this.orbit.update(),g!==u){this._animator=window.requestAnimationFrame(n);return}else this._animator=0,this.onPointerMove(void 0),this._emitter.emit("axis-select-end",p);this.onPointerMove(void 0)};this._emitter.emit("axis-select-start",p),n()},this.drawCircle=(s,r=10,o="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-r,s.y-r,r*2,r*2),this.context.fillStyle=o,this.context.fill(),this.context.closePath())},this.drawLine=(s,r,o=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(r.x,r.y),this.context.lineWidth=o,this.context.strokeStyle=c,this.context.stroke(),this.context.closePath())},this.drawLayers=(s=!1)=>{this.context&&(s&&this.context.clearRect(0,0,this.domElement.width,this.domElement.height),this.axes.forEach(r=>{const o=this.selectedAxis===r,c=r.position.z>=-.01?r.color[0]:r.color[1];if(r.line&&this.drawLine(this.center,r.position,r.line,c),this.drawCircle(r.position,r.size,o?"#0066ff":c),r.label){const h=r.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,h+"px",this.options.fontFamily].join(" "),this.context.fillStyle=this.options.fontColor,this.context.textBaseline="middle",this.context.textAlign="center",this.context.fillText(r.label,r.position.x,r.position.y)}}))},this.setAxisPosition=s=>{const r=s.direction.clone().applyMatrix4(this.invRotMat),o=s.size;s.position.set(r.x*(this.center.x-o/2-this.options.padding)+this.center.x,this.center.y-r.y*(this.center.y-o/2-this.options.padding),r.z)};const i={offset:new f.Vector2,size:90,padding:8,bubbleSizePrimary:8,bubbleSizeSecondary:6,lineWidth:2,fontSize:11,fontFamily:"arial",fontWeight:"normal",fontColor:"#fff",className:"orbit-controls-gizmo",colors:{x:["#f35f5f","#902525"],y:["#78da2f","#71ae45"],z:["#1d92fa","#d0d1d1"]}};this.options={...i,...t},this.orbit=e,this.camera=e.object,this.center=new f.Vector3(this.options.size/2,this.options.size/2,0),this.axes=this.createAxes(),this.domElement=this.createCanvas(this.options),this.orbit.addEventListener("change",this._update),this._text.style.cssText=`
|
|
3732
3732
|
transition: all 0.8s ease-in-out;
|
|
3733
3733
|
color: rgb(68, 78, 105);
|
|
3734
3734
|
position: absolute;
|
|
@@ -3935,7 +3935,7 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3935
3935
|
// Combine
|
|
3936
3936
|
gl_FragColor = vec4(uColor, alpha * fade * uOpacity);
|
|
3937
3937
|
}
|
|
3938
|
-
`});super(s,r),this.position.z=-.02}}const Nc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",jc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Qc="https://cdn2.seer-group.com/libs/fonts.type.json",qc=new Cn.Font(Qc);class xs{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof f.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof f.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof f.MeshStandardMaterial);if(this._props.target.material instanceof f.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var gn=(a=>(a[a.DEFAULT=0]="DEFAULT",a[a.CAN_INSTALL=1]="CAN_INSTALL",a))(gn||{});const Lr=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let ft,wi=0,ws=0;const Yc=()=>{ft=void 0,wi=0,ws=0},Kc=new f.MeshBasicMaterial({colorWrite:!1});class Zc{constructor(e){this.props=e,this.stats=new Vt,this.scene=new f.Scene,this.overlayScene=new f.Scene,this.renderer=new f.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new Ae.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new ln({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new f.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new f.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new f.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new f.Group,this._raycaster=new f.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new Ke,this.sound=new $a,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new f.Mesh(new f.PlaneGeometry(100,100),new f.MeshPhysicalMaterial({color:new f.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Gc(18,40),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._lastTarget=new f.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:u}=this.renderer.domElement.getBoundingClientRect();this.offset.set(u,h),this.mousePos.set(c.clientX-u,c.clientY-h),this.mouseCoord.set((c.clientX-u)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(n=>n.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(n=>{n.traverse(l=>{l==p.object||(n.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{ft||typeof ft<"u"||(wi===0&&(ws=performance.now()),wi++,performance.now()-ws>66&&(wi>5?ft=!0:ft=!1,ft?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Yc,2e3)))},this.debounceForkHeightChange=nl(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var W;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(W=this._fitAnimation)==null||W.stop();const u=new f.Box3,p=new f.Box3,n=new f.Vector3,l=new f.Vector3,d=new f.Vector3,g=new f.Vector3,v=O=>{O.geometry&&(O.geometry.boundingBox||O.geometry.computeBoundingBox(),p.copy(O.geometry.boundingBox).applyMatrix4(O.matrixWorld),p.isEmpty()||u.union(p))},m=O=>{var Nt,jt;const Q=O.geometry,U=(Nt=Q==null?void 0:Q.attributes)==null?void 0:Nt.position;if(!U){v(O);return}const se=((jt=Q.morphAttributes)==null?void 0:jt.position)||[],Ze=O.morphTargetInfluences||[],ve=se.length>0&&Ze.length>0;for(let ye=0;ye<U.count;ye++){if(n.set(U.getX(ye),U.getY(ye),U.getZ(ye)),ve){l.set(0,0,0);let Qt=0;for(let X=0;X<se.length;X++){const ee=Ze[X]||0;ee&&(Qt+=ee,d.set(se[X].getX(ye),se[X].getY(ye),se[X].getZ(ye)),Q.morphTargetsRelative,l.addScaledVector(d,ee))}Q.morphTargetsRelative?n.add(l):Qt>0&&(n.multiplyScalar(1-Qt),n.add(l))}g.copy(n).applyMatrix4(O.matrixWorld),u.expandByPoint(g)}};if(c.forEach(O=>{O.traverse(Q=>{if(Q.visible){if(Q instanceof f.Mesh){m(Q);return}(Q.isPoint||Q.isLine)&&v(Q)}})}),u.isEmpty())return;const _=new f.Vector3;u.getCenter(_);const y=new f.Vector3;u.getSize(y);const x=_.clone();this._lastTarget.copy(x);let w;h?w=h.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),T=[new f.Vector3(b.x,b.y,b.z),new f.Vector3(b.x,b.y,-b.z),new f.Vector3(b.x,-b.y,b.z),new f.Vector3(b.x,-b.y,-b.z),new f.Vector3(-b.x,b.y,b.z),new f.Vector3(-b.x,b.y,-b.z),new f.Vector3(-b.x,-b.y,b.z),new f.Vector3(-b.x,-b.y,-b.z)],M=new f.Vector3(0,1,0);Math.abs(w.dot(M))>.99&&M.set(0,0,1);const R=new f.Vector3().crossVectors(w,M).normalize(),C=new f.Vector3().crossVectors(R,w).normalize();let P=0;T.forEach(O=>{const Q=O.dot(R),U=O.dot(C),se=Math.sqrt(Q*Q+U*U);P=Math.max(P,se)}),P=P/2+.4;const D=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(D/2)*this.camera.aspect),S=P/Math.tan(A/2),L=P/Math.tan(D/2),I=Math.max(S,L),k=_.clone().add(w.multiplyScalar(I)),F=this.camera.position.clone(),z=this.controls.target.clone();let B=500;const N=F.distanceTo(k)+z.distanceTo(x);N>.001&&(B=Math.min(1e3,Math.max(450,N*45))),this._animateCamera(F,k,z,x,B)},this.focusSlots=c=>{var C,P;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),S=this.controls.target.clone(),L=D.position.clone(),I=D.target.clone();let k=500;const F=A.distanceTo(L)+S.distanceTo(I);F>.001&&(k=Math.min(1e3,Math.max(450,F*45))),this._animateCamera(A,L,S,I,k,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new f.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(P=this._fitAnimation)==null||P.stop(),this.shadowMode=!0;const h=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const A=new f.Vector3;return D.parent.getWorldPosition(A),[A]});if(!h.length)return;const u=h.reduce((D,A)=>D.add(A),new f.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),n=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of h){const A=D.clone().sub(u),S=A.dot(n),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>l&&(l=L)}l=l+.4;const d=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(d/2)*this.camera.aspect),v=l/Math.tan(g/2),m=l/Math.tan(d/2),_=Math.max(v,m),y=u.clone(),x=u.clone().add(n.clone().multiplyScalar(_<1?1:_)),w=this.camera.position.clone(),b=p.clone(),T={t:0};let M=500;const R=w.distanceTo(x)+b.distanceTo(y);R>.001&&(M=Math.min(1e3,Math.max(450,R*45))),this._lastTarget=y.clone(),this._fitAnimation=new bi(T).to({t:1},M).easing(oe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=T.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new f.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new f.Vector3),u=h.clone().multiplyScalar(.5),p=new f.Vector3(0,0,u.z);this._lastTarget.copy(p);let n=u.clone().sub(p);n.lengthSq()<1e-6&&(n=new f.Vector3(1,0,0));const l=n.clone().normalize(),d=h.clone().multiplyScalar(.5),g=[new f.Vector3(d.x,d.y,d.z),new f.Vector3(d.x,d.y,-d.z),new f.Vector3(d.x,-d.y,d.z),new f.Vector3(d.x,-d.y,-d.z),new f.Vector3(-d.x,d.y,d.z),new f.Vector3(-d.x,d.y,-d.z),new f.Vector3(-d.x,-d.y,d.z),new f.Vector3(-d.x,-d.y,-d.z)];let v=0;for(const A of g){const S=A.dot(l),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>v&&(v=L)}v=v*1.05;const m=this.camera.fov*Math.PI/180,_=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=v/Math.tan(_/2),x=v/Math.tan(m/2),w=Math.max(y,x),b=u.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const M=n.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(h.x*2,5);const R=this.camera.position.clone(),C=this.controls.target.clone();let P=600;const D=R.distanceTo(M)+C.distanceTo(p);D>.001&&(P=Math.min(800,Math.max(650,D*45))),this._animateCamera(R,M,C,p,P,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,n;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,u=c.clientHeight;this.size.set(h,u),this.camera.aspect=h/u,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,u),this._updateCamera(),this.css2dRenderer.setSize(h,u),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,u),(n=this._jumpFlood)==null||n.setSize(h,u)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Kc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const u=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(u)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),oe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Jr(qe,this.renderer),this._ground.visible=!1,this.controls=new Mn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=Lr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:sn()?.2:1,this._cameraPositionUI=new zc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=f.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=f.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=sl();this.pathTracer=new _a(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new Ec(e.workerUrl),r=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=r,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const o=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,o(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new Fc(this.renderer,this.scene,{size:8,lightCount:6,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.75}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Hc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new kc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new f.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new f.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new Fs.HDRLoader().load(jc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.attach(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:Lr,this.sampleCount=0}get fpsAverage(){return tn(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof f.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),this.amr.ikControllers.forEach(i=>i.enabled=!1),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&(this.amr.controllers.forEach(t=>t.show()),this.amr.ikControllers.forEach(t=>t.enabled=!0)),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide()),this.amr.ikControllers.forEach(t=>e?t.enabled=!0:t.enabled=!1)}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new Fs.HDRLoader().load(Nc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new f.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{this.overlayScene.attach(e.target)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const r=document.createElement("canvas");r.width=t,r.height=i;const o=r.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let u=0;u<t;u++){const p=((i-h-1)*t+u)*4,n=(h*t+u)*4;c.data[n]=s[p],c.data[n+1]=s[p+1],c.data[n+2]=s[p+2],c.data[n+3]=s[p+3]}return o.putImageData(c,0,0),r.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const r=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(r)},this.fpsAverage)})}async captureTriViews(e){var o;const t=(e==null?void 0:e.subject)??this._container;(o=this._progressShadow)==null||o.visible;const i=this.scene.background,s=this.showSize;return new _n({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){Re(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await nn.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(r=>{if(!Object.keys(r.morphTargetDictionary||{}).includes(i))return;let o=s;r.userData[`origin_${i}`]&&(o-=r.userData[`origin_${i}`]);const c=r.morphTargetDictionary[i];r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o),r instanceof f.Mesh&&r.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,r,o){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new bi(c).to({t:1},r).easing(oe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const u=c.t;this.controls.target.lerpVectors(i,s,u);const p=s.clone(),n=e.clone().sub(p),l=t.clone().sub(p),d=n.length(),g=l.length(),v=d+(g-d)*u;let m;if(d>.001&&g>.001){const _=n.clone().normalize(),y=l.clone().normalize(),x=_.angleTo(y);if(x>.001){const w=new f.Vector3().crossVectors(_,y);if(w.lengthSq()>.001){w.normalize();const b=new f.Quaternion().setFromAxisAngle(w,x*u),T=_.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=e.clone().lerp(t,u);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,o==null||o()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3938
|
+
`});super(s,r),this.position.z=-.02}}const Nc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",jc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Qc="https://cdn2.seer-group.com/libs/fonts.type.json",qc=new Cn.Font(Qc);class xs{constructor(e){var i;this._props=e,this.name="",this._defaults={color:"",metalness:0,roughness:0,envMapIntensity:1},this.color="",this.metalness=0,this.roughness=0,this.envMapIntensity=1,this.name=this._props.name;const t=this.material;t&&(this.color=this._defaults.color="#"+((i=t.color)==null?void 0:i.getHexString()),this.metalness=this._defaults.metalness=t.metalness??0,this.roughness=this._defaults.roughness=t.roughness??1,this.envMapIntensity=this._defaults.envMapIntensity=t.envMapIntensity??1)}get material(){if(this._props.target instanceof f.MeshStandardMaterial)return this._props.target;if(this._props.target instanceof f.Mesh){if(Array.isArray(this._props.target.material))return this._props.target.material.find(e=>e instanceof f.MeshStandardMaterial);if(this._props.target.material instanceof f.MeshStandardMaterial)return this._props.target.material}}change(e){var i;this.color=e;const t=this.material;(i=t==null?void 0:t.color)==null||i.set(e)}reset(){this.change(this._defaults.color);const e=this.material;e&&(e.metalness=this._defaults.metalness,e.roughness=this._defaults.roughness,e.envMapIntensity=this._defaults.envMapIntensity,e.needsUpdate=!0)}}var gn=(a=>(a[a.DEFAULT=0]="DEFAULT",a[a.CAN_INSTALL=1]="CAN_INSTALL",a))(gn||{});const Lr=.15;f.Object3D.DEFAULT_UP.set(0,0,1);let ft,wi=0,ws=0;const Yc=()=>{ft=void 0,wi=0,ws=0},Kc=new f.MeshBasicMaterial({colorWrite:!1});class Zc{constructor(e){this.props=e,this.stats=new Vt,this.scene=new f.Scene,this.overlayScene=new f.Scene,this.renderer=new f.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new Ae.CSS2DRenderer,this.mousePos=new f.Vector2,this.mouseCoord=new f.Vector2,this.offset=new f.Vector2,this.size=new f.Vector2,this.amr=new ln({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new f.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new f.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new f.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new f.Group,this._raycaster=new f.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new Ke,this.sound=new $a,this._rafId=null,this._destroyed=!1,this._css2dUiStyleInjected=!1,this._ground=new f.Mesh(new f.PlaneGeometry(100,100),new f.MeshPhysicalMaterial({color:new f.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Gc(18,40),this._amrRender=new f.WebGLRenderTarget(1024,1024,{format:f.RGBAFormat,type:f.UnsignedByteType,colorSpace:f.SRGBColorSpace,samples:8}),this._lastTarget=new f.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:h,left:u}=this.renderer.domElement.getBoundingClientRect();this.offset.set(u,h),this.mousePos.set(c.clientX-u,c.clientY-h),this.mouseCoord.set((c.clientX-u)/this.size.x*2-1,-((c.clientY-h)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const h=()=>{this.amr.slots.forEach(n=>n.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(n=>{n.traverse(l=>{l==p.object||(n.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(h,200)},this._detectTrackpad=()=>{ft||typeof ft<"u"||(wi===0&&(ws=performance.now()),wi++,performance.now()-ws>66&&(wi>5?ft=!0:ft=!1,ft?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Yc,2e3)))},this.debounceForkHeightChange=nl(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,h)=>{var W;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(W=this._fitAnimation)==null||W.stop();const u=new f.Box3,p=new f.Box3,n=new f.Vector3,l=new f.Vector3,d=new f.Vector3,g=new f.Vector3,v=O=>{O.geometry&&(O.geometry.boundingBox||O.geometry.computeBoundingBox(),p.copy(O.geometry.boundingBox).applyMatrix4(O.matrixWorld),p.isEmpty()||u.union(p))},m=O=>{var Nt,jt;const Q=O.geometry,U=(Nt=Q==null?void 0:Q.attributes)==null?void 0:Nt.position;if(!U){v(O);return}const se=((jt=Q.morphAttributes)==null?void 0:jt.position)||[],Ze=O.morphTargetInfluences||[],ve=se.length>0&&Ze.length>0;for(let ye=0;ye<U.count;ye++){if(n.set(U.getX(ye),U.getY(ye),U.getZ(ye)),ve){l.set(0,0,0);let Qt=0;for(let X=0;X<se.length;X++){const ee=Ze[X]||0;ee&&(Qt+=ee,d.set(se[X].getX(ye),se[X].getY(ye),se[X].getZ(ye)),Q.morphTargetsRelative,l.addScaledVector(d,ee))}Q.morphTargetsRelative?n.add(l):Qt>0&&(n.multiplyScalar(1-Qt),n.add(l))}g.copy(n).applyMatrix4(O.matrixWorld),u.expandByPoint(g)}};if(c.forEach(O=>{O.traverse(Q=>{if(Q.visible){if(Q instanceof f.Mesh){m(Q);return}(Q.isPoint||Q.isLine)&&v(Q)}})}),u.isEmpty())return;const _=new f.Vector3;u.getCenter(_);const y=new f.Vector3;u.getSize(y);const x=_.clone();this._lastTarget.copy(x);let w;h?w=h.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),T=[new f.Vector3(b.x,b.y,b.z),new f.Vector3(b.x,b.y,-b.z),new f.Vector3(b.x,-b.y,b.z),new f.Vector3(b.x,-b.y,-b.z),new f.Vector3(-b.x,b.y,b.z),new f.Vector3(-b.x,b.y,-b.z),new f.Vector3(-b.x,-b.y,b.z),new f.Vector3(-b.x,-b.y,-b.z)],M=new f.Vector3(0,1,0);Math.abs(w.dot(M))>.99&&M.set(0,0,1);const R=new f.Vector3().crossVectors(w,M).normalize(),C=new f.Vector3().crossVectors(R,w).normalize();let P=0;T.forEach(O=>{const Q=O.dot(R),U=O.dot(C),se=Math.sqrt(Q*Q+U*U);P=Math.max(P,se)}),P=P/2+.4;const D=this.camera.fov*Math.PI/180,A=2*Math.atan(Math.tan(D/2)*this.camera.aspect),S=P/Math.tan(A/2),L=P/Math.tan(D/2),I=Math.max(S,L),k=_.clone().add(w.multiplyScalar(I)),F=this.camera.position.clone(),z=this.controls.target.clone();let B=500;const N=F.distanceTo(k)+z.distanceTo(x);N>.001&&(B=Math.min(1e3,Math.max(450,N*45))),this._animateCamera(F,k,z,x,B)},this.focusSlots=c=>{var C,P;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const A=this.camera.position.clone(),S=this.controls.target.clone(),L=D.position.clone(),I=D.target.clone();let k=500;const F=A.distanceTo(L)+S.distanceTo(I);F>.001&&(k=Math.min(1e3,Math.max(450,F*45))),this._animateCamera(A,L,S,I,k,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(C=this._fitAnimation)!=null&&C.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new f.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(P=this._fitAnimation)==null||P.stop(),this.shadowMode=!0;const h=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const A=new f.Vector3;return D.parent.getWorldPosition(A),[A]});if(!h.length)return;const u=h.reduce((D,A)=>D.add(A),new f.Vector3).multiplyScalar(1/h.length),p=this.controls.target.clone(),n=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of h){const A=D.clone().sub(u),S=A.dot(n),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>l&&(l=L)}l=l+.4;const d=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(d/2)*this.camera.aspect),v=l/Math.tan(g/2),m=l/Math.tan(d/2),_=Math.max(v,m),y=u.clone(),x=u.clone().add(n.clone().multiplyScalar(_<1?1:_)),w=this.camera.position.clone(),b=p.clone(),T={t:0};let M=500;const R=w.distanceTo(x)+b.distanceTo(y);R>.001&&(M=Math.min(1e3,Math.max(450,R*45))),this._lastTarget=y.clone(),this._fitAnimation=new bi(T).to({t:1},M).easing(oe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=T.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new f.Box3().setFromObject(this._container);const h=this.amr.sizeBox.size.getSize(new f.Vector3),u=h.clone().multiplyScalar(.5),p=new f.Vector3(0,0,u.z);this._lastTarget.copy(p);let n=u.clone().sub(p);n.lengthSq()<1e-6&&(n=new f.Vector3(1,0,0));const l=n.clone().normalize(),d=h.clone().multiplyScalar(.5),g=[new f.Vector3(d.x,d.y,d.z),new f.Vector3(d.x,d.y,-d.z),new f.Vector3(d.x,-d.y,d.z),new f.Vector3(d.x,-d.y,-d.z),new f.Vector3(-d.x,d.y,d.z),new f.Vector3(-d.x,d.y,-d.z),new f.Vector3(-d.x,-d.y,d.z),new f.Vector3(-d.x,-d.y,-d.z)];let v=0;for(const A of g){const S=A.dot(l),L=Math.sqrt(Math.max(0,A.lengthSq()-S*S));L>v&&(v=L)}v=v*1.05;const m=this.camera.fov*Math.PI/180,_=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=v/Math.tan(_/2),x=v/Math.tan(m/2),w=Math.max(y,x),b=u.clone();let T=h.z/3;h.z<h.x&&h.z<h.y&&(T=h.x*.8),h.z>h.x&&h.z>h.y&&(T=0),b.z+=T;const M=n.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(h.x*2,5);const R=this.camera.position.clone(),C=this.controls.target.clone();let P=600;const D=R.distanceTo(M)+C.distanceTo(p);D>.001&&(P=Math.min(800,Math.max(650,D*45))),this._animateCamera(R,M,C,p,P,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,n;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const h=c.clientWidth,u=c.clientHeight;this.size.set(h,u),this.camera.aspect=h/u,this.camera.updateProjectionMatrix(),this._amrRender.setSize(h,u),this._updateCamera(),this.css2dRenderer.setSize(h,u),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(h,u),(n=this._jumpFlood)==null||n.setSize(h,u)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.amr.shapeKeyDirty&&(this.amr.shapeKeyDirty=!1,this._invalidateMorphGeometries(),this.pathTracer.setScene(this.scene,this.mainCamera),this.sampleCount=0,this.pathTracer.pausePathTracing=!1),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const h=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Kc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=h}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const u=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(u)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),oe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Jr(qe,this.renderer),this._ground.visible=!1,this.controls=new Mn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=Lr,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:sn()?.2:1,this._cameraPositionUI=new zc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=f.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=f.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.css2dRenderer.domElement.setAttribute("data-css2d-root","1"),this._ensureCss2dUiStyle(),this.camera.position.set(10,-10,5),this.camera.lookAt(new f.Vector3);const{tiles:t}=sl();this.pathTracer=new _a(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new Ec(e.workerUrl),r=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=r,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const o=()=>{let c=this._lastTarget.x,h=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=h};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,o(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new Fc(this.renderer,this.scene,{size:8,lightCount:6,frames:e.isMobile?20:60,lightRadius:2,ambientWeight:.75}),this._progressShadow.lightOrigin.position.set(3,2.5,.6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Hc(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new kc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new f.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}_invalidateMorphGeometries(){this.scene.traverse(e=>{if(e instanceof f.Mesh&&e.morphTargetInfluences&&e.morphTargetDictionary){const t=e.geometry.attributes.position;t&&(t.needsUpdate=!0)}})}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new f.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new Fs.HDRLoader().load(jc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.attach(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:Lr,this.sampleCount=0}get fpsAverage(){return tn(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof f.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),this.amr.ikControllers.forEach(i=>i.enabled=!1),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&(this.amr.controllers.forEach(t=>t.show()),this.amr.ikControllers.forEach(t=>t.enabled=!0)),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide()),this.amr.ikControllers.forEach(t=>e?t.enabled=!0:t.enabled=!1)}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new Fs.HDRLoader().load(Nc,t=>{t.mapping=f.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new f.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new f.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{this.overlayScene.attach(e.target)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const r=document.createElement("canvas");r.width=t,r.height=i;const o=r.getContext("2d"),c=new ImageData(t,i);for(let h=0;h<i;h++)for(let u=0;u<t;u++){const p=((i-h-1)*t+u)*4,n=(h*t+u)*4;c.data[n]=s[p],c.data[n+1]=s[p+1],c.data[n+2]=s[p+2],c.data[n+3]=s[p+3]}return o.putImageData(c,0,0),r.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const r=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(r)},this.fpsAverage)})}async captureTriViews(e){var o;const t=(e==null?void 0:e.subject)??this._container;(o=this._progressShadow)==null||o.visible;const i=this.scene.background,s=this.showSize;return new _n({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){Re(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await nn.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.overlayScene.traverse(r=>{if(!Object.keys(r.morphTargetDictionary||{}).includes(i))return;let o=s;r.userData[`origin_${i}`]&&(o-=r.userData[`origin_${i}`]);const c=r.morphTargetDictionary[i];r.morphTargetInfluences&&(r.morphTargetInfluences[c]=o)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,r,o){var h;const c={t:0};(h=this._fitAnimation)==null||h.stop(),this._fitAnimation=new bi(c).to({t:1},r).easing(oe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const u=c.t;this.controls.target.lerpVectors(i,s,u);const p=s.clone(),n=e.clone().sub(p),l=t.clone().sub(p),d=n.length(),g=l.length(),v=d+(g-d)*u;let m;if(d>.001&&g>.001){const _=n.clone().normalize(),y=l.clone().normalize(),x=_.angleTo(y);if(x>.001){const w=new f.Vector3().crossVectors(_,y);if(w.lengthSq()>.001){w.normalize();const b=new f.Quaternion().setFromAxisAngle(w,x*u),T=_.clone().applyQuaternion(b);m=p.clone().add(T.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=p.clone().add(_.multiplyScalar(v))}else m=e.clone().lerp(t,u);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,o==null||o()}).start()}select(e,t=4){if(this._jumpFlood&&(this._jumpFlood.params.thickness=t),!e){this._selectedForOutline=[];return}typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
|
|
3939
3939
|
-webkit-user-select: none;
|
|
3940
3940
|
user-select: none;
|
|
3941
3941
|
touch-action: none;
|
|
@@ -3944,4 +3944,4 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3944
3944
|
[data-css2d-root="1"] [data-ui-type="mechanism"] {
|
|
3945
3945
|
z-index: 2147483647 !important;
|
|
3946
3946
|
}
|
|
3947
|
-
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,r,o,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(r=this._sciFiGrid.material)==null||r.dispose(),oe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(o=this._fitAnimation)==null||o.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),Re(this.scene),this.scene.clear()}}class _n{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new f.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new f.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,v,m,_,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new f.Vector2;t.getSize(s);const r=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((v=e==null?void 0:e.size)==null?void 0:v.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,u=r/o||1,p=this.resolveViews(e==null?void 0:e.views),n=new f.WebGLRenderTarget(r,o,{format:f.RGBAFormat,type:f.UnsignedByteType});n.texture.colorSpace=f.SRGBColorSpace,n.texture.generateMipmaps=!1,n.depthBuffer=!0;const l=this.storeRendererState(t),d={};try{(_=(m=this.deps).onBeforeCapture)==null||_.call(m);const w=this.computeBounds(i);this.applyRendererState(t,r,o,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,u,c,r,o);t.setRenderTarget(n),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const M=this.readPixels(t,n,r,o);d[b.key]=M}}finally{n.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return d}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new f.Vector3(0,0,1),up:new f.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new f.Vector3(0,-1,0),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new f.Vector3(1,0,0),up:new f.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new f.Vector3(1,1,1),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new f.Box3,i=new f.Box3,s=new f.Vector3,r=new f.Vector3,o=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const u=c.geometry;if(!u)return;u.boundingBox||u.computeBoundingBox();const p=u.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),r.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(r),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(r.length()*.5,.001)),{box:t,center:s,size:r,sphere:o}}configureCamera(e,t,i,s,r,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,T=f.MathUtils.degToRad(b),M=Math.max(Math.tan(T/2),1e-4),R=Math.max(M*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),P=new f.Vector3().crossVectors(C,h).normalize();P.lengthSq()<1e-6&&P.set(1,0,0);const D=new f.Vector3().crossVectors(P,C).normalize(),A=Math.max(e.size.x*.5,1e-4),S=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),I=[new f.Vector3(-A,-S,-L),new f.Vector3(-A,-S,L),new f.Vector3(-A,S,-L),new f.Vector3(-A,S,L),new f.Vector3(A,-S,-L),new f.Vector3(A,-S,L),new f.Vector3(A,S,-L),new f.Vector3(A,S,L)];let k=0,F=-1/0;for(const N of I){const W=P.dot(N),O=D.dot(N),Q=C.dot(N);F=Math.max(F,Q);const U=Q+Math.abs(W)/R,se=Q+Math.abs(O)/M;k=Math.max(k,U,se)}k=Math.max(k,F+.1);const z=k*(1+s);let B=1/0;for(const N of I){const W=C.dot(N),O=z-W;O>.001&&(B=Math.min(B,O))}return w.fov=b,w.aspect=i||r/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(B)?B*.5:z*.1),w.far=Math.max(w.near+1,z+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(z)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,n=e.size,l=e.center,d=Math.max(n[t.plane.width]*.5,.01),g=Math.max(n[t.plane.height]*.5,.01),v=Math.max(n[t.plane.depth]*.5,.01);let m=d*(1+s),_=g*(1+s);m/i>_?_=m/i:m=_*i;const y=v*(1+s)+Math.max(m,_),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=_,p.bottom=-_,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(h),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new f.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),r=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new f.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),u=Math.max(t.z,.001),p=Math.max(o,s.z),n=u*.5+h*.5;return c.z=p*n,c.multiply(r),c}storeRendererState(e){const t=new f.Vector2;e.getSize(t);const i=new f.Vector4;e.getViewport(i);const s=new f.Vector4;e.getScissor(s);const r=e.getClearColor(new f.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:r,clearAlpha:o}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const r=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==r)&&(this.pixelBuffer=new Uint8Array(r)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const o=this.ensureCanvas(i,s),c=o.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),u=h.data,p=this.pixelBuffer;for(let n=0;n<s;n+=1){const d=(s-n-1)*i*4,g=n*i*4;u.set(p.subarray(d,d+i*4),g)}return c.putImageData(h,0,0),o.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Xc="shop-components",Jc="0.4.
|
|
3947
|
+
`,document.head.append(t),this._css2dUiStyleInjected=!0}updatePosition(){}removeFromParent(){var t;const e=this.renderer.domElement.parentElement;e&&((t=this._resizeObserver)==null||t.unobserve(e),e.removeChild(this.renderer.domElement))}clean(){this.amr.clean(),this._progressShadow.clear()}destroy(){var t,i,s,r,o,c;this._destroyed=!0,this._rafId!==null&&(cancelAnimationFrame(this._rafId),this._rafId=null),this._clock.stop(),(t=this._controlsGizmo)==null||t.destroy(),this.amr.destroy(),this.amr.removeFromParent(),this._progressShadow.destroy(),(i=this._sciFiGrid)==null||i.removeFromParent(),(s=this._sciFiGrid)==null||s.geometry.dispose(),(r=this._sciFiGrid.material)==null||r.dispose(),oe.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(o=this._fitAnimation)==null||o.stop(),window.removeEventListener("drag",this._drag),document.removeEventListener("wheel",this._detectTrackpad),window.removeEventListener("pointermove",this._pointermove),this.renderer.domElement.removeEventListener("pointerdown",this._pointerdown);const e=this.renderer.domElement.parentElement;e&&((c=this._resizeObserver)==null||c.unobserve(e)),this.controls.dispose(),this.renderer.domElement.remove(),this.renderer.dispose(),Re(this.scene),this.scene.clear()}}class _n{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new f.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new f.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,v,m,_,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new f.Vector2;t.getSize(s);const r=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),o=((v=e==null?void 0:e.size)==null?void 0:v.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,u=r/o||1,p=this.resolveViews(e==null?void 0:e.views),n=new f.WebGLRenderTarget(r,o,{format:f.RGBAFormat,type:f.UnsignedByteType});n.texture.colorSpace=f.SRGBColorSpace,n.texture.generateMipmaps=!1,n.depthBuffer=!0;const l=this.storeRendererState(t),d={};try{(_=(m=this.deps).onBeforeCapture)==null||_.call(m);const w=this.computeBounds(i);this.applyRendererState(t,r,o,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,u,c,r,o);t.setRenderTarget(n),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const M=this.readPixels(t,n,r,o);d[b.key]=M}}finally{n.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return d}resolveViews(e){return e&&e.length?e.map(t=>({key:t.key,direction:t.direction.clone(),up:t.up.clone(),plane:t.plane})):[{key:"top",direction:new f.Vector3(0,0,1),up:new f.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new f.Vector3(0,-1,0),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new f.Vector3(1,0,0),up:new f.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new f.Vector3(1,1,1),up:new f.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new f.Box3,i=new f.Box3,s=new f.Vector3,r=new f.Vector3,o=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const u=c.geometry;if(!u)return;u.boundingBox||u.computeBoundingBox();const p=u.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),r.set(.001,.001,.001),o.center.copy(s),o.radius=.001):(t.getCenter(s),t.getSize(r),t.getBoundingSphere(o)),(!Number.isFinite(o.radius)||o.radius<=0)&&(o.radius=Math.max(r.length()*.5,.001)),{box:t,center:s,size:r,sphere:o}}configureCamera(e,t,i,s,r,o){const c=t.direction.clone().normalize();c.lengthSq()===0&&c.set(0,0,1);const h=t.up.clone().normalize();if(Math.abs(h.dot(c))>.999&&(h.set(0,0,1),Math.abs(h.dot(c))>.999&&h.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,T=f.MathUtils.degToRad(b),M=Math.max(Math.tan(T/2),1e-4),R=Math.max(M*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),P=new f.Vector3().crossVectors(C,h).normalize();P.lengthSq()<1e-6&&P.set(1,0,0);const D=new f.Vector3().crossVectors(P,C).normalize(),A=Math.max(e.size.x*.5,1e-4),S=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),I=[new f.Vector3(-A,-S,-L),new f.Vector3(-A,-S,L),new f.Vector3(-A,S,-L),new f.Vector3(-A,S,L),new f.Vector3(A,-S,-L),new f.Vector3(A,-S,L),new f.Vector3(A,S,-L),new f.Vector3(A,S,L)];let k=0,F=-1/0;for(const N of I){const W=P.dot(N),O=D.dot(N),Q=C.dot(N);F=Math.max(F,Q);const U=Q+Math.abs(W)/R,se=Q+Math.abs(O)/M;k=Math.max(k,U,se)}k=Math.max(k,F+.1);const z=k*(1+s);let B=1/0;for(const N of I){const W=C.dot(N),O=z-W;O>.001&&(B=Math.min(B,O))}return w.fov=b,w.aspect=i||r/Math.max(o,1),w.near=Math.max(.1,Number.isFinite(B)?B*.5:z*.1),w.far=Math.max(w.near+1,z+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(z)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,n=e.size,l=e.center,d=Math.max(n[t.plane.width]*.5,.01),g=Math.max(n[t.plane.height]*.5,.01),v=Math.max(n[t.plane.depth]*.5,.01);let m=d*(1+s),_=g*(1+s);m/i>_?_=m/i:m=_*i;const y=v*(1+s)+Math.max(m,_),x=l.clone().add(c.multiplyScalar(y));return p.left=-m,p.right=m,p.top=_,p.bottom=-_,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(h),p.lookAt(l),p.updateProjectionMatrix(),p.updateMatrixWorld(!0),p}getPerspectiveDirection(e,t){const i=e.direction.clone();i.lengthSq()===0&&i.set(1,1,1);const s=new f.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),r=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),o=.25,c=new f.Vector3(Math.max(o,s.x)*Math.max(t.x,.001),Math.max(o,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),u=Math.max(t.z,.001),p=Math.max(o,s.z),n=u*.5+h*.5;return c.z=p*n,c.multiply(r),c}storeRendererState(e){const t=new f.Vector2;e.getSize(t);const i=new f.Vector4;e.getViewport(i);const s=new f.Vector4;e.getScissor(s);const r=e.getClearColor(new f.Color),o=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:r,clearAlpha:o}}applyRendererState(e,t,i,s){if(e.setPixelRatio(1),e.setSize(t,i,!1),e.setViewport(0,0,t,i),e.setScissor(0,0,t,i),e.setScissorTest(!1),e.autoClear=!0,s!==void 0)if(s===null){const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const r=e.getClearColor(new f.Color);e.setClearColor(r,0)}}restoreRendererState(e,t){e.setPixelRatio(t.pixelRatio),e.setSize(t.size.x,t.size.y,!1),e.setViewport(t.viewport.x,t.viewport.y,t.viewport.z,t.viewport.w),e.setScissor(t.scissor.x,t.scissor.y,t.scissor.z,t.scissor.w),e.setScissorTest(t.scissorTest),e.autoClear=t.autoClear,e.setRenderTarget(t.target),e.setClearColor(t.clearColor,t.clearAlpha)}readPixels(e,t,i,s){const r=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==r)&&(this.pixelBuffer=new Uint8Array(r)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const o=this.ensureCanvas(i,s),c=o.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),u=h.data,p=this.pixelBuffer;for(let n=0;n<s;n+=1){const d=(s-n-1)*i*4,g=n*i*4;u.set(p.subarray(d,d+i*4),g)}return c.putImageData(h,0,0),o.toDataURL("image/png")}ensureCanvas(e,t){if(typeof document>"u")throw new Error("TriViewCapture: document is not available in this environment.");return this.canvas||(this.canvas=document.createElement("canvas")),(this.canvas.width!==e||this.canvas.height!==t)&&(this.canvas.width=e,this.canvas.height=t),this.canvas}}const Xc="shop-components",Jc="0.4.30",$c="Shop components",eh="dist/shop-components.umd.js",th="dist/shop-components.mjs",ih="dist/main.d.ts",sh={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build","build:web":"BUILD_WEB=1 vite build --outDir dist/web --emptyOutDir",v:"auto-changelog -p && git add CHANGELOG.md"},rh=["dist","package.json"],nh=[],oh="machengda<machengda@seer-group.com>",ah="ISC",lh={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3",tweakpane:"^4.0.3","@tweakpane/core":"^2.0.3",stylus:"^0.63.0"},ch={"string-width":"4.2.3"},hh={three:"0.182.0"},uh={"@tweenjs/tween.js":"^23.1.2","@types/howler":"^2.2.11","@types/three":"0.182.0",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6","three-gpu-pathtracer":"^0.0.24","three-mesh-bvh":"^0.9.5","troika-three-text":"^0.49.1"},fh={name:Xc,version:Jc,description:$c,main:eh,module:th,types:ih,scripts:sh,files:rh,keywords:nh,author:oh,license:ah,devDependencies:lh,resolutions:ch,peerDependencies:hh,dependencies:uh};function Pr(){const a="Nebula Engin",e=fh.version,t=`%c ${a} %c v${e} `;console.log(t,"background:#111827;color:#ffffff;padding:4px 10px;border-radius:4px 0 0 4px;font-weight:700;","background:#10B981;color:#ffffff;padding:4px 10px;border-radius:0 4px 4px 0;font-weight:700;")}const Ir="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const a=globalThis;a[Ir]||(a[Ir]=!0,Pr())}catch{Pr()}exports.Amr=ln;exports.Logo=cs;exports.SGLBLoader=Ht;exports.SLOT_EVENTS=J;exports.Scene3D=Zc;exports.Skin=xs;exports.Slot=ls;exports.SlotState=gn;exports.TriViewCapture=_n;exports.arrayBufferToUrl=os;exports.calculateArrayAverage=tn;exports.calculateFocalLength=Xa;exports.createSGLBFile=cl;exports.downloadBlob=Za;exports.dracoExporter=ll;exports.font=qc;exports.gltfExporter=nn;exports.gltfLoader=qe;exports.imageBitmapToUrl=as;exports.isAppleDevice=sn;exports.textureLoader=Rs;
|