@pixiv/three-vrm-springbone 3.4.2 → 3.4.3

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm-springbone v3.4.2
2
+ * @pixiv/three-vrm-springbone v3.4.3
3
3
  * Spring bone module for @pixiv/three-vrm
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,2 +1,2 @@
1
1
  /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
- "use strict";var Pe=Object.create;var ne=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var je=(n,t)=>{for(var e in t)ne(n,e,{get:t[e],enumerable:!0})},xe=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Oe(t))!De.call(n,i)&&i!==e&&ne(n,i,{get:()=>t[i],enumerable:!(r=Ie(t,i))||r.enumerable});return n};var m=(n,t,e)=>(e=n!=null?Pe(Ae(n)):{},xe(t||!n||!n.__esModule?ne(e,"default",{value:n,enumerable:!0}):e,n)),Je=n=>xe(ne({},"__esModule",{value:!0}),n);var K=(n,t,e)=>new Promise((r,i)=>{var o=a=>{try{l(e.next(a))}catch(p){i(p)}},s=a=>{try{l(e.throw(a))}catch(p){i(p)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(o,s);l((e=e.apply(n,t)).next())});var ze={};je(ze,{VRMSpringBoneCollider:()=>N,VRMSpringBoneColliderHelper:()=>I,VRMSpringBoneColliderShape:()=>v,VRMSpringBoneColliderShapeCapsule:()=>W,VRMSpringBoneColliderShapePlane:()=>X,VRMSpringBoneColliderShapeSphere:()=>F,VRMSpringBoneJoint:()=>oe,VRMSpringBoneJointHelper:()=>$,VRMSpringBoneLoaderPlugin:()=>Re,VRMSpringBoneManager:()=>k});module.exports=Je(ze);var O=m(require("three"),1);var ee=m(require("three"),1);var v=class{};var ue=new ee.Vector3,G=new ee.Vector3,W=class extends v{get type(){return"capsule"}constructor(t){var e,r,i,o;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ee.Vector3(0,0,0),this.tail=(r=t==null?void 0:t.tail)!=null?r:new ee.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0,this.inside=(o=t==null?void 0:t.inside)!=null?o:!1}calculateCollision(t,e,r,i){ue.setFromMatrixPosition(t),G.subVectors(this.tail,this.offset).applyMatrix4(t),G.sub(ue);let o=G.lengthSq();i.copy(e).sub(ue);let s=G.dot(i);s<=0||(o<=s||G.multiplyScalar(s/o),i.sub(G));let l=i.length(),a=this.inside?this.radius-r-l:l-r-this.radius;return a<0&&(i.multiplyScalar(1/l),this.inside&&i.negate()),a}};var Z=m(require("three"),1);var fe=new Z.Vector3,ye=new Z.Matrix3,X=class extends v{get type(){return"plane"}constructor(t){var e,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Z.Vector3(0,0,0),this.normal=(r=t==null?void 0:t.normal)!=null?r:new Z.Vector3(0,0,1)}calculateCollision(t,e,r,i){i.setFromMatrixPosition(t),i.negate().add(e),ye.getNormalMatrix(t),fe.copy(this.normal).applyNormalMatrix(ye).normalize();let o=i.dot(fe)-r;return i.copy(fe),o}};var Ee=m(require("three"),1);var Le=new Ee.Vector3,F=class extends v{get type(){return"sphere"}constructor(t){var e,r,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Ee.Vector3(0,0,0),this.radius=(r=t==null?void 0:t.radius)!=null?r:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,r,i){i.subVectors(e,Le.setFromMatrixPosition(t));let o=i.length(),s=this.inside?this.radius-r-o:o-r-this.radius;return s<0&&(i.multiplyScalar(1/o),this.inside&&i.negate()),s}};var B=m(require("three"),1),H=new B.Vector3,se=class extends B.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new B.Vector3;this._currentTail=new B.Vector3;this._shape=e,this._attrPos=new B.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new B.BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let i=H.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(i)>1e-10&&(this._currentTail.copy(i),e=!0),e&&this._buildPosition()}_buildPosition(){H.copy(this._currentTail).sub(this._currentOffset);let e=H.length()/this._currentRadius;for(let o=0;o<=16;o++){let s=o/16*Math.PI;this._attrPos.setXYZ(o,-Math.sin(s),-Math.cos(s),0),this._attrPos.setXYZ(17+o,e+Math.sin(s),Math.cos(s),0),this._attrPos.setXYZ(34+o,-Math.sin(s),0,-Math.cos(s)),this._attrPos.setXYZ(51+o,e+Math.sin(s),0,Math.cos(s))}for(let o=0;o<32;o++){let s=o/16*Math.PI;this._attrPos.setXYZ(68+o,0,Math.sin(s),Math.cos(s)),this._attrPos.setXYZ(100+o,e,Math.sin(s),Math.cos(s))}let r=Math.atan2(H.y,Math.sqrt(H.x*H.x+H.z*H.z)),i=-Math.atan2(H.z,H.x);this.rotateZ(r),this.rotateY(i),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){let r=(e+1)%34;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(68+e*2,34+e,34+r)}for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+r),this._attrIndex.setXY(200+e*2,100+e,100+r)}this._attrIndex.needsUpdate=!0}};var P=m(require("three"),1),ae=class extends P.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentOffset=new P.Vector3;this._currentNormal=new P.Vector3;this._shape=e,this._attrPos=new P.BufferAttribute(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new P.BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}};var U=m(require("three"),1),le=class extends U.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new U.Vector3;this._shape=e,this._attrPos=new U.BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new U.BufferAttribute(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.needsUpdate=!0}};var Ge=new O.Vector3,I=class extends O.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof F)this._geometry=new le(this.collider.shape);else if(this.collider.shape instanceof W)this._geometry=new se(this.collider.shape);else if(this.collider.shape instanceof X)this._geometry=new ae(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new O.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new O.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=Ge.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};var A=m(require("three"),1);var Y=m(require("three"),1),ce=class extends Y.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentTail=new Y.Vector3;this._springBone=e,this._attrPos=new Y.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Y.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}};var We=new A.Vector3,$=class extends A.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new ce(this.springBone);let e=new A.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new A.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=We.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};var pe=m(require("three"),1),N=class extends pe.Object3D{constructor(e){super();this.colliderMatrix=new pe.Matrix4;this.shape=e}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Xe(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Xe(n,t,e){let r=t.elements;n.copy(t),e&&(n.elements[12]=r[0]*e.x+r[4]*e.y+r[8]*e.z+r[12],n.elements[13]=r[1]*e.x+r[5]*e.y+r[9]*e.z+r[13],n.elements[14]=r[2]*e.x+r[6]*e.y+r[10]*e.z+r[14])}var E=m(require("three"),1);var ve=m(require("three"),1);var He=m(require("three"),1),Fe=new He.Matrix4;function Ve(n){return n.invert?n.invert():n.getInverse(Fe.copy(n)),n}var de=class{constructor(t){this._inverseCache=new ve.Matrix4;this._shouldUpdateInverse=!0;this.matrix=t;let e={set:(r,i,o)=>(this._shouldUpdateInverse=!0,r[i]=o,!0)};this._originalElements=t.elements,t.elements=new Proxy(t.elements,e)}get inverse(){return this._shouldUpdateInverse&&(Ve(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}};var _e=new E.Matrix4,q=new E.Vector3,te=new E.Vector3,re=new E.Vector3,ie=new E.Vector3,Ue=new E.Matrix4,oe=class{constructor(t,e,r={},i=[]){this._currentTail=new E.Vector3;this._prevTail=new E.Vector3;this._boneAxis=new E.Vector3;this._worldSpaceBoneLength=0;this._center=null;this._initialLocalMatrix=new E.Matrix4;this._initialLocalRotation=new E.Quaternion;this._initialLocalChildPosition=new E.Vector3;var o,s,l,a,p,b;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(o=r.hitRadius)!=null?o:0,stiffness:(s=r.stiffness)!=null?s:1,gravityPower:(l=r.gravityPower)!=null?l:0,gravityDir:(p=(a=r.gravityDir)==null?void 0:a.clone())!=null?p:new E.Vector3(0,-1,0),dragForce:(b=r.dragForce)!=null?b:.4},this.colliderGroups=i}get dependencies(){let t=new Set,e=this.bone.parent;e&&t.add(e);for(let r=0;r<this.colliderGroups.length;r++)for(let i=0;i<this.colliderGroups[r].colliders.length;i++)t.add(this.colliderGroups[r].colliders[i]);return t}get center(){return this._center}set center(t){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=t,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new de(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:_e}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength();let e=te.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);ie.copy(this._currentTail).add(q.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*t).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*t),re.setFromMatrixPosition(this.bone.matrixWorld),ie.sub(re).normalize().multiplyScalar(this._worldSpaceBoneLength).add(re),this._collision(ie),this._prevTail.copy(this._currentTail),this._currentTail.copy(ie).applyMatrix4(this._getMatrixWorldToCenter());let r=Ue.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,q.copy(ie).applyMatrix4(r).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let r=0;r<this.colliderGroups[e].colliders.length;r++){let i=this.colliderGroups[e].colliders[r],o=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,q);if(o<0){t.addScaledVector(q,-o),t.sub(re);let s=t.length();t.multiplyScalar(this._worldSpaceBoneLength/s).add(re)}}}_calcWorldSpaceBoneLength(){q.setFromMatrixPosition(this.bone.matrixWorld),this.child?te.setFromMatrixPosition(this.child.matrixWorld):(te.copy(this._initialLocalChildPosition),te.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=q.sub(te).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:_e}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:_e}};var S=m(require("three"),1);function Be(n,t){let e=[],r=n;for(;r!==null;)e.unshift(r),r=r.parent;e.forEach(i=>{t(i)})}function he(n,t){n.children.forEach(e=>{t(e)||he(e,t)})}function we(n){var e;let t=new Map;for(let r of n){let i=r;do{let o=((e=t.get(i))!=null?e:0)+1;if(o===n.size)return i;t.set(i,o),i=i.parent}while(i!==null)}return null}var k=class{constructor(){this._joints=new Set;this._sortedJoints=[];this._hasWarnedCircularDependency=!1;this._ancestors=[];this._objectSpringBonesMap=new Map;this._isSortedJointsDirty=!1;this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let t=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(r=>{t.add(r)})}),Array.from(t)}get colliders(){let t=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(r=>{t.add(r)})}),Array.from(t)}addJoint(t){this._joints.add(t);let e=this._objectSpringBonesMap.get(t.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(t.bone,e)),e.add(t),this._isSortedJointsDirty=!0}addSpringBone(t){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(t)}deleteJoint(t){this._joints.delete(t),this._objectSpringBonesMap.get(t.bone).delete(t),this._isSortedJointsDirty=!0}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(t){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){let r=this._sortedJoints[e];r.bone.updateMatrix(),r.bone.updateWorldMatrix(!1,!1),r.update(t),he(r.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;let t=[],e=new Set,r=new Set,i=new Set;for(let s of this._joints)this._insertJointSort(s,e,r,t,i);this._sortedJoints=t;let o=we(i);this._ancestors=[],o&&(this._ancestors.push(o),he(o,s=>{var l,a;return((a=(l=this._objectSpringBonesMap.get(s))==null?void 0:l.size)!=null?a:0)>0?!0:(this._ancestors.push(s),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(t,e,r,i,o){if(r.has(t))return;if(e.has(t)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(t);let s=t.dependencies;for(let l of s){let a=!1,p=null;Be(l,b=>{let w=this._objectSpringBonesMap.get(b);if(w)for(let j of w)a=!0,this._insertJointSort(j,e,r,i,o);else a||(p=b)}),p&&o.add(p)}i.push(t),r.add(t)}_relevantChildrenUpdated(t){var e,r;return((r=(e=this._objectSpringBonesMap.get(t))==null?void 0:e.size)!=null?r:0)>0?!0:(t.updateWorldMatrix(!1,!1),!1)}};var Ce="VRMC_springBone_extended_collider",Ye=new Set(["1.0","1.0-beta"]),Ne=new Set(["1.0"]),D=class D{get name(){return D.EXTENSION_NAME}constructor(t,e){var r;this.parser=t,this.jointHelperRoot=e==null?void 0:e.jointHelperRoot,this.colliderHelperRoot=e==null?void 0:e.colliderHelperRoot,this.useExtendedColliders=(r=e==null?void 0:e.useExtendedColliders)!=null?r:!0}afterRoot(t){return K(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return K(this,null,function*(){let e=yield this._v1Import(t);if(e!=null)return e;let r=yield this._v0Import(t);return r!=null?r:null})}_v1Import(t){return K(this,null,function*(){var b,w,j,d,z;let e=t.parser.json;if(!(((b=e.extensionsUsed)==null?void 0:b.indexOf(D.EXTENSION_NAME))!==-1))return null;let i=new k,o=yield t.parser.getDependencies("node"),s=(w=e.extensions)==null?void 0:w[D.EXTENSION_NAME];if(!s)return null;let l=s.specVersion;if(!Ye.has(l))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${D.EXTENSION_NAME} specVersion "${l}"`),null;let a=(j=s.colliders)==null?void 0:j.map((f,T)=>{var c,M,R,x,J,L,y,V,C,Q,me,ge,Se,be,Te;let h=o[f.node];if(h==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${T} attempted to use the node #${f.node} but not found`),null;let u=f.shape,_=(c=f.extensions)==null?void 0:c[Ce];if(this.useExtendedColliders&&_!=null){let Me=_.specVersion;if(!Ne.has(Me))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ce} specVersion "${Me}". Fallbacking to the ${D.EXTENSION_NAME} definition`);else{let g=_.shape;if(g.sphere)return this._importSphereCollider(h,{offset:new S.Vector3().fromArray((M=g.sphere.offset)!=null?M:[0,0,0]),radius:(R=g.sphere.radius)!=null?R:0,inside:(x=g.sphere.inside)!=null?x:!1});if(g.capsule)return this._importCapsuleCollider(h,{offset:new S.Vector3().fromArray((J=g.capsule.offset)!=null?J:[0,0,0]),radius:(L=g.capsule.radius)!=null?L:0,tail:new S.Vector3().fromArray((y=g.capsule.tail)!=null?y:[0,0,0]),inside:(V=g.capsule.inside)!=null?V:!1});if(g.plane)return this._importPlaneCollider(h,{offset:new S.Vector3().fromArray((C=g.plane.offset)!=null?C:[0,0,0]),normal:new S.Vector3().fromArray((Q=g.plane.normal)!=null?Q:[0,0,1])})}}if(u.sphere)return this._importSphereCollider(h,{offset:new S.Vector3().fromArray((me=u.sphere.offset)!=null?me:[0,0,0]),radius:(ge=u.sphere.radius)!=null?ge:0,inside:!1});if(u.capsule)return this._importCapsuleCollider(h,{offset:new S.Vector3().fromArray((Se=u.capsule.offset)!=null?Se:[0,0,0]),radius:(be=u.capsule.radius)!=null?be:0,tail:new S.Vector3().fromArray((Te=u.capsule.tail)!=null?Te:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${T} has no valid shape`)}),p=(d=s.colliderGroups)==null?void 0:d.map((f,T)=>{var u;return{colliders:((u=f.colliders)!=null?u:[]).flatMap(_=>{let c=a==null?void 0:a[_];return c==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${T} attempted to use a collider #${_} but not found`),[]):c}),name:f.name}});return(z=s.springs)==null||z.forEach((f,T)=>{var M;let h=f.joints,u=(M=f.colliderGroups)==null?void 0:M.map(R=>{let x=p==null?void 0:p[R];if(x==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${T} attempted to use a colliderGroup ${R} but not found`);return x}),_=f.center!=null?o[f.center]:void 0,c;h.forEach(R=>{if(c){let x=c.node,J=o[x],L=R.node,y=o[L],V={hitRadius:c.hitRadius,dragForce:c.dragForce,gravityPower:c.gravityPower,stiffness:c.stiffness,gravityDir:c.gravityDir!=null?new S.Vector3().fromArray(c.gravityDir):void 0},C=this._importJoint(J,y,V,u);_&&(C.center=_),i.addJoint(C)}c=R})}),i.setInitState(),i})}_v0Import(t){return K(this,null,function*(){var b,w,j;let e=t.parser.json;if(!(((b=e.extensionsUsed)==null?void 0:b.indexOf("VRM"))!==-1))return null;let i=(w=e.extensions)==null?void 0:w.VRM,o=i==null?void 0:i.secondaryAnimation;if(!o)return null;let s=o==null?void 0:o.boneGroups;if(!s)return null;let l=new k,a=yield t.parser.getDependencies("node"),p=(j=o.colliderGroups)==null?void 0:j.map(d=>{var T;let z=a[d.node];return{colliders:((T=d.colliders)!=null?T:[]).map((h,u)=>{var c,M,R;let _=new S.Vector3(0,0,0);return h.offset&&_.set((c=h.offset.x)!=null?c:0,(M=h.offset.y)!=null?M:0,h.offset.z?-h.offset.z:0),this._importSphereCollider(z,{offset:_,radius:(R=h.radius)!=null?R:0,inside:!1})})}});return s==null||s.forEach((d,z)=>{let f=d.bones;f&&f.forEach(T=>{var R,x,J,L;let h=a[T],u=new S.Vector3;d.gravityDir?u.set((R=d.gravityDir.x)!=null?R:0,(x=d.gravityDir.y)!=null?x:0,(J=d.gravityDir.z)!=null?J:0):u.set(0,-1,0);let _=d.center!=null?a[d.center]:void 0,c={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:u},M=(L=d.colliderGroups)==null?void 0:L.map(y=>{let V=p==null?void 0:p[y];if(V==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${z} attempted to use a colliderGroup ${y} but not found`);return V});h.traverse(y=>{var Q;let V=(Q=y.children[0])!=null?Q:null,C=this._importJoint(y,V,c,M);_&&(C.center=_),l.addJoint(C)})})}),t.scene.updateMatrixWorld(),l.setInitState(),l})}_importJoint(t,e,r,i){let o=new oe(t,e,r,i);if(this.jointHelperRoot){let s=new $(o);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(t,e){let r=new F(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importCapsuleCollider(t,e){let r=new W(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importPlaneCollider(t,e){let r=new X(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}};D.EXTENSION_NAME="VRMC_springBone";var Re=D;
2
+ "use strict";var Pe=Object.create;var ne=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var je=(n,t)=>{for(var e in t)ne(n,e,{get:t[e],enumerable:!0})},xe=(n,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Oe(t))!De.call(n,i)&&i!==e&&ne(n,i,{get:()=>t[i],enumerable:!(r=Ie(t,i))||r.enumerable});return n};var m=(n,t,e)=>(e=n!=null?Pe(Ae(n)):{},xe(t||!n||!n.__esModule?ne(e,"default",{value:n,enumerable:!0}):e,n)),Je=n=>xe(ne({},"__esModule",{value:!0}),n);var K=(n,t,e)=>new Promise((r,i)=>{var o=a=>{try{l(e.next(a))}catch(p){i(p)}},s=a=>{try{l(e.throw(a))}catch(p){i(p)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(o,s);l((e=e.apply(n,t)).next())});var ze={};je(ze,{VRMSpringBoneCollider:()=>N,VRMSpringBoneColliderHelper:()=>I,VRMSpringBoneColliderShape:()=>v,VRMSpringBoneColliderShapeCapsule:()=>W,VRMSpringBoneColliderShapePlane:()=>X,VRMSpringBoneColliderShapeSphere:()=>F,VRMSpringBoneJoint:()=>oe,VRMSpringBoneJointHelper:()=>$,VRMSpringBoneLoaderPlugin:()=>Re,VRMSpringBoneManager:()=>k});module.exports=Je(ze);var O=m(require("three"),1);var ee=m(require("three"),1);var v=class{};var ue=new ee.Vector3,G=new ee.Vector3,W=class extends v{get type(){return"capsule"}constructor(t){var e,r,i,o;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ee.Vector3(0,0,0),this.tail=(r=t==null?void 0:t.tail)!=null?r:new ee.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0,this.inside=(o=t==null?void 0:t.inside)!=null?o:!1}calculateCollision(t,e,r,i){ue.setFromMatrixPosition(t),G.subVectors(this.tail,this.offset).applyMatrix4(t),G.sub(ue);let o=G.lengthSq();i.copy(e).sub(ue);let s=G.dot(i);s<=0||(o<=s||G.multiplyScalar(s/o),i.sub(G));let l=i.length(),a=this.inside?this.radius-r-l:l-r-this.radius;return a<0&&(i.multiplyScalar(1/l),this.inside&&i.negate()),a}};var Z=m(require("three"),1);var fe=new Z.Vector3,ye=new Z.Matrix3,X=class extends v{get type(){return"plane"}constructor(t){var e,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Z.Vector3(0,0,0),this.normal=(r=t==null?void 0:t.normal)!=null?r:new Z.Vector3(0,0,1)}calculateCollision(t,e,r,i){i.setFromMatrixPosition(t),i.negate().add(e),ye.getNormalMatrix(t),fe.copy(this.normal).applyNormalMatrix(ye).normalize();let o=i.dot(fe)-r;return i.copy(fe),o}};var Ee=m(require("three"),1);var Le=new Ee.Vector3,F=class extends v{get type(){return"sphere"}constructor(t){var e,r,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new Ee.Vector3(0,0,0),this.radius=(r=t==null?void 0:t.radius)!=null?r:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,r,i){i.subVectors(e,Le.setFromMatrixPosition(t));let o=i.length(),s=this.inside?this.radius-r-o:o-r-this.radius;return s<0&&(i.multiplyScalar(1/o),this.inside&&i.negate()),s}};var B=m(require("three"),1),H=new B.Vector3,se=class extends B.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new B.Vector3;this._currentTail=new B.Vector3;this._shape=e,this._attrPos=new B.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new B.BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let i=H.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(i)>1e-10&&(this._currentTail.copy(i),e=!0),e&&this._buildPosition()}_buildPosition(){H.copy(this._currentTail).sub(this._currentOffset);let e=H.length()/this._currentRadius;for(let o=0;o<=16;o++){let s=o/16*Math.PI;this._attrPos.setXYZ(o,-Math.sin(s),-Math.cos(s),0),this._attrPos.setXYZ(17+o,e+Math.sin(s),Math.cos(s),0),this._attrPos.setXYZ(34+o,-Math.sin(s),0,-Math.cos(s)),this._attrPos.setXYZ(51+o,e+Math.sin(s),0,Math.cos(s))}for(let o=0;o<32;o++){let s=o/16*Math.PI;this._attrPos.setXYZ(68+o,0,Math.sin(s),Math.cos(s)),this._attrPos.setXYZ(100+o,e,Math.sin(s),Math.cos(s))}let r=Math.atan2(H.y,Math.sqrt(H.x*H.x+H.z*H.z)),i=-Math.atan2(H.z,H.x);this.rotateZ(r),this.rotateY(i),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){let r=(e+1)%34;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(68+e*2,34+e,34+r)}for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+r),this._attrIndex.setXY(200+e*2,100+e,100+r)}this._attrIndex.needsUpdate=!0}};var P=m(require("three"),1),ae=class extends P.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentOffset=new P.Vector3;this._currentNormal=new P.Vector3;this._shape=e,this._attrPos=new P.BufferAttribute(new Float32Array(18),3),this.setAttribute("position",this._attrPos),this._attrIndex=new P.BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}};var U=m(require("three"),1),le=class extends U.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new U.Vector3;this._shape=e,this._attrPos=new U.BufferAttribute(new Float32Array(288),3),this.setAttribute("position",this._attrPos),this._attrIndex=new U.BufferAttribute(new Uint16Array(192),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.needsUpdate=!0}};var Ge=new O.Vector3,I=class extends O.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof F)this._geometry=new le(this.collider.shape);else if(this.collider.shape instanceof W)this._geometry=new se(this.collider.shape);else if(this.collider.shape instanceof X)this._geometry=new ae(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new O.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new O.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=Ge.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};var A=m(require("three"),1);var Y=m(require("three"),1),ce=class extends Y.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentTail=new Y.Vector3;this._springBone=e,this._attrPos=new Y.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new Y.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}};var We=new A.Vector3,$=class extends A.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new ce(this.springBone);let e=new A.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new A.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=We.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};var pe=m(require("three"),1),N=class extends pe.Object3D{constructor(e){super();this.colliderMatrix=new pe.Matrix4;this.shape=e}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Xe(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Xe(n,t,e){let r=t.elements;n.copy(t),e&&(n.elements[12]=r[0]*e.x+r[4]*e.y+r[8]*e.z+r[12],n.elements[13]=r[1]*e.x+r[5]*e.y+r[9]*e.z+r[13],n.elements[14]=r[2]*e.x+r[6]*e.y+r[10]*e.z+r[14])}var E=m(require("three"),1);var ve=m(require("three"),1);var He=m(require("three"),1),Fe=new He.Matrix4;function Ve(n){return n.invert?n.invert():n.getInverse(Fe.copy(n)),n}var de=class{constructor(t){this._inverseCache=new ve.Matrix4;this._shouldUpdateInverse=!0;this.matrix=t;let e={set:(r,i,o)=>(this._shouldUpdateInverse=!0,r[i]=o,!0)};this._originalElements=t.elements,t.elements=new Proxy(t.elements,e)}get inverse(){return this._shouldUpdateInverse&&(Ve(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}};var _e=new E.Matrix4,q=new E.Vector3,te=new E.Vector3,re=new E.Vector3,ie=new E.Vector3,Ue=new E.Matrix4,oe=class{constructor(t,e,r={},i=[]){this._currentTail=new E.Vector3;this._prevTail=new E.Vector3;this._boneAxis=new E.Vector3;this._worldSpaceBoneLength=0;this._center=null;this._initialLocalMatrix=new E.Matrix4;this._initialLocalRotation=new E.Quaternion;this._initialLocalChildPosition=new E.Vector3;var o,s,l,a,p,b;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(o=r.hitRadius)!=null?o:0,stiffness:(s=r.stiffness)!=null?s:1,gravityPower:(l=r.gravityPower)!=null?l:0,gravityDir:(p=(a=r.gravityDir)==null?void 0:a.clone())!=null?p:new E.Vector3(0,-1,0),dragForce:(b=r.dragForce)!=null?b:.4},this.colliderGroups=i}get dependencies(){let t=new Set,e=this.bone.parent;e&&t.add(e);for(let r=0;r<this.colliderGroups.length;r++)for(let i=0;i<this.colliderGroups[r].colliders.length;i++)t.add(this.colliderGroups[r].colliders[i]);return t}get center(){return this._center}set center(t){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=t,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new de(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:_e}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength();let e=te.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);ie.copy(this._currentTail).add(q.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*t).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*t),re.setFromMatrixPosition(this.bone.matrixWorld),ie.sub(re).normalize().multiplyScalar(this._worldSpaceBoneLength).add(re),this._collision(ie),this._prevTail.copy(this._currentTail),this._currentTail.copy(ie).applyMatrix4(this._getMatrixWorldToCenter());let r=Ue.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,q.copy(ie).applyMatrix4(r).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let r=0;r<this.colliderGroups[e].colliders.length;r++){let i=this.colliderGroups[e].colliders[r],o=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,q);if(o<0){t.addScaledVector(q,-o),t.sub(re);let s=t.length();t.multiplyScalar(this._worldSpaceBoneLength/s).add(re)}}}_calcWorldSpaceBoneLength(){q.setFromMatrixPosition(this.bone.matrixWorld),this.child?te.setFromMatrixPosition(this.child.matrixWorld):(te.copy(this._initialLocalChildPosition),te.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=q.sub(te).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:_e}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:_e}};var S=m(require("three"),1);function Be(n,t){let e=[],r=n;for(;r!==null;)e.unshift(r),r=r.parent;e.forEach(i=>{t(i)})}function he(n,t){n.children.forEach(e=>{t(e)||he(e,t)})}function we(n){var e;let t=new Map;for(let r of n){let i=r;do{let o=((e=t.get(i))!=null?e:0)+1;if(o===n.size)return i;t.set(i,o),i=i.parent}while(i!==null)}return null}var k=class{constructor(){this._joints=new Set;this._sortedJoints=[];this._hasWarnedCircularDependency=!1;this._ancestors=[];this._objectSpringBonesMap=new Map;this._isSortedJointsDirty=!1;this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let t=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(r=>{t.add(r)})}),Array.from(t)}get colliders(){let t=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(r=>{t.add(r)})}),Array.from(t)}addJoint(t){this._joints.add(t);let e=this._objectSpringBonesMap.get(t.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(t.bone,e)),e.add(t),this._isSortedJointsDirty=!0}addSpringBone(t){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(t)}deleteJoint(t){this._joints.delete(t),this._objectSpringBonesMap.get(t.bone).delete(t),this._isSortedJointsDirty=!0}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(t){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){let r=this._sortedJoints[e];r.bone.updateMatrix(),r.bone.updateWorldMatrix(!1,!1),r.update(t),he(r.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;let t=[],e=new Set,r=new Set,i=new Set;for(let s of this._joints)this._insertJointSort(s,e,r,t,i);this._sortedJoints=t;let o=we(i);this._ancestors=[],o&&(this._ancestors.push(o),he(o,s=>{var l,a;return((a=(l=this._objectSpringBonesMap.get(s))==null?void 0:l.size)!=null?a:0)>0?!0:(this._ancestors.push(s),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(t,e,r,i,o){if(r.has(t))return;if(e.has(t)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(t);let s=t.dependencies;for(let l of s){let a=!1,p=null;Be(l,b=>{let w=this._objectSpringBonesMap.get(b);if(w)for(let j of w)a=!0,this._insertJointSort(j,e,r,i,o);else a||(p=b)}),p&&o.add(p)}i.push(t),r.add(t)}_relevantChildrenUpdated(t){var e,r;return((r=(e=this._objectSpringBonesMap.get(t))==null?void 0:e.size)!=null?r:0)>0?!0:(t.updateWorldMatrix(!1,!1),!1)}};var Ce="VRMC_springBone_extended_collider",Ye=new Set(["1.0","1.0-beta"]),Ne=new Set(["1.0"]),D=class D{get name(){return D.EXTENSION_NAME}constructor(t,e){var r;this.parser=t,this.jointHelperRoot=e==null?void 0:e.jointHelperRoot,this.colliderHelperRoot=e==null?void 0:e.colliderHelperRoot,this.useExtendedColliders=(r=e==null?void 0:e.useExtendedColliders)!=null?r:!0}afterRoot(t){return K(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return K(this,null,function*(){let e=yield this._v1Import(t);if(e!=null)return e;let r=yield this._v0Import(t);return r!=null?r:null})}_v1Import(t){return K(this,null,function*(){var b,w,j,d,z;let e=t.parser.json;if(!(((b=e.extensionsUsed)==null?void 0:b.indexOf(D.EXTENSION_NAME))!==-1))return null;let i=new k,o=yield t.parser.getDependencies("node"),s=(w=e.extensions)==null?void 0:w[D.EXTENSION_NAME];if(!s)return null;let l=s.specVersion;if(!Ye.has(l))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${D.EXTENSION_NAME} specVersion "${l}"`),null;let a=(j=s.colliders)==null?void 0:j.map((f,T)=>{var c,M,R,x,J,L,y,V,C,Q,me,ge,Se,be,Te;let h=o[f.node];if(h==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${T} attempted to use the node #${f.node} but not found`),null;let u=f.shape,_=(c=f.extensions)==null?void 0:c[Ce];if(this.useExtendedColliders&&_!=null){let Me=_.specVersion;if(!Ne.has(Me))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ce} specVersion "${Me}". Fallbacking to the ${D.EXTENSION_NAME} definition`);else{let g=_.shape;if(g.sphere)return this._importSphereCollider(h,{offset:new S.Vector3().fromArray((M=g.sphere.offset)!=null?M:[0,0,0]),radius:(R=g.sphere.radius)!=null?R:0,inside:(x=g.sphere.inside)!=null?x:!1});if(g.capsule)return this._importCapsuleCollider(h,{offset:new S.Vector3().fromArray((J=g.capsule.offset)!=null?J:[0,0,0]),radius:(L=g.capsule.radius)!=null?L:0,tail:new S.Vector3().fromArray((y=g.capsule.tail)!=null?y:[0,0,0]),inside:(V=g.capsule.inside)!=null?V:!1});if(g.plane)return this._importPlaneCollider(h,{offset:new S.Vector3().fromArray((C=g.plane.offset)!=null?C:[0,0,0]),normal:new S.Vector3().fromArray((Q=g.plane.normal)!=null?Q:[0,0,1])})}}if(u.sphere)return this._importSphereCollider(h,{offset:new S.Vector3().fromArray((me=u.sphere.offset)!=null?me:[0,0,0]),radius:(ge=u.sphere.radius)!=null?ge:0,inside:!1});if(u.capsule)return this._importCapsuleCollider(h,{offset:new S.Vector3().fromArray((Se=u.capsule.offset)!=null?Se:[0,0,0]),radius:(be=u.capsule.radius)!=null?be:0,tail:new S.Vector3().fromArray((Te=u.capsule.tail)!=null?Te:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${T} has no valid shape`)}),p=(d=s.colliderGroups)==null?void 0:d.map((f,T)=>{var u;return{colliders:((u=f.colliders)!=null?u:[]).flatMap(_=>{let c=a==null?void 0:a[_];return c==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${T} attempted to use a collider #${_} but not found`),[]):c}),name:f.name}});return(z=s.springs)==null||z.forEach((f,T)=>{var M;let h=f.joints,u=(M=f.colliderGroups)==null?void 0:M.map(R=>{let x=p==null?void 0:p[R];if(x==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${T} attempted to use a colliderGroup ${R} but not found`);return x}),_=f.center!=null?o[f.center]:void 0,c;h.forEach(R=>{if(c){let x=c.node,J=o[x],L=R.node,y=o[L],V={hitRadius:c.hitRadius,dragForce:c.dragForce,gravityPower:c.gravityPower,stiffness:c.stiffness,gravityDir:c.gravityDir!=null?new S.Vector3().fromArray(c.gravityDir):void 0},C=this._importJoint(J,y,V,u);_&&(C.center=_),i.addJoint(C)}c=R})}),i.setInitState(),i})}_v0Import(t){return K(this,null,function*(){var b,w,j;let e=t.parser.json;if(!(((b=e.extensionsUsed)==null?void 0:b.indexOf("VRM"))!==-1))return null;let i=(w=e.extensions)==null?void 0:w.VRM,o=i==null?void 0:i.secondaryAnimation;if(!o)return null;let s=o==null?void 0:o.boneGroups;if(!s)return null;let l=new k,a=yield t.parser.getDependencies("node"),p=(j=o.colliderGroups)==null?void 0:j.map(d=>{var T;let z=a[d.node];return{colliders:((T=d.colliders)!=null?T:[]).map((h,u)=>{var c,M,R;let _=new S.Vector3(0,0,0);return h.offset&&_.set((c=h.offset.x)!=null?c:0,(M=h.offset.y)!=null?M:0,h.offset.z?-h.offset.z:0),this._importSphereCollider(z,{offset:_,radius:(R=h.radius)!=null?R:0,inside:!1})})}});return s==null||s.forEach((d,z)=>{let f=d.bones;f&&f.forEach(T=>{var R,x,J,L;let h=a[T],u=new S.Vector3;d.gravityDir?u.set((R=d.gravityDir.x)!=null?R:0,(x=d.gravityDir.y)!=null?x:0,(J=d.gravityDir.z)!=null?J:0):u.set(0,-1,0);let _=d.center!=null?a[d.center]:void 0,c={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:u},M=(L=d.colliderGroups)==null?void 0:L.map(y=>{let V=p==null?void 0:p[y];if(V==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${z} attempted to use a colliderGroup ${y} but not found`);return V});h.traverse(y=>{var Q;let V=(Q=y.children[0])!=null?Q:null,C=this._importJoint(y,V,c,M);_&&(C.center=_),l.addJoint(C)})})}),t.scene.updateMatrixWorld(),l.setInitState(),l})}_importJoint(t,e,r,i){let o=new oe(t,e,r,i);if(this.jointHelperRoot){let s=new $(o);this.jointHelperRoot.add(s),s.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(t,e){let r=new F(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importCapsuleCollider(t,e){let r=new W(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importPlaneCollider(t,e){let r=new X(e),i=new N(r);if(t.add(i),this.colliderHelperRoot){let o=new I(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}};D.EXTENSION_NAME="VRMC_springBone";var Re=D;
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @pixiv/three-vrm-springbone v3.4.2
2
+ * @pixiv/three-vrm-springbone v3.4.3
3
3
  * Spring bone module for @pixiv/three-vrm
4
4
  *
5
5
  * Copyright (c) 2019-2025 pixiv Inc.
@@ -1,2 +1,2 @@
1
1
  /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
- var q=(s,t,e)=>new Promise((r,i)=>{var o=a=>{try{l(e.next(a))}catch(p){i(p)}},n=a=>{try{l(e.throw(a))}catch(p){i(p)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(o,n);l((e=e.apply(s,t)).next())});import*as P from"three";import*as k from"three";var w=class{};var de=new k.Vector3,J=new k.Vector3,F=class extends w{get type(){return"capsule"}constructor(t){var e,r,i,o;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new k.Vector3(0,0,0),this.tail=(r=t==null?void 0:t.tail)!=null?r:new k.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0,this.inside=(o=t==null?void 0:t.inside)!=null?o:!1}calculateCollision(t,e,r,i){de.setFromMatrixPosition(t),J.subVectors(this.tail,this.offset).applyMatrix4(t),J.sub(de);let o=J.lengthSq();i.copy(e).sub(de);let n=J.dot(i);n<=0||(o<=n||J.multiplyScalar(n/o),i.sub(J));let l=i.length(),a=this.inside?this.radius-r-l:l-r-this.radius;return a<0&&(i.multiplyScalar(1/l),this.inside&&i.negate()),a}};import*as U from"three";var he=new U.Vector3,be=new U.Matrix3,Y=class extends w{get type(){return"plane"}constructor(t){var e,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new U.Vector3(0,0,0),this.normal=(r=t==null?void 0:t.normal)!=null?r:new U.Vector3(0,0,1)}calculateCollision(t,e,r,i){i.setFromMatrixPosition(t),i.negate().add(e),be.getNormalMatrix(t),he.copy(this.normal).applyNormalMatrix(be).normalize();let o=i.dot(he)-r;return i.copy(he),o}};import*as ue from"three";var Be=new ue.Vector3,N=class extends w{get type(){return"sphere"}constructor(t){var e,r,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ue.Vector3(0,0,0),this.radius=(r=t==null?void 0:t.radius)!=null?r:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,r,i){i.subVectors(e,Be.setFromMatrixPosition(t));let o=i.length(),n=this.inside?this.radius-r-o:o-r-this.radius;return n<0&&(i.multiplyScalar(1/o),this.inside&&i.negate()),n}};import*as V from"three";var y=new V.Vector3,ie=class extends V.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new V.Vector3;this._currentTail=new V.Vector3;this._shape=e,this._attrPos=new V.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new V.BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let i=y.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(i)>1e-10&&(this._currentTail.copy(i),e=!0),e&&this._buildPosition()}_buildPosition(){y.copy(this._currentTail).sub(this._currentOffset);let e=y.length()/this._currentRadius;for(let o=0;o<=16;o++){let n=o/16*Math.PI;this._attrPos.setXYZ(o,-Math.sin(n),-Math.cos(n),0),this._attrPos.setXYZ(17+o,e+Math.sin(n),Math.cos(n),0),this._attrPos.setXYZ(34+o,-Math.sin(n),0,-Math.cos(n)),this._attrPos.setXYZ(51+o,e+Math.sin(n),0,Math.cos(n))}for(let o=0;o<32;o++){let n=o/16*Math.PI;this._attrPos.setXYZ(68+o,0,Math.sin(n),Math.cos(n)),this._attrPos.setXYZ(100+o,e,Math.sin(n),Math.cos(n))}let r=Math.atan2(y.y,Math.sqrt(y.x*y.x+y.z*y.z)),i=-Math.atan2(y.z,y.x);this.rotateZ(r),this.rotateY(i),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){let r=(e+1)%34;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(68+e*2,34+e,34+r)}for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+r),this._attrIndex.setXY(200+e*2,100+e,100+r)}this._attrIndex.needsUpdate=!0}};import*as C from"three";var oe=class extends C.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentOffset=new C.Vector3;this._currentNormal=new C.Vector3;this._shape=e,this._attrPos=new C.BufferAttribute(new Float32Array(6*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new C.BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}};import*as L from"three";var ne=class extends L.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new L.Vector3;this._shape=e,this._attrPos=new L.BufferAttribute(new Float32Array(32*3*3),3),this.setAttribute("position",this._attrPos),this._attrIndex=new L.BufferAttribute(new Uint16Array(64*3),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.needsUpdate=!0}};var we=new P.Vector3,G=class extends P.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof N)this._geometry=new ne(this.collider.shape);else if(this.collider.shape instanceof F)this._geometry=new ie(this.collider.shape);else if(this.collider.shape instanceof Y)this._geometry=new oe(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new P.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new P.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=we.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};import*as I from"three";import*as W from"three";var se=class extends W.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentTail=new W.Vector3;this._springBone=e,this._attrPos=new W.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new W.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}};var Ce=new I.Vector3,Q=class extends I.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new se(this.springBone);let e=new I.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new I.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=Ce.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};import*as ae from"three";var z=class extends ae.Object3D{constructor(e){super();this.colliderMatrix=new ae.Matrix4;this.shape=e}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Pe(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Pe(s,t,e){let r=t.elements;s.copy(t),e&&(s.elements[12]=r[0]*e.x+r[4]*e.y+r[8]*e.z+r[12],s.elements[13]=r[1]*e.x+r[5]*e.y+r[9]*e.z+r[13],s.elements[14]=r[2]*e.x+r[6]*e.y+r[10]*e.z+r[14])}import*as E from"three";import*as xe from"three";import*as Te from"three";var Ie=new Te.Matrix4;function Me(s){return s.invert?s.invert():s.getInverse(Ie.copy(s)),s}var le=class{constructor(t){this._inverseCache=new xe.Matrix4;this._shouldUpdateInverse=!0;this.matrix=t;let e={set:(r,i,o)=>(this._shouldUpdateInverse=!0,r[i]=o,!0)};this._originalElements=t.elements,t.elements=new Proxy(t.elements,e)}get inverse(){return this._shouldUpdateInverse&&(Me(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}};var fe=new E.Matrix4,Z=new E.Vector3,K=new E.Vector3,ee=new E.Vector3,te=new E.Vector3,Oe=new E.Matrix4,ce=class{constructor(t,e,r={},i=[]){this._currentTail=new E.Vector3;this._prevTail=new E.Vector3;this._boneAxis=new E.Vector3;this._worldSpaceBoneLength=0;this._center=null;this._initialLocalMatrix=new E.Matrix4;this._initialLocalRotation=new E.Quaternion;this._initialLocalChildPosition=new E.Vector3;var o,n,l,a,p,S;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(o=r.hitRadius)!=null?o:0,stiffness:(n=r.stiffness)!=null?n:1,gravityPower:(l=r.gravityPower)!=null?l:0,gravityDir:(p=(a=r.gravityDir)==null?void 0:a.clone())!=null?p:new E.Vector3(0,-1,0),dragForce:(S=r.dragForce)!=null?S:.4},this.colliderGroups=i}get dependencies(){let t=new Set,e=this.bone.parent;e&&t.add(e);for(let r=0;r<this.colliderGroups.length;r++)for(let i=0;i<this.colliderGroups[r].colliders.length;i++)t.add(this.colliderGroups[r].colliders[i]);return t}get center(){return this._center}set center(t){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=t,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new le(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:fe}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength();let e=K.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);te.copy(this._currentTail).add(Z.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*t).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*t),ee.setFromMatrixPosition(this.bone.matrixWorld),te.sub(ee).normalize().multiplyScalar(this._worldSpaceBoneLength).add(ee),this._collision(te),this._prevTail.copy(this._currentTail),this._currentTail.copy(te).applyMatrix4(this._getMatrixWorldToCenter());let r=Oe.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Z.copy(te).applyMatrix4(r).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let r=0;r<this.colliderGroups[e].colliders.length;r++){let i=this.colliderGroups[e].colliders[r],o=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,Z);if(o<0){t.addScaledVector(Z,-o),t.sub(ee);let n=t.length();t.multiplyScalar(this._worldSpaceBoneLength/n).add(ee)}}}_calcWorldSpaceBoneLength(){Z.setFromMatrixPosition(this.bone.matrixWorld),this.child?K.setFromMatrixPosition(this.child.matrixWorld):(K.copy(this._initialLocalChildPosition),K.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Z.sub(K).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:fe}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:fe}};import*as g from"three";function ye(s,t){let e=[],r=s;for(;r!==null;)e.unshift(r),r=r.parent;e.forEach(i=>{t(i)})}function pe(s,t){s.children.forEach(e=>{t(e)||pe(e,t)})}function He(s){var e;let t=new Map;for(let r of s){let i=r;do{let o=((e=t.get(i))!=null?e:0)+1;if(o===s.size)return i;t.set(i,o),i=i.parent}while(i!==null)}return null}var re=class{constructor(){this._joints=new Set;this._sortedJoints=[];this._hasWarnedCircularDependency=!1;this._ancestors=[];this._objectSpringBonesMap=new Map;this._isSortedJointsDirty=!1;this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let t=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(r=>{t.add(r)})}),Array.from(t)}get colliders(){let t=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(r=>{t.add(r)})}),Array.from(t)}addJoint(t){this._joints.add(t);let e=this._objectSpringBonesMap.get(t.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(t.bone,e)),e.add(t),this._isSortedJointsDirty=!0}addSpringBone(t){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(t)}deleteJoint(t){this._joints.delete(t),this._objectSpringBonesMap.get(t.bone).delete(t),this._isSortedJointsDirty=!0}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(t){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){let r=this._sortedJoints[e];r.bone.updateMatrix(),r.bone.updateWorldMatrix(!1,!1),r.update(t),pe(r.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;let t=[],e=new Set,r=new Set,i=new Set;for(let n of this._joints)this._insertJointSort(n,e,r,t,i);this._sortedJoints=t;let o=He(i);this._ancestors=[],o&&(this._ancestors.push(o),pe(o,n=>{var l,a;return((a=(l=this._objectSpringBonesMap.get(n))==null?void 0:l.size)!=null?a:0)>0?!0:(this._ancestors.push(n),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(t,e,r,i,o){if(r.has(t))return;if(e.has(t)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(t);let n=t.dependencies;for(let l of n){let a=!1,p=null;ye(l,S=>{let v=this._objectSpringBonesMap.get(S);if(v)for(let A of v)a=!0,this._insertJointSort(A,e,r,i,o);else a||(p=S)}),p&&o.add(p)}i.push(t),r.add(t)}_relevantChildrenUpdated(t){var e,r;return((r=(e=this._objectSpringBonesMap.get(t))==null?void 0:e.size)!=null?r:0)>0?!0:(t.updateWorldMatrix(!1,!1),!1)}};var Ve="VRMC_springBone_extended_collider",Ae=new Set(["1.0","1.0-beta"]),De=new Set(["1.0"]),O=class O{get name(){return O.EXTENSION_NAME}constructor(t,e){var r;this.parser=t,this.jointHelperRoot=e==null?void 0:e.jointHelperRoot,this.colliderHelperRoot=e==null?void 0:e.colliderHelperRoot,this.useExtendedColliders=(r=e==null?void 0:e.useExtendedColliders)!=null?r:!0}afterRoot(t){return q(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return q(this,null,function*(){let e=yield this._v1Import(t);if(e!=null)return e;let r=yield this._v0Import(t);return r!=null?r:null})}_v1Import(t){return q(this,null,function*(){var S,v,A,d,X;let e=t.parser.json;if(!(((S=e.extensionsUsed)==null?void 0:S.indexOf(O.EXTENSION_NAME))!==-1))return null;let i=new re,o=yield t.parser.getDependencies("node"),n=(v=e.extensions)==null?void 0:v[O.EXTENSION_NAME];if(!n)return null;let l=n.specVersion;if(!Ae.has(l))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${O.EXTENSION_NAME} specVersion "${l}"`),null;let a=(A=n.colliders)==null?void 0:A.map((f,b)=>{var c,T,R,M,D,j,x,H,B,$,Ee,_e,Re,me,ge;let h=o[f.node];if(h==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${b} attempted to use the node #${f.node} but not found`),null;let u=f.shape,_=(c=f.extensions)==null?void 0:c[Ve];if(this.useExtendedColliders&&_!=null){let Se=_.specVersion;if(!De.has(Se))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ve} specVersion "${Se}". Fallbacking to the ${O.EXTENSION_NAME} definition`);else{let m=_.shape;if(m.sphere)return this._importSphereCollider(h,{offset:new g.Vector3().fromArray((T=m.sphere.offset)!=null?T:[0,0,0]),radius:(R=m.sphere.radius)!=null?R:0,inside:(M=m.sphere.inside)!=null?M:!1});if(m.capsule)return this._importCapsuleCollider(h,{offset:new g.Vector3().fromArray((D=m.capsule.offset)!=null?D:[0,0,0]),radius:(j=m.capsule.radius)!=null?j:0,tail:new g.Vector3().fromArray((x=m.capsule.tail)!=null?x:[0,0,0]),inside:(H=m.capsule.inside)!=null?H:!1});if(m.plane)return this._importPlaneCollider(h,{offset:new g.Vector3().fromArray((B=m.plane.offset)!=null?B:[0,0,0]),normal:new g.Vector3().fromArray(($=m.plane.normal)!=null?$:[0,0,1])})}}if(u.sphere)return this._importSphereCollider(h,{offset:new g.Vector3().fromArray((Ee=u.sphere.offset)!=null?Ee:[0,0,0]),radius:(_e=u.sphere.radius)!=null?_e:0,inside:!1});if(u.capsule)return this._importCapsuleCollider(h,{offset:new g.Vector3().fromArray((Re=u.capsule.offset)!=null?Re:[0,0,0]),radius:(me=u.capsule.radius)!=null?me:0,tail:new g.Vector3().fromArray((ge=u.capsule.tail)!=null?ge:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${b} has no valid shape`)}),p=(d=n.colliderGroups)==null?void 0:d.map((f,b)=>{var u;return{colliders:((u=f.colliders)!=null?u:[]).flatMap(_=>{let c=a==null?void 0:a[_];return c==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${b} attempted to use a collider #${_} but not found`),[]):c}),name:f.name}});return(X=n.springs)==null||X.forEach((f,b)=>{var T;let h=f.joints,u=(T=f.colliderGroups)==null?void 0:T.map(R=>{let M=p==null?void 0:p[R];if(M==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${b} attempted to use a colliderGroup ${R} but not found`);return M}),_=f.center!=null?o[f.center]:void 0,c;h.forEach(R=>{if(c){let M=c.node,D=o[M],j=R.node,x=o[j],H={hitRadius:c.hitRadius,dragForce:c.dragForce,gravityPower:c.gravityPower,stiffness:c.stiffness,gravityDir:c.gravityDir!=null?new g.Vector3().fromArray(c.gravityDir):void 0},B=this._importJoint(D,x,H,u);_&&(B.center=_),i.addJoint(B)}c=R})}),i.setInitState(),i})}_v0Import(t){return q(this,null,function*(){var S,v,A;let e=t.parser.json;if(!(((S=e.extensionsUsed)==null?void 0:S.indexOf("VRM"))!==-1))return null;let i=(v=e.extensions)==null?void 0:v.VRM,o=i==null?void 0:i.secondaryAnimation;if(!o)return null;let n=o==null?void 0:o.boneGroups;if(!n)return null;let l=new re,a=yield t.parser.getDependencies("node"),p=(A=o.colliderGroups)==null?void 0:A.map(d=>{var b;let X=a[d.node];return{colliders:((b=d.colliders)!=null?b:[]).map((h,u)=>{var c,T,R;let _=new g.Vector3(0,0,0);return h.offset&&_.set((c=h.offset.x)!=null?c:0,(T=h.offset.y)!=null?T:0,h.offset.z?-h.offset.z:0),this._importSphereCollider(X,{offset:_,radius:(R=h.radius)!=null?R:0,inside:!1})})}});return n==null||n.forEach((d,X)=>{let f=d.bones;f&&f.forEach(b=>{var R,M,D,j;let h=a[b],u=new g.Vector3;d.gravityDir?u.set((R=d.gravityDir.x)!=null?R:0,(M=d.gravityDir.y)!=null?M:0,(D=d.gravityDir.z)!=null?D:0):u.set(0,-1,0);let _=d.center!=null?a[d.center]:void 0,c={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:u},T=(j=d.colliderGroups)==null?void 0:j.map(x=>{let H=p==null?void 0:p[x];if(H==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${X} attempted to use a colliderGroup ${x} but not found`);return H});h.traverse(x=>{var $;let H=($=x.children[0])!=null?$:null,B=this._importJoint(x,H,c,T);_&&(B.center=_),l.addJoint(B)})})}),t.scene.updateMatrixWorld(),l.setInitState(),l})}_importJoint(t,e,r,i){let o=new ce(t,e,r,i);if(this.jointHelperRoot){let n=new Q(o);this.jointHelperRoot.add(n),n.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(t,e){let r=new N(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importCapsuleCollider(t,e){let r=new F(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importPlaneCollider(t,e){let r=new Y(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}};O.EXTENSION_NAME="VRMC_springBone";var ve=O;export{z as VRMSpringBoneCollider,G as VRMSpringBoneColliderHelper,w as VRMSpringBoneColliderShape,F as VRMSpringBoneColliderShapeCapsule,Y as VRMSpringBoneColliderShapePlane,N as VRMSpringBoneColliderShapeSphere,ce as VRMSpringBoneJoint,Q as VRMSpringBoneJointHelper,ve as VRMSpringBoneLoaderPlugin,re as VRMSpringBoneManager};
2
+ var q=(s,t,e)=>new Promise((r,i)=>{var o=a=>{try{l(e.next(a))}catch(p){i(p)}},n=a=>{try{l(e.throw(a))}catch(p){i(p)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(o,n);l((e=e.apply(s,t)).next())});import*as P from"three";import*as k from"three";var w=class{};var de=new k.Vector3,J=new k.Vector3,F=class extends w{get type(){return"capsule"}constructor(t){var e,r,i,o;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new k.Vector3(0,0,0),this.tail=(r=t==null?void 0:t.tail)!=null?r:new k.Vector3(0,0,0),this.radius=(i=t==null?void 0:t.radius)!=null?i:0,this.inside=(o=t==null?void 0:t.inside)!=null?o:!1}calculateCollision(t,e,r,i){de.setFromMatrixPosition(t),J.subVectors(this.tail,this.offset).applyMatrix4(t),J.sub(de);let o=J.lengthSq();i.copy(e).sub(de);let n=J.dot(i);n<=0||(o<=n||J.multiplyScalar(n/o),i.sub(J));let l=i.length(),a=this.inside?this.radius-r-l:l-r-this.radius;return a<0&&(i.multiplyScalar(1/l),this.inside&&i.negate()),a}};import*as U from"three";var he=new U.Vector3,be=new U.Matrix3,Y=class extends w{get type(){return"plane"}constructor(t){var e,r;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new U.Vector3(0,0,0),this.normal=(r=t==null?void 0:t.normal)!=null?r:new U.Vector3(0,0,1)}calculateCollision(t,e,r,i){i.setFromMatrixPosition(t),i.negate().add(e),be.getNormalMatrix(t),he.copy(this.normal).applyNormalMatrix(be).normalize();let o=i.dot(he)-r;return i.copy(he),o}};import*as ue from"three";var Be=new ue.Vector3,N=class extends w{get type(){return"sphere"}constructor(t){var e,r,i;super(),this.offset=(e=t==null?void 0:t.offset)!=null?e:new ue.Vector3(0,0,0),this.radius=(r=t==null?void 0:t.radius)!=null?r:0,this.inside=(i=t==null?void 0:t.inside)!=null?i:!1}calculateCollision(t,e,r,i){i.subVectors(e,Be.setFromMatrixPosition(t));let o=i.length(),n=this.inside?this.radius-r-o:o-r-this.radius;return n<0&&(i.multiplyScalar(1/o),this.inside&&i.negate()),n}};import*as V from"three";var y=new V.Vector3,ie=class extends V.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new V.Vector3;this._currentTail=new V.Vector3;this._shape=e,this._attrPos=new V.BufferAttribute(new Float32Array(396),3),this.setAttribute("position",this._attrPos),this._attrIndex=new V.BufferAttribute(new Uint16Array(264),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0);let i=y.copy(this._shape.tail).divideScalar(this.worldScale);this._currentTail.distanceToSquared(i)>1e-10&&(this._currentTail.copy(i),e=!0),e&&this._buildPosition()}_buildPosition(){y.copy(this._currentTail).sub(this._currentOffset);let e=y.length()/this._currentRadius;for(let o=0;o<=16;o++){let n=o/16*Math.PI;this._attrPos.setXYZ(o,-Math.sin(n),-Math.cos(n),0),this._attrPos.setXYZ(17+o,e+Math.sin(n),Math.cos(n),0),this._attrPos.setXYZ(34+o,-Math.sin(n),0,-Math.cos(n)),this._attrPos.setXYZ(51+o,e+Math.sin(n),0,Math.cos(n))}for(let o=0;o<32;o++){let n=o/16*Math.PI;this._attrPos.setXYZ(68+o,0,Math.sin(n),Math.cos(n)),this._attrPos.setXYZ(100+o,e,Math.sin(n),Math.cos(n))}let r=Math.atan2(y.y,Math.sqrt(y.x*y.x+y.z*y.z)),i=-Math.atan2(y.z,y.x);this.rotateZ(r),this.rotateY(i),this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<34;e++){let r=(e+1)%34;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(68+e*2,34+e,34+r)}for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(136+e*2,68+e,68+r),this._attrIndex.setXY(200+e*2,100+e,100+r)}this._attrIndex.needsUpdate=!0}};import*as C from"three";var oe=class extends C.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentOffset=new C.Vector3;this._currentNormal=new C.Vector3;this._shape=e,this._attrPos=new C.BufferAttribute(new Float32Array(18),3),this.setAttribute("position",this._attrPos),this._attrIndex=new C.BufferAttribute(new Uint16Array(10),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1;this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),this._currentNormal.equals(this._shape.normal)||(this._currentNormal.copy(this._shape.normal),e=!0),e&&this._buildPosition()}_buildPosition(){this._attrPos.setXYZ(0,-.5,-.5,0),this._attrPos.setXYZ(1,.5,-.5,0),this._attrPos.setXYZ(2,.5,.5,0),this._attrPos.setXYZ(3,-.5,.5,0),this._attrPos.setXYZ(4,0,0,0),this._attrPos.setXYZ(5,0,0,.25),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this.lookAt(this._currentNormal),this._attrPos.needsUpdate=!0}_buildIndex(){this._attrIndex.setXY(0,0,1),this._attrIndex.setXY(2,1,2),this._attrIndex.setXY(4,2,3),this._attrIndex.setXY(6,3,0),this._attrIndex.setXY(8,4,5),this._attrIndex.needsUpdate=!0}};import*as L from"three";var ne=class extends L.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentOffset=new L.Vector3;this._shape=e,this._attrPos=new L.BufferAttribute(new Float32Array(288),3),this.setAttribute("position",this._attrPos),this._attrIndex=new L.BufferAttribute(new Uint16Array(192),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._shape.radius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentOffset.equals(this._shape.offset)||(this._currentOffset.copy(this._shape.offset),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentOffset.x,this._currentOffset.y,this._currentOffset.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.needsUpdate=!0}};var we=new P.Vector3,G=class extends P.Group{constructor(t){if(super(),this.matrixAutoUpdate=!1,this.collider=t,this.collider.shape instanceof N)this._geometry=new ne(this.collider.shape);else if(this.collider.shape instanceof F)this._geometry=new ie(this.collider.shape);else if(this.collider.shape instanceof Y)this._geometry=new oe(this.collider.shape);else throw new Error("VRMSpringBoneColliderHelper: Unknown collider shape type detected");let e=new P.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new P.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.collider.updateWorldMatrix(!0,!1),this.matrix.copy(this.collider.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=we.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};import*as I from"three";import*as W from"three";var se=class extends W.BufferGeometry{constructor(e){super();this.worldScale=1;this._currentRadius=0;this._currentTail=new W.Vector3;this._springBone=e,this._attrPos=new W.BufferAttribute(new Float32Array(294),3),this.setAttribute("position",this._attrPos),this._attrIndex=new W.BufferAttribute(new Uint16Array(194),1),this.setIndex(this._attrIndex),this._buildIndex(),this.update()}update(){let e=!1,r=this._springBone.settings.hitRadius/this.worldScale;this._currentRadius!==r&&(this._currentRadius=r,e=!0),this._currentTail.equals(this._springBone.initialLocalChildPosition)||(this._currentTail.copy(this._springBone.initialLocalChildPosition),e=!0),e&&this._buildPosition()}_buildPosition(){for(let e=0;e<32;e++){let r=e/16*Math.PI;this._attrPos.setXYZ(e,Math.cos(r),Math.sin(r),0),this._attrPos.setXYZ(32+e,0,Math.cos(r),Math.sin(r)),this._attrPos.setXYZ(64+e,Math.sin(r),0,Math.cos(r))}this.scale(this._currentRadius,this._currentRadius,this._currentRadius),this.translate(this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.setXYZ(96,0,0,0),this._attrPos.setXYZ(97,this._currentTail.x,this._currentTail.y,this._currentTail.z),this._attrPos.needsUpdate=!0}_buildIndex(){for(let e=0;e<32;e++){let r=(e+1)%32;this._attrIndex.setXY(e*2,e,r),this._attrIndex.setXY(64+e*2,32+e,32+r),this._attrIndex.setXY(128+e*2,64+e,64+r)}this._attrIndex.setXY(192,96,97),this._attrIndex.needsUpdate=!0}};var Ce=new I.Vector3,Q=class extends I.Group{constructor(t){super(),this.matrixAutoUpdate=!1,this.springBone=t,this._geometry=new se(this.springBone);let e=new I.LineBasicMaterial({color:16776960,depthTest:!1,depthWrite:!1});this._line=new I.LineSegments(this._geometry,e),this.add(this._line)}dispose(){this._geometry.dispose()}updateMatrixWorld(t){this.springBone.bone.updateWorldMatrix(!0,!1),this.matrix.copy(this.springBone.bone.matrixWorld);let e=this.matrix.elements;this._geometry.worldScale=Ce.set(e[0],e[1],e[2]).length(),this._geometry.update(),super.updateMatrixWorld(t)}};import*as ae from"three";var z=class extends ae.Object3D{constructor(e){super();this.colliderMatrix=new ae.Matrix4;this.shape=e}updateWorldMatrix(e,r){super.updateWorldMatrix(e,r),Pe(this.colliderMatrix,this.matrixWorld,this.shape.offset)}};function Pe(s,t,e){let r=t.elements;s.copy(t),e&&(s.elements[12]=r[0]*e.x+r[4]*e.y+r[8]*e.z+r[12],s.elements[13]=r[1]*e.x+r[5]*e.y+r[9]*e.z+r[13],s.elements[14]=r[2]*e.x+r[6]*e.y+r[10]*e.z+r[14])}import*as E from"three";import*as xe from"three";import*as Te from"three";var Ie=new Te.Matrix4;function Me(s){return s.invert?s.invert():s.getInverse(Ie.copy(s)),s}var le=class{constructor(t){this._inverseCache=new xe.Matrix4;this._shouldUpdateInverse=!0;this.matrix=t;let e={set:(r,i,o)=>(this._shouldUpdateInverse=!0,r[i]=o,!0)};this._originalElements=t.elements,t.elements=new Proxy(t.elements,e)}get inverse(){return this._shouldUpdateInverse&&(Me(this._inverseCache.copy(this.matrix)),this._shouldUpdateInverse=!1),this._inverseCache}revert(){this.matrix.elements=this._originalElements}};var fe=new E.Matrix4,Z=new E.Vector3,K=new E.Vector3,ee=new E.Vector3,te=new E.Vector3,Oe=new E.Matrix4,ce=class{constructor(t,e,r={},i=[]){this._currentTail=new E.Vector3;this._prevTail=new E.Vector3;this._boneAxis=new E.Vector3;this._worldSpaceBoneLength=0;this._center=null;this._initialLocalMatrix=new E.Matrix4;this._initialLocalRotation=new E.Quaternion;this._initialLocalChildPosition=new E.Vector3;var o,n,l,a,p,S;this.bone=t,this.bone.matrixAutoUpdate=!1,this.child=e,this.settings={hitRadius:(o=r.hitRadius)!=null?o:0,stiffness:(n=r.stiffness)!=null?n:1,gravityPower:(l=r.gravityPower)!=null?l:0,gravityDir:(p=(a=r.gravityDir)==null?void 0:a.clone())!=null?p:new E.Vector3(0,-1,0),dragForce:(S=r.dragForce)!=null?S:.4},this.colliderGroups=i}get dependencies(){let t=new Set,e=this.bone.parent;e&&t.add(e);for(let r=0;r<this.colliderGroups.length;r++)for(let i=0;i<this.colliderGroups[r].colliders.length;i++)t.add(this.colliderGroups[r].colliders[i]);return t}get center(){return this._center}set center(t){var e;(e=this._center)!=null&&e.userData.inverseCacheProxy&&(this._center.userData.inverseCacheProxy.revert(),delete this._center.userData.inverseCacheProxy),this._center=t,this._center&&(this._center.userData.inverseCacheProxy||(this._center.userData.inverseCacheProxy=new le(this._center.matrixWorld)))}get initialLocalChildPosition(){return this._initialLocalChildPosition}get _parentMatrixWorld(){return this.bone.parent?this.bone.parent.matrixWorld:fe}setInitState(){this._initialLocalMatrix.copy(this.bone.matrix),this._initialLocalRotation.copy(this.bone.quaternion),this.child?this._initialLocalChildPosition.copy(this.child.position):this._initialLocalChildPosition.copy(this.bone.position).normalize().multiplyScalar(.07);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail),this._boneAxis.copy(this._initialLocalChildPosition).normalize()}reset(){this.bone.quaternion.copy(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix);let t=this._getMatrixWorldToCenter();this.bone.localToWorld(this._currentTail.copy(this._initialLocalChildPosition)).applyMatrix4(t),this._prevTail.copy(this._currentTail)}update(t){if(t<=0)return;this._calcWorldSpaceBoneLength();let e=K.copy(this._boneAxis).transformDirection(this._initialLocalMatrix).transformDirection(this._parentMatrixWorld);te.copy(this._currentTail).add(Z.subVectors(this._currentTail,this._prevTail).multiplyScalar(1-this.settings.dragForce)).applyMatrix4(this._getMatrixCenterToWorld()).addScaledVector(e,this.settings.stiffness*t).addScaledVector(this.settings.gravityDir,this.settings.gravityPower*t),ee.setFromMatrixPosition(this.bone.matrixWorld),te.sub(ee).normalize().multiplyScalar(this._worldSpaceBoneLength).add(ee),this._collision(te),this._prevTail.copy(this._currentTail),this._currentTail.copy(te).applyMatrix4(this._getMatrixWorldToCenter());let r=Oe.multiplyMatrices(this._parentMatrixWorld,this._initialLocalMatrix).invert();this.bone.quaternion.setFromUnitVectors(this._boneAxis,Z.copy(te).applyMatrix4(r).normalize()).premultiply(this._initialLocalRotation),this.bone.updateMatrix(),this.bone.matrixWorld.multiplyMatrices(this._parentMatrixWorld,this.bone.matrix)}_collision(t){for(let e=0;e<this.colliderGroups.length;e++)for(let r=0;r<this.colliderGroups[e].colliders.length;r++){let i=this.colliderGroups[e].colliders[r],o=i.shape.calculateCollision(i.colliderMatrix,t,this.settings.hitRadius,Z);if(o<0){t.addScaledVector(Z,-o),t.sub(ee);let n=t.length();t.multiplyScalar(this._worldSpaceBoneLength/n).add(ee)}}}_calcWorldSpaceBoneLength(){Z.setFromMatrixPosition(this.bone.matrixWorld),this.child?K.setFromMatrixPosition(this.child.matrixWorld):(K.copy(this._initialLocalChildPosition),K.applyMatrix4(this.bone.matrixWorld)),this._worldSpaceBoneLength=Z.sub(K).length()}_getMatrixCenterToWorld(){return this._center?this._center.matrixWorld:fe}_getMatrixWorldToCenter(){return this._center?this._center.userData.inverseCacheProxy.inverse:fe}};import*as g from"three";function ye(s,t){let e=[],r=s;for(;r!==null;)e.unshift(r),r=r.parent;e.forEach(i=>{t(i)})}function pe(s,t){s.children.forEach(e=>{t(e)||pe(e,t)})}function He(s){var e;let t=new Map;for(let r of s){let i=r;do{let o=((e=t.get(i))!=null?e:0)+1;if(o===s.size)return i;t.set(i,o),i=i.parent}while(i!==null)}return null}var re=class{constructor(){this._joints=new Set;this._sortedJoints=[];this._hasWarnedCircularDependency=!1;this._ancestors=[];this._objectSpringBonesMap=new Map;this._isSortedJointsDirty=!1;this._relevantChildrenUpdated=this._relevantChildrenUpdated.bind(this)}get joints(){return this._joints}get springBones(){return console.warn("VRMSpringBoneManager: springBones is deprecated. use joints instead."),this._joints}get colliderGroups(){let t=new Set;return this._joints.forEach(e=>{e.colliderGroups.forEach(r=>{t.add(r)})}),Array.from(t)}get colliders(){let t=new Set;return this.colliderGroups.forEach(e=>{e.colliders.forEach(r=>{t.add(r)})}),Array.from(t)}addJoint(t){this._joints.add(t);let e=this._objectSpringBonesMap.get(t.bone);e==null&&(e=new Set,this._objectSpringBonesMap.set(t.bone,e)),e.add(t),this._isSortedJointsDirty=!0}addSpringBone(t){console.warn("VRMSpringBoneManager: addSpringBone() is deprecated. use addJoint() instead."),this.addJoint(t)}deleteJoint(t){this._joints.delete(t),this._objectSpringBonesMap.get(t.bone).delete(t),this._isSortedJointsDirty=!0}deleteSpringBone(t){console.warn("VRMSpringBoneManager: deleteSpringBone() is deprecated. use deleteJoint() instead."),this.deleteJoint(t)}setInitState(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.setInitState()}}reset(){this._sortJoints();for(let t=0;t<this._sortedJoints.length;t++){let e=this._sortedJoints[t];e.bone.updateMatrix(),e.bone.updateWorldMatrix(!1,!1),e.reset()}}update(t){this._sortJoints();for(let e=0;e<this._ancestors.length;e++)this._ancestors[e].updateWorldMatrix(e===0,!1);for(let e=0;e<this._sortedJoints.length;e++){let r=this._sortedJoints[e];r.bone.updateMatrix(),r.bone.updateWorldMatrix(!1,!1),r.update(t),pe(r.bone,this._relevantChildrenUpdated)}}_sortJoints(){if(!this._isSortedJointsDirty)return;let t=[],e=new Set,r=new Set,i=new Set;for(let n of this._joints)this._insertJointSort(n,e,r,t,i);this._sortedJoints=t;let o=He(i);this._ancestors=[],o&&(this._ancestors.push(o),pe(o,n=>{var l,a;return((a=(l=this._objectSpringBonesMap.get(n))==null?void 0:l.size)!=null?a:0)>0?!0:(this._ancestors.push(n),!1)})),this._isSortedJointsDirty=!1}_insertJointSort(t,e,r,i,o){if(r.has(t))return;if(e.has(t)){this._hasWarnedCircularDependency||(console.warn("VRMSpringBoneManager: Circular dependency detected"),this._hasWarnedCircularDependency=!0);return}e.add(t);let n=t.dependencies;for(let l of n){let a=!1,p=null;ye(l,S=>{let v=this._objectSpringBonesMap.get(S);if(v)for(let A of v)a=!0,this._insertJointSort(A,e,r,i,o);else a||(p=S)}),p&&o.add(p)}i.push(t),r.add(t)}_relevantChildrenUpdated(t){var e,r;return((r=(e=this._objectSpringBonesMap.get(t))==null?void 0:e.size)!=null?r:0)>0?!0:(t.updateWorldMatrix(!1,!1),!1)}};var Ve="VRMC_springBone_extended_collider",Ae=new Set(["1.0","1.0-beta"]),De=new Set(["1.0"]),O=class O{get name(){return O.EXTENSION_NAME}constructor(t,e){var r;this.parser=t,this.jointHelperRoot=e==null?void 0:e.jointHelperRoot,this.colliderHelperRoot=e==null?void 0:e.colliderHelperRoot,this.useExtendedColliders=(r=e==null?void 0:e.useExtendedColliders)!=null?r:!0}afterRoot(t){return q(this,null,function*(){t.userData.vrmSpringBoneManager=yield this._import(t)})}_import(t){return q(this,null,function*(){let e=yield this._v1Import(t);if(e!=null)return e;let r=yield this._v0Import(t);return r!=null?r:null})}_v1Import(t){return q(this,null,function*(){var S,v,A,d,X;let e=t.parser.json;if(!(((S=e.extensionsUsed)==null?void 0:S.indexOf(O.EXTENSION_NAME))!==-1))return null;let i=new re,o=yield t.parser.getDependencies("node"),n=(v=e.extensions)==null?void 0:v[O.EXTENSION_NAME];if(!n)return null;let l=n.specVersion;if(!Ae.has(l))return console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${O.EXTENSION_NAME} specVersion "${l}"`),null;let a=(A=n.colliders)==null?void 0:A.map((f,b)=>{var c,T,R,M,D,j,x,H,B,$,Ee,_e,Re,me,ge;let h=o[f.node];if(h==null)return console.warn(`VRMSpringBoneLoaderPlugin: The collider #${b} attempted to use the node #${f.node} but not found`),null;let u=f.shape,_=(c=f.extensions)==null?void 0:c[Ve];if(this.useExtendedColliders&&_!=null){let Se=_.specVersion;if(!De.has(Se))console.warn(`VRMSpringBoneLoaderPlugin: Unknown ${Ve} specVersion "${Se}". Fallbacking to the ${O.EXTENSION_NAME} definition`);else{let m=_.shape;if(m.sphere)return this._importSphereCollider(h,{offset:new g.Vector3().fromArray((T=m.sphere.offset)!=null?T:[0,0,0]),radius:(R=m.sphere.radius)!=null?R:0,inside:(M=m.sphere.inside)!=null?M:!1});if(m.capsule)return this._importCapsuleCollider(h,{offset:new g.Vector3().fromArray((D=m.capsule.offset)!=null?D:[0,0,0]),radius:(j=m.capsule.radius)!=null?j:0,tail:new g.Vector3().fromArray((x=m.capsule.tail)!=null?x:[0,0,0]),inside:(H=m.capsule.inside)!=null?H:!1});if(m.plane)return this._importPlaneCollider(h,{offset:new g.Vector3().fromArray((B=m.plane.offset)!=null?B:[0,0,0]),normal:new g.Vector3().fromArray(($=m.plane.normal)!=null?$:[0,0,1])})}}if(u.sphere)return this._importSphereCollider(h,{offset:new g.Vector3().fromArray((Ee=u.sphere.offset)!=null?Ee:[0,0,0]),radius:(_e=u.sphere.radius)!=null?_e:0,inside:!1});if(u.capsule)return this._importCapsuleCollider(h,{offset:new g.Vector3().fromArray((Re=u.capsule.offset)!=null?Re:[0,0,0]),radius:(me=u.capsule.radius)!=null?me:0,tail:new g.Vector3().fromArray((ge=u.capsule.tail)!=null?ge:[0,0,0]),inside:!1});throw new Error(`VRMSpringBoneLoaderPlugin: The collider #${b} has no valid shape`)}),p=(d=n.colliderGroups)==null?void 0:d.map((f,b)=>{var u;return{colliders:((u=f.colliders)!=null?u:[]).flatMap(_=>{let c=a==null?void 0:a[_];return c==null?(console.warn(`VRMSpringBoneLoaderPlugin: The colliderGroup #${b} attempted to use a collider #${_} but not found`),[]):c}),name:f.name}});return(X=n.springs)==null||X.forEach((f,b)=>{var T;let h=f.joints,u=(T=f.colliderGroups)==null?void 0:T.map(R=>{let M=p==null?void 0:p[R];if(M==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${b} attempted to use a colliderGroup ${R} but not found`);return M}),_=f.center!=null?o[f.center]:void 0,c;h.forEach(R=>{if(c){let M=c.node,D=o[M],j=R.node,x=o[j],H={hitRadius:c.hitRadius,dragForce:c.dragForce,gravityPower:c.gravityPower,stiffness:c.stiffness,gravityDir:c.gravityDir!=null?new g.Vector3().fromArray(c.gravityDir):void 0},B=this._importJoint(D,x,H,u);_&&(B.center=_),i.addJoint(B)}c=R})}),i.setInitState(),i})}_v0Import(t){return q(this,null,function*(){var S,v,A;let e=t.parser.json;if(!(((S=e.extensionsUsed)==null?void 0:S.indexOf("VRM"))!==-1))return null;let i=(v=e.extensions)==null?void 0:v.VRM,o=i==null?void 0:i.secondaryAnimation;if(!o)return null;let n=o==null?void 0:o.boneGroups;if(!n)return null;let l=new re,a=yield t.parser.getDependencies("node"),p=(A=o.colliderGroups)==null?void 0:A.map(d=>{var b;let X=a[d.node];return{colliders:((b=d.colliders)!=null?b:[]).map((h,u)=>{var c,T,R;let _=new g.Vector3(0,0,0);return h.offset&&_.set((c=h.offset.x)!=null?c:0,(T=h.offset.y)!=null?T:0,h.offset.z?-h.offset.z:0),this._importSphereCollider(X,{offset:_,radius:(R=h.radius)!=null?R:0,inside:!1})})}});return n==null||n.forEach((d,X)=>{let f=d.bones;f&&f.forEach(b=>{var R,M,D,j;let h=a[b],u=new g.Vector3;d.gravityDir?u.set((R=d.gravityDir.x)!=null?R:0,(M=d.gravityDir.y)!=null?M:0,(D=d.gravityDir.z)!=null?D:0):u.set(0,-1,0);let _=d.center!=null?a[d.center]:void 0,c={hitRadius:d.hitRadius,dragForce:d.dragForce,gravityPower:d.gravityPower,stiffness:d.stiffiness,gravityDir:u},T=(j=d.colliderGroups)==null?void 0:j.map(x=>{let H=p==null?void 0:p[x];if(H==null)throw new Error(`VRMSpringBoneLoaderPlugin: The spring #${X} attempted to use a colliderGroup ${x} but not found`);return H});h.traverse(x=>{var $;let H=($=x.children[0])!=null?$:null,B=this._importJoint(x,H,c,T);_&&(B.center=_),l.addJoint(B)})})}),t.scene.updateMatrixWorld(),l.setInitState(),l})}_importJoint(t,e,r,i){let o=new ce(t,e,r,i);if(this.jointHelperRoot){let n=new Q(o);this.jointHelperRoot.add(n),n.renderOrder=this.jointHelperRoot.renderOrder}return o}_importSphereCollider(t,e){let r=new N(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importCapsuleCollider(t,e){let r=new F(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}_importPlaneCollider(t,e){let r=new Y(e),i=new z(r);if(t.add(i),this.colliderHelperRoot){let o=new G(i);this.colliderHelperRoot.add(o),o.renderOrder=this.colliderHelperRoot.renderOrder}return i}};O.EXTENSION_NAME="VRMC_springBone";var ve=O;export{z as VRMSpringBoneCollider,G as VRMSpringBoneColliderHelper,w as VRMSpringBoneColliderShape,F as VRMSpringBoneColliderShapeCapsule,Y as VRMSpringBoneColliderShapePlane,N as VRMSpringBoneColliderShapeSphere,ce as VRMSpringBoneJoint,Q as VRMSpringBoneJointHelper,ve as VRMSpringBoneLoaderPlugin,re as VRMSpringBoneManager};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixiv/three-vrm-springbone",
3
- "version": "3.4.2",
3
+ "version": "3.4.3",
4
4
  "description": "Spring bone module for @pixiv/three-vrm",
5
5
  "license": "MIT",
6
6
  "author": "pixiv",
@@ -50,9 +50,9 @@
50
50
  ]
51
51
  },
52
52
  "dependencies": {
53
- "@pixiv/types-vrm-0.0": "3.4.2",
54
- "@pixiv/types-vrmc-springbone-1.0": "3.4.2",
55
- "@pixiv/types-vrmc-springbone-extended-collider-1.0": "3.4.2"
53
+ "@pixiv/types-vrm-0.0": "3.4.3",
54
+ "@pixiv/types-vrmc-springbone-1.0": "3.4.3",
55
+ "@pixiv/types-vrmc-springbone-extended-collider-1.0": "3.4.3"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/three": "^0.177.0",
@@ -61,5 +61,5 @@
61
61
  "peerDependencies": {
62
62
  "three": ">=0.137"
63
63
  },
64
- "gitHead": "d20d8cd0ec2c18e8226a9fc45a524bb16646d86e"
64
+ "gitHead": "30666e076441ac493c3ba551d6b8dd113af6e6c6"
65
65
  }