@j-kyoda/vue-three-vrm 0.5.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vue-three-vrm.es.js +155 -143
- package/dist/vue-three-vrm.umd.js +2 -2
- package/package.json +5 -5
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(function(A,
|
|
2
|
-
/*$vite$:1*/`,document.head.appendChild($);function fe(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const D=fe(h);class V{constructor(){this.status=0,this.url=null,this.data=null}is_loaded(){return this.status==2}is_failed(){return this.status==3}async loadUrl(e,t){this.url=t,this.data=null,this.status=1;const n=await e.get(t);return n.status!=200?(this.status=3,null):n.data?(this.data=n.data,this.status=2,this.data):(this.status=3,null)}async loadPose(e,t){const n=await this.loadUrl(e,t);return n==null?null:"pose"in n?(this.data=n.pose,this.data):this.data}async loadExpression(e,t){const n=await this.loadUrl(e,t);return n==null?null:"expressions"in n?(this.data=n.expressions,this.data):this.data}}class J{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,n,s){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=n,i.rotation.z=s)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,n,s){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=n,i.position.z=s)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const n in t)e[n]=this.getExpression(n);return e}return null}}class H{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),n=window.WebGL2RenderingContext&&t.getContext("webgl2");return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let s='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",n[e]?s=s.replace("$0","graphics card"):s=s.replace("$0","browser"),s=s.replace("$1",t[e]),i.innerHTML=s,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}const ee={type:"change"},K={type:"start"},te={type:"end"},B=new h.Ray,se=new h.Plane,me=Math.cos(70*h.MathUtils.DEG2RAD),w=new h.Vector3,P=2*Math.PI,T={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},E=1e-6;class _e extends h.Controls{constructor(e,t=null){super(e,t),this.state=T.NONE,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ye.bind(this),this._onPointerDown=ge.bind(this),this._onPointerUp=xe.bind(this),this._onContextMenu=Ae.bind(this),this._onMouseWheel=Te.bind(this),this._onKeyDown=Se.bind(this),this._onTouchStart=Le.bind(this),this._onTouchMove=we.bind(this),this._onMouseDown=be.bind(this),this._onMouseMove=Me.bind(this),this._interceptControlDown=Pe.bind(this),this._interceptControlUp=Oe.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ee),this.update(),this.state=T.NONE}update(e=null){const t=this.object.position;w.copy(t).sub(this.target),w.applyQuaternion(this._quat),this._spherical.setFromVector3(w),this.autoRotate&&this.state===T.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(w.setFromSpherical(this._spherical),w.applyQuaternion(this._quatInverse),t.copy(this.target).add(w),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const r=w.length();o=this._clampDistance(r*this._scale);const a=r-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const r=new h.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(r),this.object.updateMatrixWorld(),o=w.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(B.origin.copy(this.object.position),B.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(B.direction))<me?this.object.lookAt(this.target):(se.setFromNormalAndCoplanarPoint(this.object.up,this.target),B.intersectPlane(se,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>E||8*(1-this._lastQuaternion.dot(this.object.quaternion))>E||this._lastTargetPosition.distanceToSquared(this.target)>E?(this.dispatchEvent(ee),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){w.setFromMatrixColumn(t,0),w.multiplyScalar(-e),this._panOffset.add(w)}_panUp(e,t){this.screenSpacePanning===!0?w.setFromMatrixColumn(t,1):(w.setFromMatrixColumn(t,0),w.crossVectors(this.object.up,w)),w.multiplyScalar(e),this._panOffset.add(w)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;w.copy(s).sub(this.target);let i=w.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,i=t-n.top,o=n.width,r=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(i/r)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateEnd.set(s,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,r=(e.pageY+t.y)*.5;this._updateZoomParameters(o,r)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new h.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function ge(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function ye(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function xe(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(te),this.state=T.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function be(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=T.DOLLY;break;case h.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=T.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=T.ROTATE}break;case h.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=T.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=T.PAN}break;default:this.state=T.NONE}this.state!==T.NONE&&this.dispatchEvent(K)}function Me(l){switch(this.state){case T.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case T.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case T.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function Te(l){this.enabled===!1||this.enableZoom===!1||this.state!==T.NONE||(l.preventDefault(),this.dispatchEvent(K),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(te))}function Se(l){this.enabled!==!1&&this._handleKeyDown(l)}function Le(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=T.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=T.TOUCH_PAN;break;default:this.state=T.NONE}break;case 2:switch(this.touches.TWO){case h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=T.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=T.TOUCH_DOLLY_ROTATE;break;default:this.state=T.NONE}break;default:this.state=T.NONE}this.state!==T.NONE&&this.dispatchEvent(K)}function we(l){switch(this._trackPointer(l),this.state){case T.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case T.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case T.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case T.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=T.NONE}}function Ae(l){this.enabled!==!1&&l.preventDefault()}function Pe(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Oe(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ne=((l,e)=>{const t=l.__vccOpts||l;for(const[n,s]of e)t[n]=s;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["init","animate"],setup(l,{emit:e}){const t=e,n=l,s="dom"+S.getCurrentInstance().uid,i=S.useTemplateRef(s);let o=null,r=null,a=null,c=null,u=null;const d=()=>{t("animate",{scene:r,camera:a,renderer:c,controls:u}),o!=null&&(cancelAnimationFrame(o),o=null),n.animation&&(o=requestAnimationFrame(d)),c.render(r,a)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(d)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};S.watch(()=>n.animation,y=>{y==!0?p():f()});const _=()=>{const y=i.value,m=y.clientWidth,g=y.clientHeight,M={antialias:!0,alpha:!1};if(D.ColorManagement.enabled=!1,c=new D.WebGLRenderer(M),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,g),c.setClearColor(8372223,1),c.outputColorSpace=D.SRGBColorSpace,y.appendChild(c.domElement),r=new D.Scene,a=new D.PerspectiveCamera(45,m/g,.1,1e3),a.position.set(0,1.25,1),n.useOrbitControls&&(u=new _e(a,y),u.screenSpacePanning=!0,u.target.set(0,1.25,0),u.update()),n.useGridHelper){const x=new D.GridHelper(10,10);r.add(x),x.visible=!0}if(n.useAxesHelper){const x=new D.AxesHelper(5);r.add(x)}if(n.useDefaultLight){const x=new D.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),r.add(x);const N=new D.AmbientLight(4210752);r.add(N)}t("init",{scene:r,camera:a,renderer:c,controls:u})};return S.onMounted(async()=>{if(!H.isWebGL2Available()){const m=H.getWebGLErrorMessage();console.error(m);return}const y=()=>{const m=i.value,g=m.clientWidth,M=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(g,M),a.aspect=g/M,a.updateProjectionMatrix()};window.addEventListener("resize",y),_()}),(y,m)=>(S.openBlock(),S.createElementBlock("div",{ref:s,class:"box"}))}},[["__scopeId","data-v-1ac174e9"]]),ne={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=S.inject("axios"),n=e,s=l,i=async r=>{if(!r)return;n("loading",s.name,s.command);const c=await new V().loadExpression(t,r);let u=!1;c&&(u=!0),n("loaded",s.name,s.command,u,c)},o=r=>{n("loading",s.name,s.command);let a=!1;r&&(a=!0),n("loaded",s.name,s.command,a,r)};return S.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),(r,a)=>null}},ie={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=S.inject("axios"),n=e,s=l,i=async r=>{if(!r)return;n("loading",s.name,s.command);const c=await new V().loadPose(t,r);let u=!1;c&&(u=!0),n("loaded",s.name,s.command,u,c)},o=r=>{n("loading",s.name,s.command);let a=!1;r&&(a=!0),n("loaded",s.name,s.command,a,r)};return S.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),(r,a)=>null}};function oe(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=t.count-2,s=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class Ce extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ve(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Be(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new ke(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Ze(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const r=function(c){s?s(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},a=new h.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{i.parse(c,o,function(u){t(u),i.manager.itemEnd(e)},r)}catch(u){r(u)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const o={},r={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===re){try{o[b.KHR_BINARY_GLTF]=new Qe(e)}catch(d){s&&s(d);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new lt(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[d.name]=d,o[d.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const d=i.extensionsUsed[u],p=i.extensionsRequired||[];switch(d){case b.KHR_MATERIALS_UNLIT:o[d]=new Re;break;case b.KHR_DRACO_MESH_COMPRESSION:o[d]=new $e(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[d]=new Je;break;case b.KHR_MESH_QUANTIZATION:o[d]=new He;break;default:p.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(r),c.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function De(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ie{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const u=new h.Color(16777215);a.color!==void 0&&u.setRGB(a.color[0],a.color[1],a.color[2],h.LinearSRGBColorSpace);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new h.DirectionalLight(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(u),c.distance=d;break;case"spot":c=new h.SpotLight(u),c.distance=d,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),I(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class Re{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new h.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(s)}}class ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(i)}}class je{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Fe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Ue{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){const r=o.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Ee{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class We{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let a=n.textureLoader;if(r.uri){const c=n.options.manager.getHandler(r.uri);c!==null&&(a=c)}return n.loadTextureImage(e,o.source,a)}}class Ye{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let a=n.textureLoader;if(r.uri){const c=n.options.manager.getHandler(r.uri);c!==null&&(a=c)}return n.loadTextureImage(e,o.source,a)}}class qe{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=s.byteOffset||0,c=s.byteLength||0,u=s.count,d=s.byteStride,p=new Uint8Array(r,a,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,d,p,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(u*d);return o.decodeGltfBuffer(new Uint8Array(f),u,d,p,s.mode,s.filter),f})})}else return null}}class Ze{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,r=[],a={};for(const c in o)r.push(this.parser.getDependency("accessor",o[c]).then(u=>(a[c]=u,a[c])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(c=>{const u=c.pop(),d=u.isGroup?u.children:[u],p=c[0].count,f=[];for(const _ of d){const y=new h.Matrix4,m=new h.Vector3,g=new h.Quaternion,M=new h.Vector3(1,1,1),L=new h.InstancedMesh(_.geometry,_.material,p);for(let x=0;x<p;x++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,x),a.ROTATION&&g.fromBufferAttribute(a.ROTATION,x),a.SCALE&&M.fromBufferAttribute(a.SCALE,x),L.setMatrixAt(x,y.compose(m,g,M));for(const x in a)if(x==="_COLOR_0"){const N=a[x];L.instanceColor=new h.InstancedBufferAttribute(N.array,N.itemSize,N.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&_.geometry.setAttribute(x,a[x]);h.Object3D.prototype.copy.call(L,_),this.parser.assignFinalMaterial(L),f.push(L)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const re="glTF",U=12,ae={JSON:1313821514,BIN:5130562};class Qe{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,U),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==re)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-U,i=new DataView(e,U);let o=0;for(;o<s;){const r=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===ae.JSON){const c=new Uint8Array(e,U+o,r);this.content=n.decode(c)}else if(a===ae.BIN){const c=U+o;this.body=e.slice(c,c+r)}o+=r}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class $e{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},c={};for(const u in o){const d=X[u]||u.toLowerCase();r[d]=o[u]}for(const u in e.attributes){const d=X[u]||u.toLowerCase();if(o[u]!==void 0){const p=n.accessors[e.attributes[u]],f=F[p.componentType];c[d]=f.name,a[d]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(d,p){s.decodeDracoFile(u,function(f){for(const _ in f.attributes){const y=f.attributes[_],m=a[_];m!==void 0&&(y.normalized=m)}d(f)},r,c,h.LinearSRGBColorSpace,p)})})}}class Je{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class He{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ce extends h.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,c=r*3,u=s-t,d=(n-t)/u,p=d*d,f=p*d,_=e*c,y=_-c,m=-2*f+3*p,g=f-p,M=1-m,L=g-p+d;for(let x=0;x!==r;x++){const N=o[y+x+r],k=o[y+x+a]*u,C=o[_+x+r],G=o[_+x]*u;i[x]=M*N+L*k+m*C+g*G}return i}}const et=new h.Quaternion;class tt extends ce{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return et.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},le={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},he={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},st={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function nt(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function j(l,e,t){for(const n in t.extensions)l[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function I(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function it(l,e,t){let n=!1,s=!1,i=!1;for(let c=0,u=e.length;c<u;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(p)}if(s){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;r.push(p)}if(i){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;a.push(p)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(c){const u=c[0],d=c[1],p=c[2];return n&&(l.morphAttributes.position=u),s&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ot(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)l.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function rt(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,s=l.targets.length;n<s;n++)e+=":"+Y(l.targets[n]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+l[t[n]]+";";return e}function q(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function at(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ct=new h.Matrix4;class lt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new De,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"){const r=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(r)===!0;const a=r.match(/Version\/(\d+)/);s=n&&a?parseInt(a[1],10):-1,i=r.indexOf("Firefox")>-1,o=i?r.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const r={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return j(i,r,s),I(r,s),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){for(const a of r.scenes)a.updateMatrixWorld();e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[c,u]of o.children.entries())i(u,r.children[c])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,o){n.load(h.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=z[s.type],r=F[s.componentType],a=s.normalized===!0,c=new r(s.count*o);return Promise.resolve(new h.BufferAttribute(c,o,a))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=z[s.type],c=F[s.componentType],u=c.BYTES_PER_ELEMENT,d=u*a,p=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,_=s.normalized===!0;let y,m;if(f&&f!==d){const g=Math.floor(p/f),M="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count;let L=t.cache.get(M);L||(y=new c(r,g*f,s.count*f/u),L=new h.InterleavedBuffer(y,f/u),t.cache.add(M,L)),m=new h.InterleavedBufferAttribute(L,a,p%f/u,_)}else r===null?y=new c(s.count*a):y=new c(r,p,s.count*a),m=new h.BufferAttribute(y,a,_);if(s.sparse!==void 0){const g=z.SCALAR,M=F[s.sparse.indices.componentType],L=s.sparse.indices.byteOffset||0,x=s.sparse.values.byteOffset||0,N=new M(o[1],L,s.sparse.count*g),k=new c(o[2],x,s.sparse.count*a);r!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let C=0,G=N.length;C<G;C++){const v=N[C];if(m.setX(v,k[C*a]),a>=2&&m.setY(v,k[C*a+1]),a>=3&&m.setZ(v,k[C*a+2]),a>=4&&m.setW(v,k[C*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=n.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||r.name||"",u.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(u.name=r.uri);const p=(i.samplers||{})[o.sampler]||{};return u.magFilter=le[p.magFilter]||h.LinearFilter,u.minFilter=le[p.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=he[p.wrapS]||h.RepeatWrapping,u.wrapT=he[p.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,s.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",c=!1;if(o.bufferView!==void 0)a=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return a=r.createObjectURL(p),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(a).then(function(d){return new Promise(function(p,f){let _=p;t.isImageBitmapLoader===!0&&(_=function(y){const m=new h.Texture(y);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(d,i.path),_,void 0,f)})}).then(function(d){return c===!0&&r.revokeObjectURL(a),I(d,o),d.userData.mimeType=o.mimeType||at(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=u,u}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new h.PointsMaterial,h.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(r,a)),n=a}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new h.LineBasicMaterial,h.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(r,a)),n=a}if(s||i||o){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=n.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const r={},a=i.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const d=s[b.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(r,i,t))}else{const d=i.pbrMetallicRoughness||{};if(r.color=new h.Color(1,1,1),r.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;r.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),r.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(r,"map",d.baseColorTexture,h.SRGBColorSpace)),r.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,r.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(r,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(r,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,r)})))}i.doubleSided===!0&&(r.side=h.DoubleSide);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,u===W.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;r.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const d=i.emissiveFactor;r.emissive=new h.Color().setRGB(d[0],d[1],d[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(r);return i.name&&(d.name=i.name),I(d,i),t.associations.set(d,{materials:e}),i.extensions&&j(s,d,i),d})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(r){return n[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return ue(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const c=e[r],u=rt(c),d=s[u];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ue(new h.BufferGeometry,c,t),s[u]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,r=[];for(let a=0,c=o.length;a<c;a++){const u=o[a].material===void 0?nt(this.cache):this.getDependency("material",o[a].material);r.push(u)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const c=a.slice(0,a.length-1),u=a[a.length-1],d=[];for(let f=0,_=u.length;f<_;f++){const y=u[f],m=o[f];let g;const M=c[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)g=i.isSkinnedMesh===!0?new h.SkinnedMesh(y,M):new h.Mesh(y,M),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?g.geometry=oe(g.geometry,h.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(g.geometry=oe(g.geometry,h.TriangleFanDrawMode));else if(m.mode===O.LINES)g=new h.LineSegments(y,M);else if(m.mode===O.LINE_STRIP)g=new h.Line(y,M);else if(m.mode===O.LINE_LOOP)g=new h.LineLoop(y,M);else if(m.mode===O.POINTS)g=new h.Points(y,M);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(g.geometry.morphAttributes).length>0&&ot(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),I(g,i),m.extensions&&j(s,g,m),t.assignFinalMaterial(g),d.push(g)}for(let f=0,_=d.length;f<_;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&j(s,d[0],i),d[0];const p=new h.Group;i.extensions&&j(s,p,i),t.associations.set(p,{meshes:e});for(let f=0,_=d.length;f<_;f++)p.add(d[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new h.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),I(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,r=[],a=[];for(let c=0,u=o.length;c<u;c++){const d=o[c];if(d){r.push(d);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),a.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(r,a)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],r=[],a=[],c=[],u=[];for(let d=0,p=s.channels.length;d<p;d++){const f=s.channels[d],_=s.samplers[f.sampler],y=f.target,m=y.node,g=s.parameters!==void 0?s.parameters[_.input]:_.input,M=s.parameters!==void 0?s.parameters[_.output]:_.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),r.push(this.getDependency("accessor",g)),a.push(this.getDependency("accessor",M)),c.push(_),u.push(y))}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],_=d[2],y=d[3],m=d[4],g=[];for(let M=0,L=p.length;M<L;M++){const x=p[M],N=f[M],k=_[M],C=y[M],G=m[M];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=n._createAnimationTracks(x,N,k,C,G);if(v)for(let Z=0;Z<v.length;Z++)g.push(v[Z])}return new h.AnimationClip(i,void 0,g)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,c=s.weights.length;a<c;a++)r.morphTargetInfluences[a]=s.weights[a]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],r=s.children||[];for(let c=0,u=r.length;c<u;c++)o.push(n.getDependency("node",r[c]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),a]).then(function(c){const u=c[0],d=c[1],p=c[2];p!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(p,ct)});for(let f=0,_=d.length;f<_;f++)u.add(d[f]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",r=[],a=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(s.getDependency("camera",i.camera).then(function(c){return s._getNodeRef(s.cameraCache,i.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){r.push(c)}),this.nodeCache[e]=Promise.all(r).then(function(c){let u;if(i.isBone===!0?u=new h.Bone:c.length>1?u=new h.Group:c.length===1?u=c[0]:u=new h.Object3D,u!==c[0])for(let d=0,p=c.length;d<p;d++)u.add(c[d]);if(i.name&&(u.userData.name=i.name,u.name=o),I(u,i),i.extensions&&j(n,u,i),i.matrix!==void 0){const d=new h.Matrix4;d.fromArray(i.matrix),u.applyMatrix4(d)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const d=s.associations.get(u);s.associations.set(u,{...d})}return s.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new h.Group;n.name&&(i.name=s.createUniqueName(n.name)),I(i,n),n.extensions&&j(t,i,n);const o=n.nodes||[],r=[];for(let a=0,c=o.length;a<c;a++)r.push(s.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let u=0,d=a.length;u<d;u++)i.add(a[u]);const c=u=>{const d=new Map;for(const[p,f]of s.associations)(p instanceof h.Material||p instanceof h.Texture)&&d.set(p,f);return u.traverse(p=>{const f=s.associations.get(p);f!=null&&d.set(p,f)}),d};return s.associations=c(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],r=e.name?e.name:e.uuid,a=[];R[i.path]===R.weights?e.traverse(function(p){p.morphTargetInfluences&&a.push(p.name?p.name:p.uuid)}):a.push(r);let c;switch(R[i.path]){case R.weights:c=h.NumberKeyframeTrack;break;case R.rotation:c=h.QuaternionKeyframeTrack;break;case R.translation:case R.scale:c=h.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const u=s.interpolation!==void 0?st[s.interpolation]:h.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let p=0,f=a.length;p<f;p++){const _=new c(a[p]+"."+R[i.path],t.array,d,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),o.push(_)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=q(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof h.QuaternionKeyframeTrack?tt:ce;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ht(l,e,t){const n=e.attributes,s=new h.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],a=r.min,c=r.max;if(a!==void 0&&c!==void 0){if(s.set(new h.Vector3(a[0],a[1],a[2]),new h.Vector3(c[0],c[1],c[2])),r.normalized){const u=q(F[r.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new h.Vector3,a=new h.Vector3;for(let c=0,u=i.length;c<u;c++){const d=i[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,_=p.max;if(f!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),p.normalized){const y=q(F[p.componentType]);a.multiplyScalar(y)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}l.boundingBox=s;const o=new h.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=o}function ue(l,e,t){const n=e.attributes,s=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in n){const r=X[o]||o.toLowerCase();r in l.attributes||s.push(i(n[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});s.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),I(l,e),ht(l,e,t),Promise.all(s).then(function(){return e.targets!==void 0?it(l,e.targets,t):l})}const de={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async r=>{const a=new Ce;return a.register(c=>new Q.VRMLoaderPlugin(c)),await a.loadAsync(r).then(c=>{const u=c.userData.vrm;return Q.VRMUtils.rotateVRM0(u),u})},i=async r=>{if(!r)return;t("loading",n.name,n.command);const a=await s(r);let c=!1;a&&(c=!0),t("loaded",n.name,n.command,c,a)},o=r=>{t("loading",n.name,n.command);let a=!1;r&&(a=!0),t("loaded",n.name,n.command,a,r)};return S.onMounted(async()=>{n.data!=null?o(n.data):i(n.url)}),(r,a)=>null}},pe={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s={},i={},o=S.ref(null),r=S.ref(null),a=S.ref(null),c=(d,p)=>{const f=Object.keys(s).length;s[d]=p;const _=Object.keys(s).length;f==0&&_&&t("loading",n.name)},u=(d,p,f,_)=>{const y=Object.keys(s).length;f&&(p=="load_expression"&&(o.value=_),p=="load_pose"&&(r.value=_),p=="load_vrm"&&(a.value=_),i[d]=p),delete s[d];const m=Object.keys(s).length;if(y&&m==0){const g={};for(const L in i){const x=i[L];x=="load_expression"&&(g.expression=o.value),x=="load_pose"&&(g.pose=r.value),x=="load_vrm"&&(g.vrm=a.value)}t("loaded",n.name,g);const M=Object.keys(i);for(const L of M)delete i[L]}};return(d,p)=>(S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createVNode(ne,{command:"load_expression",name:n.expression_name,url:n.expression_url,data:n.expression_data,onLoading:c,onLoaded:u},null,8,["name","url","data"]),S.createVNode(ie,{command:"load_pose",name:n.pose_name,url:n.pose_url,data:n.expression_data,onLoading:c,onLoaded:u},null,8,["name","url","data"]),S.createVNode(de,{command:"load_vrm",name:n.vrm_name,url:n.vrm_url,data:n.vrm_data,onLoading:c,onLoaded:u},null,8,["name","url","data"])],64))}},ut={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=S.ref(null);n.value=new J;const s=o=>{t("loading",o)},i=(o,r)=>{"vrm"in r&&n.value.setModel(r.vrm),"pose"in r&&(n.value.setPose(r.pose),n.value.updatePose()),"expression"in r&&(n.value.importExpression(r.expression),n.value.updateExpression()),t("loaded",o,n.value)};return(o,r)=>(S.openBlock(),S.createBlock(pe,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,onLoading:s,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=V,A.ThreeFrame=Ne,A.VrmModel=J,A.VroidControl=ut,A.VroidExpression=ne,A.VroidModel=pe,A.VroidPose=ie,A.VroidVrm=de,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(A,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("vue"),require("three"),require("@pixiv/three-vrm")):typeof define=="function"&&define.amd?define(["exports","vue","three","@pixiv/three-vrm"],M):(A=typeof globalThis<"u"?globalThis:A||self,M(A.VueThreeVrm={},A.Vue,A.THREE,A.THREE_VRM))})(this,function(A,M,h,Q){"use strict";var $=document.createElement("style");$.textContent=`.box[data-v-1ac174e9]{display:block;width:100%;height:100%}
|
|
2
|
+
/*$vite$:1*/`,document.head.appendChild($);function fe(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const t in l)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(l,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>l[t]})}}return e.default=l,Object.freeze(e)}const D=fe(h);class V{constructor(){this.status=0,this.url=null,this.data=null}is_loaded(){return this.status==2}is_failed(){return this.status==3}async loadUrl(e,t){this.url=t,this.data=null,this.status=1;const n=await e.get(t);return n.status!=200?(this.status=3,null):n.data?(this.data=n.data,this.status=2,this.data):(this.status=3,null)}async loadPose(e,t){const n=await this.loadUrl(e,t);return n==null?null:"pose"in n?(this.data=n.pose,this.data):this.data}async loadExpression(e,t){const n=await this.loadUrl(e,t);return n==null?null:"expressions"in n?(this.data=n.expressions,this.data):this.data}}class J{constructor(){this.vrm=null}get scene(){return this.vrm?this.vrm.scene:null}setModel(e){this.vrm=e}setPosition(e){this.vrm.scene.position.x=e.x,this.vrm.scene.position.y=e.y,this.vrm.scene.position.z=e.z}getPosition(){return{x:this.vrm.scene.position.x,y:this.vrm.scene.position.y,z:this.vrm.scene.position.z}}setPose(e){this.vrm&&this.vrm.humanoid.setNormalizedPose(e)}getPose(){return this.vrm?this.vrm.humanoid.getNormalizedPose():null}updatePose(){this.vrm&&this.vrm.humanoid.update()}resetPose(){this.vrm&&this.vrm.humanoid.resetNormalizedPose()}getBoneNode(e){return this.vrm?this.vrm.humanoid.getNormalizedBoneNode(e):null}isValid(){return!!this.vrm}getBoneRotate(e){const t=this.getBoneNode(e);return t?{x:t.rotation.x,y:t.rotation.y,z:t.rotation.z}:null}setBoneRotate(e,t,n,s){const i=this.getBoneNode(e);i&&(i.rotation.x=t,i.rotation.y=n,i.rotation.z=s)}getBonePosition(e){const t=this.getBoneNode(e);return t?{x:t.position.x,y:t.position.y,z:t.position.z}:null}setBonePosition(e,t,n,s){const i=this.getBoneNode(e);i&&(i.position.x=t,i.position.y=n,i.position.z=s)}getMetaVersion(){return this.vrm?this.vrm.meta.metaVersion:null}setExpression(e,t){this.vrm&&this.vrm.expressionManager.setValue(e,t)}getExpression(e){return this.vrm?this.vrm.expressionManager.getValue(e):null}updateExpression(){return this.vrm?this.vrm.expressionManager.update():null}getExpressionNames(){if(this.vrm){let e=[];for(const t in this.vrm.expressionManager.expressionMap)e.push(t);return e}return null}importExpression(e){if(this.vrm)for(const t in e)this.vrm.expressionManager.setValue(t,e[t])}exportExpression(){if(this.vrm){let e={};const t=this.getExpressionNames();for(const n in t)e[n]=this.getExpression(n);return e}return null}}class H{static isWebGL2Available(){try{const e=document.createElement("canvas");return!!(window.WebGL2RenderingContext&&e.getContext("webgl2"))}catch{return!1}}static isColorSpaceAvailable(e){try{const t=document.createElement("canvas"),n=window.WebGL2RenderingContext&&t.getContext("webgl2");return n.drawingBufferColorSpace=e,n.drawingBufferColorSpace===e}catch{return!1}}static getWebGL2ErrorMessage(){return this._getErrorMessage(2)}static _getErrorMessage(e){const t={1:"WebGL",2:"WebGL 2"},n={1:window.WebGLRenderingContext,2:window.WebGL2RenderingContext};let s='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>';const i=document.createElement("div");return i.id="webglmessage",i.style.fontFamily="monospace",i.style.fontSize="13px",i.style.fontWeight="normal",i.style.textAlign="center",i.style.background="#fff",i.style.color="#000",i.style.padding="1.5em",i.style.width="400px",i.style.margin="5em auto 0",n[e]?s=s.replace("$0","graphics card"):s=s.replace("$0","browser"),s=s.replace("$1",t[e]),i.innerHTML=s,i}static isWebGLAvailable(){console.warn("isWebGLAvailable() has been deprecated and will be removed in r178. Use isWebGL2Available() instead.");try{const e=document.createElement("canvas");return!!(window.WebGLRenderingContext&&(e.getContext("webgl")||e.getContext("experimental-webgl")))}catch{return!1}}static getWebGLErrorMessage(){return console.warn("getWebGLErrorMessage() has been deprecated and will be removed in r178. Use getWebGL2ErrorMessage() instead."),this._getErrorMessage(1)}}const ee={type:"change"},K={type:"start"},te={type:"end"},B=new h.Ray,se=new h.Plane,me=Math.cos(70*h.MathUtils.DEG2RAD),L=new h.Vector3,P=2*Math.PI,S={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},E=1e-6;class _e extends h.Controls{constructor(e,t=null){super(e,t),this.state=S.NONE,this.target=new h.Vector3,this.cursor=new h.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:h.MOUSE.ROTATE,MIDDLE:h.MOUSE.DOLLY,RIGHT:h.MOUSE.PAN},this.touches={ONE:h.TOUCH.ROTATE,TWO:h.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new h.Vector3,this._lastQuaternion=new h.Quaternion,this._lastTargetPosition=new h.Vector3,this._quat=new h.Quaternion().setFromUnitVectors(e.up,new h.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new h.Spherical,this._sphericalDelta=new h.Spherical,this._scale=1,this._panOffset=new h.Vector3,this._rotateStart=new h.Vector2,this._rotateEnd=new h.Vector2,this._rotateDelta=new h.Vector2,this._panStart=new h.Vector2,this._panEnd=new h.Vector2,this._panDelta=new h.Vector2,this._dollyStart=new h.Vector2,this._dollyEnd=new h.Vector2,this._dollyDelta=new h.Vector2,this._dollyDirection=new h.Vector3,this._mouse=new h.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ye.bind(this),this._onPointerDown=ge.bind(this),this._onPointerUp=xe.bind(this),this._onContextMenu=Ae.bind(this),this._onMouseWheel=Te.bind(this),this._onKeyDown=Se.bind(this),this._onTouchStart=we.bind(this),this._onTouchMove=Le.bind(this),this._onMouseDown=be.bind(this),this._onMouseMove=Me.bind(this),this._interceptControlDown=Pe.bind(this),this._interceptControlUp=Oe.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(ee),this.update(),this.state=S.NONE}update(e=null){const t=this.object.position;L.copy(t).sub(this.target),L.applyQuaternion(this._quat),this._spherical.setFromVector3(L),this.autoRotate&&this.state===S.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,s=this.maxAzimuthAngle;isFinite(n)&&isFinite(s)&&(n<-Math.PI?n+=P:n>Math.PI&&(n-=P),s<-Math.PI?s+=P:s>Math.PI&&(s-=P),n<=s?this._spherical.theta=Math.max(n,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+s)/2?Math.max(n,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let i=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),i=o!=this._spherical.radius}if(L.setFromSpherical(this._spherical),L.applyQuaternion(this._quatInverse),t.copy(this.target).add(L),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const r=L.length();o=this._clampDistance(r*this._scale);const a=r-o;this.object.position.addScaledVector(this._dollyDirection,a),this.object.updateMatrixWorld(),i=!!a}else if(this.object.isOrthographicCamera){const r=new h.Vector3(this._mouse.x,this._mouse.y,0);r.unproject(this.object);const a=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),i=a!==this.object.zoom;const c=new h.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(r),this.object.updateMatrixWorld(),o=L.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(B.origin.copy(this.object.position),B.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(B.direction))<me?this.object.lookAt(this.target):(se.setFromNormalAndCoplanarPoint(this.object.up,this.target),B.intersectPlane(se,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),i=!0)}return this._scale=1,this._performCursorZoom=!1,i||this._lastPosition.distanceToSquared(this.object.position)>E||8*(1-this._lastQuaternion.dot(this.object.quaternion))>E||this._lastTargetPosition.distanceToSquared(this.target)>E?(this.dispatchEvent(ee),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?P/60*this.autoRotateSpeed*e:P/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){L.setFromMatrixColumn(t,0),L.multiplyScalar(-e),this._panOffset.add(L)}_panUp(e,t){this.screenSpacePanning===!0?L.setFromMatrixColumn(t,1):(L.setFromMatrixColumn(t,0),L.crossVectors(this.object.up,L)),L.multiplyScalar(e),this._panOffset.add(L)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;L.copy(s).sub(this.target);let i=L.length();i*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*i/n.clientHeight,this.object.matrix),this._panUp(2*t*i/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),s=e-n.left,i=t-n.top,o=n.width,r=n.height;this._mouse.x=s/o*2-1,this._mouse.y=-(i/r)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-P*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(n,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(n,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyStart.set(0,i)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),s=.5*(e.pageX+n.x),i=.5*(e.pageY+n.y);this._rotateEnd.set(s,i)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(P*this._rotateDelta.x/t.clientHeight),this._rotateUp(P*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(n,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,s=e.pageY-t.y,i=Math.sqrt(n*n+s*s);this._dollyEnd.set(0,i),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,r=(e.pageY+t.y)*.5;this._updateZoomParameters(o,r)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new h.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function ge(l){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(l.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(l)&&(this._addPointer(l),l.pointerType==="touch"?this._onTouchStart(l):this._onMouseDown(l)))}function ye(l){this.enabled!==!1&&(l.pointerType==="touch"?this._onTouchMove(l):this._onMouseMove(l))}function xe(l){switch(this._removePointer(l),this._pointers.length){case 0:this.domElement.releasePointerCapture(l.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(te),this.state=S.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function be(l){let e;switch(l.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case h.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(l),this.state=S.DOLLY;break;case h.MOUSE.ROTATE:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}break;case h.MOUSE.PAN:if(l.ctrlKey||l.metaKey||l.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(l),this.state=S.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(l),this.state=S.PAN}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(K)}function Me(l){switch(this.state){case S.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(l);break;case S.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(l);break;case S.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(l);break}}function Te(l){this.enabled===!1||this.enableZoom===!1||this.state!==S.NONE||(l.preventDefault(),this.dispatchEvent(K),this._handleMouseWheel(this._customWheelEvent(l)),this.dispatchEvent(te))}function Se(l){this.enabled!==!1&&this._handleKeyDown(l)}function we(l){switch(this._trackPointer(l),this._pointers.length){case 1:switch(this.touches.ONE){case h.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(l),this.state=S.TOUCH_ROTATE;break;case h.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(l),this.state=S.TOUCH_PAN;break;default:this.state=S.NONE}break;case 2:switch(this.touches.TWO){case h.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(l),this.state=S.TOUCH_DOLLY_PAN;break;case h.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(l),this.state=S.TOUCH_DOLLY_ROTATE;break;default:this.state=S.NONE}break;default:this.state=S.NONE}this.state!==S.NONE&&this.dispatchEvent(K)}function Le(l){switch(this._trackPointer(l),this.state){case S.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(l),this.update();break;case S.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(l),this.update();break;case S.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(l),this.update();break;case S.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(l),this.update();break;default:this.state=S.NONE}}function Ae(l){this.enabled!==!1&&l.preventDefault()}function Pe(l){l.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Oe(l){l.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}const Ne=((l,e)=>{const t=l.__vccOpts||l;for(const[n,s]of e)t[n]=s;return t})({__name:"ThreeFrame",props:{animation:{type:Boolean,default:!1},useOrbitControls:{type:Boolean,default:!1},useGridHelper:{type:Boolean,default:!1},useAxesHelper:{type:Boolean,default:!1},useDefaultLight:{type:Boolean,default:!1}},emits:["init","animate"],setup(l,{emit:e}){const t=e,n=l,s="dom"+M.getCurrentInstance().uid,i=M.useTemplateRef(s);let o=null,r=null,a=null,c=null,u=null;const d=()=>{t("animate",{scene:r,camera:a,renderer:c,controls:u}),o!=null&&(cancelAnimationFrame(o),o=null),n.animation&&(o=requestAnimationFrame(d)),c.render(r,a)},p=()=>{o!=null&&(cancelAnimationFrame(o),o=null),o=requestAnimationFrame(d)},f=()=>{o!=null&&(cancelAnimationFrame(o),o=null)};M.watch(()=>n.animation,y=>{y==!0?p():f()});const _=()=>{const y=i.value,m=y.clientWidth,g=y.clientHeight,T={antialias:!0,alpha:!1};if(D.ColorManagement.enabled=!1,c=new D.WebGLRenderer(T),c.setPixelRatio(window.devicePixelRatio),c.setSize(m,g),c.setClearColor(8372223,1),c.outputColorSpace=D.SRGBColorSpace,y.appendChild(c.domElement),r=new D.Scene,a=new D.PerspectiveCamera(45,m/g,.1,1e3),a.position.set(0,1.25,1),n.useOrbitControls&&(u=new _e(a,y),u.screenSpacePanning=!0,u.target.set(0,1.25,0),u.update()),n.useGridHelper){const x=new D.GridHelper(10,10);r.add(x),x.visible=!0}if(n.useAxesHelper){const x=new D.AxesHelper(5);r.add(x)}if(n.useDefaultLight){const x=new D.DirectionalLight(16777215);x.intensity=3,x.position.set(1,1,1).normalize(),r.add(x);const N=new D.AmbientLight(4210752);r.add(N)}t("init",{scene:r,camera:a,renderer:c,controls:u})};return M.onMounted(async()=>{if(!H.isWebGL2Available()){const m=H.getWebGLErrorMessage();console.error(m);return}const y=()=>{const m=i.value,g=m.clientWidth,T=m.clientHeight;c.setPixelRatio(window.devicePixelRatio),c.setSize(g,T),a.aspect=g/T,a.updateProjectionMatrix()};window.addEventListener("resize",y),_()}),(y,m)=>(M.openBlock(),M.createElementBlock("div",{ref:s,class:"box"}))}},[["__scopeId","data-v-1ac174e9"]]),ne={__name:"VroidExpression",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=M.inject("axios"),n=e,s=l,i=async r=>{if(!r)return;n("loading",s.name,s.command);const c=await new V().loadExpression(t,r);let u=!1;c&&(u=!0),n("loaded",s.name,s.command,u,c)},o=r=>{n("loading",s.name,s.command);let a=!1;r&&(a=!0),n("loaded",s.name,s.command,a,r)};return M.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),M.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),M.watch(()=>s.url,()=>{s.url&&i(s.url)}),(r,a)=>null}},ie={__name:"VroidPose",props:{command:{type:String},name:{type:String},url:{type:String},data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=M.inject("axios"),n=e,s=l,i=async r=>{if(!r)return;n("loading",s.name,s.command);const c=await new V().loadPose(t,r);let u=!1;c&&(u=!0),n("loaded",s.name,s.command,u,c)},o=r=>{n("loading",s.name,s.command);let a=!1;r&&(a=!0),n("loaded",s.name,s.command,a,r)};return M.onMounted(async()=>{s.data!=null?o(s.data):i(s.url)}),M.watch(()=>s.data,()=>{s.data!=null&&o(s.data)}),M.watch(()=>s.url,()=>{s.url&&i(s.url)}),(r,a)=>null}};function oe(l,e){if(e===h.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===h.TriangleFanDrawMode||e===h.TriangleStripDrawMode){let t=l.getIndex();if(t===null){const o=[],r=l.getAttribute("position");if(r!==void 0){for(let a=0;a<r.count;a++)o.push(a);l.setIndex(o),t=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const n=t.count-2,s=[];if(e===h.TriangleFanDrawMode)for(let o=1;o<=n;o++)s.push(t.getX(0)),s.push(t.getX(o)),s.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(s.push(t.getX(o)),s.push(t.getX(o+1)),s.push(t.getX(o+2))):(s.push(t.getX(o+2)),s.push(t.getX(o+1)),s.push(t.getX(o)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const i=l.clone();return i.setIndex(s),i.clearGroups(),i}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class Ce extends h.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new ve(t)}),this.register(function(t){return new je(t)}),this.register(function(t){return new Xe(t)}),this.register(function(t){return new We(t)}),this.register(function(t){return new Ye(t)}),this.register(function(t){return new Ue(t)}),this.register(function(t){return new Ge(t)}),this.register(function(t){return new Be(t)}),this.register(function(t){return new Ve(t)}),this.register(function(t){return new ke(t)}),this.register(function(t){return new Ke(t)}),this.register(function(t){return new Fe(t)}),this.register(function(t){return new ze(t)}),this.register(function(t){return new Ee(t)}),this.register(function(t){return new Ie(t)}),this.register(function(t){return new qe(t)}),this.register(function(t){return new Ze(t)})}load(e,t,n,s){const i=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=h.LoaderUtils.extractUrlBase(e);o=h.LoaderUtils.resolveURL(c,this.path)}else o=h.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const r=function(c){s?s(c):console.error(c),i.manager.itemError(e),i.manager.itemEnd(e)},a=new h.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(c){try{i.parse(c,o,function(u){t(u),i.manager.itemEnd(e)},r)}catch(u){r(u)}},n,r)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,s){let i;const o={},r={},a=new TextDecoder;if(typeof e=="string")i=JSON.parse(e);else if(e instanceof ArrayBuffer)if(a.decode(new Uint8Array(e,0,4))===re){try{o[b.KHR_BINARY_GLTF]=new Qe(e)}catch(d){s&&s(d);return}i=JSON.parse(o[b.KHR_BINARY_GLTF].content)}else i=JSON.parse(a.decode(e));else i=e;if(i.asset===void 0||i.asset.version[0]<2){s&&s(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new lt(i,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const d=this.pluginCallbacks[u](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),r[d.name]=d,o[d.name]=!0}if(i.extensionsUsed)for(let u=0;u<i.extensionsUsed.length;++u){const d=i.extensionsUsed[u],p=i.extensionsRequired||[];switch(d){case b.KHR_MATERIALS_UNLIT:o[d]=new Re;break;case b.KHR_DRACO_MESH_COMPRESSION:o[d]=new $e(i,this.dracoLoader);break;case b.KHR_TEXTURE_TRANSFORM:o[d]=new Je;break;case b.KHR_MESH_QUANTIZATION:o[d]=new He;break;default:p.indexOf(d)>=0&&r[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(o),c.setPlugins(r),c.parse(n,s)}parseAsync(e,t){const n=this;return new Promise(function(s,i){n.parse(e,t,s,i)})}}function De(){let l={};return{get:function(e){return l[e]},add:function(e,t){l[e]=t},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const b={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class Ie{constructor(e){this.parser=e,this.name=b.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,s=t.length;n<s;n++){const i=t[n];i.extensions&&i.extensions[this.name]&&i.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let s=t.cache.get(n);if(s)return s;const i=t.json,a=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let c;const u=new h.Color(16777215);a.color!==void 0&&u.setRGB(a.color[0],a.color[1],a.color[2],h.LinearSRGBColorSpace);const d=a.range!==void 0?a.range:0;switch(a.type){case"directional":c=new h.DirectionalLight(u),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new h.PointLight(u),c.distance=d;break;case"spot":c=new h.SpotLight(u),c.distance=d,a.spot=a.spot||{},a.spot.innerConeAngle=a.spot.innerConeAngle!==void 0?a.spot.innerConeAngle:0,a.spot.outerConeAngle=a.spot.outerConeAngle!==void 0?a.spot.outerConeAngle:Math.PI/4,c.angle=a.spot.outerConeAngle,c.penumbra=1-a.spot.innerConeAngle/a.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+a.type)}return c.position.set(0,0,0),I(c,a),a.intensity!==void 0&&(c.intensity=a.intensity),c.name=t.createUniqueName(a.name||"light_"+e),s=Promise.resolve(c),t.cache.add(n,s),s}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,i=n.json.nodes[e],r=(i.extensions&&i.extensions[this.name]||{}).light;return r===void 0?null:this._loadLight(r).then(function(a){return n._getNodeRef(t.cache,r,a)})}}class Re{constructor(){this.name=b.KHR_MATERIALS_UNLIT}getMaterialType(){return h.MeshBasicMaterial}extendParams(e,t,n){const s=[];e.color=new h.Color(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const o=i.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],h.LinearSRGBColorSpace),e.opacity=o[3]}i.baseColorTexture!==void 0&&s.push(n.assignTexture(e,"map",i.baseColorTexture,h.SRGBColorSpace))}return Promise.all(s)}}class ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name].emissiveStrength;return i!==void 0&&(t.emissiveIntensity=i),Promise.resolve()}}class ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(i.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const r=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new h.Vector2(r,r)}return Promise.all(i)}}class je{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.dispersion=i.dispersion!==void 0?i.dispersion:0,Promise.resolve()}}class Fe{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&i.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(i)}}class Ue{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new h.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=s.extensions[this.name];if(o.sheenColorFactor!==void 0){const r=o.sheenColorFactor;t.sheenColor.setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&i.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,h.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&i.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(i)}}class Ge{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&i.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(i)}}class Be{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&i.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const r=o.attenuationColor||[1,1,1];return t.attenuationColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),Promise.all(i)}}class Ve{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const s=this.parser.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=s.extensions[this.name];return t.ior=i.ior!==void 0?i.ior:1.5,Promise.resolve()}}class Ke{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&i.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const r=o.specularColorFactor||[1,1,1];return t.specularColor=new h.Color().setRGB(r[0],r[1],r[2],h.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&i.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,h.SRGBColorSpace)),Promise.all(i)}}class Ee{constructor(e){this.parser=e,this.name=b.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&i.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(i)}}class ze{constructor(e){this.parser=e,this.name=b.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:h.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,s=n.json.materials[e];if(!s.extensions||!s.extensions[this.name])return Promise.resolve();const i=[],o=s.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&i.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(i)}}class Xe{constructor(e){this.parser=e,this.name=b.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,s=n.textures[e];if(!s.extensions||!s.extensions[this.name])return null;const i=s.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,o)}}class We{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let a=n.textureLoader;if(r.uri){const c=n.options.manager.getHandler(r.uri);c!==null&&(a=c)}return n.loadTextureImage(e,o.source,a)}}class Ye{constructor(e){this.parser=e,this.name=b.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,s=n.json,i=s.textures[e];if(!i.extensions||!i.extensions[t])return null;const o=i.extensions[t],r=s.images[o.source];let a=n.textureLoader;if(r.uri){const c=n.options.manager.getHandler(r.uri);c!==null&&(a=c)}return n.loadTextureImage(e,o.source,a)}}class qe{constructor(e){this.name=b.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const s=n.extensions[this.name],i=this.parser.getDependency("buffer",s.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return i.then(function(r){const a=s.byteOffset||0,c=s.byteLength||0,u=s.count,d=s.byteStride,p=new Uint8Array(r,a,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(u,d,p,s.mode,s.filter).then(function(f){return f.buffer}):o.ready.then(function(){const f=new ArrayBuffer(u*d);return o.decodeGltfBuffer(new Uint8Array(f),u,d,p,s.mode,s.filter),f})})}else return null}}class Ze{constructor(e){this.name=b.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const s=t.meshes[n.mesh];for(const c of s.primitives)if(c.mode!==O.TRIANGLES&&c.mode!==O.TRIANGLE_STRIP&&c.mode!==O.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,r=[],a={};for(const c in o)r.push(this.parser.getDependency("accessor",o[c]).then(u=>(a[c]=u,a[c])));return r.length<1?null:(r.push(this.parser.createNodeMesh(e)),Promise.all(r).then(c=>{const u=c.pop(),d=u.isGroup?u.children:[u],p=c[0].count,f=[];for(const _ of d){const y=new h.Matrix4,m=new h.Vector3,g=new h.Quaternion,T=new h.Vector3(1,1,1),w=new h.InstancedMesh(_.geometry,_.material,p);for(let x=0;x<p;x++)a.TRANSLATION&&m.fromBufferAttribute(a.TRANSLATION,x),a.ROTATION&&g.fromBufferAttribute(a.ROTATION,x),a.SCALE&&T.fromBufferAttribute(a.SCALE,x),w.setMatrixAt(x,y.compose(m,g,T));for(const x in a)if(x==="_COLOR_0"){const N=a[x];w.instanceColor=new h.InstancedBufferAttribute(N.array,N.itemSize,N.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&_.geometry.setAttribute(x,a[x]);h.Object3D.prototype.copy.call(w,_),this.parser.assignFinalMaterial(w),f.push(w)}return u.isGroup?(u.clear(),u.add(...f),u):f[0]}))}}const re="glTF",U=12,ae={JSON:1313821514,BIN:5130562};class Qe{constructor(e){this.name=b.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,U),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==re)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const s=this.header.length-U,i=new DataView(e,U);let o=0;for(;o<s;){const r=i.getUint32(o,!0);o+=4;const a=i.getUint32(o,!0);if(o+=4,a===ae.JSON){const c=new Uint8Array(e,U+o,r);this.content=n.decode(c)}else if(a===ae.BIN){const c=U+o;this.body=e.slice(c,c+r)}o+=r}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class $e{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=b.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,s=this.dracoLoader,i=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,r={},a={},c={};for(const u in o){const d=X[u]||u.toLowerCase();r[d]=o[u]}for(const u in e.attributes){const d=X[u]||u.toLowerCase();if(o[u]!==void 0){const p=n.accessors[e.attributes[u]],f=F[p.componentType];c[d]=f.name,a[d]=p.normalized===!0}}return t.getDependency("bufferView",i).then(function(u){return new Promise(function(d,p){s.decodeDracoFile(u,function(f){for(const _ in f.attributes){const y=f.attributes[_],m=a[_];m!==void 0&&(y.normalized=m)}d(f)},r,c,h.LinearSRGBColorSpace,p)})})}}class Je{constructor(){this.name=b.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class He{constructor(){this.name=b.KHR_MESH_QUANTIZATION}}class ce extends h.Interpolant{constructor(e,t,n,s){super(e,t,n,s)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,s=this.valueSize,i=e*s*3+s;for(let o=0;o!==s;o++)t[o]=n[i+o];return t}interpolate_(e,t,n,s){const i=this.resultBuffer,o=this.sampleValues,r=this.valueSize,a=r*2,c=r*3,u=s-t,d=(n-t)/u,p=d*d,f=p*d,_=e*c,y=_-c,m=-2*f+3*p,g=f-p,T=1-m,w=g-p+d;for(let x=0;x!==r;x++){const N=o[y+x+r],k=o[y+x+a]*u,C=o[_+x+r],G=o[_+x]*u;i[x]=T*N+w*k+m*C+g*G}return i}}const et=new h.Quaternion;class tt extends ce{interpolate_(e,t,n,s){const i=super.interpolate_(e,t,n,s);return et.fromArray(i).normalize().toArray(i),i}}const O={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},le={9728:h.NearestFilter,9729:h.LinearFilter,9984:h.NearestMipmapNearestFilter,9985:h.LinearMipmapNearestFilter,9986:h.NearestMipmapLinearFilter,9987:h.LinearMipmapLinearFilter},he={33071:h.ClampToEdgeWrapping,33648:h.MirroredRepeatWrapping,10497:h.RepeatWrapping},z={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},R={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},st={CUBICSPLINE:void 0,LINEAR:h.InterpolateLinear,STEP:h.InterpolateDiscrete},W={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function nt(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new h.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:h.FrontSide})),l.DefaultMaterial}function j(l,e,t){for(const n in t.extensions)l[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function I(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function it(l,e,t){let n=!1,s=!1,i=!1;for(let c=0,u=e.length;c<u;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(s=!0),d.COLOR_0!==void 0&&(i=!0),n&&s&&i)break}if(!n&&!s&&!i)return Promise.resolve(l);const o=[],r=[],a=[];for(let c=0,u=e.length;c<u;c++){const d=e[c];if(n){const p=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):l.attributes.position;o.push(p)}if(s){const p=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):l.attributes.normal;r.push(p)}if(i){const p=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):l.attributes.color;a.push(p)}}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a)]).then(function(c){const u=c[0],d=c[1],p=c[2];return n&&(l.morphAttributes.position=u),s&&(l.morphAttributes.normal=d),i&&(l.morphAttributes.color=p),l.morphTargetsRelative=!0,l})}function ot(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)l.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(l.morphTargetInfluences.length===t.length){l.morphTargetDictionary={};for(let n=0,s=t.length;n<s;n++)l.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function rt(l){let e;const t=l.extensions&&l.extensions[b.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Y(t.attributes):e=l.indices+":"+Y(l.attributes)+":"+l.mode,l.targets!==void 0)for(let n=0,s=l.targets.length;n<s;n++)e+=":"+Y(l.targets[n]);return e}function Y(l){let e="";const t=Object.keys(l).sort();for(let n=0,s=t.length;n<s;n++)e+=t[n]+":"+l[t[n]]+";";return e}function q(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function at(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":l.search(/\.ktx2($|\?)/i)>0||l.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const ct=new h.Matrix4;class lt{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new De,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,s=-1,i=!1,o=-1;if(typeof navigator<"u"){const r=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(r)===!0;const a=r.match(/Version\/(\d+)/);s=n&&a?parseInt(a[1],10):-1,i=r.indexOf("Firefox")>-1,o=i?r.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&s<17||i&&o<98?this.textureLoader=new h.TextureLoader(this.options.manager):this.textureLoader=new h.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new h.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,s=this.json,i=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const r={scene:o[0][s.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:s.asset,parser:n,userData:{}};return j(i,r,s),I(r,s),Promise.all(n._invokeAll(function(a){return a.afterRoot&&a.afterRoot(r)})).then(function(){for(const a of r.scenes)a.updateMatrixWorld();e(r)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let s=0,i=t.length;s<i;s++){const o=t[s].joints;for(let r=0,a=o.length;r<a;r++)e[o[r]].isBone=!0}for(let s=0,i=e.length;s<i;s++){const o=e[s];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const s=n.clone(),i=(o,r)=>{const a=this.associations.get(o);a!=null&&this.associations.set(r,a);for(const[c,u]of o.children.entries())i(u,r.children[c])};return i(n,s),s.name+="_instance_"+e.uses[t]++,s}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const s=e(t[n]);if(s)return s}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let s=0;s<t.length;s++){const i=e(t[s]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let s=this.cache.get(n);if(!s){switch(e){case"scene":s=this.loadScene(t);break;case"node":s=this._invokeOne(function(i){return i.loadNode&&i.loadNode(t)});break;case"mesh":s=this._invokeOne(function(i){return i.loadMesh&&i.loadMesh(t)});break;case"accessor":s=this.loadAccessor(t);break;case"bufferView":s=this._invokeOne(function(i){return i.loadBufferView&&i.loadBufferView(t)});break;case"buffer":s=this.loadBuffer(t);break;case"material":s=this._invokeOne(function(i){return i.loadMaterial&&i.loadMaterial(t)});break;case"texture":s=this._invokeOne(function(i){return i.loadTexture&&i.loadTexture(t)});break;case"skin":s=this.loadSkin(t);break;case"animation":s=this._invokeOne(function(i){return i.loadAnimation&&i.loadAnimation(t)});break;case"camera":s=this.loadCamera(t);break;default:if(s=this._invokeOne(function(i){return i!=this&&i.getDependency&&i.getDependency(e,t)}),!s)throw new Error("Unknown type: "+e);break}this.cache.add(n,s)}return s}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,s=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(s.map(function(i,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[b.KHR_BINARY_GLTF].body);const s=this.options;return new Promise(function(i,o){n.load(h.LoaderUtils.resolveURL(t.uri,s.path),i,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const s=t.byteLength||0,i=t.byteOffset||0;return n.slice(i,i+s)})}loadAccessor(e){const t=this,n=this.json,s=this.json.accessors[e];if(s.bufferView===void 0&&s.sparse===void 0){const o=z[s.type],r=F[s.componentType],a=s.normalized===!0,c=new r(s.count*o);return Promise.resolve(new h.BufferAttribute(c,o,a))}const i=[];return s.bufferView!==void 0?i.push(this.getDependency("bufferView",s.bufferView)):i.push(null),s.sparse!==void 0&&(i.push(this.getDependency("bufferView",s.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",s.sparse.values.bufferView))),Promise.all(i).then(function(o){const r=o[0],a=z[s.type],c=F[s.componentType],u=c.BYTES_PER_ELEMENT,d=u*a,p=s.byteOffset||0,f=s.bufferView!==void 0?n.bufferViews[s.bufferView].byteStride:void 0,_=s.normalized===!0;let y,m;if(f&&f!==d){const g=Math.floor(p/f),T="InterleavedBuffer:"+s.bufferView+":"+s.componentType+":"+g+":"+s.count;let w=t.cache.get(T);w||(y=new c(r,g*f,s.count*f/u),w=new h.InterleavedBuffer(y,f/u),t.cache.add(T,w)),m=new h.InterleavedBufferAttribute(w,a,p%f/u,_)}else r===null?y=new c(s.count*a):y=new c(r,p,s.count*a),m=new h.BufferAttribute(y,a,_);if(s.sparse!==void 0){const g=z.SCALAR,T=F[s.sparse.indices.componentType],w=s.sparse.indices.byteOffset||0,x=s.sparse.values.byteOffset||0,N=new T(o[1],w,s.sparse.count*g),k=new c(o[2],x,s.sparse.count*a);r!==null&&(m=new h.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let C=0,G=N.length;C<G;C++){const v=N[C];if(m.setX(v,k[C*a]),a>=2&&m.setY(v,k[C*a+1]),a>=3&&m.setZ(v,k[C*a+2]),a>=4&&m.setW(v,k[C*a+3]),a>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=_}return m})}loadTexture(e){const t=this.json,n=this.options,i=t.textures[e].source,o=t.images[i];let r=this.textureLoader;if(o.uri){const a=n.manager.getHandler(o.uri);a!==null&&(r=a)}return this.loadTextureImage(e,i,r)}loadTextureImage(e,t,n){const s=this,i=this.json,o=i.textures[e],r=i.images[t],a=(r.uri||r.bufferView)+":"+o.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=o.name||r.name||"",u.name===""&&typeof r.uri=="string"&&r.uri.startsWith("data:image/")===!1&&(u.name=r.uri);const p=(i.samplers||{})[o.sampler]||{};return u.magFilter=le[p.magFilter]||h.LinearFilter,u.minFilter=le[p.minFilter]||h.LinearMipmapLinearFilter,u.wrapS=he[p.wrapS]||h.RepeatWrapping,u.wrapT=he[p.wrapT]||h.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==h.NearestFilter&&u.minFilter!==h.LinearFilter,s.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const n=this,s=this.json,i=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const o=s.images[e],r=self.URL||self.webkitURL;let a=o.uri||"",c=!1;if(o.bufferView!==void 0)a=n.getDependency("bufferView",o.bufferView).then(function(d){c=!0;const p=new Blob([d],{type:o.mimeType});return a=r.createObjectURL(p),a});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(a).then(function(d){return new Promise(function(p,f){let _=p;t.isImageBitmapLoader===!0&&(_=function(y){const m=new h.Texture(y);m.needsUpdate=!0,p(m)}),t.load(h.LoaderUtils.resolveURL(d,i.path),_,void 0,f)})}).then(function(d){return c===!0&&r.revokeObjectURL(a),I(d,o),d.userData.mimeType=o.mimeType||at(o.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),d});return this.sourceCache[e]=u,u}assignTexture(e,t,n,s){const i=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),i.extensions[b.KHR_TEXTURE_TRANSFORM]){const r=n.extensions!==void 0?n.extensions[b.KHR_TEXTURE_TRANSFORM]:void 0;if(r){const a=i.associations.get(o);o=i.extensions[b.KHR_TEXTURE_TRANSFORM].extendTexture(o,r),i.associations.set(o,a)}}return s!==void 0&&(o.colorSpace=s),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const s=t.attributes.tangent===void 0,i=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const r="PointsMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new h.PointsMaterial,h.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,a.sizeAttenuation=!1,this.cache.add(r,a)),n=a}else if(e.isLine){const r="LineBasicMaterial:"+n.uuid;let a=this.cache.get(r);a||(a=new h.LineBasicMaterial,h.Material.prototype.copy.call(a,n),a.color.copy(n.color),a.map=n.map,this.cache.add(r,a)),n=a}if(s||i||o){let r="ClonedMaterial:"+n.uuid+":";s&&(r+="derivative-tangents:"),i&&(r+="vertex-colors:"),o&&(r+="flat-shading:");let a=this.cache.get(r);a||(a=n.clone(),i&&(a.vertexColors=!0),o&&(a.flatShading=!0),s&&(a.normalScale&&(a.normalScale.y*=-1),a.clearcoatNormalScale&&(a.clearcoatNormalScale.y*=-1)),this.cache.add(r,a),this.associations.set(a,this.associations.get(n))),n=a}e.material=n}getMaterialType(){return h.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,s=this.extensions,i=n.materials[e];let o;const r={},a=i.extensions||{},c=[];if(a[b.KHR_MATERIALS_UNLIT]){const d=s[b.KHR_MATERIALS_UNLIT];o=d.getMaterialType(),c.push(d.extendParams(r,i,t))}else{const d=i.pbrMetallicRoughness||{};if(r.color=new h.Color(1,1,1),r.opacity=1,Array.isArray(d.baseColorFactor)){const p=d.baseColorFactor;r.color.setRGB(p[0],p[1],p[2],h.LinearSRGBColorSpace),r.opacity=p[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(r,"map",d.baseColorTexture,h.SRGBColorSpace)),r.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,r.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(r,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(r,"roughnessMap",d.metallicRoughnessTexture))),o=this._invokeOne(function(p){return p.getMaterialType&&p.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(p){return p.extendMaterialParams&&p.extendMaterialParams(e,r)})))}i.doubleSided===!0&&(r.side=h.DoubleSide);const u=i.alphaMode||W.OPAQUE;if(u===W.BLEND?(r.transparent=!0,r.depthWrite=!1):(r.transparent=!1,u===W.MASK&&(r.alphaTest=i.alphaCutoff!==void 0?i.alphaCutoff:.5)),i.normalTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"normalMap",i.normalTexture)),r.normalScale=new h.Vector2(1,1),i.normalTexture.scale!==void 0)){const d=i.normalTexture.scale;r.normalScale.set(d,d)}if(i.occlusionTexture!==void 0&&o!==h.MeshBasicMaterial&&(c.push(t.assignTexture(r,"aoMap",i.occlusionTexture)),i.occlusionTexture.strength!==void 0&&(r.aoMapIntensity=i.occlusionTexture.strength)),i.emissiveFactor!==void 0&&o!==h.MeshBasicMaterial){const d=i.emissiveFactor;r.emissive=new h.Color().setRGB(d[0],d[1],d[2],h.LinearSRGBColorSpace)}return i.emissiveTexture!==void 0&&o!==h.MeshBasicMaterial&&c.push(t.assignTexture(r,"emissiveMap",i.emissiveTexture,h.SRGBColorSpace)),Promise.all(c).then(function(){const d=new o(r);return i.name&&(d.name=i.name),I(d,i),t.associations.set(d,{materials:e}),i.extensions&&j(s,d,i),d})}createUniqueName(e){const t=h.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,s=this.primitiveCache;function i(r){return n[b.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(r,t).then(function(a){return ue(a,r,t)})}const o=[];for(let r=0,a=e.length;r<a;r++){const c=e[r],u=rt(c),d=s[u];if(d)o.push(d.promise);else{let p;c.extensions&&c.extensions[b.KHR_DRACO_MESH_COMPRESSION]?p=i(c):p=ue(new h.BufferGeometry,c,t),s[u]={primitive:c,promise:p},o.push(p)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,s=this.extensions,i=n.meshes[e],o=i.primitives,r=[];for(let a=0,c=o.length;a<c;a++){const u=o[a].material===void 0?nt(this.cache):this.getDependency("material",o[a].material);r.push(u)}return r.push(t.loadGeometries(o)),Promise.all(r).then(function(a){const c=a.slice(0,a.length-1),u=a[a.length-1],d=[];for(let f=0,_=u.length;f<_;f++){const y=u[f],m=o[f];let g;const T=c[f];if(m.mode===O.TRIANGLES||m.mode===O.TRIANGLE_STRIP||m.mode===O.TRIANGLE_FAN||m.mode===void 0)g=i.isSkinnedMesh===!0?new h.SkinnedMesh(y,T):new h.Mesh(y,T),g.isSkinnedMesh===!0&&g.normalizeSkinWeights(),m.mode===O.TRIANGLE_STRIP?g.geometry=oe(g.geometry,h.TriangleStripDrawMode):m.mode===O.TRIANGLE_FAN&&(g.geometry=oe(g.geometry,h.TriangleFanDrawMode));else if(m.mode===O.LINES)g=new h.LineSegments(y,T);else if(m.mode===O.LINE_STRIP)g=new h.Line(y,T);else if(m.mode===O.LINE_LOOP)g=new h.LineLoop(y,T);else if(m.mode===O.POINTS)g=new h.Points(y,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(g.geometry.morphAttributes).length>0&&ot(g,i),g.name=t.createUniqueName(i.name||"mesh_"+e),I(g,i),m.extensions&&j(s,g,m),t.assignFinalMaterial(g),d.push(g)}for(let f=0,_=d.length;f<_;f++)t.associations.set(d[f],{meshes:e,primitives:f});if(d.length===1)return i.extensions&&j(s,d[0],i),d[0];const p=new h.Group;i.extensions&&j(s,p,i),t.associations.set(p,{meshes:e});for(let f=0,_=d.length;f<_;f++)p.add(d[f]);return p})}loadCamera(e){let t;const n=this.json.cameras[e],s=n[n.type];if(!s){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new h.PerspectiveCamera(h.MathUtils.radToDeg(s.yfov),s.aspectRatio||1,s.znear||1,s.zfar||2e6):n.type==="orthographic"&&(t=new h.OrthographicCamera(-s.xmag,s.xmag,s.ymag,-s.ymag,s.znear,s.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),I(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let s=0,i=t.joints.length;s<i;s++)n.push(this._loadNodeShallow(t.joints[s]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(s){const i=s.pop(),o=s,r=[],a=[];for(let c=0,u=o.length;c<u;c++){const d=o[c];if(d){r.push(d);const p=new h.Matrix4;i!==null&&p.fromArray(i.array,c*16),a.push(p)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new h.Skeleton(r,a)})}loadAnimation(e){const t=this.json,n=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],r=[],a=[],c=[],u=[];for(let d=0,p=s.channels.length;d<p;d++){const f=s.channels[d],_=s.samplers[f.sampler],y=f.target,m=y.node,g=s.parameters!==void 0?s.parameters[_.input]:_.input,T=s.parameters!==void 0?s.parameters[_.output]:_.output;y.node!==void 0&&(o.push(this.getDependency("node",m)),r.push(this.getDependency("accessor",g)),a.push(this.getDependency("accessor",T)),c.push(_),u.push(y))}return Promise.all([Promise.all(o),Promise.all(r),Promise.all(a),Promise.all(c),Promise.all(u)]).then(function(d){const p=d[0],f=d[1],_=d[2],y=d[3],m=d[4],g=[];for(let T=0,w=p.length;T<w;T++){const x=p[T],N=f[T],k=_[T],C=y[T],G=m[T];if(x===void 0)continue;x.updateMatrix&&x.updateMatrix();const v=n._createAnimationTracks(x,N,k,C,G);if(v)for(let Z=0;Z<v.length;Z++)g.push(v[Z])}return new h.AnimationClip(i,void 0,g)})}createNodeMesh(e){const t=this.json,n=this,s=t.nodes[e];return s.mesh===void 0?null:n.getDependency("mesh",s.mesh).then(function(i){const o=n._getNodeRef(n.meshCache,s.mesh,i);return s.weights!==void 0&&o.traverse(function(r){if(r.isMesh)for(let a=0,c=s.weights.length;a<c;a++)r.morphTargetInfluences[a]=s.weights[a]}),o})}loadNode(e){const t=this.json,n=this,s=t.nodes[e],i=n._loadNodeShallow(e),o=[],r=s.children||[];for(let c=0,u=r.length;c<u;c++)o.push(n.getDependency("node",r[c]));const a=s.skin===void 0?Promise.resolve(null):n.getDependency("skin",s.skin);return Promise.all([i,Promise.all(o),a]).then(function(c){const u=c[0],d=c[1],p=c[2];p!==null&&u.traverse(function(f){f.isSkinnedMesh&&f.bind(p,ct)});for(let f=0,_=d.length;f<_;f++)u.add(d[f]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,s=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const i=t.nodes[e],o=i.name?s.createUniqueName(i.name):"",r=[],a=s._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return a&&r.push(a),i.camera!==void 0&&r.push(s.getDependency("camera",i.camera).then(function(c){return s._getNodeRef(s.cameraCache,i.camera,c)})),s._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){r.push(c)}),this.nodeCache[e]=Promise.all(r).then(function(c){let u;if(i.isBone===!0?u=new h.Bone:c.length>1?u=new h.Group:c.length===1?u=c[0]:u=new h.Object3D,u!==c[0])for(let d=0,p=c.length;d<p;d++)u.add(c[d]);if(i.name&&(u.userData.name=i.name,u.name=o),I(u,i),i.extensions&&j(n,u,i),i.matrix!==void 0){const d=new h.Matrix4;d.fromArray(i.matrix),u.applyMatrix4(d)}else i.translation!==void 0&&u.position.fromArray(i.translation),i.rotation!==void 0&&u.quaternion.fromArray(i.rotation),i.scale!==void 0&&u.scale.fromArray(i.scale);if(!s.associations.has(u))s.associations.set(u,{});else if(i.mesh!==void 0&&s.meshCache.refs[i.mesh]>1){const d=s.associations.get(u);s.associations.set(u,{...d})}return s.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],s=this,i=new h.Group;n.name&&(i.name=s.createUniqueName(n.name)),I(i,n),n.extensions&&j(t,i,n);const o=n.nodes||[],r=[];for(let a=0,c=o.length;a<c;a++)r.push(s.getDependency("node",o[a]));return Promise.all(r).then(function(a){for(let u=0,d=a.length;u<d;u++)i.add(a[u]);const c=u=>{const d=new Map;for(const[p,f]of s.associations)(p instanceof h.Material||p instanceof h.Texture)&&d.set(p,f);return u.traverse(p=>{const f=s.associations.get(p);f!=null&&d.set(p,f)}),d};return s.associations=c(i),i})}_createAnimationTracks(e,t,n,s,i){const o=[],r=e.name?e.name:e.uuid,a=[];R[i.path]===R.weights?e.traverse(function(p){p.morphTargetInfluences&&a.push(p.name?p.name:p.uuid)}):a.push(r);let c;switch(R[i.path]){case R.weights:c=h.NumberKeyframeTrack;break;case R.rotation:c=h.QuaternionKeyframeTrack;break;case R.translation:case R.scale:c=h.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=h.NumberKeyframeTrack;break;case 2:case 3:default:c=h.VectorKeyframeTrack;break}break}const u=s.interpolation!==void 0?st[s.interpolation]:h.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let p=0,f=a.length;p<f;p++){const _=new c(a[p]+"."+R[i.path],t.array,d,u);s.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(_),o.push(_)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=q(t.constructor),s=new Float32Array(t.length);for(let i=0,o=t.length;i<o;i++)s[i]=t[i]*n;t=s}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const s=this instanceof h.QuaternionKeyframeTrack?tt:ce;return new s(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ht(l,e,t){const n=e.attributes,s=new h.Box3;if(n.POSITION!==void 0){const r=t.json.accessors[n.POSITION],a=r.min,c=r.max;if(a!==void 0&&c!==void 0){if(s.set(new h.Vector3(a[0],a[1],a[2]),new h.Vector3(c[0],c[1],c[2])),r.normalized){const u=q(F[r.componentType]);s.min.multiplyScalar(u),s.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const i=e.targets;if(i!==void 0){const r=new h.Vector3,a=new h.Vector3;for(let c=0,u=i.length;c<u;c++){const d=i[c];if(d.POSITION!==void 0){const p=t.json.accessors[d.POSITION],f=p.min,_=p.max;if(f!==void 0&&_!==void 0){if(a.setX(Math.max(Math.abs(f[0]),Math.abs(_[0]))),a.setY(Math.max(Math.abs(f[1]),Math.abs(_[1]))),a.setZ(Math.max(Math.abs(f[2]),Math.abs(_[2]))),p.normalized){const y=q(F[p.componentType]);a.multiplyScalar(y)}r.max(a)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(r)}l.boundingBox=s;const o=new h.Sphere;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,l.boundingSphere=o}function ue(l,e,t){const n=e.attributes,s=[];function i(o,r){return t.getDependency("accessor",o).then(function(a){l.setAttribute(r,a)})}for(const o in n){const r=X[o]||o.toLowerCase();r in l.attributes||s.push(i(n[o],r))}if(e.indices!==void 0&&!l.index){const o=t.getDependency("accessor",e.indices).then(function(r){l.setIndex(r)});s.push(o)}return h.ColorManagement.workingColorSpace!==h.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${h.ColorManagement.workingColorSpace}" not supported.`),I(l,e),ht(l,e,t),Promise.all(s).then(function(){return e.targets!==void 0?it(l,e.targets,t):l})}const de={__name:"VroidVrm",props:{url:{type:String},data:{type:[Object,null],default:null},name:{type:String},command:{type:String}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s=async r=>{const a=new Ce;return a.register(c=>new Q.VRMLoaderPlugin(c)),await a.loadAsync(r).then(c=>{const u=c.userData.vrm;return Q.VRMUtils.rotateVRM0(u),u})},i=async r=>{if(!r)return;t("loading",n.name,n.command);const a=await s(r);let c=!1;a&&(c=!0),t("loaded",n.name,n.command,c,a)},o=r=>{t("loading",n.name,n.command);let a=!1;r&&(a=!0),t("loaded",n.name,n.command,a,r)};return M.onMounted(async()=>{n.data!=null?o(n.data):i(n.url)}),M.watch(()=>n.data,()=>{n.data!=null&&o(n.data)}),M.watch(()=>n.url,()=>{n.url&&i(n.url)}),(r,a)=>null}},pe={__name:"VroidModel",props:{name:{type:String},expression_name:{type:String},expression_url:{type:String},expression_data:{type:[Object,null],default:null},pose_name:{type:String},pose_url:{type:String},pose_data:{type:[Object,null],default:null},vrm_name:{type:String},vrm_url:{type:String},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=l,s={},i={},o=M.ref(null),r=M.ref(null),a=M.ref(null),c=(d,p)=>{const f=Object.keys(s).length;s[d]=p;const _=Object.keys(s).length;f==0&&_&&t("loading",n.name)},u=(d,p,f,_)=>{const y=Object.keys(s).length;f&&(p=="load_expression"&&(o.value=_),p=="load_pose"&&(r.value=_),p=="load_vrm"&&(a.value=_),i[d]=p),delete s[d];const m=Object.keys(s).length;if(y&&m==0){const g={};for(const w in i){const x=i[w];x=="load_expression"&&(g.expression=o.value),x=="load_pose"&&(g.pose=r.value),x=="load_vrm"&&(g.vrm=a.value)}t("loaded",n.name,g);const T=Object.keys(i);for(const w of T)delete i[w]}};return(d,p)=>(M.openBlock(),M.createElementBlock(M.Fragment,null,[M.createVNode(ne,{command:"load_expression",name:n.expression_name,url:n.expression_url,data:n.expression_data,onLoading:c,onLoaded:u},null,8,["name","url","data"]),M.createVNode(ie,{command:"load_pose",name:n.pose_name,url:n.pose_url,data:n.pose_data,onLoading:c,onLoaded:u},null,8,["name","url","data"]),M.createVNode(de,{command:"load_vrm",name:n.vrm_name,url:n.vrm_url,data:n.vrm_data,onLoading:c,onLoaded:u},null,8,["name","url","data"])],64))}},ut={__name:"VroidControl",props:{model_name:{type:String,required:!0},expression_name:{type:String,default:"expression"},expression_url:{type:String,default:""},expression_data:{type:[Object,null],default:null},pose_name:{type:String,default:"pose"},pose_url:{type:String,default:""},pose_data:{type:[Object,null],default:null},vrm_name:{type:String,default:"vrm"},vrm_url:{type:String,default:""},vrm_data:{type:[Object,null],default:null}},emits:["loading","loaded"],setup(l,{emit:e}){const t=e,n=M.ref(null);n.value=new J;const s=o=>{t("loading",o)},i=(o,r)=>{"vrm"in r&&n.value.setModel(r.vrm),"pose"in r&&(n.value.setPose(r.pose),n.value.updatePose()),"expression"in r&&(n.value.importExpression(r.expression),n.value.updateExpression()),t("loaded",o,n.value)};return(o,r)=>(M.openBlock(),M.createBlock(pe,{name:l.model_name,expression_name:l.expression_name,expression_url:l.expression_url,expression_data:l.expression_data,pose_name:l.pose_name,pose_url:l.pose_url,pose_data:l.pose_data,vrm_name:l.vrm_name,vrm_url:l.vrm_url,vrm_data:l.vrm_data,onLoading:s,onLoaded:i},null,8,["name","expression_name","expression_url","expression_data","pose_name","pose_url","pose_data","vrm_name","vrm_url","vrm_data"]))}};A.ResourceLoader=V,A.ThreeFrame=Ne,A.VrmModel=J,A.VroidControl=ut,A.VroidExpression=ne,A.VroidModel=pe,A.VroidPose=ie,A.VroidVrm=de,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j-kyoda/vue-three-vrm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "A Vue 3 component designed to render and display VRM models on your web pages.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"url": "https://github.com/j-kyoda/vue-three-vrm.git"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@pixiv/three-vrm": "^3.4.
|
|
24
|
+
"@pixiv/three-vrm": "^3.4.0",
|
|
25
25
|
"axios": "^1.9.0",
|
|
26
|
-
"three": "
|
|
27
|
-
"vue": "^3.5.
|
|
28
|
-
"vue-axios": "^3.5.
|
|
26
|
+
"three": ">=0.137",
|
|
27
|
+
"vue": "^3.5.0",
|
|
28
|
+
"vue-axios": "^3.5.0"
|
|
29
29
|
},
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|