Files
lit-examples/assets/mode-vr-C6IEbqHj.js
T
2026-07-05 02:38:01 +00:00

25 lines
342 KiB
JavaScript

import"./aframe-forcegraph-component-B3vzsuem.js";import{i as lc,h as mr}from"./Paired-C4wB-ooD.js";import{p as uc,c as dc}from"./polished.esm-BeKV07fA.js";import"./three.module-Unazwo7z.js";import"./data-bind-mapper-D9QKwI5o.js";import"./_commonjsHelpers-Cpj98o6Y.js";const yr=.1;AFRAME.registerComponent("checkpoint-controls",{schema:{enabled:{default:!0},mode:{default:"teleport",oneOf:["teleport","animate"]},animateSpeed:{default:3}},init:function(){this.active=!0,this.checkpoint=null,this.isNavMeshConstrained=!1,this.offset=new THREE.Vector3,this.position=new THREE.Vector3,this.targetPosition=new THREE.Vector3},play:function(){this.active=!0},pause:function(){this.active=!1},setCheckpoint:function(r){const t=this.el;if(this.active&&this.checkpoint!==r){if(this.checkpoint&&t.emit("navigation-end",{checkpoint:this.checkpoint}),this.checkpoint=r,this.sync(),this.position.distanceTo(this.targetPosition)<yr){this.checkpoint=null;return}t.emit("navigation-start",{checkpoint:r}),this.data.mode==="teleport"&&(this.el.setAttribute("position",this.targetPosition),this.checkpoint=null,t.emit("navigation-end",{checkpoint:r}),t.components["movement-controls"].updateNavLocation())}},isVelocityActive:function(){return!!(this.active&&this.checkpoint)},getVelocity:function(){if(!this.active)return;const r=this.data,t=this.offset,e=this.position,i=this.targetPosition,n=this.checkpoint;return this.sync(),e.distanceTo(i)<yr?(this.checkpoint=null,this.el.emit("navigation-end",{checkpoint:n}),t.set(0,0,0)):(t.setLength(r.animateSpeed),t)},sync:function(){const r=this.offset,t=this.position,e=this.targetPosition;t.copy(this.el.getAttribute("position")),this.checkpoint.object3D.getWorldPosition(e),e.add(this.checkpoint.components.checkpoint.getOffset()),r.copy(e).sub(t)}});const je=Object.assign(function(){},{FACE_1:0,FACE_2:1,FACE_3:2,FACE_4:3,L_SHOULDER_1:4,R_SHOULDER_1:5,L_SHOULDER_2:6,R_SHOULDER_2:7,SELECT:8,START:9,DPAD_UP:12,DPAD_DOWN:13,DPAD_LEFT:14,DPAD_RIGHT:15,VENDOR:16});function Bn(r,t,e){this.type=r,this.index=t,this.pressed=e.pressed,this.value=e.value}const xe=.2,ae={LEFT:"left",RIGHT:"right"},ce={MOVEMENT:1,ROTATION:2};AFRAME.registerComponent("gamepad-controls",{GamepadButton:je,schema:{enabled:{default:!0},rotationSensitivity:{default:2}},init:function(){const r=this.el.sceneEl;this.system=r.systems["tracked-controls"]||r.systems["tracked-controls-webxr"]||{controllers:[]},this.prevTime=window.performance.now(),this.buttons={};const t=this.el.object3D.rotation;this.pitch=new THREE.Object3D,this.pitch.rotation.x=t.x,this.yaw=new THREE.Object3D,this.yaw.position.y=10,this.yaw.rotation.y=t.y,this.yaw.add(this.pitch),this._lookVector=new THREE.Vector2,this._moveVector=new THREE.Vector2,this._dpadVector=new THREE.Vector2,r.addBehavior(this)},update:function(){this.tick()},tick:function(r,t){this.updateButtonState(),this.updateRotation(t)},remove:function(){},isVelocityActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const r=this._dpadVector,t=this._moveVector;this.getDpad(r),this.getJoystick(ce.MOVEMENT,t);const e=r.x||t.x,i=r.y||t.y;return Math.abs(e)>xe||Math.abs(i)>xe},getVelocityDelta:function(){const r=this._dpadVector,t=this._moveVector;this.getDpad(r),this.getJoystick(ce.MOVEMENT,t);const e=r.x||t.x,i=r.y||t.y,n=new THREE.Vector3;return Math.abs(e)>xe&&(n.x+=e),Math.abs(i)>xe&&(n.z+=i),n},isRotationActive:function(){if(!this.data.enabled||!this.isConnected())return!1;const r=this._lookVector;return this.getJoystick(ce.ROTATION,r),Math.abs(r.x)>xe||Math.abs(r.y)>xe},updateRotation:function(r){if(!this.isRotationActive())return;const t=this.data,e=this.yaw,i=this.pitch;e.rotation.y=this.el.object3D.rotation.y,i.rotation.x=this.el.object3D.rotation.x;const n=this._lookVector;this.getJoystick(ce.ROTATION,n),Math.abs(n.x)<=xe&&(n.x=0),Math.abs(n.y)<=xe&&(n.y=0),n.multiplyScalar(t.rotationSensitivity*r/1e3),e.rotation.y-=n.x,i.rotation.x-=n.y,i.rotation.x=Math.max(-Math.PI/2,Math.min(Math.PI/2,i.rotation.x)),this.el.object3D.rotation.set(i.rotation.x,e.rotation.y,0)},updateButtonState:function(){const r=this.getGamepad(ae.RIGHT);if(this.data.enabled&&r)for(var t=0;t<r.buttons.length;t++)r.buttons[t].pressed&&!this.buttons[t]?this.emit(new Bn("gamepadbuttondown",t,r.buttons[t])):!r.buttons[t].pressed&&this.buttons[t]&&this.emit(new Bn("gamepadbuttonup",t,r.buttons[t])),this.buttons[t]=r.buttons[t].pressed;else for(const e in this.buttons)this.buttons[e]=!1},emit:function(r){this.el.emit(r.type,r),this.el.emit(r.type+":"+r.index,new Bn(r.type,r.index,r))},getGamepad:function(){const r=[],t=[];return function(e){const i=this.el.sceneEl.components["proxy-controls"],n=i&&i.isConnected()&&i.getGamepad(0);if(n)return n;r.length=0;for(let o=0;o<this.system.controllers.length;o++){const a=this.system.controllers[o],c=a?a.gamepad:null;if(r.push(c),c&&a.handedness===e)return c}const s=navigator.getGamepads?navigator.getGamepads():t;for(let o=0;o<s.length;o++){const a=s[o];if(a&&a.hand===e)return a}return r[0]||s[0]}}(),getButton:function(r){return this.getGamepad(ae.RIGHT).buttons[r]},getAxis:function(r){return this.getGamepad(r>1?ae.RIGHT:ae.LEFT).axes[r]},getJoystick:function(r,t){const e=this.getGamepad(r===ce.MOVEMENT?ae.LEFT:ae.RIGHT);if(!e)return t.set(0,0);if(e.mapping==="xr-standard")switch(r){case ce.MOVEMENT:return t.set(e.axes[2],e.axes[3]);case ce.ROTATION:return t.set(e.axes[2],0)}else switch(r){case ce.MOVEMENT:return t.set(e.axes[0],e.axes[1]);case ce.ROTATION:return t.set(e.axes[2],e.axes[3])}throw new Error('Unexpected joystick index "%d".',r)},getDpad:function(r){const t=this.getGamepad(ae.LEFT);return!t||!t.buttons[je.DPAD_RIGHT]?r.set(0,0):r.set((t.buttons[je.DPAD_RIGHT].pressed?1:0)+(t.buttons[je.DPAD_LEFT].pressed?-1:0),(t.buttons[je.DPAD_UP].pressed?-1:0)+(t.buttons[je.DPAD_DOWN].pressed?1:0))},isConnected:function(){const r=this.getGamepad(ae.LEFT);return!!(r&&r.connected)},getID:function(){return this.getGamepad(ae.LEFT).id}});(function(r){var t="KeyboardEvent"in r;t||(r.KeyboardEvent=function(){throw TypeError("Illegal constructor")}),"DOM_KEY_LOCATION_STANDARD"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_STANDARD=0),"DOM_KEY_LOCATION_LEFT"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_LEFT=1),"DOM_KEY_LOCATION_RIGHT"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_RIGHT=2),"DOM_KEY_LOCATION_NUMPAD"in r.KeyboardEvent||(r.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD=3);var e=window.KeyboardEvent.DOM_KEY_LOCATION_STANDARD,i=window.KeyboardEvent.DOM_KEY_LOCATION_LEFT,n=window.KeyboardEvent.DOM_KEY_LOCATION_RIGHT,s=window.KeyboardEvent.DOM_KEY_LOCATION_NUMPAD;function o(_,z){return String(_).indexOf(z)!==-1}var a=function(){return o(navigator.platform,"Win")?"win":o(navigator.platform,"Mac")?"mac":o(navigator.platform,"CrOS")?"cros":o(navigator.platform,"Linux")?"linux":o(navigator.userAgent,"iPad")||o(navigator.platform,"iPod")||o(navigator.platform,"iPhone")?"ios":""}(),c=function(){return o(navigator.userAgent,"Chrome/")?"chrome":o(navigator.vendor,"Apple")?"safari":o(navigator.userAgent,"MSIE")?"ie":o(navigator.userAgent,"Gecko/")?"moz":o(navigator.userAgent,"Opera/")?"opera":""}(),h=c+"-"+a;function l(_,z,F){(h===z||c===z||a===z)&&Object.keys(F).forEach(function(R){_[R]=F[R]})}function u(_,z){var F={};return Object.keys(_).forEach(function(R){var L=_[R];z in L&&(F[L[z]]=L)}),F}var d={3:{code:"Cancel"},6:{code:"Help"},8:{code:"Backspace"},9:{code:"Tab"},12:{code:"Clear"},13:{code:"Enter"},16:{code:"Shift"},17:{code:"Control"},18:{code:"Alt"},19:{code:"Pause"},20:{code:"CapsLock"},21:{code:"KanaMode"},22:{code:"HangulMode"},23:{code:"JunjaMode"},24:{code:"FinalMode"},25:{code:"KanjiMode"},27:{code:"Escape"},28:{code:"Convert"},29:{code:"NonConvert"},30:{code:"Accept"},31:{code:"ModeChange"},32:{code:"Space"},33:{code:"PageUp"},34:{code:"PageDown"},35:{code:"End"},36:{code:"Home"},37:{code:"ArrowLeft"},38:{code:"ArrowUp"},39:{code:"ArrowRight"},40:{code:"ArrowDown"},41:{code:"Select"},42:{code:"Print"},43:{code:"Execute"},44:{code:"PrintScreen"},45:{code:"Insert"},46:{code:"Delete"},47:{code:"Help"},48:{code:"Digit0",keyCap:"0"},49:{code:"Digit1",keyCap:"1"},50:{code:"Digit2",keyCap:"2"},51:{code:"Digit3",keyCap:"3"},52:{code:"Digit4",keyCap:"4"},53:{code:"Digit5",keyCap:"5"},54:{code:"Digit6",keyCap:"6"},55:{code:"Digit7",keyCap:"7"},56:{code:"Digit8",keyCap:"8"},57:{code:"Digit9",keyCap:"9"},65:{code:"KeyA",keyCap:"a"},66:{code:"KeyB",keyCap:"b"},67:{code:"KeyC",keyCap:"c"},68:{code:"KeyD",keyCap:"d"},69:{code:"KeyE",keyCap:"e"},70:{code:"KeyF",keyCap:"f"},71:{code:"KeyG",keyCap:"g"},72:{code:"KeyH",keyCap:"h"},73:{code:"KeyI",keyCap:"i"},74:{code:"KeyJ",keyCap:"j"},75:{code:"KeyK",keyCap:"k"},76:{code:"KeyL",keyCap:"l"},77:{code:"KeyM",keyCap:"m"},78:{code:"KeyN",keyCap:"n"},79:{code:"KeyO",keyCap:"o"},80:{code:"KeyP",keyCap:"p"},81:{code:"KeyQ",keyCap:"q"},82:{code:"KeyR",keyCap:"r"},83:{code:"KeyS",keyCap:"s"},84:{code:"KeyT",keyCap:"t"},85:{code:"KeyU",keyCap:"u"},86:{code:"KeyV",keyCap:"v"},87:{code:"KeyW",keyCap:"w"},88:{code:"KeyX",keyCap:"x"},89:{code:"KeyY",keyCap:"y"},90:{code:"KeyZ",keyCap:"z"},91:{code:"OSLeft",location:i},92:{code:"OSRight",location:n},93:{code:"ContextMenu"},95:{code:"Standby"},96:{code:"Numpad0",keyCap:"0",location:s},97:{code:"Numpad1",keyCap:"1",location:s},98:{code:"Numpad2",keyCap:"2",location:s},99:{code:"Numpad3",keyCap:"3",location:s},100:{code:"Numpad4",keyCap:"4",location:s},101:{code:"Numpad5",keyCap:"5",location:s},102:{code:"Numpad6",keyCap:"6",location:s},103:{code:"Numpad7",keyCap:"7",location:s},104:{code:"Numpad8",keyCap:"8",location:s},105:{code:"Numpad9",keyCap:"9",location:s},106:{code:"NumpadMultiply",keyCap:"*",location:s},107:{code:"NumpadAdd",keyCap:"+",location:s},108:{code:"NumpadComma",keyCap:",",location:s},109:{code:"NumpadSubtract",keyCap:"-",location:s},110:{code:"NumpadDecimal",keyCap:".",location:s},111:{code:"NumpadDivide",keyCap:"/",location:s},112:{code:"F1"},113:{code:"F2"},114:{code:"F3"},115:{code:"F4"},116:{code:"F5"},117:{code:"F6"},118:{code:"F7"},119:{code:"F8"},120:{code:"F9"},121:{code:"F10"},122:{code:"F11"},123:{code:"F12"},124:{code:"F13"},125:{code:"F14"},126:{code:"F15"},127:{code:"F16"},128:{code:"F17"},129:{code:"F18"},130:{code:"F19"},131:{code:"F20"},132:{code:"F21"},133:{code:"F22"},134:{code:"F23"},135:{code:"F24"},144:{code:"NumLock",location:s},145:{code:"ScrollLock"},160:{code:"ShiftLeft",location:i},161:{code:"ShiftRight",location:n},162:{code:"ControlLeft",location:i},163:{code:"ControlRight",location:n},164:{code:"AltLeft",location:i},165:{code:"AltRight",location:n},166:{code:"BrowserBack"},167:{code:"BrowserForward"},168:{code:"BrowserRefresh"},169:{code:"BrowserStop"},170:{code:"BrowserSearch"},171:{code:"BrowserFavorites"},172:{code:"BrowserHome"},173:{code:"VolumeMute"},174:{code:"VolumeDown"},175:{code:"VolumeUp"},176:{code:"MediaTrackNext"},177:{code:"MediaTrackPrevious"},178:{code:"MediaStop"},179:{code:"MediaPlayPause"},180:{code:"LaunchMail"},181:{code:"MediaSelect"},182:{code:"LaunchApp1"},183:{code:"LaunchApp2"},186:{code:"Semicolon",keyCap:";"},187:{code:"Equal",keyCap:"="},188:{code:"Comma",keyCap:","},189:{code:"Minus",keyCap:"-"},190:{code:"Period",keyCap:"."},191:{code:"Slash",keyCap:"/"},192:{code:"Backquote",keyCap:"`"},219:{code:"BracketLeft",keyCap:"["},220:{code:"Backslash",keyCap:"\\"},221:{code:"BracketRight",keyCap:"]"},222:{code:"Quote",keyCap:"'"},226:{code:"IntlBackslash",keyCap:"\\"},229:{code:"Process"},246:{code:"Attn"},247:{code:"CrSel"},248:{code:"ExSel"},249:{code:"EraseEof"},250:{code:"Play"},251:{code:"ZoomToggle"},254:{code:"Clear"}};l(d,"moz",{59:{code:"Semicolon",keyCap:";"},61:{code:"Equal",keyCap:"="},107:{code:"Equal",keyCap:"="},109:{code:"Minus",keyCap:"-"},187:{code:"NumpadAdd",keyCap:"+",location:s},189:{code:"NumpadSubtract",keyCap:"-",location:s}}),l(d,"moz-mac",{12:{code:"NumLock",location:s},173:{code:"Minus",keyCap:"-"}}),l(d,"moz-win",{173:{code:"Minus",keyCap:"-"}}),l(d,"chrome-mac",{93:{code:"OSRight",location:n}}),l(d,"safari",{3:{code:"Enter"},25:{code:"Tab"}}),l(d,"ios",{10:{code:"Enter",location:e}}),l(d,"safari-mac",{91:{code:"OSLeft",location:i},93:{code:"OSRight",location:n},229:{code:"KeyQ",keyCap:"Q"}});var p={};a==="cros"&&(p["U+00A0"]={code:"ShiftLeft",location:i},p["U+00A1"]={code:"ShiftRight",location:n},p["U+00A2"]={code:"ControlLeft",location:i},p["U+00A3"]={code:"ControlRight",location:n},p["U+00A4"]={code:"AltLeft",location:i},p["U+00A5"]={code:"AltRight",location:n}),h==="chrome-mac"&&(p["U+0010"]={code:"ContextMenu"}),h==="safari-mac"&&(p["U+0010"]={code:"ContextMenu"}),a==="ios"&&(p["U+0010"]={code:"Function"},p["U+001C"]={code:"ArrowLeft"},p["U+001D"]={code:"ArrowRight"},p["U+001E"]={code:"ArrowUp"},p["U+001F"]={code:"ArrowDown"},p["U+0001"]={code:"Home"},p["U+0004"]={code:"End"},p["U+000B"]={code:"PageUp"},p["U+000C"]={code:"PageDown"});var y=[];y[i]={16:{code:"ShiftLeft",location:i},17:{code:"ControlLeft",location:i},18:{code:"AltLeft",location:i}},y[n]={16:{code:"ShiftRight",location:n},17:{code:"ControlRight",location:n},18:{code:"AltRight",location:n}},y[s]={13:{code:"NumpadEnter",location:s}},l(y[s],"moz",{109:{code:"NumpadSubtract",location:s},107:{code:"NumpadAdd",location:s}}),l(y[i],"moz-mac",{224:{code:"OSLeft",location:i}}),l(y[n],"moz-mac",{224:{code:"OSRight",location:n}}),l(y[n],"moz-win",{91:{code:"OSRight",location:n}}),l(y[n],"mac",{93:{code:"OSRight",location:n}}),l(y[s],"chrome-mac",{12:{code:"NumLock",location:s}}),l(y[s],"safari-mac",{12:{code:"NumLock",location:s},187:{code:"NumpadAdd",location:s},189:{code:"NumpadSubtract",location:s},190:{code:"NumpadDecimal",location:s},191:{code:"NumpadDivide",location:s}});var w={ShiftLeft:{key:"Shift"},ShiftRight:{key:"Shift"},ControlLeft:{key:"Control"},ControlRight:{key:"Control"},AltLeft:{key:"Alt"},AltRight:{key:"Alt"},OSLeft:{key:"OS"},OSRight:{key:"OS"},NumpadEnter:{key:"Enter"},Space:{key:" "},Digit0:{key:"0",shiftKey:")"},Digit1:{key:"1",shiftKey:"!"},Digit2:{key:"2",shiftKey:"@"},Digit3:{key:"3",shiftKey:"#"},Digit4:{key:"4",shiftKey:"$"},Digit5:{key:"5",shiftKey:"%"},Digit6:{key:"6",shiftKey:"^"},Digit7:{key:"7",shiftKey:"&"},Digit8:{key:"8",shiftKey:"*"},Digit9:{key:"9",shiftKey:"("},KeyA:{key:"a",shiftKey:"A"},KeyB:{key:"b",shiftKey:"B"},KeyC:{key:"c",shiftKey:"C"},KeyD:{key:"d",shiftKey:"D"},KeyE:{key:"e",shiftKey:"E"},KeyF:{key:"f",shiftKey:"F"},KeyG:{key:"g",shiftKey:"G"},KeyH:{key:"h",shiftKey:"H"},KeyI:{key:"i",shiftKey:"I"},KeyJ:{key:"j",shiftKey:"J"},KeyK:{key:"k",shiftKey:"K"},KeyL:{key:"l",shiftKey:"L"},KeyM:{key:"m",shiftKey:"M"},KeyN:{key:"n",shiftKey:"N"},KeyO:{key:"o",shiftKey:"O"},KeyP:{key:"p",shiftKey:"P"},KeyQ:{key:"q",shiftKey:"Q"},KeyR:{key:"r",shiftKey:"R"},KeyS:{key:"s",shiftKey:"S"},KeyT:{key:"t",shiftKey:"T"},KeyU:{key:"u",shiftKey:"U"},KeyV:{key:"v",shiftKey:"V"},KeyW:{key:"w",shiftKey:"W"},KeyX:{key:"x",shiftKey:"X"},KeyY:{key:"y",shiftKey:"Y"},KeyZ:{key:"z",shiftKey:"Z"},Numpad0:{key:"0"},Numpad1:{key:"1"},Numpad2:{key:"2"},Numpad3:{key:"3"},Numpad4:{key:"4"},Numpad5:{key:"5"},Numpad6:{key:"6"},Numpad7:{key:"7"},Numpad8:{key:"8"},Numpad9:{key:"9"},NumpadMultiply:{key:"*"},NumpadAdd:{key:"+"},NumpadComma:{key:","},NumpadSubtract:{key:"-"},NumpadDecimal:{key:"."},NumpadDivide:{key:"/"},Semicolon:{key:";",shiftKey:":"},Equal:{key:"=",shiftKey:"+"},Comma:{key:",",shiftKey:"<"},Minus:{key:"-",shiftKey:"_"},Period:{key:".",shiftKey:">"},Slash:{key:"/",shiftKey:"?"},Backquote:{key:"`",shiftKey:"~"},BracketLeft:{key:"[",shiftKey:"{"},Backslash:{key:"\\",shiftKey:"|"},BracketRight:{key:"]",shiftKey:"}"},Quote:{key:"'",shiftKey:'"'},IntlBackslash:{key:"\\",shiftKey:"|"}};l(w,"mac",{OSLeft:{key:"Meta"},OSRight:{key:"Meta"}});var v={Esc:"Escape",Nonconvert:"NonConvert",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Menu:"ContextMenu",MediaNextTrack:"MediaTrackNext",MediaPreviousTrack:"MediaTrackPrevious",SelectMedia:"MediaSelect",HalfWidth:"Hankaku",FullWidth:"Zenkaku",RomanCharacters:"Romaji",Crsel:"CrSel",Exsel:"ExSel",Zoom:"ZoomToggle"},k=u(d,"code");try{var C=t&&"location"in new KeyboardEvent("")}catch{}function A(_){var z="keyCode"in _?_.keyCode:"which"in _?_.which:0,F=function(){if(C||"keyLocation"in _){var L=C?_.location:_.keyLocation;if(L&&z in y[L])return y[L][z]}return"keyIdentifier"in _&&_.keyIdentifier in p?p[_.keyIdentifier]:z in d?d[z]:null}();if(!F)return null;var R=function(){var L=w[F.code];return L?_.shiftKey&&"shiftKey"in L?L.shiftKey:L.key:F.code}();return{code:F.code,key:R,location:F.location,keyCap:F.keyCap}}function T(_,z){if(_=String(_),!k.hasOwnProperty(_))return"Undefined";if(z&&String(z).toLowerCase()!=="en-us")throw Error("Unsupported locale");var F=k[_];return F.keyCap||F.code||"Undefined"}"KeyboardEvent"in r&&"defineProperty"in Object&&function(){function _(F,R,L){R in F||Object.defineProperty(F,R,L)}if(_(KeyboardEvent.prototype,"code",{get:function(){var F=A(this);return F?F.code:""}}),"key"in KeyboardEvent.prototype){var z=Object.getOwnPropertyDescriptor(KeyboardEvent.prototype,"key");Object.defineProperty(KeyboardEvent.prototype,"key",{get:function(){var F=z.get.call(this);return v.hasOwnProperty(F)?v[F]:F}})}_(KeyboardEvent.prototype,"key",{get:function(){var F=A(this);return F&&"key"in F?F.key:"Unidentified"}}),_(KeyboardEvent.prototype,"location",{get:function(){var F=A(this);return F&&"location"in F?F.location:e}}),_(KeyboardEvent.prototype,"locale",{get:function(){return""}})}(),"queryKeyCap"in r.KeyboardEvent||(r.KeyboardEvent.queryKeyCap=T),r.identifyKey=function(_){if(!("code"in _)){var z=A(_);_.code=z?z.code:"",_.key=z&&"key"in z?z.key:"Unidentified",_.location="location"in _?_.location:"keyLocation"in _?_.keyLocation:z&&"location"in z?z.location:e,_.locale=""}}})(window);const pc="__keyboard-controls-proxy",fc=window.KeyboardEvent;AFRAME.registerComponent("keyboard-controls",{schema:{enabled:{default:!0},debug:{default:!1}},init:function(){this.dVelocity=new THREE.Vector3,this.localKeys={},this.listeners={keydown:this.onKeyDown.bind(this),keyup:this.onKeyUp.bind(this),blur:this.onBlur.bind(this),onContextMenu:this.onContextMenu.bind(this)}},isVelocityActive:function(){return this.data.enabled&&!!Object.keys(this.getKeys()).length},getVelocityDelta:function(){const r=this.data,t=this.getKeys();return this.dVelocity.set(0,0,0),r.enabled&&((t.KeyW||t.ArrowUp)&&(this.dVelocity.z-=1),(t.KeyA||t.ArrowLeft)&&(this.dVelocity.x-=1),(t.KeyS||t.ArrowDown)&&(this.dVelocity.z+=1),(t.KeyD||t.ArrowRight)&&(this.dVelocity.x+=1),t.ShiftLeft&&(this.dVelocity=this.dVelocity.multiplyScalar(2))),this.dVelocity.clone()},play:function(){this.attachEventListeners()},pause:function(){this.removeEventListeners()},attachEventListeners:function(){window.addEventListener("contextmenu",this.listeners.onContextMenu,!1),window.addEventListener("keydown",this.listeners.keydown,!1),window.addEventListener("keyup",this.listeners.keyup,!1),window.addEventListener("blur",this.listeners.blur,!1)},onContextMenu:function(){for(const r in this.localKeys)this.localKeys.hasOwnProperty(r)&&delete this.localKeys[r]},removeEventListeners:function(){window.removeEventListener("keydown",this.listeners.keydown),window.removeEventListener("keyup",this.listeners.keyup),window.removeEventListener("blur",this.listeners.blur)},onKeyDown:function(r){AFRAME.utils.shouldCaptureKeyEvent(r)&&(this.localKeys[r.code]=!0,this.emit(r))},onKeyUp:function(r){AFRAME.utils.shouldCaptureKeyEvent(r)&&(delete this.localKeys[r.code],this.emit(r))},onBlur:function(){for(const r in this.localKeys)this.localKeys.hasOwnProperty(r)&&delete this.localKeys[r]},emit:function(r){pc in r&&this.el.emit(r.type,r),this.el.emit(r.type+":"+r.code,new fc(r.type,r)),this.data.debug&&console.log(r.type+":"+r.code)},isPressed:function(r){return r in this.getKeys()},getKeys:function(){return this.isProxied()?this.el.sceneEl.components["proxy-controls"].getKeyboard():this.localKeys},isProxied:function(){const r=this.el.sceneEl.components["proxy-controls"];return r&&r.isConnected()}});AFRAME.registerComponent("touch-controls",{schema:{enabled:{default:!0},reverseEnabled:{default:!0}},init:function(){this.dVelocity=new THREE.Vector3,this.bindMethods(),this.direction=0},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const r=this.el.sceneEl,t=r.canvas;if(!t){r.addEventListener("render-target-loaded",this.addEventListeners.bind(this));return}t.addEventListener("touchstart",this.onTouchStart,{passive:!0}),t.addEventListener("touchend",this.onTouchEnd,{passive:!0});const e=r.getAttribute("vr-mode-ui");e&&e.cardboardModeEnabled&&r.addEventListener("enter-vr",this.onEnterVR)},removeEventListeners:function(){const r=this.el.sceneEl&&this.el.sceneEl.canvas;r&&(r.removeEventListener("touchstart",this.onTouchStart),r.removeEventListener("touchend",this.onTouchEnd),this.el.sceneEl.removeEventListener("enter-vr",this.onEnterVR))},isVelocityActive:function(){return this.data.enabled&&!!this.direction},getVelocityDelta:function(){return this.dVelocity.z=this.direction,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onEnterVR=this.onEnterVR.bind(this)},onTouchStart:function(r){this.direction=-1,this.data.reverseEnabled&&r.touches&&r.touches.length===2&&(this.direction=1),r.preventDefault()},onTouchEnd:function(r){this.direction=0,r.preventDefault()},onEnterVR:function(){const r=this.el.sceneEl.xrSession;r&&(r.addEventListener("selectstart",this.onTouchStart),r.addEventListener("selectend",this.onTouchEnd))}});const Vn="-controls",mc=.2,yc=1e-5,gc="moved";AFRAME.registerComponent("movement-controls",{dependencies:["rotation"],schema:{enabled:{default:!0},controls:{default:["gamepad","trackpad","keyboard","touch"]},speed:{default:.3,min:0},fly:{default:!1},constrainToNavMesh:{default:!1},camera:{default:"[movement-controls] [camera]",type:"selector"}},init:function(){const r=this.el;this.data.camera||(this.data.camera=r.querySelector("[camera]")),this.velocityCtrl=null,this.velocity=new THREE.Vector3,this.heading=new THREE.Quaternion,this.eventDetail={},this.navGroup=null,this.navNode=null,r.sceneEl.hasLoaded?this.injectControls():r.sceneEl.addEventListener("loaded",this.injectControls.bind(this))},update:function(r){const t=this.el,e=this.data,i=t.sceneEl.systems.nav;if(t.sceneEl.hasLoaded&&this.injectControls(),i&&e.constrainToNavMesh!==r.constrainToNavMesh&&(e.constrainToNavMesh?i.addAgent(this):i.removeAgent(this)),e.enabled!==r.enabled)for(let n=0;n<e.controls.length;n++){const s=e.controls[n]+Vn;this.el.setAttribute(s,{enabled:this.data.enabled})}},injectControls:function(){const r=this.data;for(let t=0;t<r.controls.length;t++){const e=r.controls[t]+Vn;this.el.setAttribute(e,{enabled:this.data.enabled})}},updateNavLocation:function(){this.navGroup=null,this.navNode=null},tick:function(){const r=new THREE.Vector3,t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3;return function(n,s){if(!s)return;const o=this.el,a=this.data;if(!a.enabled)return;this.updateVelocityCtrl();const c=this.velocityCtrl,h=this.velocity,l=this.el.sceneEl.is("vr-mode");if(!(!c&&!l))if(s/1e3>mc?h.set(0,0,0):this.updateVelocity(s),a.constrainToNavMesh&&(!c&&l||c.isNavMeshConstrained!==!1)){if(h.lengthSq()<yc)return;r.copy(o.object3D.position),l&&(a.camera.object3D.getWorldPosition(i),o.object3D.parent&&o.object3D.parent.worldToLocal(i),i.sub(o.object3D.position),i.y=0,r.add(i)),c?t.copy(h).multiplyScalar(s/1e3).add(r):t.copy(r);const u=o.sceneEl.systems.nav;this.navGroup=this.navGroup===null?u.getGroup(r):this.navGroup,this.navNode=this.navNode||u.getNode(r,this.navGroup),this.navNode=u.clampStep(r,t,this.navGroup,this.navNode,e),l&&e.sub(i),o.object3D.position.copy(e)}else c&&o.hasAttribute("velocity")?o.setAttribute("velocity",h):c&&(o.object3D.position.x+=h.x*s/1e3,o.object3D.position.y+=h.y*s/1e3,o.object3D.position.z+=h.z*s/1e3)}}(),updateVelocityCtrl:function(){const r=this.data;if(r.enabled){for(let t=0,e=r.controls.length;t<e;t++){const i=this.el.components[r.controls[t]+Vn];if(i&&i.isVelocityActive()){this.velocityCtrl=i;return}}this.velocityCtrl=null}},updateVelocity:function(){const r=new THREE.Vector2,t=new THREE.Quaternion;return function(e){let i;const n=this.el,s=this.velocityCtrl,o=this.velocity,a=this.data;if(s)if(s.getVelocityDelta)i=s.getVelocityDelta(e);else if(s.getVelocity){o.copy(s.getVelocity());return}else if(s.getPositionDelta){o.copy(s.getPositionDelta(e).multiplyScalar(1e3/e));return}else throw new Error("Incompatible movement controls: ",s);if(n.hasAttribute("velocity")&&!a.constrainToNavMesh&&o.copy(this.el.getAttribute("velocity")),i&&a.enabled){const c=a.camera;t.copy(c.object3D.quaternion),t.premultiply(n.object3D.quaternion),i.applyQuaternion(t);const h=i.length();a.fly?(o.copy(i),o.multiplyScalar(this.data.speed*16.66667)):(r.set(i.x,i.z),r.setLength(h*this.data.speed*16.66667),o.x=r.x,o.y=0,o.z=r.y),(o.x!==0||o.y!==0||o.z!==0)&&(this.eventDetail.velocity=o,this.el.emit(gc,this.eventDetail))}}}()});AFRAME.registerComponent("trackpad-controls",{schema:{enabled:{default:!0},enableNegX:{default:!0},enablePosX:{default:!0},enableNegZ:{default:!0},enablePosZ:{default:!0},mode:{default:"touch",oneOf:["swipe","touch","press"]}},init:function(){this.dVelocity=new THREE.Vector3,this.zVel=0,this.xVel=0,this.bindMethods()},play:function(){this.addEventListeners()},pause:function(){this.removeEventListeners(),this.dVelocity.set(0,0,0)},remove:function(){this.pause()},addEventListeners:function(){const r=this.data,t=this.el.sceneEl;switch(t.addEventListener("axismove",this.onAxisMove),r.mode){case"swipe":case"touch":t.addEventListener("trackpadtouchstart",this.onTouchStart),t.addEventListener("trackpadtouchend",this.onTouchEnd);break;case"press":t.addEventListener("trackpaddown",this.onTouchStart),t.addEventListener("trackpadup",this.onTouchEnd);break}},removeEventListeners:function(){const r=this.el.sceneEl;r.removeEventListener("axismove",this.onAxisMove),r.removeEventListener("trackpadtouchstart",this.onTouchStart),r.removeEventListener("trackpadtouchend",this.onTouchEnd),r.removeEventListener("trackpaddown",this.onTouchStart),r.removeEventListener("trackpadup",this.onTouchEnd)},isVelocityActive:function(){return this.data.enabled&&this.isMoving},getVelocityDelta:function(){return this.dVelocity.z=this.isMoving?-this.zVel:1,this.dVelocity.x=this.isMoving?this.xVel:1,this.dVelocity.clone()},bindMethods:function(){this.onTouchStart=this.onTouchStart.bind(this),this.onTouchEnd=this.onTouchEnd.bind(this),this.onAxisMove=this.onAxisMove.bind(this)},onTouchStart:function(r){switch(this.data.mode){case"swipe":this.canRecordAxis=!0,this.startingAxisData=[];break;case"touch":this.isMoving=!0;break;case"press":this.isMoving=!0;break}r.preventDefault()},onTouchEnd:function(r){this.data.mode=="swipe"&&(this.startingAxisData=[]),this.isMoving=!1,r.preventDefault()},onAxisMove:function(r){switch(this.data.mode){case"swipe":return this.handleSwipeAxis(r);case"touch":case"press":return this.handleTouchAxis(r)}},handleSwipeAxis:function(r){const t=this.data,e=r.detail.axis;if(this.startingAxisData.length===0&&this.canRecordAxis&&(this.canRecordAxis=!1,this.startingAxisData[0]=e[0],this.startingAxisData[1]=e[1]),this.startingAxisData.length>0){let i=0,n=0;t.enableNegX&&e[0]<this.startingAxisData[0]&&(i=-1),t.enablePosX&&e[0]>this.startingAxisData[0]&&(i=1),t.enablePosZ&&e[1]>this.startingAxisData[1]&&(n=-1),t.enableNegZ&&e[1]<this.startingAxisData[1]&&(n=1);const s=Math.abs(this.startingAxisData[1]-e[1]);Math.abs(this.startingAxisData[0]-e[0])>s?(this.zVel=0,this.xVel=i,this.isMoving=!0):(this.xVel=0,this.zVel=n,this.isMoving=!0)}},handleTouchAxis:function(r){const t=this.data,e=r.detail.axis;let i=0,n=0;t.enableNegX&&e[0]<0&&(i=-1),t.enablePosX&&e[0]>0&&(i=1),t.enablePosZ&&e[1]>0&&(n=-1),t.enableNegZ&&e[1]<0&&(n=1),Math.abs(e[0])>Math.abs(e[1])?(this.zVel=0,this.xVel=i):(this.xVel=0,this.zVel=n)}});const mn=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return Math.sqrt(e*e+i*i)},xc=(r,t)=>{const e=t.x-r.x,i=t.y-r.y;return wc(Math.atan2(i,e))},bc=(r,t,e)=>{const i={x:0,y:0};return e=ws(e),i.x=r.x-t*Math.cos(e),i.y=r.y-t*Math.sin(e),i},ws=r=>r*(Math.PI/180),wc=r=>r*(180/Math.PI),vc=r=>isNaN(r.buttons)?r.pressure!==0:r.buttons!==0,jn=new Map,gr=r=>{jn.has(r)&&clearTimeout(jn.get(r)),jn.set(r,setTimeout(r,100))},gn=(r,t,e)=>{const i=t.split(/[ ,]+/g);let n;for(let s=0;s<i.length;s+=1)n=i[s],r.addEventListener?r.addEventListener(n,e,!1):r.attachEvent&&r.attachEvent(n,e)},xr=(r,t,e)=>{const i=t.split(/[ ,]+/g);let n;for(let s=0;s<i.length;s+=1)n=i[s],r.removeEventListener?r.removeEventListener(n,e):r.detachEvent&&r.detachEvent(n,e)},So=r=>(r.preventDefault(),r.type.match(/^touch/)?r.changedTouches:r),br=()=>{const r=window.pageXOffset!==void 0?window.pageXOffset:(document.documentElement||document.body.parentNode||document.body).scrollLeft,t=window.pageYOffset!==void 0?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;return{x:r,y:t}},wr=(r,t)=>{t.top||t.right||t.bottom||t.left?(r.style.top=t.top,r.style.right=t.right,r.style.bottom=t.bottom,r.style.left=t.left):(r.style.left=t.x+"px",r.style.top=t.y+"px")},zs=(r,t,e)=>{const i=Co(r);for(let n in i)if(i.hasOwnProperty(n))if(typeof t=="string")i[n]=t+" "+e;else{let s="";for(let o=0,a=t.length;o<a;o+=1)s+=t[o]+" "+e+", ";i[n]=s.slice(0,-2)}return i},Mc=(r,t)=>{const e=Co(r);for(let i in e)e.hasOwnProperty(i)&&(e[i]=t);return e},Co=r=>{const t={};return t[r]="",["webkit","Moz","o"].forEach(function(i){t[i+r.charAt(0).toUpperCase()+r.slice(1)]=""}),t},Un=(r,t)=>{for(let e in t)t.hasOwnProperty(e)&&(r[e]=t[e]);return r},kc=(r,t)=>{const e={};for(let i in r)r.hasOwnProperty(i)&&t.hasOwnProperty(i)?e[i]=t[i]:r.hasOwnProperty(i)&&(e[i]=r[i]);return e},vs=(r,t)=>{if(r.length)for(let e=0,i=r.length;e<i;e+=1)t(r[e]);else t(r)},Ac=(r,t,e)=>({x:Math.min(Math.max(r.x,t.x-e),t.x+e),y:Math.min(Math.max(r.y,t.y-e),t.y+e)});var Ec="ontouchstart"in window,Tc=!!window.PointerEvent,_c=!!window.MSPointerEvent,di={touch:{start:"touchstart",move:"touchmove",end:"touchend, touchcancel"},mouse:{start:"mousedown",move:"mousemove",end:"mouseup"},pointer:{start:"pointerdown",move:"pointermove",end:"pointerup, pointercancel"},MSPointer:{start:"MSPointerDown",move:"MSPointerMove",end:"MSPointerUp"}},si,_i={};Tc?si=di.pointer:_c?si=di.MSPointer:Ec?(si=di.touch,_i=di.mouse):si=di.mouse;function ye(){}ye.prototype.on=function(r,t){var e=this,i=r.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<i.length;s+=1)n=i[s],e._handlers_[n]=e._handlers_[n]||[],e._handlers_[n].push(t);return e};ye.prototype.off=function(r,t){var e=this;return e._handlers_=e._handlers_||{},r===void 0?e._handlers_={}:t===void 0?e._handlers_[r]=null:e._handlers_[r]&&e._handlers_[r].indexOf(t)>=0&&e._handlers_[r].splice(e._handlers_[r].indexOf(t),1),e};ye.prototype.trigger=function(r,t){var e=this,i=r.split(/[ ,]+/g),n;e._handlers_=e._handlers_||{};for(var s=0;s<i.length;s+=1)n=i[s],e._handlers_[n]&&e._handlers_[n].length&&e._handlers_[n].forEach(function(o){o.call(e,{type:n,target:e},t)})};ye.prototype.config=function(r){var t=this;t.options=t.defaults||{},r&&(t.options=kc(t.options,r))};ye.prototype.bindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},e._domHandlers_[t]=function(){typeof e["on"+t]=="function"?e["on"+t].apply(e,arguments):console.warn('[WARNING] : Missing "on'+t+'" handler.')},gn(r,si[t],e._domHandlers_[t]),_i[t]&&gn(r,_i[t],e._domHandlers_[t]),e};ye.prototype.unbindEvt=function(r,t){var e=this;return e._domHandlers_=e._domHandlers_||{},xr(r,si[t],e._domHandlers_[t]),_i[t]&&xr(r,_i[t],e._domHandlers_[t]),delete e._domHandlers_[t],this};function Tt(r,t){return this.identifier=t.identifier,this.position=t.position,this.frontPosition=t.frontPosition,this.collection=r,this.defaults={size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,mode:"dynamic",zone:document.body,lockX:!1,lockY:!1,shape:"circle"},this.config(t),this.options.mode==="dynamic"&&(this.options.restOpacity=0),this.id=Tt.id,Tt.id+=1,this.buildEl().stylize(),this.instance={el:this.ui.el,on:this.on.bind(this),off:this.off.bind(this),show:this.show.bind(this),hide:this.hide.bind(this),add:this.addToDom.bind(this),remove:this.removeFromDom.bind(this),destroy:this.destroy.bind(this),setPosition:this.setPosition.bind(this),resetDirection:this.resetDirection.bind(this),computeDirection:this.computeDirection.bind(this),trigger:this.trigger.bind(this),position:this.position,frontPosition:this.frontPosition,ui:this.ui,identifier:this.identifier,id:this.id,options:this.options},this.instance}Tt.prototype=new ye;Tt.constructor=Tt;Tt.id=0;Tt.prototype.buildEl=function(r){return this.ui={},this.options.dataOnly?this:(this.ui.el=document.createElement("div"),this.ui.back=document.createElement("div"),this.ui.front=document.createElement("div"),this.ui.el.className="nipple collection_"+this.collection.id,this.ui.back.className="back",this.ui.front.className="front",this.ui.el.setAttribute("id","nipple_"+this.collection.id+"_"+this.id),this.ui.el.appendChild(this.ui.back),this.ui.el.appendChild(this.ui.front),this)};Tt.prototype.stylize=function(){if(this.options.dataOnly)return this;var r=this.options.fadeTime+"ms",t=Mc("borderRadius","50%"),e=zs("transition","opacity",r),i={};return i.el={position:"absolute",opacity:this.options.restOpacity,display:"block",zIndex:999},i.back={position:"absolute",display:"block",width:this.options.size+"px",height:this.options.size+"px",left:0,marginLeft:-this.options.size/2+"px",marginTop:-this.options.size/2+"px",background:this.options.color,opacity:".5"},i.front={width:this.options.size/2+"px",height:this.options.size/2+"px",position:"absolute",display:"block",left:0,marginLeft:-this.options.size/4+"px",marginTop:-this.options.size/4+"px",background:this.options.color,opacity:".5",transform:"translate(0px, 0px)"},Un(i.el,e),this.options.shape==="circle"&&Un(i.back,t),Un(i.front,t),this.applyStyles(i),this};Tt.prototype.applyStyles=function(r){for(var t in this.ui)if(this.ui.hasOwnProperty(t))for(var e in r[t])this.ui[t].style[e]=r[t][e];return this};Tt.prototype.addToDom=function(){return this.options.dataOnly||document.body.contains(this.ui.el)?this:(this.options.zone.appendChild(this.ui.el),this)};Tt.prototype.removeFromDom=function(){return this.options.dataOnly||!document.body.contains(this.ui.el)?this:(this.options.zone.removeChild(this.ui.el),this)};Tt.prototype.destroy=function(){clearTimeout(this.removeTimeout),clearTimeout(this.showTimeout),clearTimeout(this.restTimeout),this.trigger("destroyed",this.instance),this.removeFromDom(),this.off()};Tt.prototype.show=function(r){var t=this;return t.options.dataOnly||(clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.addToDom(),t.restCallback(),setTimeout(function(){t.ui.el.style.opacity=1},0),t.showTimeout=setTimeout(function(){t.trigger("shown",t.instance),typeof r=="function"&&r.call(this)},t.options.fadeTime)),t};Tt.prototype.hide=function(r){var t=this;if(t.options.dataOnly)return t;if(t.ui.el.style.opacity=t.options.restOpacity,clearTimeout(t.removeTimeout),clearTimeout(t.showTimeout),clearTimeout(t.restTimeout),t.removeTimeout=setTimeout(function(){var e=t.options.mode==="dynamic"?"none":"block";t.ui.el.style.display=e,typeof r=="function"&&r.call(t),t.trigger("hidden",t.instance)},t.options.fadeTime),t.options.restJoystick){const e=t.options.restJoystick,i={};i.x=e===!0||e.x!==!1?0:t.instance.frontPosition.x,i.y=e===!0||e.y!==!1?0:t.instance.frontPosition.y,t.setPosition(r,i)}return t};Tt.prototype.setPosition=function(r,t){var e=this;e.frontPosition={x:t.x,y:t.y};var i=e.options.fadeTime+"ms",n={};n.front=zs("transition",["transform"],i);var s={front:{}};s.front={transform:"translate("+e.frontPosition.x+"px,"+e.frontPosition.y+"px)"},e.applyStyles(n),e.applyStyles(s),e.restTimeout=setTimeout(function(){typeof r=="function"&&r.call(e),e.restCallback()},e.options.fadeTime)};Tt.prototype.restCallback=function(){var r=this,t={};t.front=zs("transition","none",""),r.applyStyles(t),r.trigger("rested",r.instance)};Tt.prototype.resetDirection=function(){this.direction={x:!1,y:!1,angle:!1}};Tt.prototype.computeDirection=function(r){var t=r.angle.radian,e=Math.PI/4,i=Math.PI/2,n,s,o;if(t>e&&t<e*3&&!r.lockX?n="up":t>-e&&t<=e&&!r.lockY?n="left":t>-e*3&&t<=-e&&!r.lockX?n="down":r.lockY||(n="right"),r.lockY||(t>-i&&t<i?s="left":s="right"),r.lockX||(t>0?o="up":o="down"),r.force>this.options.threshold){var a={},c;for(c in this.direction)this.direction.hasOwnProperty(c)&&(a[c]=this.direction[c]);var h={};this.direction={x:s,y:o,angle:n},r.direction=this.direction;for(c in a)a[c]===this.direction[c]&&(h[c]=!0);if(h.x&&h.y&&h.angle)return r;(!h.x||!h.y)&&this.trigger("plain",r),h.x||this.trigger("plain:"+s,r),h.y||this.trigger("plain:"+o,r),h.angle||this.trigger("dir dir:"+n,r)}else this.resetDirection();return r};function vt(r,t){var e=this;e.nipples=[],e.idles=[],e.actives=[],e.ids=[],e.pressureIntervals={},e.manager=r,e.id=vt.id,vt.id+=1,e.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},e.config(t),(e.options.mode==="static"||e.options.mode==="semi")&&(e.options.multitouch=!1),e.options.multitouch||(e.options.maxNumberOfNipples=1);const i=getComputedStyle(e.options.zone.parentElement);return i&&i.display==="flex"&&(e.parentIsFlex=!0),e.updateBox(),e.prepareNipples(),e.bindings(),e.begin(),e.nipples}vt.prototype=new ye;vt.constructor=vt;vt.id=0;vt.prototype.prepareNipples=function(){var r=this,t=r.nipples;t.on=r.on.bind(r),t.off=r.off.bind(r),t.options=r.options,t.destroy=r.destroy.bind(r),t.ids=r.ids,t.id=r.id,t.processOnMove=r.processOnMove.bind(r),t.processOnEnd=r.processOnEnd.bind(r),t.get=function(e){if(e===void 0)return t[0];for(var i=0,n=t.length;i<n;i+=1)if(t[i].identifier===e)return t[i];return!1}};vt.prototype.bindings=function(){var r=this;r.bindEvt(r.options.zone,"start"),r.options.zone.style.touchAction="none",r.options.zone.style.msTouchAction="none"};vt.prototype.begin=function(){var r=this,t=r.options;if(t.mode==="static"){var e=r.createNipple(t.position,r.manager.getIdentifier());e.add(),r.idles.push(e)}};vt.prototype.createNipple=function(r,t){var e=this,i=e.manager.scroll,n={},s=e.options,o={x:e.parentIsFlex?i.x:i.x+e.box.left,y:e.parentIsFlex?i.y:i.y+e.box.top};if(r.x&&r.y)n={x:r.x-o.x,y:r.y-o.y};else if(r.top||r.right||r.bottom||r.left){var a=document.createElement("DIV");a.style.display="hidden",a.style.top=r.top,a.style.right=r.right,a.style.bottom=r.bottom,a.style.left=r.left,a.style.position="absolute",s.zone.appendChild(a);var c=a.getBoundingClientRect();s.zone.removeChild(a),n=r,r={x:c.left+i.x,y:c.top+i.y}}var h=new Tt(e,{color:s.color,size:s.size,threshold:s.threshold,fadeTime:s.fadeTime,dataOnly:s.dataOnly,restJoystick:s.restJoystick,restOpacity:s.restOpacity,mode:s.mode,identifier:t,position:r,zone:s.zone,frontPosition:{x:0,y:0},shape:s.shape});return s.dataOnly||(wr(h.ui.el,n),wr(h.ui.front,h.frontPosition)),e.nipples.push(h),e.trigger("added "+h.identifier+":added",h),e.manager.trigger("added "+h.identifier+":added",h),e.bindNipple(h),h};vt.prototype.updateBox=function(){var r=this;r.box=r.options.zone.getBoundingClientRect()};vt.prototype.bindNipple=function(r){var t=this,e,i=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",i),r.on("dir:up dir:right dir:down dir:left",i),r.on("plain:up plain:right plain:down plain:left",i)};vt.prototype.pressureFn=function(r,t,e){var i=this,n=0;clearInterval(i.pressureIntervals[e]),i.pressureIntervals[e]=setInterval((function(){var s=r.force||r.pressure||r.webkitForce||0;s!==n&&(t.trigger("pressure",s),i.trigger("pressure "+t.identifier+":pressure",s),n=s)}).bind(i),100)};vt.prototype.onstart=function(r){var t=this,e=t.options,i=r;r=So(r),t.updateBox();var n=function(s){t.actives.length<e.maxNumberOfNipples?t.processOnStart(s):i.type.match(/^touch/)&&(Object.keys(t.manager.ids).forEach(function(o){if(Object.values(i.touches).findIndex(function(c){return c.identifier===o})<0){var a=[r[0]];a.identifier=o,t.processOnEnd(a)}}),t.actives.length<e.maxNumberOfNipples&&t.processOnStart(s))};return vs(r,n),t.manager.bindDocument(),!1};vt.prototype.processOnStart=function(r){var t=this,e=t.options,i,n=t.manager.getIdentifier(r),s=r.force||r.pressure||r.webkitForce||0,o={x:r.pageX,y:r.pageY},a=t.getOrCreate(n,o);a.identifier!==n&&t.manager.removeIdentifier(a.identifier),a.identifier=n;var c=function(l){l.trigger("start",l),t.trigger("start "+l.id+":start",l),l.show(),s>0&&t.pressureFn(r,l,l.identifier),t.processOnMove(r)};if((i=t.idles.indexOf(a))>=0&&t.idles.splice(i,1),t.actives.push(a),t.ids.push(a.identifier),e.mode!=="semi")c(a);else{var h=mn(o,a.position);if(h<=e.catchDistance)c(a);else{a.destroy(),t.processOnStart(r);return}}return a};vt.prototype.getOrCreate=function(r,t){var e=this,i=e.options,n;return/(semi|static)/.test(i.mode)?(n=e.idles[0],n?(e.idles.splice(0,1),n):i.mode==="semi"?e.createNipple(t,r):(console.warn("Coudln't find the needed nipple."),!1)):(n=e.createNipple(t,r),n)};vt.prototype.processOnMove=function(r){var t=this,e=t.options,i=t.manager.getIdentifier(r),n=t.nipples.get(i),s=t.manager.scroll;if(!vc(r)){this.processOnEnd(r);return}if(!n){console.error("Found zombie joystick with ID "+i),t.manager.removeIdentifier(i);return}if(e.dynamicPage){var o=n.el.getBoundingClientRect();n.position={x:s.x+o.left,y:s.y+o.top}}n.identifier=i;var a=n.options.size/2,c={x:r.pageX,y:r.pageY};e.lockX&&(c.y=n.position.y),e.lockY&&(c.x=n.position.x);var h=mn(c,n.position),l=xc(c,n.position),u=ws(l),d=h/a,p={distance:h,position:c},y,w;if(n.options.shape==="circle"?(y=Math.min(h,a),w=bc(n.position,y,l)):(w=Ac(c,n.position,a),y=mn(w,n.position)),e.follow){if(h>a){let A=c.x-w.x,T=c.y-w.y;n.position.x+=A,n.position.y+=T,n.el.style.top=n.position.y-(t.box.top+s.y)+"px",n.el.style.left=n.position.x-(t.box.left+s.x)+"px",h=mn(c,n.position)}}else c=w,h=y;var v=c.x-n.position.x,k=c.y-n.position.y;n.frontPosition={x:v,y:k},e.dataOnly||(n.ui.front.style.transform="translate("+v+"px,"+k+"px)");var C={identifier:n.identifier,position:c,force:d,pressure:r.force||r.pressure||r.webkitForce||0,distance:h,angle:{radian:u,degree:l},vector:{x:v/a,y:-k/a},raw:p,instance:n,lockX:e.lockX,lockY:e.lockY};C=n.computeDirection(C),C.angle={radian:ws(180-l),degree:180-l},n.trigger("move",C),t.trigger("move "+n.id+":move",C)};vt.prototype.processOnEnd=function(r){var t=this,e=t.options,i=t.manager.getIdentifier(r),n=t.nipples.get(i),s=t.manager.removeIdentifier(n.identifier);n&&(e.dataOnly||n.hide(function(){e.mode==="dynamic"&&(n.trigger("removed",n),t.trigger("removed "+n.id+":removed",n),t.manager.trigger("removed "+n.id+":removed",n),n.destroy())}),clearInterval(t.pressureIntervals[n.identifier]),n.resetDirection(),n.trigger("end",n),t.trigger("end "+n.id+":end",n),t.ids.indexOf(n.identifier)>=0&&t.ids.splice(t.ids.indexOf(n.identifier),1),t.actives.indexOf(n)>=0&&t.actives.splice(t.actives.indexOf(n),1),/(semi|static)/.test(e.mode)?t.idles.push(n):t.nipples.indexOf(n)>=0&&t.nipples.splice(t.nipples.indexOf(n),1),t.manager.unbindDocument(),/(semi|static)/.test(e.mode)&&(t.manager.ids[s.id]=s.identifier))};vt.prototype.onDestroyed=function(r,t){var e=this;e.nipples.indexOf(t)>=0&&e.nipples.splice(e.nipples.indexOf(t),1),e.actives.indexOf(t)>=0&&e.actives.splice(e.actives.indexOf(t),1),e.idles.indexOf(t)>=0&&e.idles.splice(e.idles.indexOf(t),1),e.ids.indexOf(t.identifier)>=0&&e.ids.splice(e.ids.indexOf(t.identifier),1),e.manager.removeIdentifier(t.identifier),e.manager.unbindDocument()};vt.prototype.destroy=function(){var r=this;r.unbindEvt(r.options.zone,"start"),r.nipples.forEach(function(e){e.destroy()});for(var t in r.pressureIntervals)r.pressureIntervals.hasOwnProperty(t)&&clearInterval(r.pressureIntervals[t]);r.trigger("destroyed",r.nipples),r.manager.unbindDocument(),r.off()};function St(r){var t=this;t.ids={},t.index=0,t.collections=[],t.scroll=br(),t.config(r),t.prepareCollections();var e=function(){var n;t.collections.forEach(function(s){s.forEach(function(o){n=o.el.getBoundingClientRect(),o.position={x:t.scroll.x+n.left,y:t.scroll.y+n.top}})})};gn(window,"resize",function(){gr(e)});var i=function(){t.scroll=br()};return gn(window,"scroll",function(){gr(i)}),t.collections}St.prototype=new ye;St.constructor=St;St.prototype.prepareCollections=function(){var r=this;r.collections.create=r.create.bind(r),r.collections.on=r.on.bind(r),r.collections.off=r.off.bind(r),r.collections.destroy=r.destroy.bind(r),r.collections.get=function(t){var e;return r.collections.every(function(i){return e=i.get(t),!e}),e}};St.prototype.create=function(r){return this.createCollection(r)};St.prototype.createCollection=function(r){var t=this,e=new vt(t,r);return t.bindCollection(e),t.collections.push(e),e};St.prototype.bindCollection=function(r){var t=this,e,i=function(n,s){e=n.type+" "+s.id+":"+n.type,t.trigger(e,s)};r.on("destroyed",t.onDestroyed.bind(t)),r.on("shown hidden rested dir plain",i),r.on("dir:up dir:right dir:down dir:left",i),r.on("plain:up plain:right plain:down plain:left",i)};St.prototype.bindDocument=function(){var r=this;r.binded||(r.bindEvt(document,"move").bindEvt(document,"end"),r.binded=!0)};St.prototype.unbindDocument=function(r){var t=this;(!Object.keys(t.ids).length||r===!0)&&(t.unbindEvt(document,"move").unbindEvt(document,"end"),t.binded=!1)};St.prototype.getIdentifier=function(r){var t;return r?(t=r.identifier===void 0?r.pointerId:r.identifier,t===void 0&&(t=this.latest||0)):t=this.index,this.ids[t]===void 0&&(this.ids[t]=this.index,this.index+=1),this.latest=t,this.ids[t]};St.prototype.removeIdentifier=function(r){var t={};for(var e in this.ids)if(this.ids[e]===r){t.id=e,t.identifier=this.ids[e],delete this.ids[e];break}return t};St.prototype.onmove=function(r){var t=this;return t.onAny("move",r),!1};St.prototype.onend=function(r){var t=this;return t.onAny("end",r),!1};St.prototype.oncancel=function(r){var t=this;return t.onAny("end",r),!1};St.prototype.onAny=function(r,t){var e=this,i,n="processOn"+r.charAt(0).toUpperCase()+r.slice(1);t=So(t);var s=function(a,c,h){h.ids.indexOf(c)>=0&&(h[n](a),a._found_=!0)},o=function(a){i=e.getIdentifier(a),vs(e.collections,s.bind(null,a,i)),a._found_||e.removeIdentifier(i)};return vs(t,o),!1};St.prototype.destroy=function(){var r=this;r.unbindDocument(!0),r.ids={},r.index=0,r.collections.forEach(function(t){t.destroy()}),r.off()};St.prototype.onDestroyed=function(r,t){var e=this;if(e.collections.indexOf(t)<0)return!1;e.collections.splice(e.collections.indexOf(t),1)};const vr=new St,Mr={create:function(r){return vr.create(r)},factory:vr};AFRAME.registerComponent("nipple-controls",{schema:{enabled:{default:!0},mode:{default:"dynamic",oneOf:["static","semi","dynamic"]},rotationSensitivity:{default:1},moveJoystickEnabled:{default:!0},lookJoystickEnabled:{default:!0},sideMargin:{default:"30px"},bottomMargin:{default:"70px"},moveJoystickPosition:{default:"left",oneOf:["left","right"]},lookJoystickPosition:{default:"right",oneOf:["left","right"]}},init(){this.dVelocity=new THREE.Vector3,this.lookVector=new THREE.Vector2;const r=this.el.querySelector("[look-controls]").components["look-controls"];this.pitchObject=r.pitchObject,this.yawObject=r.yawObject,this.rigRotation=this.el.object3D.rotation,this.moveData=void 0,this.lookData=void 0,this.moving=!1,this.rotating=!1},update(r){(this.data.moveJoystickPosition!==r.moveJoystickPosition||this.data.sideMargin!==r.sideMargin||this.data.bottomMargin!==r.bottomMargin||this.data.mode!==r.mode)&&this.removeMoveJoystick(),(this.data.lookJoystickPosition!==r.lookJoystickPosition||this.data.sideMargin!==r.sideMargin||this.data.bottomMargin!==r.bottomMargin||this.data.mode!==r.mode)&&this.removeLookJoystick(),this.data.enabled&&this.data.moveJoystickEnabled?this.createMoveJoystick():this.removeMoveJoystick(),this.data.enabled&&this.data.lookJoystickEnabled?this.createLookJoystick():this.removeLookJoystick()},pause(){this.moving=!1,this.rotating=!1},remove(){this.removeMoveJoystick(),this.removeLookJoystick()},isVelocityActive(){return this.data.enabled&&this.moving},getVelocityDelta(){if(this.dVelocity.set(0,0,0),this.isVelocityActive()){const r=this.moveData.force<1?this.moveData.force:1,t=this.moveData.angle.radian,e=Math.cos(t)*r,i=-Math.sin(t)*r;this.dVelocity.set(e,0,i)}return this.dVelocity},isRotationActive(){return this.data.enabled&&this.rotating},updateRotation(r){if(!this.isRotationActive())return;const t=this.lookData.force<1?this.lookData.force:1,e=this.lookData.angle.radian,i=this.lookVector;i.x=Math.cos(e)*t,i.y=Math.sin(e)*t,i.multiplyScalar(this.data.rotationSensitivity*r/1e3),this.yawObject.rotation.y-=i.x;let n=this.pitchObject.rotation.x+i.y;n=Math.max(-Math.PI/2,Math.min(Math.PI/2,n)),this.pitchObject.rotation.x=n},tick:function(r,t){this.updateRotation(t)},initLeftZone(){const r=document.createElement("div");r.setAttribute("id","joystickLeftZone"),r.setAttribute("style",`position:absolute;${this.data.moveJoystickPosition}:${this.data.sideMargin};bottom:${this.data.bottomMargin};z-index:1`),this.el.sceneEl.appendChild(r),this.leftZone=r},initRightZone(){const r=document.createElement("div");r.setAttribute("id","joystickRightZone"),r.setAttribute("style",`position:absolute;${this.data.lookJoystickPosition}:${this.data.sideMargin};bottom:${this.data.bottomMargin};z-index:1`),this.el.sceneEl.appendChild(r),this.rightZone=r},createMoveJoystick(){if(this.moveJoystick)return;this.initLeftZone();const r={mode:this.data.mode,zone:this.leftZone,color:"white",fadeTime:0};this.leftZone.style.width="100px",this.data.mode==="static"?(this.leftZone.style.height="100px",r.position={left:"50%",bottom:"50%"}):this.leftZone.style.height="400px",this.moveJoystick=Mr.create(r),this.moveJoystick.on("move",(t,e)=>{this.moveData=e,this.moving=!0}),this.moveJoystick.on("end",(t,e)=>{this.moving=!1})},createLookJoystick(){if(this.lookJoystick)return;this.initRightZone();const r={mode:this.data.mode,zone:this.rightZone,color:"white",fadeTime:0};this.rightZone.style.width="100px",this.data.mode==="static"?(this.rightZone.style.height="100px",r.position={left:"50%",bottom:"50%"}):this.rightZone.style.height="400px",this.lookJoystick=Mr.create(r),this.lookJoystick.on("move",(t,e)=>{this.lookData=e,this.rotating=!0}),this.lookJoystick.on("end",(t,e)=>{this.rotating=!1})},removeMoveJoystick(){this.moveJoystick&&(this.moveJoystick.destroy(),this.moveJoystick=void 0),this.moveData=void 0,this.leftZone&&this.leftZone.parentNode&&(this.leftZone.remove(),this.leftZone=void 0)},removeLookJoystick(){this.lookJoystick&&(this.lookJoystick.destroy(),this.lookJoystick=void 0),this.lookData=void 0,this.rightZone&&this.rightZone.parentNode&&(this.rightZone.remove(),this.rightZone=void 0)}});const Hn={once:THREE.LoopOnce,repeat:THREE.LoopRepeat,pingpong:THREE.LoopPingPong};AFRAME.registerComponent("animation-mixer",{schema:{clip:{default:"*"},useRegExp:{default:!1},duration:{default:0},clampWhenFinished:{default:!1,type:"boolean"},crossFadeDuration:{default:0},loop:{default:"repeat",oneOf:Object.keys(Hn)},repetitions:{default:1/0,min:0},timeScale:{default:1},startAt:{default:0}},init:function(){this.model=null,this.mixer=null,this.activeActions=[];const r=this.el.getObject3D("mesh");r?this.load(r):this.el.addEventListener("model-loaded",t=>{this.load(t.detail.model)})},load:function(r){const t=this.el;this.model=r,this.mixer=new THREE.AnimationMixer(r),this.mixer.addEventListener("loop",e=>{t.emit("animation-loop",{action:e.action,loopDelta:e.loopDelta})}),this.mixer.addEventListener("finished",e=>{t.emit("animation-finished",{action:e.action,direction:e.direction})}),this.data.clip&&this.update({})},remove:function(){this.mixer&&this.mixer.stopAllAction()},update:function(r){if(!r)return;const t=this.data,e=AFRAME.utils.diff(t,r);if("clip"in e){this.stopAction(),t.clip&&this.playAction();return}this.activeActions.forEach(i=>{"duration"in e&&t.duration&&i.setDuration(t.duration),"clampWhenFinished"in e&&(i.clampWhenFinished=t.clampWhenFinished),("loop"in e||"repetitions"in e)&&i.setLoop(Hn[t.loop],t.repetitions),"timeScale"in e&&i.setEffectiveTimeScale(t.timeScale)})},stopAction:function(){const r=this.data;for(let t=0;t<this.activeActions.length;t++)r.crossFadeDuration?this.activeActions[t].fadeOut(r.crossFadeDuration):this.activeActions[t].stop();this.activeActions.length=0},playAction:function(){if(!this.mixer)return;const r=this.model,t=this.data,e=r.animations||(r.geometry||{}).animations||[];if(!e.length)return;const i=t.useRegExp?t.clip:Sc(t.clip);for(let n,s=0;n=e[s];s++)if(n.name.match(i)){const o=this.mixer.clipAction(n,r);o.enabled=!0,o.clampWhenFinished=t.clampWhenFinished,t.duration&&o.setDuration(t.duration),t.timeScale!==1&&o.setEffectiveTimeScale(t.timeScale),o.startAt(this.mixer.time-t.startAt/1e3),o.setLoop(Hn[t.loop],t.repetitions).fadeIn(t.crossFadeDuration).play(),this.activeActions.push(o)}},tick:function(r,t){this.mixer&&!isNaN(t)&&this.mixer.update(t/1e3)}});function Sc(r){return new RegExp("^"+r.split(/\*+/).map(Cc).join(".*")+"$")}function Cc(r){return r.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")}/**
* @license
* Copyright 2010-2024 Three.js Authors
* SPDX-License-Identifier: MIT
*/const Fo="164",xn=0,Fc=1,Ic=2,kr=1,Ar=100,Er=204,Tr=205,_r=3,Rs=0,Sr="attached",zc="detached",Io=300,Rc=303,_e=1e3,ie=1001,Cr=1002,bn=1003,yn=1006,Ds=1008,Dc=1009,Nc=1014,zo=1015,Pc=1020,Ro=1023,Gn=1026,Fr=1027,wn=2300,vn=2301,Wn=2302,Ir=2400,zr=2401,Rr=2402,Lc=2500,Do=0,No="",Bt="srgb",Ns="srgb-linear",Oc="display-p3",Po="display-p3-linear",Ms="linear",Dr="srgb",Nr="rec709",Pr="p3",Ue=7680,Lr=519,Bc=515,Or=35044,De=2e3,ks=2001;class Cn{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const n=this._listeners[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const i=this._listeners[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,o=n.length;s<o;s++)n[s].call(this,t);t.target=null}}}const Ft=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Br=1234567;const ki=Math.PI/180,Si=180/Math.PI;function Ce(){const r=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(Ft[r&255]+Ft[r>>8&255]+Ft[r>>16&255]+Ft[r>>24&255]+"-"+Ft[t&255]+Ft[t>>8&255]+"-"+Ft[t>>16&15|64]+Ft[t>>24&255]+"-"+Ft[e&63|128]+Ft[e>>8&255]+"-"+Ft[e>>16&255]+Ft[e>>24&255]+Ft[i&255]+Ft[i>>8&255]+Ft[i>>16&255]+Ft[i>>24&255]).toLowerCase()}function Ct(r,t,e){return Math.max(t,Math.min(e,r))}function Ps(r,t){return(r%t+t)%t}function Vc(r,t,e,i,n){return i+(r-t)*(n-i)/(e-t)}function jc(r,t,e){return r!==t?(e-r)/(t-r):0}function Ai(r,t,e){return(1-e)*r+e*t}function Uc(r,t,e,i){return Ai(r,t,1-Math.exp(-e*i))}function Hc(r,t=1){return t-Math.abs(Ps(r,t*2)-t)}function Gc(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*(3-2*r))}function Wc(r,t,e){return r<=t?0:r>=e?1:(r=(r-t)/(e-t),r*r*r*(r*(r*6-15)+10))}function Kc(r,t){return r+Math.floor(Math.random()*(t-r+1))}function qc(r,t){return r+Math.random()*(t-r)}function Xc(r){return r*(.5-Math.random())}function Zc(r){r!==void 0&&(Br=r);let t=Br+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function Jc(r){return r*ki}function Yc(r){return r*Si}function $c(r){return(r&r-1)===0&&r!==0}function Qc(r){return Math.pow(2,Math.ceil(Math.log(r)/Math.LN2))}function th(r){return Math.pow(2,Math.floor(Math.log(r)/Math.LN2))}function eh(r,t,e,i,n){const s=Math.cos,o=Math.sin,a=s(e/2),c=o(e/2),h=s((t+i)/2),l=o((t+i)/2),u=s((t-i)/2),d=o((t-i)/2),p=s((i-t)/2),y=o((i-t)/2);switch(n){case"XYX":r.set(a*l,c*u,c*d,a*h);break;case"YZY":r.set(c*d,a*l,c*u,a*h);break;case"ZXZ":r.set(c*u,c*d,a*l,a*h);break;case"XZX":r.set(a*l,c*y,c*p,a*h);break;case"YXY":r.set(c*p,a*l,c*y,a*h);break;case"ZYZ":r.set(c*y,c*p,a*l,a*h);break;default:console.warn("THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function ni(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return r/4294967295;case Uint16Array:return r/65535;case Uint8Array:return r/255;case Int32Array:return Math.max(r/2147483647,-1);case Int16Array:return Math.max(r/32767,-1);case Int8Array:return Math.max(r/127,-1);default:throw new Error("Invalid component type.")}}function Pt(r,t){switch(t.constructor){case Float32Array:return r;case Uint32Array:return Math.round(r*4294967295);case Uint16Array:return Math.round(r*65535);case Uint8Array:return Math.round(r*255);case Int32Array:return Math.round(r*2147483647);case Int16Array:return Math.round(r*32767);case Int8Array:return Math.round(r*127);default:throw new Error("Invalid component type.")}}const kt={DEG2RAD:ki,RAD2DEG:Si,generateUUID:Ce,clamp:Ct,euclideanModulo:Ps,mapLinear:Vc,inverseLerp:jc,lerp:Ai,damp:Uc,pingpong:Hc,smoothstep:Gc,smootherstep:Wc,randInt:Kc,randFloat:qc,randFloatSpread:Xc,seededRandom:Zc,degToRad:Jc,radToDeg:Yc,isPowerOfTwo:$c,ceilPowerOfTwo:Qc,floorPowerOfTwo:th,setQuaternionFromProperEuler:eh,normalize:Pt,denormalize:ni};class pt{constructor(t=0,e=0){pt.prototype.isVector2=!0,this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ct(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,o=this.y-t.y;return this.x=s*i-o*n+t.x,this.y=s*n+o*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class se{constructor(t,e,i,n,s,o,a,c,h){se.prototype.isMatrix3=!0,this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,o,a,c,h)}set(t,e,i,n,s,o,a,c,h){const l=this.elements;return l[0]=t,l[1]=n,l[2]=a,l[3]=e,l[4]=s,l[5]=c,l[6]=i,l[7]=o,l[8]=h,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,o=i[0],a=i[3],c=i[6],h=i[1],l=i[4],u=i[7],d=i[2],p=i[5],y=i[8],w=n[0],v=n[3],k=n[6],C=n[1],A=n[4],T=n[7],_=n[2],z=n[5],F=n[8];return s[0]=o*w+a*C+c*_,s[3]=o*v+a*A+c*z,s[6]=o*k+a*T+c*F,s[1]=h*w+l*C+u*_,s[4]=h*v+l*A+u*z,s[7]=h*k+l*T+u*F,s[2]=d*w+p*C+y*_,s[5]=d*v+p*A+y*z,s[8]=d*k+p*T+y*F,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8];return e*o*l-e*a*h-i*s*l+i*a*c+n*s*h-n*o*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=l*o-a*h,d=a*c-l*s,p=h*s-o*c,y=e*u+i*d+n*p;if(y===0)return this.set(0,0,0,0,0,0,0,0,0);const w=1/y;return t[0]=u*w,t[1]=(n*h-l*i)*w,t[2]=(a*i-n*o)*w,t[3]=d*w,t[4]=(l*e-n*c)*w,t[5]=(n*s-a*e)*w,t[6]=p*w,t[7]=(i*c-h*e)*w,t[8]=(o*e-i*s)*w,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,i,n,s,o,a){const c=Math.cos(s),h=Math.sin(s);return this.set(i*c,i*h,-i*(c*o+h*a)+o+t,-n*h,n*c,-n*(-h*o+c*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(Kn.makeScale(t,e)),this}rotate(t){return this.premultiply(Kn.makeRotation(-t)),this}translate(t,e){return this.premultiply(Kn.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Kn=new se;function ih(r){for(let t=r.length-1;t>=0;--t)if(r[t]>=65535)return!0;return!1}function As(r){return document.createElementNS("http://www.w3.org/1999/xhtml",r)}const Vr={};function nh(r){r in Vr||(Vr[r]=!0,console.warn(r))}const jr=new se().set(.8224621,.177538,0,.0331941,.9668058,0,.0170827,.0723974,.9105199),Ur=new se().set(1.2249401,-.2249404,0,-.0420569,1.0420571,0,-.0196376,-.0786361,1.0982735),ji={[Ns]:{transfer:Ms,primaries:Nr,toReference:r=>r,fromReference:r=>r},[Bt]:{transfer:Dr,primaries:Nr,toReference:r=>r.convertSRGBToLinear(),fromReference:r=>r.convertLinearToSRGB()},[Po]:{transfer:Ms,primaries:Pr,toReference:r=>r.applyMatrix3(Ur),fromReference:r=>r.applyMatrix3(jr)},[Oc]:{transfer:Dr,primaries:Pr,toReference:r=>r.convertSRGBToLinear().applyMatrix3(Ur),fromReference:r=>r.applyMatrix3(jr).convertLinearToSRGB()}},sh=new Set([Ns,Po]),Zt={enabled:!0,_workingColorSpace:Ns,get workingColorSpace(){return this._workingColorSpace},set workingColorSpace(r){if(!sh.has(r))throw new Error(`Unsupported working color space, "${r}".`);this._workingColorSpace=r},convert:function(r,t,e){if(this.enabled===!1||t===e||!t||!e)return r;const i=ji[t].toReference,n=ji[e].fromReference;return n(i(r))},fromWorkingColorSpace:function(r,t){return this.convert(r,this._workingColorSpace,t)},toWorkingColorSpace:function(r,t){return this.convert(r,t,this._workingColorSpace)},getPrimaries:function(r){return ji[r].primaries},getTransfer:function(r){return r===No?Ms:ji[r].transfer}};function ai(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function qn(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}let He;class rh{static getDataURL(t){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let e;if(t instanceof HTMLCanvasElement)e=t;else{He===void 0&&(He=As("canvas")),He.width=t.width,He.height=t.height;const i=He.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),e=He}return e.width>2048||e.height>2048?(console.warn("THREE.ImageUtils.getDataURL: Image converted to jpg for performance reasons",t),e.toDataURL("image/jpeg",.6)):e.toDataURL("image/png")}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=As("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let o=0;o<s.length;o++)s[o]=ai(s[o]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(ai(e[i]/255)*255):e[i]=ai(e[i]);return{data:e,width:t.width,height:t.height}}else return console.warn("THREE.ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let oh=0;class ah{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:oh++}),this.uuid=Ce(),this.data=t,this.dataReady=!0,this.version=0}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let o=0,a=n.length;o<a;o++)n[o].isDataTexture?s.push(Xn(n[o].image)):s.push(Xn(n[o]))}else s=Xn(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Xn(r){return typeof HTMLImageElement<"u"&&r instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&r instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&r instanceof ImageBitmap?rh.getDataURL(r):r.data?{data:Array.from(r.data),width:r.width,height:r.height,type:r.data.constructor.name}:(console.warn("THREE.Texture: Unable to serialize Texture."),{})}let ch=0;class Gt extends Cn{constructor(t=Gt.DEFAULT_IMAGE,e=Gt.DEFAULT_MAPPING,i=ie,n=ie,s=yn,o=Ds,a=Ro,c=Dc,h=Gt.DEFAULT_ANISOTROPY,l=No){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:ch++}),this.uuid=Ce(),this.name="",this.source=new ah(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=o,this.anisotropy=h,this.format=a,this.internalFormat=null,this.type=c,this.offset=new pt(0,0),this.repeat=new pt(1,1),this.center=new pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new se,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=l,this.userData={},this.version=0,this.onUpdate=null,this.isRenderTargetTexture=!1,this.pmremVersion=0}get image(){return this.source.data}set image(t=null){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={metadata:{version:4.6,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Io)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case _e:t.x=t.x-Math.floor(t.x);break;case ie:t.x=t.x<0?0:1;break;case Cr:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case _e:t.y=t.y-Math.floor(t.y);break;case ie:t.y=t.y<0?0:1;break;case Cr:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}Gt.DEFAULT_IMAGE=null;Gt.DEFAULT_MAPPING=Io;Gt.DEFAULT_ANISOTROPY=1;class Rt{constructor(t=0,e=0,i=0,n=1){Rt.prototype.isVector4=!0,this.x=t,this.y=e,this.z=i,this.w=n}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=this.w,o=t.elements;return this.x=o[0]*e+o[4]*i+o[8]*n+o[12]*s,this.y=o[1]*e+o[5]*i+o[9]*n+o[13]*s,this.z=o[2]*e+o[6]*i+o[10]*n+o[14]*s,this.w=o[3]*e+o[7]*i+o[11]*n+o[15]*s,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,i,n,s;const c=t.elements,h=c[0],l=c[4],u=c[8],d=c[1],p=c[5],y=c[9],w=c[2],v=c[6],k=c[10];if(Math.abs(l-d)<.01&&Math.abs(u-w)<.01&&Math.abs(y-v)<.01){if(Math.abs(l+d)<.1&&Math.abs(u+w)<.1&&Math.abs(y+v)<.1&&Math.abs(h+p+k-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const A=(h+1)/2,T=(p+1)/2,_=(k+1)/2,z=(l+d)/4,F=(u+w)/4,R=(y+v)/4;return A>T&&A>_?A<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(A),n=z/i,s=F/i):T>_?T<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(T),i=z/n,s=R/n):_<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(_),i=F/s,n=R/s),this.set(i,n,s,e),this}let C=Math.sqrt((v-y)*(v-y)+(u-w)*(u-w)+(d-l)*(d-l));return Math.abs(C)<.001&&(C=1),this.x=(v-y)/C,this.y=(u-w)/C,this.z=(d-l)/C,this.w=Math.acos((h+p+k-1)/2),this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this.w=Math.max(t.w,Math.min(e.w,this.w)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this.w=Math.max(t,Math.min(e,this.w)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Ot{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,o,a){let c=i[n+0],h=i[n+1],l=i[n+2],u=i[n+3];const d=s[o+0],p=s[o+1],y=s[o+2],w=s[o+3];if(a===0){t[e+0]=c,t[e+1]=h,t[e+2]=l,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=p,t[e+2]=y,t[e+3]=w;return}if(u!==w||c!==d||h!==p||l!==y){let v=1-a;const k=c*d+h*p+l*y+u*w,C=k>=0?1:-1,A=1-k*k;if(A>Number.EPSILON){const _=Math.sqrt(A),z=Math.atan2(_,k*C);v=Math.sin(v*z)/_,a=Math.sin(a*z)/_}const T=a*C;if(c=c*v+d*T,h=h*v+p*T,l=l*v+y*T,u=u*v+w*T,v===1-a){const _=1/Math.sqrt(c*c+h*h+l*l+u*u);c*=_,h*=_,l*=_,u*=_}}t[e]=c,t[e+1]=h,t[e+2]=l,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,s,o){const a=i[n],c=i[n+1],h=i[n+2],l=i[n+3],u=s[o],d=s[o+1],p=s[o+2],y=s[o+3];return t[e]=a*y+l*u+c*p-h*d,t[e+1]=c*y+l*d+h*u-a*p,t[e+2]=h*y+l*p+a*d-c*u,t[e+3]=l*y-a*u-c*d-h*p,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const i=t._x,n=t._y,s=t._z,o=t._order,a=Math.cos,c=Math.sin,h=a(i/2),l=a(n/2),u=a(s/2),d=c(i/2),p=c(n/2),y=c(s/2);switch(o){case"XYZ":this._x=d*l*u+h*p*y,this._y=h*p*u-d*l*y,this._z=h*l*y+d*p*u,this._w=h*l*u-d*p*y;break;case"YXZ":this._x=d*l*u+h*p*y,this._y=h*p*u-d*l*y,this._z=h*l*y-d*p*u,this._w=h*l*u+d*p*y;break;case"ZXY":this._x=d*l*u-h*p*y,this._y=h*p*u+d*l*y,this._z=h*l*y+d*p*u,this._w=h*l*u-d*p*y;break;case"ZYX":this._x=d*l*u-h*p*y,this._y=h*p*u+d*l*y,this._z=h*l*y-d*p*u,this._w=h*l*u+d*p*y;break;case"YZX":this._x=d*l*u+h*p*y,this._y=h*p*u+d*l*y,this._z=h*l*y-d*p*u,this._w=h*l*u-d*p*y;break;case"XZY":this._x=d*l*u-h*p*y,this._y=h*p*u-d*l*y,this._z=h*l*y+d*p*u,this._w=h*l*u+d*p*y;break;default:console.warn("THREE.Quaternion: .setFromEuler() encountered an unknown order: "+o)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],o=e[1],a=e[5],c=e[9],h=e[2],l=e[6],u=e[10],d=i+a+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(l-c)*p,this._y=(s-h)*p,this._z=(o-n)*p}else if(i>a&&i>u){const p=2*Math.sqrt(1+i-a-u);this._w=(l-c)/p,this._x=.25*p,this._y=(n+o)/p,this._z=(s+h)/p}else if(a>u){const p=2*Math.sqrt(1+a-i-u);this._w=(s-h)/p,this._x=(n+o)/p,this._y=.25*p,this._z=(c+l)/p}else{const p=2*Math.sqrt(1+u-i-a);this._w=(o-n)/p,this._x=(s+h)/p,this._y=(c+l)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Ct(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const i=t._x,n=t._y,s=t._z,o=t._w,a=e._x,c=e._y,h=e._z,l=e._w;return this._x=i*l+o*a+n*h-s*c,this._y=n*l+o*c+s*a-i*h,this._z=s*l+o*h+i*c-n*a,this._w=o*l-i*a-n*c-s*h,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,n=this._y,s=this._z,o=this._w;let a=o*t._w+i*t._x+n*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=n,this._z=s,this;const c=1-a*a;if(c<=Number.EPSILON){const p=1-e;return this._w=p*o+e*this._w,this._x=p*i+e*this._x,this._y=p*n+e*this._y,this._z=p*s+e*this._z,this.normalize(),this}const h=Math.sqrt(c),l=Math.atan2(h,a),u=Math.sin((1-e)*l)/h,d=Math.sin(e*l)/h;return this._w=o*u+this._w*d,this._x=i*u+this._x*d,this._y=n*u+this._y*d,this._z=s*u+this._z*d,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class M{constructor(t=0,e=0,i=0){M.prototype.isVector3=!0,this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Hr.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Hr.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,o=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*o,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*o,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,o=t.y,a=t.z,c=t.w,h=2*(o*n-a*i),l=2*(a*e-s*n),u=2*(s*i-o*e);return this.x=e+c*h+o*u-a*l,this.y=i+c*l+a*h-s*u,this.z=n+c*u+s*l-o*h,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,o=e.x,a=e.y,c=e.z;return this.x=n*c-s*a,this.y=s*o-i*c,this.z=i*a-n*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Zn.copy(this).projectOnVector(t),this.sub(Zn)}reflect(t){return this.sub(Zn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const i=this.dot(t)/e;return Math.acos(Ct(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Zn=new M,Hr=new Ot;class ci{constructor(t=new M(1/0,1/0,1/0),e=new M(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e+=3)this.expandByPoint(Jt.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(Jt.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Jt.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const i=t.geometry;if(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let o=0,a=s.count;o<a;o++)t.isMesh===!0?t.getVertexPosition(o,Jt):Jt.fromBufferAttribute(s,o),Jt.applyMatrix4(t.matrixWorld),this.expandByPoint(Jt);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ui.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),Ui.copy(i.boundingBox)),Ui.applyMatrix4(t.matrixWorld),this.union(Ui)}const n=t.children;for(let s=0,o=n.length;s<o;s++)this.expandByObject(n[s],e);return this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsSphere(t){return this.clampPoint(t.center,Jt),Jt.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(pi),Hi.subVectors(this.max,pi),Ge.subVectors(t.a,pi),We.subVectors(t.b,pi),Ke.subVectors(t.c,pi),be.subVectors(We,Ge),we.subVectors(Ke,We),Fe.subVectors(Ge,Ke);let e=[0,-be.z,be.y,0,-we.z,we.y,0,-Fe.z,Fe.y,be.z,0,-be.x,we.z,0,-we.x,Fe.z,0,-Fe.x,-be.y,be.x,0,-we.y,we.x,0,-Fe.y,Fe.x,0];return!Jn(e,Ge,We,Ke,Hi)||(e=[1,0,0,0,1,0,0,0,1],!Jn(e,Ge,We,Ke,Hi))?!1:(Gi.crossVectors(be,we),e=[Gi.x,Gi.y,Gi.z],Jn(e,Ge,We,Ke,Hi))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Jt).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Jt).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(he[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),he[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),he[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),he[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),he[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),he[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),he[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),he[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(he),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}}const he=[new M,new M,new M,new M,new M,new M,new M,new M],Jt=new M,Ui=new ci,Ge=new M,We=new M,Ke=new M,be=new M,we=new M,Fe=new M,pi=new M,Hi=new M,Gi=new M,Ie=new M;function Jn(r,t,e,i,n){for(let s=0,o=r.length-3;s<=o;s+=3){Ie.fromArray(r,s);const a=n.x*Math.abs(Ie.x)+n.y*Math.abs(Ie.y)+n.z*Math.abs(Ie.z),c=t.dot(Ie),h=e.dot(Ie),l=i.dot(Ie);if(Math.max(-Math.max(c,h,l),Math.min(c,h,l))>a)return!1}return!0}const hh=new ci,fi=new M,Yn=new M;class hi{constructor(t=new M,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const i=this.center;e!==void 0?i.copy(e):hh.setFromPoints(t).getCenter(i);let n=0;for(let s=0,o=t.length;s<o;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const i=this.center.distanceToSquared(t);return e.copy(t),i>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;fi.subVectors(t,this.center);const e=fi.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(fi,n/i),this.radius+=n}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Yn.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(fi.copy(t.center).add(Yn)),this.expandByPoint(fi.copy(t.center).sub(Yn))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}}const le=new M,$n=new M,Wi=new M,ve=new M,Qn=new M,Ki=new M,ts=new M;class Ls{constructor(t=new M,e=new M(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,le)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=le.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(le.copy(this.origin).addScaledVector(this.direction,e),le.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){$n.copy(t).add(e).multiplyScalar(.5),Wi.copy(e).sub(t).normalize(),ve.copy(this.origin).sub($n);const s=t.distanceTo(e)*.5,o=-this.direction.dot(Wi),a=ve.dot(this.direction),c=-ve.dot(Wi),h=ve.lengthSq(),l=Math.abs(1-o*o);let u,d,p,y;if(l>0)if(u=o*c-a,d=o*a-c,y=s*l,u>=0)if(d>=-y)if(d<=y){const w=1/l;u*=w,d*=w,p=u*(u+o*d+2*a)+d*(o*u+d+2*c)+h}else d=s,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+h;else d=-s,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+h;else d<=-y?(u=Math.max(0,-(-o*s+a)),d=u>0?-s:Math.min(Math.max(-s,-c),s),p=-u*u+d*(d+2*c)+h):d<=y?(u=0,d=Math.min(Math.max(-s,-c),s),p=d*(d+2*c)+h):(u=Math.max(0,-(o*s+a)),d=u>0?s:Math.min(Math.max(-s,-c),s),p=-u*u+d*(d+2*c)+h);else d=o>0?-s:s,u=Math.max(0,-(o*d+a)),p=-u*u+d*(d+2*c)+h;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy($n).addScaledVector(Wi,d),p}intersectSphere(t,e){le.subVectors(t.center,this.origin);const i=le.dot(this.direction),n=le.dot(le)-i*i,s=t.radius*t.radius;if(n>s)return null;const o=Math.sqrt(s-n),a=i-o,c=i+o;return c<0?null:a<0?this.at(c,e):this.at(a,e)}intersectsSphere(t){return this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,o,a,c;const h=1/this.direction.x,l=1/this.direction.y,u=1/this.direction.z,d=this.origin;return h>=0?(i=(t.min.x-d.x)*h,n=(t.max.x-d.x)*h):(i=(t.max.x-d.x)*h,n=(t.min.x-d.x)*h),l>=0?(s=(t.min.y-d.y)*l,o=(t.max.y-d.y)*l):(s=(t.max.y-d.y)*l,o=(t.min.y-d.y)*l),i>o||s>n||((s>i||isNaN(i))&&(i=s),(o<n||isNaN(n))&&(n=o),u>=0?(a=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(a=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),i>c||a>n)||((a>i||i!==i)&&(i=a),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,le)!==null}intersectTriangle(t,e,i,n,s){Qn.subVectors(e,t),Ki.subVectors(i,t),ts.crossVectors(Qn,Ki);let o=this.direction.dot(ts),a;if(o>0){if(n)return null;a=1}else if(o<0)a=-1,o=-o;else return null;ve.subVectors(this.origin,t);const c=a*this.direction.dot(Ki.crossVectors(ve,Ki));if(c<0)return null;const h=a*this.direction.dot(Qn.cross(ve));if(h<0||c+h>o)return null;const l=-a*ve.dot(ts);return l<0?null:this.at(l/o,s)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class H{constructor(t,e,i,n,s,o,a,c,h,l,u,d,p,y,w,v){H.prototype.isMatrix4=!0,this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,o,a,c,h,l,u,d,p,y,w,v)}set(t,e,i,n,s,o,a,c,h,l,u,d,p,y,w,v){const k=this.elements;return k[0]=t,k[4]=e,k[8]=i,k[12]=n,k[1]=s,k[5]=o,k[9]=a,k[13]=c,k[2]=h,k[6]=l,k[10]=u,k[14]=d,k[3]=p,k[7]=y,k[11]=w,k[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new H().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,n=1/qe.setFromMatrixColumn(t,0).length(),s=1/qe.setFromMatrixColumn(t,1).length(),o=1/qe.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(n),h=Math.sin(n),l=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=o*l,p=o*u,y=a*l,w=a*u;e[0]=c*l,e[4]=-c*u,e[8]=h,e[1]=p+y*h,e[5]=d-w*h,e[9]=-a*c,e[2]=w-d*h,e[6]=y+p*h,e[10]=o*c}else if(t.order==="YXZ"){const d=c*l,p=c*u,y=h*l,w=h*u;e[0]=d+w*a,e[4]=y*a-p,e[8]=o*h,e[1]=o*u,e[5]=o*l,e[9]=-a,e[2]=p*a-y,e[6]=w+d*a,e[10]=o*c}else if(t.order==="ZXY"){const d=c*l,p=c*u,y=h*l,w=h*u;e[0]=d-w*a,e[4]=-o*u,e[8]=y+p*a,e[1]=p+y*a,e[5]=o*l,e[9]=w-d*a,e[2]=-o*h,e[6]=a,e[10]=o*c}else if(t.order==="ZYX"){const d=o*l,p=o*u,y=a*l,w=a*u;e[0]=c*l,e[4]=y*h-p,e[8]=d*h+w,e[1]=c*u,e[5]=w*h+d,e[9]=p*h-y,e[2]=-h,e[6]=a*c,e[10]=o*c}else if(t.order==="YZX"){const d=o*c,p=o*h,y=a*c,w=a*h;e[0]=c*l,e[4]=w-d*u,e[8]=y*u+p,e[1]=u,e[5]=o*l,e[9]=-a*l,e[2]=-h*l,e[6]=p*u+y,e[10]=d-w*u}else if(t.order==="XZY"){const d=o*c,p=o*h,y=a*c,w=a*h;e[0]=c*l,e[4]=-u,e[8]=h*l,e[1]=d*u+w,e[5]=o*l,e[9]=p*u-y,e[2]=y*u-p,e[6]=a*l,e[10]=w*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(lh,t,uh)}lookAt(t,e,i){const n=this.elements;return Ut.subVectors(t,e),Ut.lengthSq()===0&&(Ut.z=1),Ut.normalize(),Me.crossVectors(i,Ut),Me.lengthSq()===0&&(Math.abs(i.z)===1?Ut.x+=1e-4:Ut.z+=1e-4,Ut.normalize(),Me.crossVectors(i,Ut)),Me.normalize(),qi.crossVectors(Ut,Me),n[0]=Me.x,n[4]=qi.x,n[8]=Ut.x,n[1]=Me.y,n[5]=qi.y,n[9]=Ut.y,n[2]=Me.z,n[6]=qi.z,n[10]=Ut.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,o=i[0],a=i[4],c=i[8],h=i[12],l=i[1],u=i[5],d=i[9],p=i[13],y=i[2],w=i[6],v=i[10],k=i[14],C=i[3],A=i[7],T=i[11],_=i[15],z=n[0],F=n[4],R=n[8],L=n[12],G=n[1],Q=n[5],xt=n[9],dt=n[13],Dt=n[2],Wt=n[6],N=n[10],nt=n[14],it=n[3],$=n[7],lt=n[11],et=n[15];return s[0]=o*z+a*G+c*Dt+h*it,s[4]=o*F+a*Q+c*Wt+h*$,s[8]=o*R+a*xt+c*N+h*lt,s[12]=o*L+a*dt+c*nt+h*et,s[1]=l*z+u*G+d*Dt+p*it,s[5]=l*F+u*Q+d*Wt+p*$,s[9]=l*R+u*xt+d*N+p*lt,s[13]=l*L+u*dt+d*nt+p*et,s[2]=y*z+w*G+v*Dt+k*it,s[6]=y*F+w*Q+v*Wt+k*$,s[10]=y*R+w*xt+v*N+k*lt,s[14]=y*L+w*dt+v*nt+k*et,s[3]=C*z+A*G+T*Dt+_*it,s[7]=C*F+A*Q+T*Wt+_*$,s[11]=C*R+A*xt+T*N+_*lt,s[15]=C*L+A*dt+T*nt+_*et,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[12],o=t[1],a=t[5],c=t[9],h=t[13],l=t[2],u=t[6],d=t[10],p=t[14],y=t[3],w=t[7],v=t[11],k=t[15];return y*(+s*c*u-n*h*u-s*a*d+i*h*d+n*a*p-i*c*p)+w*(+e*c*p-e*h*d+s*o*d-n*o*p+n*h*l-s*c*l)+v*(+e*h*u-e*a*p-s*o*u+i*o*p+s*a*l-i*h*l)+k*(-n*a*l-e*c*u+e*a*d+n*o*u-i*o*d+i*c*l)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],o=t[4],a=t[5],c=t[6],h=t[7],l=t[8],u=t[9],d=t[10],p=t[11],y=t[12],w=t[13],v=t[14],k=t[15],C=u*v*h-w*d*h+w*c*p-a*v*p-u*c*k+a*d*k,A=y*d*h-l*v*h-y*c*p+o*v*p+l*c*k-o*d*k,T=l*w*h-y*u*h+y*a*p-o*w*p-l*a*k+o*u*k,_=y*u*c-l*w*c-y*a*d+o*w*d+l*a*v-o*u*v,z=e*C+i*A+n*T+s*_;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/z;return t[0]=C*F,t[1]=(w*d*s-u*v*s-w*n*p+i*v*p+u*n*k-i*d*k)*F,t[2]=(a*v*s-w*c*s+w*n*h-i*v*h-a*n*k+i*c*k)*F,t[3]=(u*c*s-a*d*s-u*n*h+i*d*h+a*n*p-i*c*p)*F,t[4]=A*F,t[5]=(l*v*s-y*d*s+y*n*p-e*v*p-l*n*k+e*d*k)*F,t[6]=(y*c*s-o*v*s-y*n*h+e*v*h+o*n*k-e*c*k)*F,t[7]=(o*d*s-l*c*s+l*n*h-e*d*h-o*n*p+e*c*p)*F,t[8]=T*F,t[9]=(y*u*s-l*w*s-y*i*p+e*w*p+l*i*k-e*u*k)*F,t[10]=(o*w*s-y*a*s+y*i*h-e*w*h-o*i*k+e*a*k)*F,t[11]=(l*a*s-o*u*s-l*i*h+e*u*h+o*i*p-e*a*p)*F,t[12]=_*F,t[13]=(l*w*n-y*u*n+y*i*d-e*w*d-l*i*v+e*u*v)*F,t[14]=(y*a*n-o*w*n-y*i*c+e*w*c+o*i*v-e*a*v)*F,t[15]=(o*u*n-l*a*n+l*i*c-e*u*c-o*i*d+e*a*d)*F,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,o=t.x,a=t.y,c=t.z,h=s*o,l=s*a;return this.set(h*o+i,h*a-n*c,h*c+n*a,0,h*a+n*c,l*a+i,l*c-n*o,0,h*c-n*a,l*c+n*o,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,o){return this.set(1,i,s,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,o=e._y,a=e._z,c=e._w,h=s+s,l=o+o,u=a+a,d=s*h,p=s*l,y=s*u,w=o*l,v=o*u,k=a*u,C=c*h,A=c*l,T=c*u,_=i.x,z=i.y,F=i.z;return n[0]=(1-(w+k))*_,n[1]=(p+T)*_,n[2]=(y-A)*_,n[3]=0,n[4]=(p-T)*z,n[5]=(1-(d+k))*z,n[6]=(v+C)*z,n[7]=0,n[8]=(y+A)*F,n[9]=(v-C)*F,n[10]=(1-(d+w))*F,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;let s=qe.set(n[0],n[1],n[2]).length();const o=qe.set(n[4],n[5],n[6]).length(),a=qe.set(n[8],n[9],n[10]).length();this.determinant()<0&&(s=-s),t.x=n[12],t.y=n[13],t.z=n[14],Yt.copy(this);const h=1/s,l=1/o,u=1/a;return Yt.elements[0]*=h,Yt.elements[1]*=h,Yt.elements[2]*=h,Yt.elements[4]*=l,Yt.elements[5]*=l,Yt.elements[6]*=l,Yt.elements[8]*=u,Yt.elements[9]*=u,Yt.elements[10]*=u,e.setFromRotationMatrix(Yt),i.x=s,i.y=o,i.z=a,this}makePerspective(t,e,i,n,s,o,a=De){const c=this.elements,h=2*s/(e-t),l=2*s/(i-n),u=(e+t)/(e-t),d=(i+n)/(i-n);let p,y;if(a===De)p=-(o+s)/(o-s),y=-2*o*s/(o-s);else if(a===ks)p=-o/(o-s),y=-o*s/(o-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return c[0]=h,c[4]=0,c[8]=u,c[12]=0,c[1]=0,c[5]=l,c[9]=d,c[13]=0,c[2]=0,c[6]=0,c[10]=p,c[14]=y,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(t,e,i,n,s,o,a=De){const c=this.elements,h=1/(e-t),l=1/(i-n),u=1/(o-s),d=(e+t)*h,p=(i+n)*l;let y,w;if(a===De)y=(o+s)*u,w=-2*u;else if(a===ks)y=s*u,w=-1*u;else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return c[0]=2*h,c[4]=0,c[8]=0,c[12]=-d,c[1]=0,c[5]=2*l,c[9]=0,c[13]=-p,c[2]=0,c[6]=0,c[10]=w,c[14]=-y,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const qe=new M,Yt=new H,lh=new M(0,0,0),uh=new M(1,1,1),Me=new M,qi=new M,Ut=new M,Gr=new H,Wr=new Ot;class Et{constructor(t=0,e=0,i=0,n=Et.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,i=!0){const n=t.elements,s=n[0],o=n[4],a=n[8],c=n[1],h=n[5],l=n[9],u=n[2],d=n[6],p=n[10];switch(e){case"XYZ":this._y=Math.asin(Ct(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-l,p),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,h),this._z=0);break;case"YXZ":this._x=Math.asin(-Ct(l,-1,1)),Math.abs(l)<.9999999?(this._y=Math.atan2(a,p),this._z=Math.atan2(c,h)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Ct(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-o,h)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Ct(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-o,h));break;case"YZX":this._z=Math.asin(Ct(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-l,h),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(a,p));break;case"XZY":this._z=Math.asin(-Ct(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,h),this._y=Math.atan2(a,s)):(this._x=Math.atan2(-l,p),this._y=0);break;default:console.warn("THREE.Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return Gr.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Gr,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Wr.setFromEuler(this),this.setFromQuaternion(Wr,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Et.DEFAULT_ORDER="XYZ";class dh{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let ph=0;const Kr=new M,Xe=new Ot,ue=new H,Xi=new M,mi=new M,fh=new M,mh=new Ot,qr=new M(1,0,0),Xr=new M(0,1,0),Zr=new M(0,0,1),Jr={type:"added"},yh={type:"removed"},Ze={type:"childadded",child:null},es={type:"childremoved",child:null};class gt extends Cn{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:ph++}),this.uuid=Ce(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=gt.DEFAULT_UP.clone();const t=new M,e=new Et,i=new Ot,n=new M(1,1,1);function s(){i.setFromEuler(e,!1)}function o(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(o),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new H},normalMatrix:{value:new se}}),this.matrix=new H,this.matrixWorld=new H,this.matrixAutoUpdate=gt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new dh,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.userData={}}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return Xe.setFromAxisAngle(t,e),this.quaternion.multiply(Xe),this}rotateOnWorldAxis(t,e){return Xe.setFromAxisAngle(t,e),this.quaternion.premultiply(Xe),this}rotateX(t){return this.rotateOnAxis(qr,t)}rotateY(t){return this.rotateOnAxis(Xr,t)}rotateZ(t){return this.rotateOnAxis(Zr,t)}translateOnAxis(t,e){return Kr.copy(t).applyQuaternion(this.quaternion),this.position.add(Kr.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(qr,t)}translateY(t){return this.translateOnAxis(Xr,t)}translateZ(t){return this.translateOnAxis(Zr,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(ue.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Xi.copy(t):Xi.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),mi.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?ue.lookAt(mi,Xi,this.up):ue.lookAt(Xi,mi,this.up),this.quaternion.setFromRotationMatrix(ue),n&&(ue.extractRotation(n.matrixWorld),Xe.setFromRotationMatrix(ue),this.quaternion.premultiply(Xe.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(console.error("THREE.Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Jr),Ze.child=t,this.dispatchEvent(Ze),Ze.child=null):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(yh),es.child=t,this.dispatchEvent(es),es.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),ue.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),ue.multiply(t.parent.matrixWorld)),t.applyMatrix4(ue),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Jr),Ze.child=t,this.dispatchEvent(Ze),Ze.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let i=0,n=this.children.length;i<n;i++){const o=this.children[i].getObjectByProperty(t,e);if(o!==void 0)return o}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,o=n.length;s<o;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mi,t,fh),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(mi,mh,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale),this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let i=0,n=e.length;i<n;i++){const s=e[i];(s.matrixWorldAutoUpdate===!0||t===!0)&&s.updateMatrixWorld(t)}}updateWorldMatrix(t,e){const i=this.parent;if(t===!0&&i!==null&&i.matrixWorldAutoUpdate===!0&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),e===!0){const n=this.children;for(let s=0,o=n.length;s<o;s++){const a=n[s];a.matrixWorldAutoUpdate===!0&&a.updateWorldMatrix(!1,!0)}}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.6,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.visibility=this._visibility,n.active=this._active,n.bounds=this._bounds.map(a=>({boxInitialized:a.boxInitialized,boxMin:a.box.min.toArray(),boxMax:a.box.max.toArray(),sphereInitialized:a.sphereInitialized,sphereRadius:a.sphere.radius,sphereCenter:a.sphere.center.toArray()})),n.maxGeometryCount=this._maxGeometryCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.geometryCount=this._geometryCount,n.matricesTexture=this._matricesTexture.toJSON(t),this.boundingSphere!==null&&(n.boundingSphere={center:n.boundingSphere.center.toArray(),radius:n.boundingSphere.radius}),this.boundingBox!==null&&(n.boundingBox={min:n.boundingBox.min.toArray(),max:n.boundingBox.max.toArray()}));function s(a,c){return a[c.uuid]===void 0&&(a[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(t.geometries,this.geometry);const a=this.geometry.parameters;if(a!==void 0&&a.shapes!==void 0){const c=a.shapes;if(Array.isArray(c))for(let h=0,l=c.length;h<l;h++){const u=c[h];s(t.shapes,u)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const a=[];for(let c=0,h=this.material.length;c<h;c++)a.push(s(t.materials,this.material[c]));n.material=a}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let a=0;a<this.children.length;a++)n.children.push(this.children[a].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let a=0;a<this.animations.length;a++){const c=this.animations[a];n.animations.push(s(t.animations,c))}}if(e){const a=o(t.geometries),c=o(t.materials),h=o(t.textures),l=o(t.images),u=o(t.shapes),d=o(t.skeletons),p=o(t.animations),y=o(t.nodes);a.length>0&&(i.geometries=a),c.length>0&&(i.materials=c),h.length>0&&(i.textures=h),l.length>0&&(i.images=l),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),p.length>0&&(i.animations=p),y.length>0&&(i.nodes=y)}return i.object=n,i;function o(a){const c=[];for(const h in a){const l=a[h];delete l.metadata,c.push(l)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}gt.DEFAULT_UP=new M(0,1,0);gt.DEFAULT_MATRIX_AUTO_UPDATE=!0;gt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;const $t=new M,de=new M,is=new M,pe=new M,Je=new M,Ye=new M,Yr=new M,ns=new M,ss=new M,rs=new M;class ee{constructor(t=new M,e=new M,i=new M){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),$t.subVectors(t,e),n.cross($t);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){$t.subVectors(n,e),de.subVectors(i,e),is.subVectors(t,e);const o=$t.dot($t),a=$t.dot(de),c=$t.dot(is),h=de.dot(de),l=de.dot(is),u=o*h-a*a;if(u===0)return s.set(0,0,0),null;const d=1/u,p=(h*c-a*l)*d,y=(o*l-a*c)*d;return s.set(1-p-y,y,p)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,pe)===null?!1:pe.x>=0&&pe.y>=0&&pe.x+pe.y<=1}static getInterpolation(t,e,i,n,s,o,a,c){return this.getBarycoord(t,e,i,n,pe)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,pe.x),c.addScaledVector(o,pe.y),c.addScaledVector(a,pe.z),c)}static isFrontFacing(t,e,i,n){return $t.subVectors(i,e),de.subVectors(t,e),$t.cross(de).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return $t.subVectors(this.c,this.b),de.subVectors(this.a,this.b),$t.cross(de).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return ee.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return ee.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return ee.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return ee.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return ee.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let o,a;Je.subVectors(n,i),Ye.subVectors(s,i),ns.subVectors(t,i);const c=Je.dot(ns),h=Ye.dot(ns);if(c<=0&&h<=0)return e.copy(i);ss.subVectors(t,n);const l=Je.dot(ss),u=Ye.dot(ss);if(l>=0&&u<=l)return e.copy(n);const d=c*u-l*h;if(d<=0&&c>=0&&l<=0)return o=c/(c-l),e.copy(i).addScaledVector(Je,o);rs.subVectors(t,s);const p=Je.dot(rs),y=Ye.dot(rs);if(y>=0&&p<=y)return e.copy(s);const w=p*h-c*y;if(w<=0&&h>=0&&y<=0)return a=h/(h-y),e.copy(i).addScaledVector(Ye,a);const v=l*y-p*u;if(v<=0&&u-l>=0&&p-y>=0)return Yr.subVectors(s,n),a=(u-l)/(u-l+(p-y)),e.copy(n).addScaledVector(Yr,a);const k=1/(v+w+d);return o=w*k,a=d*k,e.copy(i).addScaledVector(Je,o).addScaledVector(Ye,a)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}const Lo={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ke={h:0,s:0,l:0},Zi={h:0,s:0,l:0};function os(r,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?r+(t-r)*6*e:e<1/2?t:e<2/3?r+(t-r)*6*(2/3-e):r}class yt{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Bt){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Zt.toWorkingColorSpace(this,e),this}setRGB(t,e,i,n=Zt.workingColorSpace){return this.r=t,this.g=e,this.b=i,Zt.toWorkingColorSpace(this,n),this}setHSL(t,e,i,n=Zt.workingColorSpace){if(t=Ps(t,1),e=Ct(e,0,1),i=Ct(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,o=2*i-s;this.r=os(o,s,t+1/3),this.g=os(o,s,t),this.b=os(o,s,t-1/3)}return Zt.toWorkingColorSpace(this,n),this}setStyle(t,e=Bt){function i(s){s!==void 0&&parseFloat(s)<1&&console.warn("THREE.Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const o=n[1],a=n[2];switch(o){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(a))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:console.warn("THREE.Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],o=s.length;if(o===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(o===6)return this.setHex(parseInt(s,16),e);console.warn("THREE.Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Bt){const i=Lo[t.toLowerCase()];return i!==void 0?this.setHex(i,e):console.warn("THREE.Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=ai(t.r),this.g=ai(t.g),this.b=ai(t.b),this}copyLinearToSRGB(t){return this.r=qn(t.r),this.g=qn(t.g),this.b=qn(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Bt){return Zt.fromWorkingColorSpace(It.copy(this),t),Math.round(Ct(It.r*255,0,255))*65536+Math.round(Ct(It.g*255,0,255))*256+Math.round(Ct(It.b*255,0,255))}getHexString(t=Bt){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Zt.workingColorSpace){Zt.fromWorkingColorSpace(It.copy(this),e);const i=It.r,n=It.g,s=It.b,o=Math.max(i,n,s),a=Math.min(i,n,s);let c,h;const l=(a+o)/2;if(a===o)c=0,h=0;else{const u=o-a;switch(h=l<=.5?u/(o+a):u/(2-o-a),o){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return t.h=c,t.s=h,t.l=l,t}getRGB(t,e=Zt.workingColorSpace){return Zt.fromWorkingColorSpace(It.copy(this),e),t.r=It.r,t.g=It.g,t.b=It.b,t}getStyle(t=Bt){Zt.fromWorkingColorSpace(It.copy(this),t);const e=It.r,i=It.g,n=It.b;return t!==Bt?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(ke),this.setHSL(ke.h+t,ke.s+e,ke.l+i)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(ke),t.getHSL(Zi);const i=Ai(ke.h,Zi.h,e),n=Ai(ke.s,Zi.s,e),s=Ai(ke.l,Zi.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const It=new yt;yt.NAMES=Lo;let gh=0;class Fn extends Cn{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:gh++}),this.uuid=Ce(),this.name="",this.type="Material",this.blending=kr,this.side=xn,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=Er,this.blendDst=Tr,this.blendEquation=Ar,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new yt(0,0,0),this.blendAlpha=0,this.depthFunc=_r,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Lr,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ue,this.stencilZFail=Ue,this.stencilZPass=Ue,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBuild(){}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const i=t[e];if(i===void 0){console.warn(`THREE.Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){console.warn(`THREE.Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.6,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==kr&&(i.blending=this.blending),this.side!==xn&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Er&&(i.blendSrc=this.blendSrc),this.blendDst!==Tr&&(i.blendDst=this.blendDst),this.blendEquation!==Ar&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==_r&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Lr&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ue&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ue&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ue&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const o=[];for(const a in s){const c=s[a];delete c.metadata,o.push(c)}return o}if(e){const s=n(t.textures),o=n(t.images);s.length>0&&(i.textures=s),o.length>0&&(i.images=o)}return i}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let i=null;if(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class Es extends Fn{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Et,this.combine=Rs,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const Mt=new M,Ji=new pt;class Ne{constructor(t,e,i=!1){if(Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Or,this._updateRange={offset:0,count:-1},this.updateRanges=[],this.gpuType=zo,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}get updateRange(){return nh("THREE.BufferAttribute: updateRange() is deprecated and will be removed in r169. Use addUpdateRange() instead."),this._updateRange}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)Ji.fromBufferAttribute(this,e),Ji.applyMatrix3(t),this.setXY(e,Ji.x,Ji.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)Mt.fromBufferAttribute(this,e),Mt.applyMatrix3(t),this.setXYZ(e,Mt.x,Mt.y,Mt.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)Mt.fromBufferAttribute(this,e),Mt.applyMatrix4(t),this.setXYZ(e,Mt.x,Mt.y,Mt.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Mt.fromBufferAttribute(this,e),Mt.applyNormalMatrix(t),this.setXYZ(e,Mt.x,Mt.y,Mt.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Mt.fromBufferAttribute(this,e),Mt.transformDirection(t),this.setXYZ(e,Mt.x,Mt.y,Mt.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=ni(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Pt(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=ni(e,this.array)),e}setX(t,e){return this.normalized&&(e=Pt(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=ni(e,this.array)),e}setY(t,e){return this.normalized&&(e=Pt(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=ni(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Pt(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=ni(e,this.array)),e}setW(t,e){return this.normalized&&(e=Pt(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Pt(e,this.array),i=Pt(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Pt(e,this.array),i=Pt(i,this.array),n=Pt(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=Pt(e,this.array),i=Pt(i,this.array),n=Pt(n,this.array),s=Pt(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Or&&(t.usage=this.usage),t}}class Oo extends Ne{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class xh extends Ne{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class zt extends Ne{constructor(t,e,i){super(new Float32Array(t),e,i)}}let bh=0;const Kt=new H,as=new gt,$e=new M,Ht=new ci,yi=new ci,_t=new M;class me extends Cn{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:bh++}),this.uuid=Ce(),this.name="",this.type="BufferGeometry",this.index=null,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={}}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(ih(t)?xh:Oo)(t,1):this.index=t,this}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,i=0){this.groups.push({start:t,count:e,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const s=new se().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}applyQuaternion(t){return Kt.makeRotationFromQuaternion(t),this.applyMatrix4(Kt),this}rotateX(t){return Kt.makeRotationX(t),this.applyMatrix4(Kt),this}rotateY(t){return Kt.makeRotationY(t),this.applyMatrix4(Kt),this}rotateZ(t){return Kt.makeRotationZ(t),this.applyMatrix4(Kt),this}translate(t,e,i){return Kt.makeTranslation(t,e,i),this.applyMatrix4(Kt),this}scale(t,e,i){return Kt.makeScale(t,e,i),this.applyMatrix4(Kt),this}lookAt(t){return as.lookAt(t),as.updateMatrix(),this.applyMatrix4(as.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($e).negate(),this.translate($e.x,$e.y,$e.z),this}setFromPoints(t){const e=[];for(let i=0,n=t.length;i<n;i++){const s=t[i];e.push(s.x,s.y,s.z||0)}return this.setAttribute("position",new zt(e,3)),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ci);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new M(-1/0,-1/0,-1/0),new M(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Ht.setFromBufferAttribute(s),this.morphTargetsRelative?(_t.addVectors(this.boundingBox.min,Ht.min),this.boundingBox.expandByPoint(_t),_t.addVectors(this.boundingBox.max,Ht.max),this.boundingBox.expandByPoint(_t)):(this.boundingBox.expandByPoint(Ht.min),this.boundingBox.expandByPoint(Ht.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new hi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){console.error("THREE.BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new M,1/0);return}if(t){const i=this.boundingSphere.center;if(Ht.setFromBufferAttribute(t),e)for(let s=0,o=e.length;s<o;s++){const a=e[s];yi.setFromBufferAttribute(a),this.morphTargetsRelative?(_t.addVectors(Ht.min,yi.min),Ht.expandByPoint(_t),_t.addVectors(Ht.max,yi.max),Ht.expandByPoint(_t)):(Ht.expandByPoint(yi.min),Ht.expandByPoint(yi.max))}Ht.getCenter(i);let n=0;for(let s=0,o=t.count;s<o;s++)_t.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(_t));if(e)for(let s=0,o=e.length;s<o;s++){const a=e[s],c=this.morphTargetsRelative;for(let h=0,l=a.count;h<l;h++)_t.fromBufferAttribute(a,h),c&&($e.fromBufferAttribute(t,h),_t.add($e)),n=Math.max(n,i.distanceToSquared(_t))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){console.error("THREE.BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;this.hasAttribute("tangent")===!1&&this.setAttribute("tangent",new Ne(new Float32Array(4*i.count),4));const o=this.getAttribute("tangent"),a=[],c=[];for(let R=0;R<i.count;R++)a[R]=new M,c[R]=new M;const h=new M,l=new M,u=new M,d=new pt,p=new pt,y=new pt,w=new M,v=new M;function k(R,L,G){h.fromBufferAttribute(i,R),l.fromBufferAttribute(i,L),u.fromBufferAttribute(i,G),d.fromBufferAttribute(s,R),p.fromBufferAttribute(s,L),y.fromBufferAttribute(s,G),l.sub(h),u.sub(h),p.sub(d),y.sub(d);const Q=1/(p.x*y.y-y.x*p.y);isFinite(Q)&&(w.copy(l).multiplyScalar(y.y).addScaledVector(u,-p.y).multiplyScalar(Q),v.copy(u).multiplyScalar(p.x).addScaledVector(l,-y.x).multiplyScalar(Q),a[R].add(w),a[L].add(w),a[G].add(w),c[R].add(v),c[L].add(v),c[G].add(v))}let C=this.groups;C.length===0&&(C=[{start:0,count:t.count}]);for(let R=0,L=C.length;R<L;++R){const G=C[R],Q=G.start,xt=G.count;for(let dt=Q,Dt=Q+xt;dt<Dt;dt+=3)k(t.getX(dt+0),t.getX(dt+1),t.getX(dt+2))}const A=new M,T=new M,_=new M,z=new M;function F(R){_.fromBufferAttribute(n,R),z.copy(_);const L=a[R];A.copy(L),A.sub(_.multiplyScalar(_.dot(L))).normalize(),T.crossVectors(z,L);const Q=T.dot(c[R])<0?-1:1;o.setXYZW(R,A.x,A.y,A.z,Q)}for(let R=0,L=C.length;R<L;++R){const G=C[R],Q=G.start,xt=G.count;for(let dt=Q,Dt=Q+xt;dt<Dt;dt+=3)F(t.getX(dt+0)),F(t.getX(dt+1)),F(t.getX(dt+2))}}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0)i=new Ne(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,p=i.count;d<p;d++)i.setXYZ(d,0,0,0);const n=new M,s=new M,o=new M,a=new M,c=new M,h=new M,l=new M,u=new M;if(t)for(let d=0,p=t.count;d<p;d+=3){const y=t.getX(d+0),w=t.getX(d+1),v=t.getX(d+2);n.fromBufferAttribute(e,y),s.fromBufferAttribute(e,w),o.fromBufferAttribute(e,v),l.subVectors(o,s),u.subVectors(n,s),l.cross(u),a.fromBufferAttribute(i,y),c.fromBufferAttribute(i,w),h.fromBufferAttribute(i,v),a.add(l),c.add(l),h.add(l),i.setXYZ(y,a.x,a.y,a.z),i.setXYZ(w,c.x,c.y,c.z),i.setXYZ(v,h.x,h.y,h.z)}else for(let d=0,p=e.count;d<p;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),o.fromBufferAttribute(e,d+2),l.subVectors(o,s),u.subVectors(n,s),l.cross(u),i.setXYZ(d+0,l.x,l.y,l.z),i.setXYZ(d+1,l.x,l.y,l.z),i.setXYZ(d+2,l.x,l.y,l.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)_t.fromBufferAttribute(t,e),_t.normalize(),t.setXYZ(e,_t.x,_t.y,_t.z)}toNonIndexed(){function t(a,c){const h=a.array,l=a.itemSize,u=a.normalized,d=new h.constructor(c.length*l);let p=0,y=0;for(let w=0,v=c.length;w<v;w++){a.isInterleavedBufferAttribute?p=c[w]*a.data.stride+a.offset:p=c[w]*l;for(let k=0;k<l;k++)d[y++]=h[p++]}return new Ne(d,l,u)}if(this.index===null)return console.warn("THREE.BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new me,i=this.index.array,n=this.attributes;for(const a in n){const c=n[a],h=t(c,i);e.setAttribute(a,h)}const s=this.morphAttributes;for(const a in s){const c=[],h=s[a];for(let l=0,u=h.length;l<u;l++){const d=h[l],p=t(d,i);c.push(p)}e.morphAttributes[a]=c}e.morphTargetsRelative=this.morphTargetsRelative;const o=this.groups;for(let a=0,c=o.length;a<c;a++){const h=o[a];e.addGroup(h.start,h.count,h.materialIndex)}return e}toJSON(){const t={metadata:{version:4.6,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0){const c=this.parameters;for(const h in c)c[h]!==void 0&&(t[h]=c[h]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const i=this.attributes;for(const c in i){const h=i[c];t.data.attributes[c]=h.toJSON(t.data)}const n={};let s=!1;for(const c in this.morphAttributes){const h=this.morphAttributes[c],l=[];for(let u=0,d=h.length;u<d;u++){const p=h[u];l.push(p.toJSON(t.data))}l.length>0&&(n[c]=l,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const o=this.groups;o.length>0&&(t.data.groups=JSON.parse(JSON.stringify(o)));const a=this.boundingSphere;return a!==null&&(t.data.boundingSphere={center:a.center.toArray(),radius:a.radius}),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const i=t.index;i!==null&&this.setIndex(i.clone(e));const n=t.attributes;for(const h in n){const l=n[h];this.setAttribute(h,l.clone(e))}const s=t.morphAttributes;for(const h in s){const l=[],u=s[h];for(let d=0,p=u.length;d<p;d++)l.push(u[d].clone(e));this.morphAttributes[h]=l}this.morphTargetsRelative=t.morphTargetsRelative;const o=t.groups;for(let h=0,l=o.length;h<l;h++){const u=o[h];this.addGroup(u.start,u.count,u.materialIndex)}const a=t.boundingBox;a!==null&&(this.boundingBox=a.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this}dispose(){this.dispatchEvent({type:"dispose"})}}const $r=new H,ze=new Ls,Yi=new hi,Qr=new M,Qe=new M,ti=new M,ei=new M,cs=new M,$i=new M,Qi=new pt,tn=new pt,en=new pt,to=new M,eo=new M,io=new M,nn=new M,sn=new M;class Os extends gt{constructor(t=new me,e=new Es){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){const a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,o=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const a=this.morphTargetInfluences;if(s&&a){$i.set(0,0,0);for(let c=0,h=s.length;c<h;c++){const l=a[c],u=s[c];l!==0&&(cs.fromBufferAttribute(u,t),o?$i.addScaledVector(cs,l):$i.addScaledVector(cs.sub(e),l))}e.add($i)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),Yi.copy(i.boundingSphere),Yi.applyMatrix4(s),ze.copy(t.ray).recast(t.near),!(Yi.containsPoint(ze.origin)===!1&&(ze.intersectSphere(Yi,Qr)===null||ze.origin.distanceToSquared(Qr)>(t.far-t.near)**2))&&($r.copy(s).invert(),ze.copy(t.ray).applyMatrix4($r),!(i.boundingBox!==null&&ze.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,ze)))}_computeIntersections(t,e,i){let n;const s=this.geometry,o=this.material,a=s.index,c=s.attributes.position,h=s.attributes.uv,l=s.attributes.uv1,u=s.attributes.normal,d=s.groups,p=s.drawRange;if(a!==null)if(Array.isArray(o))for(let y=0,w=d.length;y<w;y++){const v=d[y],k=o[v.materialIndex],C=Math.max(v.start,p.start),A=Math.min(a.count,Math.min(v.start+v.count,p.start+p.count));for(let T=C,_=A;T<_;T+=3){const z=a.getX(T),F=a.getX(T+1),R=a.getX(T+2);n=rn(this,k,t,i,h,l,u,z,F,R),n&&(n.faceIndex=Math.floor(T/3),n.face.materialIndex=v.materialIndex,e.push(n))}}else{const y=Math.max(0,p.start),w=Math.min(a.count,p.start+p.count);for(let v=y,k=w;v<k;v+=3){const C=a.getX(v),A=a.getX(v+1),T=a.getX(v+2);n=rn(this,o,t,i,h,l,u,C,A,T),n&&(n.faceIndex=Math.floor(v/3),e.push(n))}}else if(c!==void 0)if(Array.isArray(o))for(let y=0,w=d.length;y<w;y++){const v=d[y],k=o[v.materialIndex],C=Math.max(v.start,p.start),A=Math.min(c.count,Math.min(v.start+v.count,p.start+p.count));for(let T=C,_=A;T<_;T+=3){const z=T,F=T+1,R=T+2;n=rn(this,k,t,i,h,l,u,z,F,R),n&&(n.faceIndex=Math.floor(T/3),n.face.materialIndex=v.materialIndex,e.push(n))}}else{const y=Math.max(0,p.start),w=Math.min(c.count,p.start+p.count);for(let v=y,k=w;v<k;v+=3){const C=v,A=v+1,T=v+2;n=rn(this,o,t,i,h,l,u,C,A,T),n&&(n.faceIndex=Math.floor(v/3),e.push(n))}}}}function wh(r,t,e,i,n,s,o,a){let c;if(t.side===Fc?c=i.intersectTriangle(o,s,n,!0,a):c=i.intersectTriangle(n,s,o,t.side===xn,a),c===null)return null;sn.copy(a),sn.applyMatrix4(r.matrixWorld);const h=e.ray.origin.distanceTo(sn);return h<e.near||h>e.far?null:{distance:h,point:sn.clone(),object:r}}function rn(r,t,e,i,n,s,o,a,c,h){r.getVertexPosition(a,Qe),r.getVertexPosition(c,ti),r.getVertexPosition(h,ei);const l=wh(r,t,e,i,Qe,ti,ei,nn);if(l){n&&(Qi.fromBufferAttribute(n,a),tn.fromBufferAttribute(n,c),en.fromBufferAttribute(n,h),l.uv=ee.getInterpolation(nn,Qe,ti,ei,Qi,tn,en,new pt)),s&&(Qi.fromBufferAttribute(s,a),tn.fromBufferAttribute(s,c),en.fromBufferAttribute(s,h),l.uv1=ee.getInterpolation(nn,Qe,ti,ei,Qi,tn,en,new pt)),o&&(to.fromBufferAttribute(o,a),eo.fromBufferAttribute(o,c),io.fromBufferAttribute(o,h),l.normal=ee.getInterpolation(nn,Qe,ti,ei,to,eo,io,new M),l.normal.dot(i.direction)>0&&l.normal.multiplyScalar(-1));const u={a,b:c,c:h,normal:new M,materialIndex:0};ee.getNormal(Qe,ti,ei,u.normal),l.face=u}return l}class Bo extends gt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new H,this.projectionMatrix=new H,this.projectionMatrixInverse=new H,this.coordinateSystem=De}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(t,e){super.updateWorldMatrix(t,e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}clone(){return new this.constructor().copy(this)}}const Ae=new M,no=new pt,so=new pt;class Ci extends Bo{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Si*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(ki*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Si*2*Math.atan(Math.tan(ki*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,i){Ae.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ae.x,Ae.y).multiplyScalar(-t/Ae.z),Ae.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ae.x,Ae.y).multiplyScalar(-t/Ae.z)}getViewSize(t,e){return this.getViewBounds(t,no,so),e.subVectors(so,no)}setViewOffset(t,e,i,n,s,o){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(ki*.5*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const o=this.view;if(this.view!==null&&this.view.enabled){const c=o.fullWidth,h=o.fullHeight;s+=o.offsetX*n/c,e-=o.offsetY*i/h,n*=o.width/c,i*=o.height/h}const a=this.filmOffset;a!==0&&(s+=t*a/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,t,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}const hs=new M,vh=new M,Mh=new se;class Te{constructor(t=new M(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=hs.subVectors(i,e).cross(vh.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e){const i=t.delta(hs),n=this.normal.dot(i);if(n===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const s=-(t.start.dot(this.normal)+this.constant)/n;return s<0||s>1?null:e.copy(t.start).addScaledVector(i,s)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const i=e||Mh.getNormalMatrix(t),n=this.coplanarPoint(hs).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Re=new hi,on=new M;class kh{constructor(t=new Te,e=new Te,i=new Te,n=new Te,s=new Te,o=new Te){this.planes=[t,e,i,n,s,o]}set(t,e,i,n,s,o){const a=this.planes;return a[0].copy(t),a[1].copy(e),a[2].copy(i),a[3].copy(n),a[4].copy(s),a[5].copy(o),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=De){const i=this.planes,n=t.elements,s=n[0],o=n[1],a=n[2],c=n[3],h=n[4],l=n[5],u=n[6],d=n[7],p=n[8],y=n[9],w=n[10],v=n[11],k=n[12],C=n[13],A=n[14],T=n[15];if(i[0].setComponents(c-s,d-h,v-p,T-k).normalize(),i[1].setComponents(c+s,d+h,v+p,T+k).normalize(),i[2].setComponents(c+o,d+l,v+y,T+C).normalize(),i[3].setComponents(c-o,d-l,v-y,T-C).normalize(),i[4].setComponents(c-a,d-u,v-w,T-A).normalize(),e===De)i[5].setComponents(c+a,d+u,v+w,T+A).normalize();else if(e===ks)i[5].setComponents(a,u,w,A).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Re.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Re.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Re)}intersectsSprite(t){return Re.center.set(0,0,0),Re.radius=.7071067811865476,Re.applyMatrix4(t.matrixWorld),this.intersectsSphere(Re)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(on.x=n.normal.x>0?t.max.x:t.min.x,on.y=n.normal.y>0?t.max.y:t.min.y,on.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(on)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends Bo{constructor(t=-1,e=1,i=1,n=-1,s=.1,o=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=o,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,i,n,s,o){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=o,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,o=i+t,a=n+e,c=n-e;if(this.view!==null&&this.view.enabled){const h=(this.right-this.left)/this.view.fullWidth/this.zoom,l=(this.top-this.bottom)/this.view.fullHeight/this.zoom;s+=h*this.view.offsetX,o=s+h*this.view.width,a-=l*this.view.offsetY,c=a-l*this.view.height}this.projectionMatrix.makeOrthographic(s,o,a,c,this.near,this.far,this.coordinateSystem),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class Ah extends Gt{constructor(t,e,i,n,s,o,a,c,h,l){if(l=l!==void 0?l:Gn,l!==Gn&&l!==Fr)throw new Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");i===void 0&&l===Gn&&(i=Nc),i===void 0&&l===Fr&&(i=Pc),super(null,n,s,o,a,c,l,i,h),this.isDepthTexture=!0,this.image={width:t,height:e},this.magFilter=a!==void 0?a:bn,this.minFilter=c!==void 0?c:bn,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}const Eh=new Ah(1,1);Eh.compareFunction=Bc;class Mn extends gt{constructor(){super(),this.isGroup=!0,this.type="Group"}}class Th extends gt{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Et,this.environmentIntensity=1,this.environmentRotation=new Et,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const ro=new M,oo=new Rt,ao=new Rt,_h=new M,co=new H,an=new M,ls=new hi,ho=new H,us=new Ls;class Vo extends Os{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Sr,this.bindMatrix=new H,this.bindMatrixInverse=new H,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new ci),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,an),this.boundingBox.expandByPoint(an)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new hi),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,an),this.boundingSphere.expandByPoint(an)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),ls.copy(this.boundingSphere),ls.applyMatrix4(n),t.ray.intersectsSphere(ls)!==!1&&(ho.copy(n).invert(),us.copy(t.ray).applyMatrix4(ho),!(this.boundingBox!==null&&us.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,us)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new Rt,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===Sr?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===zc?this.bindMatrixInverse.copy(this.bindMatrix).invert():console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;oo.fromBufferAttribute(n.attributes.skinIndex,t),ao.fromBufferAttribute(n.attributes.skinWeight,t),ro.copy(e).applyMatrix4(this.bindMatrix),e.set(0,0,0);for(let s=0;s<4;s++){const o=ao.getComponent(s);if(o!==0){const a=oo.getComponent(s);co.multiplyMatrices(i.bones[a].matrixWorld,i.boneInverses[a]),e.addScaledVector(_h.copy(ro).applyMatrix4(co),o)}}return e.applyMatrix4(this.bindMatrixInverse)}}class kn extends gt{constructor(){super(),this.isBone=!0,this.type="Bone"}}class jo extends Gt{constructor(t=null,e=1,i=1,n,s,o,a,c,h=bn,l=bn,u,d){super(null,o,a,c,h,l,n,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const lo=new H,Sh=new H;class In{constructor(t=[],e=[]){this.uuid=Ce(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){console.warn("THREE.Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new H)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new H;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,o=t.length;s<o;s++){const a=t[s]?t[s].matrixWorld:Sh;lo.multiplyMatrices(a,e[s]),lo.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new In(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const i=new jo(e,t,t,Ro,zo);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const s=t.bones[i];let o=e[s];o===void 0&&(console.warn("THREE.Skeleton: No bone found with UUID:",s),o=new kn),this.bones.push(o),this.boneInverses.push(new H().fromArray(t.boneInverses[i]))}return this.init(),this}toJSON(){const t={metadata:{version:4.6,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const o=e[n];t.bones.push(o.uuid);const a=i[n];t.boneInverses.push(a.toArray())}return t}}class An extends Fn{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new yt(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const En=new M,Tn=new M,uo=new H,gi=new Ls,cn=new hi,ds=new M,po=new M;class Vs extends gt{constructor(t=new me,e=new An){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[0];for(let n=1,s=e.count;n<s;n++)En.fromBufferAttribute(e,n-1),Tn.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=En.distanceTo(Tn);t.setAttribute("lineDistance",new zt(i,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,o=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),cn.copy(i.boundingSphere),cn.applyMatrix4(n),cn.radius+=s,t.ray.intersectsSphere(cn)===!1)return;uo.copy(n).invert(),gi.copy(t.ray).applyMatrix4(uo);const a=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=a*a,h=this.isLineSegments?2:1,l=i.index,d=i.attributes.position;if(l!==null){const p=Math.max(0,o.start),y=Math.min(l.count,o.start+o.count);for(let w=p,v=y-1;w<v;w+=h){const k=l.getX(w),C=l.getX(w+1),A=hn(this,t,gi,c,k,C);A&&e.push(A)}if(this.isLineLoop){const w=l.getX(y-1),v=l.getX(p),k=hn(this,t,gi,c,w,v);k&&e.push(k)}}else{const p=Math.max(0,o.start),y=Math.min(d.count,o.start+o.count);for(let w=p,v=y-1;w<v;w+=h){const k=hn(this,t,gi,c,w,w+1);k&&e.push(k)}if(this.isLineLoop){const w=hn(this,t,gi,c,y-1,p);w&&e.push(w)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,o=n.length;s<o;s++){const a=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=s}}}}}function hn(r,t,e,i,n,s){const o=r.geometry.attributes.position;if(En.fromBufferAttribute(o,n),Tn.fromBufferAttribute(o,s),e.distanceSqToSegment(En,Tn,ds,po)>i)return;ds.applyMatrix4(r.matrixWorld);const c=t.ray.origin.distanceTo(ds);if(!(c<t.near||c>t.far))return{distance:c,point:po.clone().applyMatrix4(r.matrixWorld),index:n,face:null,faceIndex:null,object:r}}const fo=new M,mo=new M;class Ch extends Vs{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,i=[];for(let n=0,s=e.count;n<s;n+=2)fo.fromBufferAttribute(e,n),mo.fromBufferAttribute(e,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+fo.distanceTo(mo);t.setAttribute("lineDistance",new zt(i,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class Fh{constructor(){this.type="Curve",this.arcLengthDivisions=200}getPoint(){return console.warn("THREE.Curve: .getPoint() not implemented."),null}getPointAt(t,e){const i=this.getUtoTmapping(t);return this.getPoint(i,e)}getPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){if(this.cacheArcLengths&&this.cacheArcLengths.length===t+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;const e=[];let i,n=this.getPoint(0),s=0;e.push(0);for(let o=1;o<=t;o++)i=this.getPoint(o/t),s+=i.distanceTo(n),e.push(s),n=i;return this.cacheArcLengths=e,e}updateArcLengths(){this.needsUpdate=!0,this.getLengths()}getUtoTmapping(t,e){const i=this.getLengths();let n=0;const s=i.length;let o;e?o=e:o=t*i[s-1];let a=0,c=s-1,h;for(;a<=c;)if(n=Math.floor(a+(c-a)/2),h=i[n]-o,h<0)a=n+1;else if(h>0)c=n-1;else{c=n;break}if(n=c,i[n]===o)return n/(s-1);const l=i[n],d=i[n+1]-l,p=(o-l)/d;return(n+p)/(s-1)}getTangent(t,e){let n=t-1e-4,s=t+1e-4;n<0&&(n=0),s>1&&(s=1);const o=this.getPoint(n),a=this.getPoint(s),c=e||(o.isVector2?new pt:new M);return c.copy(a).sub(o).normalize(),c}getTangentAt(t,e){const i=this.getUtoTmapping(t);return this.getTangent(i,e)}computeFrenetFrames(t,e){const i=new M,n=[],s=[],o=[],a=new M,c=new H;for(let p=0;p<=t;p++){const y=p/t;n[p]=this.getTangentAt(y,new M)}s[0]=new M,o[0]=new M;let h=Number.MAX_VALUE;const l=Math.abs(n[0].x),u=Math.abs(n[0].y),d=Math.abs(n[0].z);l<=h&&(h=l,i.set(1,0,0)),u<=h&&(h=u,i.set(0,1,0)),d<=h&&i.set(0,0,1),a.crossVectors(n[0],i).normalize(),s[0].crossVectors(n[0],a),o[0].crossVectors(n[0],s[0]);for(let p=1;p<=t;p++){if(s[p]=s[p-1].clone(),o[p]=o[p-1].clone(),a.crossVectors(n[p-1],n[p]),a.length()>Number.EPSILON){a.normalize();const y=Math.acos(Ct(n[p-1].dot(n[p]),-1,1));s[p].applyMatrix4(c.makeRotationAxis(a,y))}o[p].crossVectors(n[p],s[p])}if(e===!0){let p=Math.acos(Ct(s[0].dot(s[t]),-1,1));p/=t,n[0].dot(a.crossVectors(s[0],s[t]))>0&&(p=-p);for(let y=1;y<=t;y++)s[y].applyMatrix4(c.makeRotationAxis(n[y],p*y)),o[y].crossVectors(n[y],s[y])}return{tangents:n,normals:s,binormals:o}}clone(){return new this.constructor().copy(this)}copy(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}toJSON(){const t={metadata:{version:4.6,type:"Curve",generator:"Curve.toJSON"}};return t.arcLengthDivisions=this.arcLengthDivisions,t.type=this.type,t}fromJSON(t){return this.arcLengthDivisions=t.arcLengthDivisions,this}}const Ih={triangulate:function(r,t,e=2){const i=t&&t.length,n=i?t[0]*e:r.length;let s=Uo(r,0,n,e,!0);const o=[];if(!s||s.next===s.prev)return o;let a,c,h,l,u,d,p;if(i&&(s=Ph(r,t,s,e)),r.length>80*e){a=h=r[0],c=l=r[1];for(let y=e;y<n;y+=e)u=r[y],d=r[y+1],u<a&&(a=u),d<c&&(c=d),u>h&&(h=u),d>l&&(l=d);p=Math.max(h-a,l-c),p=p!==0?32767/p:0}return Fi(s,o,e,a,c,p,0),o}};function Uo(r,t,e,i,n){let s,o;if(n===qh(r,t,e,i)>0)for(s=t;s<e;s+=i)o=yo(s,r[s],r[s+1],o);else for(s=e-i;s>=t;s-=i)o=yo(s,r[s],r[s+1],o);return o&&zn(o,o.next)&&(zi(o),o=o.next),o}function Pe(r,t){if(!r)return r;t||(t=r);let e=r,i;do if(i=!1,!e.steiner&&(zn(e,e.next)||mt(e.prev,e,e.next)===0)){if(zi(e),e=t=e.prev,e===e.next)break;i=!0}else e=e.next;while(i||e!==t);return t}function Fi(r,t,e,i,n,s,o){if(!r)return;!o&&s&&jh(r,i,n,s);let a=r,c,h;for(;r.prev!==r.next;){if(c=r.prev,h=r.next,s?Rh(r,i,n,s):zh(r)){t.push(c.i/e|0),t.push(r.i/e|0),t.push(h.i/e|0),zi(r),r=h.next,a=h.next;continue}if(r=h,r===a){o?o===1?(r=Dh(Pe(r),t,e),Fi(r,t,e,i,n,s,2)):o===2&&Nh(r,t,e,i,n,s):Fi(Pe(r),t,e,i,n,s,1);break}}}function zh(r){const t=r.prev,e=r,i=r.next;if(mt(t,e,i)>=0)return!1;const n=t.x,s=e.x,o=i.x,a=t.y,c=e.y,h=i.y,l=n<s?n<o?n:o:s<o?s:o,u=a<c?a<h?a:h:c<h?c:h,d=n>s?n>o?n:o:s>o?s:o,p=a>c?a>h?a:h:c>h?c:h;let y=i.next;for(;y!==t;){if(y.x>=l&&y.x<=d&&y.y>=u&&y.y<=p&&ri(n,a,s,c,o,h,y.x,y.y)&&mt(y.prev,y,y.next)>=0)return!1;y=y.next}return!0}function Rh(r,t,e,i){const n=r.prev,s=r,o=r.next;if(mt(n,s,o)>=0)return!1;const a=n.x,c=s.x,h=o.x,l=n.y,u=s.y,d=o.y,p=a<c?a<h?a:h:c<h?c:h,y=l<u?l<d?l:d:u<d?u:d,w=a>c?a>h?a:h:c>h?c:h,v=l>u?l>d?l:d:u>d?u:d,k=Ts(p,y,t,e,i),C=Ts(w,v,t,e,i);let A=r.prevZ,T=r.nextZ;for(;A&&A.z>=k&&T&&T.z<=C;){if(A.x>=p&&A.x<=w&&A.y>=y&&A.y<=v&&A!==n&&A!==o&&ri(a,l,c,u,h,d,A.x,A.y)&&mt(A.prev,A,A.next)>=0||(A=A.prevZ,T.x>=p&&T.x<=w&&T.y>=y&&T.y<=v&&T!==n&&T!==o&&ri(a,l,c,u,h,d,T.x,T.y)&&mt(T.prev,T,T.next)>=0))return!1;T=T.nextZ}for(;A&&A.z>=k;){if(A.x>=p&&A.x<=w&&A.y>=y&&A.y<=v&&A!==n&&A!==o&&ri(a,l,c,u,h,d,A.x,A.y)&&mt(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;T&&T.z<=C;){if(T.x>=p&&T.x<=w&&T.y>=y&&T.y<=v&&T!==n&&T!==o&&ri(a,l,c,u,h,d,T.x,T.y)&&mt(T.prev,T,T.next)>=0)return!1;T=T.nextZ}return!0}function Dh(r,t,e){let i=r;do{const n=i.prev,s=i.next.next;!zn(n,s)&&Ho(n,i,i.next,s)&&Ii(n,s)&&Ii(s,n)&&(t.push(n.i/e|0),t.push(i.i/e|0),t.push(s.i/e|0),zi(i),zi(i.next),i=r=s),i=i.next}while(i!==r);return Pe(i)}function Nh(r,t,e,i,n,s){let o=r;do{let a=o.next.next;for(;a!==o.prev;){if(o.i!==a.i&&Gh(o,a)){let c=Go(o,a);o=Pe(o,o.next),c=Pe(c,c.next),Fi(o,t,e,i,n,s,0),Fi(c,t,e,i,n,s,0);return}a=a.next}o=o.next}while(o!==r)}function Ph(r,t,e,i){const n=[];let s,o,a,c,h;for(s=0,o=t.length;s<o;s++)a=t[s]*i,c=s<o-1?t[s+1]*i:r.length,h=Uo(r,a,c,i,!1),h===h.next&&(h.steiner=!0),n.push(Hh(h));for(n.sort(Lh),s=0;s<n.length;s++)e=Oh(n[s],e);return e}function Lh(r,t){return r.x-t.x}function Oh(r,t){const e=Bh(r,t);if(!e)return t;const i=Go(e,r);return Pe(i,i.next),Pe(e,e.next)}function Bh(r,t){let e=t,i=-1/0,n;const s=r.x,o=r.y;do{if(o<=e.y&&o>=e.next.y&&e.next.y!==e.y){const d=e.x+(o-e.y)*(e.next.x-e.x)/(e.next.y-e.y);if(d<=s&&d>i&&(i=d,n=e.x<e.next.x?e:e.next,d===s))return n}e=e.next}while(e!==t);if(!n)return null;const a=n,c=n.x,h=n.y;let l=1/0,u;e=n;do s>=e.x&&e.x>=c&&s!==e.x&&ri(o<h?s:i,o,c,h,o<h?i:s,o,e.x,e.y)&&(u=Math.abs(o-e.y)/(s-e.x),Ii(e,r)&&(u<l||u===l&&(e.x>n.x||e.x===n.x&&Vh(n,e)))&&(n=e,l=u)),e=e.next;while(e!==a);return n}function Vh(r,t){return mt(r.prev,r,t.prev)<0&&mt(t.next,r,r.next)<0}function jh(r,t,e,i){let n=r;do n.z===0&&(n.z=Ts(n.x,n.y,t,e,i)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==r);n.prevZ.nextZ=null,n.prevZ=null,Uh(n)}function Uh(r){let t,e,i,n,s,o,a,c,h=1;do{for(e=r,r=null,s=null,o=0;e;){for(o++,i=e,a=0,t=0;t<h&&(a++,i=i.nextZ,!!i);t++);for(c=h;a>0||c>0&&i;)a!==0&&(c===0||!i||e.z<=i.z)?(n=e,e=e.nextZ,a--):(n=i,i=i.nextZ,c--),s?s.nextZ=n:r=n,n.prevZ=s,s=n;e=i}s.nextZ=null,h*=2}while(o>1);return r}function Ts(r,t,e,i,n){return r=(r-e)*n|0,t=(t-i)*n|0,r=(r|r<<8)&16711935,r=(r|r<<4)&252645135,r=(r|r<<2)&858993459,r=(r|r<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,r|t<<1}function Hh(r){let t=r,e=r;do(t.x<e.x||t.x===e.x&&t.y<e.y)&&(e=t),t=t.next;while(t!==r);return e}function ri(r,t,e,i,n,s,o,a){return(n-o)*(t-a)>=(r-o)*(s-a)&&(r-o)*(i-a)>=(e-o)*(t-a)&&(e-o)*(s-a)>=(n-o)*(i-a)}function Gh(r,t){return r.next.i!==t.i&&r.prev.i!==t.i&&!Wh(r,t)&&(Ii(r,t)&&Ii(t,r)&&Kh(r,t)&&(mt(r.prev,r,t.prev)||mt(r,t.prev,t))||zn(r,t)&&mt(r.prev,r,r.next)>0&&mt(t.prev,t,t.next)>0)}function mt(r,t,e){return(t.y-r.y)*(e.x-t.x)-(t.x-r.x)*(e.y-t.y)}function zn(r,t){return r.x===t.x&&r.y===t.y}function Ho(r,t,e,i){const n=un(mt(r,t,e)),s=un(mt(r,t,i)),o=un(mt(e,i,r)),a=un(mt(e,i,t));return!!(n!==s&&o!==a||n===0&&ln(r,e,t)||s===0&&ln(r,i,t)||o===0&&ln(e,r,i)||a===0&&ln(e,t,i))}function ln(r,t,e){return t.x<=Math.max(r.x,e.x)&&t.x>=Math.min(r.x,e.x)&&t.y<=Math.max(r.y,e.y)&&t.y>=Math.min(r.y,e.y)}function un(r){return r>0?1:r<0?-1:0}function Wh(r,t){let e=r;do{if(e.i!==r.i&&e.next.i!==r.i&&e.i!==t.i&&e.next.i!==t.i&&Ho(e,e.next,r,t))return!0;e=e.next}while(e!==r);return!1}function Ii(r,t){return mt(r.prev,r,r.next)<0?mt(r,t,r.next)>=0&&mt(r,r.prev,t)>=0:mt(r,t,r.prev)<0||mt(r,r.next,t)<0}function Kh(r,t){let e=r,i=!1;const n=(r.x+t.x)/2,s=(r.y+t.y)/2;do e.y>s!=e.next.y>s&&e.next.y!==e.y&&n<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next;while(e!==r);return i}function Go(r,t){const e=new _s(r.i,r.x,r.y),i=new _s(t.i,t.x,t.y),n=r.next,s=t.prev;return r.next=t,t.prev=r,e.next=n,n.prev=e,i.next=e,e.prev=i,s.next=i,i.prev=s,i}function yo(r,t,e,i){const n=new _s(r,t,e);return i?(n.next=i.next,n.prev=i,i.next.prev=n,i.next=n):(n.prev=n,n.next=n),n}function zi(r){r.next.prev=r.prev,r.prev.next=r.next,r.prevZ&&(r.prevZ.nextZ=r.nextZ),r.nextZ&&(r.nextZ.prevZ=r.prevZ)}function _s(r,t,e){this.i=r,this.x=t,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qh(r,t,e,i){let n=0;for(let s=t,o=e-i;s<e;s+=i)n+=(r[o]-r[s])*(r[s+1]+r[o+1]),o=s;return n}class js{static area(t){const e=t.length;let i=0;for(let n=e-1,s=0;s<e;n=s++)i+=t[n].x*t[s].y-t[s].x*t[n].y;return i*.5}static isClockWise(t){return js.area(t)<0}static triangulateShape(t,e){const i=[],n=[],s=[];go(t),xo(i,t);let o=t.length;e.forEach(go);for(let c=0;c<e.length;c++)n.push(o),o+=e[c].length,xo(i,e[c]);const a=Ih.triangulate(i,n);for(let c=0;c<a.length;c+=3)s.push(a.slice(c,c+3));return s}}function go(r){const t=r.length;t>2&&r[t-1].equals(r[0])&&r.pop()}function xo(r,t){for(let e=0;e<t.length;e++)r.push(t[e].x),r.push(t[e].y)}class Ei extends Fn{constructor(t){super(),this.isMeshPhongMaterial=!0,this.type="MeshPhongMaterial",this.color=new yt(16777215),this.specular=new yt(1118481),this.shininess=30,this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Do,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Et,this.combine=Rs,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.specular.copy(t.specular),this.shininess=t.shininess,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Wo extends Fn{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new yt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new yt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Do,this.normalScale=new pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Et,this.combine=Rs,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}function dn(r,t,e){return!r||!e&&r.constructor===t?r:typeof t.BYTES_PER_ELEMENT=="number"?new t(r):Array.prototype.slice.call(r)}function Xh(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function Zh(r){function t(n,s){return r[n]-r[s]}const e=r.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(t),i}function bo(r,t,e){const i=r.length,n=new r.constructor(i);for(let s=0,o=0;o!==i;++s){const a=e[s]*t;for(let c=0;c!==t;++c)n[o++]=r[a+c]}return n}function Ko(r,t,e,i){let n=1,s=r[0];for(;s!==void 0&&s[i]===void 0;)s=r[n++];if(s===void 0)return;let o=s[i];if(o!==void 0)if(Array.isArray(o))do o=s[i],o!==void 0&&(t.push(s.time),e.push.apply(e,o)),s=r[n++];while(s!==void 0);else if(o.toArray!==void 0)do o=s[i],o!==void 0&&(t.push(s.time),o.toArray(e,e.length)),s=r[n++];while(s!==void 0);else do o=s[i],o!==void 0&&(t.push(s.time),e.push(o)),s=r[n++];while(s!==void 0)}class Rn{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];i:{t:{let o;e:{n:if(!(t<n)){for(let a=i+2;;){if(n===void 0){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===a)break;if(s=n,n=e[++i],t<n)break t}o=e.length;break e}if(!(t>=s)){const a=e[1];t<a&&(i=2,s=a);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=e[--i-1],t>=s)break t}o=i,i=0;break e}break i}for(;i<o;){const a=i+o>>>1;t<e[a]?o=a:i=a+1}if(n=e[i],s=e[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let o=0;o!==n;++o)e[o]=i[s+o];return e}interpolate_(){throw new Error("call to abstract method")}intervalChanged_(){}}class Jh extends Rn{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:Ir,endingEnd:Ir}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,o=t+1,a=n[s],c=n[o];if(a===void 0)switch(this.getSettings_().endingStart){case zr:s=t,a=2*e-i;break;case Rr:s=n.length-2,a=e+n[s]-n[s+1];break;default:s=t,a=i}if(c===void 0)switch(this.getSettings_().endingEnd){case zr:o=t,c=2*i-e;break;case Rr:o=1,c=i+n[1]-n[0];break;default:o=t-1,c=e}const h=(i-e)*.5,l=this.valueSize;this._weightPrev=h/(e-a),this._weightNext=h/(c-i),this._offsetPrev=s*l,this._offsetNext=o*l}interpolate_(t,e,i,n){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,h=c-a,l=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,p=this._weightNext,y=(i-e)/(n-e),w=y*y,v=w*y,k=-d*v+2*d*w-d*y,C=(1+d)*v+(-1.5-2*d)*w+(-.5+d)*y+1,A=(-1-p)*v+(1.5+p)*w+.5*y,T=p*v-p*w;for(let _=0;_!==a;++_)s[_]=k*o[l+_]+C*o[h+_]+A*o[c+_]+T*o[u+_];return s}}class Yh extends Rn{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=t*a,h=c-a,l=(i-e)/(n-e),u=1-l;for(let d=0;d!==a;++d)s[d]=o[h+d]*u+o[c+d]*l;return s}}class $h extends Rn{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class re{constructor(t,e,i,n){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=dn(e,this.TimeBufferType),this.values=dn(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:dn(t.times,Array),values:dn(t.values,Array)};const n=t.getInterpolation();n!==t.DefaultInterpolation&&(i.interpolation=n)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new $h(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Yh(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new Jh(this.times,this.values,this.getValueSize(),t)}setInterpolation(t){let e;switch(t){case wn:e=this.InterpolantFactoryMethodDiscrete;break;case vn:e=this.InterpolantFactoryMethodLinear;break;case Wn:e=this.InterpolantFactoryMethodSmooth;break}if(e===void 0){const i="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(i);return console.warn("THREE.KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return wn;case this.InterpolantFactoryMethodLinear:return vn;case this.InterpolantFactoryMethodSmooth:return Wn}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,o=n-1;for(;s!==n&&i[s]<t;)++s;for(;o!==-1&&i[o]>e;)--o;if(++o,s!==0||o!==n){s>=o&&(o=Math.max(o,1),s=o-1);const a=this.getValueSize();this.times=i.slice(s,o),this.values=this.values.slice(s*a,o*a)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,s=i.length;s===0&&(console.error("THREE.KeyframeTrack: Track is empty.",this),t=!1);let o=null;for(let a=0;a!==s;a++){const c=i[a];if(typeof c=="number"&&isNaN(c)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,a,c),t=!1;break}if(o!==null&&o>c){console.error("THREE.KeyframeTrack: Out of order keys.",this,a,c,o),t=!1;break}o=c}if(n!==void 0&&Xh(n))for(let a=0,c=n.length;a!==c;++a){const h=n[a];if(isNaN(h)){console.error("THREE.KeyframeTrack: Value is not a valid number.",this,a,h),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),i=this.getValueSize(),n=this.getInterpolation()===Wn,s=t.length-1;let o=1;for(let a=1;a<s;++a){let c=!1;const h=t[a],l=t[a+1];if(h!==l&&(a!==1||h!==t[0]))if(n)c=!0;else{const u=a*i,d=u-i,p=u+i;for(let y=0;y!==i;++y){const w=e[u+y];if(w!==e[d+y]||w!==e[p+y]){c=!0;break}}}if(c){if(a!==o){t[o]=t[a];const u=a*i,d=o*i;for(let p=0;p!==i;++p)e[d+p]=e[u+p]}++o}}if(s>0){t[o]=t[s];for(let a=s*i,c=o*i,h=0;h!==i;++h)e[c+h]=e[a+h];++o}return o!==t.length?(this.times=t.slice(0,o),this.values=e.slice(0,o*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,n=new i(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}re.prototype.TimeBufferType=Float32Array;re.prototype.ValueBufferType=Float32Array;re.prototype.DefaultInterpolation=vn;class li extends re{}li.prototype.ValueTypeName="bool";li.prototype.ValueBufferType=Array;li.prototype.DefaultInterpolation=wn;li.prototype.InterpolantFactoryMethodLinear=void 0;li.prototype.InterpolantFactoryMethodSmooth=void 0;class qo extends re{}qo.prototype.ValueTypeName="color";class Ri extends re{}Ri.prototype.ValueTypeName="number";class Qh extends Rn{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,c=(i-e)/(n-e);let h=t*a;for(let l=h+a;h!==l;h+=4)Ot.slerpFlat(s,0,o,h-a,o,h,c);return s}}class Se extends re{InterpolantFactoryMethodLinear(t){return new Qh(this.times,this.values,this.getValueSize(),t)}}Se.prototype.ValueTypeName="quaternion";Se.prototype.DefaultInterpolation=vn;Se.prototype.InterpolantFactoryMethodSmooth=void 0;class ui extends re{}ui.prototype.ValueTypeName="string";ui.prototype.ValueBufferType=Array;ui.prototype.DefaultInterpolation=wn;ui.prototype.InterpolantFactoryMethodLinear=void 0;ui.prototype.InterpolantFactoryMethodSmooth=void 0;class Le extends re{}Le.prototype.ValueTypeName="vector";class Ss{constructor(t="",e=-1,i=[],n=Lc){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Ce(),this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let o=0,a=i.length;o!==a;++o)e.push(el(i[o]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode};for(let s=0,o=i.length;s!==o;++s)e.push(re.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,o=[];for(let a=0;a<s;a++){let c=[],h=[];c.push((a+s-1)%s,a,(a+1)%s),h.push(0,1,0);const l=Zh(c);c=bo(c,1,l),h=bo(h,1,l),!n&&c[0]===0&&(c.push(s),h.push(h[0])),o.push(new Ri(".morphTargetInfluences["+e[a].name+"]",c,h).scale(1/i))}return new this(t,-1,o)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const n=t;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let a=0,c=t.length;a<c;a++){const h=t[a],l=h.name.match(s);if(l&&l.length>1){const u=l[1];let d=n[u];d||(n[u]=d=[]),d.push(h)}}const o=[];for(const a in n)o.push(this.CreateFromMorphTargetSequence(a,n[a],e,i));return o}static parseAnimation(t,e){if(!t)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;const i=function(u,d,p,y,w){if(p.length!==0){const v=[],k=[];Ko(p,v,k,y),v.length!==0&&w.push(new u(d,v,k))}},n=[],s=t.name||"default",o=t.fps||30,a=t.blendMode;let c=t.length||-1;const h=t.hierarchy||[];for(let u=0;u<h.length;u++){const d=h[u].keys;if(!(!d||d.length===0))if(d[0].morphTargets){const p={};let y;for(y=0;y<d.length;y++)if(d[y].morphTargets)for(let w=0;w<d[y].morphTargets.length;w++)p[d[y].morphTargets[w]]=-1;for(const w in p){const v=[],k=[];for(let C=0;C!==d[y].morphTargets.length;++C){const A=d[y];v.push(A.time),k.push(A.morphTarget===w?1:0)}n.push(new Ri(".morphTargetInfluence["+w+"]",v,k))}c=p.length*o}else{const p=".bones["+e[u].name+"]";i(Le,p+".position",d,"pos",n),i(Se,p+".quaternion",d,"rot",n),i(Le,p+".scale",d,"scl",n)}}return n.length===0?null:new this(s,c,n,a)}resetDuration(){const t=this.tracks;let e=0;for(let i=0,n=t.length;i!==n;++i){const s=this.tracks[i];e=Math.max(e,s.times[s.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let e=0;e<this.tracks.length;e++)t.push(this.tracks[e].clone());return new this.constructor(this.name,this.duration,t,this.blendMode)}toJSON(){return this.constructor.toJSON(this)}}function tl(r){switch(r.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Ri;case"vector":case"vector2":case"vector3":case"vector4":return Le;case"color":return qo;case"quaternion":return Se;case"bool":case"boolean":return li;case"string":return ui}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+r)}function el(r){if(r.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=tl(r.type);if(r.times===void 0){const e=[],i=[];Ko(r.keys,e,i,"value"),r.times=e,r.values=i}return t.parse!==void 0?t.parse(r):new t(r.name,r.times,r.values,r.interpolation)}const _n={enabled:!1,files:{},add:function(r,t){this.enabled!==!1&&(this.files[r]=t)},get:function(r){if(this.enabled!==!1)return this.files[r]},remove:function(r){delete this.files[r]},clear:function(){this.files={}}};class il{constructor(t,e,i){const n=this;let s=!1,o=0,a=0,c;const h=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this.itemStart=function(l){a++,s===!1&&n.onStart!==void 0&&n.onStart(l,o,a),s=!0},this.itemEnd=function(l){o++,n.onProgress!==void 0&&n.onProgress(l,o,a),o===a&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(l){n.onError!==void 0&&n.onError(l)},this.resolveURL=function(l){return c?c(l):l},this.setURLModifier=function(l){return c=l,this},this.addHandler=function(l,u){return h.push(l,u),this},this.removeHandler=function(l){const u=h.indexOf(l);return u!==-1&&h.splice(u,2),this},this.getHandler=function(l){for(let u=0,d=h.length;u<d;u+=2){const p=h[u],y=h[u+1];if(p.global&&(p.lastIndex=0),p.test(l))return y}return null}}}const nl=new il;class ne{constructor(t){this.manager=t!==void 0?t:nl,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}load(){}loadAsync(t,e){const i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}ne.DEFAULT_MATERIAL_NAME="__DEFAULT";const fe={};class sl extends Error{constructor(t,e){super(t),this.response=e}}class Us extends ne{constructor(t){super(t)}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=_n.get(t);if(s!==void 0)return this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0),s;if(fe[t]!==void 0){fe[t].push({onLoad:e,onProgress:i,onError:n});return}fe[t]=[],fe[t].push({onLoad:e,onProgress:i,onError:n});const o=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin"}),a=this.mimeType,c=this.responseType;fetch(o).then(h=>{if(h.status===200||h.status===0){if(h.status===0&&console.warn("THREE.FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||h.body===void 0||h.body.getReader===void 0)return h;const l=fe[t],u=h.body.getReader(),d=h.headers.get("X-File-Size")||h.headers.get("Content-Length"),p=d?parseInt(d):0,y=p!==0;let w=0;const v=new ReadableStream({start(k){C();function C(){u.read().then(({done:A,value:T})=>{if(A)k.close();else{w+=T.byteLength;const _=new ProgressEvent("progress",{lengthComputable:y,loaded:w,total:p});for(let z=0,F=l.length;z<F;z++){const R=l[z];R.onProgress&&R.onProgress(_)}k.enqueue(T),C()}})}}});return new Response(v)}else throw new sl(`fetch for "${h.url}" responded with ${h.status}: ${h.statusText}`,h)}).then(h=>{switch(c){case"arraybuffer":return h.arrayBuffer();case"blob":return h.blob();case"document":return h.text().then(l=>new DOMParser().parseFromString(l,a));case"json":return h.json();default:if(a===void 0)return h.text();{const u=/charset="?([^;"\s]*)"?/i.exec(a),d=u&&u[1]?u[1].toLowerCase():void 0,p=new TextDecoder(d);return h.arrayBuffer().then(y=>p.decode(y))}}}).then(h=>{_n.add(t,h);const l=fe[t];delete fe[t];for(let u=0,d=l.length;u<d;u++){const p=l[u];p.onLoad&&p.onLoad(h)}}).catch(h=>{const l=fe[t];if(l===void 0)throw this.manager.itemError(t),h;delete fe[t];for(let u=0,d=l.length;u<d;u++){const p=l[u];p.onError&&p.onError(h)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}}class rl extends ne{constructor(t){super(t)}load(t,e,i,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,o=_n.get(t);if(o!==void 0)return s.manager.itemStart(t),setTimeout(function(){e&&e(o),s.manager.itemEnd(t)},0),o;const a=As("img");function c(){l(),_n.add(t,this),e&&e(this),s.manager.itemEnd(t)}function h(u){l(),n&&n(u),s.manager.itemError(t),s.manager.itemEnd(t)}function l(){a.removeEventListener("load",c,!1),a.removeEventListener("error",h,!1)}return a.addEventListener("load",c,!1),a.addEventListener("error",h,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(a.crossOrigin=this.crossOrigin),s.manager.itemStart(t),a.src=t,a}}class ol extends ne{constructor(t){super(t)}load(t,e,i,n){const s=this,o=new jo,a=new Us(this.manager);return a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setPath(this.path),a.setWithCredentials(s.withCredentials),a.load(t,function(c){let h;try{h=s.parse(c)}catch(l){if(n!==void 0)n(l);else{console.error(l);return}}h.image!==void 0?o.image=h.image:h.data!==void 0&&(o.image.width=h.width,o.image.height=h.height,o.image.data=h.data),o.wrapS=h.wrapS!==void 0?h.wrapS:ie,o.wrapT=h.wrapT!==void 0?h.wrapT:ie,o.magFilter=h.magFilter!==void 0?h.magFilter:yn,o.minFilter=h.minFilter!==void 0?h.minFilter:yn,o.anisotropy=h.anisotropy!==void 0?h.anisotropy:1,h.colorSpace!==void 0&&(o.colorSpace=h.colorSpace),h.flipY!==void 0&&(o.flipY=h.flipY),h.format!==void 0&&(o.format=h.format),h.type!==void 0&&(o.type=h.type),h.mipmaps!==void 0&&(o.mipmaps=h.mipmaps,o.minFilter=Ds),h.mipmapCount===1&&(o.minFilter=yn),h.generateMipmaps!==void 0&&(o.generateMipmaps=h.generateMipmaps),o.needsUpdate=!0,e&&e(o,h)},i,n),o}}class Xo extends ne{constructor(t){super(t)}load(t,e,i,n){const s=new Gt,o=new rl(this.manager);return o.setCrossOrigin(this.crossOrigin),o.setPath(this.path),o.load(t,function(a){s.image=a,s.needsUpdate=!0,e!==void 0&&e(s)},i,n),s}}class Dn extends gt{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new yt(t),this.intensity=e}dispose(){}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,this.groundColor!==void 0&&(e.object.groundColor=this.groundColor.getHex()),this.distance!==void 0&&(e.object.distance=this.distance),this.angle!==void 0&&(e.object.angle=this.angle),this.decay!==void 0&&(e.object.decay=this.decay),this.penumbra!==void 0&&(e.object.penumbra=this.penumbra),this.shadow!==void 0&&(e.object.shadow=this.shadow.toJSON()),e}}const ps=new H,wo=new M,vo=new M;class Hs{constructor(t){this.camera=t,this.bias=0,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new pt(512,512),this.map=null,this.mapPass=null,this.matrix=new H,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new kh,this._frameExtents=new pt(1,1),this._viewportCount=1,this._viewports=[new Rt(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;wo.setFromMatrixPosition(t.matrixWorld),e.position.copy(wo),vo.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(vo),e.updateMatrixWorld(),ps.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(ps),i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(ps)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.bias=t.bias,this.radius=t.radius,this.mapSize.copy(t.mapSize),this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}class al extends Hs{constructor(){super(new Ci(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1}updateMatrices(t){const e=this.camera,i=Si*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height,s=t.distance||e.far;(i!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class Zo extends Dn{constructor(t,e,i=0,n=Math.PI/3,s=0,o=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.distance=i,this.angle=n,this.penumbra=s,this.decay=o,this.map=null,this.shadow=new al}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}const Mo=new H,xi=new M,fs=new M;class cl extends Hs{constructor(){super(new Ci(90,1,.5,500)),this.isPointLightShadow=!0,this._frameExtents=new pt(4,2),this._viewportCount=6,this._viewports=[new Rt(2,1,1,1),new Rt(0,1,1,1),new Rt(3,1,1,1),new Rt(1,1,1,1),new Rt(3,0,1,1),new Rt(1,0,1,1)],this._cubeDirections=[new M(1,0,0),new M(-1,0,0),new M(0,0,1),new M(0,0,-1),new M(0,1,0),new M(0,-1,0)],this._cubeUps=[new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,1,0),new M(0,0,1),new M(0,0,-1)]}updateMatrices(t,e=0){const i=this.camera,n=this.matrix,s=t.distance||i.far;s!==i.far&&(i.far=s,i.updateProjectionMatrix()),xi.setFromMatrixPosition(t.matrixWorld),i.position.copy(xi),fs.copy(i.position),fs.add(this._cubeDirections[e]),i.up.copy(this._cubeUps[e]),i.lookAt(fs),i.updateMatrixWorld(),n.makeTranslation(-xi.x,-xi.y,-xi.z),Mo.multiplyMatrices(i.projectionMatrix,i.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Mo)}}class Cs extends Dn{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new cl}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}}class hl extends Hs{constructor(){super(new Bs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Jo extends Dn{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(gt.DEFAULT_UP),this.updateMatrix(),this.target=new gt,this.shadow=new hl}dispose(){this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}}class Yo extends Dn{constructor(t,e){super(t,e),this.isAmbientLight=!0,this.type="AmbientLight"}}class $o{static decodeText(t){if(typeof TextDecoder<"u")return new TextDecoder().decode(t);let e="";for(let i=0,n=t.length;i<n;i++)e+=String.fromCharCode(t[i]);try{return decodeURIComponent(escape(e))}catch{return e}}static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}const Gs="\\[\\]\\.:\\/",ll=new RegExp("["+Gs+"]","g"),Ws="[^"+Gs+"]",ul="[^"+Gs.replace("\\.","")+"]",dl=/((?:WC+[\/:])*)/.source.replace("WC",Ws),pl=/(WCOD+)?/.source.replace("WCOD",ul),fl=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",Ws),ml=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",Ws),yl=new RegExp("^"+dl+pl+fl+ml+"$"),gl=["material","materials","bones","map"];class xl{constructor(t,e,i){const n=i||ot.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class ot{constructor(t,e,i){this.path=e,this.parsedPath=i||ot.parseTrackName(e),this.node=ot.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new ot.Composite(t,e,i):new ot(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(ll,"")}static parseTrackName(t){const e=yl.exec(t);if(e===null)throw new Error("PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);gl.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(s){for(let o=0;o<s.length;o++){const a=s[o];if(a.name===e||a.uuid===e)return a;const c=i(a.children);if(c)return c}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=ot.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){console.warn("THREE.PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let h=e.objectIndex;switch(i){case"materials":if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let l=0;l<t.length;l++)if(t[l].name===h){h=l;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){console.error("THREE.PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[i]===void 0){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(h!==void 0){if(t[h]===void 0){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[h]}}const o=t[n];if(o===void 0){const h=e.nodeName;console.error("THREE.PropertyBinding: Trying to update property for track: "+h+"."+n+" but it wasn't found.",t);return}let a=this.Versioning.None;this.targetObject=t,t.needsUpdate!==void 0?a=this.Versioning.NeedsUpdate:t.matrixWorldNeedsUpdate!==void 0&&(a=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=o,this.propertyIndex=s}else o.fromArray!==void 0&&o.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=o):Array.isArray(o)?(c=this.BindingType.EntireArray,this.resolvedProperty=o):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][a]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ot.Composite=xl;ot.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ot.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ot.prototype.GetterByBindingType=[ot.prototype._getValue_direct,ot.prototype._getValue_array,ot.prototype._getValue_arrayElement,ot.prototype._getValue_toArray];ot.prototype.SetterByBindingTypeAndVersioning=[[ot.prototype._setValue_direct,ot.prototype._setValue_direct_setNeedsUpdate,ot.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_array,ot.prototype._setValue_array_setNeedsUpdate,ot.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_arrayElement,ot.prototype._setValue_arrayElement_setNeedsUpdate,ot.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ot.prototype._setValue_fromArray,ot.prototype._setValue_fromArray_setNeedsUpdate,ot.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Fo}}));typeof window<"u"&&(window.__THREE__?console.warn("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Fo);class ko extends ol{constructor(t){super(t)}parse(t){function e(N){switch(N.image_type){case d:case w:if(N.colormap_length>256||N.colormap_size!==24||N.colormap_type!==1)throw new Error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case p:case y:case v:case k:if(N.colormap_type)throw new Error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case u:throw new Error("THREE.TGALoader: No data.");default:throw new Error("THREE.TGALoader: Invalid type "+N.image_type)}if(N.width<=0||N.height<=0)throw new Error("THREE.TGALoader: Invalid image size.");if(N.pixel_size!==8&&N.pixel_size!==16&&N.pixel_size!==24&&N.pixel_size!==32)throw new Error("THREE.TGALoader: Invalid pixel size "+N.pixel_size)}function i(N,nt,it,$,lt){let et,at;const Y=it.pixel_size>>3,Z=it.width*it.height*Y;if(nt&&(at=lt.subarray($,$+=it.colormap_length*(it.colormap_size>>3))),N){et=new Uint8Array(Z);let W,O,q,ct=0;const Nt=new Uint8Array(Y);for(;ct<Z;)if(W=lt[$++],O=(W&127)+1,W&128){for(q=0;q<Y;++q)Nt[q]=lt[$++];for(q=0;q<O;++q)et.set(Nt,ct+q*Y);ct+=Y*O}else{for(O*=Y,q=0;q<O;++q)et[ct+q]=lt[$++];ct+=O}}else et=lt.subarray($,$+=nt?it.width*it.height:Z);return{pixel_data:et,palettes:at}}function n(N,nt,it,$,lt,et,at,Y,Z){const W=Z;let O,q=0,ct,Nt;const ge=G.width;for(Nt=nt;Nt!==$;Nt+=it)for(ct=lt;ct!==at;ct+=et,q++)O=Y[q],N[(ct+ge*Nt)*4+3]=255,N[(ct+ge*Nt)*4+2]=W[O*3+0],N[(ct+ge*Nt)*4+1]=W[O*3+1],N[(ct+ge*Nt)*4+0]=W[O*3+2];return N}function s(N,nt,it,$,lt,et,at,Y){let Z,W=0,O,q;const ct=G.width;for(q=nt;q!==$;q+=it)for(O=lt;O!==at;O+=et,W+=2)Z=Y[W+0]+(Y[W+1]<<8),N[(O+ct*q)*4+0]=(Z&31744)>>7,N[(O+ct*q)*4+1]=(Z&992)>>2,N[(O+ct*q)*4+2]=(Z&31)<<3,N[(O+ct*q)*4+3]=Z&32768?0:255;return N}function o(N,nt,it,$,lt,et,at,Y){let Z=0,W,O;const q=G.width;for(O=nt;O!==$;O+=it)for(W=lt;W!==at;W+=et,Z+=3)N[(W+q*O)*4+3]=255,N[(W+q*O)*4+2]=Y[Z+0],N[(W+q*O)*4+1]=Y[Z+1],N[(W+q*O)*4+0]=Y[Z+2];return N}function a(N,nt,it,$,lt,et,at,Y){let Z=0,W,O;const q=G.width;for(O=nt;O!==$;O+=it)for(W=lt;W!==at;W+=et,Z+=4)N[(W+q*O)*4+2]=Y[Z+0],N[(W+q*O)*4+1]=Y[Z+1],N[(W+q*O)*4+0]=Y[Z+2],N[(W+q*O)*4+3]=Y[Z+3];return N}function c(N,nt,it,$,lt,et,at,Y){let Z,W=0,O,q;const ct=G.width;for(q=nt;q!==$;q+=it)for(O=lt;O!==at;O+=et,W++)Z=Y[W],N[(O+ct*q)*4+0]=Z,N[(O+ct*q)*4+1]=Z,N[(O+ct*q)*4+2]=Z,N[(O+ct*q)*4+3]=255;return N}function h(N,nt,it,$,lt,et,at,Y){let Z=0,W,O;const q=G.width;for(O=nt;O!==$;O+=it)for(W=lt;W!==at;W+=et,Z+=2)N[(W+q*O)*4+0]=Y[Z+0],N[(W+q*O)*4+1]=Y[Z+0],N[(W+q*O)*4+2]=Y[Z+0],N[(W+q*O)*4+3]=Y[Z+1];return N}function l(N,nt,it,$,lt){let et,at,Y,Z,W,O;switch((G.flags&C)>>A){default:case z:et=0,Y=1,W=nt,at=0,Z=1,O=it;break;case T:et=0,Y=1,W=nt,at=it-1,Z=-1,O=-1;break;case F:et=nt-1,Y=-1,W=-1,at=0,Z=1,O=it;break;case _:et=nt-1,Y=-1,W=-1,at=it-1,Z=-1,O=-1;break}if(dt)switch(G.pixel_size){case 8:c(N,at,Z,O,et,Y,W,$);break;case 16:h(N,at,Z,O,et,Y,W,$);break;default:throw new Error("THREE.TGALoader: Format not supported.")}else switch(G.pixel_size){case 8:n(N,at,Z,O,et,Y,W,$,lt);break;case 16:s(N,at,Z,O,et,Y,W,$);break;case 24:o(N,at,Z,O,et,Y,W,$);break;case 32:a(N,at,Z,O,et,Y,W,$);break;default:throw new Error("THREE.TGALoader: Format not supported.")}return N}const u=0,d=1,p=2,y=3,w=9,v=10,k=11,C=48,A=4,T=0,_=1,z=2,F=3;if(t.length<19)throw new Error("THREE.TGALoader: Not enough data to contain header.");let R=0;const L=new Uint8Array(t),G={id_length:L[R++],colormap_type:L[R++],image_type:L[R++],colormap_index:L[R++]|L[R++]<<8,colormap_length:L[R++]|L[R++]<<8,colormap_size:L[R++],origin:[L[R++]|L[R++]<<8,L[R++]|L[R++]<<8],width:L[R++]|L[R++]<<8,height:L[R++]|L[R++]<<8,pixel_size:L[R++],flags:L[R++]};if(e(G),G.id_length+R>t.length)throw new Error("THREE.TGALoader: No data.");R+=G.id_length;let Q=!1,xt=!1,dt=!1;switch(G.image_type){case w:Q=!0,xt=!0;break;case d:xt=!0;break;case v:Q=!0;break;case p:break;case k:Q=!0,dt=!0;break;case y:dt=!0;break}const Dt=new Uint8Array(G.width*G.height*4),Wt=i(Q,xt,G,R,L);return l(Dt,G.width,G.height,Wt.pixel_data,Wt.palettes),{data:Dt,width:G.width,height:G.height,flipY:!0,generateMipmaps:!0,minFilter:Ds}}}class bl extends ne{load(t,e,i,n){const s=this,o=s.path===""?$o.extractUrlBase(t):s.path,a=new Us(s.manager);a.setPath(s.path),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(t,function(c){try{e(s.parse(c,o))}catch(h){n?n(h):console.error(h),s.manager.itemError(t)}},i,n)}parse(t,e){function i(m,f){const x=[],g=m.childNodes;for(let b=0,E=g.length;b<E;b++){const S=g[b];S.nodeName===f&&x.push(S)}return x}function n(m){if(m.length===0)return[];const f=m.trim().split(/\s+/),x=new Array(f.length);for(let g=0,b=f.length;g<b;g++)x[g]=f[g];return x}function s(m){if(m.length===0)return[];const f=m.trim().split(/\s+/),x=new Array(f.length);for(let g=0,b=f.length;g<b;g++)x[g]=parseFloat(f[g]);return x}function o(m){if(m.length===0)return[];const f=m.trim().split(/\s+/),x=new Array(f.length);for(let g=0,b=f.length;g<b;g++)x[g]=parseInt(f[g]);return x}function a(m){return m.substring(1)}function c(){return"three_default_"+cc++}function h(m){return Object.keys(m).length===0}function l(m){return{unit:u(i(m,"unit")[0]),upAxis:d(i(m,"up_axis")[0])}}function u(m){return m!==void 0&&m.hasAttribute("meter")===!0?parseFloat(m.getAttribute("meter")):1}function d(m){return m!==void 0?m.textContent:"Y_UP"}function p(m,f,x,g){const b=i(m,f)[0];if(b!==void 0){const E=i(b,x);for(let S=0;S<E.length;S++)g(E[S])}}function y(m,f){for(const x in m){const g=m[x];g.build=f(m[x])}}function w(m,f){return m.build!==void 0||(m.build=f(m)),m.build}function v(m){const f={sources:{},samplers:{},channels:{}};let x=!1;for(let g=0,b=m.childNodes.length;g<b;g++){const E=m.childNodes[g];if(E.nodeType!==1)continue;let S;switch(E.nodeName){case"source":S=E.getAttribute("id"),f.sources[S]=Nn(E);break;case"sampler":S=E.getAttribute("id"),f.samplers[S]=k(E);break;case"channel":S=E.getAttribute("target"),f.channels[S]=C(E);break;case"animation":v(E),x=!0;break;default:console.log(E)}}x===!1&&(J.animations[m.getAttribute("id")||kt.generateUUID()]=f)}function k(m){const f={inputs:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"input":const E=a(b.getAttribute("source")),S=b.getAttribute("semantic");f.inputs[S]=E;break}}return f}function C(m){const f={};let g=m.getAttribute("target").split("/");const b=g.shift();let E=g.shift();const S=E.indexOf("(")!==-1,B=E.indexOf(".")!==-1;if(B)g=E.split("."),E=g.shift(),f.member=g.shift();else if(S){const D=E.split("(");E=D.shift();for(let P=0;P<D.length;P++)D[P]=parseInt(D[P].replace(/\)/,""));f.indices=D}return f.id=b,f.sid=E,f.arraySyntax=S,f.memberSyntax=B,f.sampler=a(m.getAttribute("source")),f}function A(m){const f=[],x=m.channels,g=m.samplers,b=m.sources;for(const E in x)if(x.hasOwnProperty(E)){const S=x[E],B=g[S.sampler],D=B.inputs.INPUT,P=B.inputs.OUTPUT,U=b[D],I=b[P],j=_(S,U,I);G(j,f)}return f}function T(m){return w(J.animations[m],A)}function _(m,f,x){const g=J.nodes[m.id],b=Be(g.id),E=g.transforms[m.sid],S=g.matrix.clone().transpose();let B,D,P,U,I,j;const V={};switch(E){case"matrix":for(P=0,U=f.array.length;P<U;P++)if(B=f.array[P],D=P*x.stride,V[B]===void 0&&(V[B]={}),m.arraySyntax===!0){const ft=x.array[D],ht=m.indices[0]+4*m.indices[1];V[B][ht]=ft}else for(I=0,j=x.stride;I<j;I++)V[B][I]=x.array[D+I];break;case"translate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',E);break;case"rotate":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',E);break;case"scale":console.warn('THREE.ColladaLoader: Animation transform type "%s" not yet implemented.',E);break}const X=z(V,S);return{name:b.uuid,keyframes:X}}function z(m,f){const x=[];for(const b in m)x.push({time:parseFloat(b),value:m[b]});x.sort(g);for(let b=0;b<16;b++)Q(x,b,f.elements[b]);return x;function g(b,E){return b.time-E.time}}const F=new M,R=new M,L=new Ot;function G(m,f){const x=m.keyframes,g=m.name,b=[],E=[],S=[],B=[];for(let D=0,P=x.length;D<P;D++){const U=x[D],I=U.time,j=U.value;jt.fromArray(j).transpose(),jt.decompose(F,L,R),b.push(I),E.push(F.x,F.y,F.z),S.push(L.x,L.y,L.z,L.w),B.push(R.x,R.y,R.z)}return E.length>0&&f.push(new Le(g+".position",b,E)),S.length>0&&f.push(new Se(g+".quaternion",b,S)),B.length>0&&f.push(new Le(g+".scale",b,B)),f}function Q(m,f,x){let g,b=!0,E,S;for(E=0,S=m.length;E<S;E++)g=m[E],g.value[f]===void 0?g.value[f]=null:b=!1;if(b===!0)for(E=0,S=m.length;E<S;E++)g=m[E],g.value[f]=x;else xt(m,f)}function xt(m,f){let x,g;for(let b=0,E=m.length;b<E;b++){const S=m[b];if(S.value[f]===null){if(x=dt(m,b,f),g=Dt(m,b,f),x===null){S.value[f]=g.value[f];continue}if(g===null){S.value[f]=x.value[f];continue}Wt(S,x,g,f)}}}function dt(m,f,x){for(;f>=0;){const g=m[f];if(g.value[x]!==null)return g;f--}return null}function Dt(m,f,x){for(;f<m.length;){const g=m[f];if(g.value[x]!==null)return g;f++}return null}function Wt(m,f,x,g){if(x.time-f.time===0){m.value[g]=f.value[g];return}m.value[g]=(m.time-f.time)*(x.value[g]-f.value[g])/(x.time-f.time)+f.value[g]}function N(m){const f={name:m.getAttribute("id")||"default",start:parseFloat(m.getAttribute("start")||0),end:parseFloat(m.getAttribute("end")||0),animations:[]};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"instance_animation":f.animations.push(a(b.getAttribute("url")));break}}J.clips[m.getAttribute("id")]=f}function nt(m){const f=[],x=m.name,g=m.end-m.start||-1,b=m.animations;for(let E=0,S=b.length;E<S;E++){const B=T(b[E]);for(let D=0,P=B.length;D<P;D++)f.push(B[D])}return new Ss(x,g,f)}function it(m){return w(J.clips[m],nt)}function $(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"skin":f.id=a(b.getAttribute("source")),f.skin=lt(b);break;case"morph":f.id=a(b.getAttribute("source")),console.warn("THREE.ColladaLoader: Morph target animation not supported yet.");break}}J.controllers[m.getAttribute("id")]=f}function lt(m){const f={sources:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"bind_shape_matrix":f.bindShapeMatrix=s(b.textContent);break;case"source":const E=b.getAttribute("id");f.sources[E]=Nn(b);break;case"joints":f.joints=et(b);break;case"vertex_weights":f.vertexWeights=at(b);break}}return f}function et(m){const f={inputs:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"input":const E=b.getAttribute("semantic"),S=a(b.getAttribute("source"));f.inputs[E]=S;break}}return f}function at(m){const f={inputs:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"input":const E=b.getAttribute("semantic"),S=a(b.getAttribute("source")),B=parseInt(b.getAttribute("offset"));f.inputs[E]={id:S,offset:B};break;case"vcount":f.vcount=o(b.textContent);break;case"v":f.v=o(b.textContent);break}}return f}function Y(m){const f={id:m.id},x=J.geometries[f.id];return m.skin!==void 0&&(f.skin=Z(m.skin),x.sources.skinIndices=f.skin.indices,x.sources.skinWeights=f.skin.weights),f}function Z(m){const x={joints:[],indices:{array:[],stride:4},weights:{array:[],stride:4}},g=m.sources,b=m.vertexWeights,E=b.vcount,S=b.v,B=b.inputs.JOINT.offset,D=b.inputs.WEIGHT.offset,P=m.sources[m.joints.inputs.JOINT],U=m.sources[m.joints.inputs.INV_BIND_MATRIX],I=g[b.inputs.WEIGHT.id].array;let j=0,V,X,K;for(V=0,K=E.length;V<K;V++){const ht=E[V],st=[];for(X=0;X<ht;X++){const rt=S[j+B],oe=S[j+D],Vt=I[oe];st.push({index:rt,weight:Vt}),j+=2}for(st.sort(ft),X=0;X<4;X++){const rt=st[X];rt!==void 0?(x.indices.array.push(rt.index),x.weights.array.push(rt.weight)):(x.indices.array.push(0),x.weights.array.push(0))}}for(m.bindShapeMatrix?x.bindMatrix=new H().fromArray(m.bindShapeMatrix).transpose():x.bindMatrix=new H().identity(),V=0,K=P.array.length;V<K;V++){const ht=P.array[V],st=new H().fromArray(U.array,V*U.stride).transpose();x.joints.push({name:ht,boneInverse:st})}return x;function ft(ht,st){return st.weight-ht.weight}}function W(m){return w(J.controllers[m],Y)}function O(m){const f={init_from:i(m,"init_from")[0].textContent};J.images[m.getAttribute("id")]=f}function q(m){return m.build!==void 0?m.build:m.init_from}function ct(m){const f=J.images[m];return f!==void 0?w(f,q):(console.warn("THREE.ColladaLoader: Couldn't find image with ID:",m),null)}function Nt(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"profile_COMMON":f.profile=ge(b);break}}J.effects[m.getAttribute("id")]=f}function ge(m){const f={surfaces:{},samplers:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"newparam":Ni(b,f);break;case"technique":f.technique=ua(b);break;case"extra":f.extra=Xs(b);break}}return f}function Ni(m,f){const x=m.getAttribute("sid");for(let g=0,b=m.childNodes.length;g<b;g++){const E=m.childNodes[g];if(E.nodeType===1)switch(E.nodeName){case"surface":f.surfaces[x]=Pi(E);break;case"sampler2D":f.samplers[x]=Li(E);break}}}function Pi(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"init_from":f.init_from=b.textContent;break}}return f}function Li(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"source":f.source=b.textContent;break}}return f}function ua(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"constant":case"lambert":case"blinn":case"phong":f.type=b.nodeName,f.parameters=da(b);break;case"extra":f.extra=Xs(b);break}}return f}function da(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"emission":case"diffuse":case"specular":case"bump":case"ambient":case"shininess":case"transparency":f[b.nodeName]=Ks(b);break;case"transparent":f[b.nodeName]={opaque:b.hasAttribute("opaque")?b.getAttribute("opaque"):"A_ONE",data:Ks(b)};break}}return f}function Ks(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"color":f[b.nodeName]=s(b.textContent);break;case"float":f[b.nodeName]=parseFloat(b.textContent);break;case"texture":f[b.nodeName]={id:b.getAttribute("texture"),extra:qs(b)};break}}return f}function qs(m){const f={technique:{}};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"extra":pa(b,f);break}}return f}function pa(m,f){for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"technique":fa(b,f);break}}}function fa(m,f){for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"repeatU":case"repeatV":case"offsetU":case"offsetV":f.technique[b.nodeName]=parseFloat(b.textContent);break;case"wrapU":case"wrapV":b.textContent.toUpperCase()==="TRUE"?f.technique[b.nodeName]=1:b.textContent.toUpperCase()==="FALSE"?f.technique[b.nodeName]=0:f.technique[b.nodeName]=parseInt(b.textContent);break;case"bump":f[b.nodeName]=Zs(b);break}}}function Xs(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"technique":f.technique=ma(b);break}}return f}function ma(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"double_sided":f[b.nodeName]=parseInt(b.textContent);break;case"bump":f[b.nodeName]=Zs(b);break}}return f}function Zs(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"texture":f[b.nodeName]={id:b.getAttribute("texture"),texcoord:b.getAttribute("texcoord"),extra:qs(b)};break}}return f}function Js(m){return m}function ya(m){return w(J.effects[m],Js)}function ga(m){const f={name:m.getAttribute("name")};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"instance_effect":f.url=a(b.getAttribute("url"));break}}J.materials[m.getAttribute("id")]=f}function xa(m){let f,x=m.slice((m.lastIndexOf(".")-1>>>0)+2);switch(x=x.toLowerCase(),x){case"tga":f=On;break;default:f=dr}return f}function Ys(m){const f=ya(m.url),x=f.profile.technique;let g;switch(x.type){case"phong":case"blinn":g=new Ei;break;case"lambert":g=new Wo;break;default:g=new Es;break}g.name=m.name||"";function b(D,P=null){const U=f.profile.samplers[D.id];let I=null;if(U!==void 0){const j=f.profile.surfaces[U.source];I=ct(j.init_from)}else console.warn("THREE.ColladaLoader: Undefined sampler. Access image directly (see #12530)."),I=ct(D.id);if(I!==null){const j=xa(I);if(j!==void 0){const V=j.load(I),X=D.extra;if(X!==void 0&&X.technique!==void 0&&h(X.technique)===!1){const K=X.technique;V.wrapS=K.wrapU?_e:ie,V.wrapT=K.wrapV?_e:ie,V.offset.set(K.offsetU||0,K.offsetV||0),V.repeat.set(K.repeatU||1,K.repeatV||1)}else V.wrapS=_e,V.wrapT=_e;return P!==null&&(V.colorSpace=P),V}else return console.warn("THREE.ColladaLoader: Loader for texture %s not found.",I),null}else return console.warn("THREE.ColladaLoader: Couldn't create texture with ID:",D.id),null}const E=x.parameters;for(const D in E){const P=E[D];switch(D){case"diffuse":P.color&&g.color.fromArray(P.color),P.texture&&(g.map=b(P.texture,Bt));break;case"specular":P.color&&g.specular&&g.specular.fromArray(P.color),P.texture&&(g.specularMap=b(P.texture));break;case"bump":P.texture&&(g.normalMap=b(P.texture));break;case"ambient":P.texture&&(g.lightMap=b(P.texture,Bt));break;case"shininess":P.float&&g.shininess&&(g.shininess=P.float);break;case"emission":P.color&&g.emissive&&g.emissive.fromArray(P.color),P.texture&&(g.emissiveMap=b(P.texture,Bt));break}}g.color.convertSRGBToLinear(),g.specular&&g.specular.convertSRGBToLinear(),g.emissive&&g.emissive.convertSRGBToLinear();let S=E.transparent,B=E.transparency;if(B===void 0&&S&&(B={float:1}),S===void 0&&B&&(S={opaque:"A_ONE",data:{color:[1,1,1,1]}}),S&&B)if(S.data.texture)g.transparent=!0;else{const D=S.data.color;switch(S.opaque){case"A_ONE":g.opacity=D[3]*B.float;break;case"RGB_ZERO":g.opacity=1-D[0]*B.float;break;case"A_ZERO":g.opacity=1-D[3]*B.float;break;case"RGB_ONE":g.opacity=D[0]*B.float;break;default:console.warn('THREE.ColladaLoader: Invalid opaque type "%s" of transparent tag.',S.opaque)}g.opacity<1&&(g.transparent=!0)}if(x.extra!==void 0&&x.extra.technique!==void 0){const D=x.extra.technique;for(const P in D){const U=D[P];switch(P){case"double_sided":g.side=U===1?Ic:xn;break;case"bump":g.normalMap=b(U.texture),g.normalScale=new pt(1,1);break}}}return g}function ba(m){return w(J.materials[m],Ys)}function wa(m){const f={name:m.getAttribute("name")};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"optics":f.optics=va(b);break}}J.cameras[m.getAttribute("id")]=f}function va(m){for(let f=0;f<m.childNodes.length;f++){const x=m.childNodes[f];switch(x.nodeName){case"technique_common":return Ma(x)}}return{}}function Ma(m){const f={};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];switch(g.nodeName){case"perspective":case"orthographic":f.technique=g.nodeName,f.parameters=ka(g);break}}return f}function ka(m){const f={};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];switch(g.nodeName){case"xfov":case"yfov":case"xmag":case"ymag":case"znear":case"zfar":case"aspect_ratio":f[g.nodeName]=parseFloat(g.textContent);break}}return f}function $s(m){let f;switch(m.optics.technique){case"perspective":f=new Ci(m.optics.parameters.yfov,m.optics.parameters.aspect_ratio,m.optics.parameters.znear,m.optics.parameters.zfar);break;case"orthographic":let x=m.optics.parameters.ymag,g=m.optics.parameters.xmag;const b=m.optics.parameters.aspect_ratio;g=g===void 0?x*b:g,x=x===void 0?g/b:x,g*=.5,x*=.5,f=new Bs(-g,g,x,-x,m.optics.parameters.znear,m.optics.parameters.zfar);break;default:f=new Ci;break}return f.name=m.name||"",f}function Aa(m){const f=J.cameras[m];return f!==void 0?w(f,$s):(console.warn("THREE.ColladaLoader: Couldn't find camera with ID:",m),null)}function Ea(m){let f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"technique_common":f=Ta(b);break}}J.lights[m.getAttribute("id")]=f}function Ta(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"directional":case"point":case"spot":case"ambient":f.technique=b.nodeName,f.parameters=_a(b)}}return f}function _a(m){const f={};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"color":const E=s(b.textContent);f.color=new yt().fromArray(E).convertSRGBToLinear();break;case"falloff_angle":f.falloffAngle=parseFloat(b.textContent);break;case"quadratic_attenuation":const S=parseFloat(b.textContent);f.distance=S?Math.sqrt(1/S):0;break}}return f}function Qs(m){let f;switch(m.technique){case"directional":f=new Jo;break;case"point":f=new Cs;break;case"spot":f=new Zo;break;case"ambient":f=new Yo;break}return m.parameters.color&&f.color.copy(m.parameters.color),m.parameters.distance&&(f.distance=m.parameters.distance),f}function Sa(m){const f=J.lights[m];return f!==void 0?w(f,Qs):(console.warn("THREE.ColladaLoader: Couldn't find light with ID:",m),null)}function Ca(m){const f={name:m.getAttribute("name"),sources:{},vertices:{},primitives:[]},x=i(m,"mesh")[0];if(x!==void 0){for(let g=0;g<x.childNodes.length;g++){const b=x.childNodes[g];if(b.nodeType!==1)continue;const E=b.getAttribute("id");switch(b.nodeName){case"source":f.sources[E]=Nn(b);break;case"vertices":f.vertices=Fa(b);break;case"polygons":console.warn("THREE.ColladaLoader: Unsupported primitive type: ",b.nodeName);break;case"lines":case"linestrips":case"polylist":case"triangles":f.primitives.push(Ia(b));break;default:console.log(b)}}J.geometries[m.getAttribute("id")]=f}}function Nn(m){const f={array:[],stride:3};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"float_array":f.array=s(g.textContent);break;case"Name_array":f.array=n(g.textContent);break;case"technique_common":const b=i(g,"accessor")[0];b!==void 0&&(f.stride=parseInt(b.getAttribute("stride")));break}}return f}function Fa(m){const f={};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];g.nodeType===1&&(f[g.getAttribute("semantic")]=a(g.getAttribute("source")))}return f}function Ia(m){const f={type:m.nodeName,material:m.getAttribute("material"),count:parseInt(m.getAttribute("count")),inputs:{},stride:0,hasUV:!1};for(let x=0,g=m.childNodes.length;x<g;x++){const b=m.childNodes[x];if(b.nodeType===1)switch(b.nodeName){case"input":const E=a(b.getAttribute("source")),S=b.getAttribute("semantic"),B=parseInt(b.getAttribute("offset")),D=parseInt(b.getAttribute("set")),P=D>0?S+D:S;f.inputs[P]={id:E,offset:B},f.stride=Math.max(f.stride,B+1),S==="TEXCOORD"&&(f.hasUV=!0);break;case"vcount":f.vcount=o(b.textContent);break;case"p":f.p=o(b.textContent);break}}return f}function za(m){const f={};for(let x=0;x<m.length;x++){const g=m[x];f[g.type]===void 0&&(f[g.type]=[]),f[g.type].push(g)}return f}function Ra(m){let f=0;for(let x=0,g=m.length;x<g;x++)m[x].hasUV===!0&&f++;f>0&&f<m.length&&(m.uvsNeedsFix=!0)}function tr(m){const f={},x=m.sources,g=m.vertices,b=m.primitives;if(b.length===0)return{};const E=za(b);for(const S in E){const B=E[S];Ra(B),f[S]=Da(B,x,g)}return f}function Da(m,f,x){const g={},b={array:[],stride:0},E={array:[],stride:0},S={array:[],stride:0},B={array:[],stride:0},D={array:[],stride:0},P={array:[],stride:4},U={array:[],stride:4},I=new me,j=[];let V=0;for(let X=0;X<m.length;X++){const K=m[X],ft=K.inputs;let ht=0;switch(K.type){case"lines":case"linestrips":ht=K.count*2;break;case"triangles":ht=K.count*3;break;case"polylist":for(let st=0;st<K.count;st++){const rt=K.vcount[st];switch(rt){case 3:ht+=3;break;case 4:ht+=6;break;default:ht+=(rt-2)*3;break}}break;default:console.warn("THREE.ColladaLoader: Unknow primitive type:",K.type)}I.addGroup(V,ht,X),V+=ht,K.material&&j.push(K.material);for(const st in ft){const rt=ft[st];switch(st){case"VERTEX":for(const oe in x){const Vt=x[oe];switch(oe){case"POSITION":const Ve=b.array.length;if(Xt(K,f[Vt],rt.offset,b.array),b.stride=f[Vt].stride,f.skinWeights&&f.skinIndices&&(Xt(K,f.skinIndices,rt.offset,P.array),Xt(K,f.skinWeights,rt.offset,U.array)),K.hasUV===!1&&m.uvsNeedsFix===!0){const hc=(b.array.length-Ve)/b.stride;for(let fr=0;fr<hc;fr++)S.array.push(0,0)}break;case"NORMAL":Xt(K,f[Vt],rt.offset,E.array),E.stride=f[Vt].stride;break;case"COLOR":Xt(K,f[Vt],rt.offset,D.array),D.stride=f[Vt].stride;break;case"TEXCOORD":Xt(K,f[Vt],rt.offset,S.array),S.stride=f[Vt].stride;break;case"TEXCOORD1":Xt(K,f[Vt],rt.offset,B.array),S.stride=f[Vt].stride;break;default:console.warn('THREE.ColladaLoader: Semantic "%s" not handled in geometry build process.',oe)}}break;case"NORMAL":Xt(K,f[rt.id],rt.offset,E.array),E.stride=f[rt.id].stride;break;case"COLOR":Xt(K,f[rt.id],rt.offset,D.array,!0),D.stride=f[rt.id].stride;break;case"TEXCOORD":Xt(K,f[rt.id],rt.offset,S.array),S.stride=f[rt.id].stride;break;case"TEXCOORD1":Xt(K,f[rt.id],rt.offset,B.array),B.stride=f[rt.id].stride;break}}}return b.array.length>0&&I.setAttribute("position",new zt(b.array,b.stride)),E.array.length>0&&I.setAttribute("normal",new zt(E.array,E.stride)),D.array.length>0&&I.setAttribute("color",new zt(D.array,D.stride)),S.array.length>0&&I.setAttribute("uv",new zt(S.array,S.stride)),B.array.length>0&&I.setAttribute("uv1",new zt(B.array,B.stride)),P.array.length>0&&I.setAttribute("skinIndex",new zt(P.array,P.stride)),U.array.length>0&&I.setAttribute("skinWeight",new zt(U.array,U.stride)),g.data=I,g.type=m[0].type,g.materialKeys=j,g}function Xt(m,f,x,g,b=!1){const E=m.p,S=m.stride,B=m.vcount;function D(I){let j=E[I+x]*U;const V=j+U;for(;j<V;j++)g.push(P[j]);if(b){const X=g.length-U-1;Oi.setRGB(g[X+0],g[X+1],g[X+2]).convertSRGBToLinear(),g[X+0]=Oi.r,g[X+1]=Oi.g,g[X+2]=Oi.b}}const P=f.array,U=f.stride;if(m.vcount!==void 0){let I=0;for(let j=0,V=B.length;j<V;j++){const X=B[j];if(X===4){const K=I+S*0,ft=I+S*1,ht=I+S*2,st=I+S*3;D(K),D(ft),D(st),D(ft),D(ht),D(st)}else if(X===3){const K=I+S*0,ft=I+S*1,ht=I+S*2;D(K),D(ft),D(ht)}else if(X>4)for(let K=1,ft=X-2;K<=ft;K++){const ht=I+S*0,st=I+S*K,rt=I+S*(K+1);D(ht),D(st),D(rt)}I+=S*X}}else for(let I=0,j=E.length;I<j;I+=S)D(I)}function er(m){return w(J.geometries[m],tr)}function Na(m){const f={name:m.getAttribute("name")||"",joints:{},links:[]};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"technique_common":Oa(g,f);break}}J.kinematicsModels[m.getAttribute("id")]=f}function Pa(m){return m.build!==void 0?m.build:m}function La(m){return w(J.kinematicsModels[m],Pa)}function Oa(m,f){for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"joint":f.joints[g.getAttribute("sid")]=Ba(g);break;case"link":f.links.push(ir(g));break}}}function Ba(m){let f;for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"prismatic":case"revolute":f=Va(g);break}}return f}function Va(m){const f={sid:m.getAttribute("sid"),name:m.getAttribute("name")||"",axis:new M,limits:{min:0,max:0},type:m.nodeName,static:!1,zeroPosition:0,middlePosition:0};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"axis":const b=s(g.textContent);f.axis.fromArray(b);break;case"limits":const E=g.getElementsByTagName("max")[0],S=g.getElementsByTagName("min")[0];f.limits.max=parseFloat(E.textContent),f.limits.min=parseFloat(S.textContent);break}}return f.limits.min>=f.limits.max&&(f.static=!0),f.middlePosition=(f.limits.min+f.limits.max)/2,f}function ir(m){const f={sid:m.getAttribute("sid"),name:m.getAttribute("name")||"",attachments:[],transforms:[]};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"attachment_full":f.attachments.push(ja(g));break;case"matrix":case"translate":case"rotate":f.transforms.push(nr(g));break}}return f}function ja(m){const f={joint:m.getAttribute("joint").split("/").pop(),transforms:[],links:[]};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"link":f.links.push(ir(g));break;case"matrix":case"translate":case"rotate":f.transforms.push(nr(g));break}}return f}function nr(m){const f={type:m.nodeName},x=s(m.textContent);switch(f.type){case"matrix":f.obj=new H,f.obj.fromArray(x).transpose();break;case"translate":f.obj=new M,f.obj.fromArray(x);break;case"rotate":f.obj=new M,f.obj.fromArray(x),f.angle=kt.degToRad(x[3]);break}return f}function Ua(m){const f={name:m.getAttribute("name")||"",rigidBodies:{}};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"rigid_body":f.rigidBodies[g.getAttribute("name")]={},Ha(g,f.rigidBodies[g.getAttribute("name")]);break}}J.physicsModels[m.getAttribute("id")]=f}function Ha(m,f){for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"technique_common":Ga(g,f);break}}}function Ga(m,f){for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"inertia":f.inertia=s(g.textContent);break;case"mass":f.mass=s(g.textContent)[0];break}}}function Wa(m){const f={bindJointAxis:[]};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"bind_joint_axis":f.bindJointAxis.push(Ka(g));break}}J.kinematicsScenes[a(m.getAttribute("url"))]=f}function Ka(m){const f={target:m.getAttribute("target").split("/").pop()};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType===1)switch(g.nodeName){case"axis":const b=g.getElementsByTagName("param")[0];f.axis=b.textContent;const E=f.axis.split("inst_").pop().split("axis")[0];f.jointIndex=E.substring(0,E.length-1);break}}return f}function qa(m){return m.build!==void 0?m.build:m}function Xa(m){return w(J.kinematicsScenes[m],qa)}function Za(){const m=Object.keys(J.kinematicsModels)[0],f=Object.keys(J.kinematicsScenes)[0],x=Object.keys(J.visualScenes)[0];if(m===void 0||f===void 0)return;const g=La(m),b=Xa(f),E=hr(x),S=b.bindJointAxis,B={};for(let U=0,I=S.length;U<I;U++){const j=S[U],V=At.querySelector('[sid="'+j.target+'"]');if(V){const X=V.parentElement;D(j.jointIndex,X)}}function D(U,I){const j=I.getAttribute("name"),V=g.joints[U];E.traverse(function(X){X.name===j&&(B[U]={object:X,transforms:Ja(I),joint:V,position:V.zeroPosition})})}const P=new H;pr={joints:g&&g.joints,getJointValue:function(U){const I=B[U];if(I)return I.position;console.warn("THREE.ColladaLoader: Joint "+U+" doesn't exist.")},setJointValue:function(U,I){const j=B[U];if(j){const V=j.joint;if(I>V.limits.max||I<V.limits.min)console.warn("THREE.ColladaLoader: Joint "+U+" value "+I+" outside of limits (min: "+V.limits.min+", max: "+V.limits.max+").");else if(V.static)console.warn("THREE.ColladaLoader: Joint "+U+" is static.");else{const X=j.object,K=V.axis,ft=j.transforms;jt.identity();for(let ht=0;ht<ft.length;ht++){const st=ft[ht];if(st.sid&&st.sid.indexOf(U)!==-1)switch(V.type){case"revolute":jt.multiply(P.makeRotationAxis(K,kt.degToRad(I)));break;case"prismatic":jt.multiply(P.makeTranslation(K.x*I,K.y*I,K.z*I));break;default:console.warn("THREE.ColladaLoader: Unknown joint type: "+V.type);break}else switch(st.type){case"matrix":jt.multiply(st.obj);break;case"translate":jt.multiply(P.makeTranslation(st.obj.x,st.obj.y,st.obj.z));break;case"scale":jt.scale(st.obj);break;case"rotate":jt.multiply(P.makeRotationAxis(st.obj,st.angle));break}}X.matrix.copy(jt),X.matrix.decompose(X.position,X.quaternion,X.scale),B[U].position=I}}else console.log("THREE.ColladaLoader: "+U+" does not exist.")}}}function Ja(m){const f=[],x=At.querySelector('[id="'+m.id+'"]');for(let g=0;g<x.childNodes.length;g++){const b=x.childNodes[g];if(b.nodeType!==1)continue;let E,S;switch(b.nodeName){case"matrix":E=s(b.textContent);const B=new H().fromArray(E).transpose();f.push({sid:b.getAttribute("sid"),type:b.nodeName,obj:B});break;case"translate":case"scale":E=s(b.textContent),S=new M().fromArray(E),f.push({sid:b.getAttribute("sid"),type:b.nodeName,obj:S});break;case"rotate":E=s(b.textContent),S=new M().fromArray(E);const D=kt.degToRad(E[3]);f.push({sid:b.getAttribute("sid"),type:b.nodeName,obj:S,angle:D});break}}return f}function Ya(m){const f=m.getElementsByTagName("node");for(let x=0;x<f.length;x++){const g=f[x];g.hasAttribute("id")===!1&&g.setAttribute("id",c())}}const jt=new H,Oe=new M;function Pn(m){const f={name:m.getAttribute("name")||"",type:m.getAttribute("type"),id:m.getAttribute("id"),sid:m.getAttribute("sid"),matrix:new H,nodes:[],instanceCameras:[],instanceControllers:[],instanceLights:[],instanceGeometries:[],instanceNodes:[],transforms:{}};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];if(g.nodeType!==1)continue;let b;switch(g.nodeName){case"node":f.nodes.push(g.getAttribute("id")),Pn(g);break;case"instance_camera":f.instanceCameras.push(a(g.getAttribute("url")));break;case"instance_controller":f.instanceControllers.push(sr(g));break;case"instance_light":f.instanceLights.push(a(g.getAttribute("url")));break;case"instance_geometry":f.instanceGeometries.push(sr(g));break;case"instance_node":f.instanceNodes.push(a(g.getAttribute("url")));break;case"matrix":b=s(g.textContent),f.matrix.multiply(jt.fromArray(b).transpose()),f.transforms[g.getAttribute("sid")]=g.nodeName;break;case"translate":b=s(g.textContent),Oe.fromArray(b),f.matrix.multiply(jt.makeTranslation(Oe.x,Oe.y,Oe.z)),f.transforms[g.getAttribute("sid")]=g.nodeName;break;case"rotate":b=s(g.textContent);const E=kt.degToRad(b[3]);f.matrix.multiply(jt.makeRotationAxis(Oe.fromArray(b),E)),f.transforms[g.getAttribute("sid")]=g.nodeName;break;case"scale":b=s(g.textContent),f.matrix.scale(Oe.fromArray(b)),f.transforms[g.getAttribute("sid")]=g.nodeName;break;case"extra":break;default:console.log(g)}}return ar(f.id)?console.warn("THREE.ColladaLoader: There is already a node with ID %s. Exclude current node from further processing.",f.id):J.nodes[f.id]=f,f}function sr(m){const f={id:a(m.getAttribute("url")),materials:{},skeletons:[]};for(let x=0;x<m.childNodes.length;x++){const g=m.childNodes[x];switch(g.nodeName){case"bind_material":const b=g.getElementsByTagName("instance_material");for(let E=0;E<b.length;E++){const S=b[E],B=S.getAttribute("symbol"),D=S.getAttribute("target");f.materials[B]=a(D)}break;case"skeleton":f.skeletons.push(a(g.textContent));break}}return f}function $a(m,f){const x=[],g=[];let b,E,S;for(b=0;b<m.length;b++){const P=m[b];let U;if(ar(P))U=Be(P),rr(U,f,x);else if(nc(P)){const j=J.visualScenes[P].children;for(let V=0;V<j.length;V++){const X=j[V];if(X.type==="JOINT"){const K=Be(X.id);rr(K,f,x)}}}else console.error("THREE.ColladaLoader: Unable to find root bone of skeleton with ID:",P)}for(b=0;b<f.length;b++)for(E=0;E<x.length;E++)if(S=x[E],S.bone.name===f[b].name){g[b]=S,S.processed=!0;break}for(b=0;b<x.length;b++)S=x[b],S.processed===!1&&(g.push(S),S.processed=!0);const B=[],D=[];for(b=0;b<g.length;b++)S=g[b],B.push(S.bone),D.push(S.boneInverse);return new In(B,D)}function rr(m,f,x){m.traverse(function(g){if(g.isBone===!0){let b;for(let E=0;E<f.length;E++){const S=f[E];if(S.name===g.name){b=S.boneInverse;break}}b===void 0&&(b=new H),x.push({bone:g,boneInverse:b,processed:!1})}})}function Qa(m){const f=[],x=m.matrix,g=m.nodes,b=m.type,E=m.instanceCameras,S=m.instanceControllers,B=m.instanceLights,D=m.instanceGeometries,P=m.instanceNodes;for(let I=0,j=g.length;I<j;I++)f.push(Be(g[I]));for(let I=0,j=E.length;I<j;I++){const V=Aa(E[I]);V!==null&&f.push(V.clone())}for(let I=0,j=S.length;I<j;I++){const V=S[I],X=W(V.id),K=er(X.id),ft=or(K,V.materials),ht=V.skeletons,st=X.skin.joints,rt=$a(ht,st);for(let oe=0,Vt=ft.length;oe<Vt;oe++){const Ve=ft[oe];Ve.isSkinnedMesh&&(Ve.bind(rt,X.skin.bindMatrix),Ve.normalizeSkinWeights()),f.push(Ve)}}for(let I=0,j=B.length;I<j;I++){const V=Sa(B[I]);V!==null&&f.push(V.clone())}for(let I=0,j=D.length;I<j;I++){const V=D[I],X=er(V.id),K=or(X,V.materials);for(let ft=0,ht=K.length;ft<ht;ft++)f.push(K[ft])}for(let I=0,j=P.length;I<j;I++)f.push(Be(P[I]).clone());let U;if(g.length===0&&f.length===1)U=f[0];else{U=b==="JOINT"?new kn:new Mn;for(let I=0;I<f.length;I++)U.add(f[I])}return U.name=b==="JOINT"?m.sid:m.name,U.matrix.copy(x),U.matrix.decompose(U.position,U.quaternion,U.scale),U}const tc=new Es({name:ne.DEFAULT_MATERIAL_NAME,color:16711935});function ec(m,f){const x=[];for(let g=0,b=m.length;g<b;g++){const E=f[m[g]];E===void 0?(console.warn("THREE.ColladaLoader: Material with key %s not found. Apply fallback material.",m[g]),x.push(tc)):x.push(ba(E))}return x}function or(m,f){const x=[];for(const g in m){const b=m[g],E=ec(b.materialKeys,f);if(E.length===0&&(g==="lines"||g==="linestrips"?E.push(new An):E.push(new Ei)),g==="lines"||g==="linestrips")for(let P=0,U=E.length;P<U;P++){const I=E[P];if(I.isMeshPhongMaterial===!0||I.isMeshLambertMaterial===!0){const j=new An;j.color.copy(I.color),j.opacity=I.opacity,j.transparent=I.transparent,E[P]=j}}const S=b.data.attributes.skinIndex!==void 0,B=E.length===1?E[0]:E;let D;switch(g){case"lines":D=new Ch(b.data,B);break;case"linestrips":D=new Vs(b.data,B);break;case"triangles":case"polylist":S?D=new Vo(b.data,B):D=new Os(b.data,B);break}x.push(D)}return x}function ar(m){return J.nodes[m]!==void 0}function Be(m){return w(J.nodes[m],Qa)}function ic(m){const f={name:m.getAttribute("name"),children:[]};Ya(m);const x=i(m,"node");for(let g=0;g<x.length;g++)f.children.push(Pn(x[g]));J.visualScenes[m.getAttribute("id")]=f}function cr(m){const f=new Mn;f.name=m.name;const x=m.children;for(let g=0;g<x.length;g++){const b=x[g];f.add(Be(b.id))}return f}function nc(m){return J.visualScenes[m]!==void 0}function hr(m){return w(J.visualScenes[m],cr)}function sc(m){const f=i(m,"instance_visual_scene")[0];return hr(a(f.getAttribute("url")))}function rc(){const m=J.clips;if(h(m)===!0){if(h(J.animations)===!1){const f=[];for(const x in J.animations){const g=T(x);for(let b=0,E=g.length;b<E;b++)f.push(g[b])}Bi.push(new Ss("default",-1,f))}}else for(const f in m)Bi.push(it(f))}function oc(m){let f="";const x=[m];for(;x.length;){const g=x.shift();g.nodeType===Node.TEXT_NODE?f+=g.textContent:(f+=`
`,x.push.apply(x,g.childNodes))}return f.trim()}if(t.length===0)return{scene:new Th};const lr=new DOMParser().parseFromString(t,"application/xml"),At=i(lr,"COLLADA")[0],Ln=lr.getElementsByTagName("parsererror")[0];if(Ln!==void 0){const m=i(Ln,"div")[0];let f;return m?f=m.textContent:f=oc(Ln),console.error(`THREE.ColladaLoader: Failed to parse collada file.
`,f),null}const ac=At.getAttribute("version");console.debug("THREE.ColladaLoader: File version",ac);const ur=l(i(At,"asset")[0]),dr=new Xo(this.manager);dr.setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);let On;ko&&(On=new ko(this.manager),On.setPath(this.resourcePath||e));const Oi=new yt,Bi=[];let pr={},cc=0;const J={animations:{},clips:{},controllers:{},images:{},effects:{},materials:{},cameras:{},lights:{},geometries:{},nodes:{},visualScenes:{},kinematicsModels:{},physicsModels:{},kinematicsScenes:{}};p(At,"library_animations","animation",v),p(At,"library_animation_clips","animation_clip",N),p(At,"library_controllers","controller",$),p(At,"library_images","image",O),p(At,"library_effects","effect",Nt),p(At,"library_materials","material",ga),p(At,"library_cameras","camera",wa),p(At,"library_lights","light",Ea),p(At,"library_geometries","geometry",Ca),p(At,"library_nodes","node",Pn),p(At,"library_visual_scenes","visual_scene",ic),p(At,"library_kinematics_models","kinematics_model",Na),p(At,"library_physics_models","physics_model",Ua),p(At,"scene","instance_kinematics_scene",Wa),y(J.animations,A),y(J.clips,nt),y(J.controllers,Y),y(J.images,q),y(J.effects,Js),y(J.materials,Ys),y(J.cameras,$s),y(J.lights,Qs),y(J.geometries,tr),y(J.visualScenes,cr),rc(),Za();const Vi=sc(i(At,"scene")[0]);return Vi.animations=Bi,ur.upAxis==="Z_UP"&&(console.warn("THREE.ColladaLoader: You are loading an asset with a Z-UP coordinate system. The loader just rotates the asset to transform it into Y-UP. The vertex data are not converted, see #24289."),Vi.rotation.set(-Math.PI/2,0,0)),Vi.scale.multiplyScalar(ur.unit),{get animations(){return console.warn("THREE.ColladaLoader: Please access animations over scene.animations now."),Bi},kinematics:pr,library:J,scene:Vi}}}THREE.ColladaLoader=bl;AFRAME.registerComponent("collada-model-legacy",{schema:{type:"asset"},init:function(){this.model=null,this.loader=new THREE.ColladaLoader},update:function(){var r=this,t=this.el,e=this.data,i=this.el.sceneEl.systems.renderer;e&&(this.remove(),this.loader.load(e,function(n){r.model=n.scene,r.model.traverse(function(s){if(s.isMesh){var o=s.material;o.color&&i.applyColorCorrection(o.color),o.map&&i.applyColorCorrection(o.map),o.emissive&&i.applyColorCorrection(o.emissive),o.emissiveMap&&i.applyColorCorrection(o.emissiveMap)}}),t.setObject3D("mesh",r.model),t.emit("model-loaded",{format:"collada",model:r.model})}))},remove:function(){this.model&&this.el.removeObject3D("mesh")}});/*!
fflate - fast JavaScript compression/decompression
<https://101arrowz.github.io/fflate>
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
version 0.8.2
*/var qt=Uint8Array,oi=Uint16Array,wl=Int32Array,Qo=new qt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),ta=new qt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),vl=new qt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ea=function(r,t){for(var e=new oi(31),i=0;i<31;++i)e[i]=t+=1<<r[i-1];for(var n=new wl(e[30]),i=1;i<30;++i)for(var s=e[i];s<e[i+1];++s)n[s]=s-e[i]<<5|i;return{b:e,r:n}},ia=ea(Qo,2),na=ia.b,Ml=ia.r;na[28]=258,Ml[258]=28;var kl=ea(ta,0),Al=kl.b,Fs=new oi(32768);for(var ut=0;ut<32768;++ut){var Ee=(ut&43690)>>1|(ut&21845)<<1;Ee=(Ee&52428)>>2|(Ee&13107)<<2,Ee=(Ee&61680)>>4|(Ee&3855)<<4,Fs[ut]=((Ee&65280)>>8|(Ee&255)<<8)>>1}var Ti=function(r,t,e){for(var i=r.length,n=0,s=new oi(t);n<i;++n)r[n]&&++s[r[n]-1];var o=new oi(t);for(n=1;n<t;++n)o[n]=o[n-1]+s[n-1]<<1;var a;if(e){a=new oi(1<<t);var c=15-t;for(n=0;n<i;++n)if(r[n])for(var h=n<<4|r[n],l=t-r[n],u=o[r[n]-1]++<<l,d=u|(1<<l)-1;u<=d;++u)a[Fs[u]>>c]=h}else for(a=new oi(i),n=0;n<i;++n)r[n]&&(a[n]=Fs[o[r[n]-1]++]>>15-r[n]);return a},Di=new qt(288);for(var ut=0;ut<144;++ut)Di[ut]=8;for(var ut=144;ut<256;++ut)Di[ut]=9;for(var ut=256;ut<280;++ut)Di[ut]=7;for(var ut=280;ut<288;++ut)Di[ut]=8;var sa=new qt(32);for(var ut=0;ut<32;++ut)sa[ut]=5;var El=Ti(Di,9,1),Tl=Ti(sa,5,1),ms=function(r){for(var t=r[0],e=1;e<r.length;++e)r[e]>t&&(t=r[e]);return t},Qt=function(r,t,e){var i=t/8|0;return(r[i]|r[i+1]<<8)>>(t&7)&e},ys=function(r,t){var e=t/8|0;return(r[e]|r[e+1]<<8|r[e+2]<<16)>>(t&7)},_l=function(r){return(r+7)/8|0},Sl=function(r,t,e){return(e==null||e>r.length)&&(e=r.length),new qt(r.subarray(t,e))},Cl=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],te=function(r,t,e){var i=new Error(t||Cl[r]);if(i.code=r,Error.captureStackTrace&&Error.captureStackTrace(i,te),!e)throw i;return i},Fl=function(r,t,e,i){var n=r.length,s=0;if(!n||t.f&&!t.l)return e||new qt(0);var o=!e,a=o||t.i!=2,c=t.i;o&&(e=new qt(n*3));var h=function(Ni){var Pi=e.length;if(Ni>Pi){var Li=new qt(Math.max(Pi*2,Ni));Li.set(e),e=Li}},l=t.f||0,u=t.p||0,d=t.b||0,p=t.l,y=t.d,w=t.m,v=t.n,k=n*8;do{if(!p){l=Qt(r,u,1);var C=Qt(r,u+1,3);if(u+=3,C)if(C==1)p=El,y=Tl,w=9,v=5;else if(C==2){var z=Qt(r,u,31)+257,F=Qt(r,u+10,15)+4,R=z+Qt(r,u+5,31)+1;u+=14;for(var L=new qt(R),G=new qt(19),Q=0;Q<F;++Q)G[vl[Q]]=Qt(r,u+Q*3,7);u+=F*3;for(var xt=ms(G),dt=(1<<xt)-1,Dt=Ti(G,xt,1),Q=0;Q<R;){var Wt=Dt[Qt(r,u,dt)];u+=Wt&15;var A=Wt>>4;if(A<16)L[Q++]=A;else{var N=0,nt=0;for(A==16?(nt=3+Qt(r,u,3),u+=2,N=L[Q-1]):A==17?(nt=3+Qt(r,u,7),u+=3):A==18&&(nt=11+Qt(r,u,127),u+=7);nt--;)L[Q++]=N}}var it=L.subarray(0,z),$=L.subarray(z);w=ms(it),v=ms($),p=Ti(it,w,1),y=Ti($,v,1)}else te(1);else{var A=_l(u)+4,T=r[A-4]|r[A-3]<<8,_=A+T;if(_>n){c&&te(0);break}a&&h(d+T),e.set(r.subarray(A,_),d),t.b=d+=T,t.p=u=_*8,t.f=l;continue}if(u>k){c&&te(0);break}}a&&h(d+131072);for(var lt=(1<<w)-1,et=(1<<v)-1,at=u;;at=u){var N=p[ys(r,u)&lt],Y=N>>4;if(u+=N&15,u>k){c&&te(0);break}if(N||te(2),Y<256)e[d++]=Y;else if(Y==256){at=u,p=null;break}else{var Z=Y-254;if(Y>264){var Q=Y-257,W=Qo[Q];Z=Qt(r,u,(1<<W)-1)+na[Q],u+=W}var O=y[ys(r,u)&et],q=O>>4;O||te(3),u+=O&15;var $=Al[q];if(q>3){var W=ta[q];$+=ys(r,u)&(1<<W)-1,u+=W}if(u>k){c&&te(0);break}a&&h(d+131072);var ct=d+Z;if(d<$){var Nt=s-$,ge=Math.min($,ct);for(Nt+d<0&&te(3);d<ge;++d)e[d]=i[Nt+d]}for(;d<ct;++d)e[d]=e[d-$]}}t.l=p,t.p=at,t.b=d,t.f=l,p&&(l=1,t.m=w,t.d=y,t.n=v)}while(!l);return d!=e.length&&o?Sl(e,0,d):e.subarray(0,d)},Il=new qt(0),zl=function(r,t){return((r[0]&15)!=8||r[0]>>4>7||(r[0]<<8|r[1])%31)&&te(6,"invalid zlib data"),(r[1]>>5&1)==1&&te(6,"invalid zlib data: "+(r[1]&32?"need":"unexpected")+" dictionary"),(r[1]>>3&4)+2};function Rl(r,t){return Fl(r.subarray(zl(r),-4),{i:2},t,t)}var Dl=typeof TextDecoder<"u"&&new TextDecoder,Nl=0;try{Dl.decode(Il,{stream:!0}),Nl=1}catch{}function ra(r,t,e){const i=e.length-r-1;if(t>=e[i])return i-1;if(t<=e[r])return r;let n=r,s=i,o=Math.floor((n+s)/2);for(;t<e[o]||t>=e[o+1];)t<e[o]?s=o:n=o,o=Math.floor((n+s)/2);return o}function Pl(r,t,e,i){const n=[],s=[],o=[];n[0]=1;for(let a=1;a<=e;++a){s[a]=t-i[r+1-a],o[a]=i[r+a]-t;let c=0;for(let h=0;h<a;++h){const l=o[h+1],u=s[a-h],d=n[h]/(l+u);n[h]=c+l*d,c=u*d}n[a]=c}return n}function Ll(r,t,e,i){const n=ra(r,i,t),s=Pl(n,i,r,t),o=new Rt(0,0,0,0);for(let a=0;a<=r;++a){const c=e[n-r+a],h=s[a],l=c.w*h;o.x+=c.x*l,o.y+=c.y*l,o.z+=c.z*l,o.w+=c.w*h}return o}function Ol(r,t,e,i,n){const s=[];for(let u=0;u<=e;++u)s[u]=0;const o=[];for(let u=0;u<=i;++u)o[u]=s.slice(0);const a=[];for(let u=0;u<=e;++u)a[u]=s.slice(0);a[0][0]=1;const c=s.slice(0),h=s.slice(0);for(let u=1;u<=e;++u){c[u]=t-n[r+1-u],h[u]=n[r+u]-t;let d=0;for(let p=0;p<u;++p){const y=h[p+1],w=c[u-p];a[u][p]=y+w;const v=a[p][u-1]/a[u][p];a[p][u]=d+y*v,d=w*v}a[u][u]=d}for(let u=0;u<=e;++u)o[0][u]=a[u][e];for(let u=0;u<=e;++u){let d=0,p=1;const y=[];for(let w=0;w<=e;++w)y[w]=s.slice(0);y[0][0]=1;for(let w=1;w<=i;++w){let v=0;const k=u-w,C=e-w;u>=w&&(y[p][0]=y[d][0]/a[C+1][k],v=y[p][0]*a[k][C]);const A=k>=-1?1:-k,T=u-1<=C?w-1:e-u;for(let z=A;z<=T;++z)y[p][z]=(y[d][z]-y[d][z-1])/a[C+1][k+z],v+=y[p][z]*a[k+z][C];u<=C&&(y[p][w]=-y[d][w-1]/a[C+1][u],v+=y[p][w]*a[u][C]),o[w][u]=v;const _=d;d=p,p=_}}let l=e;for(let u=1;u<=i;++u){for(let d=0;d<=e;++d)o[u][d]*=l;l*=e-u}return o}function Bl(r,t,e,i,n){const s=n<r?n:r,o=[],a=ra(r,i,t),c=Ol(a,i,r,s,t),h=[];for(let l=0;l<e.length;++l){const u=e[l].clone(),d=u.w;u.x*=d,u.y*=d,u.z*=d,h[l]=u}for(let l=0;l<=s;++l){const u=h[a-r].clone().multiplyScalar(c[l][0]);for(let d=1;d<=r;++d)u.add(h[a-r+d].clone().multiplyScalar(c[l][d]));o[l]=u}for(let l=s+1;l<=n+1;++l)o[l]=new Rt(0,0,0);return o}function Vl(r,t){let e=1;for(let n=2;n<=r;++n)e*=n;let i=1;for(let n=2;n<=t;++n)i*=n;for(let n=2;n<=r-t;++n)i*=n;return e/i}function jl(r){const t=r.length,e=[],i=[];for(let s=0;s<t;++s){const o=r[s];e[s]=new M(o.x,o.y,o.z),i[s]=o.w}const n=[];for(let s=0;s<t;++s){const o=e[s].clone();for(let a=1;a<=s;++a)o.sub(n[s-a].clone().multiplyScalar(Vl(s,a)*i[a]));n[s]=o.divideScalar(i[0])}return n}function Ul(r,t,e,i,n){const s=Bl(r,t,e,i,n);return jl(s)}class Hl extends Fh{constructor(t,e,i,n,s){super(),this.degree=t,this.knots=e,this.controlPoints=[],this.startKnot=n||0,this.endKnot=s||this.knots.length-1;for(let o=0;o<i.length;++o){const a=i[o];this.controlPoints[o]=new Rt(a.x,a.y,a.z,a.w)}}getPoint(t,e=new M){const i=e,n=this.knots[this.startKnot]+t*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=Ll(this.degree,this.knots,this.controlPoints,n);return s.w!==1&&s.divideScalar(s.w),i.set(s.x,s.y,s.z)}getTangent(t,e=new M){const i=e,n=this.knots[0]+t*(this.knots[this.knots.length-1]-this.knots[0]),s=Ul(this.degree,this.knots,this.controlPoints,n,1);return i.copy(s[1]).normalize(),i}}let tt,bt,Lt;class Gl extends ne{constructor(t){super(t)}load(t,e,i,n){const s=this,o=s.path===""?$o.extractUrlBase(t):s.path,a=new Us(this.manager);a.setPath(s.path),a.setResponseType("arraybuffer"),a.setRequestHeader(s.requestHeader),a.setWithCredentials(s.withCredentials),a.load(t,function(c){try{e(s.parse(c,o))}catch(h){n?n(h):console.error(h),s.manager.itemError(t)}},i,n)}parse(t,e){if(Jl(t))tt=new Zl().parse(t);else{const n=ha(t);if(!Yl(n))throw new Error("THREE.FBXLoader: Unknown format.");if(Eo(n)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Eo(n));tt=new Xl().parse(n)}const i=new Xo(this.manager).setPath(this.resourcePath||e).setCrossOrigin(this.crossOrigin);return new Wl(i,this.manager).parse(tt)}}class Wl{constructor(t,e){this.textureLoader=t,this.manager=e}parse(){bt=this.parseConnections();const t=this.parseImages(),e=this.parseTextures(t),i=this.parseMaterials(e),n=this.parseDeformers(),s=new Kl().parse(n);return this.parseScene(n,s,i),Lt}parseConnections(){const t=new Map;return"Connections"in tt&&tt.Connections.connections.forEach(function(i){const n=i[0],s=i[1],o=i[2];t.has(n)||t.set(n,{parents:[],children:[]});const a={ID:s,relationship:o};t.get(n).parents.push(a),t.has(s)||t.set(s,{parents:[],children:[]});const c={ID:n,relationship:o};t.get(s).children.push(c)}),t}parseImages(){const t={},e={};if("Video"in tt.Objects){const i=tt.Objects.Video;for(const n in i){const s=i[n],o=parseInt(n);if(t[o]=s.RelativeFilename||s.Filename,"Content"in s){const a=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,c=typeof s.Content=="string"&&s.Content!=="";if(a||c){const h=this.parseImage(i[n]);e[s.RelativeFilename||s.Filename]=h}}}}for(const i in t){const n=t[i];e[n]!==void 0?t[i]=e[n]:t[i]=t[i].split("\\").pop()}return t}parseImage(t){const e=t.Content,i=t.RelativeFilename||t.Filename,n=i.slice(i.lastIndexOf(".")+1).toLowerCase();let s;switch(n){case"bmp":s="image/bmp";break;case"jpg":case"jpeg":s="image/jpeg";break;case"png":s="image/png";break;case"tif":s="image/tiff";break;case"tga":this.manager.getHandler(".tga")===null&&console.warn("FBXLoader: TGA loader not found, skipping ",i),s="image/tga";break;default:console.warn('FBXLoader: Image type "'+n+'" is not supported.');return}if(typeof e=="string")return"data:"+s+";base64,"+e;{const o=new Uint8Array(e);return window.URL.createObjectURL(new Blob([o],{type:s}))}}parseTextures(t){const e=new Map;if("Texture"in tt.Objects){const i=tt.Objects.Texture;for(const n in i){const s=this.parseTexture(i[n],t);e.set(parseInt(n),s)}}return e}parseTexture(t,e){const i=this.loadTexture(t,e);i.ID=t.id,i.name=t.attrName;const n=t.WrapModeU,s=t.WrapModeV,o=n!==void 0?n.value:0,a=s!==void 0?s.value:0;if(i.wrapS=o===0?_e:ie,i.wrapT=a===0?_e:ie,"Scaling"in t){const c=t.Scaling.value;i.repeat.x=c[0],i.repeat.y=c[1]}if("Translation"in t){const c=t.Translation.value;i.offset.x=c[0],i.offset.y=c[1]}return i}loadTexture(t,e){let i;const n=this.textureLoader.path,s=bt.get(t.id).children;s!==void 0&&s.length>0&&e[s[0].ID]!==void 0&&(i=e[s[0].ID],(i.indexOf("blob:")===0||i.indexOf("data:")===0)&&this.textureLoader.setPath(void 0));let o;const a=t.FileName.slice(-3).toLowerCase();if(a==="tga"){const c=this.manager.getHandler(".tga");c===null?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",t.RelativeFilename),o=new Gt):(c.setPath(this.textureLoader.path),o=c.load(i))}else if(a==="dds"){const c=this.manager.getHandler(".dds");c===null?(console.warn("FBXLoader: DDS loader not found, creating placeholder texture for",t.RelativeFilename),o=new Gt):(c.setPath(this.textureLoader.path),o=c.load(i))}else a==="psd"?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",t.RelativeFilename),o=new Gt):o=this.textureLoader.load(i);return this.textureLoader.setPath(n),o}parseMaterials(t){const e=new Map;if("Material"in tt.Objects){const i=tt.Objects.Material;for(const n in i){const s=this.parseMaterial(i[n],t);s!==null&&e.set(parseInt(n),s)}}return e}parseMaterial(t,e){const i=t.id,n=t.attrName;let s=t.ShadingModel;if(typeof s=="object"&&(s=s.value),!bt.has(i))return null;const o=this.parseParameters(t,e,i);let a;switch(s.toLowerCase()){case"phong":a=new Ei;break;case"lambert":a=new Wo;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',s),a=new Ei;break}return a.setValues(o),a.name=n,a}parseParameters(t,e,i){const n={};t.BumpFactor&&(n.bumpScale=t.BumpFactor.value),t.Diffuse?n.color=new yt().fromArray(t.Diffuse.value).convertSRGBToLinear():t.DiffuseColor&&(t.DiffuseColor.type==="Color"||t.DiffuseColor.type==="ColorRGB")&&(n.color=new yt().fromArray(t.DiffuseColor.value).convertSRGBToLinear()),t.DisplacementFactor&&(n.displacementScale=t.DisplacementFactor.value),t.Emissive?n.emissive=new yt().fromArray(t.Emissive.value).convertSRGBToLinear():t.EmissiveColor&&(t.EmissiveColor.type==="Color"||t.EmissiveColor.type==="ColorRGB")&&(n.emissive=new yt().fromArray(t.EmissiveColor.value).convertSRGBToLinear()),t.EmissiveFactor&&(n.emissiveIntensity=parseFloat(t.EmissiveFactor.value)),t.Opacity&&(n.opacity=parseFloat(t.Opacity.value)),n.opacity<1&&(n.transparent=!0),t.ReflectionFactor&&(n.reflectivity=t.ReflectionFactor.value),t.Shininess&&(n.shininess=t.Shininess.value),t.Specular?n.specular=new yt().fromArray(t.Specular.value).convertSRGBToLinear():t.SpecularColor&&t.SpecularColor.type==="Color"&&(n.specular=new yt().fromArray(t.SpecularColor.value).convertSRGBToLinear());const s=this;return bt.get(i).children.forEach(function(o){const a=o.relationship;switch(a){case"Bump":n.bumpMap=s.getTexture(e,o.ID);break;case"Maya|TEX_ao_map":n.aoMap=s.getTexture(e,o.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=s.getTexture(e,o.ID),n.map!==void 0&&(n.map.colorSpace=Bt);break;case"DisplacementColor":n.displacementMap=s.getTexture(e,o.ID);break;case"EmissiveColor":n.emissiveMap=s.getTexture(e,o.ID),n.emissiveMap!==void 0&&(n.emissiveMap.colorSpace=Bt);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=s.getTexture(e,o.ID);break;case"ReflectionColor":n.envMap=s.getTexture(e,o.ID),n.envMap!==void 0&&(n.envMap.mapping=Rc,n.envMap.colorSpace=Bt);break;case"SpecularColor":n.specularMap=s.getTexture(e,o.ID),n.specularMap!==void 0&&(n.specularMap.colorSpace=Bt);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=s.getTexture(e,o.ID),n.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",a);break}}),n}getTexture(t,e){return"LayeredTexture"in tt.Objects&&e in tt.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),e=bt.get(e).children[0].ID),t.get(e)}parseDeformers(){const t={},e={};if("Deformer"in tt.Objects){const i=tt.Objects.Deformer;for(const n in i){const s=i[n],o=bt.get(parseInt(n));if(s.attrType==="Skin"){const a=this.parseSkeleton(o,i);a.ID=n,o.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),a.geometryID=o.parents[0].ID,t[n]=a}else if(s.attrType==="BlendShape"){const a={id:n};a.rawTargets=this.parseMorphTargets(o,i),a.id=n,o.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),e[n]=a}}}return{skeletons:t,morphTargets:e}}parseSkeleton(t,e){const i=[];return t.children.forEach(function(n){const s=e[n.ID];if(s.attrType!=="Cluster")return;const o={ID:n.ID,indices:[],weights:[],transformLink:new H().fromArray(s.TransformLink.a)};"Indexes"in s&&(o.indices=s.Indexes.a,o.weights=s.Weights.a),i.push(o)}),{rawBones:i,bones:[]}}parseMorphTargets(t,e){const i=[];for(let n=0;n<t.children.length;n++){const s=t.children[n],o=e[s.ID],a={name:o.attrName,initialWeight:o.DeformPercent,id:o.id,fullWeights:o.FullWeights.a};if(o.attrType!=="BlendShapeChannel")return;a.geoID=bt.get(parseInt(s.ID)).children.filter(function(c){return c.relationship===void 0})[0].ID,i.push(a)}return i}parseScene(t,e,i){Lt=new Mn;const n=this.parseModels(t.skeletons,e,i),s=tt.Objects.Model,o=this;n.forEach(function(c){const h=s[c.ID];o.setLookAtProperties(c,h),bt.get(c.ID).parents.forEach(function(u){const d=n.get(u.ID);d!==void 0&&d.add(c)}),c.parent===null&&Lt.add(c)}),this.bindSkeleton(t.skeletons,e,n),this.addGlobalSceneSettings(),Lt.traverse(function(c){if(c.userData.transformData){c.parent&&(c.userData.transformData.parentMatrix=c.parent.matrix,c.userData.transformData.parentMatrixWorld=c.parent.matrixWorld);const h=aa(c.userData.transformData);c.applyMatrix4(h),c.updateWorldMatrix()}});const a=new ql().parse();Lt.children.length===1&&Lt.children[0].isGroup&&(Lt.children[0].animations=a,Lt=Lt.children[0]),Lt.animations=a}parseModels(t,e,i){const n=new Map,s=tt.Objects.Model;for(const o in s){const a=parseInt(o),c=s[o],h=bt.get(a);let l=this.buildSkeleton(h,t,a,c.attrName);if(!l){switch(c.attrType){case"Camera":l=this.createCamera(h);break;case"Light":l=this.createLight(h);break;case"Mesh":l=this.createMesh(h,e,i);break;case"NurbsCurve":l=this.createCurve(h,e);break;case"LimbNode":case"Root":l=new kn;break;case"Null":default:l=new Mn;break}l.name=c.attrName?ot.sanitizeNodeName(c.attrName):"",l.userData.originalName=c.attrName,l.ID=a}this.getTransformData(l,c),n.set(a,l)}return n}buildSkeleton(t,e,i,n){let s=null;return t.parents.forEach(function(o){for(const a in e){const c=e[a];c.rawBones.forEach(function(h,l){if(h.ID===o.ID){const u=s;s=new kn,s.matrixWorld.copy(h.transformLink),s.name=n?ot.sanitizeNodeName(n):"",s.userData.originalName=n,s.ID=i,c.bones[l]=s,u!==null&&s.add(u)}})}}),s}createCamera(t){let e,i;if(t.children.forEach(function(n){const s=tt.Objects.NodeAttribute[n.ID];s!==void 0&&(i=s)}),i===void 0)e=new gt;else{let n=0;i.CameraProjectionType!==void 0&&i.CameraProjectionType.value===1&&(n=1);let s=1;i.NearPlane!==void 0&&(s=i.NearPlane.value/1e3);let o=1e3;i.FarPlane!==void 0&&(o=i.FarPlane.value/1e3);let a=window.innerWidth,c=window.innerHeight;i.AspectWidth!==void 0&&i.AspectHeight!==void 0&&(a=i.AspectWidth.value,c=i.AspectHeight.value);const h=a/c;let l=45;i.FieldOfView!==void 0&&(l=i.FieldOfView.value);const u=i.FocalLength?i.FocalLength.value:null;switch(n){case 0:e=new Ci(l,h,s,o),u!==null&&e.setFocalLength(u);break;case 1:e=new Bs(-a/2,a/2,c/2,-c/2,s,o);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+n+"."),e=new gt;break}}return e}createLight(t){let e,i;if(t.children.forEach(function(n){const s=tt.Objects.NodeAttribute[n.ID];s!==void 0&&(i=s)}),i===void 0)e=new gt;else{let n;i.LightType===void 0?n=0:n=i.LightType.value;let s=16777215;i.Color!==void 0&&(s=new yt().fromArray(i.Color.value).convertSRGBToLinear());let o=i.Intensity===void 0?1:i.Intensity.value/100;i.CastLightOnObject!==void 0&&i.CastLightOnObject.value===0&&(o=0);let a=0;i.FarAttenuationEnd!==void 0&&(i.EnableFarAttenuation!==void 0&&i.EnableFarAttenuation.value===0?a=0:a=i.FarAttenuationEnd.value);const c=1;switch(n){case 0:e=new Cs(s,o,a,c);break;case 1:e=new Jo(s,o);break;case 2:let h=Math.PI/3;i.InnerAngle!==void 0&&(h=kt.degToRad(i.InnerAngle.value));let l=0;i.OuterAngle!==void 0&&(l=kt.degToRad(i.OuterAngle.value),l=Math.max(l,1)),e=new Zo(s,o,a,h,l,c);break;default:console.warn("THREE.FBXLoader: Unknown light type "+i.LightType.value+", defaulting to a PointLight."),e=new Cs(s,o);break}i.CastShadows!==void 0&&i.CastShadows.value===1&&(e.castShadow=!0)}return e}createMesh(t,e,i){let n,s=null,o=null;const a=[];return t.children.forEach(function(c){e.has(c.ID)&&(s=e.get(c.ID)),i.has(c.ID)&&a.push(i.get(c.ID))}),a.length>1?o=a:a.length>0?o=a[0]:(o=new Ei({name:ne.DEFAULT_MATERIAL_NAME,color:13421772}),a.push(o)),"color"in s.attributes&&a.forEach(function(c){c.vertexColors=!0}),s.FBX_Deformer?(n=new Vo(s,o),n.normalizeSkinWeights()):n=new Os(s,o),n}createCurve(t,e){const i=t.children.reduce(function(s,o){return e.has(o.ID)&&(s=e.get(o.ID)),s},null),n=new An({name:ne.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new Vs(i,n)}getTransformData(t,e){const i={};"InheritType"in e&&(i.inheritType=parseInt(e.InheritType.value)),"RotationOrder"in e?i.eulerOrder=ca(e.RotationOrder.value):i.eulerOrder="ZYX","Lcl_Translation"in e&&(i.translation=e.Lcl_Translation.value),"PreRotation"in e&&(i.preRotation=e.PreRotation.value),"Lcl_Rotation"in e&&(i.rotation=e.Lcl_Rotation.value),"PostRotation"in e&&(i.postRotation=e.PostRotation.value),"Lcl_Scaling"in e&&(i.scale=e.Lcl_Scaling.value),"ScalingOffset"in e&&(i.scalingOffset=e.ScalingOffset.value),"ScalingPivot"in e&&(i.scalingPivot=e.ScalingPivot.value),"RotationOffset"in e&&(i.rotationOffset=e.RotationOffset.value),"RotationPivot"in e&&(i.rotationPivot=e.RotationPivot.value),t.userData.transformData=i}setLookAtProperties(t,e){"LookAtProperty"in e&&bt.get(t.ID).children.forEach(function(n){if(n.relationship==="LookAtProperty"){const s=tt.Objects.Model[n.ID];if("Lcl_Translation"in s){const o=s.Lcl_Translation.value;t.target!==void 0?(t.target.position.fromArray(o),Lt.add(t.target)):t.lookAt(new M().fromArray(o))}}})}bindSkeleton(t,e,i){const n=this.parsePoseNodes();for(const s in t){const o=t[s];bt.get(parseInt(o.ID)).parents.forEach(function(c){if(e.has(c.ID)){const h=c.ID;bt.get(h).parents.forEach(function(u){i.has(u.ID)&&i.get(u.ID).bind(new In(o.bones),n[u.ID])})}})}}parsePoseNodes(){const t={};if("Pose"in tt.Objects){const e=tt.Objects.Pose;for(const i in e)if(e[i].attrType==="BindPose"&&e[i].NbPoseNodes>0){const n=e[i].PoseNode;Array.isArray(n)?n.forEach(function(s){t[s.Node]=new H().fromArray(s.Matrix.a)}):t[n.Node]=new H().fromArray(n.Matrix.a)}}return t}addGlobalSceneSettings(){if("GlobalSettings"in tt){if("AmbientColor"in tt.GlobalSettings){const t=tt.GlobalSettings.AmbientColor.value,e=t[0],i=t[1],n=t[2];if(e!==0||i!==0||n!==0){const s=new yt(e,i,n).convertSRGBToLinear();Lt.add(new Yo(s,1))}}"UnitScaleFactor"in tt.GlobalSettings&&(Lt.userData.unitScaleFactor=tt.GlobalSettings.UnitScaleFactor.value)}}}class Kl{constructor(){this.negativeMaterialIndices=!1}parse(t){const e=new Map;if("Geometry"in tt.Objects){const i=tt.Objects.Geometry;for(const n in i){const s=bt.get(parseInt(n)),o=this.parseGeometry(s,i[n],t);e.set(parseInt(n),o)}}return this.negativeMaterialIndices===!0&&console.warn("THREE.FBXLoader: The FBX file contains invalid (negative) material indices. The asset might not render as expected."),e}parseGeometry(t,e,i){switch(e.attrType){case"Mesh":return this.parseMeshGeometry(t,e,i);case"NurbsCurve":return this.parseNurbsGeometry(e)}}parseMeshGeometry(t,e,i){const n=i.skeletons,s=[],o=t.parents.map(function(u){return tt.Objects.Model[u.ID]});if(o.length===0)return;const a=t.children.reduce(function(u,d){return n[d.ID]!==void 0&&(u=n[d.ID]),u},null);t.children.forEach(function(u){i.morphTargets[u.ID]!==void 0&&s.push(i.morphTargets[u.ID])});const c=o[0],h={};"RotationOrder"in c&&(h.eulerOrder=ca(c.RotationOrder.value)),"InheritType"in c&&(h.inheritType=parseInt(c.InheritType.value)),"GeometricTranslation"in c&&(h.translation=c.GeometricTranslation.value),"GeometricRotation"in c&&(h.rotation=c.GeometricRotation.value),"GeometricScaling"in c&&(h.scale=c.GeometricScaling.value);const l=aa(h);return this.genGeometry(e,a,s,l)}genGeometry(t,e,i,n){const s=new me;t.attrName&&(s.name=t.attrName);const o=this.parseGeoNode(t,e),a=this.genBuffers(o),c=new zt(a.vertex,3);if(c.applyMatrix4(n),s.setAttribute("position",c),a.colors.length>0&&s.setAttribute("color",new zt(a.colors,3)),e&&(s.setAttribute("skinIndex",new Oo(a.weightsIndices,4)),s.setAttribute("skinWeight",new zt(a.vertexWeights,4)),s.FBX_Deformer=e),a.normal.length>0){const h=new se().getNormalMatrix(n),l=new zt(a.normal,3);l.applyNormalMatrix(h),s.setAttribute("normal",l)}if(a.uvs.forEach(function(h,l){const u=l===0?"uv":`uv${l}`;s.setAttribute(u,new zt(a.uvs[l],2))}),o.material&&o.material.mappingType!=="AllSame"){let h=a.materialIndex[0],l=0;if(a.materialIndex.forEach(function(u,d){u!==h&&(s.addGroup(l,d-l,h),h=u,l=d)}),s.groups.length>0){const u=s.groups[s.groups.length-1],d=u.start+u.count;d!==a.materialIndex.length&&s.addGroup(d,a.materialIndex.length-d,h)}s.groups.length===0&&s.addGroup(0,a.materialIndex.length,a.materialIndex[0])}return this.addMorphTargets(s,t,i,n),s}parseGeoNode(t,e){const i={};if(i.vertexPositions=t.Vertices!==void 0?t.Vertices.a:[],i.vertexIndices=t.PolygonVertexIndex!==void 0?t.PolygonVertexIndex.a:[],t.LayerElementColor&&(i.color=this.parseVertexColors(t.LayerElementColor[0])),t.LayerElementMaterial&&(i.material=this.parseMaterialIndices(t.LayerElementMaterial[0])),t.LayerElementNormal&&(i.normal=this.parseNormals(t.LayerElementNormal[0])),t.LayerElementUV){i.uv=[];let n=0;for(;t.LayerElementUV[n];)t.LayerElementUV[n].UV&&i.uv.push(this.parseUVs(t.LayerElementUV[n])),n++}return i.weightTable={},e!==null&&(i.skeleton=e,e.rawBones.forEach(function(n,s){n.indices.forEach(function(o,a){i.weightTable[o]===void 0&&(i.weightTable[o]=[]),i.weightTable[o].push({id:s,weight:n.weights[a]})})})),i}genBuffers(t){const e={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let i=0,n=0,s=!1,o=[],a=[],c=[],h=[],l=[],u=[];const d=this;return t.vertexIndices.forEach(function(p,y){let w,v=!1;p<0&&(p=p^-1,v=!0);let k=[],C=[];if(o.push(p*3,p*3+1,p*3+2),t.color){const A=pn(y,i,p,t.color);c.push(A[0],A[1],A[2])}if(t.skeleton){if(t.weightTable[p]!==void 0&&t.weightTable[p].forEach(function(A){C.push(A.weight),k.push(A.id)}),C.length>4){s||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),s=!0);const A=[0,0,0,0],T=[0,0,0,0];C.forEach(function(_,z){let F=_,R=k[z];T.forEach(function(L,G,Q){if(F>L){Q[G]=F,F=L;const xt=A[G];A[G]=R,R=xt}})}),k=A,C=T}for(;C.length<4;)C.push(0),k.push(0);for(let A=0;A<4;++A)l.push(C[A]),u.push(k[A])}if(t.normal){const A=pn(y,i,p,t.normal);a.push(A[0],A[1],A[2])}t.material&&t.material.mappingType!=="AllSame"&&(w=pn(y,i,p,t.material)[0],w<0&&(d.negativeMaterialIndices=!0,w=0)),t.uv&&t.uv.forEach(function(A,T){const _=pn(y,i,p,A);h[T]===void 0&&(h[T]=[]),h[T].push(_[0]),h[T].push(_[1])}),n++,v&&(d.genFace(e,t,o,w,a,c,h,l,u,n),i++,n=0,o=[],a=[],c=[],h=[],l=[],u=[])}),e}getNormalNewell(t){const e=new M(0,0,0);for(let i=0;i<t.length;i++){const n=t[i],s=t[(i+1)%t.length];e.x+=(n.y-s.y)*(n.z+s.z),e.y+=(n.z-s.z)*(n.x+s.x),e.z+=(n.x-s.x)*(n.y+s.y)}return e.normalize(),e}getNormalTangentAndBitangent(t){const e=this.getNormalNewell(t),n=(Math.abs(e.z)>.5?new M(0,1,0):new M(0,0,1)).cross(e).normalize(),s=e.clone().cross(n).normalize();return{normal:e,tangent:n,bitangent:s}}flattenVertex(t,e,i){return new pt(t.dot(e),t.dot(i))}genFace(t,e,i,n,s,o,a,c,h,l){let u;if(l>3){const d=[];for(let v=0;v<i.length;v+=3)d.push(new M(e.vertexPositions[i[v]],e.vertexPositions[i[v+1]],e.vertexPositions[i[v+2]]));const{tangent:p,bitangent:y}=this.getNormalTangentAndBitangent(d),w=[];for(const v of d)w.push(this.flattenVertex(v,p,y));u=js.triangulateShape(w,[])}else u=[[0,1,2]];for(const[d,p,y]of u)t.vertex.push(e.vertexPositions[i[d*3]]),t.vertex.push(e.vertexPositions[i[d*3+1]]),t.vertex.push(e.vertexPositions[i[d*3+2]]),t.vertex.push(e.vertexPositions[i[p*3]]),t.vertex.push(e.vertexPositions[i[p*3+1]]),t.vertex.push(e.vertexPositions[i[p*3+2]]),t.vertex.push(e.vertexPositions[i[y*3]]),t.vertex.push(e.vertexPositions[i[y*3+1]]),t.vertex.push(e.vertexPositions[i[y*3+2]]),e.skeleton&&(t.vertexWeights.push(c[d*4]),t.vertexWeights.push(c[d*4+1]),t.vertexWeights.push(c[d*4+2]),t.vertexWeights.push(c[d*4+3]),t.vertexWeights.push(c[p*4]),t.vertexWeights.push(c[p*4+1]),t.vertexWeights.push(c[p*4+2]),t.vertexWeights.push(c[p*4+3]),t.vertexWeights.push(c[y*4]),t.vertexWeights.push(c[y*4+1]),t.vertexWeights.push(c[y*4+2]),t.vertexWeights.push(c[y*4+3]),t.weightsIndices.push(h[d*4]),t.weightsIndices.push(h[d*4+1]),t.weightsIndices.push(h[d*4+2]),t.weightsIndices.push(h[d*4+3]),t.weightsIndices.push(h[p*4]),t.weightsIndices.push(h[p*4+1]),t.weightsIndices.push(h[p*4+2]),t.weightsIndices.push(h[p*4+3]),t.weightsIndices.push(h[y*4]),t.weightsIndices.push(h[y*4+1]),t.weightsIndices.push(h[y*4+2]),t.weightsIndices.push(h[y*4+3])),e.color&&(t.colors.push(o[d*3]),t.colors.push(o[d*3+1]),t.colors.push(o[d*3+2]),t.colors.push(o[p*3]),t.colors.push(o[p*3+1]),t.colors.push(o[p*3+2]),t.colors.push(o[y*3]),t.colors.push(o[y*3+1]),t.colors.push(o[y*3+2])),e.material&&e.material.mappingType!=="AllSame"&&(t.materialIndex.push(n),t.materialIndex.push(n),t.materialIndex.push(n)),e.normal&&(t.normal.push(s[d*3]),t.normal.push(s[d*3+1]),t.normal.push(s[d*3+2]),t.normal.push(s[p*3]),t.normal.push(s[p*3+1]),t.normal.push(s[p*3+2]),t.normal.push(s[y*3]),t.normal.push(s[y*3+1]),t.normal.push(s[y*3+2])),e.uv&&e.uv.forEach(function(w,v){t.uvs[v]===void 0&&(t.uvs[v]=[]),t.uvs[v].push(a[v][d*2]),t.uvs[v].push(a[v][d*2+1]),t.uvs[v].push(a[v][p*2]),t.uvs[v].push(a[v][p*2+1]),t.uvs[v].push(a[v][y*2]),t.uvs[v].push(a[v][y*2+1])})}addMorphTargets(t,e,i,n){if(i.length===0)return;t.morphTargetsRelative=!0,t.morphAttributes.position=[];const s=this;i.forEach(function(o){o.rawTargets.forEach(function(a){const c=tt.Objects.Geometry[a.geoID];c!==void 0&&s.genMorphGeometry(t,e,c,n,a.name)})})}genMorphGeometry(t,e,i,n,s){const o=e.PolygonVertexIndex!==void 0?e.PolygonVertexIndex.a:[],a=i.Vertices!==void 0?i.Vertices.a:[],c=i.Indexes!==void 0?i.Indexes.a:[],h=t.attributes.position.count*3,l=new Float32Array(h);for(let y=0;y<c.length;y++){const w=c[y]*3;l[w]=a[y*3],l[w+1]=a[y*3+1],l[w+2]=a[y*3+2]}const u={vertexIndices:o,vertexPositions:l},d=this.genBuffers(u),p=new zt(d.vertex,3);p.name=s||i.attrName,p.applyMatrix4(n),t.morphAttributes.position.push(p)}parseNormals(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.Normals.a;let s=[];return i==="IndexToDirect"&&("NormalIndex"in t?s=t.NormalIndex.a:"NormalsIndex"in t&&(s=t.NormalsIndex.a)),{dataSize:3,buffer:n,indices:s,mappingType:e,referenceType:i}}parseUVs(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.UV.a;let s=[];return i==="IndexToDirect"&&(s=t.UVIndex.a),{dataSize:2,buffer:n,indices:s,mappingType:e,referenceType:i}}parseVertexColors(t){const e=t.MappingInformationType,i=t.ReferenceInformationType,n=t.Colors.a;let s=[];i==="IndexToDirect"&&(s=t.ColorIndex.a);for(let o=0,a=new yt;o<n.length;o+=4)a.fromArray(n,o).convertSRGBToLinear().toArray(n,o);return{dataSize:4,buffer:n,indices:s,mappingType:e,referenceType:i}}parseMaterialIndices(t){const e=t.MappingInformationType,i=t.ReferenceInformationType;if(e==="NoMappingInformation")return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:i};const n=t.Materials.a,s=[];for(let o=0;o<n.length;++o)s.push(o);return{dataSize:1,buffer:n,indices:s,mappingType:e,referenceType:i}}parseNurbsGeometry(t){const e=parseInt(t.Order);if(isNaN(e))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",t.Order,t.id),new me;const i=e-1,n=t.KnotVector.a,s=[],o=t.Points.a;for(let u=0,d=o.length;u<d;u+=4)s.push(new Rt().fromArray(o,u));let a,c;if(t.Form==="Closed")s.push(s[0]);else if(t.Form==="Periodic"){a=i,c=n.length-1-a;for(let u=0;u<i;++u)s.push(s[u])}const l=new Hl(i,n,s,a,c).getPoints(s.length*12);return new me().setFromPoints(l)}}class ql{parse(){const t=[],e=this.parseClips();if(e!==void 0)for(const i in e){const n=e[i],s=this.addClip(n);t.push(s)}return t}parseClips(){if(tt.Objects.AnimationCurve===void 0)return;const t=this.parseAnimationCurveNodes();this.parseAnimationCurves(t);const e=this.parseAnimationLayers(t);return this.parseAnimStacks(e)}parseAnimationCurveNodes(){const t=tt.Objects.AnimationCurveNode,e=new Map;for(const i in t){const n=t[i];if(n.attrName.match(/S|R|T|DeformPercent/)!==null){const s={id:n.id,attr:n.attrName,curves:{}};e.set(s.id,s)}}return e}parseAnimationCurves(t){const e=tt.Objects.AnimationCurve;for(const i in e){const n={id:e[i].id,times:e[i].KeyTime.a.map($l),values:e[i].KeyValueFloat.a},s=bt.get(n.id);if(s!==void 0){const o=s.parents[0].ID,a=s.parents[0].relationship;a.match(/X/)?t.get(o).curves.x=n:a.match(/Y/)?t.get(o).curves.y=n:a.match(/Z/)?t.get(o).curves.z=n:a.match(/DeformPercent/)&&t.has(o)&&(t.get(o).curves.morph=n)}}}parseAnimationLayers(t){const e=tt.Objects.AnimationLayer,i=new Map;for(const n in e){const s=[],o=bt.get(parseInt(n));o!==void 0&&(o.children.forEach(function(c,h){if(t.has(c.ID)){const l=t.get(c.ID);if(l.curves.x!==void 0||l.curves.y!==void 0||l.curves.z!==void 0){if(s[h]===void 0){const u=bt.get(c.ID).parents.filter(function(d){return d.relationship!==void 0})[0].ID;if(u!==void 0){const d=tt.Objects.Model[u.toString()];if(d===void 0){console.warn("THREE.FBXLoader: Encountered a unused curve.",c);return}const p={modelName:d.attrName?ot.sanitizeNodeName(d.attrName):"",ID:d.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Lt.traverse(function(y){y.ID===d.id&&(p.transform=y.matrix,y.userData.transformData&&(p.eulerOrder=y.userData.transformData.eulerOrder))}),p.transform||(p.transform=new H),"PreRotation"in d&&(p.preRotation=d.PreRotation.value),"PostRotation"in d&&(p.postRotation=d.PostRotation.value),s[h]=p}}s[h]&&(s[h][l.attr]=l)}else if(l.curves.morph!==void 0){if(s[h]===void 0){const u=bt.get(c.ID).parents.filter(function(k){return k.relationship!==void 0})[0].ID,d=bt.get(u).parents[0].ID,p=bt.get(d).parents[0].ID,y=bt.get(p).parents[0].ID,w=tt.Objects.Model[y],v={modelName:w.attrName?ot.sanitizeNodeName(w.attrName):"",morphName:tt.Objects.Deformer[u].attrName};s[h]=v}s[h][l.attr]=l}}}),i.set(parseInt(n),s))}return i}parseAnimStacks(t){const e=tt.Objects.AnimationStack,i={};for(const n in e){const s=bt.get(parseInt(n)).children;s.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const o=t.get(s[0].ID);i[n]={name:e[n].attrName,layer:o}}return i}addClip(t){let e=[];const i=this;return t.layer.forEach(function(n){e=e.concat(i.generateTracks(n))}),new Ss(t.name,-1,e)}generateTracks(t){const e=[];let i=new M,n=new M;if(t.transform&&t.transform.decompose(i,new Ot,n),i=i.toArray(),n=n.toArray(),t.T!==void 0&&Object.keys(t.T.curves).length>0){const s=this.generateVectorTrack(t.modelName,t.T.curves,i,"position");s!==void 0&&e.push(s)}if(t.R!==void 0&&Object.keys(t.R.curves).length>0){const s=this.generateRotationTrack(t.modelName,t.R.curves,t.preRotation,t.postRotation,t.eulerOrder);s!==void 0&&e.push(s)}if(t.S!==void 0&&Object.keys(t.S.curves).length>0){const s=this.generateVectorTrack(t.modelName,t.S.curves,n,"scale");s!==void 0&&e.push(s)}if(t.DeformPercent!==void 0){const s=this.generateMorphTrack(t);s!==void 0&&e.push(s)}return e}generateVectorTrack(t,e,i,n){const s=this.getTimesForAllAxes(e),o=this.getKeyframeTrackValues(s,e,i);return new Le(t+"."+n,s,o)}generateRotationTrack(t,e,i,n,s){let o,a;if(e.x!==void 0&&e.y!==void 0&&e.z!==void 0){const u=this.interpolateRotations(e.x,e.y,e.z,s);o=u[0],a=u[1]}i!==void 0&&(i=i.map(kt.degToRad),i.push(s),i=new Et().fromArray(i),i=new Ot().setFromEuler(i)),n!==void 0&&(n=n.map(kt.degToRad),n.push(s),n=new Et().fromArray(n),n=new Ot().setFromEuler(n).invert());const c=new Ot,h=new Et,l=[];if(!a||!o)return new Se(t+".quaternion",[0],[0]);for(let u=0;u<a.length;u+=3)h.set(a[u],a[u+1],a[u+2],s),c.setFromEuler(h),i!==void 0&&c.premultiply(i),n!==void 0&&c.multiply(n),u>2&&new Ot().fromArray(l,(u-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w),c.toArray(l,u/3*4);return new Se(t+".quaternion",o,l)}generateMorphTrack(t){const e=t.DeformPercent.curves.morph,i=e.values.map(function(s){return s/100}),n=Lt.getObjectByName(t.modelName).morphTargetDictionary[t.morphName];return new Ri(t.modelName+".morphTargetInfluences["+n+"]",e.times,i)}getTimesForAllAxes(t){let e=[];if(t.x!==void 0&&(e=e.concat(t.x.times)),t.y!==void 0&&(e=e.concat(t.y.times)),t.z!==void 0&&(e=e.concat(t.z.times)),e=e.sort(function(i,n){return i-n}),e.length>1){let i=1,n=e[0];for(let s=1;s<e.length;s++){const o=e[s];o!==n&&(e[i]=o,n=o,i++)}e=e.slice(0,i)}return e}getKeyframeTrackValues(t,e,i){const n=i,s=[];let o=-1,a=-1,c=-1;return t.forEach(function(h){if(e.x&&(o=e.x.times.indexOf(h)),e.y&&(a=e.y.times.indexOf(h)),e.z&&(c=e.z.times.indexOf(h)),o!==-1){const l=e.x.values[o];s.push(l),n[0]=l}else s.push(n[0]);if(a!==-1){const l=e.y.values[a];s.push(l),n[1]=l}else s.push(n[1]);if(c!==-1){const l=e.z.values[c];s.push(l),n[2]=l}else s.push(n[2])}),s}interpolateRotations(t,e,i,n){const s=[],o=[];s.push(t.times[0]),o.push(kt.degToRad(t.values[0])),o.push(kt.degToRad(e.values[0])),o.push(kt.degToRad(i.values[0]));for(let a=1;a<t.values.length;a++){const c=[t.values[a-1],e.values[a-1],i.values[a-1]];if(isNaN(c[0])||isNaN(c[1])||isNaN(c[2]))continue;const h=c.map(kt.degToRad),l=[t.values[a],e.values[a],i.values[a]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const u=l.map(kt.degToRad),d=[l[0]-c[0],l[1]-c[1],l[2]-c[2]],p=[Math.abs(d[0]),Math.abs(d[1]),Math.abs(d[2])];if(p[0]>=180||p[1]>=180||p[2]>=180){const w=Math.max(...p)/180,v=new Et(...h,n),k=new Et(...u,n),C=new Ot().setFromEuler(v),A=new Ot().setFromEuler(k);C.dot(A)&&A.set(-A.x,-A.y,-A.z,-A.w);const T=t.times[a-1],_=t.times[a]-T,z=new Ot,F=new Et;for(let R=0;R<1;R+=1/w)z.copy(C.clone().slerp(A.clone(),R)),s.push(T+R*_),F.setFromQuaternion(z,n),o.push(F.x),o.push(F.y),o.push(F.z)}else s.push(t.times[a]),o.push(kt.degToRad(t.values[a])),o.push(kt.degToRad(e.values[a])),o.push(kt.degToRad(i.values[a]))}return[s,o]}}class Xl{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(t){this.nodeStack.push(t),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(t,e){this.currentProp=t,this.currentPropName=e}parse(t){this.currentIndent=0,this.allNodes=new oa,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const e=this,i=t.split(/[\r\n]+/);return i.forEach(function(n,s){const o=n.match(/^[\s\t]*;/),a=n.match(/^[\s\t]*$/);if(o||a)return;const c=n.match("^\\t{"+e.currentIndent+"}(\\w+):(.*){",""),h=n.match("^\\t{"+e.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=n.match("^\\t{"+(e.currentIndent-1)+"}}");c?e.parseNodeBegin(n,c):h?e.parseNodeProperty(n,h,i[++s]):l?e.popStack():n.match(/^[^\s\t}]/)&&e.parseNodePropertyContinued(n)}),this.allNodes}parseNodeBegin(t,e){const i=e[1].trim().replace(/^"/,"").replace(/"$/,""),n=e[2].split(",").map(function(c){return c.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:i},o=this.parseNodeAttr(n),a=this.getCurrentNode();this.currentIndent===0?this.allNodes.add(i,s):i in a?(i==="PoseNode"?a.PoseNode.push(s):a[i].id!==void 0&&(a[i]={},a[i][a[i].id]=a[i]),o.id!==""&&(a[i][o.id]=s)):typeof o.id=="number"?(a[i]={},a[i][o.id]=s):i!=="Properties70"&&(i==="PoseNode"?a[i]=[s]:a[i]=s),typeof o.id=="number"&&(s.id=o.id),o.name!==""&&(s.attrName=o.name),o.type!==""&&(s.attrType=o.type),this.pushStack(s)}parseNodeAttr(t){let e=t[0];t[0]!==""&&(e=parseInt(t[0]),isNaN(e)&&(e=t[0]));let i="",n="";return t.length>1&&(i=t[1].replace(/^(\w+)::/,""),n=t[2]),{id:e,name:i,type:n}}parseNodeProperty(t,e,i){let n=e[1].replace(/^"/,"").replace(/"$/,"").trim(),s=e[2].replace(/^"/,"").replace(/"$/,"").trim();n==="Content"&&s===","&&(s=i.replace(/"/g,"").replace(/,$/,"").trim());const o=this.getCurrentNode();if(o.name==="Properties70"){this.parseNodeSpecialProperty(t,n,s);return}if(n==="C"){const c=s.split(",").slice(1),h=parseInt(c[0]),l=parseInt(c[1]);let u=s.split(",").slice(3);u=u.map(function(d){return d.trim().replace(/^"/,"")}),n="connections",s=[h,l],tu(s,u),o[n]===void 0&&(o[n]=[])}n==="Node"&&(o.id=s),n in o&&Array.isArray(o[n])?o[n].push(s):n!=="a"?o[n]=s:o.a=s,this.setCurrentProp(o,n),n==="a"&&s.slice(-1)!==","&&(o.a=xs(s))}parseNodePropertyContinued(t){const e=this.getCurrentNode();e.a+=t,t.slice(-1)!==","&&(e.a=xs(e.a))}parseNodeSpecialProperty(t,e,i){const n=i.split('",').map(function(l){return l.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=n[0],o=n[1],a=n[2],c=n[3];let h=n[4];switch(o){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":h=parseFloat(h);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":h=xs(h);break}this.getPrevNode()[s]={type:o,type2:a,flag:c,value:h},this.setCurrentProp(this.getPrevNode(),s)}}class Zl{parse(t){const e=new Ao(t);e.skip(23);const i=e.getUint32();if(i<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+i);const n=new oa;for(;!this.endOfContent(e);){const s=this.parseNode(e,i);s!==null&&n.add(s.name,s)}return n}endOfContent(t){return t.size()%16===0?(t.getOffset()+160+16&-16)>=t.size():t.getOffset()+160+16>=t.size()}parseNode(t,e){const i={},n=e>=7500?t.getUint64():t.getUint32(),s=e>=7500?t.getUint64():t.getUint32();e>=7500?t.getUint64():t.getUint32();const o=t.getUint8(),a=t.getString(o);if(n===0)return null;const c=[];for(let d=0;d<s;d++)c.push(this.parseProperty(t));const h=c.length>0?c[0]:"",l=c.length>1?c[1]:"",u=c.length>2?c[2]:"";for(i.singleProperty=s===1&&t.getOffset()===n;n>t.getOffset();){const d=this.parseNode(t,e);d!==null&&this.parseSubNode(a,i,d)}return i.propertyList=c,typeof h=="number"&&(i.id=h),l!==""&&(i.attrName=l),u!==""&&(i.attrType=u),a!==""&&(i.name=a),i}parseSubNode(t,e,i){if(i.singleProperty===!0){const n=i.propertyList[0];Array.isArray(n)?(e[i.name]=i,i.a=n):e[i.name]=n}else if(t==="Connections"&&i.name==="C"){const n=[];i.propertyList.forEach(function(s,o){o!==0&&n.push(s)}),e.connections===void 0&&(e.connections=[]),e.connections.push(n)}else if(i.name==="Properties70")Object.keys(i).forEach(function(s){e[s]=i[s]});else if(t==="Properties70"&&i.name==="P"){let n=i.propertyList[0],s=i.propertyList[1];const o=i.propertyList[2],a=i.propertyList[3];let c;n.indexOf("Lcl ")===0&&(n=n.replace("Lcl ","Lcl_")),s.indexOf("Lcl ")===0&&(s=s.replace("Lcl ","Lcl_")),s==="Color"||s==="ColorRGB"||s==="Vector"||s==="Vector3D"||s.indexOf("Lcl_")===0?c=[i.propertyList[4],i.propertyList[5],i.propertyList[6]]:c=i.propertyList[4],e[n]={type:s,type2:o,flag:a,value:c}}else e[i.name]===void 0?typeof i.id=="number"?(e[i.name]={},e[i.name][i.id]=i):e[i.name]=i:i.name==="PoseNode"?(Array.isArray(e[i.name])||(e[i.name]=[e[i.name]]),e[i.name].push(i)):e[i.name][i.id]===void 0&&(e[i.name][i.id]=i)}parseProperty(t){const e=t.getString(1);let i;switch(e){case"C":return t.getBoolean();case"D":return t.getFloat64();case"F":return t.getFloat32();case"I":return t.getInt32();case"L":return t.getInt64();case"R":return i=t.getUint32(),t.getArrayBuffer(i);case"S":return i=t.getUint32(),t.getString(i);case"Y":return t.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=t.getUint32(),s=t.getUint32(),o=t.getUint32();if(s===0)switch(e){case"b":case"c":return t.getBooleanArray(n);case"d":return t.getFloat64Array(n);case"f":return t.getFloat32Array(n);case"i":return t.getInt32Array(n);case"l":return t.getInt64Array(n)}const a=Rl(new Uint8Array(t.getArrayBuffer(o))),c=new Ao(a.buffer);switch(e){case"b":case"c":return c.getBooleanArray(n);case"d":return c.getFloat64Array(n);case"f":return c.getFloat32Array(n);case"i":return c.getInt32Array(n);case"l":return c.getInt64Array(n)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+e)}}}class Ao{constructor(t,e){this.dv=new DataView(t),this.offset=0,this.littleEndian=e!==void 0?e:!0,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(t){this.offset+=t}getBoolean(){return(this.getUint8()&1)===1}getBooleanArray(t){const e=[];for(let i=0;i<t;i++)e.push(this.getBoolean());return e}getUint8(){const t=this.dv.getUint8(this.offset);return this.offset+=1,t}getInt16(){const t=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}getInt32(){const t=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}getInt32Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getInt32());return e}getUint32(){const t=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}getInt64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e&2147483648?(e=~e&4294967295,t=~t&4294967295,t===4294967295&&(e=e+1&4294967295),t=t+1&4294967295,-(e*4294967296+t)):e*4294967296+t}getInt64Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getInt64());return e}getUint64(){let t,e;return this.littleEndian?(t=this.getUint32(),e=this.getUint32()):(e=this.getUint32(),t=this.getUint32()),e*4294967296+t}getFloat32(){const t=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}getFloat32Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getFloat32());return e}getFloat64(){const t=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}getFloat64Array(t){const e=[];for(let i=0;i<t;i++)e.push(this.getFloat64());return e}getArrayBuffer(t){const e=this.dv.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}getString(t){const e=this.offset;let i=new Uint8Array(this.dv.buffer,e,t);this.skip(t);const n=i.indexOf(0);return n>=0&&(i=new Uint8Array(this.dv.buffer,e,n)),this._textDecoder.decode(i)}}class oa{add(t,e){this[t]=e}}function Jl(r){const t="Kaydara FBX Binary \0";return r.byteLength>=t.length&&t===ha(r,0,t.length)}function Yl(r){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let e=0;function i(n){const s=r[n-1];return r=r.slice(e+n),e++,s}for(let n=0;n<t.length;++n)if(i(1)===t[n])return!1;return!0}function Eo(r){const t=/FBXVersion: (\d+)/,e=r.match(t);if(e)return parseInt(e[1]);throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function $l(r){return r/46186158e3}const Ql=[];function pn(r,t,e,i){let n;switch(i.mappingType){case"ByPolygonVertex":n=r;break;case"ByPolygon":n=t;break;case"ByVertice":n=e;break;case"AllSame":n=i.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+i.mappingType)}i.referenceType==="IndexToDirect"&&(n=i.indices[n]);const s=n*i.dataSize,o=s+i.dataSize;return eu(Ql,i.buffer,s,o)}const gs=new Et,ii=new M;function aa(r){const t=new H,e=new H,i=new H,n=new H,s=new H,o=new H,a=new H,c=new H,h=new H,l=new H,u=new H,d=new H,p=r.inheritType?r.inheritType:0;if(r.translation&&t.setPosition(ii.fromArray(r.translation)),r.preRotation){const G=r.preRotation.map(kt.degToRad);G.push(r.eulerOrder||Et.DEFAULT_ORDER),e.makeRotationFromEuler(gs.fromArray(G))}if(r.rotation){const G=r.rotation.map(kt.degToRad);G.push(r.eulerOrder||Et.DEFAULT_ORDER),i.makeRotationFromEuler(gs.fromArray(G))}if(r.postRotation){const G=r.postRotation.map(kt.degToRad);G.push(r.eulerOrder||Et.DEFAULT_ORDER),n.makeRotationFromEuler(gs.fromArray(G)),n.invert()}r.scale&&s.scale(ii.fromArray(r.scale)),r.scalingOffset&&a.setPosition(ii.fromArray(r.scalingOffset)),r.scalingPivot&&o.setPosition(ii.fromArray(r.scalingPivot)),r.rotationOffset&&c.setPosition(ii.fromArray(r.rotationOffset)),r.rotationPivot&&h.setPosition(ii.fromArray(r.rotationPivot)),r.parentMatrixWorld&&(u.copy(r.parentMatrix),l.copy(r.parentMatrixWorld));const y=e.clone().multiply(i).multiply(n),w=new H;w.extractRotation(l);const v=new H;v.copyPosition(l);const k=v.clone().invert().multiply(l),C=w.clone().invert().multiply(k),A=s,T=new H;if(p===0)T.copy(w).multiply(y).multiply(C).multiply(A);else if(p===1)T.copy(w).multiply(C).multiply(y).multiply(A);else{const Q=new H().scale(new M().setFromMatrixScale(u)).clone().invert(),xt=C.clone().multiply(Q);T.copy(w).multiply(y).multiply(xt).multiply(A)}const _=h.clone().invert(),z=o.clone().invert();let F=t.clone().multiply(c).multiply(h).multiply(e).multiply(i).multiply(n).multiply(_).multiply(a).multiply(o).multiply(s).multiply(z);const R=new H().copyPosition(F),L=l.clone().multiply(R);return d.copyPosition(L),F=d.clone().multiply(T),F.premultiply(l.invert()),F}function ca(r){r=r||0;const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return r===6?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[r]}function xs(r){return r.split(",").map(function(e){return parseFloat(e)})}function ha(r,t,e){return t===void 0&&(t=0),e===void 0&&(e=r.byteLength),new TextDecoder().decode(new Uint8Array(r,t,e))}function tu(r,t){for(let e=0,i=r.length,n=t.length;e<n;e++,i++)r[i]=t[e]}function eu(r,t,e,i){for(let n=e,s=0;n<i;n++,s++)r[s]=t[n];return r}THREE.FBXLoader=Gl;AFRAME.registerComponent("fbx-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){const r=this.data;if(!r.src)return;this.remove();const t=new THREE.FBXLoader;r.crossorigin&&t.setCrossOrigin(r.crossorigin),t.load(r.src,this.load.bind(this))},load:function(r){this.model=r,this.el.setObject3D("mesh",r),this.el.emit("model-loaded",{format:"fbx",model:r})},remove:function(){this.model&&this.el.removeObject3D("mesh")}});AFRAME.registerComponent("object-model",{schema:{src:{type:"asset"},crossorigin:{default:""}},init:function(){this.model=null},update:function(){let r;const t=this.data;t.src&&(this.remove(),r=new THREE.ObjectLoader,t.crossorigin&&r.setCrossOrigin(t.crossorigin),r.load(t.src,e=>{e.traverse(i=>{i instanceof THREE.SkinnedMesh&&i.material&&(i.material.skinning=!!(i.geometry&&i.geometry.bones||[]).length)}),this.load(e)}))},load:function(r){this.model=r,this.el.setObject3D("mesh",r),this.el.emit("model-loaded",{format:"json",model:r})},remove:function(){this.model&&this.el.removeObject3D("mesh")}});AFRAME.registerComponent("checkpoint",{schema:{offset:{default:{x:0,y:0,z:0},type:"vec3"}},init:function(){this.active=!1,this.targetEl=null,this.fire=this.fire.bind(this),this.offset=new THREE.Vector3},update:function(){this.offset.copy(this.data.offset)},play:function(){this.el.addEventListener("click",this.fire)},pause:function(){this.el.removeEventListener("click",this.fire)},remove:function(){this.pause()},fire:function(){const r=this.el.sceneEl.querySelector("[checkpoint-controls]");if(!r)throw new Error("No `checkpoint-controls` component found.");r.components["checkpoint-controls"].setCheckpoint(this.el)},getOffset:function(){return this.offset.copy(this.data.offset)}});function iu(r){return r?Array.isArray(r)?r:r.materials?r.materials:[r]:[]}function bi(r,t,e,i){r&&(t=t||[],r.traverse(n=>{if(!n.isMesh)return;iu(n.material).forEach(o=>{o&&!("envMap"in o)||t.length&&t.indexOf(o.name)===-1||(o.envMap=e,o.reflectivity=i,o.needsUpdate=!0)})}))}AFRAME.registerComponent("cube-env-map",{multiple:!0,schema:{path:{default:""},extension:{default:"jpg",oneOf:["jpg","png"]},enableBackground:{default:!1},reflectivity:{default:1,min:0,max:1},materials:{default:[]}},init:function(){const r=this.data;this.texture=new THREE.CubeTextureLoader().load([r.path+"posx."+r.extension,r.path+"negx."+r.extension,r.path+"posy."+r.extension,r.path+"negy."+r.extension,r.path+"posz."+r.extension,r.path+"negz."+r.extension]),this.texture.format=THREE.RGBAFormat,this.object3dsetHandler=()=>{const t=this.el.getObject3D("mesh"),e=this.data;bi(t,e.materials,this.texture,e.reflectivity)},this.object3dsetHandler(),this.el.addEventListener("object3dset",this.object3dsetHandler)},update:function(r){const t=this.data,e=this.el.getObject3D("mesh");let i=[],n=[];if(t.materials.length&&(r.materials?(i=t.materials.filter(s=>!r.materials.includes(s)),n=r.materials.filter(s=>!t.materials.includes(s))):i=t.materials),i.length&&bi(e,i,this.texture,t.reflectivity),n.length&&bi(e,n,null,1),r.materials&&t.reflectivity!==r.reflectivity){const s=t.materials.filter(o=>r.materials.includes(o));s.length&&bi(e,s,this.texture,t.reflectivity)}this.data.enableBackground&&!r.enableBackground?this.setBackground(this.texture):!this.data.enableBackground&&r.enableBackground&&this.setBackground(null)},remove:function(){this.el.removeEventListener("object3dset",this.object3dsetHandler);const r=this.el.getObject3D("mesh"),t=this.data;bi(r,t.materials,null,1),t.enableBackground&&this.setBackground(null)},setBackground:function(r){this.el.sceneEl.object3D.background=r}});AFRAME.registerComponent("grab",{init:function(){this.system=this.el.sceneEl.systems.physics,this.GRABBED_STATE="grabbed",this.grabbing=!1,this.hitEl=null,this.physics=this.el.sceneEl.systems.physics,this.constraint=null,this.onHit=this.onHit.bind(this),this.onGripOpen=this.onGripOpen.bind(this),this.onGripClose=this.onGripClose.bind(this)},play:function(){const r=this.el;r.addEventListener("hit",this.onHit),r.addEventListener("gripdown",this.onGripClose),r.addEventListener("gripup",this.onGripOpen),r.addEventListener("trackpaddown",this.onGripClose),r.addEventListener("trackpadup",this.onGripOpen),r.addEventListener("triggerdown",this.onGripClose),r.addEventListener("triggerup",this.onGripOpen)},pause:function(){const r=this.el;r.removeEventListener("hit",this.onHit),r.removeEventListener("gripdown",this.onGripClose),r.removeEventListener("gripup",this.onGripOpen),r.removeEventListener("trackpaddown",this.onGripClose),r.removeEventListener("trackpadup",this.onGripOpen),r.removeEventListener("triggerdown",this.onGripClose),r.removeEventListener("triggerup",this.onGripOpen)},onGripClose:function(){this.grabbing=!0},onGripOpen:function(){const r=this.hitEl;this.grabbing=!1,r&&(r.removeState(this.GRABBED_STATE),this.hitEl=void 0,this.system.removeConstraint(this.constraint),this.constraint=null)},onHit:function(r){const t=r.detail.el;t.is(this.GRABBED_STATE)||!this.grabbing||this.hitEl||(t.addState(this.GRABBED_STATE),this.hitEl=t,this.constraint=new CANNON.LockConstraint(this.el.body,t.body),this.system.addConstraint(this.constraint))}});AFRAME.registerComponent("normal-material",{init:function(){this.material=new THREE.MeshNormalMaterial({flatShading:!0}),this.applyMaterial=this.applyMaterial.bind(this),this.el.addEventListener("object3dset",this.applyMaterial),this.applyMaterial()},remove:function(){this.el.removeEventListener("object3dset",this.applyMaterial)},applyMaterial:function(){this.el.object3D.traverse(r=>{r.isMesh&&(r.material=this.material)})}});AFRAME.registerComponent("sphere-collider",{schema:{enabled:{default:!0},interval:{default:80},objects:{default:""},state:{default:"collided"},radius:{default:.05},watch:{default:!0}},init:function(){this.observer=null,this.els=[],this.collisions=[],this.prevCheckTime=void 0,this.eventDetail={},this.handleHit=this.handleHit.bind(this),this.handleHitEnd=this.handleHitEnd.bind(this)},play:function(){const r=this.el.sceneEl;this.data.watch&&(this.observer=new MutationObserver(this.update.bind(this,null)),this.observer.observe(r,{childList:!0,subtree:!0}))},pause:function(){this.observer&&(this.observer.disconnect(),this.observer=null)},update:function(){const r=this.data;let t;r.objects?t=this.el.sceneEl.querySelectorAll(r.objects):t=this.el.sceneEl.children,this.els=Array.prototype.slice.call(t)},tick:function(){const r=new THREE.Vector3,t=new THREE.Vector3,e=new THREE.Vector3,i=new THREE.Vector3,n=new THREE.Box3,s=[],o=new Map;return function(a){if(!this.data.enabled)return;const c=this.prevCheckTime;if(c&&a-c<this.data.interval)return;this.prevCheckTime=a;const h=this.el,l=this.data,u=h.getObject3D("mesh");let d;if(!u)return;s.length=0,o.clear(),h.object3D.getWorldPosition(r),h.object3D.getWorldScale(e),d=l.radius*y(e),this.els.forEach(p),s.sort((w,v)=>o.get(w)>o.get(v)?1:-1).forEach(this.handleHit),this.collisions.filter(w=>!o.has(w)).forEach(this.handleHitEnd),nu(this.collisions,s);function p(w){let v,k,C,A;w.isEntity&&(k=w.getObject3D("mesh"),k&&(n.setFromObject(k).getSize(i),A=Math.max(i.x,i.y,i.z)/2,v=Math.sqrt(2*A*A),n.getCenter(t),v&&(C=r.distanceTo(t),C<v+d&&(s.push(w),o.set(w,C)))))}function y(w){return Math.max(w.x,w.y,w.z)}}}(),handleHit:function(r){r.emit("hit"),r.addState(this.data.state),this.eventDetail.el=r,this.el.emit("hit",this.eventDetail)},handleHitEnd:function(r){r.emit("hitend"),r.removeState(this.data.state),this.eventDetail.el=r,this.el.emit("hitend",this.eventDetail)}});function nu(r,t){r.length=0;for(let e=0;e<t.length;e++)r[e]=t[e]}AFRAME.registerComponent("nav-mesh",{schema:{nodeName:{type:"string"}},init:function(){this.system=this.el.sceneEl.systems.nav,this.hasLoadedNavMesh=!1,this.nodeName=this.data.nodeName,this.el.addEventListener("object3dset",this.loadNavMesh.bind(this))},play:function(){this.hasLoadedNavMesh||this.loadNavMesh()},loadNavMesh:function(){var r=this;const t=this.el.getObject3D("mesh");if(this.el.sceneEl.object3D,!t)return;let e;if(t.traverse(n=>{n.isMesh&&(!r.nodeName||n.name===r.nodeName)&&(e=n)}),!e)return;const i=e.geometry.clone();e.updateWorldMatrix(!0,!1),i.applyMatrix4(e.matrixWorld),this.system.setNavMeshGeometry(i),this.hasLoadedNavMesh=!0}});AFRAME.registerComponent("nav-agent",{schema:{destination:{type:"vec3"},active:{default:!1},speed:{default:2}},init:function(){this.system=this.el.sceneEl.systems.nav,this.system.addAgent(this),this.group=null,this.path=[],this.raycaster=new THREE.Raycaster},remove:function(){this.system.removeAgent(this)},update:function(){this.path.length=0},updateNavLocation:function(){this.group=null,this.path=[]},tick:function(){const r=new THREE.Vector3,t=new THREE.Vector3,e=new THREE.Vector3;return function(i,n){const s=this.el,o=this.data,a=this.raycaster,c=o.speed*n/1e3;if(!o.active)return;if(!this.path.length){const y=this.el.object3D.position;this.group=this.group||this.system.getGroup(y),this.path=this.system.getPath(y,r.copy(o.destination),this.group)||[],s.emit("navigation-start")}if(!this.path.length){console.warn("[nav] Unable to find path to %o.",o.destination),this.el.setAttribute("nav-agent",{active:!1}),s.emit("navigation-end");return}const h=s.object3D.position,l=this.path[0];t.subVectors(l,h);const u=t.length();let d;if(u<c){if(this.path.shift(),!this.path.length){this.el.setAttribute("nav-agent",{active:!1}),s.emit("navigation-end");return}e.copy(h),d=this.path[0]}else e.copy(t.setLength(c)).add(h),d=l;d.y=h.y,s.object3D.lookAt(d),a.ray.origin.copy(e),a.ray.origin.y+=1.5,a.ray.direction={x:0,y:-1,z:0};const p=a.intersectObject(this.system.getNavMesh());p.length?(t.subVectors(p[0].point,h),h.add(t.setLength(c))):h.copy(e)}}()});class wt{static roundNumber(t,e){const i=Math.pow(10,e);return Math.round(t*i)/i}static sample(t){return t[Math.floor(Math.random()*t.length)]}static distanceToSquared(t,e){var i=t.x-e.x,n=t.y-e.y,s=t.z-e.z;return i*i+n*n+s*s}static isPointInPoly(t,e){for(var i=!1,n=-1,s=t.length,o=s-1;++n<s;o=n)(t[n].z<=e.z&&e.z<t[o].z||t[o].z<=e.z&&e.z<t[n].z)&&e.x<(t[o].x-t[n].x)*(e.z-t[n].z)/(t[o].z-t[n].z)+t[n].x&&(i=!i);return i}static isVectorInPolygon(t,e,i){var n=1e5,s=-1e5,o=[];return e.vertexIds.forEach(a=>{n=Math.min(i[a].y,n),s=Math.max(i[a].y,s),o.push(i[a])}),!!(t.y<s+.5&&t.y>n-.5&&this.isPointInPoly(o,t))}static triarea2(t,e,i){return(i.x-t.x)*(e.z-t.z)-(e.x-t.x)*(i.z-t.z)}static vequal(t,e){return this.distanceToSquared(t,e)<1e-5}static mergeVertices(t,e=1e-4){e=Math.max(e,Number.EPSILON);for(var i={},n=t.getIndex(),s=t.getAttribute("position"),o=n?n.count:s.count,a=0,c=[],h=[],l=Math.log10(1/e),u=Math.pow(10,l),d=0;d<o;d++){var p=n?n.getX(d):d,y="";y+=~~(s.getX(p)*u)+",",y+=~~(s.getY(p)*u)+",",(y+=~~(s.getZ(p)*u)+",")in i?c.push(i[y]):(h.push(s.getX(p)),h.push(s.getY(p)),h.push(s.getZ(p)),i[y]=a,c.push(a),a++)}const w=new Ne(new Float32Array(h),s.itemSize,s.normalized),v=new me;return v.setAttribute("position",w),v.setIndex(c),v}}class su{constructor(t){this.content=[],this.scoreFunction=t}push(t){this.content.push(t),this.sinkDown(this.content.length-1)}pop(){const t=this.content[0],e=this.content.pop();return this.content.length>0&&(this.content[0]=e,this.bubbleUp(0)),t}remove(t){const e=this.content.indexOf(t),i=this.content.pop();e!==this.content.length-1&&(this.content[e]=i,this.scoreFunction(i)<this.scoreFunction(t)?this.sinkDown(e):this.bubbleUp(e))}size(){return this.content.length}rescoreElement(t){this.sinkDown(this.content.indexOf(t))}sinkDown(t){const e=this.content[t];for(;t>0;){const i=(t+1>>1)-1,n=this.content[i];if(!(this.scoreFunction(e)<this.scoreFunction(n)))break;this.content[i]=e,this.content[t]=n,t=i}}bubbleUp(t){const e=this.content.length,i=this.content[t],n=this.scoreFunction(i);for(;;){const s=t+1<<1,o=s-1;let a,c=null;if(o<e&&(a=this.scoreFunction(this.content[o]),a<n&&(c=o)),s<e&&this.scoreFunction(this.content[s])<(c===null?n:a)&&(c=s),c===null)break;this.content[t]=this.content[c],this.content[c]=i,t=c}}}class ru{constructor(){this.portals=[]}push(t,e){e===void 0&&(e=t),this.portals.push({left:t,right:e})}stringPull(){const t=this.portals,e=[];let i,n,s,o=0,a=0,c=0;i=t[0].left,n=t[0].left,s=t[0].right,e.push(i);for(let h=1;h<t.length;h++){const l=t[h].left,u=t[h].right;if(wt.triarea2(i,s,u)<=0){if(!(wt.vequal(i,s)||wt.triarea2(i,n,u)>0)){e.push(n),i=n,o=a,n=i,s=i,a=o,c=o,h=o;continue}s=u,c=h}if(wt.triarea2(i,n,l)>=0){if(!(wt.vequal(i,n)||wt.triarea2(i,s,l)<0)){e.push(s),i=s,o=c,n=i,s=i,a=o,c=o,h=o;continue}n=l,a=h}}return e.length!==0&&wt.vequal(e[e.length-1],t[t.length-1].left)||e.push(t[t.length-1].left),this.path=e,e}}class Sn{constructor(){this.zones={}}static createZone(t,e=1e-4){return(class{static buildZone(i,n){const s=this._buildNavigationMesh(i,n),o={};s.vertices.forEach(c=>{c.x=wt.roundNumber(c.x,2),c.y=wt.roundNumber(c.y,2),c.z=wt.roundNumber(c.z,2)}),o.vertices=s.vertices;const a=this._buildPolygonGroups(s);return o.groups=new Array(a.length),a.forEach((c,h)=>{const l=new Map;c.forEach((d,p)=>{l.set(d,p)});const u=new Array(c.length);c.forEach((d,p)=>{const y=[];d.neighbours.forEach(k=>y.push(l.get(k)));const w=[];d.neighbours.forEach(k=>w.push(this._getSharedVerticesInOrder(d,k)));const v=new M(0,0,0);v.add(o.vertices[d.vertexIds[0]]),v.add(o.vertices[d.vertexIds[1]]),v.add(o.vertices[d.vertexIds[2]]),v.divideScalar(3),v.x=wt.roundNumber(v.x,2),v.y=wt.roundNumber(v.y,2),v.z=wt.roundNumber(v.z,2),u[p]={id:p,neighbours:y,vertexIds:d.vertexIds,centroid:v,portals:w}}),o.groups[h]=u}),o}static _buildNavigationMesh(i,n){return i=wt.mergeVertices(i,n),this._buildPolygonsFromGeometry(i)}static _spreadGroupId(i){let n=new Set([i]);for(;n.size>0;){const s=n;n=new Set,s.forEach(o=>{o.group=i.group,o.neighbours.forEach(a=>{a.group===void 0&&n.add(a)})})}}static _buildPolygonGroups(i){const n=[];return i.polygons.forEach(s=>{s.group!==void 0?n[s.group].push(s):(s.group=n.length,this._spreadGroupId(s),n.push([s]))}),n}static _buildPolygonNeighbours(i,n){const s=new Set,o=n[i.vertexIds[1]],a=n[i.vertexIds[2]];return n[i.vertexIds[0]].forEach(c=>{c!==i&&(o.includes(c)||a.includes(c))&&s.add(c)}),o.forEach(c=>{c!==i&&a.includes(c)&&s.add(c)}),s}static _buildPolygonsFromGeometry(i){const n=[],s=[],o=i.attributes.position,a=i.index,c=[];for(let h=0;h<o.count;h++)s.push(new M().fromBufferAttribute(o,h)),c[h]=[];for(let h=0;h<i.index.count;h+=3){const l=a.getX(h),u=a.getX(h+1),d=a.getX(h+2),p={vertexIds:[l,u,d],neighbours:null};n.push(p),c[l].push(p),c[u].push(p),c[d].push(p)}return n.forEach(h=>{h.neighbours=this._buildPolygonNeighbours(h,c)}),{polygons:n,vertices:s}}static _getSharedVerticesInOrder(i,n){const s=i.vertexIds,o=s[0],a=s[1],c=s[2],h=n.vertexIds,l=h.includes(o),u=h.includes(a),d=h.includes(c);return l&&u&&d?Array.from(s):l&&u?[o,a]:u&&d?[a,c]:l&&d?[c,o]:(console.warn("Error processing navigation mesh neighbors; neighbors with <2 shared vertices found."),[])}}).buildZone(t,e)}setZoneData(t,e){this.zones[t]=e}getRandomNode(t,e,i,n){if(!this.zones[t])return new M;i=i||null,n=n||0;const s=[];return this.zones[t].groups[e].forEach(o=>{i&&n?wt.distanceToSquared(i,o.centroid)<n*n&&s.push(o.centroid):s.push(o.centroid)}),wt.sample(s)||new M}getClosestNode(t,e,i,n=!1){const s=this.zones[e].vertices;let o=null,a=1/0;return this.zones[e].groups[i].forEach(c=>{const h=wt.distanceToSquared(c.centroid,t);h<a&&(!n||wt.isVectorInPolygon(t,c,s))&&(o=c,a=h)}),o}findPath(t,e,i,n){const s=this.zones[i].groups[n],o=this.zones[i].vertices,a=this.getClosestNode(t,i,n,!0),c=this.getClosestNode(e,i,n,!0);if(!a||!c)return null;const h=(class{static init(p){for(let y=0;y<p.length;y++){const w=p[y];w.f=0,w.g=0,w.h=0,w.cost=1,w.visited=!1,w.closed=!1,w.parent=null}}static cleanUp(p){for(let y=0;y<p.length;y++){const w=p[y];delete w.f,delete w.g,delete w.h,delete w.cost,delete w.visited,delete w.closed,delete w.parent}}static heap(){return new su(function(p){return p.f})}static search(p,y,w){this.init(p);const v=this.heap();for(v.push(y);v.size()>0;){const k=v.pop();if(k===w){let A=k;const T=[];for(;A.parent;)T.push(A),A=A.parent;return this.cleanUp(T),T.reverse()}k.closed=!0;const C=this.neighbours(p,k);for(let A=0,T=C.length;A<T;A++){const _=C[A];if(_.closed)continue;const z=k.g+_.cost,F=_.visited;if(!F||z<_.g){if(_.visited=!0,_.parent=k,!_.centroid||!w.centroid)throw new Error("Unexpected state");_.h=_.h||this.heuristic(_.centroid,w.centroid),_.g=z,_.f=_.g+_.h,F?v.rescoreElement(_):v.push(_)}}}return[]}static heuristic(p,y){return wt.distanceToSquared(p,y)}static neighbours(p,y){const w=[];for(let v=0;v<y.neighbours.length;v++)w.push(p[y.neighbours[v]]);return w}}).search(s,a,c),l=function(p,y){for(var w=0;w<p.neighbours.length;w++)if(p.neighbours[w]===y.id)return p.portals[w]},u=new ru;u.push(t);for(let p=0;p<h.length;p++){const y=h[p],w=h[p+1];if(w){const v=l(y,w);u.push(o[v[0]],o[v[1]])}}u.push(e),u.stringPull();const d=u.path.map(p=>new M(p.x,p.y,p.z));return d.shift(),d}}Sn.prototype.getGroup=function(){const r=new Te;return function(t,e,i=!1){if(!this.zones[t])return null;let n=null,s=Math.pow(50,2);const o=this.zones[t];for(let a=0;a<o.groups.length;a++){const c=o.groups[a];for(const h of c){if(i&&(r.setFromCoplanarPoints(o.vertices[h.vertexIds[0]],o.vertices[h.vertexIds[1]],o.vertices[h.vertexIds[2]]),Math.abs(r.distanceToPoint(e))<.01)&&wt.isPointInPoly([o.vertices[h.vertexIds[0]],o.vertices[h.vertexIds[1]],o.vertices[h.vertexIds[2]]],e))return a;const l=wt.distanceToSquared(h.centroid,e);l<s&&(n=a,s=l)}}return n}}(),Sn.prototype.clampStep=function(){const r=new M,t=new Te,e=new ee,i=new M;let n,s,o=new M;return function(a,c,h,l,u,d){const p=this.zones[l].vertices,y=this.zones[l].groups[u],w=[h],v={};v[h.id]=0,n=void 0,o.set(0,0,0),s=1/0,t.setFromCoplanarPoints(p[h.vertexIds[0]],p[h.vertexIds[1]],p[h.vertexIds[2]]),t.projectPoint(c,r),i.copy(r);for(let k=w.pop();k;k=w.pop()){e.set(p[k.vertexIds[0]],p[k.vertexIds[1]],p[k.vertexIds[2]]),e.closestPointToPoint(i,r),r.distanceToSquared(i)<s&&(n=k,o.copy(r),s=r.distanceToSquared(i));const C=v[k.id];if(!(C>2))for(let A=0;A<k.neighbours.length;A++){const T=y[k.neighbours[A]];T.id in v||(w.push(T),v[T.id]=C+1)}}return d.copy(o),n}}();const wi=new Sn,vi="level";AFRAME.registerSystem("nav",{init:function(){this.navMesh=null,this.agents=new Set},setNavMeshGeometry:function(r){this.navMesh=new THREE.Mesh(r),wi.setZoneData(vi,Sn.createZone(r)),Array.from(this.agents).forEach(t=>t.updateNavLocation())},getNavMesh:function(){return this.navMesh},addAgent:function(r){this.agents.add(r)},removeAgent:function(r){this.agents.delete(r)},getPath:function(r,t,e){return this.navMesh?wi.findPath(r,t,vi,e):null},getGroup:function(r){return this.navMesh?wi.getGroup(vi,r):null},getNode:function(r,t){return this.navMesh?wi.getClosestNode(r,vi,t,!0):null},clampStep:function(r,t,e,i,n){if(this.navMesh){if(!i)return n.copy(t),this.getNode(t,e)}else return n.copy(t),null;return wi.clampStep(r,t,i,vi,e,n)}});AFRAME.registerPrimitive("a-grid",{defaultComponents:{geometry:{primitive:"plane",width:75,height:75},rotation:{x:-90,y:0,z:0},material:{src:"url(https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v1.16.3/assets/grid.png)",repeat:"75 75"}},mappings:{width:"geometry.width",height:"geometry.height",src:"material.src"}});AFRAME.registerPrimitive("a-ocean",{defaultComponents:{ocean:{},rotation:{x:-90,y:0,z:0}},mappings:{width:"ocean.width",depth:"ocean.depth",density:"ocean.density",amplitude:"ocean.amplitude",amplitudeVariance:"ocean.amplitudeVariance",speed:"ocean.speed",speedVariance:"ocean.speedVariance",color:"ocean.color",opacity:"ocean.opacity"}});AFRAME.registerComponent("ocean",{schema:{width:{default:10,min:0},depth:{default:10,min:0},density:{default:10},amplitude:{default:.1},amplitudeVariance:{default:.3},speed:{default:1},speedVariance:{default:2},color:{default:"#7AD2F7",type:"color"},opacity:{default:.8}},play:function(){const r=this.el,t=this.data;let e=r.components.material;const i=new THREE.PlaneGeometry(t.width,t.depth,t.density,t.density);this.waves=[];const n=i.getAttribute("position");for(let s=0;s<n.count;s++)this.waves.push({z:n.getZ(s),ang:Math.random()*Math.PI*2,amp:t.amplitude+Math.random()*t.amplitudeVariance,speed:(t.speed+Math.random()*t.speedVariance)/1e3});e||(e={},e.material=new THREE.MeshPhongMaterial({color:t.color,transparent:t.opacity<1,opacity:t.opacity,flatShading:!0})),this.mesh=new THREE.Mesh(i,e.material),r.setObject3D("mesh",this.mesh)},remove:function(){this.el.removeObject3D("mesh")},tick:function(r,t){if(!t)return;const e=this.mesh.geometry.getAttribute("position");for(let i=0;i<e.count;i++){const n=this.waves[i],s=n.z+Math.sin(n.ang)*n.amp;e.setZ(i,s),n.ang+=n.speed*t}e.needsUpdate=!0}});AFRAME.registerPrimitive("a-tube",{defaultComponents:{tube:{}},mappings:{path:"tube.path",segments:"tube.segments",radius:"tube.radius","radial-segments":"tube.radialSegments",closed:"tube.closed"}});AFRAME.registerComponent("tube",{schema:{path:{default:[]},segments:{default:64},radius:{default:1},radialSegments:{default:8},closed:{default:!1}},init:function(){const r=this.el,t=this.data;let e=r.components.material;if(!t.path.length){console.error("[a-tube] `path` property expected but not found.");return}const i=new THREE.CatmullRomCurve3(t.path.map(function(s){return s=s.split(" "),new THREE.Vector3(Number(s[0]),Number(s[1]),Number(s[2]))})),n=new THREE.TubeGeometry(i,t.segments,t.radius,t.radialSegments,t.closed);e||(e={},e.material=new THREE.MeshPhongMaterial),this.mesh=new THREE.Mesh(n,e.material),this.el.setObject3D("mesh",this.mesh)},update:function(r){Object.keys(r).length&&(this.remove(),this.init())},remove:function(){this.mesh&&this.el.removeObject3D("mesh")}});function ou(r,t){t===void 0&&(t={});var e=t.insertAt;if(!(typeof document>"u")){var i=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css",e==="top"&&i.firstChild?i.insertBefore(n,i.firstChild):i.appendChild(n),n.styleSheet?n.styleSheet.cssText=r:n.appendChild(document.createTextNode(r))}}var au=`.graph-nav-info {
position: absolute;
bottom: 5px;
width: 100%;
text-align: center;
color: slategrey;
opacity: 0.7;
font-size: 10px;
font-family: Sans-serif;
z-index: 1000;
}`;ou(au);function Is(r,t){(t==null||t>r.length)&&(t=r.length);for(var e=0,i=Array(t);e<t;e++)i[e]=r[e];return i}function cu(r){if(Array.isArray(r))return r}function hu(r){if(Array.isArray(r))return Is(r)}function Mi(r,t,e){return(t=mu(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e,r}function lu(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function uu(r,t){var e=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(e!=null){var i,n,s,o,a=[],c=!0,h=!1;try{if(s=(e=e.call(r)).next,t!==0)for(;!(c=(i=s.call(e)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(l){h=!0,n=l}finally{try{if(!c&&e.return!=null&&(o=e.return(),Object(o)!==o))return}finally{if(h)throw n}}return a}}function du(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function pu(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function To(r,t){var e=Object.keys(r);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(r);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),e.push.apply(e,i)}return e}function _o(r){for(var t=1;t<arguments.length;t++){var e=arguments[t]!=null?arguments[t]:{};t%2?To(Object(e),!0).forEach(function(i){Mi(r,i,e[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(e)):To(Object(e)).forEach(function(i){Object.defineProperty(r,i,Object.getOwnPropertyDescriptor(e,i))})}return r}function bs(r,t){return cu(r)||uu(r,t)||la(r,t)||du()}function fn(r){return hu(r)||lu(r)||la(r)||pu()}function fu(r,t){if(typeof r!="object"||!r)return r;var e=r[Symbol.toPrimitive];if(e!==void 0){var i=e.call(r,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(r)}function mu(r){var t=fu(r,"string");return typeof t=="symbol"?t:t+""}function la(r,t){if(r){if(typeof r=="string")return Is(r,t);var e={}.toString.call(r).slice(8,-1);return e==="Object"&&r.constructor&&(e=r.constructor.name),e==="Map"||e==="Set"?Array.from(r):e==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?Is(r,t):void 0}}var yu=lc({props:{width:{default:window.innerWidth,triggerUpdate:!1,onChange:function(t,e){e.container&&(e.container.style.width="".concat(t,"px"))}},height:{default:window.innerHeight,triggerUpdate:!1,onChange:function(t,e){e.container&&(e.container.style.height="".concat(t,"px"))}},jsonUrl:{},graphData:{default:{nodes:[],links:[]}},numDimensions:{default:3},dagMode:{},dagLevelDistance:{},dagNodeFilter:{default:function(){return!0}},onDagError:{default:void 0},backgroundColor:{default:"#002"},showNavInfo:{default:!0},nodeRelSize:{default:4},nodeId:{default:"id"},nodeLabel:{default:"name"},nodeDesc:{default:"desc"},onNodeHover:{},onNodeClick:{},nodeVal:{default:"val"},nodeResolution:{default:8},nodeVisibility:{default:!0},nodeColor:{default:"color"},nodeAutoColorBy:{},nodeOpacity:{default:.75},nodeThreeObject:{},nodeThreeObjectExtend:{default:!1},linkSource:{default:"source"},linkTarget:{default:"target"},linkLabel:{default:"name"},linkDesc:{default:"desc"},onLinkHover:{},onLinkClick:{},linkVisibility:{default:!0},linkColor:{default:"color"},linkAutoColorBy:{},linkOpacity:{default:.2},linkWidth:{default:0},linkResolution:{default:6},linkCurvature:{default:0},linkCurveRotation:{default:0},linkMaterial:{},linkThreeObject:{},linkThreeObjectExtend:{default:!1},linkPositionUpdate:{},linkDirectionalArrowLength:{default:0},linkDirectionalArrowColor:{},linkDirectionalArrowRelPos:{default:.5},linkDirectionalArrowResolution:{default:8},linkDirectionalParticles:{default:0},linkDirectionalParticleSpeed:{default:.01},linkDirectionalParticleWidth:{default:.5},linkDirectionalParticleColor:{},linkDirectionalParticleResolution:{default:4},forceEngine:{default:"d3"},d3AlphaMin:{default:0},d3AlphaDecay:{default:.0228},d3VelocityDecay:{default:.4},ngraphPhysics:{},warmupTicks:{default:0},cooldownTicks:{},cooldownTime:{default:15e3},onEngineTick:{},onEngineStop:{}},methods:_o(_o({},Object.assign.apply(Object,[{}].concat(fn(["getGraphBbox","emitParticle","d3Force","d3ReheatSimulation","refresh"].map(function(r){return Mi({},r,function(t){for(var e=t.forcegraph.components.forcegraph,i=arguments.length,n=new Array(i>1?i-1:0),s=1;s<i;s++)n[s-1]=arguments[s];var o=e[r].apply(e,n);return o===e?this:o})}))))),{},{_destructor:function(){this.graphData({nodes:[],links:[]})}}),init:function(t,e){t.innerHTML="",e.container=document.createElement("div"),t.appendChild(e.container),e.container.style.position="relative",e.container.style.width="".concat(e.width,"px"),e.container.style.height="".concat(e.height,"px"),e.container.appendChild(e.navInfo=document.createElement("div")),e.navInfo.className="graph-nav-info",e.navInfo.textContent="Mouse drag: look, gamepad/arrow/wasd keys: move";var i=document.createElement("a-scene");i.setAttribute("embedded",""),i.appendChild(e.sky=document.createElement("a-sky")),e.sky.setAttribute("radius",3e3);var n;i.appendChild(n=document.createElement("a-entity")),n.setAttribute("position","0 0 300"),n.setAttribute("movement-controls","controls: gamepad, touch; fly: true; speed: 7");var s;n.appendChild(s=document.createElement("a-entity")),s.setAttribute("camera",""),s.setAttribute("position","0 0 0"),s.setAttribute("look-controls","pointerLockEnabled: false"),s.setAttribute("wasd-controls","fly: true; acceleration: 700");var o;s.appendChild(o=document.createElement("a-text")),o.setAttribute("position","0 -0.3 -1"),o.setAttribute("width",2),o.setAttribute("align","center"),o.setAttribute("color","lavender"),o.setAttribute("value","");var a;s.appendChild(a=document.createElement("a-text")),a.setAttribute("position","0 -0.4 -1"),a.setAttribute("width",1.3),a.setAttribute("align","center"),a.setAttribute("color","lavender"),a.setAttribute("value",""),e.raycasterEls=[];var c;i.appendChild(c=document.createElement("a-entity")),c.setAttribute("cursor","rayOrigin: mouse; mouseCursorStylesEnabled: true"),c.setAttribute("raycaster","objects: [forcegraph]; interval: 100"),e.raycasterEls.push(c),["left","right"].forEach(function(h){var l;n.appendChild(l=document.createElement("a-entity")),l.setAttribute("laser-controls","hand: ".concat(h,"; model: false;")),l.setAttribute("raycaster","objects: [forcegraph]; interval: 100; lineColor: steelblue; lineOpacity: 0.85"),e.raycasterEls.push(l)}),i.appendChild(e.forcegraph=document.createElement("a-entity")),e.forcegraph.setAttribute("forcegraph",null),e.container.appendChild(i),e.forcegraph.setAttribute("forcegraph",Object.assign.apply(Object,fn(["node","link"].map(function(h){var l={node:"Node",link:"Link"}[h];return Mi({},"on".concat(l,"Hover"),function(d,p){var y=d&&mr(e["".concat(h,"Label")])(d)||"",w=d&&mr(e["".concat(h,"Desc")])(d)||"";o.setAttribute("value",y),a.setAttribute("value",w),e["on".concat(l,"Hover")]&&e["on".concat(l,"Hover")](d,p)})}))))},update:function(t,e){if(e.hasOwnProperty("backgroundColor")){var i=uc(t.backgroundColor).alpha;i===void 0&&(i=1),t.sky.setAttribute("color",dc(1,t.backgroundColor)),t.sky.setAttribute("opacity",i)}e.hasOwnProperty("showNavInfo")&&(t.navInfo.style.display=t.showNavInfo?null:"none");var n=["onNodeHover","onLinkHover","onNodeClick","onLinkClick"].some(function(a){return t[a]})||["nodeLabel","linkLabel"].some(function(a){return t[a]!=="name"})||["nodeDesc","linkDesc"].some(function(a){return t[a]!=="desc"});t.raycasterEls.forEach(function(a){return a.setAttribute("raycaster",n?"objects: [forcegraph]; interval: 100":"objects: __none__")});var s=["jsonUrl","numDimensions","dagMode","dagLevelDistance","dagNodeFilter","onDagError","nodeRelSize","nodeId","onNodeClick","nodeVal","nodeResolution","nodeVisibility","nodeColor","nodeAutoColorBy","nodeOpacity","nodeThreeObject","nodeThreeObjectExtend","linkSource","linkTarget","onLinkClick","linkVisibility","linkColor","linkAutoColorBy","linkOpacity","linkWidth","linkResolution","linkCurvature","linkCurveRotation","linkMaterial","linkThreeObject","linkThreeObjectExtend","linkPositionUpdate","linkDirectionalArrowLength","linkDirectionalArrowColor","linkDirectionalArrowRelPos","linkDirectionalArrowResolution","linkDirectionalParticles","linkDirectionalParticleSpeed","linkDirectionalParticleWidth","linkDirectionalParticleColor","linkDirectionalParticleResolution","forceEngine","d3AlphaMin","d3AlphaDecay","d3VelocityDecay","ngraphPhysics","warmupTicks","cooldownTicks","cooldownTime","onEngineTick","onEngineStop"],o=Object.assign.apply(Object,[{}].concat(fn(Object.entries(t).filter(function(a){var c=bs(a,2),h=c[0],l=c[1];return e.hasOwnProperty(h)&&s.indexOf(h)!==-1&&l!==void 0&&l!==null}).map(function(a){var c=bs(a,2),h=c[0],l=c[1];return Mi({},h,l)})),fn(Object.entries(t.graphData).map(function(a){var c=bs(a,2),h=c[0],l=c[1];return Mi({},h,l)}))));t.forcegraph.setAttribute("forcegraph",o)}});function ku(r){const t=r.instance||yu(),e=getComputedStyle(r.element);return r.instance||t(r.element),t.graphData(r.data).width(Number(e.width.slice(0,-2))||window.innerWidth).height(Number(e.height.slice(0,-2))||window.innerHeight).showNavInfo(!1).cooldownTicks(100),t}export{ku as render};