shop-components 0.4.10 → 0.4.12

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.
@@ -129,6 +129,9 @@ export declare class Amr extends Object3D {
129
129
  setRoller(): void;
130
130
  get isTopInvert(): boolean | undefined;
131
131
  setTopInvert(invert?: boolean): void;
132
+ private _levelCount;
133
+ get levels(): number;
134
+ setLevels(levels: number): void;
132
135
  setRollerHeight(level: number, height: number): void;
133
136
  private _generateRollers;
134
137
  getShelfMinHeight(): number;
@@ -6,6 +6,7 @@ export interface SlotProps {
6
6
  name: string;
7
7
  follows: Map<string, {
8
8
  scale: number;
9
+ initPos: Vector3;
9
10
  origin: number;
10
11
  }>;
11
12
  slot: Object3D;
@@ -3728,7 +3728,7 @@ ${t.name}`)}break}}}}else a.texture_lod=0}};ie=new WeakMap,be=new WeakMap,di=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",Nr);const Y={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 Xi extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new mt,this._slotContainer=new d.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 d.Vector3,this._wrapper=new d.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 Nr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(Y.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(Y.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(Y.ON_DROP,this)}catch(c){this._emitter.emit(Y.ON_DROP_ERROR,c)}}else this._emitter.emit(Y.ON_DROP_ERROR,new Error("No device info"))})}get hasDevice(){return this._slotContainer.children.length>0}get isMirror(){return this._isMirror}shapeKeyChanged(e,t){var i;if(this.props.follows.has(e)){const s=this.props.follows.get(e);if(s){let a="x";["height","mast"].includes(e)?a="z":["width","liftOuterWidth"].includes(e)&&(a="y");const n=((i=this.props.slot)==null?void 0:i.position[a])-s.origin-t>0?1:-1;this._wrapper.position[a]=(t-s.origin)*s.scale*n}}}async loadGlb(e){const i=await new kt({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new kt({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(Y.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(Y.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(Y.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.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(),_e(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(Y.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(Y.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(Y.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(Y.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.clearSlot(),this._emitter.removeAllListeners(),_e(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 d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(n=34,c=60,u=60),a<u){let f=(u-a)*1+n;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(n)}clone(e){return new d.Group}}class sl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=gs(),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 u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ai extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new sl(""),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;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.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 d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0)),n.normalize();const c=new d.Vector3().addVectors(e,n.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,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 d.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=>_e(e)),this.removeFromParent()}}class Gr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new rl(""),this._line=new ai(void 0,!1,!1),this._box=new d.Mesh,this._arc=new xn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new Ms.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new wn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.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 d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.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 d.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 u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}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 f=0;f<=n;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new Ms.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class rl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=gs();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 nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",ir="data:image/png;base64,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",al="data:image/png;base64,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";class sr extends ve.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 mt,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 u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=gs();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(${ir}) 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(${ir}) 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:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${al}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${ol}) 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 _=document.createElement("div");_.style.background=`url(${nl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).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=f/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 hi(l.rotation).to({z:v}).duration(u).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 ve.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof ve.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class ll extends bn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new mt,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,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=u=>{this.endNode.releasePointerCapture(u.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 cl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new ai("长:"),this._line12=new ai("宽:"),this._line13=new ai("高:"),this._outline=new Gr(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 ve.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 ve.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}=Qa(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 u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class rr extends d.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){_e(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new d.Mesh(new d.BoxGeometry(e,t,i),new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new d.EdgesGeometry(s.geometry),n=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),c=new d.LineSegments(a,n);c.computeLineDistances(),this.add(s,c)}}const ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Ki{constructor(e){this._props=e,this.name="",this.transparentTexture=vs.load(ul),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 d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;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 d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.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 nr(o){return o.type?o.type==="Mesh":o.isMesh}const vs=new d.TextureLoader;vs.crossOrigin="anonymous";class qr extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new mt,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new cl,this._goodsSize=new Za(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],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._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 d.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((e=this._lift)==null?void 0:e.position.z)||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(){var e;return((e=this._centerModel)==null?void 0:e.visible)??!1}set useCenterModel(e){this._centerModel&&(this._centerModel.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 d.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 d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Xi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.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("topLength",a),this.isTopInvert){const n=i-.257;this.setShapeKey("width",n)}else this.setShapeKey("length",a);this._generateRollers()}if(t==="goodsWidth"){const s=i+.193;this.setShapeKey("boxWidth",s);const a=i+.219;if(this.setShapeKey("topWidth",a),this.isTopInvert){const n=i+.62;this.setShapeKey("length",n)}else this.setShapeKey("width",a);this._generateRollers()}})}_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 u=await He.loadAsync(e);i=u.animations||[],s=u.scene}else if(t==="sglb"||e.endsWith(".sglb")){const f=await new kt({useCache:!0}).loadAsync(e);i=f.animations||[],s=f.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 d.AnimationMixer(this._modelRoot));const c=typeof wi.retargetClip=="function";i.forEach(u=>{let f=u;if(c&&a&&n)try{f=wi.retargetClip(n,a,u)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",u.name,r)}this._clips=this._clips.filter(r=>r.name!==f.name),this._clips.push(f);const p=this._mixer.clipAction(f);this._actionsMap.set(f.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 kt({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=wi.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 d.Vector2(t.scaleX,t.scaleY),new d.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 u;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(u=a.morphTargetDictionary)==null?void 0:u[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.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 d.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){const s=`1-${i.userData.level||0}`;this._rollerLevel.set(s,i)}i.userData.isLift&&(this._lift=i),i.userData.isCenterModel&&(i.visible=!1,this._centerModel=i),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&this._liftBrackets.push(i),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!1),i.userData.isRoller&&(this._roller=i,this._generateRollers()),i.userData.isRollerLevelBox&&(this._rollerGoodsBox=i),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 d.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 as({name:a.userData.name,target:a})))});else{if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Fe.Tween(i.material).to({emissiveIntensity:.2}).easing(Fe.Easing.Quintic.InOut).duration(a),c=new Fe.Tween(i.material).to({emissiveIntensity:2}).easing(Fe.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 as({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 u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Zi(i.material.map.image));const f=new Ki({name:n.userData.name,target:i,size:Js(i),imageSize:u,imageUrl:c});this._logos.push(f)}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=Zi(i.material.map.image));const u=new Ki({name:a.userData.name,target:i,size:Js(i),imageSize:c,imageUrl:n});this._logos.push(u)}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){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),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()}setRoller(){this._goodsSize}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.length),this.setShapeKey("goodsLength",this.goodsSize.width))}setRollerHeight(e,t){const i=this._rollerLevel.get(`1-${e}`);i&&(i.position.z=t)}_generateRollers(){var p,r;if(!this._roller)return;(((p=this._roller.parent)==null?void 0:p.children.filter(l=>l.userData.isCloned))||[]).forEach(l=>{_e(l),l.removeFromParent()});let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s;if(n<0){this._roller.visible=!1;return}else this._roller.visible=!0;const c=i+s;let u=Math.floor(n/c);const f=n%c;if(u>0){u>1&&(s+=f/(u+2));const l=i+s,h=-t/2+s+i/2;for(let g=0;g<u;g++){let _=this._roller;g>0&&(_=this._roller.clone(!0),_.userData.isCloned=!0),_.position.y=h+l*g,(r=this._roller.parent)==null||r.add(_);const m=this._shapeKeyTargets.get("goodsWidth");m&&_.traverse(v=>{nr(v)&&m.push(v)})}}}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=>{_e(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(u=>{nr(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"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(u=>{u.userData.isShelfContainer&&(c=u)}),(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 u=new rr(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new rr(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}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 Gr(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(u=>{u.name===i&&(n=u)}),!n)return;const c=new sr({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(u=>{u.name===i&&(n=u)}),!n)return;const c=new sr({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",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=qa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new d.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new d.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new d.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 ll({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 u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Xi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(Y.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(Y.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(Y.ON_ERROR_STATE_CHANGE,h=>{var _;if(!this._app)return;const g=(_=this._app)==null?void 0:_._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),h){if(l.device){if(g.selectedObjects.find(v=>{var y;return v.parent===((y=l.device)==null?void 0:y.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=[],_e(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),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._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._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,u=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const f=(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(f?d.LoopRepeat:d.LoopOnce,f?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!f,s.play();const p=(t==null?void 0:t.timeScale)??1;return u?(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=h=>{var g;h.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 jr=0,hl=1,fl=2,or=2,Li=1.25,ar=1,Ft=6*4+4+4,vi=65535,dl=Math.pow(2,-24),Pi=Symbol("SKIP_GENERATION");function pl(o){return o.index?o.index.count:o.attributes.position.count}function gt(o){return pl(o)/3}function ml(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function gl(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=ml(t,i);o.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Qr(o){const e=gt(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 Yr(o){if(!o.groups||!o.groups.length)return Qr(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 u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const n=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<n.length-1;c++){const u=n[c],f=n[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function vl(o){if(o.groups.length===0)return!1;const e=gt(o),t=Yr(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 Fi(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=o[v+0],w=o[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],C=o[v+3],M=S-C,I=S+C;M<n&&(n=M),I>f&&(f=I),S<l&&(l=S),S>_&&(_=S);const D=o[v+4],T=o[v+5],R=D-T,L=D+T;R<c&&(c=R),L>p&&(p=L),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=n,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function _l(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=gt(o),c=s.normalized;let u;e===null?(u=new Float32Array(n*6*4),t=0,i=n):(u=e,t=t||0,i=i||n);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let S=w;b<S&&(S=b),A<S&&(S=A);let C=w;b>C&&(C=b),A>C&&(C=A);const M=(C-S)/2,I=x*2;u[_+I+0]=S+M,u[_+I+1]=M+(Math.abs(S)+M)*dl}}return u}function q(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 lr(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 cr(o,e){e.set(o)}function ur(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 jt(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 At(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 xe=32,yl=(o,e)=>o.candidate-e.candidate,Re=new Array(xe).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Qt=new Float32Array(6);function xl(o,e,t,i,s,a){let n=-1,c=0;if(a===jr)n=lr(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===hl)n=lr(o),n!==-1&&(c=wl(t,i,s,n));else if(a===fl){const u=At(o);let f=Li*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/xe;if(s<xe/4){const v=[...Re];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:S,rightCacheBounds:C}=b;for(let M=0;M<3;M++)C[M]=1/0,C[M+3]=-1/0,S[M]=1/0,S[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;jt(w,t,A)}v.sort(yl);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 A=0;A<x;A++){const S=v[A];b>=S.candidate?jt(w,t,S.rightCacheBounds):(jt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,S=s-b.count,C=b.leftCacheBounds,M=b.rightCacheBounds;let I=0;A!==0&&(I=At(C)/u);let D=0;S!==0&&(D=At(M)/u);const T=ar+Li*(I*A+D*S);T<f&&(n=l,f=T,c=b.candidate)}}else{for(let x=0;x<xe;x++){const w=Re[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=xe&&(A=xe-1);const S=Re[A];S.count++,jt(x,t,S.bounds)}const v=Re[xe-1];cr(v.bounds,v.rightCacheBounds);for(let x=xe-2;x>=0;x--){const w=Re[x],b=Re[x+1];ur(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<xe-1;x++){const w=Re[x],b=w.count,A=w.bounds,C=Re[x+1].rightCacheBounds;b!==0&&(y===0?cr(A,Qt):ur(A,Qt,Qt)),y+=b;let M=0,I=0;y!==0&&(M=At(Qt)/u);const D=s-y;D!==0&&(I=At(C)/u);const T=ar+Li*(M*y+I*D);T<f&&(n=l,f=T,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function wl(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 Ei{constructor(){this.boundingData=new Float32Array(6)}}function bl(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)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 Al(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)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 re(o,e){return e[o+6]}function oe(o,e){return e[o+14]}function ae(o){return o+8}function le(o,e){return e[o+6]}function Zr(o,e){return e[o+7]}let Xr,Dt,li,Kr;const Tl=Math.pow(2,32);function Ji(o){return"count"in o?1:1+Ji(o.left)+Ji(o.right)}function Sl(o,e,t){return Xr=new Float32Array(t),Dt=new Uint32Array(t),li=new Uint16Array(t),Kr=new Uint8Array(t),$i(o,e)}function $i(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)Xr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Kr.set(new Uint8Array(n),o);for(let c=o,u=o+n.byteLength;c<u;c+=Ft){const f=c/2;ee(f,li)||(Dt[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return Dt[t+6]=n,li[i+14]=c,li[i+15]=vi,o+Ft}else{const n=e.left,c=e.right,u=e.splitAxis;let f;if(f=$i(o+Ft,n),f/4>Tl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Dt[t+6]=f/4,f=$i(f,c),Dt[t+7]=u,f}}function Ml(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,u=n.length;c<u;c++)n[c]=c;return n}function Cl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,h=l.index?l.index.array:null,g=p?Al:bl,_=gt(l),m=new Float32Array(6);let v=!1;const y=new Ei;return Fi(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,S,C=null,M=0){if(!v&&M>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||M>=a)return x(A+S),b.offset=A,b.count=S,b;const I=xl(b.boundingData,C,e,A,S,u);if(I.axis===-1)return x(A+S),b.offset=A,b.count=S,b;const D=g(r,h,e,A,S,I);if(D===A||D===A+S)x(A+S),b.offset=A,b.count=S;else{b.splitAxis=I.axis;const T=new Ei,R=A,L=D-A;b.left=T,Fi(e,R,L,T.boundingData,m),w(T,R,L,m,M+1);const F=new Ei,E=D,z=S-L;b.right=F,Fi(e,E,z,F.boundingData,m),w(F,E,z,m,M+1)}return b}}function Rl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=Ml(t,e.useSharedArrayBuffer),vl(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||gl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=_l(t),a=e.indirect?Qr(t):Yr(t);o._roots=a.map(n=>{const c=Cl(o,s,n.offset,n.count,e),u=Ji(c),f=new i(Ft*u);return Sl(0,c,f),f})}class Te{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 u=e[a][t];i=u<i?u:i,s=u>s?u: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],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Te.prototype.setFromBox=function(){const o=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){o.x=s.x*u+a.x*(1-u),o.y=s.y*f+a.y*(1-f),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 Il=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,n){const c=s.start,u=o,f=a.start,p=e;t.subVectors(c,f),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,n.x=v,n.y=y}}(),_s=function(){const o=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,n,c){Il(s,a,o);let u=o.x,f=o.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,n),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(f>=0&&f<=1){u<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(h);return}}}}(),Dl=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,n){const{radius:c,center:u}=a,{a:f,b:p,c:r}=n;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c))return!0;const _=n.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(n.containsPoint(v))return!0}return!1}}(),Ll=1e-15;function ki(o){return Math.abs(o)<Ll}class pe extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new Te),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Dl(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],u=n[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=n[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=n[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}pe.prototype.closestPointToSegment=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,n=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),_s(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(u,o),p=u.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(u)),Math.sqrt(r)}}();pe.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Array(3),i=new Te,s=new Te,a=new d.Vector3,n=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:S}=p;A.copy(y[b]),S.copy(y[(b+1)%3]),p.delta(n);const C=ki(m.distanceToPoint(A));if(ki(m.normal.dot(n))&&C){v.copy(p),x=2;break}const M=m.intersectLine(p,h);if(!M&&C&&h.copy(A),(M||C)&&!ki(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),C&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!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,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let M=0;M<4;M++){const I=b[M],D=A[M];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const S=m.satBounds,C=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let M=0;M<4;M++){const I=S[M],D=C[M];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let M=0;M<4;M++){const I=A[M];for(let D=0;D<4;D++){const T=C[D];if(a.crossVectors(I,T),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||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 A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let R=l.start;l.start=l.end,l.end=R}const S=r.start.dot(c),C=r.end.dot(c),M=l.start.dot(c),I=l.end.dot(c),D=C<M,T=S<I;return S!==I&&M!==C&&D===T?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();pe.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();pe.prototype.distanceToTriangle=function(){const o=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(n,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(n,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=n[h];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),u&&u.copy(g));const _=this[h];n.closestPointToPoint(_,o),l=_.distanceToSquared(o),l<p&&(p=l,c&&c.copy(_),u&&u.copy(o))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(n[_],n[m]),_s(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),u&&u.copy(e))}}return Math.sqrt(p)}}();class K{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new Te),this.alignedSatBounds=new Array(3).fill().map(()=>new Te),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}}K.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=n[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();K.prototype.intersectsBox=function(){const o=new Te;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 u=0;u<3;u++){const f=n[u],p=a[u];if(o.setFromBox(f,t),p.isSeparated(o))return!1}return!0}}();K.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Te,i=new Te,s=new d.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,u=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();K.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}}();K.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();K.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(n,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(u||f)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=n.min,l=n.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,S=h[b],C=h[A];e[_].set(S,C);const I=o[m],D=o[x],T=o[w],R=t[_],L=R.start,F=R.end;L[I]=r[I],L[D]=v?r[D]:l[D],L[T]=y?r[T]:l[D],F[I]=l[I],F[D]=v?r[D]:l[D],F[T]=y?r[T]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];_s(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class ys{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 Pl extends ys{constructor(){super(()=>new pe)}}const ce=new Pl;class Fl{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 H=new Fl;let Ee,lt;const Ye=[],Yt=new ys(()=>new d.Box3);function El(o,e,t,i,s,a){Ee=Yt.getPrimitive(),lt=Yt.getPrimitive(),Ye.push(Ee,lt),H.setBuffer(o._roots[e]);const n=es(0,o.geometry,t,i,s,a);H.clearBuffer(),Yt.releasePrimitive(Ee),Yt.releasePrimitive(lt),Ye.pop(),Ye.pop();const c=Ye.length;return c>0&&(lt=Ye[c-1],Ee=Ye[c-2]),n}function es(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:u,uint32Array:f}=H;let p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);return q(o,c,Ee),i(l,h,!1,n,a+o,Ee)}else{let I=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=ae(T),F=T*2;return re(T,L)},D=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=le(T,L),F=T*2;return re(T,L)+oe(F,R)};const l=ae(o),h=le(o,f);let g=l,_=h,m,v,y,x;if(s&&(y=Ee,x=lt,q(g,c,y),q(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const T=m;m=v,v=T,y=x}y||(y=Ee,q(g,c,y));const w=ee(g*2,u),b=t(y,w,m,n+1,a+g);let A;if(b===or){const T=I(g),L=D(g)-T;A=i(T,L,!0,n+1,a+g,y)}else A=b&&es(g,e,t,i,s,a,n+1);if(A)return!0;x=lt,q(_,c,x);const S=ee(_*2,u),C=t(x,S,v,n+1,a+_);let M;if(C===or){const T=I(_),L=D(_)-T;M=i(T,L,!0,n+1,a+_,x)}else M=C&&es(_,e,t,i,s,a,n+1);return!!M}}const Tt=new d.Vector3,Bi=new d.Vector3;function kl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,u=null;if(o.shapecast({boundsTraverseOrder:p=>(Tt.copy(e).clamp(p.min,p.max),Tt.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,Tt);const l=e.distanceToSquared(Tt);return l<c&&(Bi.copy(Tt),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Bi):t.point=Bi.clone(),t.distance=f,t.faceIndex=u,t}const Ze=new d.Vector3,Xe=new d.Vector3,Ke=new d.Vector3,Zt=new d.Vector2,Xt=new d.Vector2,Kt=new d.Vector2,hr=new d.Vector3,fr=new d.Vector3,dr=new d.Vector3,Jt=new d.Vector3;function Bl(o,e,t,i,s,a,n,c){let u;if(a===d.BackSide?u=o.intersectTriangle(i,t,e,!0,s):u=o.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=o.origin.distanceTo(s);return f<n||f>c?null:{distance:f,point:s.clone()}}function Ol(o,e,t,i,s,a,n,c,u,f,p){Ze.fromBufferAttribute(e,a),Xe.fromBufferAttribute(e,n),Ke.fromBufferAttribute(e,c);const r=Bl(o,Ze,Xe,Ke,Jt,u,f,p);if(r){i&&(Zt.fromBufferAttribute(i,a),Xt.fromBufferAttribute(i,n),Kt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,Zt,Xt,Kt,new d.Vector2)),s&&(Zt.fromBufferAttribute(s,a),Xt.fromBufferAttribute(s,n),Kt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,Zt,Xt,Kt,new d.Vector2)),t&&(hr.fromBufferAttribute(t,a),fr.fromBufferAttribute(t,n),dr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,hr,fr,dr,new d.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ze,Xe,Ke,l.normal),r.face=l,r.faceIndex=a}return r}function _i(o,e,t,i,s,a,n){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=o.index;o.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=o.attributes,m=Ol(t,l,h,g,_,u,f,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Q(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),n.x=i.getX(f),n.y=i.getY(f),n.z=i.getZ(f)}function zl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++)_i(u,e,t,p,a,n,c)}function Vl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=_i(c,e,t,r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Wl(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,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=3*v,I=3*(v+y);M<I;M++){let D=i[M];const T=s.getX(D),R=s.getY(D),L=s.getZ(D);T<x&&(x=T),T>A&&(A=T),R<w&&(w=R),R>S&&(S=R),L<b&&(b=L),L>C&&(C=L)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function ke(o,e,t,i,s){let a,n,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[o],y=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],A=e[o+3+2];return r>=0?(a=(v-g)*r,n=(y-g)*r):(a=(y-g)*r,n=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>n||((c>a||isNaN(a))&&(a=c),(u<n||isNaN(n))&&(n=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>n)?!1:((f>a||a!==a)&&(a=f),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function Hl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;_i(u,e,t,l,a,n,c)}}function Nl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=_i(c,e,t,u?u[r]:r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Gl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function ql(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),ts(0,o,t,i,s,a,n),H.clearBuffer()}function ts(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);zl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&ts(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&ts(h,e,t,i,s,a,n)}}const jl=["x","y","z"];function Ql(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=is(0,o,t,i,s,a);return H.clearBuffer(),n}function is(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=jl[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?is(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?is(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const $t=new d.Box3,Je=new pe,$e=new pe,St=new d.Matrix4,pr=new K,ei=new K;function Yl(o,e,t,i){H.setBuffer(o._roots[e]);const s=ss(0,o,t,i);return H.clearBuffer(),s}function ss(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),pr.set(t.boundingBox.min,t.boundingBox.max,i),s=pr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(St.copy(i).invert(),t.boundsTree)return q(o,a,ei),ei.matrix.copy(St),ei.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ei.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(Q($e,x,r,l),$e.needsUpdate=!0,y.intersectsTriangle($e))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){Q(Je,v,r,l),Je.a.applyMatrix4(St),Je.b.applyMatrix4(St),Je.c.applyMatrix4(St),Je.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(Q($e,x,h,g),$e.needsUpdate=!0,Je.intersectsTriangle($e))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,$t),!!(s.intersectsBox($t)&&ss(p,e,t,i,s)||(q(r,a,$t),s.intersectsBox($t)&&ss(r,e,t,i,s)))}}const ti=new d.Matrix4,Oi=new K,Mt=new K,Zl=new d.Vector3,Xl=new d.Vector3,Kl=new d.Vector3,Jl=new d.Vector3;function $l(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Oi.set(e.boundingBox.min,e.boundingBox.max,t),Oi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=Zl,_=Xl,m=null,v=null;s&&(m=Kl,v=Jl);let y=1/0,x=null,w=null;return ti.copy(t).invert(),Mt.matrix.copy(ti),o.shapecast({boundsTraverseOrder:b=>Oi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Mt.min.copy(b.min),Mt.max.copy(b.max),Mt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:C=>Mt.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){Q(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let T=b,R=b+A;T<R;T++){Q(l,3*T,f,u),l.needsUpdate=!0;const L=l.distanceToTriangle(h,g,m);if(L<y&&(_.copy(g),v&&v.copy(m),y=L,x=T,w=I),L<a)return!0}}}});{const S=gt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){Q(l,3*I,f,u),l.needsUpdate=!0;const T=l.distanceToTriangle(h,g,m);if(T<y&&(_.copy(g),v&&v.copy(m),y=T,x=I,w=C),T<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ti),_.applyMatrix4(ti),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function ec(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,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=v,I=v+y;M<I;M++){const D=3*o.resolveTriangleIndex(M);for(let T=0;T<3;T++){let R=D+T;R=i?i[R]:R;const L=s.getX(R),F=s.getY(R),E=s.getZ(R);L<x&&(x=L),L>A&&(A=L),F<w&&(w=F),F>S&&(S=F),E<b&&(b=E),E>C&&(C=E)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function tc(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),rs(0,o,t,i,s,a,n),H.clearBuffer()}function rs(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);Hl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&rs(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&rs(h,e,t,i,s,a,n)}}const ic=["x","y","z"];function sc(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=ns(0,o,t,i,s,a);return H.clearBuffer(),n}function ns(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Nl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=ic[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?ns(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?ns(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ii=new d.Box3,et=new pe,it=new pe,Ct=new d.Matrix4,mr=new K,si=new K;function rc(o,e,t,i){H.setBuffer(o._roots[e]);const s=os(0,o,t,i);return H.clearBuffer(),s}function os(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),mr.set(t.boundingBox.min,t.boundingBox.max,i),s=mr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(Ct.copy(i).invert(),t.boundsTree)return q(o,a,si),si.matrix.copy(Ct),si.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>si.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(Q(it,3*e.resolveTriangleIndex(x),r,l),it.needsUpdate=!0,y.intersectsTriangle(it))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);Q(et,3*x,r,l),et.a.applyMatrix4(Ct),et.b.applyMatrix4(Ct),et.c.applyMatrix4(Ct),et.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(Q(it,w,h,g),it.needsUpdate=!0,et.intersectsTriangle(it))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,ii),!!(s.intersectsBox(ii)&&os(p,e,t,i,s)||(q(r,a,ii),s.intersectsBox(ii)&&os(r,e,t,i,s)))}}const ri=new d.Matrix4,zi=new K,Rt=new K,nc=new d.Vector3,oc=new d.Vector3,ac=new d.Vector3,lc=new d.Vector3;function cc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),zi.set(e.boundingBox.min,e.boundingBox.max,t),zi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=nc,_=oc,m=null,v=null;s&&(m=ac,v=lc);let y=1/0,x=null,w=null;return ri.copy(t).invert(),Rt.matrix.copy(ri),o.shapecast({boundsTraverseOrder:b=>zi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Rt.min.copy(b.min),Rt.max.copy(b.max),Rt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:C=>Rt.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){const T=S.resolveTriangleIndex(I);Q(h,3*T,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,L=b+A;R<L;R++){const F=o.resolveTriangleIndex(R);Q(l,3*F,f,u),l.needsUpdate=!0;const E=l.distanceToTriangle(h,g,m);if(E<y&&(_.copy(g),v&&v.copy(m),y=E,x=R,w=I),E<a)return!0}}}})}else{const S=gt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){const T=o.resolveTriangleIndex(I);Q(l,3*T,f,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=I,w=C),R<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ri),_.applyMatrix4(ri),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function uc(){return typeof SharedArrayBuffer<"u"}const Et=new H.constructor,fi=new H.constructor,De=new ys(()=>new d.Box3),st=new d.Box3,rt=new d.Box3,Vi=new d.Box3,Ui=new d.Box3;let Wi=!1;function hc(o,e,t,i){if(Wi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Wi=!0;const s=o._roots,a=e._roots;let n,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Et.setBuffer(s[p]),u=0;const l=De.getPrimitive();q(0,Et.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(fi.setBuffer(a[p]),n=fe(0,0,t,f,i,c,u,0,0,l),fi.clearBuffer(),u+=a[h].length,!n);h++);if(De.releasePrimitive(l),Et.clearBuffer(),c+=s[p].length,n)break}return Wi=!1,n}function fe(o,e,t,i,s,a=0,n=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=fi,l=Et):(r=Et,l=fi);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=o*2,w=e*2,b=ee(x,_),A=ee(w,y);let S=!1;if(A&&b)p?S=s(re(e,v),oe(e*2,y),re(o,g),oe(o*2,_),u,n+e,c,a+o):S=s(re(o,g),oe(o*2,_),re(e,v),oe(e*2,y),c,a+o,u,n+e);else if(A){const C=De.getPrimitive();q(e,m,C),C.applyMatrix4(t);const M=ae(o),I=le(o,g);q(M,h,st),q(I,h,rt);const D=C.intersectsBox(st),T=C.intersectsBox(rt);S=D&&fe(e,M,i,t,s,n,a,u,c+1,C,!p)||T&&fe(e,I,i,t,s,n,a,u,c+1,C,!p),De.releasePrimitive(C)}else{const C=ae(e),M=le(e,v);q(C,m,Vi),q(M,m,Ui);const I=f.intersectsBox(Vi),D=f.intersectsBox(Ui);if(I&&D)S=fe(o,C,t,i,s,a,n,c,u+1,f,p)||fe(o,M,t,i,s,a,n,c,u+1,f,p);else if(I)if(b)S=fe(o,C,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Vi).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,st),q(L,h,rt);const F=T.intersectsBox(st),E=T.intersectsBox(rt);S=F&&fe(C,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(C,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}else if(D)if(b)S=fe(o,M,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Ui).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,st),q(L,h,rt);const F=T.intersectsBox(st),E=T.intersectsBox(rt);S=F&&fe(M,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(M,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}}return S}const ni=new K,gr=new d.Box3,fc={strategy:jr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class xs{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(u=>u.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 xs(t,{...i,[Pi]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.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({...fc,[Pi]:!1},t),t.useSharedArrayBuffer&&!uc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Pi]||(Rl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?ec:Wl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,u=0){const f=c*2,p=a[f+15]===vi;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Ft/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(n(r,u+1),n(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=n.groups,r=u?t.side:t,l=this.indirect?tc:ql;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=n.groups,r=c?t.side:t,l=this.indirect?sc:Ql;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?rc:Yl;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=ce.getPrimitive(),i=this.indirect?Gl:Ul;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else n||(c?n=(r,l,h,g)=>i(r,l,this,c,h,g,t):n=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=El(this,r,a,n,s,f),u)break;f+=h.byteLength}return ce.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=ce.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);Q(n,_*3,c,u)}:g=>{Q(n,g*3,c,u)},p=ce.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);Q(p,_*3,r,l)}:g=>{Q(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let S=v,C=v+y;S<C;S++){h(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let M=_,I=_+m;M<I;M++)if(f(M),n.needsUpdate=!0,a(n,p,M,S,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,S){return _(m,v,y,x,w,b,A,S)?!0:g(m,v,y,x,w,b,A,S)}}else s=g}return hc(this,e,t,s)}intersectsBox(e,t){return ni.set(e.min,e.max,t),ni.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ni.intersectsBox(i),intersectsTriangle:i=>ni.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?cc:$l)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return kl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{q(0,new Float32Array(i),gr),e.union(gr)}),e}}class dc{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 pc extends dc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:dt&&dt.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=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=xs.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 _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];n&&u.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class mc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new mt,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:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*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,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){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 u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"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 d.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 d.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",Nr);const Y={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 Xi extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._emitter=new mt,this._slotContainer=new d.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 d.Vector3,this._wrapper=new d.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 Nr({name:e.name,isMobile:e.isMobile,onRemove:()=>{this.clearSlot(),this._emitter.emit(Y.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(Y.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(Y.ON_DROP,this)}catch(c){this._emitter.emit(Y.ON_DROP_ERROR,c)}}else this._emitter.emit(Y.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 kt({useCache:!0}).loadAsync(e);if(i.glb)return i.glb.clone(!0)}async installBracket(e){const i=await new kt({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(Y.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(Y.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(Y.ON_FUNCTION_ADDED,e))}removeFunction(e){this._functions.has(e)&&(this._functions.delete(e),this._slotUI.functions=[...this.functions],this._emitter.emit(Y.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(),_e(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(Y.ON_BEFORE_SELECTED,e),this._selected=e,this._slotUI.selected=e,this._emitter.emit(Y.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(Y.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(Y.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(),_e(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 d.Vector2(parseFloat(i[1]),parseFloat(i[2])),a=e.mousePos.distanceTo(s);let n=this.props.isMobile?12:18,c=38,u=30;if(this._canInstall&&(n=34,c=60,u=60),a<u){let f=(u-a)*1+n;a<20&&(f=c),f>c&&(f=c),this._slotUI.setSize(f)}else this._slotUI.setSize(n)}clone(e){return new d.Group}}class sl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._text=document.createElement("div");const i=gs(),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 u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor="#666",this._text.style.color="#000",(u=this.onPointMove)==null||u.call(this)}),this._text.addEventListener("pointerleave",()=>{var u;n.style.borderColor=c.style.borderColor=this.element.style.borderColor=s,this._text.style.transform="scale(1)",this._text.style.color="#fff",(u=this.onPointLeave)==null||u.call(this)})}set text(e){this._text.innerText=e}dispose(){this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}}class ai extends d.Group{constructor(e,t=!0,i=!0){super(),this._startWith=e,this._showText=t,this.useStartEnd=i,this._line2Length=.01,this._line=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._line2=new d.LineSegments(new d.BufferGeometry,new d.LineBasicMaterial({color:"#666",linewidth:2})),this._text=new sl(""),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;(e=this._line.geometry)==null||e.dispose(),this._line.computeLineDistances()}update(e,t,i=0){var h,g;(h=this._line.geometry)==null||h.dispose(),this._line.geometry.setFromPoints([e,t]),this._line.computeLineDistances();const s=this._line2Length+i*.02,a=new d.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 d.Vector3(-a.y,a.x,0):Math.abs(a.y)>Math.abs(a.x)?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0),n.length()<.001&&(Math.abs(a.x)<.9?n=new d.Vector3(1,0,0):n=new d.Vector3(0,1,0)),n.normalize();const c=new d.Vector3().addVectors(e,n.clone().multiplyScalar(s)),u=new d.Vector3().addVectors(e,n.clone().multiplyScalar(-s)),f=new d.Vector3().addVectors(t,n.clone().multiplyScalar(s)),p=new d.Vector3().addVectors(t,n.clone().multiplyScalar(-s));(g=this._line2.geometry)==null||g.dispose(),this._line2.geometry=new d.BufferGeometry,this._line2.geometry.setFromPoints([c,u,f,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 d.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=>_e(e)),this.removeFromParent()}}class Gr extends d.Object3D{constructor(e,t){super(),this.radius=e,this._text=new rl(""),this._line=new ai(void 0,!1,!1),this._box=new d.Mesh,this._arc=new xn.Line2,this._previousPosition=null,this._updateTimer=null,this._updateDelay=300,this._accumulatedAngle=0,this._lastAngle=null,this._line.updateMaterial(new d.LineDashedMaterial({color:"#555",dashSize:.06,gapSize:.06})),this._line.renderOrder=0,this._box.geometry=new d.RingGeometry(e,e+.003,128),this._box.material=new d.MeshBasicMaterial({color:"#666",side:d.DoubleSide}),this._arc.geometry=new Ms.LineGeometry,this._arc.geometry.setPositions([0,0,0,0,0,0]),this._arc.geometry.instanceCount=0,this._arc.material=new wn.LineMaterial({color:"#eee",linewidth:2,resolution:new d.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 d.RingGeometry(e,e+.003,128),this._line.updateMaterial(new d.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 d.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 u=i-this._lastAngle;u>Math.PI?u-=2*Math.PI:u<-Math.PI&&(u+=2*Math.PI),this._accumulatedAngle+=u}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 f=0;f<=n;f++){const p=e+f*c,r=Math.cos(p),l=Math.sin(p);s.push(i*r,0,i*l)}const u=new Ms.LineGeometry;return u.setPositions(s),u.instanceCount=Math.max(0,s.length/3-1),u}}class rl extends ve.CSS2DObject{constructor(e){const t=document.createElement("div");super(t),this._wrapper=document.createElement("div"),this._circle=document.createElement("div");const i=gs();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 nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAAUCAYAAADY6P5TAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAEvSURBVFiFzZdbFYMwEEQroRKQgAQkVEIlICEOkFAJlRAJSIgEJNx+sPS0nGxIaOhyv3nM7mTmwOViDHAFesADD+BqrakKQAcMwMQ3AWis9e1C3HLASJoAdNZ6sxG3/MZQMZy1dhWgFbfWRzDGlFjAwFlyyXdh5OD5OIqykBgBy1yiF0aMUQaJugLclOcEoP3nULmFgQgeyCwOoJGBYrijByspDM98ZIszJAt8Ks8dag/VUFYYLtetjHdruRz5JZf8WBg1Ae7KcgOluaSsMAKJwqgJ6Vz2WzcvhZHjVlFh1ESG1DQ67SYtyGs8OwujNpTkUtw4nVtbyLK1XDafF3aKW90Z3EpBbi5lE0u9n3qoNTKk9rHh3heZqqwA8Vw6a11VkVwuPK31HALzb5pfovYC2xSs5LCDIUcAAAAASUVORK5CYII=",ol="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAKCAYAAACngj4SAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAChSURBVDiNrdJbFYMwEIRhJFQCEpCAhEqIhDhBAlKQgAQkIOHrSziHpmkbLvua7P4zO9s0FYUeM0b0NT2nC9FnLQho7wQ9MOwgQ3K4ZPDrrtGmFcKKkL0HTAXXw2HX6HYuFnR/hMWC6ykX+W1AzJqq1abDGguux6LoPK9aUGFOm1Y+F+Bh+7DlsSKehRXgnfdDm5od7GdeN8ADnpuKQ3ldqReHZFd3742nZgAAAABJRU5ErkJggg==",ir="data:image/png;base64,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",al="data:image/png;base64,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";class sr extends ve.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 mt,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 u=this._initial+.005*c*this._direction;if(u>this.props.max||u<this.props.min){this.mechanism&&(u<this.props.min?(this.mechanism.position.setZ(this.props.min),this._emitter.emit("change",this.props.min)):u>this.props.max&&(this.mechanism.position.setZ(this.props.max),this._emitter.emit("change",this.props.max)));return}if(this._initial=u,!this.mechanism)return;this.mechanism.position.setZ(u),this._emitter.emit("change",u)}};const s=gs();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(${ir}) 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(${ir}) 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:u,rotateStep:f,rotateMax:p,rotateMin:r}=e.userData;let l;if(c&&(t.traverse(h=>{h.name===c.name&&(l=h)}),l)){const h=document.createElement("div");h.style.background=`url(${al}) center no-repeat`,h.style.backgroundSize="100% auto",h.style.position="absolute",h.style.top="-50%",h.style.left="-50%",h.style.width=s?"140px":"160px",h.style.height=s?"70px":"80px",h.style.transform="translateX(-50%) translateY(-50%)",i.append(h);const g=document.createElement("div");g.style.background=`url(${ol}) 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 _=document.createElement("div");_.style.background=`url(${nl}) center no-repeat`,_.style.backgroundSize="100% auto",_.style.width=_.style.height=s?"20px":"26px",_.style.position="absolute",g.style.left=_.style.right=s?"62px":"69px",_.style.top="0",_.style.transform="translateY(-50%)",_.style.marginBottom="5px",_.setAttribute("data-direction","right"),i.append(_),Array.from([g,_]).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=f/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 hi(l.rotation).to({z:v}).duration(u).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 ve.CSS2DObject&&(e.element.style.visibility="hidden")}),this.visible=!1}show(){this.element.style.display="auto",this.traverse(e=>{e.visible=!0,e instanceof ve.CSS2DObject&&(e.element.style.visibility="visible")}),this.visible=!0}dispose(){this._emitter.removeAllListeners(),cancelAnimationFrame(this._looper),this.element.remove()}}class ll extends bn.CSS3DObject{constructor(e){const t=document.createElement("div");super(t),this.props=e,this._scale=.01,this._emitter=new mt,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._mouseStart=new d.Vector2,this._targetSize=new d.Vector2,this._caches=[],this._sizeFlag="width",this._direction=1,this._lines=[],this._pointerdown=u=>{const{pageX:f,pageY:p}=u;this.endNode.setPointerCapture(u.pointerId),this._mouseStart.set(f,p),this._targetSize.setX(parseFloat(this.endNode.parentElement.style.width)),this._targetSize.setY(parseFloat(this.endNode.parentElement.style.height))},this._pointermove=u=>{if(!this._mouseStart.x)return;const{pageX:f,pageY:p}=u;let r=f-this._mouseStart.x,l=r+this._targetSize.x;this._sizeFlag==="height"&&(r=p-this._mouseStart.y,l=r*this._direction+this._targetSize.y);const h=l%10;l=l-h,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=u=>{this.endNode.releasePointerCapture(u.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 cl extends d.Object3D{constructor(){super(),this._box3=new d.Box3,this._line11=new ai("长:"),this._line12=new ai("宽:"),this._line13=new ai("高:"),this._outline=new Gr(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 ve.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 ve.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}=Qa(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 u=this._box3.min.x,f=this._box3.max.x,p=this._box3.min.z,r=this._box3.max.z,l=this._box3.min.y,h=this._box3.max.y;let g=.2;const _=new d.Vector3(u,h,0),m=new d.Vector3(f,h,0);this._line11.update(_.clone().sub(new d.Vector3(0,-g/1.8,0)),m.clone().sub(new d.Vector3(0,-g/1.8,0)),this._radius);const v=new d.Vector3(f,l,0);this._line12.update(m.clone().add(new d.Vector3(g,0,0)),v.clone().add(new d.Vector3(g,0,0)),this._radius);const y=new d.Vector3(u,h,p),x=new d.Vector3(u,h,r),w=y.clone();w.y-=g/6;const b=x.clone();b.y-=g/6,this._line13.update(w,b,this._radius)}}class rr extends d.Object3D{constructor(e=.6,t=.4,i=.2){super(),this.isGoods=!0,this._generate(e,t,i)}updateSize(e=.1,t=.1,i=.1){this._generate(e,t,i)}clearAll(){_e(this)}hide(){this.traverse(e=>e.visible=!1)}show(){this.traverse(e=>e.visible=!0)}_generate(e,t,i){this.clearAll();const s=new d.Mesh(new d.BoxGeometry(e,t,i),new d.MeshBasicMaterial({color:new d.Color("#0f5fd5"),transparent:!0,opacity:.4}));s.geometry.translate(0,0,i/2);const a=new d.EdgesGeometry(s.geometry),n=new d.LineDashedMaterial({color:new d.Color("#000"),dashSize:.015,gapSize:.015}),c=new d.LineSegments(a,n);c.computeLineDistances(),this.add(s,c)}}const ul="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARzQklUCAgICHwIZIgAAAALSURBVAiZY2AAAgAABQABYlUyiAAAAABJRU5ErkJggg==";class Ki{constructor(e){this._props=e,this.name="",this.transparentTexture=vs.load(ul),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 d.Vector2(1,1),i=new d.Vector2){this.imageUrl=e;let s;if(e){const a=new Image;a.crossOrigin="anonymous",a.src=e,a.onload=async()=>{var f;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 d.Texture(this._offscreen),s.minFilter=1003,s.colorSpace=d.SRGBColorSpace,s.wrapS=s.wrapT=d.ClampToEdgeWrapping,s.repeat.set(1/t.x,1/t.y),s.offset.set(i.x,i.y),s.flipY=!1,s.needsUpdate=!0;const u=this._props.target;u.material&&((f=u.material.map)==null||f.dispose(),s?(u.material.map=s,u.material.opacity=1):(u.material.map=this.transparentTexture,u.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 nr(o){return o.type?o.type==="Mesh":o.isMesh}const vs=new d.TextureLoader;vs.crossOrigin="anonymous";class qr extends d.Object3D{constructor(e){super(),this._props=e,this._emitter=new mt,this.addEventListener=this._emitter.addListener.bind(this._emitter),this._container=new d.Group,this.lines=new d.Group,this._clips=[],this._actionsMap=new Map,this._animationClock=new d.Clock,this.sizeBox=new cl,this._goodsSize=new Za(0,0,0),this._slots=[],this._logos=[],this._skins=[],this._levels=new Map,this._rollerLevel=new Map,this._liftBrackets=[],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._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 d.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((e=this._lift)==null?void 0:e.position.z)||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(){var e;return((e=this._centerModel)==null?void 0:e.visible)??!1}set useCenterModel(e){this._centerModel&&(this._centerModel.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 d.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 d.Mesh&&!s.userData.isDevice&&!s.userData.isBracket&&s.geometry.translate(this.sizeBox.originOffset-this.sizeBox.translateCache,0,0),s instanceof Xi&&!s.props.slot.userData.ignoreOriginChanged&&s.parent&&s.parent.position.add(new d.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);this._generateRollers()}})}_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 u=await He.loadAsync(e);i=u.animations||[],s=u.scene}else if(t==="sglb"||e.endsWith(".sglb")){const f=await new kt({useCache:!0}).loadAsync(e);i=f.animations||[],s=f.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 d.AnimationMixer(this._modelRoot));const c=typeof wi.retargetClip=="function";i.forEach(u=>{let f=u;if(c&&a&&n)try{f=wi.retargetClip(n,a,u)}catch(r){console.warn("[Amr.loadAnimation] 重定向动画失败,回退到原始 clip",u.name,r)}this._clips=this._clips.filter(r=>r.name!==f.name),this._clips.push(f);const p=this._mixer.clipAction(f);this._actionsMap.set(f.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 kt({useCache:!0}).loadAsync(e);if(!c.glb)return;i=c.glb}const a=wi.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 d.Vector2(t.scaleX,t.scaleY),new d.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 u;performance.now();let n=t;a.userData[`origin_${e}`]&&(n-=a.userData[`origin_${e}`]);const c=(u=a.morphTargetDictionary)==null?void 0:u[e];c!==void 0&&a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.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 d.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=>{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.isLift&&(this._lift=i),i.userData.isCenterModel&&(i.visible=!1,this._centerModel=i),i.userData.isSwitch&&i.userData.switchName==="top"&&(this._rollerTop=i),i.userData.isLiftBracket&&this._liftBrackets.push(i),i.userData.isBaffle&&(this._rollerBaffle=i,i.visible=!1),i.userData.isRoller&&(this._roller=i,this._generateRollers()),i.userData.isRollerLevelBox&&(this._rollerGoodsBox=i),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 d.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 as({name:a.userData.name,target:a})))});else{if(i.material.userData.isBreathLight&&i.material.emissiveIntensity){i.material.emissive||(i.material.emissive=new d.Color(16777215)),i.material.emissiveIntensity=2,i.material.toneMapped=!1;const a=1e3,n=new Fe.Tween(i.material).to({emissiveIntensity:.2}).easing(Fe.Easing.Quintic.InOut).duration(a),c=new Fe.Tween(i.material).to({emissiveIntensity:2}).easing(Fe.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 as({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 u={width:0,height:0};i.material.map&&i.material.map.image&&(u.width=i.material.map.image.width,u.height=i.material.map.image.height,c=Zi(i.material.map.image));const f=new Ki({name:n.userData.name,target:i,size:Js(i),imageSize:u,imageUrl:c});this._logos.push(f)}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=Zi(i.material.map.image));const u=new Ki({name:a.userData.name,target:i,size:Js(i),imageSize:c,imageUrl:n});this._logos.push(u)}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){this._lift&&(e>this._liftMaxHeight&&(e=this._liftMaxHeight),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()}setRoller(){this._goodsSize}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 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.position.z+=.2,this._rollerLevel.set(n,c),(a=s.parent)==null||a.add(c)}}setRollerHeight(e,t){const i=this._rollerLevel.get(e);i&&(i.position.z=t)}_generateRollers(){var p,r;if(!this._roller)return;(((p=this._roller.parent)==null?void 0:p.children.filter(l=>l.userData.isCloned))||[]).forEach(l=>{_e(l),l.removeFromParent()});let{length:t}=this._goodsSize;t=t||.5;const i=.05;let s=.02;const n=t-s;if(n<0){this._roller.visible=!1;return}else this._roller.visible=!0;const c=i+s;let u=Math.floor(n/c);const f=n%c;if(u>0){u>1&&(s+=f/(u+2));const l=i+s,h=-t/2+s+i/2;for(let g=0;g<u;g++){let _=this._roller;g>0&&(_=this._roller.clone(!0),_.userData.isCloned=!0),_.position.y=h+l*g,(r=this._roller.parent)==null||r.add(_);const m=this._shapeKeyTargets.get("goodsWidth");m&&_.traverse(v=>{nr(v)&&m.push(v)})}}}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=>{_e(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(u=>{nr(u)&&(this.setShapeKeyToMesh(u,"goodsWidth",this._goodsSize.width),this.setShapeKeyToMesh(u,"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(u=>{u.userData.isShelfContainer&&(c=u)}),(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 u=new rr(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);if(c.add(u),this.goods.push(u),a===1){const f=new rr(this._goodsSize.length,this._goodsSize.width,this._goodsSize.height);f.position.z-=t,c.add(f),this.goods.push(f)}}}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 Gr(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(u=>{u.name===i&&(n=u)}),!n)return;const c=new sr({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(u=>{u.name===i&&(n=u)}),!n)return;const c=new sr({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",u=>{this.setForkHeight(u),this.setLiftHeight(u),this.setJackHeight(u)}))}}}generateDimension(e,t){if(e.userData.isDimension){const i=e.userData.divider,s=qa(e.userData.startOrigin),a=e.userData.axios;let n,c;if(a==="x"?(n=new d.Vector3(e.userData.start-e.position.x,0,0),c=n.clone().setX(e.userData.end-e.position.x)):a==="z"?(n=new d.Vector3(0,e.userData.start-e.position.y,0),c=n.clone().setY(e.userData.end-e.position.y)):(n=new d.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 ll({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 u=e.userData.holeTarget&&e.userData.holeTarget.name;let f;u&&t.traverse(h=>{h.name===u&&(f=h)});const p=new Map;Object.keys(e.userData).forEach(h=>{if(h.startsWith("follow_")){const g=h.split("_")[1];if(g){let _=e.userData[h];p.set(g,{scale:_,initPos:e.position.clone(),origin:this.shapeKeys.get(g)||0})}}});const r=(s=this._app)==null?void 0:s.props.isMobile,l=new Xi({name:a,follows:p,slot:e,show:this._showSlots,isMirror:n,mirrorTarget:c,isMobile:r});return l.holeTarget=f,l.addEventListener(Y.ON_DROP,h=>{this._app&&this._app.props.useSound&&this._app.sound.play()}),l.addEventListener(Y.ON_BEFORE_SELECTED,h=>{this._slots.forEach(g=>{g.selected&&(g.selected=!1)})}),l.addEventListener(Y.ON_ERROR_STATE_CHANGE,h=>{var _;if(!this._app)return;const g=(_=this._app)==null?void 0:_._outlinePassError;if(g)if(g.selectedObjects=g.selectedObjects.filter(m=>!!m.parent),h){if(l.device){if(g.selectedObjects.find(v=>{var y;return v.parent===((y=l.device)==null?void 0:y.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=[],_e(this._container),this._levels.forEach(e=>e.destroy()),this._levels.clear(),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._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._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,u=a&&!n&&a.isRunning();this._actionsMap.forEach(r=>{r!==s&&r!==a&&(r.stopFading(),r.setEffectiveWeight(0),r.stop())});const f=(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(f?d.LoopRepeat:d.LoopOnce,f?1/0:1),s.clampWhenFinished=(t==null?void 0:t.clampWhenFinished)??!f,s.play();const p=(t==null?void 0:t.timeScale)??1;return u?(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=h=>{var g;h.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 jr=0,hl=1,fl=2,or=2,Li=1.25,ar=1,Ft=6*4+4+4,vi=65535,dl=Math.pow(2,-24),Pi=Symbol("SKIP_GENERATION");function pl(o){return o.index?o.index.count:o.attributes.position.count}function gt(o){return pl(o)/3}function ml(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function gl(o,e){if(!o.index){const t=o.attributes.position.count,i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=ml(t,i);o.setIndex(new d.BufferAttribute(s,1));for(let a=0;a<t;a++)s[a]=a}}function Qr(o){const e=gt(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 Yr(o){if(!o.groups||!o.groups.length)return Qr(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 u=c.start/3,f=(c.start+c.count)/3;t.add(Math.max(s,u)),t.add(Math.min(a,f))}const n=Array.from(t.values()).sort((c,u)=>c-u);for(let c=0;c<n.length-1;c++){const u=n[c],f=n[c+1];e.push({offset:Math.floor(u),count:Math.floor(f-u)})}return e}function vl(o){if(o.groups.length===0)return!1;const e=gt(o),t=Yr(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 Fi(o,e,t,i,s){let a=1/0,n=1/0,c=1/0,u=-1/0,f=-1/0,p=-1/0,r=1/0,l=1/0,h=1/0,g=-1/0,_=-1/0,m=-1/0;for(let v=e*6,y=(e+t)*6;v<y;v+=6){const x=o[v+0],w=o[v+1],b=x-w,A=x+w;b<a&&(a=b),A>u&&(u=A),x<r&&(r=x),x>g&&(g=x);const S=o[v+2],C=o[v+3],M=S-C,I=S+C;M<n&&(n=M),I>f&&(f=I),S<l&&(l=S),S>_&&(_=S);const D=o[v+4],T=o[v+5],R=D-T,L=D+T;R<c&&(c=R),L>p&&(p=L),D<h&&(h=D),D>m&&(m=D)}i[0]=a,i[1]=n,i[2]=c,i[3]=u,i[4]=f,i[5]=p,s[0]=r,s[1]=l,s[2]=h,s[3]=g,s[4]=_,s[5]=m}function _l(o,e=null,t=null,i=null){const s=o.attributes.position,a=o.index?o.index.array:null,n=gt(o),c=s.normalized;let u;e===null?(u=new Float32Array(n*6*4),t=0,i=n):(u=e,t=t||0,i=i||n);const f=s.array,p=s.offset||0;let r=3;s.isInterleavedBufferAttribute&&(r=s.data.stride);const l=["getX","getY","getZ"];for(let h=t;h<t+i;h++){const g=h*3,_=h*6;let m=g+0,v=g+1,y=g+2;a&&(m=a[m],v=a[v],y=a[y]),c||(m=m*r+p,v=v*r+p,y=y*r+p);for(let x=0;x<3;x++){let w,b,A;c?(w=s[l[x]](m),b=s[l[x]](v),A=s[l[x]](y)):(w=f[m+x],b=f[v+x],A=f[y+x]);let S=w;b<S&&(S=b),A<S&&(S=A);let C=w;b>C&&(C=b),A>C&&(C=A);const M=(C-S)/2,I=x*2;u[_+I+0]=S+M,u[_+I+1]=M+(Math.abs(S)+M)*dl}}return u}function q(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 lr(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 cr(o,e){e.set(o)}function ur(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 jt(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 At(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 xe=32,yl=(o,e)=>o.candidate-e.candidate,Re=new Array(xe).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Qt=new Float32Array(6);function xl(o,e,t,i,s,a){let n=-1,c=0;if(a===jr)n=lr(e),n!==-1&&(c=(e[n]+e[n+3])/2);else if(a===hl)n=lr(o),n!==-1&&(c=wl(t,i,s,n));else if(a===fl){const u=At(o);let f=Li*s;const p=i*6,r=(i+s)*6;for(let l=0;l<3;l++){const h=e[l],m=(e[l+3]-h)/xe;if(s<xe/4){const v=[...Re];v.length=s;let y=0;for(let w=p;w<r;w+=6,y++){const b=v[y];b.candidate=t[w+2*l],b.count=0;const{bounds:A,leftCacheBounds:S,rightCacheBounds:C}=b;for(let M=0;M<3;M++)C[M]=1/0,C[M+3]=-1/0,S[M]=1/0,S[M+3]=-1/0,A[M]=1/0,A[M+3]=-1/0;jt(w,t,A)}v.sort(yl);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 A=0;A<x;A++){const S=v[A];b>=S.candidate?jt(w,t,S.rightCacheBounds):(jt(w,t,S.leftCacheBounds),S.count++)}}for(let w=0;w<x;w++){const b=v[w],A=b.count,S=s-b.count,C=b.leftCacheBounds,M=b.rightCacheBounds;let I=0;A!==0&&(I=At(C)/u);let D=0;S!==0&&(D=At(M)/u);const T=ar+Li*(I*A+D*S);T<f&&(n=l,f=T,c=b.candidate)}}else{for(let x=0;x<xe;x++){const w=Re[x];w.count=0,w.candidate=h+m+x*m;const b=w.bounds;for(let A=0;A<3;A++)b[A]=1/0,b[A+3]=-1/0}for(let x=p;x<r;x+=6){let A=~~((t[x+2*l]-h)/m);A>=xe&&(A=xe-1);const S=Re[A];S.count++,jt(x,t,S.bounds)}const v=Re[xe-1];cr(v.bounds,v.rightCacheBounds);for(let x=xe-2;x>=0;x--){const w=Re[x],b=Re[x+1];ur(w.bounds,b.rightCacheBounds,w.rightCacheBounds)}let y=0;for(let x=0;x<xe-1;x++){const w=Re[x],b=w.count,A=w.bounds,C=Re[x+1].rightCacheBounds;b!==0&&(y===0?cr(A,Qt):ur(A,Qt,Qt)),y+=b;let M=0,I=0;y!==0&&(M=At(Qt)/u);const D=s-y;D!==0&&(I=At(C)/u);const T=ar+Li*(M*y+I*D);T<f&&(n=l,f=T,c=w.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${a} used.`);return{axis:n,pos:c}}function wl(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 Ei{constructor(){this.boundingData=new Float32Array(6)}}function bl(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)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 Al(o,e,t,i,s,a){let n=i,c=i+s-1;const u=a.pos,f=a.axis*2;for(;;){for(;n<=c&&t[n*6+f]<u;)n++;for(;n<=c&&t[c*6+f]>=u;)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 re(o,e){return e[o+6]}function oe(o,e){return e[o+14]}function ae(o){return o+8}function le(o,e){return e[o+6]}function Zr(o,e){return e[o+7]}let Xr,Dt,li,Kr;const Tl=Math.pow(2,32);function Ji(o){return"count"in o?1:1+Ji(o.left)+Ji(o.right)}function Sl(o,e,t){return Xr=new Float32Array(t),Dt=new Uint32Array(t),li=new Uint16Array(t),Kr=new Uint8Array(t),$i(o,e)}function $i(o,e){const t=o/4,i=o/2,s="count"in e,a=e.boundingData;for(let n=0;n<6;n++)Xr[t+n]=a[n];if(s)if(e.buffer){const n=e.buffer;Kr.set(new Uint8Array(n),o);for(let c=o,u=o+n.byteLength;c<u;c+=Ft){const f=c/2;ee(f,li)||(Dt[c/4+6]+=t)}return o+n.byteLength}else{const n=e.offset,c=e.count;return Dt[t+6]=n,li[i+14]=c,li[i+15]=vi,o+Ft}else{const n=e.left,c=e.right,u=e.splitAxis;let f;if(f=$i(o+Ft,n),f/4>Tl)throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return Dt[t+6]=f/4,f=$i(f,c),Dt[t+7]=u,f}}function Ml(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,u=n.length;c<u;c++)n[c]=c;return n}function Cl(o,e,t,i,s){const{maxDepth:a,verbose:n,maxLeafTris:c,strategy:u,onProgress:f,indirect:p}=s,r=o._indirectBuffer,l=o.geometry,h=l.index?l.index.array:null,g=p?Al:bl,_=gt(l),m=new Float32Array(6);let v=!1;const y=new Ei;return Fi(e,t,i,y.boundingData,m),w(y,t,i,m),y;function x(b){f&&f(b/_)}function w(b,A,S,C=null,M=0){if(!v&&M>=a&&(v=!0,n&&(console.warn(`MeshBVH: Max depth of ${a} reached when generating BVH. Consider increasing maxDepth.`),console.warn(l))),S<=c||M>=a)return x(A+S),b.offset=A,b.count=S,b;const I=xl(b.boundingData,C,e,A,S,u);if(I.axis===-1)return x(A+S),b.offset=A,b.count=S,b;const D=g(r,h,e,A,S,I);if(D===A||D===A+S)x(A+S),b.offset=A,b.count=S;else{b.splitAxis=I.axis;const T=new Ei,R=A,L=D-A;b.left=T,Fi(e,R,L,T.boundingData,m),w(T,R,L,m,M+1);const F=new Ei,E=D,z=S-L;b.right=F,Fi(e,E,z,F.boundingData,m),w(F,E,z,m,M+1)}return b}}function Rl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=Ml(t,e.useSharedArrayBuffer),vl(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||gl(t,e);const i=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,s=_l(t),a=e.indirect?Qr(t):Yr(t);o._roots=a.map(n=>{const c=Cl(o,s,n.offset,n.count,e),u=Ji(c),f=new i(Ft*u);return Sl(0,c,f),f})}class Te{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 u=e[a][t];i=u<i?u:i,s=u>s?u: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],u=e.dot(c);i=u<i?u:i,s=u>s?u:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}Te.prototype.setFromBox=function(){const o=new d.Vector3;return function(t,i){const s=i.min,a=i.max;let n=1/0,c=-1/0;for(let u=0;u<=1;u++)for(let f=0;f<=1;f++)for(let p=0;p<=1;p++){o.x=s.x*u+a.x*(1-u),o.y=s.y*f+a.y*(1-f),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 Il=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Vector3;return function(s,a,n){const c=s.start,u=o,f=a.start,p=e;t.subVectors(c,f),o.subVectors(s.end,s.start),e.subVectors(a.end,a.start);const r=t.dot(p),l=p.dot(u),h=p.dot(p),g=t.dot(u),m=u.dot(u)*h-l*l;let v,y;m!==0?v=(r*l-g*h)/m:v=0,y=(r+v*l)/h,n.x=v,n.y=y}}(),_s=function(){const o=new d.Vector2,e=new d.Vector3,t=new d.Vector3;return function(s,a,n,c){Il(s,a,o);let u=o.x,f=o.y;if(u>=0&&u<=1&&f>=0&&f<=1){s.at(u,n),a.at(f,c);return}else if(u>=0&&u<=1){f<0?a.at(0,c):a.at(1,c),s.closestPointToPoint(c,!0,n);return}else if(f>=0&&f<=1){u<0?s.at(0,n):s.at(1,n),a.closestPointToPoint(n,!0,c);return}else{let p;u<0?p=s.start:p=s.end;let r;f<0?r=a.start:r=a.end;const l=e,h=t;if(s.closestPointToPoint(r,!0,e),a.closestPointToPoint(p,!0,t),l.distanceToSquared(r)<=h.distanceToSquared(p)){n.copy(l),c.copy(r);return}else{n.copy(p),c.copy(h);return}}}}(),Dl=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Plane,i=new d.Line3;return function(a,n){const{radius:c,center:u}=a,{a:f,b:p,c:r}=n;if(i.start=f,i.end=p,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c||(i.start=f,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c)||(i.start=p,i.end=r,i.closestPointToPoint(u,!0,o).distanceTo(u)<=c))return!0;const _=n.getPlane(t);if(Math.abs(_.distanceToPoint(u))<=c){const v=_.projectPoint(u,e);if(n.containsPoint(v))return!0}return!1}}(),Ll=1e-15;function ki(o){return Math.abs(o)<Ll}class pe extends d.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new d.Vector3),this.satBounds=new Array(4).fill().map(()=>new Te),this.points=[this.a,this.b,this.c],this.sphere=new d.Sphere,this.plane=new d.Plane,this.needsUpdate=!0}intersectsSphere(e){return Dl(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],u=n[0];this.getNormal(c),u.setFromPoints(c,s);const f=a[1],p=n[1];f.subVectors(e,t),p.setFromPoints(f,s);const r=a[2],l=n[2];r.subVectors(t,i),l.setFromPoints(r,s);const h=a[3],g=n[3];h.subVectors(i,e),g.setFromPoints(h,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(c,e),this.needsUpdate=!1}}pe.prototype.closestPointToSegment=function(){const o=new d.Vector3,e=new d.Vector3,t=new d.Line3;return function(s,a=null,n=null){const{start:c,end:u}=s,f=this.points;let p,r=1/0;for(let l=0;l<3;l++){const h=(l+1)%3;t.start.copy(f[l]),t.end.copy(f[h]),_s(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(u,o),p=u.distanceToSquared(o),p<r&&(r=p,a&&a.copy(o),n&&n.copy(u)),Math.sqrt(r)}}();pe.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Array(3),i=new Te,s=new Te,a=new d.Vector3,n=new d.Vector3,c=new d.Vector3,u=new d.Vector3,f=new d.Vector3,p=new d.Line3,r=new d.Line3,l=new d.Line3,h=new d.Vector3;function g(_,m,v){const y=_.points;let x=0,w=-1;for(let b=0;b<3;b++){const{start:A,end:S}=p;A.copy(y[b]),S.copy(y[(b+1)%3]),p.delta(n);const C=ki(m.distanceToPoint(A));if(ki(m.normal.dot(n))&&C){v.copy(p),x=2;break}const M=m.intersectLine(p,h);if(!M&&C&&h.copy(A),(M||C)&&!ki(h.distanceTo(S))){if(x<=1)(x===1?v.start:v.end).copy(h),C&&(w=x);else if(x>=2){(w===1?v.start:v.end).copy(h),x=2;break}if(x++,x===2&&w===-1)break}}return x}return function(m,v=null,y=!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,A=this.satAxes;t[0]=m.a,t[1]=m.b,t[2]=m.c;for(let M=0;M<4;M++){const I=b[M],D=A[M];if(i.setFromPoints(D,t),I.isSeparated(i))return!1}const S=m.satBounds,C=m.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let M=0;M<4;M++){const I=S[M],D=C[M];if(i.setFromPoints(D,e),I.isSeparated(i))return!1}for(let M=0;M<4;M++){const I=A[M];for(let D=0;D<4;D++){const T=C[D];if(a.crossVectors(I,T),i.setFromPoints(a,e),s.setFromPoints(a,t),i.isSeparated(s))return!1}}return v&&(y||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 A=g(m,x,l);if(A===1&&this.containsPoint(l.end))return v&&(v.start.copy(l.end),v.end.copy(l.end)),!0;if(A!==2)return!1;if(r.delta(c),l.delta(u),c.dot(u)<0){let R=l.start;l.start=l.end,l.end=R}const S=r.start.dot(c),C=r.end.dot(c),M=l.start.dot(c),I=l.end.dot(c),D=C<M,T=S<I;return S!==I&&M!==C&&D===T?!1:(v&&(f.subVectors(r.start,l.start),f.dot(c)>0?v.start.copy(r.start):v.start.copy(l.start),f.subVectors(r.end,l.end),f.dot(c)<0?v.end.copy(r.end):v.end.copy(l.end)),!0)}}}();pe.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();pe.prototype.distanceToTriangle=function(){const o=new d.Vector3,e=new d.Vector3,t=["a","b","c"],i=new d.Line3,s=new d.Line3;return function(n,c=null,u=null){const f=c||u?i:null;if(this.intersectsTriangle(n,f))return(c||u)&&(c&&f.getCenter(c),u&&f.getCenter(u)),0;let p=1/0;for(let r=0;r<3;r++){let l;const h=t[r],g=n[h];this.closestPointToPoint(g,o),l=g.distanceToSquared(o),l<p&&(p=l,c&&c.copy(o),u&&u.copy(g));const _=this[h];n.closestPointToPoint(_,o),l=_.distanceToSquared(o),l<p&&(p=l,c&&c.copy(_),u&&u.copy(o))}for(let r=0;r<3;r++){const l=t[r],h=t[(r+1)%3];i.set(this[l],this[h]);for(let g=0;g<3;g++){const _=t[g],m=t[(g+1)%3];s.set(n[_],n[m]),_s(i,s,o,e);const v=o.distanceToSquared(e);v<p&&(p=v,c&&c.copy(o),u&&u.copy(e))}}return Math.sqrt(p)}}();class K{constructor(e,t,i){this.isOrientedBox=!0,this.min=new d.Vector3,this.max=new d.Vector3,this.matrix=new d.Matrix4,this.invMatrix=new d.Matrix4,this.points=new Array(8).fill().map(()=>new d.Vector3),this.satAxes=new Array(3).fill().map(()=>new d.Vector3),this.satBounds=new Array(3).fill().map(()=>new Te),this.alignedSatBounds=new Array(3).fill().map(()=>new Te),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}}K.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let f=0;f<=1;f++)for(let p=0;p<=1;p++)for(let r=0;r<=1;r++){const l=1*f|2*p|4*r,h=s[l];h.x=f?i.x:t.x,h.y=p?i.y:t.y,h.z=r?i.z:t.z,h.applyMatrix4(e)}const a=this.satBounds,n=this.satAxes,c=s[0];for(let f=0;f<3;f++){const p=n[f],r=a[f],l=1<<f,h=s[l];p.subVectors(c,h),r.setFromPoints(p,s)}const u=this.alignedSatBounds;u[0].setFromPointsField(s,"x"),u[1].setFromPointsField(s,"y"),u[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}();K.prototype.intersectsBox=function(){const o=new Te;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 u=0;u<3;u++){const f=n[u],p=a[u];if(o.setFromBox(f,t),p.isSeparated(o))return!1}return!0}}();K.prototype.intersectsTriangle=function(){const o=new pe,e=new Array(3),t=new Te,i=new Te,s=new d.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,u=this.satAxes;e[0]=n.a,e[1]=n.b,e[2]=n.c;for(let l=0;l<3;l++){const h=c[l],g=u[l];if(t.setFromPoints(g,e),h.isSeparated(t))return!1}const f=n.satBounds,p=n.satAxes,r=this.points;for(let l=0;l<3;l++){const h=f[l],g=p[l];if(t.setFromPoints(g,r),h.isSeparated(t))return!1}for(let l=0;l<3;l++){const h=u[l];for(let g=0;g<4;g++){const _=p[g];if(s.crossVectors(h,_),t.setFromPoints(s,e),i.setFromPoints(s,r),t.isSeparated(i))return!1}}return!0}}();K.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}}();K.prototype.distanceToPoint=function(){const o=new d.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}();K.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new d.Line3),t=new Array(12).fill().map(()=>new d.Line3),i=new d.Vector3,s=new d.Vector3;return function(n,c=0,u=null,f=null){if(this.needsUpdate&&this.update(),this.intersectsBox(n))return(u||f)&&(n.getCenter(s),this.closestPointToPoint(s,i),n.closestPointToPoint(i,s),u&&u.copy(i),f&&f.copy(s)),0;const p=c*c,r=n.min,l=n.max,h=this.points;let g=1/0;for(let m=0;m<8;m++){const v=h[m];s.copy(v).clamp(r,l);const y=v.distanceToSquared(s);if(y<g&&(g=y,u&&u.copy(v),f&&f.copy(s),y<p))return Math.sqrt(y)}let _=0;for(let m=0;m<3;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){const x=(m+1)%3,w=(m+2)%3,b=v<<x|y<<w,A=1<<m|v<<x|y<<w,S=h[b],C=h[A];e[_].set(S,C);const I=o[m],D=o[x],T=o[w],R=t[_],L=R.start,F=R.end;L[I]=r[I],L[D]=v?r[D]:l[D],L[T]=y?r[T]:l[D],F[I]=l[I],F[D]=v?r[D]:l[D],F[T]=y?r[T]:l[D],_++}for(let m=0;m<=1;m++)for(let v=0;v<=1;v++)for(let y=0;y<=1;y++){s.x=m?l.x:r.x,s.y=v?l.y:r.y,s.z=y?l.z:r.z,this.closestPointToPoint(s,i);const x=s.distanceToSquared(i);if(x<g&&(g=x,u&&u.copy(i),f&&f.copy(s),x<p))return Math.sqrt(x)}for(let m=0;m<12;m++){const v=e[m];for(let y=0;y<12;y++){const x=t[y];_s(v,x,i,s);const w=i.distanceToSquared(s);if(w<g&&(g=w,u&&u.copy(i),f&&f.copy(s),w<p))return Math.sqrt(w)}}return Math.sqrt(g)}}();class ys{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 Pl extends ys{constructor(){super(()=>new pe)}}const ce=new Pl;class Fl{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 H=new Fl;let Ee,lt;const Ye=[],Yt=new ys(()=>new d.Box3);function El(o,e,t,i,s,a){Ee=Yt.getPrimitive(),lt=Yt.getPrimitive(),Ye.push(Ee,lt),H.setBuffer(o._roots[e]);const n=es(0,o.geometry,t,i,s,a);H.clearBuffer(),Yt.releasePrimitive(Ee),Yt.releasePrimitive(lt),Ye.pop(),Ye.pop();const c=Ye.length;return c>0&&(lt=Ye[c-1],Ee=Ye[c-2]),n}function es(o,e,t,i,s=null,a=0,n=0){const{float32Array:c,uint16Array:u,uint32Array:f}=H;let p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);return q(o,c,Ee),i(l,h,!1,n,a+o,Ee)}else{let I=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=ae(T),F=T*2;return re(T,L)},D=function(T){const{uint16Array:R,uint32Array:L}=H;let F=T*2;for(;!ee(F,R);)T=le(T,L),F=T*2;return re(T,L)+oe(F,R)};const l=ae(o),h=le(o,f);let g=l,_=h,m,v,y,x;if(s&&(y=Ee,x=lt,q(g,c,y),q(_,c,x),m=s(y),v=s(x),v<m)){g=h,_=l;const T=m;m=v,v=T,y=x}y||(y=Ee,q(g,c,y));const w=ee(g*2,u),b=t(y,w,m,n+1,a+g);let A;if(b===or){const T=I(g),L=D(g)-T;A=i(T,L,!0,n+1,a+g,y)}else A=b&&es(g,e,t,i,s,a,n+1);if(A)return!0;x=lt,q(_,c,x);const S=ee(_*2,u),C=t(x,S,v,n+1,a+_);let M;if(C===or){const T=I(_),L=D(_)-T;M=i(T,L,!0,n+1,a+_,x)}else M=C&&es(_,e,t,i,s,a,n+1);return!!M}}const Tt=new d.Vector3,Bi=new d.Vector3;function kl(o,e,t={},i=0,s=1/0){const a=i*i,n=s*s;let c=1/0,u=null;if(o.shapecast({boundsTraverseOrder:p=>(Tt.copy(e).clamp(p.min,p.max),Tt.distanceToSquared(e)),intersectsBounds:(p,r,l)=>l<c&&l<n,intersectsTriangle:(p,r)=>{p.closestPointToPoint(e,Tt);const l=e.distanceToSquared(Tt);return l<c&&(Bi.copy(Tt),c=l,u=r),l<a}}),c===1/0)return null;const f=Math.sqrt(c);return t.point?t.point.copy(Bi):t.point=Bi.clone(),t.distance=f,t.faceIndex=u,t}const Ze=new d.Vector3,Xe=new d.Vector3,Ke=new d.Vector3,Zt=new d.Vector2,Xt=new d.Vector2,Kt=new d.Vector2,hr=new d.Vector3,fr=new d.Vector3,dr=new d.Vector3,Jt=new d.Vector3;function Bl(o,e,t,i,s,a,n,c){let u;if(a===d.BackSide?u=o.intersectTriangle(i,t,e,!0,s):u=o.intersectTriangle(e,t,i,a!==d.DoubleSide,s),u===null)return null;const f=o.origin.distanceTo(s);return f<n||f>c?null:{distance:f,point:s.clone()}}function Ol(o,e,t,i,s,a,n,c,u,f,p){Ze.fromBufferAttribute(e,a),Xe.fromBufferAttribute(e,n),Ke.fromBufferAttribute(e,c);const r=Bl(o,Ze,Xe,Ke,Jt,u,f,p);if(r){i&&(Zt.fromBufferAttribute(i,a),Xt.fromBufferAttribute(i,n),Kt.fromBufferAttribute(i,c),r.uv=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,Zt,Xt,Kt,new d.Vector2)),s&&(Zt.fromBufferAttribute(s,a),Xt.fromBufferAttribute(s,n),Kt.fromBufferAttribute(s,c),r.uv1=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,Zt,Xt,Kt,new d.Vector2)),t&&(hr.fromBufferAttribute(t,a),fr.fromBufferAttribute(t,n),dr.fromBufferAttribute(t,c),r.normal=d.Triangle.getInterpolation(Jt,Ze,Xe,Ke,hr,fr,dr,new d.Vector3),r.normal.dot(o.direction)>0&&r.normal.multiplyScalar(-1));const l={a,b:n,c,normal:new d.Vector3,materialIndex:0};d.Triangle.getNormal(Ze,Xe,Ke,l.normal),r.face=l,r.faceIndex=a}return r}function _i(o,e,t,i,s,a,n){const c=i*3;let u=c+0,f=c+1,p=c+2;const r=o.index;o.index&&(u=r.getX(u),f=r.getX(f),p=r.getX(p));const{position:l,normal:h,uv:g,uv1:_}=o.attributes,m=Ol(t,l,h,g,_,u,f,p,e,a,n);return m?(m.faceIndex=i,s&&s.push(m),m):null}function Q(o,e,t,i){const s=o.a,a=o.b,n=o.c;let c=e,u=e+1,f=e+2;t&&(c=t.getX(c),u=t.getX(u),f=t.getX(f)),s.x=i.getX(c),s.y=i.getY(c),s.z=i.getZ(c),a.x=i.getX(u),a.y=i.getY(u),a.z=i.getZ(u),n.x=i.getX(f),n.y=i.getY(f),n.z=i.getZ(f)}function zl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++)_i(u,e,t,p,a,n,c)}function Vl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=_i(c,e,t,r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Ul(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=p,Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function Wl(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,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=3*v,I=3*(v+y);M<I;M++){let D=i[M];const T=s.getX(D),R=s.getY(D),L=s.getZ(D);T<x&&(x=T),T>A&&(A=T),R<w&&(w=R),R>S&&(S=R),L<b&&(b=L),L>C&&(C=L)}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function ke(o,e,t,i,s){let a,n,c,u,f,p;const r=1/t.direction.x,l=1/t.direction.y,h=1/t.direction.z,g=t.origin.x,_=t.origin.y,m=t.origin.z;let v=e[o],y=e[o+3],x=e[o+1],w=e[o+3+1],b=e[o+2],A=e[o+3+2];return r>=0?(a=(v-g)*r,n=(y-g)*r):(a=(y-g)*r,n=(v-g)*r),l>=0?(c=(x-_)*l,u=(w-_)*l):(c=(w-_)*l,u=(x-_)*l),a>u||c>n||((c>a||isNaN(a))&&(a=c),(u<n||isNaN(n))&&(n=u),h>=0?(f=(b-m)*h,p=(A-m)*h):(f=(A-m)*h,p=(b-m)*h),a>p||f>n)?!1:((f>a||a!==a)&&(a=f),(p<n||n!==n)&&(n=p),a<=s&&n>=i)}function Hl(o,e,t,i,s,a,n,c){const{geometry:u,_indirectBuffer:f}=o;for(let p=i,r=i+s;p<r;p++){let l=f?f[p]:p;_i(u,e,t,l,a,n,c)}}function Nl(o,e,t,i,s,a,n){const{geometry:c,_indirectBuffer:u}=o;let f=1/0,p=null;for(let r=i,l=i+s;r<l;r++){let h;h=_i(c,e,t,u?u[r]:r,null,a,n),h&&h.distance<f&&(p=h,f=h.distance)}return p}function Gl(o,e,t,i,s,a,n){const{geometry:c}=t,{index:u}=c,f=c.attributes.position;for(let p=o,r=e+o;p<r;p++){let l;if(l=t.resolveTriangleIndex(p),Q(n,l*3,u,f),n.needsUpdate=!0,i(n,l,s,a))return!0}return!1}function ql(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),ts(0,o,t,i,s,a,n),H.clearBuffer()}function ts(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);zl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&ts(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&ts(h,e,t,i,s,a,n)}}const jl=["x","y","z"];function Ql(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=is(0,o,t,i,s,a);return H.clearBuffer(),n}function is(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Vl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=jl[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?is(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?is(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const $t=new d.Box3,Je=new pe,$e=new pe,St=new d.Matrix4,pr=new K,ei=new K;function Yl(o,e,t,i){H.setBuffer(o._roots[e]);const s=ss(0,o,t,i);return H.clearBuffer(),s}function ss(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),pr.set(t.boundingBox.min,t.boundingBox.max,i),s=pr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(St.copy(i).invert(),t.boundsTree)return q(o,a,ei),ei.matrix.copy(St),ei.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>ei.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_*3,w=(m+_)*3;x<w;x+=3)if(Q($e,x,r,l),$e.needsUpdate=!0,y.intersectsTriangle($e))return!0;return!1}});for(let v=_*3,y=(m+_)*3;v<y;v+=3){Q(Je,v,r,l),Je.a.applyMatrix4(St),Je.b.applyMatrix4(St),Je.c.applyMatrix4(St),Je.needsUpdate=!0;for(let x=0,w=h.count;x<w;x+=3)if(Q($e,x,h,g),$e.needsUpdate=!0,Je.intersectsTriangle($e))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,$t),!!(s.intersectsBox($t)&&ss(p,e,t,i,s)||(q(r,a,$t),s.intersectsBox($t)&&ss(r,e,t,i,s)))}}const ti=new d.Matrix4,Oi=new K,Mt=new K,Zl=new d.Vector3,Xl=new d.Vector3,Kl=new d.Vector3,Jl=new d.Vector3;function $l(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),Oi.set(e.boundingBox.min,e.boundingBox.max,t),Oi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=Zl,_=Xl,m=null,v=null;s&&(m=Kl,v=Jl);let y=1/0,x=null,w=null;return ti.copy(t).invert(),Mt.matrix.copy(ti),o.shapecast({boundsTraverseOrder:b=>Oi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Mt.min.copy(b.min),Mt.max.copy(b.max),Mt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:C=>Mt.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){Q(h,3*I,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let T=b,R=b+A;T<R;T++){Q(l,3*T,f,u),l.needsUpdate=!0;const L=l.distanceToTriangle(h,g,m);if(L<y&&(_.copy(g),v&&v.copy(m),y=L,x=T,w=I),L<a)return!0}}}});{const S=gt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){Q(l,3*I,f,u),l.needsUpdate=!0;const T=l.distanceToTriangle(h,g,m);if(T<y&&(_.copy(g),v&&v.copy(m),y=T,x=I,w=C),T<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ti),_.applyMatrix4(ti),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function ec(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,u,f=0;const p=o._roots;for(let l=0,h=p.length;l<h;l++)a=p[l],n=new Uint32Array(a),c=new Uint16Array(a),u=new Float32Array(a),r(0,f),f+=a.byteLength;function r(l,h,g=!1){const _=l*2;if(c[_+15]===vi){const v=n[l+6],y=c[_+14];let x=1/0,w=1/0,b=1/0,A=-1/0,S=-1/0,C=-1/0;for(let M=v,I=v+y;M<I;M++){const D=3*o.resolveTriangleIndex(M);for(let T=0;T<3;T++){let R=D+T;R=i?i[R]:R;const L=s.getX(R),F=s.getY(R),E=s.getZ(R);L<x&&(x=L),L>A&&(A=L),F<w&&(w=F),F>S&&(S=F),E<b&&(b=E),E>C&&(C=E)}}return u[l+0]!==x||u[l+1]!==w||u[l+2]!==b||u[l+3]!==A||u[l+4]!==S||u[l+5]!==C?(u[l+0]=x,u[l+1]=w,u[l+2]=b,u[l+3]=A,u[l+4]=S,u[l+5]=C,!0):!1}else{const v=l+8,y=n[l+6],x=v+h,w=y+h;let b=g,A=!1,S=!1;e?b||(A=e.has(x),S=e.has(w),b=!A&&!S):(A=!0,S=!0);const C=b||A,M=b||S;let I=!1;C&&(I=r(v,h,b));let D=!1;M&&(D=r(y,h,b));const T=I||D;if(T)for(let R=0;R<3;R++){const L=v+R,F=y+R,E=u[L],z=u[L+3],N=u[F],j=u[F+3];u[l+R]=E<N?E:N,u[l+R+3]=z>j?z:j}return T}}}function tc(o,e,t,i,s,a,n){H.setBuffer(o._roots[e]),rs(0,o,t,i,s,a,n),H.clearBuffer()}function rs(o,e,t,i,s,a,n){const{float32Array:c,uint16Array:u,uint32Array:f}=H,p=o*2;if(ee(p,u)){const l=re(o,f),h=oe(p,u);Hl(e,t,i,l,h,s,a,n)}else{const l=ae(o);ke(l,c,i,a,n)&&rs(l,e,t,i,s,a,n);const h=le(o,f);ke(h,c,i,a,n)&&rs(h,e,t,i,s,a,n)}}const ic=["x","y","z"];function sc(o,e,t,i,s,a){H.setBuffer(o._roots[e]);const n=ns(0,o,t,i,s,a);return H.clearBuffer(),n}function ns(o,e,t,i,s,a){const{float32Array:n,uint16Array:c,uint32Array:u}=H;let f=o*2;if(ee(f,c)){const r=re(o,u),l=oe(f,c);return Nl(e,t,i,r,l,s,a)}else{const r=Zr(o,u),l=ic[r],g=i.direction[l]>=0;let _,m;g?(_=ae(o),m=le(o,u)):(_=le(o,u),m=ae(o));const y=ke(_,n,i,s,a)?ns(_,e,t,i,s,a):null;if(y){const b=y.point[l];if(g?b<=n[m+r]:b>=n[m+r+3])return y}const w=ke(m,n,i,s,a)?ns(m,e,t,i,s,a):null;return y&&w?y.distance<=w.distance?y:w:y||w||null}}const ii=new d.Box3,et=new pe,it=new pe,Ct=new d.Matrix4,mr=new K,si=new K;function rc(o,e,t,i){H.setBuffer(o._roots[e]);const s=os(0,o,t,i);return H.clearBuffer(),s}function os(o,e,t,i,s=null){const{float32Array:a,uint16Array:n,uint32Array:c}=H;let u=o*2;if(s===null&&(t.boundingBox||t.computeBoundingBox(),mr.set(t.boundingBox.min,t.boundingBox.max,i),s=mr),ee(u,n)){const p=e.geometry,r=p.index,l=p.attributes.position,h=t.index,g=t.attributes.position,_=re(o,c),m=oe(u,n);if(Ct.copy(i).invert(),t.boundsTree)return q(o,a,si),si.matrix.copy(Ct),si.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:y=>si.intersectsBox(y),intersectsTriangle:y=>{y.a.applyMatrix4(i),y.b.applyMatrix4(i),y.c.applyMatrix4(i),y.needsUpdate=!0;for(let x=_,w=m+_;x<w;x++)if(Q(it,3*e.resolveTriangleIndex(x),r,l),it.needsUpdate=!0,y.intersectsTriangle(it))return!0;return!1}});for(let v=_,y=m+_;v<y;v++){const x=e.resolveTriangleIndex(v);Q(et,3*x,r,l),et.a.applyMatrix4(Ct),et.b.applyMatrix4(Ct),et.c.applyMatrix4(Ct),et.needsUpdate=!0;for(let w=0,b=h.count;w<b;w+=3)if(Q(it,w,h,g),it.needsUpdate=!0,et.intersectsTriangle(it))return!0}}else{const p=o+8,r=c[o+6];return q(p,a,ii),!!(s.intersectsBox(ii)&&os(p,e,t,i,s)||(q(r,a,ii),s.intersectsBox(ii)&&os(r,e,t,i,s)))}}const ri=new d.Matrix4,zi=new K,Rt=new K,nc=new d.Vector3,oc=new d.Vector3,ac=new d.Vector3,lc=new d.Vector3;function cc(o,e,t,i={},s={},a=0,n=1/0){e.boundingBox||e.computeBoundingBox(),zi.set(e.boundingBox.min,e.boundingBox.max,t),zi.needsUpdate=!0;const c=o.geometry,u=c.attributes.position,f=c.index,p=e.attributes.position,r=e.index,l=ce.getPrimitive(),h=ce.getPrimitive();let g=nc,_=oc,m=null,v=null;s&&(m=ac,v=lc);let y=1/0,x=null,w=null;return ri.copy(t).invert(),Rt.matrix.copy(ri),o.shapecast({boundsTraverseOrder:b=>zi.distanceToBox(b),intersectsBounds:(b,A,S)=>S<y&&S<n?(A&&(Rt.min.copy(b.min),Rt.max.copy(b.max),Rt.needsUpdate=!0),!0):!1,intersectsRange:(b,A)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:C=>Rt.distanceToBox(C),intersectsBounds:(C,M,I)=>I<y&&I<n,intersectsRange:(C,M)=>{for(let I=C,D=C+M;I<D;I++){const T=S.resolveTriangleIndex(I);Q(h,3*T,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let R=b,L=b+A;R<L;R++){const F=o.resolveTriangleIndex(R);Q(l,3*F,f,u),l.needsUpdate=!0;const E=l.distanceToTriangle(h,g,m);if(E<y&&(_.copy(g),v&&v.copy(m),y=E,x=R,w=I),E<a)return!0}}}})}else{const S=gt(e);for(let C=0,M=S;C<M;C++){Q(h,3*C,r,p),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let I=b,D=b+A;I<D;I++){const T=o.resolveTriangleIndex(I);Q(l,3*T,f,u),l.needsUpdate=!0;const R=l.distanceToTriangle(h,g,m);if(R<y&&(_.copy(g),v&&v.copy(m),y=R,x=I,w=C),R<a)return!0}}}}}),ce.releasePrimitive(l),ce.releasePrimitive(h),y===1/0?null:(i.point?i.point.copy(_):i.point=_.clone(),i.distance=y,i.faceIndex=x,s&&(s.point?s.point.copy(v):s.point=v.clone(),s.point.applyMatrix4(ri),_.applyMatrix4(ri),s.distance=_.sub(s.point).length(),s.faceIndex=w),i)}function uc(){return typeof SharedArrayBuffer<"u"}const Et=new H.constructor,fi=new H.constructor,De=new ys(()=>new d.Box3),st=new d.Box3,rt=new d.Box3,Vi=new d.Box3,Ui=new d.Box3;let Wi=!1;function hc(o,e,t,i){if(Wi)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Wi=!0;const s=o._roots,a=e._roots;let n,c=0,u=0;const f=new d.Matrix4().copy(t).invert();for(let p=0,r=s.length;p<r;p++){Et.setBuffer(s[p]),u=0;const l=De.getPrimitive();q(0,Et.float32Array,l),l.applyMatrix4(f);for(let h=0,g=a.length;h<g&&(fi.setBuffer(a[p]),n=fe(0,0,t,f,i,c,u,0,0,l),fi.clearBuffer(),u+=a[h].length,!n);h++);if(De.releasePrimitive(l),Et.clearBuffer(),c+=s[p].length,n)break}return Wi=!1,n}function fe(o,e,t,i,s,a=0,n=0,c=0,u=0,f=null,p=!1){let r,l;p?(r=fi,l=Et):(r=Et,l=fi);const h=r.float32Array,g=r.uint32Array,_=r.uint16Array,m=l.float32Array,v=l.uint32Array,y=l.uint16Array,x=o*2,w=e*2,b=ee(x,_),A=ee(w,y);let S=!1;if(A&&b)p?S=s(re(e,v),oe(e*2,y),re(o,g),oe(o*2,_),u,n+e,c,a+o):S=s(re(o,g),oe(o*2,_),re(e,v),oe(e*2,y),c,a+o,u,n+e);else if(A){const C=De.getPrimitive();q(e,m,C),C.applyMatrix4(t);const M=ae(o),I=le(o,g);q(M,h,st),q(I,h,rt);const D=C.intersectsBox(st),T=C.intersectsBox(rt);S=D&&fe(e,M,i,t,s,n,a,u,c+1,C,!p)||T&&fe(e,I,i,t,s,n,a,u,c+1,C,!p),De.releasePrimitive(C)}else{const C=ae(e),M=le(e,v);q(C,m,Vi),q(M,m,Ui);const I=f.intersectsBox(Vi),D=f.intersectsBox(Ui);if(I&&D)S=fe(o,C,t,i,s,a,n,c,u+1,f,p)||fe(o,M,t,i,s,a,n,c,u+1,f,p);else if(I)if(b)S=fe(o,C,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Vi).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,st),q(L,h,rt);const F=T.intersectsBox(st),E=T.intersectsBox(rt);S=F&&fe(C,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(C,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}else if(D)if(b)S=fe(o,M,t,i,s,a,n,c,u+1,f,p);else{const T=De.getPrimitive();T.copy(Ui).applyMatrix4(t);const R=ae(o),L=le(o,g);q(R,h,st),q(L,h,rt);const F=T.intersectsBox(st),E=T.intersectsBox(rt);S=F&&fe(M,R,i,t,s,n,a,u,c+1,T,!p)||E&&fe(M,L,i,t,s,n,a,u,c+1,T,!p),De.releasePrimitive(T)}}return S}const ni=new K,gr=new d.Box3,fc={strategy:jr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0};class xs{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(u=>u.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 xs(t,{...i,[Pi]:!0});if(c._roots=a,c._indirectBuffer=n||null,i.setIndex){const u=t.getIndex();if(u===null){const f=new d.BufferAttribute(e.index,1,!1);t.setIndex(f)}else u.array!==s&&(u.array.set(s),u.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({...fc,[Pi]:!1},t),t.useSharedArrayBuffer&&!uc())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Pi]||(Rl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new d.Box3))),this.resolveTriangleIndex=t.indirect?i=>this._indirectBuffer[i]:i=>i}refit(e=null){return(this.indirect?ec:Wl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),a=new Uint16Array(i);n(0);function n(c,u=0){const f=c*2,p=a[f+15]===vi;if(p){const r=s[c+6],l=a[f+14];e(u,p,new Float32Array(i,c*4,6),r,l)}else{const r=c+Ft/4,l=s[c+6],h=s[c+7];e(u,p,new Float32Array(i,c*4,6),h)||(n(r,u+1),n(l,u+1))}}}raycast(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=[],u=t.isMaterial,f=Array.isArray(t),p=n.groups,r=u?t.side:t,l=this.indirect?tc:ql;for(let h=0,g=a.length;h<g;h++){const _=f?t[p[h].materialIndex].side:r,m=c.length;if(l(this,h,_,e,c,i,s),f){const v=p[h].materialIndex;for(let y=m,x=c.length;y<x;y++)c[y].face.materialIndex=v}}return c}raycastFirst(e,t=d.FrontSide,i=0,s=1/0){const a=this._roots,n=this.geometry,c=t.isMaterial,u=Array.isArray(t);let f=null;const p=n.groups,r=c?t.side:t,l=this.indirect?sc:Ql;for(let h=0,g=a.length;h<g;h++){const _=u?t[p[h].materialIndex].side:r,m=l(this,h,_,e,i,s);m!=null&&(f==null||m.distance<f.distance)&&(f=m,u&&(m.face.materialIndex=p[h].materialIndex))}return f}intersectsGeometry(e,t){let i=!1;const s=this._roots,a=this.indirect?rc:Yl;for(let n=0,c=s.length;n<c&&(i=a(this,n,e,t),!i);n++);return i}shapecast(e){const t=ce.getPrimitive(),i=this.indirect?Gl:Ul;let{boundsTraverseOrder:s,intersectsBounds:a,intersectsRange:n,intersectsTriangle:c}=e;if(n&&c){const r=n;n=(l,h,g,_,m)=>r(l,h,g,_,m)?!0:i(l,h,this,c,g,_,t)}else n||(c?n=(r,l,h,g)=>i(r,l,this,c,h,g,t):n=(r,l,h)=>h);let u=!1,f=0;const p=this._roots;for(let r=0,l=p.length;r<l;r++){const h=p[r];if(u=El(this,r,a,n,s,f),u)break;f+=h.byteLength}return ce.releasePrimitive(t),u}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:a}=i;const n=ce.getPrimitive(),c=this.geometry.index,u=this.geometry.attributes.position,f=this.indirect?g=>{const _=this.resolveTriangleIndex(g);Q(n,_*3,c,u)}:g=>{Q(n,g*3,c,u)},p=ce.getPrimitive(),r=e.geometry.index,l=e.geometry.attributes.position,h=e.indirect?g=>{const _=e.resolveTriangleIndex(g);Q(p,_*3,r,l)}:g=>{Q(p,g*3,r,l)};if(a){const g=(_,m,v,y,x,w,b,A)=>{for(let S=v,C=v+y;S<C;S++){h(S),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let M=_,I=_+m;M<I;M++)if(f(M),n.needsUpdate=!0,a(n,p,M,S,x,w,b,A))return!0}return!1};if(s){const _=s;s=function(m,v,y,x,w,b,A,S){return _(m,v,y,x,w,b,A,S)?!0:g(m,v,y,x,w,b,A,S)}}else s=g}return hc(this,e,t,s)}intersectsBox(e,t){return ni.set(e.min,e.max,t),ni.needsUpdate=!0,this.shapecast({intersectsBounds:i=>ni.intersectsBox(i),intersectsTriangle:i=>ni.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?cc:$l)(this,e,t,i,s,a,n)}closestPointToPoint(e,t={},i=0,s=1/0){return kl(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{q(0,new Float32Array(i),gr),e.union(gr)}),e}}class dc{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 pc extends dc{constructor(e){const t=new Worker(e||new URL("data:text/javascript;base64,aW1wb3J0IHsKCUJ1ZmZlckdlb21ldHJ5LAoJQnVmZmVyQXR0cmlidXRlLAp9IGZyb20gJ3RocmVlJzsKaW1wb3J0IHsgTWVzaEJWSCB9IGZyb20gJy4uL2NvcmUvTWVzaEJWSC5qcyc7Cgpvbm1lc3NhZ2UgPSAoIHsgZGF0YSB9ICkgPT4gewoKCWxldCBwcmV2VGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJZnVuY3Rpb24gb25Qcm9ncmVzc0NhbGxiYWNrKCBwcm9ncmVzcyApIHsKCgkJLy8gYWNjb3VudCBmb3IgZXJyb3IKCQlwcm9ncmVzcyA9IE1hdGgubWluKCBwcm9ncmVzcywgMSApOwoKCQljb25zdCBjdXJyVGltZSA9IHBlcmZvcm1hbmNlLm5vdygpOwoJCWlmICggY3VyclRpbWUgLSBwcmV2VGltZSA+PSAxMCAmJiBwcm9ncmVzcyAhPT0gMS4wICkgewoKCQkJcG9zdE1lc3NhZ2UoIHsKCgkJCQllcnJvcjogbnVsbCwKCQkJCXNlcmlhbGl6ZWQ6IG51bGwsCgkJCQlwb3NpdGlvbjogbnVsbCwKCQkJCXByb2dyZXNzLAoKCQkJfSApOwoJCQlwcmV2VGltZSA9IGN1cnJUaW1lOwoKCQl9CgoJfQoKCWNvbnN0IHsgaW5kZXgsIHBvc2l0aW9uLCBvcHRpb25zIH0gPSBkYXRhOwoJdHJ5IHsKCgkJY29uc3QgZ2VvbWV0cnkgPSBuZXcgQnVmZmVyR2VvbWV0cnkoKTsKCQlnZW9tZXRyeS5zZXRBdHRyaWJ1dGUoICdwb3NpdGlvbicsIG5ldyBCdWZmZXJBdHRyaWJ1dGUoIHBvc2l0aW9uLCAzLCBmYWxzZSApICk7CgkJaWYgKCBpbmRleCApIHsKCgkJCWdlb21ldHJ5LnNldEluZGV4KCBuZXcgQnVmZmVyQXR0cmlidXRlKCBpbmRleCwgMSwgZmFsc2UgKSApOwoKCQl9CgoJCWlmICggb3B0aW9ucy5pbmNsdWRlZFByb2dyZXNzQ2FsbGJhY2sgKSB7CgoJCQlvcHRpb25zLm9uUHJvZ3Jlc3MgPSBvblByb2dyZXNzQ2FsbGJhY2s7CgoJCX0KCgkJaWYgKCBvcHRpb25zLmdyb3VwcyApIHsKCgkJCWNvbnN0IGdyb3VwcyA9IG9wdGlvbnMuZ3JvdXBzOwoJCQlmb3IgKCBjb25zdCBpIGluIGdyb3VwcyApIHsKCgkJCQljb25zdCBncm91cCA9IGdyb3Vwc1sgaSBdOwoJCQkJZ2VvbWV0cnkuYWRkR3JvdXAoIGdyb3VwLnN0YXJ0LCBncm91cC5jb3VudCwgZ3JvdXAubWF0ZXJpYWxJbmRleCApOwoKCQkJfQoKCQl9CgoJCWNvbnN0IGJ2aCA9IG5ldyBNZXNoQlZIKCBnZW9tZXRyeSwgb3B0aW9ucyApOwoJCWNvbnN0IHNlcmlhbGl6ZWQgPSBNZXNoQlZILnNlcmlhbGl6ZSggYnZoLCB7IGNvcHlJbmRleEJ1ZmZlcjogZmFsc2UgfSApOwoJCWxldCB0b1RyYW5zZmVyID0gWyBwb3NpdGlvbi5idWZmZXIsIC4uLnNlcmlhbGl6ZWQucm9vdHMgXTsKCQlpZiAoIHNlcmlhbGl6ZWQuaW5kZXggKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kZXguYnVmZmVyICk7CgoJCX0KCgkJdG9UcmFuc2ZlciA9IHRvVHJhbnNmZXIuZmlsdGVyKCB2ID0+ICggdHlwZW9mIFNoYXJlZEFycmF5QnVmZmVyID09PSAndW5kZWZpbmVkJyApIHx8ICEgKCB2IGluc3RhbmNlb2YgU2hhcmVkQXJyYXlCdWZmZXIgKSApOwoKCQlpZiAoIGJ2aC5faW5kaXJlY3RCdWZmZXIgKSB7CgoJCQl0b1RyYW5zZmVyLnB1c2goIHNlcmlhbGl6ZWQuaW5kaXJlY3RCdWZmZXIuYnVmZmVyICk7CgoJCX0KCgkJcG9zdE1lc3NhZ2UoIHsKCgkJCWVycm9yOiBudWxsLAoJCQlzZXJpYWxpemVkLAoJCQlwb3NpdGlvbiwKCQkJcHJvZ3Jlc3M6IDEsCgoJCX0sIHRvVHJhbnNmZXIgKTsKCgl9IGNhdGNoICggZXJyb3IgKSB7CgoJCXBvc3RNZXNzYWdlKCB7CgoJCQllcnJvciwKCQkJc2VyaWFsaXplZDogbnVsbCwKCQkJcG9zaXRpb246IG51bGwsCgkJCXByb2dyZXNzOiAxLAoKCQl9ICk7CgoJfQoKfTsK",typeof document>"u"?require("url").pathToFileURL(__filename).href:dt&&dt.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=f=>{a(new Error(`GenerateMeshBVHWorker: ${f.message}`))},e.onmessage=f=>{const{data:p}=f;if(p.error)a(new Error(p.error)),e.onmessage=null;else if(p.serialized){const{serialized:r,position:l}=p,h=xs.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 _=new d.BufferAttribute(r.index,1,!1);t.setIndex(_)}g.setBoundingBox&&(t.boundingBox=h.getBoundingBox(new d.Box3)),i.onProgress&&i.onProgress(p.progress),s(h),e.onmessage=null}else i.onProgress&&i.onProgress(p.progress)};const n=t.index?t.index.array:null,c=t.attributes.position.array,u=[c];n&&u.push(n),e.postMessage({index:n,position:c,options:{...i,onProgress:null,includedProgressCallback:!!i.onProgress,groups:[...t.groups]}},u.map(f=>f.buffer).filter(f=>typeof SharedArrayBuffer>"u"||!(f instanceof SharedArrayBuffer)))})}}class mc{constructor(e,t){this.lock=!1,this.lockX=!1,this.lockY=!1,this.invRotMat=new d.Matrix4,this.mouse=new d.Vector3,this.rotateStart=new d.Vector2,this.rotateEnd=new d.Vector2,this.rotateDelta=new d.Vector2,this.selectedAxis=null,this.isDragging=!1,this.context=null,this.orbitState=!0,this._animator=0,this._emitter=new mt,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:u}=this.rect;this.mouse.set((s.clientX-c)*a,(s.clientY-u)*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,u=performance.now(),f=1,p=this.selectedAxis.axis,r=()=>{const h=performance.now()-u,g=Math.min(h/c,f);if(this.camera.position.lerp(a,g),this.orbit.update(),g!==f){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 u=a.axis==="-x"?this.options.fontSize-3:this.options.fontSize;this.context.font=[this.options.fontWeight,u+"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 d.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 d.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;
@@ -3924,9 +3924,9 @@ vec3 texelOld = texture2D(previousShadowMap, vUv).rgb;
3924
3924
  // Combine
3925
3925
  gl_FragColor = vec4(uColor, alpha * fade * uOpacity);
3926
3926
  }
3927
- `});super(s,a),this.position.z=-.02}}const Sc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Mc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Cc="https://cdn2.seer-group.com/libs/fonts.type.json",Rc=new fn.Font(Cc);class as{constructor(e){var t;this._props=e,this.name="",this._defaults={color:""},this.color="",this.name=this._props.name,this.color=this._defaults.color="#"+((t=e.target.color)==null?void 0:t.getHexString())}change(e){var t;this.color=e,(t=this._props.target.color)==null||t.set(e)}reset(){this.change(this._defaults.color)}}var $r=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))($r||{});const _r=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let ot,ci=0,ls=0;const Ic=()=>{ot=void 0,ci=0,ls=0},Dc=new d.MeshBasicMaterial({colorWrite:!1});class Lc{constructor(e){this.props=e,this.stats=new Pt,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new ve.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new qr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new d.Group,this._raycaster=new d.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new mt,this.sound=new Ga,this._rafId=null,this._destroyed=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Tc(18,40),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:u,left:f}=this.renderer.domElement.getBoundingClientRect();this.offset.set(f,u),this.mousePos.set(c.clientX-f,c.clientY-u),this.mouseCoord.set((c.clientX-f)/this.size.x*2-1,-((c.clientY-u)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const u=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(u,200)},this._detectTrackpad=()=>{ot||typeof ot<"u"||(ci===0&&(ls=performance.now()),ci++,performance.now()-ls>66&&(ci>5?ot=!0:ot=!1,ot?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Ic,2e3)))},this.debounceForkHeightChange=Ya(()=>{var c;(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,u)=>{var X;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(X=this._fitAnimation)==null||X.stop();const f=new d.Box3,p=new d.Box3,r=new d.Vector3,l=new d.Vector3,h=new d.Vector3,g=new d.Vector3,_=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||f.union(p))},m=U=>{var bs,As;const G=U.geometry,ne=(bs=G==null?void 0:G.attributes)==null?void 0:bs.position;if(!ne){_(U);return}const te=((As=G.morphAttributes)==null?void 0:As.position)||[],ws=U.morphTargetInfluences||[],tn=te.length>0&&ws.length>0;for(let Se=0;Se<ne.count;Se++){if(r.set(ne.getX(Se),ne.getY(Se),ne.getZ(Se)),tn){l.set(0,0,0);let yi=0;for(let Ge=0;Ge<te.length;Ge++){const Ot=ws[Ge]||0;Ot&&(yi+=Ot,h.set(te[Ge].getX(Se),te[Ge].getY(Se),te[Ge].getZ(Se)),G.morphTargetsRelative,l.addScaledVector(h,Ot))}G.morphTargetsRelative?r.add(l):yi>0&&(r.multiplyScalar(1-yi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),f.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(G=>{if(G.visible){if(G instanceof d.Mesh){m(G);return}(G.isPoint||G.isLine)&&_(G)}})}),f.isEmpty())return;const v=new d.Vector3;f.getCenter(v);const y=new d.Vector3;f.getSize(y);const x=v.clone();this._lastTarget.copy(x);let w;u?w=u.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),A=[new d.Vector3(b.x,b.y,b.z),new d.Vector3(b.x,b.y,-b.z),new d.Vector3(b.x,-b.y,b.z),new d.Vector3(b.x,-b.y,-b.z),new d.Vector3(-b.x,b.y,b.z),new d.Vector3(-b.x,b.y,-b.z),new d.Vector3(-b.x,-b.y,b.z),new d.Vector3(-b.x,-b.y,-b.z)],S=new d.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const C=new d.Vector3().crossVectors(w,S).normalize(),M=new d.Vector3().crossVectors(C,w).normalize();let I=0;A.forEach(U=>{const G=U.dot(C),ne=U.dot(M),te=Math.sqrt(G*G+ne*ne);I=Math.max(I,te)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,T=2*Math.atan(Math.tan(D/2)*this.camera.aspect),R=I/Math.tan(T/2),L=I/Math.tan(D/2),F=Math.max(R,L),E=v.clone().add(w.multiplyScalar(F)),z=this.camera.position.clone(),N=this.controls.target.clone();let j=500;const Z=z.distanceTo(E)+N.distanceTo(x);Z>.001&&(j=Math.min(1e3,Math.max(450,Z*45))),this._animateCamera(z,E,N,x,j)},this.focusSlots=c=>{var M,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const T=this.camera.position.clone(),R=this.controls.target.clone(),L=D.position.clone(),F=D.target.clone();let E=500;const z=T.distanceTo(L)+R.distanceTo(F);z>.001&&(E=Math.min(1e3,Math.max(450,z*45))),this._animateCamera(T,L,R,F,E,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(M=this._fitAnimation)!=null&&M.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const u=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const T=new d.Vector3;return D.parent.getWorldPosition(T),[T]});if(!u.length)return;const f=u.reduce((D,T)=>D.add(T),new d.Vector3).multiplyScalar(1/u.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of u){const T=D.clone().sub(f),R=T.dot(r),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>l&&(l=L)}l=l+.4;const h=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(h/2)*this.camera.aspect),_=l/Math.tan(g/2),m=l/Math.tan(h/2),v=Math.max(_,m),y=f.clone(),x=f.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),A={t:0};let S=500;const C=w.distanceTo(x)+b.distanceTo(y);C>.001&&(S=Math.min(1e3,Math.max(450,C*45))),this._lastTarget=y.clone(),this._fitAnimation=new hi(A).to({t:1},S).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=A.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new d.Box3().setFromObject(this._container);const u=this.amr.sizeBox.size.getSize(new d.Vector3),f=u.clone().multiplyScalar(.5),p=new d.Vector3(0,0,f.z);this._lastTarget.copy(p);let r=f.clone().sub(p);r.lengthSq()<1e-6&&(r=new d.Vector3(1,0,0));const l=r.clone().normalize(),h=u.clone().multiplyScalar(.5),g=[new d.Vector3(h.x,h.y,h.z),new d.Vector3(h.x,h.y,-h.z),new d.Vector3(h.x,-h.y,h.z),new d.Vector3(h.x,-h.y,-h.z),new d.Vector3(-h.x,h.y,h.z),new d.Vector3(-h.x,h.y,-h.z),new d.Vector3(-h.x,-h.y,h.z),new d.Vector3(-h.x,-h.y,-h.z)];let _=0;for(const T of g){const R=T.dot(l),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>_&&(_=L)}_=_*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=_/Math.tan(v/2),x=_/Math.tan(m/2),w=Math.max(y,x),b=f.clone();let A=u.z/3;u.z<u.x&&u.z<u.y&&(A=u.x*.8),u.z>u.x&&u.z>u.y&&(A=0),b.z+=A;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(u.x*2,5);const C=this.camera.position.clone(),M=this.controls.target.clone();let I=600;const D=C.distanceTo(S)+M.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(C,S,M,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const u=c.clientWidth,f=c.clientHeight;this.size.set(u,f),this.camera.aspect=u/f,this.camera.updateProjectionMatrix(),this._amrRender.setSize(u,f),this._updateCamera(),this.css2dRenderer.setSize(u,f),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(u,f),(r=this._jumpFlood)==null||r.setSize(u,f)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const u=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Dc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=u}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Fe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Br(He,this.renderer),this._ground.visible=!1,this.controls=new hn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=_r,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:Ur()?.2:1,this._cameraPositionUI=new yc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=ja();this.pathTracer=new oa(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new pc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,u=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=u};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new gc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),this._progressShadow.lightOrigin.position.set(3,2.5,6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Ac(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new mc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new Ss.HDRLoader().load(Mc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:_r,this.sampleCount=0}get fpsAverage(){return Vr(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof d.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new Ss.HDRLoader().load(Sc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new d.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let f=0;f<t;f++){const p=((i-u-1)*t+f)*4,r=(u*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new en({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){_e(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await Hr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this._progressShadow.recalculate())})}_animateCamera(e,t,i,s,a,n){var u;const c={t:0};(u=this._fitAnimation)==null||u.stop(),this._fitAnimation=new hi(c).to({t:1},a).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const f=c.t;this.controls.target.lerpVectors(i,s,f);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),h=r.length(),g=l.length(),_=h+(g-h)*f;let m;if(h>.001&&g>.001){const v=r.clone().normalize(),y=l.clone().normalize(),x=v.angleTo(y);if(x>.001){const w=new d.Vector3().crossVectors(v,y);if(w.lengthSq()>.001){w.normalize();const b=new d.Quaternion().setFromAxisAngle(w,x*f),A=v.clone().applyQuaternion(b);m=p.clone().add(A.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=e.clone().lerp(t,f);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e){typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile&&(e.classList.add("is-mobile"),e.style.cssText=`
3927
+ `});super(s,a),this.position.z=-.02}}const Sc="https://cdn2.seer-group.com/libs/hdr/aristea_wreck_512.hdr",Mc="https://cdn2.seer-group.com/libs/hdr/lightroom_14b_512.hdr",Cc="https://cdn2.seer-group.com/libs/fonts.type.json",Rc=new fn.Font(Cc);class as{constructor(e){var t;this._props=e,this.name="",this._defaults={color:""},this.color="",this.name=this._props.name,this.color=this._defaults.color="#"+((t=e.target.color)==null?void 0:t.getHexString())}change(e){var t;this.color=e,(t=this._props.target.color)==null||t.set(e)}reset(){this.change(this._defaults.color)}}var $r=(o=>(o[o.DEFAULT=0]="DEFAULT",o[o.CAN_INSTALL=1]="CAN_INSTALL",o))($r||{});const _r=.15;d.Object3D.DEFAULT_UP.set(0,0,1);let ot,ci=0,ls=0;const Ic=()=>{ot=void 0,ci=0,ls=0},Dc=new d.MeshBasicMaterial({colorWrite:!1});class Lc{constructor(e){this.props=e,this.stats=new Pt,this.scene=new d.Scene,this.overlayScene=new d.Scene,this.renderer=new d.WebGLRenderer({antialias:!0,alpha:!0,logarithmicDepthBuffer:!0,powerPreference:"high-performance",preserveDrawingBuffer:!0}),this.css2dRenderer=new ve.CSS2DRenderer,this.mousePos=new d.Vector2,this.mouseCoord=new d.Vector2,this.offset=new d.Vector2,this.size=new d.Vector2,this.amr=new qr({showSizeBox:!0,showController:!0}),this._selectedForOutline=[],this._clock=new d.Clock(!0),this._uiHiddenTime=this._clock.getElapsedTime(),this.camera=new d.PerspectiveCamera(39.6,window.innerWidth/window.innerHeight,.1,1e4),this.d=2,this.orthographicCamera=new d.OrthographicCamera(-this.d*(window.innerWidth/window.innerHeight),this.d*(window.innerWidth/window.innerHeight),this.d,-this.d,.1,1e3),this._axisMoving=!1,this._container=new d.Group,this._raycaster=new d.Raycaster,this._selected=[],this._pointerDownTimeout=0,this._dragging=!1,this.maxSample=1024*2,this.sampleCount=0,this._usePathTracing=!1,this._fpsCache=[],this._fpsCacheMax=20,this._emitter=new mt,this.sound=new Ga,this._rafId=null,this._destroyed=!1,this._ground=new d.Mesh(new d.PlaneGeometry(100,100),new d.MeshPhysicalMaterial({color:new d.Color("#eee"),metalness:.4,roughness:.1,clearcoat:1,clearcoatRoughness:.1})),this._sciFiGrid=new Tc(18,40),this._amrRender=new d.WebGLRenderTarget(1024,1024,{format:d.RGBAFormat,type:d.UnsignedByteType,colorSpace:d.SRGBColorSpace,samples:8}),this._lastTarget=new d.Vector3,this._shadowMode=!1,this.addEventListener=this._emitter.on.bind(this._emitter),this.removeEventListener=this._emitter.on.bind(this._emitter),this._showSlots=!0,this._showSize=!0,this._showControls=!0,this._drag=c=>{this._dragging=!0,this._pointermove(c)},this._dragend=c=>{this._dragging=!1},this._pointermove=c=>{if(this._pointerDownTimeout)return clearTimeout(this._pointerDownTimeout),this._pointerDownTimeout=0;let{top:u,left:f}=this.renderer.domElement.getBoundingClientRect();this.offset.set(f,u),this.mousePos.set(c.clientX-f,c.clientY-u),this.mouseCoord.set((c.clientX-f)/this.size.x*2-1,-((c.clientY-u)/this.size.y)*2+1),this._raycaster.setFromCamera(this.mouseCoord,this.camera)},this._pointerdown=c=>{const u=()=>{this.amr.slots.forEach(r=>r.selected=!1);const p=this._raycaster.intersectObjects(this.amr.slots,!1)[0];p&&this.amr.slots.forEach(r=>{r.traverse(l=>{l==p.object||(r.deviceSelected=!1)})}),this._pointerDownTimeout=0};this._pointerDownTimeout=window.setTimeout(u,200)},this._detectTrackpad=()=>{ot||typeof ot<"u"||(ci===0&&(ls=performance.now()),ci++,performance.now()-ls>66&&(ci>5?ot=!0:ot=!1,ot?this.controls.zoomSpeed=.2:this.controls.zoomSpeed=1,setTimeout(Ic,2e3)))},this.debounceForkHeightChange=Ya(()=>{var c;this._progressShadow.clear(),(c=this._progressShadow)==null||c.recalculate()},300),this.focusObjects=(c,u)=>{var X;if(!c.length){this.fit();return}this.scene.updateMatrixWorld(!0),this._focusRestoreView=void 0,(X=this._fitAnimation)==null||X.stop();const f=new d.Box3,p=new d.Box3,r=new d.Vector3,l=new d.Vector3,h=new d.Vector3,g=new d.Vector3,_=U=>{U.geometry&&(U.geometry.boundingBox||U.geometry.computeBoundingBox(),p.copy(U.geometry.boundingBox).applyMatrix4(U.matrixWorld),p.isEmpty()||f.union(p))},m=U=>{var bs,As;const G=U.geometry,ne=(bs=G==null?void 0:G.attributes)==null?void 0:bs.position;if(!ne){_(U);return}const te=((As=G.morphAttributes)==null?void 0:As.position)||[],ws=U.morphTargetInfluences||[],tn=te.length>0&&ws.length>0;for(let Se=0;Se<ne.count;Se++){if(r.set(ne.getX(Se),ne.getY(Se),ne.getZ(Se)),tn){l.set(0,0,0);let yi=0;for(let Ge=0;Ge<te.length;Ge++){const Ot=ws[Ge]||0;Ot&&(yi+=Ot,h.set(te[Ge].getX(Se),te[Ge].getY(Se),te[Ge].getZ(Se)),G.morphTargetsRelative,l.addScaledVector(h,Ot))}G.morphTargetsRelative?r.add(l):yi>0&&(r.multiplyScalar(1-yi),r.add(l))}g.copy(r).applyMatrix4(U.matrixWorld),f.expandByPoint(g)}};if(c.forEach(U=>{U.traverse(G=>{if(G.visible){if(G instanceof d.Mesh){m(G);return}(G.isPoint||G.isLine)&&_(G)}})}),f.isEmpty())return;const v=new d.Vector3;f.getCenter(v);const y=new d.Vector3;f.getSize(y);const x=v.clone();this._lastTarget.copy(x);let w;u?w=u.clone().normalize().negate():w=this.camera.position.clone().sub(this.controls.target).normalize();const b=y.clone().multiplyScalar(.5),A=[new d.Vector3(b.x,b.y,b.z),new d.Vector3(b.x,b.y,-b.z),new d.Vector3(b.x,-b.y,b.z),new d.Vector3(b.x,-b.y,-b.z),new d.Vector3(-b.x,b.y,b.z),new d.Vector3(-b.x,b.y,-b.z),new d.Vector3(-b.x,-b.y,b.z),new d.Vector3(-b.x,-b.y,-b.z)],S=new d.Vector3(0,1,0);Math.abs(w.dot(S))>.99&&S.set(0,0,1);const C=new d.Vector3().crossVectors(w,S).normalize(),M=new d.Vector3().crossVectors(C,w).normalize();let I=0;A.forEach(U=>{const G=U.dot(C),ne=U.dot(M),te=Math.sqrt(G*G+ne*ne);I=Math.max(I,te)}),I=I/2+.4;const D=this.camera.fov*Math.PI/180,T=2*Math.atan(Math.tan(D/2)*this.camera.aspect),R=I/Math.tan(T/2),L=I/Math.tan(D/2),F=Math.max(R,L),E=v.clone().add(w.multiplyScalar(F)),z=this.camera.position.clone(),N=this.controls.target.clone();let j=500;const Z=z.distanceTo(E)+N.distanceTo(x);Z>.001&&(j=Math.min(1e3,Math.max(450,Z*45))),this._animateCamera(z,E,N,x,j)},this.focusSlots=c=>{var M,I;if(this.amr.slots.forEach(D=>{D.focused=!1,D.hide()}),!c.length)if(this._lastTarget.set(0,0,this._lastTarget.z),this.amr.slots.forEach(D=>{D.show()}),this.shadowMode=!1,this._focusRestoreView){const D=this._focusRestoreView;this._focusRestoreView=void 0;const T=this.camera.position.clone(),R=this.controls.target.clone(),L=D.position.clone(),F=D.target.clone();let E=500;const z=T.distanceTo(L)+R.distanceTo(F);z>.001&&(E=Math.min(1e3,Math.max(450,z*45))),this._animateCamera(T,L,R,F,E,()=>{this.camera.up.copy(D.up)});return}else{this.fit();return}(M=this._fitAnimation)!=null&&M.isPlaying()||this.shadowMode||(this._focusRestoreView={position:this.camera.position.clone(),target:new d.Vector3(0,0,this.controls.target.z),up:this.camera.up.clone()}),(I=this._fitAnimation)==null||I.stop(),this.shadowMode=!0;const u=c.flatMap(D=>{if(D.show(),D.focused=!0,!D.parent)return[];const T=new d.Vector3;return D.parent.getWorldPosition(T),[T]});if(!u.length)return;const f=u.reduce((D,T)=>D.add(T),new d.Vector3).multiplyScalar(1/u.length),p=this.controls.target.clone(),r=this.camera.position.clone().sub(p).normalize();let l=0;for(const D of u){const T=D.clone().sub(f),R=T.dot(r),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>l&&(l=L)}l=l+.4;const h=this.camera.fov*Math.PI/180,g=2*Math.atan(Math.tan(h/2)*this.camera.aspect),_=l/Math.tan(g/2),m=l/Math.tan(h/2),v=Math.max(_,m),y=f.clone(),x=f.clone().add(r.clone().multiplyScalar(v<1?1:v)),w=this.camera.position.clone(),b=p.clone(),A={t:0};let S=500;const C=w.distanceTo(x)+b.distanceTo(y);C>.001&&(S=Math.min(1e3,Math.max(450,C*45))),this._lastTarget=y.clone(),this._fitAnimation=new hi(A).to({t:1},S).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const D=A.t;this.camera.position.lerpVectors(w,x,D),this.controls.target.lerpVectors(b,y,D)}).onComplete(()=>{this.controls.enabled=!0}).start()},this.fit=()=>{this._focusRestoreView=void 0,new d.Box3().setFromObject(this._container);const u=this.amr.sizeBox.size.getSize(new d.Vector3),f=u.clone().multiplyScalar(.5),p=new d.Vector3(0,0,f.z);this._lastTarget.copy(p);let r=f.clone().sub(p);r.lengthSq()<1e-6&&(r=new d.Vector3(1,0,0));const l=r.clone().normalize(),h=u.clone().multiplyScalar(.5),g=[new d.Vector3(h.x,h.y,h.z),new d.Vector3(h.x,h.y,-h.z),new d.Vector3(h.x,-h.y,h.z),new d.Vector3(h.x,-h.y,-h.z),new d.Vector3(-h.x,h.y,h.z),new d.Vector3(-h.x,h.y,-h.z),new d.Vector3(-h.x,-h.y,h.z),new d.Vector3(-h.x,-h.y,-h.z)];let _=0;for(const T of g){const R=T.dot(l),L=Math.sqrt(Math.max(0,T.lengthSq()-R*R));L>_&&(_=L)}_=_*1.05;const m=this.camera.fov*Math.PI/180,v=2*Math.atan(Math.tan(m/2)*this.camera.aspect),y=_/Math.tan(v/2),x=_/Math.tan(m/2),w=Math.max(y,x),b=f.clone();let A=u.z/3;u.z<u.x&&u.z<u.y&&(A=u.x*.8),u.z>u.x&&u.z>u.y&&(A=0),b.z+=A;const S=r.clone().normalize().multiplyScalar(w<1?1:w).add(b);Math.max(u.x*2,5);const C=this.camera.position.clone(),M=this.controls.target.clone();let I=600;const D=C.distanceTo(S)+M.distanceTo(p);D>.001&&(I=Math.min(800,Math.max(650,D*45))),this._animateCamera(C,S,M,p,I,()=>{this.shadowMode||(this._progressShadow.visible=!0,this._progressShadow.isFinished||this._progressShadow.recalculate())}),this.controls.minDistance=Math.max(.2,Math.min(w*.25,w-.1)),this.controls.maxDistance=w*4},this.resize=()=>{var p,r;const c=this.renderer.domElement.parentElement;if(!c)return;c.style.display="flex",this.renderer.domElement.style.width="100%",this.renderer.domElement.style.height="100%",this.renderer.domElement.style.flexGrow="1";const u=c.clientWidth,f=c.clientHeight;this.size.set(u,f),this.camera.aspect=u/f,this.camera.updateProjectionMatrix(),this._amrRender.setSize(u,f),this._updateCamera(),this.css2dRenderer.setSize(u,f),this.renderer.getPixelRatio(),(p=this.pathTracer)==null||p.updateCamera(),this.sampleCount=0,this.renderer.setSize(u,f),(r=this._jumpFlood)==null||r.setSize(u,f)},this.ticker=c=>{if(!this._destroyed){if(this.stats.begin(),this.renderer.domElement.dispatchEvent(new CustomEvent("ticker",{detail:c})),this._rafId=requestAnimationFrame(this.ticker),this.renderer.clear(),this.usePathTracing){this.hideAmrUI(),this.sampleCount<this.maxSample?this.sampleCount++:this.pathTracer.pausePathTracing=!0,this.pathTracer.renderSample();const u=this.renderer.autoClear;this.renderer.autoClear=!1,this.scene.overrideMaterial=Dc,this.renderer.clearDepth(),this.renderer.render(this.scene,this.mainCamera),this.scene.overrideMaterial=null,this.renderer.render(this.overlayScene,this.mainCamera),this.renderer.autoClear=u}else{this._clock.getElapsedTime()-this._uiHiddenTime>.15?this.showControls&&this.amr.controllers.forEach(p=>p.show()):this.amr.controllers.forEach(p=>p.hide());const f=this.stats.fps();if(this.usePathTracing||(this._fpsCache.length>this._fpsCacheMax&&this._fpsCache.shift(),this._fpsCache.push(f)),this.amr.slots.forEach(p=>{this._dragging?p.getCanInstall()&&p.render(this):p.render(this)}),Fe.update(),this.controls.update(),this._progressShadow.update(this.mainCamera),this.css2dRenderer.render(this.scene,this.mainCamera),this.updatePosition(),this.scene.overrideMaterial=null,this.renderer.render(this.scene,this.mainCamera),this._jumpFlood&&this._selectedForOutline.length>0){const p=this.scene.background;this.scene.background=null,this._jumpFlood.render(this._selectedForOutline),this.scene.background=p}}this.stats.end()}},this.stats.showPanel(0),this.hideState(),e.fov&&(this.camera.fov=e.fov,this.camera.updateProjectionMatrix()),Br(He,this.renderer),this._ground.visible=!1,this.controls=new hn.OrbitControls(this.camera,this.renderer.domElement),this.controls.enablePan=!0,this.controls.rotateSpeed=this.props.isMobile?.6:.5,this.controls.dampingFactor=_r,this.controls.enableDamping=!0,this.controls.maxDistance=10,this.controls.minDistance=1,this.controls.zoomSpeed=this.props.isMobile?.3:Ur()?.2:1,this._cameraPositionUI=new yc(this.controls),this.renderer.setPixelRatio(window.devicePixelRatio||1),this.renderer.autoClear=!0,this.renderer.toneMapping=d.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.4,this.renderer.outputColorSpace=d.SRGBColorSpace,this.renderer.localClippingEnabled=!0,this.renderer.shadowMap.enabled=!0,this.css2dRenderer.domElement.style.pointerEvents="none",this.css2dRenderer.domElement.style.position="absolute",this.css2dRenderer.domElement.style.top="0px",this.camera.position.set(10,-10,5),this.camera.lookAt(new d.Vector3);const{tiles:t}=ja();this.pathTracer=new oa(this.renderer),this.pathTracer.multipleImportanceSampling=!0,this.pathTracer.filterGlossyFactor=.6;let i=window.devicePixelRatio;i<2&&(i=2),this.pathTracer.renderScale=this.props.isMobile?1:i,this.pathTracer.bounces=this.props.isMobile?8:10,this.pathTracer.transmissiveBounces=this.props.isMobile?1:3,this.pathTracer.tiles.set(t,t),this.pathTracer.minSamples=10,this.pathTracer.dynamicLowRes=!0,this.pathTracer.lowResScale=.5,this.pathTracer.fadeDuration=0;const s=new pc(e.workerUrl),a=typeof navigator<"u"?navigator.hardwareConcurrency:4;s.maxWorkerCount=a,this.pathTracer.setBVHWorker(s),this.orthographicCamera.left=-20,this.orthographicCamera.right=20,this.orthographicCamera.top=-20,this.orthographicCamera.bottom=20,this._lastTarget=this.controls.target.clone();const n=()=>{let c=this._lastTarget.x,u=this._lastTarget.y;this.controls.target.x=c,this.controls.target.y=u};this.controls.addEventListener("change",()=>{var c;this.sampleCount=0,n(),this._uiHiddenTime=this._clock.getElapsedTime(),this.orthographicCamera.position.copy(this.camera.position),this.orthographicCamera.lookAt(this.controls.target),this.usePathTracing&&(this.pathTracer.pausePathTracing=!1,(c=this.pathTracer)==null||c.updateCamera()),this._updateCamera(),!(Math.abs(this.camera.position.x)<.001||Math.abs(this.camera.position.y)<.001)&&(this._axisMoving||(this.mainCamera=this.camera,this.usePathTracing&&this.generateBVH().then()))}),this._mainCamera=this.camera,this._progressShadow=new gc(this.renderer,this.scene,{size:8,lightCount:e.isMobile?6:12,frames:e.isMobile?80:120,lightRadius:8,ambientWeight:.8}),this._progressShadow.lightOrigin.position.set(3,2.5,6),this._progressShadow.visible=!1,this._container.add(this.amr),this.scene.add(this._container),this.ticker(0),this._loadEnv(),this._initEvents(),this.scene.add(this._cameraPositionUI),this._ground.rotateX(-Math.PI/2),this.scene.add(this._ground),this._jumpFlood=new Ac(this.renderer,this.scene,this.camera,{thickness:4,color:"#fff"}),(typeof e.useAxisBall!="boolean"||e.useAxisBall)&&(this._controlsGizmo=new mc(this.controls,{size:160,padding:12,offset:e.axisBallOffset||new d.Vector2(10,10),fontSize:17,bubbleSizePrimary:18,bubbleSizeSecondary:14}),this._controlsGizmo.addListener("axis-select-start",()=>{this._axisMoving=!0,this.mainCamera=this.orthographicCamera,this.usePathTracing&&this.generateBVH().then()}),this._controlsGizmo.addListener("axis-select-end",()=>{this._axisMoving=!1}))}get usePathTracing(){return this._usePathTracing}_clearAmrContent(){const e=this.renderer.getRenderTarget();this.renderer.setRenderTarget(this._amrRender),this.renderer.setClearColor(0,0),this.renderer.clear(!0,!0,!0),this.renderer.setRenderTarget(e)}get shadowMode(){return this._shadowMode}set shadowMode(e){e?(this._progressShadow.visible=!1,this.amr.bodyOpacity=.2):(this._progressShadow.visible=!0,this.amr.bodyOpacity=1,this._progressShadow.isFinished||this._progressShadow.recalculate().then()),this._shadowMode=e}set usePathTracing(e){this._clearAmrContent(),e?(this.scene.background=new d.Color("transparent"),this.renderer.toneMappingExposure=1.8,this.overlayScene.add(this._progressShadow.shadowCatcherMesh),this.amr&&(this.amr.bodyOpacity=1),this.hideAmrUI(),this.pathTracer.renderToCanvas=!0,this.scene.background=null,this._ptEnvMap?(this.scene.environment=this._ptEnvMap,this.pathTracer.updateEnvironment()):new Ss.HDRLoader().load(Mc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._ptEnvMap=t,this.usePathTracing&&(this.scene.environment=t,this.pathTracer.updateEnvironment())})):(this.renderer.toneMappingExposure=1.4,this.scene.add(this._progressShadow.shadowCatcherMesh),this.pathTracer.renderToCanvas=!1,this.amr.logos.forEach(t=>{var i;(i=t.parent)==null||i.add(t.target)}),this.showAmrUI(),this.amr&&this.amr.opacityCache!==void 0?(this.amr.bodyOpacity=this.amr.opacityCache,this.amr.opacityCache=void 0):this.amr&&(this.amr.bodyOpacity=1),this.pathTracer.reset(),this._ground.visible=!1,this._envMap&&(this.scene.background=this._envMap,this.scene.environment=this._envMap)),this._usePathTracing=e,this.controls.dampingFactor=e?1:_r,this.sampleCount=0}get fpsAverage(){return Vr(this._fpsCache)}get mainCamera(){return this._mainCamera}set mainCamera(e){this._mainCamera=e,e instanceof d.OrthographicCamera?this.scene.background=null:this.scene.background=this.scene.environment}showState(){this.stats.dom.style.display="block"}hideState(){this.stats.dom.style.display="none"}hideAmrUI(e=!0,t=!0){this.shadowMode||this.amr.slots.forEach(i=>i.hide()),this.amr.sizeBox.hide(e),this.amr.controllers.forEach(i=>i.hide()),t&&this.amr.goods.forEach(i=>i.hide())}showAmrUI(e=!0){this.showSlots&&this.amr.slots.forEach(t=>t.show()),this.showSize&&this.amr.sizeBox.show(e),this.showControls&&this.amr.controllers.forEach(t=>t.show()),this.amr.goods.forEach(t=>t.show())}get showSlots(){return this._showSlots}set showSlots(e){this._showSlots=e,this.amr.slots.forEach(t=>e?t.show():t.hide())}get showSize(){return this._showSize}set showSize(e){this._showSize=e,e?this.amr.sizeBox.show(!0):this.amr.sizeBox.hide(!0)}get showControls(){return this._showControls}set showControls(e){this._showControls=e,this.amr.controllers.forEach(t=>e?t.show():t.hide())}_updateCamera(){const e=this.mainCamera.position.distanceTo(this.controls.target),t=2*Math.tan(this.camera.fov*.5*Math.PI/180)*e,i=this.size.x/this.size.y;this.orthographicCamera.left=-t*i/2,this.orthographicCamera.right=t*i/2,this.orthographicCamera.top=t/2,this.orthographicCamera.bottom=-t/2,this.orthographicCamera.updateProjectionMatrix()}_loadEnv(){new Ss.HDRLoader().load(Sc,t=>{t.mapping=d.EquirectangularReflectionMapping,this._envMap=t,this._usePathTracing||(this.scene.background=t,this.scene.backgroundBlurriness=1,this.scene.backgroundIntensity=1,this.scene.backgroundRotation=new d.Euler(Math.PI/2,0,Math.PI*.98*.8),this.scene.environment=t,this.overlayScene.environment=t,this.scene.environmentRotation=this.scene.backgroundRotation,this.overlayScene.environmentRotation=this.scene.environmentRotation,this.scene.environmentIntensity=1.4,this.overlayScene.environmentIntensity=this.scene.environmentIntensity),this.pathTracer.updateEnvironment()},()=>{},()=>{})}_initEvents(){window.addEventListener("drag",this._drag),window.addEventListener("dragend",this._dragend),document.addEventListener("wheel",this._detectTrackpad),window.addEventListener("pointermove",this._pointermove),this.renderer.domElement.addEventListener("pointerdown",this._pointerdown);const e=this.scene.children.find(t=>t.type==="Mesh");e&&this.select(e)}switchCamera(){this.mainCamera=this.mainCamera===this.camera?this.orthographicCamera:this.camera}toCameraTop(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,e+this.controls.target.y,0))}toCameraRight(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(0,this.controls.target.y,e))}toCameraFace(){const e=this.camera.position.distanceTo(this.controls.target);this.camera.position.copy(new d.Vector3(e,this.controls.target.y,0))}async generateBVH(){this.pathTracer.pausePathTracing=!1,this.amr.slots.forEach(e=>e.hide()),this.amr&&(this.amr.opacityCache=this.amr.bodyOpacity,this.amr.bodyOpacity=1,this.overlayScene.clear(),this.amr.logos.forEach(e=>{const t=new d.Group;e.target.updateMatrixWorld(!0),t.applyMatrix4(e.target.matrixWorld),t.add(e.target),this.overlayScene.add(t)})),this.usePathTracing=!0,this.pathTracer.setScene(this.scene,this.mainCamera)}async download(e=!1){if(e&&!this.usePathTracing){const t=this._amrRender.width,i=this._amrRender.height,s=new Uint8Array(t*i*4);this.renderer.setRenderTarget(this._amrRender),this.renderer.readRenderTargetPixels(this._amrRender,0,0,t,i,s),this.renderer.setRenderTarget(null);const a=document.createElement("canvas");a.width=t,a.height=i;const n=a.getContext("2d"),c=new ImageData(t,i);for(let u=0;u<i;u++)for(let f=0;f<t;f++){const p=((i-u-1)*t+f)*4,r=(u*t+f)*4;c.data[r]=s[p],c.data[r+1]=s[p+1],c.data[r+2]=s[p+2],c.data[r+3]=s[p+3]}return n.putImageData(c,0,0),a.toDataURL("image/png")}else return new Promise((t,i)=>{this._uiHiddenTime=this._clock.getElapsedTime(),this.hideAmrUI();const s=this.scene.background;this.scene.background=null,setTimeout(()=>{const a=this.renderer.domElement.toDataURL("image/png");return this.scene.background=s,t(a)},this.fpsAverage)})}async captureTriViews(e){var n;const t=(e==null?void 0:e.subject)??this._container;(n=this._progressShadow)==null||n.visible;const i=this.scene.background,s=this.showSize;return new en({renderer:this.renderer,scene:this.scene,overlayScene:this.overlayScene,subject:t,onBeforeCapture:()=>{this.scene.background=null,this.hideAmrUI(),this.showSize=!1,this.usePathTracing&&(this.usePathTracing=!1),this._progressShadow.visible=!1},onAfterCapture:()=>{this.scene.background=i,this.showAmrUI(),this.showSize=s,this._progressShadow.visible=!0}}).capture(e)}clearAMR(){_e(this.overlayScene),this.amr.clean(),this.usePathTracing=!1}async exportAMR(){const e=this._container.clone(!0);return e.traverse(t=>{t.dispose&&(t.dispose(),t.removeFromParent())}),await Hr.parseAsync(e,{onlyVisible:!0,binary:!0})}async addAMR(e,t=""){this.amr.init(this),await this.amr.load(e,t),this.amr.addEventListener("fork-height-change",this.debounceForkHeightChange),this.amr.addEventListener("shape-key-changed",(i,s)=>{this.pathTracer.reset(),this.sampleCount=0,this.pathTracer.setScene(this.scene,this.camera),this.overlayScene.traverse(a=>{if(!Object.keys(a.morphTargetDictionary||{}).includes(i))return;let n=s;a.userData[`origin_${i}`]&&(n-=a.userData[`origin_${i}`]);const c=a.morphTargetDictionary[i];a.morphTargetInfluences&&(a.morphTargetInfluences[c]=n),a instanceof d.Mesh&&a.geometry.translate(0,0,1e-5)}),["width","length","liftLength","liftWidth","liftOuterWidth"].includes(i)&&(this._progressShadow.clear(),this.debounceForkHeightChange())})}_animateCamera(e,t,i,s,a,n){var u;const c={t:0};(u=this._fitAnimation)==null||u.stop(),this._fitAnimation=new hi(c).to({t:1},a).easing(Fe.Easing.Quadratic.InOut).onStart(()=>{this.controls.enabled=!1}).onUpdate(()=>{const f=c.t;this.controls.target.lerpVectors(i,s,f);const p=s.clone(),r=e.clone().sub(p),l=t.clone().sub(p),h=r.length(),g=l.length(),_=h+(g-h)*f;let m;if(h>.001&&g>.001){const v=r.clone().normalize(),y=l.clone().normalize(),x=v.angleTo(y);if(x>.001){const w=new d.Vector3().crossVectors(v,y);if(w.lengthSq()>.001){w.normalize();const b=new d.Quaternion().setFromAxisAngle(w,x*f),A=v.clone().applyQuaternion(b);m=p.clone().add(A.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=p.clone().add(v.multiplyScalar(_))}else m=e.clone().lerp(t,f);this.camera.position.copy(m),this.camera.lookAt(this.controls.target)}).onComplete(()=>{this.controls.enabled=!0,n==null||n()}).start()}select(e){typeof e=="string"||(Array.isArray(e)?this._selectedForOutline=[...e]:this._selectedForOutline=[e])}appendTo(e){e.append(this.renderer.domElement),e.append(this.stats.dom),e.append(this.css2dRenderer.domElement),this.props.isMobile?(e.classList.add("is-mobile"),e.style.cssText=`
3928
3928
  -webkit-user-select: none;
3929
3929
  user-select: none;
3930
3930
  touch-action: none;
3931
3931
  -webkit-touch-callout: none;
3932
- `),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(),Fe.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(),_e(this.scene),this.scene.clear()}}class en{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,n,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};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 A=this.configureCamera(w,b,f,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const S=this.readPixels(t,r,a,n);h[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}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 d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,n=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.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 u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),S=Math.max(Math.tan(A/2),1e-4),C=Math.max(S*(i||1),1e-4),M=this.getPerspectiveDirection(t,e.size).normalize(),I=new d.Vector3().crossVectors(M,u).normalize();I.lengthSq()<1e-6&&I.set(1,0,0);const D=new d.Vector3().crossVectors(I,M).normalize(),T=Math.max(e.size.x*.5,1e-4),R=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),F=[new d.Vector3(-T,-R,-L),new d.Vector3(-T,-R,L),new d.Vector3(-T,R,-L),new d.Vector3(-T,R,L),new d.Vector3(T,-R,-L),new d.Vector3(T,-R,L),new d.Vector3(T,R,-L),new d.Vector3(T,R,L)];let E=0,z=-1/0;for(const Z of F){const X=I.dot(Z),U=D.dot(Z),G=M.dot(Z);z=Math.max(z,G);const ne=G+Math.abs(X)/C,te=G+Math.abs(U)/S;E=Math.max(E,ne,te)}E=Math.max(E,z+.1);const N=E*(1+s);let j=1/0;for(const Z of F){const X=M.dot(Z),U=N-X;U>.001&&(j=Math.min(j,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(j)?j*.5:N*.1),w.far=Math.max(w.near+1,N+e.sphere.radius*3),w.position.copy(e.center).add(M.clone().multiplyScalar(N)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(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(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),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 d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new d.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(n,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.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 d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.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 u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,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 Pc="shop-components",Fc="0.4.10",Ec="Shop components",kc="dist/shop-components.umd.js",Bc="dist/shop-components.mjs",Oc="dist/main.d.ts",zc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build",v:"auto-changelog -p && git add CHANGELOG.md"},Vc=["dist","package.json"],Uc=[],Wc="machengda<machengda@seer-group.com>",Hc="ISC",Nc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Gc={"string-width":"4.2.3"},qc={"@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.180.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.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},jc={name:Pc,version:Fc,description:Ec,main:kc,module:Bc,types:Oc,scripts:zc,files:Vc,keywords:Uc,author:Wc,license:Hc,devDependencies:Nc,resolutions:Gc,dependencies:qc};function yr(){const o="Nebular Engin",e=jc.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 xr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[xr]||(o[xr]=!0,yr())}catch{yr()}exports.Amr=qr;exports.Logo=Ki;exports.SGLBLoader=kt;exports.SLOT_EVENTS=Y;exports.Scene3D=Lc;exports.Skin=as;exports.Slot=Xi;exports.SlotState=$r;exports.TriViewCapture=en;exports.arrayBufferToUrl=Yi;exports.calculateArrayAverage=Vr;exports.calculateFocalLength=Ha;exports.createSGLBFile=Ja;exports.downloadBlob=Wa;exports.dracoExporter=Ka;exports.font=Rc;exports.gltfExporter=Hr;exports.gltfLoader=He;exports.imageBitmapToUrl=Zi;exports.isAppleDevice=Ur;exports.textureLoader=vs;
3932
+ `):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(),Fe.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(),_e(this.scene),this.scene.clear()}}class en{constructor(e){this.deps=e,this.canvas=null,this.pixelBuffer=null,this.orthoCamera=new d.OrthographicCamera(-1,1,1,-1,.1,1e3),this.orthoCamera.position.set(0,0,5),this.perspectiveCamera=new d.PerspectiveCamera(45,1,.1,2e3)}async capture(e){var g,_,m,v,y,x;const t=this.deps.renderer,i=(e==null?void 0:e.subject)??this.deps.subject;if(!i)throw new Error("TriViewCapture: subject is required.");const s=new d.Vector2;t.getSize(s);const a=((g=e==null?void 0:e.size)==null?void 0:g.width)??Math.round(s.x),n=((_=e==null?void 0:e.size)==null?void 0:_.height)??Math.round(s.y),c=(e==null?void 0:e.margin)??.15,u=(e==null?void 0:e.includeOverlay)??!1,f=a/n||1,p=this.resolveViews(e==null?void 0:e.views),r=new d.WebGLRenderTarget(a,n,{format:d.RGBAFormat,type:d.UnsignedByteType});r.texture.colorSpace=d.SRGBColorSpace,r.texture.generateMipmaps=!1,r.depthBuffer=!0;const l=this.storeRendererState(t),h={};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 A=this.configureCamera(w,b,f,c,a,n);t.setRenderTarget(r),t.clear(!0,!0,!0),t.render(this.deps.scene,A),u&&this.deps.overlayScene&&(t.clearDepth(),t.render(this.deps.overlayScene,A));const S=this.readPixels(t,r,a,n);h[b.key]=S}}finally{r.dispose(),this.restoreRendererState(t,l),(x=(y=this.deps).onAfterCapture)==null||x.call(y)}return h}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 d.Vector3(0,0,1),up:new d.Vector3(0,1,0),plane:{width:"x",height:"y",depth:"z"}},{key:"front",direction:new d.Vector3(0,-1,0),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"}},{key:"side",direction:new d.Vector3(1,0,0),up:new d.Vector3(0,0,1),plane:{width:"y",height:"z",depth:"x"}},{key:"perspective",direction:new d.Vector3(1,1,1),up:new d.Vector3(0,0,1),plane:{width:"x",height:"z",depth:"y"},mode:"perspective",fov:39.6}]}computeBounds(e){const t=new d.Box3,i=new d.Box3,s=new d.Vector3,a=new d.Vector3,n=new d.Sphere;return e.updateMatrixWorld(!0),e.traverse(c=>{if(!c.visible)return;const f=c.geometry;if(!f)return;f.boundingBox||f.computeBoundingBox();const p=f.boundingBox;p&&(i.copy(p).applyMatrix4(c.matrixWorld),t.union(i))}),t.isEmpty()?(t.setFromCenterAndSize(s,new d.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 u=t.up.clone().normalize();if(Math.abs(u.dot(c))>.999&&(u.set(0,0,1),Math.abs(u.dot(c))>.999&&u.set(0,1,0)),(t.mode??"orthographic")==="perspective"){const w=this.perspectiveCamera,b=t.fov??45,A=d.MathUtils.degToRad(b),S=Math.max(Math.tan(A/2),1e-4),C=Math.max(S*(i||1),1e-4),M=this.getPerspectiveDirection(t,e.size).normalize(),I=new d.Vector3().crossVectors(M,u).normalize();I.lengthSq()<1e-6&&I.set(1,0,0);const D=new d.Vector3().crossVectors(I,M).normalize(),T=Math.max(e.size.x*.5,1e-4),R=Math.max(e.size.y*.5,1e-4),L=Math.max(e.size.z*.5,1e-4),F=[new d.Vector3(-T,-R,-L),new d.Vector3(-T,-R,L),new d.Vector3(-T,R,-L),new d.Vector3(-T,R,L),new d.Vector3(T,-R,-L),new d.Vector3(T,-R,L),new d.Vector3(T,R,-L),new d.Vector3(T,R,L)];let E=0,z=-1/0;for(const Z of F){const X=I.dot(Z),U=D.dot(Z),G=M.dot(Z);z=Math.max(z,G);const ne=G+Math.abs(X)/C,te=G+Math.abs(U)/S;E=Math.max(E,ne,te)}E=Math.max(E,z+.1);const N=E*(1+s);let j=1/0;for(const Z of F){const X=M.dot(Z),U=N-X;U>.001&&(j=Math.min(j,U))}return w.fov=b,w.aspect=i||a/Math.max(n,1),w.near=Math.max(.1,Number.isFinite(j)?j*.5:N*.1),w.far=Math.max(w.near+1,N+e.sphere.radius*3),w.position.copy(e.center).add(M.clone().multiplyScalar(N)),w.up.copy(D),w.lookAt(e.center),w.updateProjectionMatrix(),w.updateMatrixWorld(!0),w}const p=this.orthoCamera,r=e.size,l=e.center,h=Math.max(r[t.plane.width]*.5,.01),g=Math.max(r[t.plane.height]*.5,.01),_=Math.max(r[t.plane.depth]*.5,.01);let m=h*(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(y));return p.left=-m,p.right=m,p.top=v,p.bottom=-v,p.near=.1,p.far=y*4,p.zoom=1,p.position.copy(x),p.up.copy(u),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 d.Vector3(Math.abs(i.x)||1,Math.abs(i.y)||1,Math.abs(i.z)||1),a=new d.Vector3(Math.sign(i.x||1),Math.sign(i.y||1),Math.sign(i.z||1)),n=.25,c=new d.Vector3(Math.max(n,s.x)*Math.max(t.x,.001),Math.max(n,s.y)*Math.max(t.y,.001),0),u=Math.max((t.x+t.y)*.5,.001),f=Math.max(t.z,.001),p=Math.max(n,s.z),r=f*.5+u*.5;return c.z=p*r,c.multiply(a),c}storeRendererState(e){const t=new d.Vector2;e.getSize(t);const i=new d.Vector4;e.getViewport(i);const s=new d.Vector4;e.getScissor(s);const a=e.getClearColor(new d.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 d.Color);e.setClearColor(a,0)}else s instanceof d.Color?e.setClearColor(s,1):e.setClearColor(new d.Color(s),1);else{const a=e.getClearColor(new d.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 u=c.createImageData(i,s),f=u.data,p=this.pixelBuffer;for(let r=0;r<s;r+=1){const h=(s-r-1)*i*4,g=r*i*4;f.set(p.subarray(h,h+i*4),g)}return c.putImageData(u,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 Pc="shop-components",Fc="0.4.11",Ec="Shop components",kc="dist/shop-components.umd.js",Bc="dist/shop-components.mjs",Oc="dist/main.d.ts",zc={dts:"tsc --emitDeclarationOnly & tsc & storybook build -o dist",dev:"vite dev",build:"vite build",v:"auto-changelog -p && git add CHANGELOG.md"},Vc=["dist","package.json"],Uc=[],Wc="machengda<machengda@seer-group.com>",Hc="ISC",Nc={"@needle-tools/gltf-progressive":"^3.3.5","auto-changelog":"^2.4.0",vite:"5.1.6","vite-plugin-dts":"^3.7.3"},Gc={"string-width":"4.2.3"},qc={"@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.180.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.180.0","three-gpu-pathtracer":"^0.0.23","three-mesh-bvh":"^0.7.5","troika-three-text":"^0.49.1",tweakpane:"^4.0.3"},jc={name:Pc,version:Fc,description:Ec,main:kc,module:Bc,types:Oc,scripts:zc,files:Vc,keywords:Uc,author:Wc,license:Hc,devDependencies:Nc,resolutions:Gc,dependencies:qc};function yr(){const o="Nebular Engin",e=jc.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 xr="__SHOP_COMPONENTS_BANNER_PRINTED__";try{const o=globalThis;o[xr]||(o[xr]=!0,yr())}catch{yr()}exports.Amr=qr;exports.Logo=Ki;exports.SGLBLoader=kt;exports.SLOT_EVENTS=Y;exports.Scene3D=Lc;exports.Skin=as;exports.Slot=Xi;exports.SlotState=$r;exports.TriViewCapture=en;exports.arrayBufferToUrl=Yi;exports.calculateArrayAverage=Vr;exports.calculateFocalLength=Ha;exports.createSGLBFile=Ja;exports.downloadBlob=Wa;exports.dracoExporter=Ka;exports.font=Rc;exports.gltfExporter=Hr;exports.gltfLoader=He;exports.imageBitmapToUrl=Zi;exports.isAppleDevice=Ur;exports.textureLoader=vs;
@@ -9210,14 +9210,13 @@ class Vr extends He {
9210
9210
  return this._isMirror;
9211
9211
  }
9212
9212
  shapeKeyChanged(e, t) {
9213
- var i;
9214
9213
  if (this.props.follows.has(e)) {
9215
- const s = this.props.follows.get(e);
9216
- if (s) {
9217
- let a = "x";
9218
- ["height", "mast"].includes(e) ? a = "z" : ["width", "liftOuterWidth"].includes(e) && (a = "y");
9219
- const n = ((i = this.props.slot) == null ? void 0 : i.position[a]) - s.origin - t > 0 ? 1 : -1;
9220
- this._wrapper.position[a] = (t - s.origin) * s.scale * n;
9214
+ const i = this.props.follows.get(e);
9215
+ if (i) {
9216
+ let s = "x";
9217
+ ["height", "mast"].includes(e) ? s = "z" : ["width", "liftOuterWidth"].includes(e) && (s = "y");
9218
+ const a = i.initPos[s] > 0 ? 1 : -1;
9219
+ this._wrapper.position[s] = (t - i.origin) * i.scale * a;
9221
9220
  }
9222
9221
  }
9223
9222
  }
@@ -9363,7 +9362,7 @@ class Vr extends He {
9363
9362
  dispose() {
9364
9363
  cancelAnimationFrame(this._timer), ["dragenter", "dragover", "dragleave", "drop"].forEach((e) => {
9365
9364
  this.element.addEventListener(e, this._preventDefaults, !1);
9366
- }), this.clearSlot(), this._emitter.removeAllListeners(), De(this._slotContainer), this.element.remove();
9365
+ }), this.props.follows.clear(), this.clearSlot(), this._emitter.removeAllListeners(), De(this._slotContainer), this.element.remove();
9367
9366
  }
9368
9367
  render(e) {
9369
9368
  const t = this.element.style.transform, i = /translate\(-?\d*\.?\d*%?,?\s-?\d*\.?\d*%?\)\s*translate\((-?\d*\.?\d*)px,\s*(-?\d*\.?\d*)px\)/.exec(t);
@@ -9855,7 +9854,7 @@ const Bn = new mn();
9855
9854
  Bn.crossOrigin = "anonymous";
9856
9855
  class Ac extends Bt {
9857
9856
  constructor(e) {
9858
- super(), this._props = e, this._emitter = new Ot(), this.addEventListener = this._emitter.addListener.bind(this._emitter), this._container = new ge(), this.lines = new ge(), this._clips = [], this._actionsMap = /* @__PURE__ */ new Map(), this._animationClock = new qi(), this.sizeBox = new wc(), this._goodsSize = new lc(0, 0, 0), this._slots = [], this._logos = [], this._skins = [], this._levels = /* @__PURE__ */ new Map(), this._rollerLevel = /* @__PURE__ */ new Map(), this._liftBrackets = [], this._rollerColumns = 1, this._bodyOpacity = 1, this._masts = /* @__PURE__ */ new Map(), this._liftMaxHeight = 0, this._jackMaxHeight = 0, this._forkMaxHeight = 0, this.controllers = [], this.goods = [], this._breathLights = [], this._shelves = /* @__PURE__ */ new Map(), this._shelfMaxLevel = 1, this._url = "", this._showController = !0, this._showSlots = !0, this._shapeKeys = /* @__PURE__ */ new Map(), this._shapeKeyTargets = /* @__PURE__ */ new Map(), this._shapeKeyTimer = 0, this._shapeKeyCache = "", this._materialsCache = /* @__PURE__ */ new Map(), this.opacityCache = void 0, this.actions = [], 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;
9857
+ super(), this._props = e, this._emitter = new Ot(), this.addEventListener = this._emitter.addListener.bind(this._emitter), this._container = new ge(), this.lines = new ge(), this._clips = [], this._actionsMap = /* @__PURE__ */ new Map(), this._animationClock = new qi(), this.sizeBox = new wc(), this._goodsSize = new lc(0, 0, 0), this._slots = [], this._logos = [], this._skins = [], this._levels = /* @__PURE__ */ new Map(), this._rollerLevel = /* @__PURE__ */ new Map(), this._liftBrackets = [], this._rollerColumns = 1, this._bodyOpacity = 1, this._masts = /* @__PURE__ */ new Map(), this._liftMaxHeight = 0, this._jackMaxHeight = 0, this._forkMaxHeight = 0, this.controllers = [], this.goods = [], this._breathLights = [], this._shelves = /* @__PURE__ */ new Map(), this._shelfMaxLevel = 1, this._url = "", this._showController = !0, this._showSlots = !0, this._shapeKeys = /* @__PURE__ */ new Map(), this._shapeKeyTargets = /* @__PURE__ */ new Map(), this._shapeKeyTimer = 0, this._shapeKeyCache = "", this._materialsCache = /* @__PURE__ */ new Map(), this.opacityCache = void 0, this.actions = [], 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;
9859
9858
  }
9860
9859
  get shapeKeys() {
9861
9860
  return this._shapeKeys;
@@ -9938,22 +9937,22 @@ class Ac extends Bt {
9938
9937
  const s = i + 0.14 - 0.54;
9939
9938
  this.setShapeKey("boxLength", s);
9940
9939
  const a = i + 0.14;
9941
- if (this.setShapeKey("topLength", a), this.isTopInvert) {
9940
+ if (this.setShapeKey("topWidth", a), this.isTopInvert) {
9942
9941
  const n = i - 0.257;
9943
- this.setShapeKey("width", n);
9942
+ this.setShapeKey("length", n);
9944
9943
  } else
9945
- this.setShapeKey("length", a);
9944
+ this.setShapeKey("width", a);
9946
9945
  this._generateRollers();
9947
9946
  }
9948
9947
  if (t === "goodsWidth") {
9949
9948
  const s = i + 0.193;
9950
9949
  this.setShapeKey("boxWidth", s);
9951
9950
  const a = i + 0.219;
9952
- if (this.setShapeKey("topWidth", a), this.isTopInvert) {
9951
+ if (this.setShapeKey("topLength", a), this.isTopInvert) {
9953
9952
  const n = i + 0.62;
9954
- this.setShapeKey("length", n);
9953
+ this.setShapeKey("width", n);
9955
9954
  } else
9956
- this.setShapeKey("width", a);
9955
+ this.setShapeKey("length", a);
9957
9956
  this._generateRollers();
9958
9957
  }
9959
9958
  });
@@ -10057,11 +10056,7 @@ class Ac extends Bt {
10057
10056
  const s = this._mixer.clipAction(i);
10058
10057
  this._actionsMap.set(i.name, s);
10059
10058
  }), this.actions = t.map((i) => i.name)), this._shapeKeyTargets.clear(), this._shapeKeys.clear(), e.traverse((i) => {
10060
- 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) {
10061
- const s = `1-${i.userData.level || 0}`;
10062
- this._rollerLevel.set(s, i);
10063
- }
10064
- i.userData.isLift && (this._lift = i), i.userData.isCenterModel && (i.visible = !1, this._centerModel = i), i.userData.isSwitch && i.userData.switchName === "top" && (this._rollerTop = i), i.userData.isLiftBracket && this._liftBrackets.push(i), i.userData.isBaffle && (this._rollerBaffle = i, i.visible = !1), i.userData.isRoller && (this._roller = i, this._generateRollers()), i.userData.isRollerLevelBox && (this._rollerGoodsBox = i), Object.keys(i.morphTargetDictionary || {}).forEach((s) => {
10059
+ 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.isLift && (this._lift = i), i.userData.isCenterModel && (i.visible = !1, this._centerModel = i), i.userData.isSwitch && i.userData.switchName === "top" && (this._rollerTop = i), i.userData.isLiftBracket && this._liftBrackets.push(i), i.userData.isBaffle && (this._rollerBaffle = i, i.visible = !1), i.userData.isRoller && (this._roller = i, this._generateRollers()), i.userData.isRollerLevelBox && (this._rollerGoodsBox = i), Object.keys(i.morphTargetDictionary || {}).forEach((s) => {
10065
10060
  let a = i.morphTargetInfluences[i.morphTargetDictionary[s]];
10066
10061
  i.userData[`origin_${s}`] && (a += i.userData[`origin_${s}`]), this._shapeKeys.has(s) || this._shapeKeys.set(s, a);
10067
10062
  const n = this._shapeKeyTargets.get(s);
@@ -10226,10 +10221,27 @@ class Ac extends Bt {
10226
10221
  return Math.abs(this._rollerTop.rotation.z) === Math.PI / 2;
10227
10222
  }
10228
10223
  setTopInvert(e = !0) {
10229
- this._rollerTop && (this._rollerTop.rotation.z = e ? Math.PI / 2 : 0, this.setShapeKey("switch", e ? 1 : 0), this.setShapeKey("goodsWidth", this.goodsSize.length), this.setShapeKey("goodsLength", this.goodsSize.width));
10224
+ 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));
10225
+ }
10226
+ get levels() {
10227
+ return this._levelCount;
10228
+ }
10229
+ setLevels(e) {
10230
+ var a;
10231
+ if (!e)
10232
+ return;
10233
+ this._levelCount = e;
10234
+ const t = this._rollerLevel.size;
10235
+ let i = e - t;
10236
+ const s = this._rollerLevel.get(0);
10237
+ if (i > 0 && s)
10238
+ for (let n = t; n < e; n++) {
10239
+ const c = s.clone(!0);
10240
+ c.position.z += 0.2, this._rollerLevel.set(n, c), (a = s.parent) == null || a.add(c);
10241
+ }
10230
10242
  }
10231
10243
  setRollerHeight(e, t) {
10232
- const i = this._rollerLevel.get(`1-${e}`);
10244
+ const i = this._rollerLevel.get(e);
10233
10245
  i && (i.position.z = t);
10234
10246
  }
10235
10247
  _generateRollers() {
@@ -10395,6 +10407,7 @@ class Ac extends Bt {
10395
10407
  let v = e.userData[h];
10396
10408
  d.set(m, {
10397
10409
  scale: v,
10410
+ initPos: e.position.clone(),
10398
10411
  origin: this.shapeKeys.get(m) || 0
10399
10412
  });
10400
10413
  }
@@ -13249,7 +13262,7 @@ class Lh {
13249
13262
  Mt || typeof Mt < "u" || (Fi === 0 && (Ws = performance.now()), Fi++, performance.now() - Ws > 66 && (Fi > 5 ? Mt = !0 : Mt = !1, Mt ? this.controls.zoomSpeed = 0.2 : this.controls.zoomSpeed = 1, setTimeout(Vu, 2e3)));
13250
13263
  }, this.debounceForkHeightChange = ac(() => {
13251
13264
  var c;
13252
- (c = this._progressShadow) == null || c.recalculate();
13265
+ this._progressShadow.clear(), (c = this._progressShadow) == null || c.recalculate();
13253
13266
  }, 300), this.focusObjects = (c, u) => {
13254
13267
  var se;
13255
13268
  if (!c.length) {
@@ -13462,7 +13475,7 @@ class Lh {
13462
13475
  frames: e.isMobile ? 80 : 120,
13463
13476
  lightRadius: 8,
13464
13477
  ambientWeight: 0.8
13465
- }), this._progressShadow.lightOrigin.position.set(3, 2.5, 6), this._progressShadow.visible = !1, this._container.add(this.amr), this.scene.add(this._container), this.ticker(), this._loadEnv(), this._initEvents(), this.scene.add(this._cameraPositionUI), this._ground.rotateX(-Math.PI / 2), this.scene.add(this._ground), this._jumpFlood = new Bu(this.renderer, this.scene, this.camera, {
13478
+ }), this._progressShadow.lightOrigin.position.set(3, 2.5, 6), this._progressShadow.visible = !1, this._container.add(this.amr), this.scene.add(this._container), this.ticker(0), this._loadEnv(), this._initEvents(), this.scene.add(this._cameraPositionUI), this._ground.rotateX(-Math.PI / 2), this.scene.add(this._ground), this._jumpFlood = new Bu(this.renderer, this.scene, this.camera, {
13466
13479
  thickness: 4,
13467
13480
  color: "#fff"
13468
13481
  }), (typeof e.useAxisBall != "boolean" || e.useAxisBall) && (this._controlsGizmo = new Iu(this.controls, {
@@ -13492,7 +13505,7 @@ class Lh {
13492
13505
  e ? (this._progressShadow.visible = !1, this.amr.bodyOpacity = 0.2) : (this._progressShadow.visible = !0, this.amr.bodyOpacity = 1, this._progressShadow.isFinished || this._progressShadow.recalculate().then()), this._shadowMode = e;
13493
13506
  }
13494
13507
  set usePathTracing(e) {
13495
- this._clearAmrContent(), e ? (this.renderer.toneMappingExposure = 1.8, this.overlayScene.add(this._progressShadow.shadowCatcherMesh), this.amr && (this.amr.bodyOpacity = 1), this.hideAmrUI(), this.pathTracer.renderToCanvas = !0, this.scene.background = null, this._ptEnvMap ? (this.scene.environment = this._ptEnvMap, this.pathTracer.updateEnvironment()) : new cr().load(Uu, (t) => {
13508
+ this._clearAmrContent(), e ? (this.scene.background = new K("transparent"), this.renderer.toneMappingExposure = 1.8, this.overlayScene.add(this._progressShadow.shadowCatcherMesh), this.amr && (this.amr.bodyOpacity = 1), this.hideAmrUI(), this.pathTracer.renderToCanvas = !0, this.scene.background = null, this._ptEnvMap ? (this.scene.environment = this._ptEnvMap, this.pathTracer.updateEnvironment()) : new cr().load(Uu, (t) => {
13496
13509
  t.mapping = ki, this._ptEnvMap = t, this.usePathTracing && (this.scene.environment = t, this.pathTracer.updateEnvironment());
13497
13510
  })) : (this.renderer.toneMappingExposure = 1.4, this.scene.add(this._progressShadow.shadowCatcherMesh), this.pathTracer.renderToCanvas = !1, this.amr.logos.forEach((t) => {
13498
13511
  var i;
@@ -13643,7 +13656,7 @@ class Lh {
13643
13656
  "liftLength",
13644
13657
  "liftWidth",
13645
13658
  "liftOuterWidth"
13646
- ].includes(i) && (this._progressShadow.clear(), this._progressShadow.recalculate());
13659
+ ].includes(i) && (this._progressShadow.clear(), this.debounceForkHeightChange());
13647
13660
  });
13648
13661
  }
13649
13662
  _animateCamera(e, t, i, s, a, n) {
@@ -13679,12 +13692,12 @@ class Lh {
13679
13692
  typeof e == "string" || (Array.isArray(e) ? this._selectedForOutline = [...e] : this._selectedForOutline = [e]);
13680
13693
  }
13681
13694
  appendTo(e) {
13682
- e.append(this.renderer.domElement), e.append(this.stats.dom), e.append(this.css2dRenderer.domElement), this.props.isMobile && (e.classList.add("is-mobile"), e.style.cssText = `
13695
+ e.append(this.renderer.domElement), e.append(this.stats.dom), e.append(this.css2dRenderer.domElement), this.props.isMobile ? (e.classList.add("is-mobile"), e.style.cssText = `
13683
13696
  -webkit-user-select: none;
13684
13697
  user-select: none;
13685
13698
  touch-action: none;
13686
13699
  -webkit-touch-callout: none;
13687
- `), 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);
13700
+ `) : 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);
13688
13701
  }
13689
13702
  add(e) {
13690
13703
  this._container.add(e);
@@ -13894,7 +13907,7 @@ class Gu {
13894
13907
  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;
13895
13908
  }
13896
13909
  }
13897
- const qu = "shop-components", ju = "0.4.10", Qu = "Shop components", Yu = "dist/shop-components.umd.js", Zu = "dist/shop-components.mjs", Xu = "dist/main.d.ts", Ku = {
13910
+ const qu = "shop-components", ju = "0.4.11", Qu = "Shop components", Yu = "dist/shop-components.umd.js", Zu = "dist/shop-components.mjs", Xu = "dist/main.d.ts", Ku = {
13898
13911
  dts: "tsc --emitDeclarationOnly & tsc & storybook build -o dist",
13899
13912
  dev: "vite dev",
13900
13913
  build: "vite build",
package/dist/test.glb CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shop-components",
3
- "version": "0.4.10",
3
+ "version": "0.4.12",
4
4
  "description": "Shop components",
5
5
  "main": "dist/shop-components.umd.js",
6
6
  "module": "dist/shop-components.mjs",