shop-components 0.4.17 → 0.4.19
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/shop-components.cjs
CHANGED
|
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,xe=new WeakMap,ui=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 a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Vr);const K={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 ji extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new pt,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),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Vr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(K.ON_DEVICE_DELETED)}}),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(K.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 a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const n=JSON.parse(s);try{await this.install(n),this._emitter.emit(K.ON_DROP,this)}catch(c){this._emitter.emit(K.ON_DROP_ERROR,c)}}else this._emitter.emit(K.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 a=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*a}}}async loadGlb(e){const i=await new Et({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Et({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.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(),this._emitter.emit(K.ON_DEVICE_REPLACED),s.traverse(a=>{a.name.startsWith("Slot")&&this._bracketSlots.push(a),a.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(a=>{a.add(i)})}else this.clearSlot(),this._emitter.emit(K.ON_DEVICE_REPLACED),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}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(K.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(K.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._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),ge(e)}),this._slotUI.filled=!1,this.deviceInfo=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(K.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(K.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(K.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(K.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(),ge(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])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(n=34,c=60,h=60),a<h){let d=(h-a)*1+n;a<20&&(d=c),d>c&&(d=c),this._slotUI.setSize(d)}else this._slotUI.setSize(n)}clone(e){return new f.Group}}class Za extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=us(),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 a="6px",n=document.createElement("div");n.style.pointerEvents="none",Object.assign(n.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(n);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:a,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;n.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;n.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 oi 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 Za(""),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 u,g;(u=this._line.geometry)==null||u.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new f.Vector3().subVectors(t,e).normalize();let n;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?n=new f.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0)),n.normalize();const c=new f.Vector3().addVectors(e,n.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),d=new f.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,d,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*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=>ge(e)),this.removeFromParent()}}class Ur extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new Ka(""),this._line=new oi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new pn.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 ws.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new mn.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),a=s+this._accumulatedAngle;let n=.006*this.radius;n<.003&&(n=.003),n>.006&&(n=.006);const c=this._createArcGeometry(s,a,this.radius+n);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=[],a=t-e,n=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/n;for(let d=0;d<=n;d++){const p=e+d*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const h=new ws.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class Ka extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=us();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 Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",Ja="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",Xs="data:image/png;base64,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",$a="data:image/png;base64,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";class Js extends me.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new pt,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 c=(Date.now()-this._startAt)/200;c>4&&(c=4);let h=this._initial+.005*c*this._direction;if(h>this.props.max||h<this.props.min){this.mechanism&&(h<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):h>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=h,!this.mechanism)return;this.mechanism.position.setZ(h),this._emitter.emit("change",h)}};const s=us();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Xs}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const n=document.createElement("div");if(n.style.position="absolute",n.style.left="0",n.style.transform="translateX(-50%)",a.style.bottom=n.style.top="8px",n.style.width=n.style.height=a.style.width,n.style.background=`url(${Xs}) center no-repeat`,n.style.backgroundSize="100% auto",n.style.transition="all .2s",n.setAttribute("data-direction","down"),Array.from([a,n]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:h,rotateStep:d,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(u=>{u.name===c.name&&(l=u)}),l)){const u=document.createElement("div");u.style.background=`url(${$a}) center no-repeat`,u.style.backgroundSize="100% auto",u.style.position="absolute",u.style.top="-50%",u.style.left="-50%",u.style.width=s?"140px":"160px",u.style.height=s?"70px":"80px",u.style.transform="translateX(-50%) translateY(-50%)",i.append(u);const g=document.createElement("div");g.style.background=`url(${Ja}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const y=document.createElement("div");y.style.background=`url(${Xa}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",g.style.left=y.style.right=s?"62px":"69px",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","right"),i.append(y),Array.from([g,y]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=d/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new ci(l.rotation).to({z:v}).duration(h).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,n),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 me.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof me.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class el extends gn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new pt,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:d,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(d,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:d,pageY:p}=h;let r=d-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const u=l%10;l=l-u,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(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,a=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 n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.bottom="0",t.append(n),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",n.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",n.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",n.style[this._sizeFlag]=a*100+"px",n.style.textAlign="center",this._sizeFlag==="height"?(n.style.borderLeft="0.1px dashed #fff",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):n.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 tl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new oi("长:"),this._line12=new oi("宽:"),this._line13=new oi("高:"),this._outline=new Ur(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 me.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 me.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:a,hasHeight:n,hasWidth:c}=Va(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=n,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,d=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,u=this._box3.max.y;let g=.2;const y=new f.Vector3(h,u,0),m=new f.Vector3(d,u,0);this._line11.update(y.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const v=new f.Vector3(d,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),v.clone().add(new f.Vector3(g,0,0)),this._radius);const _=new f.Vector3(h,u,p),x=new f.Vector3(h,u,r),w=_.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Ve 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 e,t;this.clear(),(e=this.lineSegments)==null||e.geometry.dispose(),this._lineMaterial.dispose(),(t=this.lineSegments)==null||t.removeFromParent()}clearAll(){this.dispose()}clone(e){const t=new Ve(this._currentLength,this._currentWidth,this._currentHeight);return t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale),t.visible=this.visible,t.castShadow=this.castShadow,t.receiveShadow=this.receiveShadow,e&&this.children.forEach(i=>{if(i!==this.lineSegments){const s=i.clone(!0);t.add(s)}}),t}_generate(e,t,i){ge(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 il="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Qi{constructor(e){this._props=e,this.name="",this.transparentTexture=fs.load(il),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 a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var d;let n=window.devicePixelRatio*2;this._offscreen.width=a.width+n,this._offscreen.height=a.height+n;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,n/2,n/2,a.width,a.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&&((d=h.material.map)==null||d.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.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 $s(o){return o.type?o.type==="Mesh":o.isMesh}const fs=new f.TextureLoader;fs.crossOrigin="anonymous";class Hr extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new pt,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 tl,this._goodsSize=new Ha(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],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._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._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 ji&&!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+.14-.54;this.setShapeKey("boxLength",s);const a=i+.14;if(this.setShapeKey("topWidth",a),this.isTopInvert){const n=i-.257;this.setShapeKey("length",n)}else this.setShapeKey("width",a);this._generateRollers()}if(t==="goodsWidth"){const s=i+.193;this.setShapeKey("boxWidth",s);const a=i+.219;if(this.setShapeKey("topLength",a),this.isTopInvert){const n=i+.62;this.setShapeKey("width",n)}else this.setShapeKey("length",a)}})}_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 He.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const d=await new Et({useCache:!0}).loadAsync(e);i=d.animations||[],s=d.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 a=this._findFirstSkinnedMesh(s),n=this._findFirstSkinnedMesh(this._modelRoot);(!a||!n)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof _i.retargetClip=="function";i.forEach(h=>{let d=h;if(c&&a&&n)try{d=_i.retargetClip(n,a,h)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,r)}this._clips=this._clips.filter(r=>r.name!==d.name),this._clips.push(d);const p=this._mixer.clipAction(d);this._actionsMap.set(d.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 n=await He.loadAsync(e);i=n.scene,s=n.animations||[]}else{const c=await new Et({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=_i.clone(i);this._generateAmr(a,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(a=>{var h;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(h=a.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof f.Mesh&&a.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(i=>{if(i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),i.userData.isRollerLevel&&this._rollerLevel.set(i.userData.level||0,i),i.userData.isCenterModel&&(i.visible=this.useCenterModel),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&(this._liftBrackets.push(i),i.visible=this._useLift),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!this._useLift),i.userData.isRoller&&(this._roller=i,this._roller.visible=!1,this._generateRollers()),i.userData.isRollerLevelBox){this._rollerGoodsBox=i;const s=new Ve(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);this.goods.push(s)}Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a);const n=this._shapeKeyTargets.get(s);n?n.push(i):this._shapeKeyTargets.set(s,[i])})}),e.traverse(i=>{if(i instanceof f.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(n=>n.name===a.userData.name)||this.skins.push(new ss({name:a.userData.name,target:a})))});else{if(i.material.userData.isVideo&&i.material.userData.video){const a=i.material.userData.video;let n=this._videoCache.get(a);n||(n=document.createElement("video"),n.src=a,n.crossOrigin="anonymous",n.loop=!0,n.muted=!0,n.playsInline=!0,n.autoplay=!0,n.preload="auto",this._videoCache.set(a,n)),n.play().catch(()=>{}),i.material.map&&i.material.map.dispose(),i.material.emissiveMap&&i.material.emissiveMap.dispose();const c=new f.VideoTexture(n);c.colorSpace=f.SRGBColorSpace,i.material.map=c,i.material.emissiveMap=c,i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=1,i.material.needsUpdate=!0}if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Le.Tween(i.material).to({emissiveIntensity:.2}).easing(Le.Easing.Quintic.InOut).duration(a),c=new Le.Tween(i.material).to({emissiveIntensity:2}).easing(Le.Easing.Quintic.InOut).duration(a);n.onComplete(()=>c.start()),c.onComplete(()=>n.start()),n.start(),this._breathLights.push(n,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new ss({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(n=>{if(n.userData.isLOGO){i.material.transparent=!0;let c;const h={width:0,height:0};i.material.map&&i.material.map.image&&(h.width=i.material.map.image.width,h.height=i.material.map.image.height,c=qi(i.material.map.image)),i.material.needsUpdate=!0;const d=new Qi({name:n.userData.name,target:i,size:Qs(i),imageSize:h,imageUrl:c});this._logos.push(d)}n.userData.isTransparent&&(n.transparent=!0),this._materialsCache.set(n.uuid,{opacity:n.opacity,transparent:n.transparent,roughness:n.roughness,metalness:n.metalness,color:n.color,mat:n})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let n;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,n=qi(i.material.map.image));const h=new Qi({name:a.userData.name,target:i,size:Qs(i),imageSize:c,imageUrl:n});this._logos.push(h)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(n=>{if(n.startsWith("follow_")){const c=n.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[n])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){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=>{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(a=>{a.name.toLowerCase().includes("lift")&&(a.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=>{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 Ve&&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.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}setColumns(e){this._columnCount=e,this._rollerLevel.forEach(t=>{const i=t.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned);if(!i)return;console.log(i);const s=new f.Box3().setFromObject(i),a=new f.Vector3;s.getSize(a);const n=.03,c=a.x;console.log(a);const h=c*e+n*(e-1)-c;for(let d=1;d<e;d++){const p=i.clone(!0);p.userData.cloned=!0,p.position.x+=(n+c)/2,t.add(p)}i.position.x-=h/2})}get levels(){return this._levelCount}setLevels(e){var a;if(!e)return;this._levelCount=e;const t=this._rollerLevel.size;let i=e-t;const s=this._rollerLevel.get(0);if(i>0&&s)for(let n=t;n<e;n++){const c=s.clone(!0);c.visible=!0,c.position.z+=.2,this._rollerLevel.set(n,c),(a=s.parent)==null||a.add(c),this.regenerateShapeKeyNode(c),c.traverse(h=>{h instanceof Ve&&this.goods.push(h)}),this.setGoodsSize({length:this.goodsSize.length,width:this.goodsSize.width,height:this.goodsSize.height})}else for(let n=0;n<t;n++){const c=this._rollerLevel.get(n);c&&(c.visible=n<e)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{$s(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);t.userData.cloned=!0,s&&s.push(t)})})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=[];this._rollerLevel.forEach(p=>{p.traverse(r=>{r.userData.isCloned&&e.push(r)})}),e.forEach(p=>{ge(p),p.removeFromParent()}),e=[];let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s,c=i+s;let h=Math.floor(n/c);const d=n%c;if(h>0){h>1&&(s+=d/(h+2));const p=i+s,r=-t/2+s+i/2;for(let l=0;l<h;l++)this._rollerLevel.forEach(u=>{let g;u.traverse(m=>{m.userData.isRollerLevelBox&&(g=m)});const y=this._roller.clone(!0);y.visible=!0,y.userData.isCloned=!0,y.position.y=r+p*l,g==null||g.add(y),this.regenerateShapeKeyNode(y)})}}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 s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{ge(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(h=>{$s(h)&&(this.setShapeKeyToMesh(h,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(h,"goodsLength",this._goodsSize.length))});const n=this._shelf.clone(!0);n.position.z+=t*a,this._shelves.set(a,n),(s=this._shelf.parent)==null||s.add(n);let c;if(n.traverse(h=>{h.userData.isShelfContainer&&(c=h)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)+this._goodsSize.length/2)),c){const h=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(h),this.goods.push(h),a===1){const d=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);d.position.z-=t,c.add(d),this.goods.push(d)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Ur(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(h=>{h.name===i&&(n=h)}),!n)return;const c=new Js({name:"",target:i,default:0,min:s,max:a},n);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(h=>{h.name===i&&(n=h)}),!n)return;const c=new Js({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},n);e.add(c),this.controllers.push(c),(n.userData.isFork||n.userData.isLift||n.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||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=Oa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new f.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new f.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new f.Vector3(0,0,e.userData.start-e.position.z),c=n.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new el({start:n,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,n=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const h=e.userData.holeTarget&&e.userData.holeTarget.name;let d;h&&t.traverse(u=>{u.name===h&&(d=u)});const p=new Map;Object.keys(e.userData).forEach(u=>{if(u.startsWith("follow_")){const g=u.split("_")[1];if(g){let y=e.userData[u];p.set(g,{scale:y,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new ji({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=d,l.addEventListener(K.ON_DROP,u=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(K.ON_BEFORE_SELECTED,u=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(K.ON_ERROR_STATE_CHANGE,u=>{var y;if(!this._app)return;const g=(y=this._app)==null?void 0:y._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),u){if(l.device){if(g.selectedObjects.find(v=>{var _;return v.parent===((_=l.device)==null?void 0:_.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var v;return m.parent!==((v=l.device)==null?void 0:v.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),ge(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._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._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 a=this._currentAction,n=a===s,c=n?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const d=(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(d?f.LoopRepeat:f.LoopOnce,d?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!d,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(a.stopFading(),a.enabled=!0,a.setEffectiveWeight(1),a.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(r=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=u=>{var g;u.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,r())};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 Wr=0,sl=1,rl=2,er=2,Ri=1.25,tr=1,Pt=6*4+4+4,pi=65535,nl=Math.pow(2,-24),Ii=Symbol("SKIP_GENERATION");function ol(o){return o.index?o.index.count:o.attributes.position.count}function mt(o){return ol(o)/3}function al(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function ll(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=al(t,i);o.setIndex(new f.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Nr(o){const e=mt(o),t=o.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),n=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(n)}]}function Gr(o){if(!o.groups||!o.groups.length)return Nr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of o.groups){const h=c.start/3,d=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(a,d))}const n=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<n.length-1;c++){const h=n[c],d=n[c+1];e.push({offset:Math.floor(h),count:Math.floor(d-h)})}return e}function cl(o){if(o.groups.length===0)return!1;const e=mt(o),t=Gr(o).sort((a,n)=>a.offset-n.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Di(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,h=-1/0,d=-1/0,p=-1/0,r=1/0,l=1/0,u=1/0,g=-1/0,y=-1/0,m=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const x=o[v+0],w=o[v+1],b=x-w,T=x+w;b<a&&(a=b),T>h&&(h=T),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],I=o[v+3],C=S-I,L=S+I;C<n&&(n=C),L>d&&(d=L),S<l&&(l=S),S>y&&(y=S);const R=o[v+4],A=o[v+5],M=R-A,D=R+A;M<c&&(c=M),D>p&&(p=D),R<u&&(u=R),R>m&&(m=R)}i[0]=a,i[1]=n,i[2]=c,i[3]=h,i[4]=d,i[5]=p,s[0]=r,s[1]=l,s[2]=u,s[3]=g,s[4]=y,s[5]=m}function hl(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=mt(o),c=s.normalized;let h;e===null?(h=new Float32Array(n*6*4),t=0,i=n):(h=e,t=t||0,i=i||n);const d=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let u=t;u<t+i;u++){const g=u*3,y=u*6;let m=g+0,v=g+1,_=g+2;a&&(m=a[m],v=a[v],_=a[_]),c||(m=m*r+p,v=v*r+p,_=_*r+p);for(let x=0;x<3;x++){let w,b,T;c?(w=s[l[x]](m),b=s[l[x]](v),T=s[l[x]](_)):(w=d[m+x],b=d[v+x],T=d[_+x]);let S=w;b<S&&(S=b),T<S&&(S=T);let I=w;b>I&&(I=b),T>I&&(I=T);const C=(I-S)/2,L=x*2;h[y+L+0]=S+C,h[y+L+1]=C+(Math.abs(S)+C)*nl}}return h}function Y(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function ir(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function sr(o,e){e.set(o)}function rr(o,e,t){let i,s;for(let a=0;a<3;a++){const n=a+3;i=o[a],s=e[a],t[a]=i<s?i:s,i=o[n],s=e[n],t[n]=i>s?i:s}}function qt(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],a=e[o+2*i+1],n=s-a,c=s+a;n<t[i]&&(t[i]=n),c>t[i+3]&&(t[i+3]=c)}}function bt(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}const _e=32,ul=(o,e)=>o.candidate-e.candidate,Me=new Array(_e).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),jt=new Float32Array(6);function fl(o,e,t,i,s,a){let n=-1,c=0;if(a===Wr)n=ir(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===sl)n=ir(o),n!==-1&&(c=dl(t,i,s,n));else if(a===rl){const h=bt(o);let d=Ri*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const u=e[l],m=(e[l+3]-u)/_e;if(s<_e/4){const v=[...Me];v.length=s;let _=0;for(let w=p;w<r;w+=6,_++){const b=v[_];b.candidate=t[w+2*l],b.count=0;const{bounds:T,leftCacheBounds:S,rightCacheBounds:I}=b;for(let C=0;C<3;C++)I[C]=1/0,I[C+3]=-1/0,S[C]=1/0,S[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;qt(w,t,T)}v.sort(ul);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let T=0;T<x;T++){const S=v[T];b>=S.candidate?qt(w,t,S.rightCacheBounds):(qt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],T=b.count,S=s-b.count,I=b.leftCacheBounds,C=b.rightCacheBounds;let L=0;T!==0&&(L=bt(I)/h);let R=0;S!==0&&(R=bt(C)/h);const A=tr+Ri*(L*T+R*S);A<d&&(n=l,d=A,c=b.candidate)}}else{for(let x=0;x<_e;x++){const w=Me[x];w.count=0,w.candidate=u+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<r;x+=6){let T=~~((t[x+2*l]-u)/m);T>=_e&&(T=_e-1);const S=Me[T];S.count++,qt(x,t,S.bounds)}const v=Me[_e-1];sr(v.bounds,v.rightCacheBounds);for(let x=_e-2;x>=0;x--){const w=Me[x],b=Me[x+1];rr(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let _=0;for(let x=0;x<_e-1;x++){const w=Me[x],b=w.count,T=w.bounds,I=Me[x+1].rightCacheBounds;b!==0&&(_===0?sr(T,jt):rr(T,jt,jt)),_+=b;let C=0,L=0;_!==0&&(C=bt(jt)/h);const R=s-_;R!==0&&(L=bt(I)/h);const A=tr+Ri*(C*_+L*R);A<d&&(n=l,d=A,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function dl(o,e,t,i){let s=0;for(let a=e,n=e+t;a<n;a++)s+=o[a*6+i*2];return s/t}class Li{constructor(){this.boundingData=new Float32Array(6)}}function pl(o,e,t,i,s,a){let n=i,c=i+s-1;const h=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<h;)n++;for(;n<=c&&t[c*6+d]>=h;)c--;if(n<c){for(let p=0;p<3;p++){let r=e[n*3+p];e[n*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[n*6+p];t[n*6+p]=t[c*6+p],t[c*6+p]=r}n++,c--}else return n}}function ml(o,e,t,i,s,a){let n=i,c=i+s-1;const h=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<h;)n++;for(;n<=c&&t[c*6+d]>=h;)c--;if(n<c){let p=o[n];o[n]=o[c],o[c]=p;for(let r=0;r<6;r++){let l=t[n*6+r];t[n*6+r]=t[c*6+r],t[c*6+r]=l}n++,c--}else return n}}function ee(o,e){return e[o+15]===65535}function se(o,e){return e[o+6]}function ne(o,e){return e[o+14]}function oe(o){return o+8}function ae(o,e){return e[o+6]}function qr(o,e){return e[o+7]}let jr,It,ai,Qr;const gl=Math.pow(2,32);function Yi(o){return"count"in o?1:1+Yi(o.left)+Yi(o.right)}function vl(o,e,t){return jr=new Float32Array(t),It=new Uint32Array(t),ai=new Uint16Array(t),Qr=new Uint8Array(t),Zi(o,e)}function Zi(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)jr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Qr.set(new Uint8Array(n),o);for(let c=o,h=o+n.byteLength;c<h;c+=Pt){const d=c/2;ee(d,ai)||(It[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return It[t+6]=n,ai[i+14]=c,ai[i+15]=pi,o+Pt}else{const n=e.left,c=e.right,h=e.splitAxis;let d;if(d=Zi(o+Pt,n),d/4>gl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return It[t+6]=d/4,d=Zi(d,c),It[t+7]=h,d}}function _l(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),n=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,h=n.length;c<h;c++)n[c]=c;return n}function yl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:h,onProgress:d,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,u=l.index?l.index.array:null,g=p?ml:pl,y=mt(l),m=new Float32Array(6);let v=!1;const _=new Li;return Di(e,t,i,_.boundingData,m),w(_,t,i,m),_;function x(b){d&&d(b/y)}function w(b,T,S,I=null,C=0){if(!v&&C>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||C>=a)return x(T+S),b.offset=T,b.count=S,b;const L=fl(b.boundingData,I,e,T,S,h);if(L.axis===-1)return x(T+S),b.offset=T,b.count=S,b;const R=g(r,u,e,T,S,L);if(R===T||R===T+S)x(T+S),b.offset=T,b.count=S;else{b.splitAxis=L.axis;const A=new Li,M=T,D=R-T;b.left=A,Di(e,M,D,A.boundingData,m),w(A,M,D,m,C+1);const P=new Li,E=R,B=S-D;b.right=P,Di(e,E,B,P.boundingData,m),w(P,E,B,m,C+1)}return b}}function xl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=_l(t,e.useSharedArrayBuffer),cl(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.')),o._indirectBuffer||ll(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=hl(t),a=e.indirect?Nr(t):Gr(t);o._roots=a.map(n=>{const c=yl(o,s,n.offset,n.count,e),h=Yi(c),d=new i(Pt*h);return vl(0,c,d),d})}class be{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,n=e.length;a<n;a++){const h=e[a][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 a=0,n=t.length;a<n;a++){const c=t[a],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}}be.prototype.setFromBox=function(){const o=new f.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let d=0;d<=1;d++)for(let p=0;p<=1;p++){o.x=s.x*h+a.x*(1-h),o.y=s.y*d+a.y*(1-d),o.z=s.z*p+a.z*(1-p);const r=t.dot(o);n=Math.min(r,n),c=Math.max(r,c)}this.min=n,this.max=c}}();const wl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,a,n){const c=s.start,h=o,d=a.start,p=e;t.subVectors(c,d),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(h),u=p.dot(p),g=t.dot(h),m=h.dot(h)*u-l*l;let v,_;m!==0?v=(r*l-g*u)/m:v=0,_=(r+v*l)/u,n.x=v,n.y=_}}(),ds=function(){const o=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,a,n,c){wl(s,a,o);let h=o.x,d=o.y;if(h>=0&&h<=1&&d>=0&&d<=1){s.at(h,n),a.at(d,c);return}else if(h>=0&&h<=1){d<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(d>=0&&d<=1){h<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let r;d<0?r=a.start:r=a.end;const l=e,u=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=u.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(u);return}}}}(),bl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(a,n){const{radius:c,center:h}=a,{a:d,b:p,c:r}=n;if(i.start=d,i.end=p,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c||(i.start=d,i.end=r,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c))return!0;const y=n.getPlane(t);if(Math.abs(y.distanceToPoint(h))<=c){const v=y.projectPoint(h,e);if(n.containsPoint(v))return!0}return!1}}(),Al=1e-15;function Pi(o){return Math.abs(o)<Al}class fe 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 be),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return bl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,n=this.satBounds,c=a[0],h=n[0];this.getNormal(c),h.setFromPoints(c,s);const d=a[1],p=n[1];d.subVectors(e,t),p.setFromPoints(d,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const u=a[3],g=n[3];u.subVectors(i,e),g.setFromPoints(u,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}fe.prototype.closestPointToSegment=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,a=null,n=null){const{start:c,end:h}=s,d=this.points;let p,r=1/0;for(let l=0;l<3;l++){const u=(l+1)%3;t.start.copy(d[l]),t.end.copy(d[u]),ds(t,s,o,e),p=o.distanceToSquared(e),p<r&&(r=p,a&&a.copy(o),n&&n.copy(e))}return this.closestPointToPoint(c,o),p=c.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(c)),this.closestPointToPoint(h,o),p=h.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(h)),Math.sqrt(r)}}();fe.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new Array(3),i=new be,s=new be,a=new f.Vector3,n=new f.Vector3,c=new f.Vector3,h=new f.Vector3,d=new f.Vector3,p=new f.Line3,r=new f.Line3,l=new f.Line3,u=new f.Vector3;function g(y,m,v){const _=y.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:T,end:S}=p;T.copy(_[b]),S.copy(_[(b+1)%3]),p.delta(n);const I=Pi(m.distanceToPoint(T));if(Pi(m.normal.dot(n))&&I){v.copy(p),x=2;break}const C=m.intersectLine(p,u);if(!C&&I&&u.copy(T),(C||I)&&!Pi(u.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(u),I&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(u),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,_=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(o.copy(m),o.update(),m=o);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 L=b[C],R=T[C];if(i.setFromPoints(R,t),L.isSeparated(i))return!1}const S=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const L=S[C],R=I[C];if(i.setFromPoints(R,e),L.isSeparated(i))return!1}for(let C=0;C<4;C++){const L=T[C];for(let R=0;R<4;R++){const A=I[R];if(a.crossVectors(L,A),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(_||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const T=g(m,x,l);if(T===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(T!==2)return!1;if(r.delta(c),l.delta(h),c.dot(h)<0){let M=l.start;l.start=l.end,l.end=M}const S=r.start.dot(c),I=r.end.dot(c),C=l.start.dot(c),L=l.end.dot(c),R=I<C,A=S<L;return S!==L&&C!==I&&R===A?!1:(v&&(d.subVectors(r.start,l.start),d.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),d.subVectors(r.end,l.end),d.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();fe.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();fe.prototype.distanceToTriangle=function(){const o=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(n,c=null,h=null){const d=c||h?i:null;if(this.intersectsTriangle(n,d))return(c||h)&&(c&&d.getCenter(c),h&&d.getCenter(h)),0;let p=1/0;for(let r=0;r<3;r++){let l;const u=t[r],g=n[u];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),h&&h.copy(g));const y=this[u];n.closestPointToPoint(y,o),l=y.distanceToSquared(o),l<p&&(p=l,c&&c.copy(y),h&&h.copy(o))}for(let r=0;r<3;r++){const l=t[r],u=t[(r+1)%3];i.set(this[l],this[u]);for(let g=0;g<3;g++){const y=t[g],m=t[(g+1)%3];s.set(n[y],n[m]),ds(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),h&&h.copy(e))}}return Math.sqrt(p)}}();class X{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 be),this.alignedSatBounds=new Array(3).fill().map(()=>new be),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}}X.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let d=0;d<=1;d++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*d|2*p|4*r,u=s[l];u.x=d?i.x:t.x,u.y=p?i.y:t.y,u.z=r?i.z:t.z,u.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let d=0;d<3;d++){const p=n[d],r=a[d],l=1<<d,u=s[l];p.subVectors(c,u),r.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}}();X.prototype.intersectsBox=function(){const o=new be;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,n=this.satAxes,c=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,c[0].isSeparated(o)||(o.min=i.y,o.max=s.y,c[1].isSeparated(o))||(o.min=i.z,o.max=s.z,c[2].isSeparated(o)))return!1;for(let h=0;h<3;h++){const d=n[h],p=a[h];if(o.setFromBox(d,t),p.isSeparated(o))return!1}return!0}}();X.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new be,i=new be,s=new f.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(o.copy(n),o.update(),n=o);const c=this.satBounds,h=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const u=c[l],g=h[l];if(t.setFromPoints(g,e),u.isSeparated(t))return!1}const d=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const u=d[l],g=p[l];if(t.setFromPoints(g,r),u.isSeparated(t))return!1}for(let l=0;l<3;l++){const u=h[l];for(let g=0;g<4;g++){const y=p[g];if(s.crossVectors(u,y),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();X.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}}();X.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();X.prototype.distanceToBox=function(){const o=["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(n,c=0,h=null,d=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(h||d)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),h&&h.copy(i),d&&d.copy(s)),0;const p=c*c,r=n.min,l=n.max,u=this.points;let g=1/0;for(let m=0;m<8;m++){const v=u[m];s.copy(v).clamp(r,l);const _=v.distanceToSquared(s);if(_<g&&(g=_,h&&h.copy(v),d&&d.copy(s),_<p))return Math.sqrt(_)}let y=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|_<<w,T=1<<m|v<<x|_<<w,S=u[b],I=u[T];e[y].set(S,I);const L=o[m],R=o[x],A=o[w],M=t[y],D=M.start,P=M.end;D[L]=r[L],D[R]=v?r[R]:l[R],D[A]=_?r[A]:l[R],P[L]=l[L],P[R]=v?r[R]:l[R],P[A]=_?r[A]:l[R],y++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=_?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,h&&h.copy(i),d&&d.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let _=0;_<12;_++){const x=t[_];ds(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,h&&h.copy(i),d&&d.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 Tl extends ps{constructor(){super(()=>new fe)}}const le=new Tl;class Sl{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 q=new Sl;let Pe,at;const Qe=[],Qt=new ps(()=>new f.Box3);function Ml(o,e,t,i,s,a){Pe=Qt.getPrimitive(),at=Qt.getPrimitive(),Qe.push(Pe,at),q.setBuffer(o._roots[e]);const n=Ki(0,o.geometry,t,i,s,a);q.clearBuffer(),Qt.releasePrimitive(Pe),Qt.releasePrimitive(at),Qe.pop(),Qe.pop();const c=Qe.length;return c>0&&(at=Qe[c-1],Pe=Qe[c-2]),n}function Ki(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:h,uint32Array:d}=q;let p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);return Y(o,c,Pe),i(l,u,!1,n,a+o,Pe)}else{let L=function(A){const{uint16Array:M,uint32Array:D}=q;let P=A*2;for(;!ee(P,M);)A=oe(A),P=A*2;return se(A,D)},R=function(A){const{uint16Array:M,uint32Array:D}=q;let P=A*2;for(;!ee(P,M);)A=ae(A,D),P=A*2;return se(A,D)+ne(P,M)};const l=oe(o),u=ae(o,d);let g=l,y=u,m,v,_,x;if(s&&(_=Pe,x=at,Y(g,c,_),Y(y,c,x),m=s(_),v=s(x),v<m)){g=u,y=l;const A=m;m=v,v=A,_=x}_||(_=Pe,Y(g,c,_));const w=ee(g*2,h),b=t(_,w,m,n+1,a+g);let T;if(b===er){const A=L(g),D=R(g)-A;T=i(A,D,!0,n+1,a+g,_)}else T=b&&Ki(g,e,t,i,s,a,n+1);if(T)return!0;x=at,Y(y,c,x);const S=ee(y*2,h),I=t(x,S,v,n+1,a+y);let C;if(I===er){const A=L(y),D=R(y)-A;C=i(A,D,!0,n+1,a+y,x)}else C=I&&Ki(y,e,t,i,s,a,n+1);return!!C}}const At=new f.Vector3,Fi=new f.Vector3;function Cl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,h=null;if(o.shapecast({boundsTraverseOrder:p=>(At.copy(e).clamp(p.min,p.max),At.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,At);const l=e.distanceToSquared(At);return l<c&&(Fi.copy(At),c=l,h=r),l<a}}),c===1/0)return null;const d=Math.sqrt(c);return t.point?t.point.copy(Fi):t.point=Fi.clone(),t.distance=d,t.faceIndex=h,t}const Ye=new f.Vector3,Ze=new f.Vector3,Ke=new f.Vector3,Yt=new f.Vector2,Zt=new f.Vector2,Kt=new f.Vector2,nr=new f.Vector3,or=new f.Vector3,ar=new f.Vector3,Xt=new f.Vector3;function Rl(o,e,t,i,s,a,n,c){let h;if(a===f.BackSide?h=o.intersectTriangle(i,t,e,!0,s):h=o.intersectTriangle(e,t,i,a!==f.DoubleSide,s),h===null)return null;const d=o.origin.distanceTo(s);return d<n||d>c?null:{distance:d,point:s.clone()}}function Il(o,e,t,i,s,a,n,c,h,d,p){Ye.fromBufferAttribute(e,a),Ze.fromBufferAttribute(e,n),Ke.fromBufferAttribute(e,c);const r=Rl(o,Ye,Ze,Ke,Xt,h,d,p);if(r){i&&(Yt.fromBufferAttribute(i,a),Zt.fromBufferAttribute(i,n),Kt.fromBufferAttribute(i,c),r.uv=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),s&&(Yt.fromBufferAttribute(s,a),Zt.fromBufferAttribute(s,n),Kt.fromBufferAttribute(s,c),r.uv1=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),t&&(nr.fromBufferAttribute(t,a),or.fromBufferAttribute(t,n),ar.fromBufferAttribute(t,c),r.normal=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,nr,or,ar,new f.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(Ye,Ze,Ke,l.normal),r.face=l,r.faceIndex=a}return r}function mi(o,e,t,i,s,a,n){const c=i*3;let h=c+0,d=c+1,p=c+2;const r=o.index;o.index&&(h=r.getX(h),d=r.getX(d),p=r.getX(p));const{position:l,normal:u,uv:g,uv1:y}=o.attributes,m=Il(t,l,u,g,y,h,d,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Z(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,h=e+1,d=e+2;t&&(c=t.getX(c),h=t.getX(h),d=t.getX(d)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(h),a.y=i.getY(h),a.z=i.getZ(h),n.x=i.getX(d),n.y=i.getY(d),n.z=i.getZ(d)}function Dl(o,e,t,i,s,a,n,c){const{geometry:h,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++)mi(h,e,t,p,a,n,c)}function Ll(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:h}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let u;u=mi(c,e,t,r,null,a,n),u&&u.distance<d&&(p=u,d=u.distance)}return p}function Pl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:h}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Z(n,l*3,h,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Fl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,h,d=0;const p=o._roots;for(let l=0,u=p.length;l<u;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),h=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,u,g=!1){const y=l*2;if(c[y+15]===pi){const v=n[l+6],_=c[y+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,I=-1/0;for(let C=3*v,L=3*(v+_);C<L;C++){let R=i[C];const A=s.getX(R),M=s.getY(R),D=s.getZ(R);A<x&&(x=A),A>T&&(T=A),M<w&&(w=M),M>S&&(S=M),D<b&&(b=D),D>I&&(I=D)}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==S||h[l+5]!==I?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=S,h[l+5]=I,!0):!1}else{const v=l+8,_=n[l+6],x=v+u,w=_+u;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const I=b||T,C=b||S;let L=!1;I&&(L=r(v,u,b));let R=!1;C&&(R=r(_,u,b));const A=L||R;if(A)for(let M=0;M<3;M++){const D=v+M,P=_+M,E=h[D],B=h[D+3],V=h[P],N=h[P+3];h[l+M]=E<V?E:V,h[l+M+3]=B>N?B:N}return A}}}function Fe(o,e,t,i,s){let a,n,c,h,d,p;const r=1/t.direction.x,l=1/t.direction.y,u=1/t.direction.z,g=t.origin.x,y=t.origin.y,m=t.origin.z;let v=e[o],_=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],T=e[o+3+2];return r>=0?(a=(v-g)*r,n=(_-g)*r):(a=(_-g)*r,n=(v-g)*r),l>=0?(c=(x-y)*l,h=(w-y)*l):(c=(w-y)*l,h=(x-y)*l),a>h||c>n||((c>a||isNaN(a))&&(a=c),(h<n||isNaN(n))&&(n=h),u>=0?(d=(b-m)*u,p=(T-m)*u):(d=(T-m)*u,p=(b-m)*u),a>p||d>n)?!1:((d>a||a!==a)&&(a=d),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function El(o,e,t,i,s,a,n,c){const{geometry:h,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++){let l=d?d[p]:p;mi(h,e,t,l,a,n,c)}}function Bl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:h}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let u;u=mi(c,e,t,h?h[r]:r,null,a,n),u&&u.distance<d&&(p=u,d=u.distance)}return p}function kl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:h}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Z(n,l*3,h,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Ol(o,e,t,i,s,a,n){q.setBuffer(o._roots[e]),Xi(0,o,t,i,s,a,n),q.clearBuffer()}function Xi(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:h,uint32Array:d}=q,p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);Dl(e,t,i,l,u,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&Xi(l,e,t,i,s,a,n);const u=ae(o,d);Fe(u,c,i,a,n)&&Xi(u,e,t,i,s,a,n)}}const zl=["x","y","z"];function Vl(o,e,t,i,s,a){q.setBuffer(o._roots[e]);const n=Ji(0,o,t,i,s,a);return q.clearBuffer(),n}function Ji(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:h}=q;let d=o*2;if(ee(d,c)){const r=se(o,h),l=ne(d,c);return Ll(e,t,i,r,l,s,a)}else{const r=qr(o,h),l=zl[r],g=i.direction[l]>=0;let y,m;g?(y=oe(o),m=ae(o,h)):(y=ae(o,h),m=oe(o));const _=Fe(y,n,i,s,a)?Ji(y,e,t,i,s,a):null;if(_){const b=_.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return _}const w=Fe(m,n,i,s,a)?Ji(m,e,t,i,s,a):null;return _&&w?_.distance<=w.distance?_:w:_||w||null}}const Jt=new f.Box3,Xe=new fe,Je=new fe,Tt=new f.Matrix4,lr=new X,$t=new X;function Ul(o,e,t,i){q.setBuffer(o._roots[e]);const s=$i(0,o,t,i);return q.clearBuffer(),s}function $i(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=q;let h=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),lr.set(t.boundingBox.min,t.boundingBox.max,i),s=lr),ee(h,n)){const p=e.geometry,r=p.index,l=p.attributes.position,u=t.index,g=t.attributes.position,y=se(o,c),m=ne(h,n);if(Tt.copy(i).invert(),t.boundsTree)return Y(o,a,$t),$t.matrix.copy(Tt),$t.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>$t.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(i),_.b.applyMatrix4(i),_.c.applyMatrix4(i),_.needsUpdate=!0;for(let x=y*3,w=(m+y)*3;x<w;x+=3)if(Z(Je,x,r,l),Je.needsUpdate=!0,_.intersectsTriangle(Je))return!0;return!1}});for(let v=y*3,_=(m+y)*3;v<_;v+=3){Z(Xe,v,r,l),Xe.a.applyMatrix4(Tt),Xe.b.applyMatrix4(Tt),Xe.c.applyMatrix4(Tt),Xe.needsUpdate=!0;for(let x=0,w=u.count;x<w;x+=3)if(Z(Je,x,u,g),Je.needsUpdate=!0,Xe.intersectsTriangle(Je))return!0}}else{const p=o+8,r=c[o+6];return Y(p,a,Jt),!!(s.intersectsBox(Jt)&&$i(p,e,t,i,s)||(Y(r,a,Jt),s.intersectsBox(Jt)&&$i(r,e,t,i,s)))}}const ei=new f.Matrix4,Ei=new X,St=new X,Hl=new f.Vector3,Wl=new f.Vector3,Nl=new f.Vector3,Gl=new f.Vector3;function ql(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Ei.set(e.boundingBox.min,e.boundingBox.max,t),Ei.needsUpdate=!0;const c=o.geometry,h=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),u=le.getPrimitive();let g=Hl,y=Wl,m=null,v=null;s&&(m=Nl,v=Gl);let _=1/0,x=null,w=null;return ei.copy(t).invert(),St.matrix.copy(ei),o.shapecast({boundsTraverseOrder:b=>Ei.distanceToBox(b),intersectsBounds:(b,T,S)=>S<_&&S<n?(T&&(St.min.copy(b.min),St.max.copy(b.max),St.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>St.distanceToBox(I),intersectsBounds:(I,C,L)=>L<_&&L<n,intersectsRange:(I,C)=>{for(let L=I,R=I+C;L<R;L++){Z(u,3*L,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let A=b,M=b+T;A<M;A++){Z(l,3*A,d,h),l.needsUpdate=!0;const D=l.distanceToTriangle(u,g,m);if(D<_&&(y.copy(g),v&&v.copy(m),_=D,x=A,w=L),D<a)return!0}}}});{const S=mt(e);for(let I=0,C=S;I<C;I++){Z(u,3*I,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=b,R=b+T;L<R;L++){Z(l,3*L,d,h),l.needsUpdate=!0;const A=l.distanceToTriangle(u,g,m);if(A<_&&(y.copy(g),v&&v.copy(m),_=A,x=L,w=I),A<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(u),_===1/0?null:(i.point?i.point.copy(y):i.point=y.clone(),i.distance=_,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ei),y.applyMatrix4(ei),s.distance=y.sub(s.point).length(),s.faceIndex=w),i)}function jl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,h,d=0;const p=o._roots;for(let l=0,u=p.length;l<u;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),h=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,u,g=!1){const y=l*2;if(c[y+15]===pi){const v=n[l+6],_=c[y+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,I=-1/0;for(let C=v,L=v+_;C<L;C++){const R=3*o.resolveTriangleIndex(C);for(let A=0;A<3;A++){let M=R+A;M=i?i[M]:M;const D=s.getX(M),P=s.getY(M),E=s.getZ(M);D<x&&(x=D),D>T&&(T=D),P<w&&(w=P),P>S&&(S=P),E<b&&(b=E),E>I&&(I=E)}}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==S||h[l+5]!==I?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=S,h[l+5]=I,!0):!1}else{const v=l+8,_=n[l+6],x=v+u,w=_+u;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const I=b||T,C=b||S;let L=!1;I&&(L=r(v,u,b));let R=!1;C&&(R=r(_,u,b));const A=L||R;if(A)for(let M=0;M<3;M++){const D=v+M,P=_+M,E=h[D],B=h[D+3],V=h[P],N=h[P+3];h[l+M]=E<V?E:V,h[l+M+3]=B>N?B:N}return A}}}function Ql(o,e,t,i,s,a,n){q.setBuffer(o._roots[e]),es(0,o,t,i,s,a,n),q.clearBuffer()}function es(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:h,uint32Array:d}=q,p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);El(e,t,i,l,u,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&es(l,e,t,i,s,a,n);const u=ae(o,d);Fe(u,c,i,a,n)&&es(u,e,t,i,s,a,n)}}const Yl=["x","y","z"];function Zl(o,e,t,i,s,a){q.setBuffer(o._roots[e]);const n=ts(0,o,t,i,s,a);return q.clearBuffer(),n}function ts(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:h}=q;let d=o*2;if(ee(d,c)){const r=se(o,h),l=ne(d,c);return Bl(e,t,i,r,l,s,a)}else{const r=qr(o,h),l=Yl[r],g=i.direction[l]>=0;let y,m;g?(y=oe(o),m=ae(o,h)):(y=ae(o,h),m=oe(o));const _=Fe(y,n,i,s,a)?ts(y,e,t,i,s,a):null;if(_){const b=_.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return _}const w=Fe(m,n,i,s,a)?ts(m,e,t,i,s,a):null;return _&&w?_.distance<=w.distance?_:w:_||w||null}}const ti=new f.Box3,$e=new fe,et=new fe,Mt=new f.Matrix4,cr=new X,ii=new X;function Kl(o,e,t,i){q.setBuffer(o._roots[e]);const s=is(0,o,t,i);return q.clearBuffer(),s}function is(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=q;let h=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),cr.set(t.boundingBox.min,t.boundingBox.max,i),s=cr),ee(h,n)){const p=e.geometry,r=p.index,l=p.attributes.position,u=t.index,g=t.attributes.position,y=se(o,c),m=ne(h,n);if(Mt.copy(i).invert(),t.boundsTree)return Y(o,a,ii),ii.matrix.copy(Mt),ii.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>ii.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(i),_.b.applyMatrix4(i),_.c.applyMatrix4(i),_.needsUpdate=!0;for(let x=y,w=m+y;x<w;x++)if(Z(et,3*e.resolveTriangleIndex(x),r,l),et.needsUpdate=!0,_.intersectsTriangle(et))return!0;return!1}});for(let v=y,_=m+y;v<_;v++){const x=e.resolveTriangleIndex(v);Z($e,3*x,r,l),$e.a.applyMatrix4(Mt),$e.b.applyMatrix4(Mt),$e.c.applyMatrix4(Mt),$e.needsUpdate=!0;for(let w=0,b=u.count;w<b;w+=3)if(Z(et,w,u,g),et.needsUpdate=!0,$e.intersectsTriangle(et))return!0}}else{const p=o+8,r=c[o+6];return Y(p,a,ti),!!(s.intersectsBox(ti)&&is(p,e,t,i,s)||(Y(r,a,ti),s.intersectsBox(ti)&&is(r,e,t,i,s)))}}const si=new f.Matrix4,Bi=new X,Ct=new X,Xl=new f.Vector3,Jl=new f.Vector3,$l=new f.Vector3,ec=new f.Vector3;function tc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Bi.set(e.boundingBox.min,e.boundingBox.max,t),Bi.needsUpdate=!0;const c=o.geometry,h=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),u=le.getPrimitive();let g=Xl,y=Jl,m=null,v=null;s&&(m=$l,v=ec);let _=1/0,x=null,w=null;return si.copy(t).invert(),Ct.matrix.copy(si),o.shapecast({boundsTraverseOrder:b=>Bi.distanceToBox(b),intersectsBounds:(b,T,S)=>S<_&&S<n?(T&&(Ct.min.copy(b.min),Ct.max.copy(b.max),Ct.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:I=>Ct.distanceToBox(I),intersectsBounds:(I,C,L)=>L<_&&L<n,intersectsRange:(I,C)=>{for(let L=I,R=I+C;L<R;L++){const A=S.resolveTriangleIndex(L);Z(u,3*A,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let M=b,D=b+T;M<D;M++){const P=o.resolveTriangleIndex(M);Z(l,3*P,d,h),l.needsUpdate=!0;const E=l.distanceToTriangle(u,g,m);if(E<_&&(y.copy(g),v&&v.copy(m),_=E,x=M,w=L),E<a)return!0}}}})}else{const S=mt(e);for(let I=0,C=S;I<C;I++){Z(u,3*I,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=b,R=b+T;L<R;L++){const A=o.resolveTriangleIndex(L);Z(l,3*A,d,h),l.needsUpdate=!0;const M=l.distanceToTriangle(u,g,m);if(M<_&&(y.copy(g),v&&v.copy(m),_=M,x=L,w=I),M<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(u),_===1/0?null:(i.point?i.point.copy(y):i.point=y.clone(),i.distance=_,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(si),y.applyMatrix4(si),s.distance=y.sub(s.point).length(),s.faceIndex=w),i)}function ic(){return typeof SharedArrayBuffer<"u"}const Ft=new q.constructor,hi=new q.constructor,Re=new ps(()=>new f.Box3),it=new f.Box3,st=new f.Box3,ki=new f.Box3,Oi=new f.Box3;let zi=!1;function sc(o,e,t,i){if(zi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");zi=!0;const s=o._roots,a=e._roots;let n,c=0,h=0;const d=new f.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Ft.setBuffer(s[p]),h=0;const l=Re.getPrimitive();Y(0,Ft.float32Array,l),l.applyMatrix4(d);for(let u=0,g=a.length;u<g&&(hi.setBuffer(a[p]),n=ue(0,0,t,d,i,c,h,0,0,l),hi.clearBuffer(),h+=a[u].length,!n);u++);if(Re.releasePrimitive(l),Ft.clearBuffer(),c+=s[p].length,n)break}return zi=!1,n}function ue(o,e,t,i,s,a=0,n=0,c=0,h=0,d=null,p=!1){let r,l;p?(r=hi,l=Ft):(r=Ft,l=hi);const u=r.float32Array,g=r.uint32Array,y=r.uint16Array,m=l.float32Array,v=l.uint32Array,_=l.uint16Array,x=o*2,w=e*2,b=ee(x,y),T=ee(w,_);let S=!1;if(T&&b)p?S=s(se(e,v),ne(e*2,_),se(o,g),ne(o*2,y),h,n+e,c,a+o):S=s(se(o,g),ne(o*2,y),se(e,v),ne(e*2,_),c,a+o,h,n+e);else if(T){const I=Re.getPrimitive();Y(e,m,I),I.applyMatrix4(t);const C=oe(o),L=ae(o,g);Y(C,u,it),Y(L,u,st);const R=I.intersectsBox(it),A=I.intersectsBox(st);S=R&&ue(e,C,i,t,s,n,a,h,c+1,I,!p)||A&&ue(e,L,i,t,s,n,a,h,c+1,I,!p),Re.releasePrimitive(I)}else{const I=oe(e),C=ae(e,v);Y(I,m,ki),Y(C,m,Oi);const L=d.intersectsBox(ki),R=d.intersectsBox(Oi);if(L&&R)S=ue(o,I,t,i,s,a,n,c,h+1,d,p)||ue(o,C,t,i,s,a,n,c,h+1,d,p);else if(L)if(b)S=ue(o,I,t,i,s,a,n,c,h+1,d,p);else{const A=Re.getPrimitive();A.copy(ki).applyMatrix4(t);const M=oe(o),D=ae(o,g);Y(M,u,it),Y(D,u,st);const P=A.intersectsBox(it),E=A.intersectsBox(st);S=P&&ue(I,M,i,t,s,n,a,h,c+1,A,!p)||E&&ue(I,D,i,t,s,n,a,h,c+1,A,!p),Re.releasePrimitive(A)}else if(R)if(b)S=ue(o,C,t,i,s,a,n,c,h+1,d,p);else{const A=Re.getPrimitive();A.copy(Oi).applyMatrix4(t);const M=oe(o),D=ae(o,g);Y(M,u,it),Y(D,u,st);const P=A.intersectsBox(it),E=A.intersectsBox(st);S=P&&ue(C,M,i,t,s,n,a,h,c+1,A,!p)||E&&ue(C,D,i,t,s,n,a,h,c+1,A,!p),Re.releasePrimitive(A)}}return S}const ri=new X,hr=new f.Box3,rc={strategy:Wr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,n=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:n?n.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:n?n.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:n}=e,c=new ms(t,{...i,[Ii]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const h=t.getIndex();if(h===null){const d=new f.BufferAttribute(e.index,1,!1);t.setIndex(d)}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({...rc,[Ii]:!1},t),t.useSharedArrayBuffer&&!ic())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ii]||(xl(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?jl:Fl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,h=0){const d=c*2,p=a[d+15]===pi;if(p){const r=s[c+6],l=a[d+14];e(h,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],u=s[c+7];e(h,p,new Float32Array(i,c*4,6),u)||(n(r,h+1),n(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],h=t.isMaterial,d=Array.isArray(t),p=n.groups,r=h?t.side:t,l=this.indirect?Ql:Ol;for(let u=0,g=a.length;u<g;u++){const y=d?t[p[u].materialIndex].side:r,m=c.length;if(l(this,u,y,e,c,i,s),d){const v=p[u].materialIndex;for(let _=m,x=c.length;_<x;_++)c[_].face.materialIndex=v}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,h=Array.isArray(t);let d=null;const p=n.groups,r=c?t.side:t,l=this.indirect?Zl:Vl;for(let u=0,g=a.length;u<g;u++){const y=h?t[p[u].materialIndex].side:r,m=l(this,u,y,e,i,s);m!=null&&(d==null||m.distance<d.distance)&&(d=m,h&&(m.face.materialIndex=p[u].materialIndex))}return d}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?Kl:Ul;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=le.getPrimitive(),i=this.indirect?kl:Pl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,u,g,y,m)=>r(l,u,g,y,m)?!0:i(l,u,this,c,g,y,t)}else n||(c?n=(r,l,u,g)=>i(r,l,this,c,u,g,t):n=(r,l,u)=>u);let h=!1,d=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const u=p[r];if(h=Ml(this,r,a,n,s,d),h)break;d+=u.byteLength}return le.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=le.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,d=this.indirect?g=>{const y=this.resolveTriangleIndex(g);Z(n,y*3,c,h)}:g=>{Z(n,g*3,c,h)},p=le.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,u=e.indirect?g=>{const y=e.resolveTriangleIndex(g);Z(p,y*3,r,l)}:g=>{Z(p,g*3,r,l)};if(a){const g=(y,m,v,_,x,w,b,T)=>{for(let S=v,I=v+_;S<I;S++){u(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=y,L=y+m;C<L;C++)if(d(C),n.needsUpdate=!0,a(n,p,C,S,x,w,b,T))return!0}return!1};if(s){const y=s;s=function(m,v,_,x,w,b,T,S){return y(m,v,_,x,w,b,T,S)?!0:g(m,v,_,x,w,b,T,S)}}else s=g}return sc(this,e,t,s)}intersectsBox(e,t){return ri.set(e.min,e.max,t),ri.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ri.intersectsBox(i),intersectsTriangle:i=>ri.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,n=1/0){return(this.indirect?tc:ql)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return Cl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Y(0,new Float32Array(i),hr),e.union(hr)}),e}}class nc{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 oc extends nc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=d=>{a(new Error(`GenerateMeshBVHWorker: ${d.message}`))},e.onmessage=d=>{const{data:p}=d;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,u=ms.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const y=new f.BufferAttribute(r.index,1,!1);t.setIndex(y)}g.setBoundingBox&&(t.boundingBox=u.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(u),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];n&&h.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(d=>d.buffer).filter(d=>typeof SharedArrayBuffer>"u"||!(d instanceof SharedArrayBuffer)))})}}class ac{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 pt,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,a)=>s.position.z>a.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 a=this.domElement.width/this.domElement.clientWidth,n=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-h)*n,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 a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==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 a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const n=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(n),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+n):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-n):a.setZ(this.orbit.target.z);const c=500,h=performance.now(),d=1,p=this.selectedAxis.axis,r=()=>{const u=performance.now()-h,g=Math.min(u/c,d);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==d){this._animator=window.requestAnimationFrame(r);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),r()},this.drawCircle=(s,a=10,n="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=n,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,n=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=n,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(a=>{const n=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,n?"#0066ff":c),a.label){const h=a.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(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),n=s.size;s.position.set(a.x*(this.center.x-n/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-n/2-this.options.padding),a.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 a=i.getAttribute("data-function");a&&this.dispatchEvent(new CustomEvent("function-removed",{detail:a}));break}case"toggle-dialog":if(!this.hasMoreFunctions)return;this._showDialog=!this._showDialog,this.scheduleRender();break;case"add-function":{const a=i.getAttribute("data-function");a&&(this.dispatchEvent(new CustomEvent("function-added",{detail:a})),this._showDialog=!1,this.scheduleRender());break}}}}customElements.get("slot-item")||customElements.define("slot-item",Vr);const K={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 ji extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new pt,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),this._showSlot=typeof e.show=="boolean"?e.show:!0,this.name=e.name,this._isMirror=e.isMirror,this._slotUI=new Vr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(K.ON_DEVICE_DELETED)}}),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(K.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 a;if(i.preventDefault(),i.stopPropagation(),!this._canInstall)return;const s=(a=i.dataTransfer)==null?void 0:a.getData("application/json");if(s){const n=JSON.parse(s);try{await this.install(n),this._emitter.emit(K.ON_DROP,this)}catch(c){this._emitter.emit(K.ON_DROP_ERROR,c)}}else this._emitter.emit(K.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 a=i.initPos[s]>0?1:-1;this._wrapper.position[s]=(t-i.origin)*i.scale*a}}}async loadGlb(e){const i=await new Et({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new Et({useCache:!0}).loadAsync(e);if(!i.glb)return;const s=i.glb.clone(!0);s.traverse(a=>{a.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(),this._emitter.emit(K.ON_DEVICE_REPLACED),s.traverse(a=>{a.name.startsWith("Slot")&&this._bracketSlots.push(a),a.userData.isBracket=!0}),this._slotContainer.add(s);else throw new Error(`Fail to load bracket from: ${e.bracketUrl}`);this._bracketSlots.forEach(a=>{a.add(i)})}else this.clearSlot(),this._emitter.emit(K.ON_DEVICE_REPLACED),this._slotContainer.add(i);this.mirrorTarget&&this.mirrorTarget.install(e),this.deviceInfo=e,this._slotUI.deviceLogo=e.logo||"",this._slotUI.deviceName=e.name,this._slotUI.filled=!0,this.holeTarget&&(this.holeTarget.visible=!1)}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(K.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(K.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._bracketSlots=[],this._slotContainer.children.forEach(e=>{e.removeFromParent(),ge(e)}),this._slotUI.filled=!1,this.deviceInfo=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(K.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(K.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(K.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(K.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(),ge(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])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,h=30;if(this._canInstall&&(n=34,c=60,h=60),a<h){let d=(h-a)*1+n;a<20&&(d=c),d>c&&(d=c),this._slotUI.setSize(d)}else this._slotUI.setSize(n)}clone(e){return new f.Group}}class Za extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=us(),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 a="6px",n=document.createElement("div");n.style.pointerEvents="none",Object.assign(n.style,{pointerEvents:"none",borderLeft:`1px solid ${s}`,borderRight:`1px solid ${s}`,position:"absolute",left:"0",top:"0",boxSizing:"border-box",height:a,width:"100%"}),this.element.append(n);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:a,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;n.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;n.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 oi 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 Za(""),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 u,g;(u=this._line.geometry)==null||u.dispose(),this._line.geometry=new f.BufferGeometry().setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new f.Vector3().subVectors(t,e).normalize();let n;Math.abs(a.z)>Math.abs(a.x)&&Math.abs(a.z)>Math.abs(a.y)?n=new f.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new f.Vector3(1,0,0):n=new f.Vector3(0,1,0)),n.normalize();const c=new f.Vector3().addVectors(e,n.clone().multiplyScalar(s)),h=new f.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),d=new f.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new f.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new f.BufferGeometry,this._line2.geometry.setFromPoints([c,h,d,p]),this._line2.computeLineDistances();const r=e.distanceTo(t);this._startWith?this._text.text=`${this._startWith}${(r*1e3).toFixed(0)} mm`:this._text.text=`${(r*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=>ge(e)),this.removeFromParent()}}class Ur extends f.Object3D{constructor(e,t){super(),this.radius=e,this._text=new Ka(""),this._line=new oi(void 0,!1,!1),this._box=new f.Mesh,this._arc=new pn.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 ws.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new mn.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),a=s+this._accumulatedAngle;let n=.006*this.radius;n<.003&&(n=.003),n>.006&&(n=.006);const c=this._createArcGeometry(s,a,this.radius+n);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=[],a=t-e,n=Math.max(128,Math.floor(Math.abs(a)/(Math.PI/128))),c=a/n;for(let d=0;d<=n;d++){const p=e+d*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const h=new ws.LineGeometry;return h.setPositions(s),h.instanceCount=Math.max(0,s.length/3-1),h}}class Ka extends me.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=us();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 Xa="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",Ja="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",Xs="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGwAAABsCAYAAACPZlfNAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAdzSURBVHic7Z3hlZs6EIUvW4E7CB3EHcQdxB08OngugVTg8yrwSQVOKnBSwW4qsFOB3cF9PxhZQsYYjEAS1neOD7ssCwPXMxoNIGWIDJJLAAsASwCfAOTyey6bLOQDABf5qJ9P8vkry48sy05j2+ySzLcBjyC5QiXOV1kuWv+hPxcAvwD8BvCBSsRL6394JDjBSC4ArFEJtG7Y5ILqwp4A/JHlxfyoC04yN/4vh/bEz9Dim9uY+/8O4EfI4nmFZEFyz1veSe5Iri0BXB13Icfekjxaxz6TPMixXXt2fJDM5WLZF+og63MPNi1IbsQGW7zyJYUToXZyEUxP8iLSPUS80hLvdYQTobbWN3fHKvMLGpKrBq/bzla4htC3C8mbutIg3JnkxrddzhCvil4omwbhDqy6IPEisV5xJFn4tsk1rDJI8wtZ+rapN+JV73PzqnuwSk7MtvkQzflabdUxGsMdIGFSnfuZZFPHPxysELjnXDOoFsTbzAJA6dumRiyxSt/2+Ma6Hlvf9lyRb9QumjAwIZKQqOLAznvEEbFUcvFS7VVXWO/WvHsTLYnVnSBEM8JgEqsDlmi7qQ++TWL1xxKtnOqgKvs5J7H6I6KdJxFNsh5FygafxLqOxVgHme6b8QIYkWqcZoW6Mr13vvMXhboi8u56x+a34eXKTWMhXSO3SQirgqZi5WSniSvS1ChyFztUoTCcetjMoNGnHbqjTQqF42P1z4pnd7IwssKUwo8Mq/uIz2eN1NWMg3vzxoUWvu3pihEa+zU/4l3RJhoRC/ZcAkKdxkfnXUC8ggE1L+tWILbartW45o1D5IIpL+tWq43du4C4BQNqXlY82jB67wJmIdhSTG/vl1FXkaP1LiB+wQCA+m5+Ya5/s7b7V5a/J7Eq0cZ/svza+FcrHEZd1ZiJh5kp/q0e1D3tqMMhMA/BgFodt1DrzJD4jyx/TmpVoo3vsqyHxTmFQ2BWHpY3ngP1Pa9h5f1AmItgQC1bXAE6JKpXVn94sSrRxocsl4AW7Iss/0xuTuIRKqfQ7dic2i9gdiHxWlu0V8yi/QLmJRhQc6jlG3T7lYboCRfVji3eoMda+mjeNhEAJ1ku31ANYQekhCNklDafTA87eTEl0YWTLHNTsNSGhYvSZvEGPWDkyY8t1xt2ua/jd0Uyah/jYinBcvt+2OTIBTgAOHi6GJ3wbKeOfkaOn09sRNM4VGcXF8N1P0wiwNmyMx+63x7HV48dnuHqpJ40ZMNbBovmUrAGsRSTjuB2PRefgokhZcPFGCSaK8FaxCqf3ecAW66Cea8juhbNhWCBiaXridRtSD61IZZRzkQbKlhIYok9ut5rCOY9Q3Ml2hDBQhNLbKoJdpBfVr4MMnEh2rOChSiW2KWeCHg3X4wO5h2woaI9I1ioYolt6gHf/RuMOpU/k+pkWVYC+GatXmCkTit1p9hOvL6JLb7JZXky+0LTjn/UgWc9rY+HhexZCuqXIzZmfAzyAdJnROsqWAxiAbUnp9bmmxJn34bdo69oXQSLRSwAt10veqwndqVFtKJh21bBWD2WHotYuo5orDzIymAyxSbuiEZbtDbBqN8hCF4soGbv3lwZbOJh00W0e4LFJhZQG81hY67UHbMIeCRak2AxigXU2q+V/QdF7sWynrSJ1nFdDGJd2y/axXnqikfhx7z+tIjWhdK3/Y+gbqpuu1yM9IU+Nt8EfUQU00ex4YU+84/m6Df55NYNgPdDXhOFb3u7wLZwaGwUXVhUdBSt8G1nV9hlvBTjpKPIFm0eiFb4tq8P7No3ZkA3NJ/hjmiFb7v6QN3Nuh8OjY3VCQffib6HJVrh256+GN5Vdtk4ZwS1xUeIaIVvO/rSy7uMf9rF7mWx0su7jH9SD31E7WWxwfoI5v0eO6QuOiYvmwgOGcGcLkZ6TnSG+kGb7m1Xw05UtnVMoXE8WJ8hYljZjL4mKXsh6HIE85SAjAvHmCqFabKcUeAYk+UYO1ePWqXpqBxBXWx3f0vLyhpL5wd4MYyoNd7bnKzX6IJ+wipkOOXUlJN8M2YMfUxNaSUh+SQHnQFWszLtfGxME2/3whJr+j4t09T2nbHE8jO1vRiSRHtAMGIZBi2M8HhO2aNGskGVYOy8i2VCXQ+bLvsJGNYfci1929OIZeQ+qG/UREjE2QcvlsIKA0cGMjrBFFjt1ZGx3EcUww/Gt2w7Z2+T890Z5/seZQJmhcjjHBMSVuW6o3GepW+bBsHqfo/pbYc5hMkGrzpG6VX3YPWWyTl24e4IVfi2axRYZVBm+h+NcKxGHdhZtm9n5VX3EOHKBo8rGVByIt5UUFdzKDbvXkIomzvCKfE2PsQzRDpYNh1lfT61TcEhwq3lItniHSX0FGMIKAKtxWveecueAbVRmW8DbESUNaopHpe4HbDrhGqU6Q9UMyao309qgyzLTsa+7E8O4LMsm/YPVPOo/QTwI8uyoMbzD04wE7ngS/l8AbBC8wUeghL/J4CPLMt+Od6/U4IWrAlpQ5aoPOSTLHNoIRfGzxfoMd9P0J74F5VIlyzLopok6H/tVqA8kSYfTwAAAABJRU5ErkJggg==",$a="data:image/png;base64,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";class Js extends me.CSS2DObject{constructor(e,t){const i=document.createElement("div");super(i),this.props=e,this.amr=t,this._direction=1,this._controllingRotate=!1,this._controlling=!1,this._startAt=0,this._looper=0,this._initial=0,this._canRotate=!1,this._emitter=new pt,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 c=(Date.now()-this._startAt)/200;c>4&&(c=4);let h=this._initial+.005*c*this._direction;if(h>this.props.max||h<this.props.min){this.mechanism&&(h<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):h>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=h,!this.mechanism)return;this.mechanism.position.setZ(h),this._emitter.emit("change",h)}};const s=us();e.userData&&e.userData.target&&(this.name=e.userData.target.name,t.traverse(c=>{c.name===e.userData.target.name&&(this.mechanism=c)})),i.style.fontSize="30px",i.style.color="#0066FF",i.style.cursor="pointer",i.style.pointerEvents="auto";const a=document.createElement("div");a.style.position="absolute",a.style.left="0",a.style.transform="translateX(-50%) rotate(-180deg)",a.style.marginBottom="5px",a.style.width=a.style.height=s?"34px":"44px",a.style.background=`url(${Xs}) center no-repeat`,a.style.backgroundSize="100% auto",a.setAttribute("data-direction","up"),a.style.transition="all .2s";const n=document.createElement("div");if(n.style.position="absolute",n.style.left="0",n.style.transform="translateX(-50%)",a.style.bottom=n.style.top="8px",n.style.width=n.style.height=a.style.width,n.style.background=`url(${Xs}) center no-repeat`,n.style.backgroundSize="100% auto",n.style.transition="all .2s",n.setAttribute("data-direction","down"),Array.from([a,n]).forEach(c=>{s||c.addEventListener("mousemove",()=>{c.style.filter="invert(100%)"}),c.addEventListener("mouseleave",()=>{c.style.filter=""}),c.addEventListener("pointerdown",()=>{this.mechanism&&(c.style.filter="invert(100%)",this._controlling=!0,this._startAt=Date.now(),this._initial=this.mechanism.position.z,this._direction=c.getAttribute("data-direction")==="up"?1:-1,this._update())}),c.addEventListener("pointerup",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""}),c.addEventListener("pointerleave",()=>{this._controlling=!1,cancelAnimationFrame(this._looper),c.style.filter=""})}),e.userData&&(this._canRotate=e.userData.canRotate,this._canRotate)){const{rotateTarget:c,rotateDuration:h,rotateStep:d,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(u=>{u.name===c.name&&(l=u)}),l)){const u=document.createElement("div");u.style.background=`url(${$a}) center no-repeat`,u.style.backgroundSize="100% auto",u.style.position="absolute",u.style.top="-50%",u.style.left="-50%",u.style.width=s?"140px":"160px",u.style.height=s?"70px":"80px",u.style.transform="translateX(-50%) translateY(-50%)",i.append(u);const g=document.createElement("div");g.style.background=`url(${Ja}) center no-repeat`,g.style.backgroundSize="100% auto",g.style.width=g.style.height=s?"20px":"26px",g.style.position="absolute",g.style.top="0",g.style.transform="translateY(-50%)",g.style.marginBottom="5px",g.setAttribute("data-direction","left"),i.append(g);const y=document.createElement("div");y.style.background=`url(${Xa}) center no-repeat`,y.style.backgroundSize="100% auto",y.style.width=y.style.height=s?"20px":"26px",y.style.position="absolute",g.style.left=y.style.right=s?"62px":"69px",y.style.top="0",y.style.transform="translateY(-50%)",y.style.marginBottom="5px",y.setAttribute("data-direction","right"),i.append(y),Array.from([g,y]).forEach(m=>{s||m.addEventListener("mousemove",()=>{m.style.filter="invert(100%)"}),m.addEventListener("mouseleave",()=>{m.style.filter=""}),m.addEventListener("pointerdown",()=>{if(this._timer&&this._timer.isPlaying())return;m.style.filter="invert(100%)",this._controllingRotate=!0,this._startAt=Date.now(),this._direction=m.getAttribute("data-direction")==="left"?1:-1;let v=d/180*Math.PI*this._direction+l.rotation.z;v>p/180*Math.PI?v=p/180*Math.PI:v<r/180*Math.PI&&(v=r/180*Math.PI),this._timer=new ci(l.rotation).to({z:v}).duration(h).start(),this._update()}),m.addEventListener("pointerup",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""}),m.addEventListener("pointerleave",()=>{this._controllingRotate=!1,cancelAnimationFrame(this._looper),m.style.filter=""})})}}i.append(a,n),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 me.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof me.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class el extends gn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new pt,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:d,pageY:p}=h;this.endNode.setPointerCapture(h.pointerId),this._mouseStart.set(d,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:d,pageY:p}=h;let r=d-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const u=l%10;l=l-u,r=(l-this._targetSize.x)*this._direction,this._sizeFlag==="height"&&(r=(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,a=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 n=document.createElement("div");n.style.position="absolute",n.style.left="0",n.style.bottom="0",t.append(n),this._textNode=document.createElement("div"),this._textNode.innerText=a.toFixed(2)+" m",n.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",n.append(c),this.scale.set(this._scale,this._scale,this._scale),t.style.fontSize="6px",t.style.color="#fff",n.style[this._sizeFlag]=a*100+"px",n.style.textAlign="center",this._sizeFlag==="height"?(n.style.borderLeft="0.1px dashed #fff",n.style.display="flex",n.style.alignItems="center",n.style.justifyContent="center",n.style.whiteSpace="nowrap",c.style.top="0",c.style.left="0",c.style.right="auto",c.style.margin="-2px 0 0 -2px"):n.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 tl extends f.Object3D{constructor(){super(),this._box3=new f.Box3,this._line11=new oi("长:"),this._line12=new oi("宽:"),this._line13=new oi("高:"),this._outline=new Ur(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 me.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 me.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:a,hasHeight:n,hasWidth:c}=Va(t);this.tail=Math.abs(i.min.x),this.head=Math.abs(i.max.x),this._hasWidthConfig=c,this._hasLengthConfig=a,this._hasHeightConfig=n,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,d=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,u=this._box3.max.y;let g=.2;const y=new f.Vector3(h,u,0),m=new f.Vector3(d,u,0);this._line11.update(y.clone().sub(new f.Vector3(0,-g/1.8,0)),m.clone().sub(new f.Vector3(0,-g/1.8,0)),this._radius);const v=new f.Vector3(d,l,0);this._line12.update(m.clone().add(new f.Vector3(g,0,0)),v.clone().add(new f.Vector3(g,0,0)),this._radius);const _=new f.Vector3(h,u,p),x=new f.Vector3(h,u,r),w=_.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class Ve 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 e,t;this.clear(),(e=this.lineSegments)==null||e.geometry.dispose(),this._lineMaterial.dispose(),(t=this.lineSegments)==null||t.removeFromParent()}clearAll(){this.dispose()}clone(e){const t=new Ve(this._currentLength,this._currentWidth,this._currentHeight);return t.position.copy(this.position),t.rotation.copy(this.rotation),t.scale.copy(this.scale),t.visible=this.visible,t.castShadow=this.castShadow,t.receiveShadow=this.receiveShadow,e&&this.children.forEach(i=>{if(i!==this.lineSegments){const s=i.clone(!0);t.add(s)}}),t}_generate(e,t,i){ge(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 il="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Qi{constructor(e){this._props=e,this.name="",this.transparentTexture=fs.load(il),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 a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var d;let n=window.devicePixelRatio*2;this._offscreen.width=a.width+n,this._offscreen.height=a.height+n;const c=this._offscreen.getContext("2d");c==null||c.clearRect(0,0,this._offscreen.width,this._offscreen.height),c==null||c.drawImage(a,n/2,n/2,a.width,a.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&&((d=h.material.map)==null||d.dispose(),s?(h.material.map=s,h.material.opacity=1):(h.material.map=this.transparentTexture,h.material.opacity=0))}}else{const a=this._props.target;a.material&&(a.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 $s(o){return o.type?o.type==="Mesh":o.isMesh}const fs=new f.TextureLoader;fs.crossOrigin="anonymous";class Hr extends f.Object3D{constructor(e){super(),this._props=e,this._emitter=new pt,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 tl,this._goodsSize=new Ha(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],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._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._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 ji&&!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+.14-.54;this.setShapeKey("boxLength",s);const a=i+.14;if(this.setShapeKey("topWidth",a),this.isTopInvert){const n=i-.257;this.setShapeKey("length",n)}else this.setShapeKey("width",a);this._generateRollers()}if(t==="goodsWidth"){const s=i+.193;this.setShapeKey("boxWidth",s);const a=i+.219;if(this.setShapeKey("topLength",a),this.isTopInvert){const n=i+.62;this.setShapeKey("width",n)}else this.setShapeKey("length",a)}})}_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 He.loadAsync(e);i=h.animations||[],s=h.scene}else if(t==="sglb"||e.endsWith(".sglb")){const d=await new Et({useCache:!0}).loadAsync(e);i=d.animations||[],s=d.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 a=this._findFirstSkinnedMesh(s),n=this._findFirstSkinnedMesh(this._modelRoot);(!a||!n)&&console.warn("[Amr.loadAnimation] 在动画或目标模型中未找到 SkinnedMesh,使用原始动画 clip",e),this._mixer||(this._mixer=new f.AnimationMixer(this._modelRoot));const c=typeof _i.retargetClip=="function";i.forEach(h=>{let d=h;if(c&&a&&n)try{d=_i.retargetClip(n,a,h)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",h.name,r)}this._clips=this._clips.filter(r=>r.name!==d.name),this._clips.push(d);const p=this._mixer.clipAction(d);this._actionsMap.set(d.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 n=await He.loadAsync(e);i=n.scene,s=n.animations||[]}else{const c=await new Et({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=_i.clone(i);this._generateAmr(a,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(a=>{var h;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(h=a.morphTargetDictionary)==null?void 0:h[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof f.Mesh&&a.geometry.translate(0,0,1e-9)}),i&&this._emitter.emit("shape-key-changed",e,t)},0)}_generateAmr(e,t){this._modelRoot=e,this._actionsMap.clear(),this.actions=[],this._clips=[],t&&t.length&&(this._mixer=new f.AnimationMixer(e),this._clips=t,t.forEach(i=>{const s=this._mixer.clipAction(i);this._actionsMap.set(i.name,s)}),this.actions=t.map(i=>i.name)),this._shapeKeyTargets.clear(),this._shapeKeys.clear(),e.traverse(i=>{if(i.userData.isShelf&&(this._shelf=i),i.userData.isFork&&(this._fork=i),i.userData.isMast&&i.userData.mastLevel&&this._masts.set(i.userData.mastLevel,i),i.userData.isJack&&(this._jack=i),i.userData.isLift&&(this._lift=i),i.userData.isRollerLevel&&this._rollerLevel.set(i.userData.level||0,i),i.userData.isCenterModel&&(i.visible=this.useCenterModel),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&(this._liftBrackets.push(i),i.visible=this._useLift),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!this._useLift),i.userData.isRoller&&(this._roller=i,this._roller.visible=!1,this._generateRollers()),i.userData.isRollerLevelBox){this._rollerGoodsBox=i;const s=new Ve(this._goodsSize.width,this._goodsSize.length,this._goodsSize.height);i.add(s),this.goods.push(s)}Object.keys(i.morphTargetDictionary||{}).forEach(s=>{let a=i.morphTargetInfluences[i.morphTargetDictionary[s]];i.userData[`origin_${s}`]&&(a+=i.userData[`origin_${s}`]),this._shapeKeys.has(s)||this._shapeKeys.set(s,a);const n=this._shapeKeyTargets.get(s);n?n.push(i):this._shapeKeyTargets.set(s,[i])})}),e.traverse(i=>{if(i instanceof f.Mesh){if(i.castShadow=!0,i.receiveShadow=!0,i.material)if(Array.isArray(i.material))i.material.forEach(a=>{a.userData.changeColor&&(this.skins.find(n=>n.name===a.userData.name)||this.skins.push(new ss({name:a.userData.name,target:a})))});else{if(i.material.userData.isVideo&&i.material.userData.video){const a=i.material.userData.video;let n=this._videoCache.get(a);n||(n=document.createElement("video"),n.src=a,n.crossOrigin="anonymous",n.loop=!0,n.muted=!0,n.playsInline=!0,n.autoplay=!0,n.preload="auto",this._videoCache.set(a,n)),n.play().catch(()=>{}),i.material.map&&i.material.map.dispose(),i.material.emissiveMap&&i.material.emissiveMap.dispose();const c=new f.VideoTexture(n);c.colorSpace=f.SRGBColorSpace,i.material.map=c,i.material.emissiveMap=c,i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=1,i.material.needsUpdate=!0}if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new f.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Le.Tween(i.material).to({emissiveIntensity:.2}).easing(Le.Easing.Quintic.InOut).duration(a),c=new Le.Tween(i.material).to({emissiveIntensity:2}).easing(Le.Easing.Quintic.InOut).duration(a);n.onComplete(()=>c.start()),c.onComplete(()=>n.start()),n.start(),this._breathLights.push(n,c)}i.material.userData.changeColor&&(this.skins.find(a=>a.name===i.material.userData.name)||this.skins.push(new ss({name:i.material.userData.name,target:i.material})))}if(i.material)if(Array.isArray(i.material))i.material.forEach(n=>{if(n.userData.isLOGO){i.material.transparent=!0;let c;const h={width:0,height:0};i.material.map&&i.material.map.image&&(h.width=i.material.map.image.width,h.height=i.material.map.image.height,c=qi(i.material.map.image)),i.material.needsUpdate=!0;const d=new Qi({name:n.userData.name,target:i,size:Qs(i),imageSize:h,imageUrl:c});this._logos.push(d)}n.userData.isTransparent&&(n.transparent=!0),this._materialsCache.set(n.uuid,{opacity:n.opacity,transparent:n.transparent,roughness:n.roughness,metalness:n.metalness,color:n.color,mat:n})});else{const a=i.material;if(a.userData.isLOGO){i.material.transparent=!0;let n;const c={width:0,height:0};i.material.map&&i.material.map.image&&(c.width=i.material.map.image.width,c.height=i.material.map.image.height,n=qi(i.material.map.image));const h=new Qi({name:a.userData.name,target:i,size:Qs(i),imageSize:c,imageUrl:n});this._logos.push(h)}a.userData.isTransparent&&(a.transparent=!0),this._materialsCache.set(a.uuid,{opacity:a.opacity,transparent:a.transparent,roughness:a.roughness,metalness:a.metalness,color:a.color,mat:a})}}this.generateController(i,e),this.generateDimension(i,e);const s=this.generateSlot(i,e);s&&this._slots.push(s),i.userData.isOrigin&&Object.keys(i.userData).forEach(n=>{if(n.startsWith("follow_")){const c=n.replace("follow_","");this.shapeKeys.has(c)&&(this.sizeBox.follow=c,this.sizeBox.followOrigin=this._shapeKeys.get(c)||0,this.sizeBox.followScale=i.userData[n])}})}),this.slots.forEach(i=>{i.props.mirrorTarget&&(i.mirrorTarget=this.slots.find(s=>s.props.slot.name===i.props.mirrorTarget))}),e.updateMatrixWorld(!0),this._container.add(e),this.sizeBox.generate(e),this.sizeBox.show()}setHeight(e){this.setShapeKey("height",e)}setWeight(e){this.setShapeKey("width",e)}setLength(e){this.setShapeKey("length",e)}limitValue(e){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=>{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(a=>{a.name.toLowerCase().includes("lift")&&(a.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=>{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 Ve&&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.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}setColumns(e){this._columnCount=e,this._rollerLevel.forEach(t=>{const i=t.children.find(d=>d.userData.isRollerLevelBox&&!d.userData.cloned);if(!i)return;console.log(i);const s=new f.Box3().setFromObject(i),a=new f.Vector3;s.getSize(a);const n=.03,c=a.x;console.log(a);const h=c*e+n*(e-1)-c;for(let d=1;d<e;d++){const p=i.clone(!0);p.userData.cloned=!0,p.position.x+=(n+c)/2,t.add(p)}i.position.x-=h/2})}get levels(){return this._levelCount}setLevels(e){var a;if(!e)return;this._levelCount=e;const t=this._rollerLevel.size;let i=e-t;const s=this._rollerLevel.get(0);if(i>0&&s)for(let n=t;n<e;n++){const c=s.clone(!0);c.visible=!0,c.position.z+=.2,this._rollerLevel.set(n,c),(a=s.parent)==null||a.add(c),this.regenerateShapeKeyNode(c),c.traverse(h=>{h instanceof Ve&&this.goods.push(h)}),this.setGoodsSize({length:this.goodsSize.length,width:this.goodsSize.width,height:this.goodsSize.height})}else for(let n=0;n<t;n++){const c=this._rollerLevel.get(n);c&&(c.visible=n<e)}}regenerateShapeKeyNode(e){e&&e.traverse(t=>{$s(t)&&Object.keys(t.morphTargetDictionary||{}).forEach(i=>{const s=this._shapeKeyTargets.get(i);t.userData.cloned=!0,s&&s.push(t)})})}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){if(!this._roller)return;let e=[];this._rollerLevel.forEach(p=>{p.traverse(r=>{r.userData.isCloned&&e.push(r)})}),e.forEach(p=>{ge(p),p.removeFromParent()}),e=[];let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s,c=i+s;let h=Math.floor(n/c);const d=n%c;if(h>0){h>1&&(s+=d/(h+2));const p=i+s,r=-t/2+s+i/2;for(let l=0;l<h;l++)this._rollerLevel.forEach(u=>{let g;u.traverse(m=>{m.userData.isRollerLevelBox&&(g=m)});const y=this._roller.clone(!0);y.visible=!0,y.userData.isCloned=!0,y.position.y=r+p*l,g==null||g.add(y),this.regenerateShapeKeyNode(y)})}}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 s;if(!this._shelf)return;this._shelfMaxLevel=e;const t=this.levelOffset;this._shelves.delete(0),this._shelves.forEach(a=>{ge(a),a.parent&&a.removeFromParent()}),this.goods=[],this._shelves.clear(),this._shelves.set(0,this._shelf);for(let a=1;a<e;a++){if(!this._shelf)return;this._shelf.traverse(h=>{$s(h)&&(this.setShapeKeyToMesh(h,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(h,"goodsLength",this._goodsSize.length))});const n=this._shelf.clone(!0);n.position.z+=t*a,this._shelves.set(a,n),(s=this._shelf.parent)==null||s.add(n);let c;if(n.traverse(h=>{h.userData.isShelfContainer&&(c=h)}),(this.shapeKeys.has("goodsLength")||this.shapeKeys.has("goodsWidth"))&&(c==null||c.position.setX((c==null?void 0:c.position.x)+this._goodsSize.length/2)),c){const h=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(h),this.goods.push(h),a===1){const d=new Ve(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);d.position.z-=t,c.add(d),this.goods.push(d)}}}const i=this.getShelfMinHeight()||0;this._liftMaxHeight<i&&this.setLiftMaxHeight(i)}generateOuterLine(){this.traverse(e=>{if(e.userData.isOuterObject){const t=this.sizeBox.radius;this._outline?this._outline.update(t):(this._outline=new Ur(t,0),this.add(this._outline))}})}generateController(e,t){if(this.showController){if(e.userData.isForkController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(h=>{h.name===i&&(n=h)}),!n)return;const c=new Js({name:"",target:i,default:0,min:s,max:a},n);e.add(c)}else if(e.userData.isController&&e.userData.target){const i=e.userData.target.name,{min:s,max:a}=e.userData;let n;if(t.traverse(h=>{h.name===i&&(n=h)}),!n)return;const c=new Js({name:"",userData:e.userData,target:e.userData.key,default:0,min:s||0,max:a||1},n);e.add(c),this.controllers.push(c),(n.userData.isFork||n.userData.isLift||n.userData.isJack)&&(this._forkMaxHeight=a||1,this._liftMaxHeight=a||1,this._jackMaxHeight=a||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=Oa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new f.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new f.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new f.Vector3(0,0,e.userData.start-e.position.z),c=n.clone().setZ(e.userData.end-e.position.z)),!Object.keys(e.userData).flatMap(r=>r.startsWith("target")?e.userData[r].name:[]).length)return;const p=new el({start:n,end:c,startOrigin:s,axios:a,divider:i});e.add(p)}}generateSlot(e,t){var i,s;if(e.userData.isSlot){const a=e.userData.name,n=e.userData.isMirror,c=(i=e.userData.mirrorSlot)==null?void 0:i.name;if(a){const h=e.userData.holeTarget&&e.userData.holeTarget.name;let d;h&&t.traverse(u=>{u.name===h&&(d=u)});const p=new Map;Object.keys(e.userData).forEach(u=>{if(u.startsWith("follow_")){const g=u.split("_")[1];if(g){let y=e.userData[u];p.set(g,{scale:y,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new ji({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=d,l.addEventListener(K.ON_DROP,u=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(K.ON_BEFORE_SELECTED,u=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(K.ON_ERROR_STATE_CHANGE,u=>{var y;if(!this._app)return;const g=(y=this._app)==null?void 0:y._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),u){if(l.device){if(g.selectedObjects.find(v=>{var _;return v.parent===((_=l.device)==null?void 0:_.parent)}))return;g.selectedObjects=[l.device,...g.selectedObjects]}}else l.device&&(g.selectedObjects=g.selectedObjects.filter(m=>{var v;return m.parent!==((v=l.device)==null?void 0:v.parent)}))}),l}}}clean(){this._emitter.removeAllListeners(),this.controllers.forEach(e=>e.dispose()),this.controllers=[],this._levels.forEach(e=>e.destroy()),this._levels.clear(),this._rollerLevel.clear(),ge(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._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._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 a=this._currentAction,n=a===s,c=n?0:t!=null&&t.fadeIn?t==null?void 0:t.fadeIn:.5,h=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const d=(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(d?f.LoopRepeat:f.LoopOnce,d?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!d,s.play();const p=(t==null?void 0:t.timeScale)??1;return h?(a.stopFading(),a.enabled=!0,a.setEffectiveWeight(1),a.crossFadeTo(s,c,!1)):c>0&&s.fadeIn(c),s.setEffectiveTimeScale(p),this._currentAction=s,new Promise(r=>{this._pendingFinishedCallback&&this._mixer&&this._mixer.removeEventListener("finished",this._pendingFinishedCallback);const l=u=>{var g;u.action===s&&((g=this._mixer)==null||g.removeEventListener("finished",l),this._pendingFinishedCallback=null,r())};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 Wr=0,sl=1,rl=2,er=2,Ri=1.25,tr=1,Pt=6*4+4+4,pi=65535,nl=Math.pow(2,-24),Ii=Symbol("SKIP_GENERATION");function ol(o){return o.index?o.index.count:o.attributes.position.count}function mt(o){return ol(o)/3}function al(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function ll(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=al(t,i);o.setIndex(new f.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Nr(o){const e=mt(o),t=o.drawRange,i=t.start/3,s=(t.start+t.count)/3,a=Math.max(0,i),n=Math.min(e,s)-a;return[{offset:Math.floor(a),count:Math.floor(n)}]}function Gr(o){if(!o.groups||!o.groups.length)return Nr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,a=(i.start+i.count)/3;for(const c of o.groups){const h=c.start/3,d=(c.start+c.count)/3;t.add(Math.max(s,h)),t.add(Math.min(a,d))}const n=Array.from(t.values()).sort((c,h)=>c-h);for(let c=0;c<n.length-1;c++){const h=n[c],d=n[c+1];e.push({offset:Math.floor(h),count:Math.floor(d-h)})}return e}function cl(o){if(o.groups.length===0)return!1;const e=mt(o),t=Gr(o).sort((a,n)=>a.offset-n.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:a})=>s+=a),e!==s}function Di(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,h=-1/0,d=-1/0,p=-1/0,r=1/0,l=1/0,u=1/0,g=-1/0,y=-1/0,m=-1/0;for(let v=e*6,_=(e+t)*6;v<_;v+=6){const x=o[v+0],w=o[v+1],b=x-w,T=x+w;b<a&&(a=b),T>h&&(h=T),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],I=o[v+3],C=S-I,L=S+I;C<n&&(n=C),L>d&&(d=L),S<l&&(l=S),S>y&&(y=S);const R=o[v+4],A=o[v+5],M=R-A,D=R+A;M<c&&(c=M),D>p&&(p=D),R<u&&(u=R),R>m&&(m=R)}i[0]=a,i[1]=n,i[2]=c,i[3]=h,i[4]=d,i[5]=p,s[0]=r,s[1]=l,s[2]=u,s[3]=g,s[4]=y,s[5]=m}function hl(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=mt(o),c=s.normalized;let h;e===null?(h=new Float32Array(n*6*4),t=0,i=n):(h=e,t=t||0,i=i||n);const d=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let u=t;u<t+i;u++){const g=u*3,y=u*6;let m=g+0,v=g+1,_=g+2;a&&(m=a[m],v=a[v],_=a[_]),c||(m=m*r+p,v=v*r+p,_=_*r+p);for(let x=0;x<3;x++){let w,b,T;c?(w=s[l[x]](m),b=s[l[x]](v),T=s[l[x]](_)):(w=d[m+x],b=d[v+x],T=d[_+x]);let S=w;b<S&&(S=b),T<S&&(S=T);let I=w;b>I&&(I=b),T>I&&(I=T);const C=(I-S)/2,L=x*2;h[y+L+0]=S+C,h[y+L+1]=C+(Math.abs(S)+C)*nl}}return h}function Y(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function ir(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function sr(o,e){e.set(o)}function rr(o,e,t){let i,s;for(let a=0;a<3;a++){const n=a+3;i=o[a],s=e[a],t[a]=i<s?i:s,i=o[n],s=e[n],t[n]=i>s?i:s}}function qt(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],a=e[o+2*i+1],n=s-a,c=s+a;n<t[i]&&(t[i]=n),c>t[i+3]&&(t[i+3]=c)}}function bt(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}const _e=32,ul=(o,e)=>o.candidate-e.candidate,Me=new Array(_e).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),jt=new Float32Array(6);function fl(o,e,t,i,s,a){let n=-1,c=0;if(a===Wr)n=ir(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===sl)n=ir(o),n!==-1&&(c=dl(t,i,s,n));else if(a===rl){const h=bt(o);let d=Ri*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const u=e[l],m=(e[l+3]-u)/_e;if(s<_e/4){const v=[...Me];v.length=s;let _=0;for(let w=p;w<r;w+=6,_++){const b=v[_];b.candidate=t[w+2*l],b.count=0;const{bounds:T,leftCacheBounds:S,rightCacheBounds:I}=b;for(let C=0;C<3;C++)I[C]=1/0,I[C+3]=-1/0,S[C]=1/0,S[C+3]=-1/0,T[C]=1/0,T[C+3]=-1/0;qt(w,t,T)}v.sort(ul);let x=s;for(let w=0;w<x;w++){const b=v[w];for(;w+1<x&&v[w+1].candidate===b.candidate;)v.splice(w+1,1),x--}for(let w=p;w<r;w+=6){const b=t[w+2*l];for(let T=0;T<x;T++){const S=v[T];b>=S.candidate?qt(w,t,S.rightCacheBounds):(qt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],T=b.count,S=s-b.count,I=b.leftCacheBounds,C=b.rightCacheBounds;let L=0;T!==0&&(L=bt(I)/h);let R=0;S!==0&&(R=bt(C)/h);const A=tr+Ri*(L*T+R*S);A<d&&(n=l,d=A,c=b.candidate)}}else{for(let x=0;x<_e;x++){const w=Me[x];w.count=0,w.candidate=u+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<r;x+=6){let T=~~((t[x+2*l]-u)/m);T>=_e&&(T=_e-1);const S=Me[T];S.count++,qt(x,t,S.bounds)}const v=Me[_e-1];sr(v.bounds,v.rightCacheBounds);for(let x=_e-2;x>=0;x--){const w=Me[x],b=Me[x+1];rr(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let _=0;for(let x=0;x<_e-1;x++){const w=Me[x],b=w.count,T=w.bounds,I=Me[x+1].rightCacheBounds;b!==0&&(_===0?sr(T,jt):rr(T,jt,jt)),_+=b;let C=0,L=0;_!==0&&(C=bt(jt)/h);const R=s-_;R!==0&&(L=bt(I)/h);const A=tr+Ri*(C*_+L*R);A<d&&(n=l,d=A,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function dl(o,e,t,i){let s=0;for(let a=e,n=e+t;a<n;a++)s+=o[a*6+i*2];return s/t}class Li{constructor(){this.boundingData=new Float32Array(6)}}function pl(o,e,t,i,s,a){let n=i,c=i+s-1;const h=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<h;)n++;for(;n<=c&&t[c*6+d]>=h;)c--;if(n<c){for(let p=0;p<3;p++){let r=e[n*3+p];e[n*3+p]=e[c*3+p],e[c*3+p]=r}for(let p=0;p<6;p++){let r=t[n*6+p];t[n*6+p]=t[c*6+p],t[c*6+p]=r}n++,c--}else return n}}function ml(o,e,t,i,s,a){let n=i,c=i+s-1;const h=a.pos,d=a.axis*2;for(;;){for(;n<=c&&t[n*6+d]<h;)n++;for(;n<=c&&t[c*6+d]>=h;)c--;if(n<c){let p=o[n];o[n]=o[c],o[c]=p;for(let r=0;r<6;r++){let l=t[n*6+r];t[n*6+r]=t[c*6+r],t[c*6+r]=l}n++,c--}else return n}}function ee(o,e){return e[o+15]===65535}function se(o,e){return e[o+6]}function ne(o,e){return e[o+14]}function oe(o){return o+8}function ae(o,e){return e[o+6]}function qr(o,e){return e[o+7]}let jr,It,ai,Qr;const gl=Math.pow(2,32);function Yi(o){return"count"in o?1:1+Yi(o.left)+Yi(o.right)}function vl(o,e,t){return jr=new Float32Array(t),It=new Uint32Array(t),ai=new Uint16Array(t),Qr=new Uint8Array(t),Zi(o,e)}function Zi(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)jr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Qr.set(new Uint8Array(n),o);for(let c=o,h=o+n.byteLength;c<h;c+=Pt){const d=c/2;ee(d,ai)||(It[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return It[t+6]=n,ai[i+14]=c,ai[i+15]=pi,o+Pt}else{const n=e.left,c=e.right,h=e.splitAxis;let d;if(d=Zi(o+Pt,n),d/4>gl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return It[t+6]=d/4,d=Zi(d,c),It[t+7]=h,d}}function _l(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>2**16,s=i?4:2,a=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),n=i?new Uint32Array(a):new Uint16Array(a);for(let c=0,h=n.length;c<h;c++)n[c]=c;return n}function yl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:h,onProgress:d,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,u=l.index?l.index.array:null,g=p?ml:pl,y=mt(l),m=new Float32Array(6);let v=!1;const _=new Li;return Di(e,t,i,_.boundingData,m),w(_,t,i,m),_;function x(b){d&&d(b/y)}function w(b,T,S,I=null,C=0){if(!v&&C>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||C>=a)return x(T+S),b.offset=T,b.count=S,b;const L=fl(b.boundingData,I,e,T,S,h);if(L.axis===-1)return x(T+S),b.offset=T,b.count=S,b;const R=g(r,u,e,T,S,L);if(R===T||R===T+S)x(T+S),b.offset=T,b.count=S;else{b.splitAxis=L.axis;const A=new Li,M=T,D=R-T;b.left=A,Di(e,M,D,A.boundingData,m),w(A,M,D,m,C+1);const P=new Li,E=R,B=S-D;b.right=P,Di(e,E,B,P.boundingData,m),w(P,E,B,m,C+1)}return b}}function xl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=_l(t,e.useSharedArrayBuffer),cl(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.')),o._indirectBuffer||ll(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=hl(t),a=e.indirect?Nr(t):Gr(t);o._roots=a.map(n=>{const c=yl(o,s,n.offset,n.count,e),h=Yi(c),d=new i(Pt*h);return vl(0,c,d),d})}class be{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let a=0,n=e.length;a<n;a++){const h=e[a][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 a=0,n=t.length;a<n;a++){const c=t[a],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}}be.prototype.setFromBox=function(){const o=new f.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let h=0;h<=1;h++)for(let d=0;d<=1;d++)for(let p=0;p<=1;p++){o.x=s.x*h+a.x*(1-h),o.y=s.y*d+a.y*(1-d),o.z=s.z*p+a.z*(1-p);const r=t.dot(o);n=Math.min(r,n),c=Math.max(r,c)}this.min=n,this.max=c}}();const wl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Vector3;return function(s,a,n){const c=s.start,h=o,d=a.start,p=e;t.subVectors(c,d),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(h),u=p.dot(p),g=t.dot(h),m=h.dot(h)*u-l*l;let v,_;m!==0?v=(r*l-g*u)/m:v=0,_=(r+v*l)/u,n.x=v,n.y=_}}(),ds=function(){const o=new f.Vector2,e=new f.Vector3,t=new f.Vector3;return function(s,a,n,c){wl(s,a,o);let h=o.x,d=o.y;if(h>=0&&h<=1&&d>=0&&d<=1){s.at(h,n),a.at(d,c);return}else if(h>=0&&h<=1){d<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(d>=0&&d<=1){h<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;h<0?p=s.start:p=s.end;let r;d<0?r=a.start:r=a.end;const l=e,u=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=u.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(u);return}}}}(),bl=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Plane,i=new f.Line3;return function(a,n){const{radius:c,center:h}=a,{a:d,b:p,c:r}=n;if(i.start=d,i.end=p,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c||(i.start=d,i.end=r,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(h,!0,o).distanceTo(h)<=c))return!0;const y=n.getPlane(t);if(Math.abs(y.distanceToPoint(h))<=c){const v=y.projectPoint(h,e);if(n.containsPoint(v))return!0}return!1}}(),Al=1e-15;function Pi(o){return Math.abs(o)<Al}class fe 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 be),this.points=[this.a,this.b,this.c],this.sphere=new f.Sphere,this.plane=new f.Plane,this.needsUpdate=!0}intersectsSphere(e){return bl(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,a=this.satAxes,n=this.satBounds,c=a[0],h=n[0];this.getNormal(c),h.setFromPoints(c,s);const d=a[1],p=n[1];d.subVectors(e,t),p.setFromPoints(d,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const u=a[3],g=n[3];u.subVectors(i,e),g.setFromPoints(u,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}fe.prototype.closestPointToSegment=function(){const o=new f.Vector3,e=new f.Vector3,t=new f.Line3;return function(s,a=null,n=null){const{start:c,end:h}=s,d=this.points;let p,r=1/0;for(let l=0;l<3;l++){const u=(l+1)%3;t.start.copy(d[l]),t.end.copy(d[u]),ds(t,s,o,e),p=o.distanceToSquared(e),p<r&&(r=p,a&&a.copy(o),n&&n.copy(e))}return this.closestPointToPoint(c,o),p=c.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(c)),this.closestPointToPoint(h,o),p=h.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(h)),Math.sqrt(r)}}();fe.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new Array(3),i=new be,s=new be,a=new f.Vector3,n=new f.Vector3,c=new f.Vector3,h=new f.Vector3,d=new f.Vector3,p=new f.Line3,r=new f.Line3,l=new f.Line3,u=new f.Vector3;function g(y,m,v){const _=y.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:T,end:S}=p;T.copy(_[b]),S.copy(_[(b+1)%3]),p.delta(n);const I=Pi(m.distanceToPoint(T));if(Pi(m.normal.dot(n))&&I){v.copy(p),x=2;break}const C=m.intersectLine(p,u);if(!C&&I&&u.copy(T),(C||I)&&!Pi(u.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(u),I&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(u),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,_=!1){this.needsUpdate&&this.update(),m.isExtendedTriangle?m.needsUpdate&&m.update():(o.copy(m),o.update(),m=o);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 L=b[C],R=T[C];if(i.setFromPoints(R,t),L.isSeparated(i))return!1}const S=m.satBounds,I=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let C=0;C<4;C++){const L=S[C],R=I[C];if(i.setFromPoints(R,e),L.isSeparated(i))return!1}for(let C=0;C<4;C++){const L=T[C];for(let R=0;R<4;R++){const A=I[R];if(a.crossVectors(L,A),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(_||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),v.start.set(0,0,0),v.end.set(0,0,0)),!0}else{const b=g(this,w,r);if(b===1&&m.containsPoint(r.end))return v&&(v.start.copy(r.end),v.end.copy(r.end)),!0;if(b!==2)return!1;const T=g(m,x,l);if(T===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(T!==2)return!1;if(r.delta(c),l.delta(h),c.dot(h)<0){let M=l.start;l.start=l.end,l.end=M}const S=r.start.dot(c),I=r.end.dot(c),C=l.start.dot(c),L=l.end.dot(c),R=I<C,A=S<L;return S!==L&&C!==I&&R===A?!1:(v&&(d.subVectors(r.start,l.start),d.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),d.subVectors(r.end,l.end),d.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();fe.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();fe.prototype.distanceToTriangle=function(){const o=new f.Vector3,e=new f.Vector3,t=["a","b","c"],i=new f.Line3,s=new f.Line3;return function(n,c=null,h=null){const d=c||h?i:null;if(this.intersectsTriangle(n,d))return(c||h)&&(c&&d.getCenter(c),h&&d.getCenter(h)),0;let p=1/0;for(let r=0;r<3;r++){let l;const u=t[r],g=n[u];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),h&&h.copy(g));const y=this[u];n.closestPointToPoint(y,o),l=y.distanceToSquared(o),l<p&&(p=l,c&&c.copy(y),h&&h.copy(o))}for(let r=0;r<3;r++){const l=t[r],u=t[(r+1)%3];i.set(this[l],this[u]);for(let g=0;g<3;g++){const y=t[g],m=t[(g+1)%3];s.set(n[y],n[m]),ds(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),h&&h.copy(e))}}return Math.sqrt(p)}}();class X{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 be),this.alignedSatBounds=new Array(3).fill().map(()=>new be),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}}X.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let d=0;d<=1;d++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*d|2*p|4*r,u=s[l];u.x=d?i.x:t.x,u.y=p?i.y:t.y,u.z=r?i.z:t.z,u.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let d=0;d<3;d++){const p=n[d],r=a[d],l=1<<d,u=s[l];p.subVectors(c,u),r.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}}();X.prototype.intersectsBox=function(){const o=new be;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,a=this.satBounds,n=this.satAxes,c=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,c[0].isSeparated(o)||(o.min=i.y,o.max=s.y,c[1].isSeparated(o))||(o.min=i.z,o.max=s.z,c[2].isSeparated(o)))return!1;for(let h=0;h<3;h++){const d=n[h],p=a[h];if(o.setFromBox(d,t),p.isSeparated(o))return!1}return!0}}();X.prototype.intersectsTriangle=function(){const o=new fe,e=new Array(3),t=new be,i=new be,s=new f.Vector3;return function(n){this.needsUpdate&&this.update(),n.isExtendedTriangle?n.needsUpdate&&n.update():(o.copy(n),o.update(),n=o);const c=this.satBounds,h=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const u=c[l],g=h[l];if(t.setFromPoints(g,e),u.isSeparated(t))return!1}const d=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const u=d[l],g=p[l];if(t.setFromPoints(g,r),u.isSeparated(t))return!1}for(let l=0;l<3;l++){const u=h[l];for(let g=0;g<4;g++){const y=p[g];if(s.crossVectors(u,y),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();X.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}}();X.prototype.distanceToPoint=function(){const o=new f.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();X.prototype.distanceToBox=function(){const o=["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(n,c=0,h=null,d=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(h||d)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),h&&h.copy(i),d&&d.copy(s)),0;const p=c*c,r=n.min,l=n.max,u=this.points;let g=1/0;for(let m=0;m<8;m++){const v=u[m];s.copy(v).clamp(r,l);const _=v.distanceToSquared(s);if(_<g&&(g=_,h&&h.copy(v),d&&d.copy(s),_<p))return Math.sqrt(_)}let y=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|_<<w,T=1<<m|v<<x|_<<w,S=u[b],I=u[T];e[y].set(S,I);const L=o[m],R=o[x],A=o[w],M=t[y],D=M.start,P=M.end;D[L]=r[L],D[R]=v?r[R]:l[R],D[A]=_?r[A]:l[R],P[L]=l[L],P[R]=v?r[R]:l[R],P[A]=_?r[A]:l[R],y++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let _=0;_<=1;_++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=_?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,h&&h.copy(i),d&&d.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let _=0;_<12;_++){const x=t[_];ds(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,h&&h.copy(i),d&&d.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 Tl extends ps{constructor(){super(()=>new fe)}}const le=new Tl;class Sl{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 q=new Sl;let Pe,at;const Qe=[],Qt=new ps(()=>new f.Box3);function Ml(o,e,t,i,s,a){Pe=Qt.getPrimitive(),at=Qt.getPrimitive(),Qe.push(Pe,at),q.setBuffer(o._roots[e]);const n=Ki(0,o.geometry,t,i,s,a);q.clearBuffer(),Qt.releasePrimitive(Pe),Qt.releasePrimitive(at),Qe.pop(),Qe.pop();const c=Qe.length;return c>0&&(at=Qe[c-1],Pe=Qe[c-2]),n}function Ki(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:h,uint32Array:d}=q;let p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);return Y(o,c,Pe),i(l,u,!1,n,a+o,Pe)}else{let L=function(A){const{uint16Array:M,uint32Array:D}=q;let P=A*2;for(;!ee(P,M);)A=oe(A),P=A*2;return se(A,D)},R=function(A){const{uint16Array:M,uint32Array:D}=q;let P=A*2;for(;!ee(P,M);)A=ae(A,D),P=A*2;return se(A,D)+ne(P,M)};const l=oe(o),u=ae(o,d);let g=l,y=u,m,v,_,x;if(s&&(_=Pe,x=at,Y(g,c,_),Y(y,c,x),m=s(_),v=s(x),v<m)){g=u,y=l;const A=m;m=v,v=A,_=x}_||(_=Pe,Y(g,c,_));const w=ee(g*2,h),b=t(_,w,m,n+1,a+g);let T;if(b===er){const A=L(g),D=R(g)-A;T=i(A,D,!0,n+1,a+g,_)}else T=b&&Ki(g,e,t,i,s,a,n+1);if(T)return!0;x=at,Y(y,c,x);const S=ee(y*2,h),I=t(x,S,v,n+1,a+y);let C;if(I===er){const A=L(y),D=R(y)-A;C=i(A,D,!0,n+1,a+y,x)}else C=I&&Ki(y,e,t,i,s,a,n+1);return!!C}}const At=new f.Vector3,Fi=new f.Vector3;function Cl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,h=null;if(o.shapecast({boundsTraverseOrder:p=>(At.copy(e).clamp(p.min,p.max),At.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,At);const l=e.distanceToSquared(At);return l<c&&(Fi.copy(At),c=l,h=r),l<a}}),c===1/0)return null;const d=Math.sqrt(c);return t.point?t.point.copy(Fi):t.point=Fi.clone(),t.distance=d,t.faceIndex=h,t}const Ye=new f.Vector3,Ze=new f.Vector3,Ke=new f.Vector3,Yt=new f.Vector2,Zt=new f.Vector2,Kt=new f.Vector2,nr=new f.Vector3,or=new f.Vector3,ar=new f.Vector3,Xt=new f.Vector3;function Rl(o,e,t,i,s,a,n,c){let h;if(a===f.BackSide?h=o.intersectTriangle(i,t,e,!0,s):h=o.intersectTriangle(e,t,i,a!==f.DoubleSide,s),h===null)return null;const d=o.origin.distanceTo(s);return d<n||d>c?null:{distance:d,point:s.clone()}}function Il(o,e,t,i,s,a,n,c,h,d,p){Ye.fromBufferAttribute(e,a),Ze.fromBufferAttribute(e,n),Ke.fromBufferAttribute(e,c);const r=Rl(o,Ye,Ze,Ke,Xt,h,d,p);if(r){i&&(Yt.fromBufferAttribute(i,a),Zt.fromBufferAttribute(i,n),Kt.fromBufferAttribute(i,c),r.uv=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),s&&(Yt.fromBufferAttribute(s,a),Zt.fromBufferAttribute(s,n),Kt.fromBufferAttribute(s,c),r.uv1=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,Yt,Zt,Kt,new f.Vector2)),t&&(nr.fromBufferAttribute(t,a),or.fromBufferAttribute(t,n),ar.fromBufferAttribute(t,c),r.normal=f.Triangle.getInterpolation(Xt,Ye,Ze,Ke,nr,or,ar,new f.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new f.Vector3,materialIndex:0};f.Triangle.getNormal(Ye,Ze,Ke,l.normal),r.face=l,r.faceIndex=a}return r}function mi(o,e,t,i,s,a,n){const c=i*3;let h=c+0,d=c+1,p=c+2;const r=o.index;o.index&&(h=r.getX(h),d=r.getX(d),p=r.getX(p));const{position:l,normal:u,uv:g,uv1:y}=o.attributes,m=Il(t,l,u,g,y,h,d,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Z(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,h=e+1,d=e+2;t&&(c=t.getX(c),h=t.getX(h),d=t.getX(d)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(h),a.y=i.getY(h),a.z=i.getZ(h),n.x=i.getX(d),n.y=i.getY(d),n.z=i.getZ(d)}function Dl(o,e,t,i,s,a,n,c){const{geometry:h,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++)mi(h,e,t,p,a,n,c)}function Ll(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:h}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let u;u=mi(c,e,t,r,null,a,n),u&&u.distance<d&&(p=u,d=u.distance)}return p}function Pl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:h}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Z(n,l*3,h,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Fl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,h,d=0;const p=o._roots;for(let l=0,u=p.length;l<u;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),h=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,u,g=!1){const y=l*2;if(c[y+15]===pi){const v=n[l+6],_=c[y+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,I=-1/0;for(let C=3*v,L=3*(v+_);C<L;C++){let R=i[C];const A=s.getX(R),M=s.getY(R),D=s.getZ(R);A<x&&(x=A),A>T&&(T=A),M<w&&(w=M),M>S&&(S=M),D<b&&(b=D),D>I&&(I=D)}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==S||h[l+5]!==I?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=S,h[l+5]=I,!0):!1}else{const v=l+8,_=n[l+6],x=v+u,w=_+u;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const I=b||T,C=b||S;let L=!1;I&&(L=r(v,u,b));let R=!1;C&&(R=r(_,u,b));const A=L||R;if(A)for(let M=0;M<3;M++){const D=v+M,P=_+M,E=h[D],B=h[D+3],V=h[P],N=h[P+3];h[l+M]=E<V?E:V,h[l+M+3]=B>N?B:N}return A}}}function Fe(o,e,t,i,s){let a,n,c,h,d,p;const r=1/t.direction.x,l=1/t.direction.y,u=1/t.direction.z,g=t.origin.x,y=t.origin.y,m=t.origin.z;let v=e[o],_=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],T=e[o+3+2];return r>=0?(a=(v-g)*r,n=(_-g)*r):(a=(_-g)*r,n=(v-g)*r),l>=0?(c=(x-y)*l,h=(w-y)*l):(c=(w-y)*l,h=(x-y)*l),a>h||c>n||((c>a||isNaN(a))&&(a=c),(h<n||isNaN(n))&&(n=h),u>=0?(d=(b-m)*u,p=(T-m)*u):(d=(T-m)*u,p=(b-m)*u),a>p||d>n)?!1:((d>a||a!==a)&&(a=d),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function El(o,e,t,i,s,a,n,c){const{geometry:h,_indirectBuffer:d}=o;for(let p=i,r=i+s;p<r;p++){let l=d?d[p]:p;mi(h,e,t,l,a,n,c)}}function Bl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:h}=o;let d=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let u;u=mi(c,e,t,h?h[r]:r,null,a,n),u&&u.distance<d&&(p=u,d=u.distance)}return p}function kl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:h}=c,d=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Z(n,l*3,h,d),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Ol(o,e,t,i,s,a,n){q.setBuffer(o._roots[e]),Xi(0,o,t,i,s,a,n),q.clearBuffer()}function Xi(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:h,uint32Array:d}=q,p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);Dl(e,t,i,l,u,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&Xi(l,e,t,i,s,a,n);const u=ae(o,d);Fe(u,c,i,a,n)&&Xi(u,e,t,i,s,a,n)}}const zl=["x","y","z"];function Vl(o,e,t,i,s,a){q.setBuffer(o._roots[e]);const n=Ji(0,o,t,i,s,a);return q.clearBuffer(),n}function Ji(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:h}=q;let d=o*2;if(ee(d,c)){const r=se(o,h),l=ne(d,c);return Ll(e,t,i,r,l,s,a)}else{const r=qr(o,h),l=zl[r],g=i.direction[l]>=0;let y,m;g?(y=oe(o),m=ae(o,h)):(y=ae(o,h),m=oe(o));const _=Fe(y,n,i,s,a)?Ji(y,e,t,i,s,a):null;if(_){const b=_.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return _}const w=Fe(m,n,i,s,a)?Ji(m,e,t,i,s,a):null;return _&&w?_.distance<=w.distance?_:w:_||w||null}}const Jt=new f.Box3,Xe=new fe,Je=new fe,Tt=new f.Matrix4,lr=new X,$t=new X;function Ul(o,e,t,i){q.setBuffer(o._roots[e]);const s=$i(0,o,t,i);return q.clearBuffer(),s}function $i(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=q;let h=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),lr.set(t.boundingBox.min,t.boundingBox.max,i),s=lr),ee(h,n)){const p=e.geometry,r=p.index,l=p.attributes.position,u=t.index,g=t.attributes.position,y=se(o,c),m=ne(h,n);if(Tt.copy(i).invert(),t.boundsTree)return Y(o,a,$t),$t.matrix.copy(Tt),$t.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>$t.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(i),_.b.applyMatrix4(i),_.c.applyMatrix4(i),_.needsUpdate=!0;for(let x=y*3,w=(m+y)*3;x<w;x+=3)if(Z(Je,x,r,l),Je.needsUpdate=!0,_.intersectsTriangle(Je))return!0;return!1}});for(let v=y*3,_=(m+y)*3;v<_;v+=3){Z(Xe,v,r,l),Xe.a.applyMatrix4(Tt),Xe.b.applyMatrix4(Tt),Xe.c.applyMatrix4(Tt),Xe.needsUpdate=!0;for(let x=0,w=u.count;x<w;x+=3)if(Z(Je,x,u,g),Je.needsUpdate=!0,Xe.intersectsTriangle(Je))return!0}}else{const p=o+8,r=c[o+6];return Y(p,a,Jt),!!(s.intersectsBox(Jt)&&$i(p,e,t,i,s)||(Y(r,a,Jt),s.intersectsBox(Jt)&&$i(r,e,t,i,s)))}}const ei=new f.Matrix4,Ei=new X,St=new X,Hl=new f.Vector3,Wl=new f.Vector3,Nl=new f.Vector3,Gl=new f.Vector3;function ql(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Ei.set(e.boundingBox.min,e.boundingBox.max,t),Ei.needsUpdate=!0;const c=o.geometry,h=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),u=le.getPrimitive();let g=Hl,y=Wl,m=null,v=null;s&&(m=Nl,v=Gl);let _=1/0,x=null,w=null;return ei.copy(t).invert(),St.matrix.copy(ei),o.shapecast({boundsTraverseOrder:b=>Ei.distanceToBox(b),intersectsBounds:(b,T,S)=>S<_&&S<n?(T&&(St.min.copy(b.min),St.max.copy(b.max),St.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:I=>St.distanceToBox(I),intersectsBounds:(I,C,L)=>L<_&&L<n,intersectsRange:(I,C)=>{for(let L=I,R=I+C;L<R;L++){Z(u,3*L,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let A=b,M=b+T;A<M;A++){Z(l,3*A,d,h),l.needsUpdate=!0;const D=l.distanceToTriangle(u,g,m);if(D<_&&(y.copy(g),v&&v.copy(m),_=D,x=A,w=L),D<a)return!0}}}});{const S=mt(e);for(let I=0,C=S;I<C;I++){Z(u,3*I,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=b,R=b+T;L<R;L++){Z(l,3*L,d,h),l.needsUpdate=!0;const A=l.distanceToTriangle(u,g,m);if(A<_&&(y.copy(g),v&&v.copy(m),_=A,x=L,w=I),A<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(u),_===1/0?null:(i.point?i.point.copy(y):i.point=y.clone(),i.distance=_,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ei),y.applyMatrix4(ei),s.distance=y.sub(s.point).length(),s.faceIndex=w),i)}function jl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let a,n,c,h,d=0;const p=o._roots;for(let l=0,u=p.length;l<u;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),h=new Float32Array(a),r(0,d),d+=a.byteLength;function r(l,u,g=!1){const y=l*2;if(c[y+15]===pi){const v=n[l+6],_=c[y+14];let x=1/0,w=1/0,b=1/0,T=-1/0,S=-1/0,I=-1/0;for(let C=v,L=v+_;C<L;C++){const R=3*o.resolveTriangleIndex(C);for(let A=0;A<3;A++){let M=R+A;M=i?i[M]:M;const D=s.getX(M),P=s.getY(M),E=s.getZ(M);D<x&&(x=D),D>T&&(T=D),P<w&&(w=P),P>S&&(S=P),E<b&&(b=E),E>I&&(I=E)}}return h[l+0]!==x||h[l+1]!==w||h[l+2]!==b||h[l+3]!==T||h[l+4]!==S||h[l+5]!==I?(h[l+0]=x,h[l+1]=w,h[l+2]=b,h[l+3]=T,h[l+4]=S,h[l+5]=I,!0):!1}else{const v=l+8,_=n[l+6],x=v+u,w=_+u;let b=g,T=!1,S=!1;e?b||(T=e.has(x),S=e.has(w),b=!T&&!S):(T=!0,S=!0);const I=b||T,C=b||S;let L=!1;I&&(L=r(v,u,b));let R=!1;C&&(R=r(_,u,b));const A=L||R;if(A)for(let M=0;M<3;M++){const D=v+M,P=_+M,E=h[D],B=h[D+3],V=h[P],N=h[P+3];h[l+M]=E<V?E:V,h[l+M+3]=B>N?B:N}return A}}}function Ql(o,e,t,i,s,a,n){q.setBuffer(o._roots[e]),es(0,o,t,i,s,a,n),q.clearBuffer()}function es(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:h,uint32Array:d}=q,p=o*2;if(ee(p,h)){const l=se(o,d),u=ne(p,h);El(e,t,i,l,u,s,a,n)}else{const l=oe(o);Fe(l,c,i,a,n)&&es(l,e,t,i,s,a,n);const u=ae(o,d);Fe(u,c,i,a,n)&&es(u,e,t,i,s,a,n)}}const Yl=["x","y","z"];function Zl(o,e,t,i,s,a){q.setBuffer(o._roots[e]);const n=ts(0,o,t,i,s,a);return q.clearBuffer(),n}function ts(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:h}=q;let d=o*2;if(ee(d,c)){const r=se(o,h),l=ne(d,c);return Bl(e,t,i,r,l,s,a)}else{const r=qr(o,h),l=Yl[r],g=i.direction[l]>=0;let y,m;g?(y=oe(o),m=ae(o,h)):(y=ae(o,h),m=oe(o));const _=Fe(y,n,i,s,a)?ts(y,e,t,i,s,a):null;if(_){const b=_.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return _}const w=Fe(m,n,i,s,a)?ts(m,e,t,i,s,a):null;return _&&w?_.distance<=w.distance?_:w:_||w||null}}const ti=new f.Box3,$e=new fe,et=new fe,Mt=new f.Matrix4,cr=new X,ii=new X;function Kl(o,e,t,i){q.setBuffer(o._roots[e]);const s=is(0,o,t,i);return q.clearBuffer(),s}function is(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=q;let h=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),cr.set(t.boundingBox.min,t.boundingBox.max,i),s=cr),ee(h,n)){const p=e.geometry,r=p.index,l=p.attributes.position,u=t.index,g=t.attributes.position,y=se(o,c),m=ne(h,n);if(Mt.copy(i).invert(),t.boundsTree)return Y(o,a,ii),ii.matrix.copy(Mt),ii.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:_=>ii.intersectsBox(_),intersectsTriangle:_=>{_.a.applyMatrix4(i),_.b.applyMatrix4(i),_.c.applyMatrix4(i),_.needsUpdate=!0;for(let x=y,w=m+y;x<w;x++)if(Z(et,3*e.resolveTriangleIndex(x),r,l),et.needsUpdate=!0,_.intersectsTriangle(et))return!0;return!1}});for(let v=y,_=m+y;v<_;v++){const x=e.resolveTriangleIndex(v);Z($e,3*x,r,l),$e.a.applyMatrix4(Mt),$e.b.applyMatrix4(Mt),$e.c.applyMatrix4(Mt),$e.needsUpdate=!0;for(let w=0,b=u.count;w<b;w+=3)if(Z(et,w,u,g),et.needsUpdate=!0,$e.intersectsTriangle(et))return!0}}else{const p=o+8,r=c[o+6];return Y(p,a,ti),!!(s.intersectsBox(ti)&&is(p,e,t,i,s)||(Y(r,a,ti),s.intersectsBox(ti)&&is(r,e,t,i,s)))}}const si=new f.Matrix4,Bi=new X,Ct=new X,Xl=new f.Vector3,Jl=new f.Vector3,$l=new f.Vector3,ec=new f.Vector3;function tc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Bi.set(e.boundingBox.min,e.boundingBox.max,t),Bi.needsUpdate=!0;const c=o.geometry,h=c.attributes.position,d=c.index,p=e.attributes.position,r=e.index,l=le.getPrimitive(),u=le.getPrimitive();let g=Xl,y=Jl,m=null,v=null;s&&(m=$l,v=ec);let _=1/0,x=null,w=null;return si.copy(t).invert(),Ct.matrix.copy(si),o.shapecast({boundsTraverseOrder:b=>Bi.distanceToBox(b),intersectsBounds:(b,T,S)=>S<_&&S<n?(T&&(Ct.min.copy(b.min),Ct.max.copy(b.max),Ct.needsUpdate=!0),!0):!1,intersectsRange:(b,T)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:I=>Ct.distanceToBox(I),intersectsBounds:(I,C,L)=>L<_&&L<n,intersectsRange:(I,C)=>{for(let L=I,R=I+C;L<R;L++){const A=S.resolveTriangleIndex(L);Z(u,3*A,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let M=b,D=b+T;M<D;M++){const P=o.resolveTriangleIndex(M);Z(l,3*P,d,h),l.needsUpdate=!0;const E=l.distanceToTriangle(u,g,m);if(E<_&&(y.copy(g),v&&v.copy(m),_=E,x=M,w=L),E<a)return!0}}}})}else{const S=mt(e);for(let I=0,C=S;I<C;I++){Z(u,3*I,r,p),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let L=b,R=b+T;L<R;L++){const A=o.resolveTriangleIndex(L);Z(l,3*A,d,h),l.needsUpdate=!0;const M=l.distanceToTriangle(u,g,m);if(M<_&&(y.copy(g),v&&v.copy(m),_=M,x=L,w=I),M<a)return!0}}}}}),le.releasePrimitive(l),le.releasePrimitive(u),_===1/0?null:(i.point?i.point.copy(y):i.point=y.clone(),i.distance=_,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(si),y.applyMatrix4(si),s.distance=y.sub(s.point).length(),s.faceIndex=w),i)}function ic(){return typeof SharedArrayBuffer<"u"}const Ft=new q.constructor,hi=new q.constructor,Re=new ps(()=>new f.Box3),it=new f.Box3,st=new f.Box3,ki=new f.Box3,Oi=new f.Box3;let zi=!1;function sc(o,e,t,i){if(zi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");zi=!0;const s=o._roots,a=e._roots;let n,c=0,h=0;const d=new f.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Ft.setBuffer(s[p]),h=0;const l=Re.getPrimitive();Y(0,Ft.float32Array,l),l.applyMatrix4(d);for(let u=0,g=a.length;u<g&&(hi.setBuffer(a[p]),n=ue(0,0,t,d,i,c,h,0,0,l),hi.clearBuffer(),h+=a[u].length,!n);u++);if(Re.releasePrimitive(l),Ft.clearBuffer(),c+=s[p].length,n)break}return zi=!1,n}function ue(o,e,t,i,s,a=0,n=0,c=0,h=0,d=null,p=!1){let r,l;p?(r=hi,l=Ft):(r=Ft,l=hi);const u=r.float32Array,g=r.uint32Array,y=r.uint16Array,m=l.float32Array,v=l.uint32Array,_=l.uint16Array,x=o*2,w=e*2,b=ee(x,y),T=ee(w,_);let S=!1;if(T&&b)p?S=s(se(e,v),ne(e*2,_),se(o,g),ne(o*2,y),h,n+e,c,a+o):S=s(se(o,g),ne(o*2,y),se(e,v),ne(e*2,_),c,a+o,h,n+e);else if(T){const I=Re.getPrimitive();Y(e,m,I),I.applyMatrix4(t);const C=oe(o),L=ae(o,g);Y(C,u,it),Y(L,u,st);const R=I.intersectsBox(it),A=I.intersectsBox(st);S=R&&ue(e,C,i,t,s,n,a,h,c+1,I,!p)||A&&ue(e,L,i,t,s,n,a,h,c+1,I,!p),Re.releasePrimitive(I)}else{const I=oe(e),C=ae(e,v);Y(I,m,ki),Y(C,m,Oi);const L=d.intersectsBox(ki),R=d.intersectsBox(Oi);if(L&&R)S=ue(o,I,t,i,s,a,n,c,h+1,d,p)||ue(o,C,t,i,s,a,n,c,h+1,d,p);else if(L)if(b)S=ue(o,I,t,i,s,a,n,c,h+1,d,p);else{const A=Re.getPrimitive();A.copy(ki).applyMatrix4(t);const M=oe(o),D=ae(o,g);Y(M,u,it),Y(D,u,st);const P=A.intersectsBox(it),E=A.intersectsBox(st);S=P&&ue(I,M,i,t,s,n,a,h,c+1,A,!p)||E&&ue(I,D,i,t,s,n,a,h,c+1,A,!p),Re.releasePrimitive(A)}else if(R)if(b)S=ue(o,C,t,i,s,a,n,c,h+1,d,p);else{const A=Re.getPrimitive();A.copy(Oi).applyMatrix4(t);const M=oe(o),D=ae(o,g);Y(M,u,it),Y(D,u,st);const P=A.intersectsBox(it),E=A.intersectsBox(st);S=P&&ue(C,M,i,t,s,n,a,h,c+1,A,!p)||E&&ue(C,D,i,t,s,n,a,h,c+1,A,!p),Re.releasePrimitive(A)}}return S}const ri=new X,hr=new f.Box3,rc={strategy:Wr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const i=e.geometry,s=e._roots,a=e._indirectBuffer,n=i.getIndex();let c;return t.cloneBuffers?c={roots:s.map(h=>h.slice()),index:n?n.array.slice():null,indirectBuffer:a?a.slice():null}:c={roots:s,index:n?n.array:null,indirectBuffer:a},c}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:a,indirectBuffer:n}=e,c=new ms(t,{...i,[Ii]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const h=t.getIndex();if(h===null){const d=new f.BufferAttribute(e.index,1,!1);t.setIndex(d)}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({...rc,[Ii]:!1},t),t.useSharedArrayBuffer&&!ic())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Ii]||(xl(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?jl:Fl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,h=0){const d=c*2,p=a[d+15]===pi;if(p){const r=s[c+6],l=a[d+14];e(h,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Pt/4,l=s[c+6],u=s[c+7];e(h,p,new Float32Array(i,c*4,6),u)||(n(r,h+1),n(l,h+1))}}}raycast(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],h=t.isMaterial,d=Array.isArray(t),p=n.groups,r=h?t.side:t,l=this.indirect?Ql:Ol;for(let u=0,g=a.length;u<g;u++){const y=d?t[p[u].materialIndex].side:r,m=c.length;if(l(this,u,y,e,c,i,s),d){const v=p[u].materialIndex;for(let _=m,x=c.length;_<x;_++)c[_].face.materialIndex=v}}return c}raycastFirst(e,t=f.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,h=Array.isArray(t);let d=null;const p=n.groups,r=c?t.side:t,l=this.indirect?Zl:Vl;for(let u=0,g=a.length;u<g;u++){const y=h?t[p[u].materialIndex].side:r,m=l(this,u,y,e,i,s);m!=null&&(d==null||m.distance<d.distance)&&(d=m,h&&(m.face.materialIndex=p[u].materialIndex))}return d}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?Kl:Ul;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=le.getPrimitive(),i=this.indirect?kl:Pl;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,u,g,y,m)=>r(l,u,g,y,m)?!0:i(l,u,this,c,g,y,t)}else n||(c?n=(r,l,u,g)=>i(r,l,this,c,u,g,t):n=(r,l,u)=>u);let h=!1,d=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const u=p[r];if(h=Ml(this,r,a,n,s,d),h)break;d+=u.byteLength}return le.releasePrimitive(t),h}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=le.getPrimitive(),c=this.geometry.index,h=this.geometry.attributes.position,d=this.indirect?g=>{const y=this.resolveTriangleIndex(g);Z(n,y*3,c,h)}:g=>{Z(n,g*3,c,h)},p=le.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,u=e.indirect?g=>{const y=e.resolveTriangleIndex(g);Z(p,y*3,r,l)}:g=>{Z(p,g*3,r,l)};if(a){const g=(y,m,v,_,x,w,b,T)=>{for(let S=v,I=v+_;S<I;S++){u(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let C=y,L=y+m;C<L;C++)if(d(C),n.needsUpdate=!0,a(n,p,C,S,x,w,b,T))return!0}return!1};if(s){const y=s;s=function(m,v,_,x,w,b,T,S){return y(m,v,_,x,w,b,T,S)?!0:g(m,v,_,x,w,b,T,S)}}else s=g}return sc(this,e,t,s)}intersectsBox(e,t){return ri.set(e.min,e.max,t),ri.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ri.intersectsBox(i),intersectsTriangle:i=>ri.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},a=0,n=1/0){return(this.indirect?tc:ql)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return Cl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Y(0,new Float32Array(i),hr),e.union(hr)}),e}}class nc{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 oc extends nc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:ft&&ft.src||new URL("shop-components.cjs",document.baseURI).href),{type:"module"});super(t),this.name="GenerateMeshBVHWorker"}runTask(e,t,i={}){return new Promise((s,a)=>{if(t.getAttribute("position").isInterleavedBufferAttribute||t.index&&t.index.isInterleavedBufferAttribute)throw new Error("GenerateMeshBVHWorker: InterleavedBufferAttribute are not supported for the geometry attributes.");e.onerror=d=>{a(new Error(`GenerateMeshBVHWorker: ${d.message}`))},e.onmessage=d=>{const{data:p}=d;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,u=ms.deserialize(r,t,{setIndex:!1}),g=Object.assign({setBoundingBox:!0},i);if(t.attributes.position.array=l,r.index)if(t.index)t.index.array=r.index;else{const y=new f.BufferAttribute(r.index,1,!1);t.setIndex(y)}g.setBoundingBox&&(t.boundingBox=u.getBoundingBox(new f.Box3)),i.onProgress&&i.onProgress(p.progress),s(u),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,h=[c];n&&h.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},h.map(d=>d.buffer).filter(d=>typeof SharedArrayBuffer>"u"||!(d instanceof SharedArrayBuffer)))})}}class ac{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 pt,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,a)=>s.position.z>a.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 a=this.domElement.width/this.domElement.clientWidth,n=this.domElement.height/this.domElement.clientHeight,{left:c,top:h}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-h)*n,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 a=this.selectedAxis;s&&(this.updateMouseFromEvent(s),this.updateSelectedAxisUnderMouse()),a!==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 a=this.selectedAxis.direction.clone();this.camera.lookAt(0,0,0);const n=this.camera.position.distanceTo(this.orbit.target);a.multiplyScalar(n),this.selectedAxis.axis==="z"?a.setZ(this.orbit.target.z+n):this.selectedAxis.axis==="-z"?a.setZ(this.orbit.target.z-n):a.setZ(this.orbit.target.z);const c=500,h=performance.now(),d=1,p=this.selectedAxis.axis,r=()=>{const u=performance.now()-h,g=Math.min(u/c,d);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==d){this._animator=window.requestAnimationFrame(r);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),r()},this.drawCircle=(s,a=10,n="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.rect(s.x-a,s.y-a,a*2,a*2),this.context.fillStyle=n,this.context.fill(),this.context.closePath())},this.drawLine=(s,a,n=1,c="#FF0000")=>{this.context&&(this.context.beginPath(),this.context.moveTo(s.x,s.y),this.context.lineTo(a.x,a.y),this.context.lineWidth=n,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(a=>{const n=this.selectedAxis===a,c=a.position.z>=-.01?a.color[0]:a.color[1];if(a.line&&this.drawLine(this.center,a.position,a.line,c),this.drawCircle(a.position,a.size,n?"#0066ff":c),a.label){const h=a.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(a.label,a.position.x,a.position.y)}}))},this.setAxisPosition=s=>{const a=s.direction.clone().applyMatrix4(this.invRotMat),n=s.size;s.position.set(a.x*(this.center.x-n/2-this.options.padding)+this.center.x,this.center.y-a.y*(this.center.y-n/2-this.options.padding),a.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;
|
|
@@ -3940,4 +3940,4 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
|
|
|
3940
3940
|
user-select: none;
|
|
3941
3941
|
touch-action: none;
|
|
3942
3942
|
-webkit-touch-callout: none;
|
|
3943
|
-
`):e.style.background="radial-gradient(326% 141% at 50% 103%, #E0E0E0 0%, #D9D9D9 38%, #C2C2C2 47%, #C2C2C2 52%, #F0F0F0 100%)",this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}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,a,n,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(),(a=this._sciFiGrid.material)==null||a.dispose(),Le.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.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(),ge(this.scene),this.scene.clear()}}class Kr{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,y,m,v,_,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 a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((y=e==null?void 0:e.size)==null?void 0:y.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,d=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new f.WebGLRenderTarget(a,n,{format:f.RGBAFormat,type:f.UnsignedByteType});r.texture.colorSpace=f.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),u={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,d,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const S=this.readPixels(t,r,a,n);u[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(_=this.deps).onAfterCapture)==null||x.call(_)}return u}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,a=new f.Vector3,n=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const d=c.geometry;if(!d)return;d.boundingBox||d.computeBoundingBox();const p=d.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){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),S=Math.max(Math.tan(T/2),1e-4),I=Math.max(S*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),L=new f.Vector3().crossVectors(C,h).normalize();L.lengthSq()<1e-6&&L.set(1,0,0);const R=new f.Vector3().crossVectors(L,C).normalize(),A=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),D=Math.max(e.size.z*.5,1e-4),P=[new f.Vector3(-A,-M,-D),new f.Vector3(-A,-M,D),new f.Vector3(-A,M,-D),new f.Vector3(-A,M,D),new f.Vector3(A,-M,-D),new f.Vector3(A,-M,D),new f.Vector3(A,M,-D),new f.Vector3(A,M,D)];let E=0,B=-1/0;for(const W of P){const j=L.dot(W),U=R.dot(W),Q=C.dot(W);B=Math.max(B,Q);const re=Q+Math.abs(j)/I,te=Q+Math.abs(U)/S;E=Math.max(E,re,te)}E=Math.max(E,B+.1);const V=E*(1+s);let N=1/0;for(const W of P){const j=C.dot(W),U=V-j;U>.001&&(N=Math.min(N,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(N)?N*.5:V*.1),w.far=Math.max(w.near+1,V+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(V)),w.up.copy(R),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,u=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),y=Math.max(r[t.plane.depth]*.5,.01);let m=u*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const _=y*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(_));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=_*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),a=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new f.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),d=Math.max(t.z,.001),p=Math.max(n,s.z),r=d*.5+h*.5;return c.z=p*r,c.multiply(a),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 a=e.getClearColor(new f.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}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 a=e.getClearColor(new f.Color);e.setClearColor(a,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const a=e.getClearColor(new f.Color);e.setClearColor(a,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 a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),d=h.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const u=(s-r-1)*i*4,g=r*i*4;d.set(p.subarray(u,u+i*4),g)}return c.putImageData(h,0,0),n.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 Tc="shop-components",Sc="0.4.17",Mc="Shop components",Cc="dist/shop-components.umd.js",Rc="dist/shop-components.mjs",Ic="dist/main.d.ts",Dc={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"},Lc=["dist","package.json"],Pc=[],Fc="machengda<machengda@seer-group.com>",Ec="ISC",Bc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},kc={"string-width":"4.2.3"},Oc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.182.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"0.182.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},zc={name:Tc,version:Sc,description:Mc,main:Cc,module:Rc,types:Ic,scripts:Dc,files:Lc,keywords:Pc,author:Fc,license:Ec,devDependencies:Bc,resolutions:kc,dependencies:Oc};function dr(){const o="Nebula Engin",e=zc.version,t=`%c ${o} %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 pr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[pr]||(o[pr]=!0,dr())}catch{dr()}exports.Amr=Hr;exports.Logo=Qi;exports.SGLBLoader=Et;exports.SLOT_EVENTS=K;exports.Scene3D=Ac;exports.Skin=ss;exports.Slot=ji;exports.SlotState=Zr;exports.TriViewCapture=Kr;exports.arrayBufferToUrl=Gi;exports.calculateArrayAverage=Br;exports.calculateFocalLength=Ea;exports.createSGLBFile=Ga;exports.downloadBlob=Fa;exports.dracoExporter=Na;exports.font=xc;exports.gltfExporter=zr;exports.gltfLoader=He;exports.imageBitmapToUrl=qi;exports.isAppleDevice=kr;exports.textureLoader=fs;
|
|
3943
|
+
`):e.style.background="radial-gradient(326% 141% at 50% 103%, #E0E0E0 0%, #D9D9D9 38%, #C2C2C2 47%, #C2C2C2 52%, #F0F0F0 100%)",this._controlsGizmo&&this._controlsGizmo.appendTo(e),this.stats.dom.style.bottom="0",this.stats.dom.style.top="auto",this.resize(),this._resizeObserver=new ResizeObserver(this.resize.bind(this)),this._resizeObserver.observe(e)}add(e){this._container.add(e)}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,a,n,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(),(a=this._sciFiGrid.material)==null||a.dispose(),Le.removeAll(),this.stats.dom.remove(),this._emitter.removeAllListeners(),(n=this._fitAnimation)==null||n.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(),ge(this.scene),this.scene.clear()}}class Kr{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,y,m,v,_,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 a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((y=e==null?void 0:e.size)==null?void 0:y.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,h=(e==null?void 0:e.includeOverlay)??!1,d=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new f.WebGLRenderTarget(a,n,{format:f.RGBAFormat,type:f.UnsignedByteType});r.texture.colorSpace=f.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),u={};try{(v=(m=this.deps).onBeforeCapture)==null||v.call(m);const w=this.computeBounds(i);this.applyRendererState(t,a,n,e==null?void 0:e.backgroundColor);for(const b of p){const T=this.configureCamera(w,b,d,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,T),h&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,T));const S=this.readPixels(t,r,a,n);u[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(_=this.deps).onAfterCapture)==null||x.call(_)}return u}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,a=new f.Vector3,n=new f.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const d=c.geometry;if(!d)return;d.boundingBox||d.computeBoundingBox();const p=d.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new f.Vector3(.001,.001,.001)),a.set(.001,.001,.001),n.center.copy(s),n.radius=.001):(t.getCenter(s),t.getSize(a),t.getBoundingSphere(n)),(!Number.isFinite(n.radius)||n.radius<=0)&&(n.radius=Math.max(a.length()*.5,.001)),{box:t,center:s,size:a,sphere:n}}configureCamera(e,t,i,s,a,n){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),S=Math.max(Math.tan(T/2),1e-4),I=Math.max(S*(i||1),1e-4),C=this.getPerspectiveDirection(t,e.size).normalize(),L=new f.Vector3().crossVectors(C,h).normalize();L.lengthSq()<1e-6&&L.set(1,0,0);const R=new f.Vector3().crossVectors(L,C).normalize(),A=Math.max(e.size.x*.5,1e-4),M=Math.max(e.size.y*.5,1e-4),D=Math.max(e.size.z*.5,1e-4),P=[new f.Vector3(-A,-M,-D),new f.Vector3(-A,-M,D),new f.Vector3(-A,M,-D),new f.Vector3(-A,M,D),new f.Vector3(A,-M,-D),new f.Vector3(A,-M,D),new f.Vector3(A,M,-D),new f.Vector3(A,M,D)];let E=0,B=-1/0;for(const W of P){const j=L.dot(W),U=R.dot(W),Q=C.dot(W);B=Math.max(B,Q);const re=Q+Math.abs(j)/I,te=Q+Math.abs(U)/S;E=Math.max(E,re,te)}E=Math.max(E,B+.1);const V=E*(1+s);let N=1/0;for(const W of P){const j=C.dot(W),U=V-j;U>.001&&(N=Math.min(N,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(N)?N*.5:V*.1),w.far=Math.max(w.near+1,V+e.sphere.radius*3),w.position.copy(e.center).add(C.clone().multiplyScalar(V)),w.up.copy(R),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,u=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),y=Math.max(r[t.plane.depth]*.5,.01);let m=u*(1+s),v=g*(1+s);m/i>v?v=m/i:m=v*i;const _=y*(1+s)+Math.max(m,v),x=l.clone().add(c.multiplyScalar(_));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=_*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),a=new f.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new f.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),h=Math.max((t.x+t.y)*.5,.001),d=Math.max(t.z,.001),p=Math.max(n,s.z),r=d*.5+h*.5;return c.z=p*r,c.multiply(a),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 a=e.getClearColor(new f.Color),n=e.getClearAlpha();return{size:t,pixelRatio:e.getPixelRatio(),viewport:i,scissor:s,scissorTest:e.getScissorTest(),autoClear:e.autoClear,target:e.getRenderTarget(),clearColor:a,clearAlpha:n}}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 a=e.getClearColor(new f.Color);e.setClearColor(a,0)}else s instanceof f.Color?e.setClearColor(s,1):e.setClearColor(new f.Color(s),1);else{const a=e.getClearColor(new f.Color);e.setClearColor(a,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 a=i*s*4;(!this.pixelBuffer||this.pixelBuffer.length!==a)&&(this.pixelBuffer=new Uint8Array(a)),e.readRenderTargetPixels(t,0,0,i,s,this.pixelBuffer);const n=this.ensureCanvas(i,s),c=n.getContext("2d");if(!c)throw new Error("TriViewCapture: failed to get 2D context.");const h=c.createImageData(i,s),d=h.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const u=(s-r-1)*i*4,g=r*i*4;d.set(p.subarray(u,u+i*4),g)}return c.putImageData(h,0,0),n.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 Tc="shop-components",Sc="0.4.19",Mc="Shop components",Cc="dist/shop-components.umd.js",Rc="dist/shop-components.mjs",Ic="dist/main.d.ts",Dc={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"},Lc=["dist","package.json"],Pc=[],Fc="machengda<machengda@seer-group.com>",Ec="ISC",Bc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},kc={"string-width":"4.2.3"},Oc={"@nodetoy/three-nodetoy":"^0.1.36","@tweakpane/core":"^2.0.3","@tweenjs/tween.js":"^23.1.2","@types/bezier-js":"^4.1.1","@types/howler":"^2.2.11","@types/three":"0.182.0","bezier-js":"^6.1.4",eventemitter3:"^5.0.1",howler:"^2.2.4","stats-fps.js":"0.0.6",stylus:"^0.63.0",terser:"^5.44.0",three:"0.182.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},zc={name:Tc,version:Sc,description:Mc,main:Cc,module:Rc,types:Ic,scripts:Dc,files:Lc,keywords:Pc,author:Fc,license:Ec,devDependencies:Bc,resolutions:kc,dependencies:Oc};function dr(){const o="Nebula Engin",e=zc.version,t=`%c ${o} %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 pr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[pr]||(o[pr]=!0,dr())}catch{dr()}exports.Amr=Hr;exports.Logo=Qi;exports.SGLBLoader=Et;exports.SLOT_EVENTS=K;exports.Scene3D=Ac;exports.Skin=ss;exports.Slot=ji;exports.SlotState=Zr;exports.TriViewCapture=Kr;exports.arrayBufferToUrl=Gi;exports.calculateArrayAverage=Br;exports.calculateFocalLength=Ea;exports.createSGLBFile=Ga;exports.downloadBlob=Fa;exports.dracoExporter=Na;exports.font=xc;exports.gltfExporter=zr;exports.gltfLoader=He;exports.imageBitmapToUrl=qi;exports.isAppleDevice=kr;exports.textureLoader=fs;
|
package/dist/shop-components.mjs
CHANGED
|
@@ -10090,7 +10090,7 @@ class gc extends oi {
|
|
|
10090
10090
|
if (i.userData.isShelf && (this._shelf = i), i.userData.isFork && (this._fork = i), i.userData.isMast && i.userData.mastLevel && this._masts.set(i.userData.mastLevel, i), i.userData.isJack && (this._jack = i), i.userData.isLift && (this._lift = i), i.userData.isRollerLevel && this._rollerLevel.set(i.userData.level || 0, i), i.userData.isCenterModel && (i.visible = this.useCenterModel), i.userData.isSwitch && i.userData.switchName === "top" && (this._rollerTop = i), i.userData.isLiftBracket && (this._liftBrackets.push(i), i.visible = this._useLift), i.userData.isBaffle && (this._rollerBaffle = i, i.visible = !this._useLift), i.userData.isRoller && (this._roller = i, this._roller.visible = !1, this._generateRollers()), i.userData.isRollerLevelBox) {
|
|
10091
10091
|
this._rollerGoodsBox = i;
|
|
10092
10092
|
const s = new at(this._goodsSize.width, this._goodsSize.length, this._goodsSize.height);
|
|
10093
|
-
this.goods.push(s);
|
|
10093
|
+
i.add(s), this.goods.push(s);
|
|
10094
10094
|
}
|
|
10095
10095
|
Object.keys(i.morphTargetDictionary || {}).forEach((s) => {
|
|
10096
10096
|
let a = i.morphTargetInfluences[i.morphTargetDictionary[s]];
|
|
@@ -14102,7 +14102,7 @@ class Oh {
|
|
|
14102
14102
|
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;
|
|
14103
14103
|
}
|
|
14104
14104
|
}
|
|
14105
|
-
const zh = "shop-components", Uh = "0.4.
|
|
14105
|
+
const zh = "shop-components", Uh = "0.4.19", Hh = "Shop components", Wh = "dist/shop-components.umd.js", Nh = "dist/shop-components.mjs", Vh = "dist/main.d.ts", Gh = {
|
|
14106
14106
|
dts: "tsc --emitDeclarationOnly & tsc & storybook build -o dist",
|
|
14107
14107
|
dev: "vite dev",
|
|
14108
14108
|
build: "vite build",
|