@pixiv/three-vrm-node-constraint 3.4.4 → 3.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2025 pixiv Inc.
1
+ Copyright (c) 2019-2026 pixiv Inc.
2
2
 
3
3
  MIT License
4
4
 
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @pixiv/three-vrm-node-constraint v3.4.4
2
+ * @pixiv/three-vrm-node-constraint v3.4.5
3
3
  * Node constraint module for @pixiv/three-vrm
4
4
  *
5
- * Copyright (c) 2019-2025 pixiv Inc.
5
+ * Copyright (c) 2019-2026 pixiv Inc.
6
6
  * @pixiv/three-vrm-node-constraint is distributed under MIT License
7
7
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
8
8
  */
@@ -1,2 +1,2 @@
1
- /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
1
+ /*! (c) 2019-2026 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
2
  "use strict";var P=Object.create;var w=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var X=(o,t)=>{for(var e in t)w(o,e,{get:t[e],enumerable:!0})},j=(o,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of L(t))!I.call(o,i)&&i!==e&&w(o,i,{get:()=>t[i],enumerable:!(s=q(t,i))||s.enumerable});return o};var x=(o,t,e)=>(e=o!=null?P(F(o)):{},j(t||!o||!o.__esModule?w(e,"default",{value:o,enumerable:!0}):e,o)),G=o=>j(w({},"__esModule",{value:!0}),o);var V=(o,t,e)=>new Promise((s,i)=>{var r=n=>{try{a(e.next(n))}catch(p){i(p)}},c=n=>{try{a(e.throw(n))}catch(p){i(p)}},a=n=>n.done?s(n.value):Promise.resolve(n.value).then(r,c);a((e=e.apply(o,t)).next())});var st={};X(st,{VRMAimConstraint:()=>_,VRMNodeConstraint:()=>d,VRMNodeConstraintHelper:()=>h,VRMNodeConstraintLoaderPlugin:()=>Q,VRMNodeConstraintManager:()=>f,VRMRollConstraint:()=>H,VRMRotationConstraint:()=>b});module.exports=G(st);var u=x(require("three"),1),R=new u.Vector3,h=class extends u.Group{constructor(t){super(),this._attrPosition=new u.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(u.DynamicDrawUsage);let e=new u.BufferGeometry;e.setAttribute("position",this._attrPosition);let s=new u.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new u.Line(e,s),this.add(this._line),this.constraint=t}updateMatrixWorld(t){R.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,R.x,R.y,R.z),this.constraint.source&&R.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,R.x,R.y,R.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};var l=x(require("three"),1);function S(o,t){return t.set(o.elements[12],o.elements[13],o.elements[14])}var y=x(require("three"),1),Y=new y.Vector3,Z=new y.Vector3;function A(o,t){return o.decompose(Y,t,Z),t}function m(o){return o.invert?o.invert():o.inverse(),o}var d=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}};var W=new l.Vector3,B=new l.Vector3,U=new l.Vector3,z=new l.Quaternion,$=new l.Quaternion,k=new l.Quaternion,_=class extends d{get aimAxis(){return this._aimAxis}set aimAxis(t){this._aimAxis=t,this._v3AimAxis.set(t==="PositiveX"?1:t==="NegativeX"?-1:0,t==="PositiveY"?1:t==="NegativeY"?-1:0,t==="PositiveZ"?1:t==="NegativeZ"?-1:0)}get dependencies(){let t=new Set([this.source]);return this.destination.parent&&t.add(this.destination.parent),t}constructor(t,e){super(t,e),this._aimAxis="PositiveX",this._v3AimAxis=new l.Vector3(1,0,0),this._dstRestQuat=new l.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=z.identity(),e=$.identity();this.destination.parent&&(A(this.destination.parent.matrixWorld,t),m(e.copy(t)));let s=W.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),i=S(this.source.matrixWorld,B).sub(S(this.destination.matrixWorld,U)).normalize(),r=k.setFromUnitVectors(s,i).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function O(o,t){let e=[o],s=o.parent;for(;s!==null;)e.unshift(s),s=s.parent;e.forEach(i=>{t(i)})}var f=class{constructor(){this._constraints=new Set;this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(t){this._constraints.add(t);let e=this._objectConstraintsMap.get(t.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(t.destination,e)),e.add(t)}deleteConstraint(t){this._constraints.delete(t),this._objectConstraintsMap.get(t.destination).delete(t)}setInitState(){let t=new Set,e=new Set;for(let s of this._constraints)this._processConstraint(s,t,e,i=>i.setInitState())}update(){let t=new Set,e=new Set;for(let s of this._constraints)this._processConstraint(s,t,e,i=>i.update())}_processConstraint(t,e,s,i){if(s.has(t))return;if(e.has(t))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(t);let r=t.dependencies;for(let c of r)O(c,a=>{let n=this._objectConstraintsMap.get(a);if(n)for(let p of n)this._processConstraint(p,e,s,i)});i(t),s.add(t)}};var M=x(require("three"),1);var J=new M.Quaternion,K=new M.Quaternion,b=class extends d{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new M.Quaternion,this._invSrcRestQuat=new M.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),m(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=J.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=K.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}};var E=x(require("three"),1);var tt=new E.Vector3,et=new E.Quaternion,ot=new E.Quaternion,H=class extends d{get rollAxis(){return this._rollAxis}set rollAxis(t){this._rollAxis=t,this._v3RollAxis.set(t==="X"?1:0,t==="Y"?1:0,t==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._rollAxis="X",this._v3RollAxis=new E.Vector3(1,0,0),this._dstRestQuat=new E.Quaternion,this._invDstRestQuat=new E.Quaternion,this._invSrcRestQuatMulDstRestQuat=new E.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),m(this._invDstRestQuat.copy(this._dstRestQuat)),m(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=et.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=tt.copy(this._v3RollAxis).applyQuaternion(t),i=ot.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(i,this.weight)}};var it=new Set(["1.0","1.0-beta"]),T=class T{get name(){return T.EXTENSION_NAME}constructor(t,e){this.parser=t,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(t){return V(this,null,function*(){t.userData.vrmNodeConstraintManager=yield this._import(t)})}_import(t){return V(this,null,function*(){var c;let e=this.parser.json;if(!(((c=e.extensionsUsed)==null?void 0:c.indexOf(T.EXTENSION_NAME))!==-1))return null;let i=new f,r=yield this.parser.getDependencies("node");return r.forEach((a,n)=>{var D;let p=e.nodes[n],N=(D=p==null?void 0:p.extensions)==null?void 0:D[T.EXTENSION_NAME];if(N==null)return;let g=N.specVersion;if(!it.has(g)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${T.EXTENSION_NAME} specVersion "${g}"`);return}let v=N.constraint;if(v.roll!=null){let C=this._importRollConstraint(a,r,v.roll);i.addConstraint(C)}else if(v.aim!=null){let C=this._importAimConstraint(a,r,v.aim);i.addConstraint(C)}else if(v.rotation!=null){let C=this._importRotationConstraint(a,r,v.rotation);i.addConstraint(C)}}),t.scene.updateMatrixWorld(),i.setInitState(),i})}_importRollConstraint(t,e,s){let{source:i,rollAxis:r,weight:c}=s,a=e[i],n=new H(t,a);if(r!=null&&(n.rollAxis=r),c!=null&&(n.weight=c),this.helperRoot){let p=new h(n);this.helperRoot.add(p)}return n}_importAimConstraint(t,e,s){let{source:i,aimAxis:r,weight:c}=s,a=e[i],n=new _(t,a);if(r!=null&&(n.aimAxis=r),c!=null&&(n.weight=c),this.helperRoot){let p=new h(n);this.helperRoot.add(p)}return n}_importRotationConstraint(t,e,s){let{source:i,weight:r}=s,c=e[i],a=new b(t,c);if(r!=null&&(a.weight=r),this.helperRoot){let n=new h(a);this.helperRoot.add(n)}return a}};T.EXTENSION_NAME="VRMC_node_constraint";var Q=T;
@@ -1,8 +1,8 @@
1
1
  /*!
2
- * @pixiv/three-vrm-node-constraint v3.4.4
2
+ * @pixiv/three-vrm-node-constraint v3.4.5
3
3
  * Node constraint module for @pixiv/three-vrm
4
4
  *
5
- * Copyright (c) 2019-2025 pixiv Inc.
5
+ * Copyright (c) 2019-2026 pixiv Inc.
6
6
  * @pixiv/three-vrm-node-constraint is distributed under MIT License
7
7
  * https://github.com/pixiv/three-vrm/blob/release/LICENSE
8
8
  */
@@ -1,2 +1,2 @@
1
- /*! (c) 2019-2025 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
1
+ /*! (c) 2019-2026 pixiv Inc. - https://github.com/pixiv/three-vrm/blob/release/LICENSE */
2
2
  var w=(n,t,e)=>new Promise((i,o)=>{var r=s=>{try{a(e.next(s))}catch(p){o(p)}},c=s=>{try{a(e.throw(s))}catch(p){o(p)}},a=s=>s.done?i(s.value):Promise.resolve(s.value).then(r,c);a((e=e.apply(n,t)).next())});import*as u from"three";var R=new u.Vector3,h=class extends u.Group{constructor(t){super(),this._attrPosition=new u.BufferAttribute(new Float32Array([0,0,0,0,0,0]),3),this._attrPosition.setUsage(u.DynamicDrawUsage);let e=new u.BufferGeometry;e.setAttribute("position",this._attrPosition);let i=new u.LineBasicMaterial({color:16711935,depthTest:!1,depthWrite:!1});this._line=new u.Line(e,i),this.add(this._line),this.constraint=t}updateMatrixWorld(t){R.setFromMatrixPosition(this.constraint.destination.matrixWorld),this._attrPosition.setXYZ(0,R.x,R.y,R.z),this.constraint.source&&R.setFromMatrixPosition(this.constraint.source.matrixWorld),this._attrPosition.setXYZ(1,R.x,R.y,R.z),this._attrPosition.needsUpdate=!0,super.updateMatrixWorld(t)}};import*as d from"three";function Q(n,t){return t.set(n.elements[12],n.elements[13],n.elements[14])}import*as N from"three";var j=new N.Vector3,A=new N.Vector3;function g(n,t){return n.decompose(j,t,A),t}function m(n){return n.invert?n.invert():n.inverse(),n}var l=class{constructor(t,e){this.destination=t,this.source=e,this.weight=1}};var O=new d.Vector3,P=new d.Vector3,q=new d.Vector3,L=new d.Quaternion,F=new d.Quaternion,I=new d.Quaternion,f=class extends l{get aimAxis(){return this._aimAxis}set aimAxis(t){this._aimAxis=t,this._v3AimAxis.set(t==="PositiveX"?1:t==="NegativeX"?-1:0,t==="PositiveY"?1:t==="NegativeY"?-1:0,t==="PositiveZ"?1:t==="NegativeZ"?-1:0)}get dependencies(){let t=new Set([this.source]);return this.destination.parent&&t.add(this.destination.parent),t}constructor(t,e){super(t,e),this._aimAxis="PositiveX",this._v3AimAxis=new d.Vector3(1,0,0),this._dstRestQuat=new d.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion)}update(){this.destination.updateWorldMatrix(!0,!1),this.source.updateWorldMatrix(!0,!1);let t=L.identity(),e=F.identity();this.destination.parent&&(g(this.destination.parent.matrixWorld,t),m(e.copy(t)));let i=O.copy(this._v3AimAxis).applyQuaternion(this._dstRestQuat).applyQuaternion(t),o=Q(this.source.matrixWorld,P).sub(Q(this.destination.matrixWorld,q)).normalize(),r=I.setFromUnitVectors(i,o).premultiply(e).multiply(t).multiply(this._dstRestQuat);this.destination.quaternion.copy(this._dstRestQuat).slerp(r,this.weight)}};function D(n,t){let e=[n],i=n.parent;for(;i!==null;)e.unshift(i),i=i.parent;e.forEach(o=>{t(o)})}var b=class{constructor(){this._constraints=new Set;this._objectConstraintsMap=new Map}get constraints(){return this._constraints}addConstraint(t){this._constraints.add(t);let e=this._objectConstraintsMap.get(t.destination);e==null&&(e=new Set,this._objectConstraintsMap.set(t.destination,e)),e.add(t)}deleteConstraint(t){this._constraints.delete(t),this._objectConstraintsMap.get(t.destination).delete(t)}setInitState(){let t=new Set,e=new Set;for(let i of this._constraints)this._processConstraint(i,t,e,o=>o.setInitState())}update(){let t=new Set,e=new Set;for(let i of this._constraints)this._processConstraint(i,t,e,o=>o.update())}_processConstraint(t,e,i,o){if(i.has(t))return;if(e.has(t))throw new Error("VRMNodeConstraintManager: Circular dependency detected while updating constraints");e.add(t);let r=t.dependencies;for(let c of r)D(c,a=>{let s=this._objectConstraintsMap.get(a);if(s)for(let p of s)this._processConstraint(p,e,i,o)});o(t),i.add(t)}};import*as H from"three";var X=new H.Quaternion,G=new H.Quaternion,C=class extends l{get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._dstRestQuat=new H.Quaternion,this._invSrcRestQuat=new H.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),m(this._invSrcRestQuat.copy(this.source.quaternion))}update(){let t=X.copy(this._invSrcRestQuat).multiply(this.source.quaternion),e=G.copy(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(e,this.weight)}};import*as E from"three";var Y=new E.Vector3,Z=new E.Quaternion,W=new E.Quaternion,x=class extends l{get rollAxis(){return this._rollAxis}set rollAxis(t){this._rollAxis=t,this._v3RollAxis.set(t==="X"?1:0,t==="Y"?1:0,t==="Z"?1:0)}get dependencies(){return new Set([this.source])}constructor(t,e){super(t,e),this._rollAxis="X",this._v3RollAxis=new E.Vector3(1,0,0),this._dstRestQuat=new E.Quaternion,this._invDstRestQuat=new E.Quaternion,this._invSrcRestQuatMulDstRestQuat=new E.Quaternion}setInitState(){this._dstRestQuat.copy(this.destination.quaternion),m(this._invDstRestQuat.copy(this._dstRestQuat)),m(this._invSrcRestQuatMulDstRestQuat.copy(this.source.quaternion)).multiply(this._dstRestQuat)}update(){let t=Z.copy(this._invDstRestQuat).multiply(this.source.quaternion).multiply(this._invSrcRestQuatMulDstRestQuat),e=Y.copy(this._v3RollAxis).applyQuaternion(t),o=W.setFromUnitVectors(e,this._v3RollAxis).premultiply(this._dstRestQuat).multiply(t);this.destination.quaternion.copy(this._dstRestQuat).slerp(o,this.weight)}};var B=new Set(["1.0","1.0-beta"]),T=class T{get name(){return T.EXTENSION_NAME}constructor(t,e){this.parser=t,this.helperRoot=e==null?void 0:e.helperRoot}afterRoot(t){return w(this,null,function*(){t.userData.vrmNodeConstraintManager=yield this._import(t)})}_import(t){return w(this,null,function*(){var c;let e=this.parser.json;if(!(((c=e.extensionsUsed)==null?void 0:c.indexOf(T.EXTENSION_NAME))!==-1))return null;let o=new b,r=yield this.parser.getDependencies("node");return r.forEach((a,s)=>{var y;let p=e.nodes[s],M=(y=p==null?void 0:p.extensions)==null?void 0:y[T.EXTENSION_NAME];if(M==null)return;let S=M.specVersion;if(!B.has(S)){console.warn(`VRMNodeConstraintLoaderPlugin: Unknown ${T.EXTENSION_NAME} specVersion "${S}"`);return}let v=M.constraint;if(v.roll!=null){let _=this._importRollConstraint(a,r,v.roll);o.addConstraint(_)}else if(v.aim!=null){let _=this._importAimConstraint(a,r,v.aim);o.addConstraint(_)}else if(v.rotation!=null){let _=this._importRotationConstraint(a,r,v.rotation);o.addConstraint(_)}}),t.scene.updateMatrixWorld(),o.setInitState(),o})}_importRollConstraint(t,e,i){let{source:o,rollAxis:r,weight:c}=i,a=e[o],s=new x(t,a);if(r!=null&&(s.rollAxis=r),c!=null&&(s.weight=c),this.helperRoot){let p=new h(s);this.helperRoot.add(p)}return s}_importAimConstraint(t,e,i){let{source:o,aimAxis:r,weight:c}=i,a=e[o],s=new f(t,a);if(r!=null&&(s.aimAxis=r),c!=null&&(s.weight=c),this.helperRoot){let p=new h(s);this.helperRoot.add(p)}return s}_importRotationConstraint(t,e,i){let{source:o,weight:r}=i,c=e[o],a=new C(t,c);if(r!=null&&(a.weight=r),this.helperRoot){let s=new h(a);this.helperRoot.add(s)}return a}};T.EXTENSION_NAME="VRMC_node_constraint";var V=T;export{f as VRMAimConstraint,l as VRMNodeConstraint,h as VRMNodeConstraintHelper,V as VRMNodeConstraintLoaderPlugin,b as VRMNodeConstraintManager,x as VRMRollConstraint,C as VRMRotationConstraint};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixiv/three-vrm-node-constraint",
3
- "version": "3.4.4",
3
+ "version": "3.4.5",
4
4
  "description": "Node constraint module for @pixiv/three-vrm",
5
5
  "license": "MIT",
6
6
  "author": "pixiv",
@@ -35,7 +35,6 @@
35
35
  "build-prod": "cross-env NODE_ENV=production yarn build-js",
36
36
  "build-types": "tsc --project ./tsconfig.build-types.json",
37
37
  "docs-legacy": "typedoc --plugin ../../typedoc-redirect-legacy-docs-plugin.mjs",
38
- "test": "jest",
39
38
  "lint": "eslint \"src/**/*.{ts,tsx}\" && yarn lint-examples && prettier \"src/**/*.{ts,tsx}\" --check",
40
39
  "lint-examples": "eslint \"examples/**/*.{js,html}\" --rule \"padded-blocks: error\"",
41
40
  "lint-fix": "eslint \"src/**/*.{ts,tsx}\" --fix && eslint \"examples/**/*.{js,html}\" --fix && prettier \"src/**/*.{ts,tsx}\" --write"
@@ -50,7 +49,7 @@
50
49
  ]
51
50
  },
52
51
  "dependencies": {
53
- "@pixiv/types-vrmc-node-constraint-1.0": "3.4.4"
52
+ "@pixiv/types-vrmc-node-constraint-1.0": "3.4.5"
54
53
  },
55
54
  "devDependencies": {
56
55
  "@types/three": "^0.180.0",
@@ -59,5 +58,5 @@
59
58
  "peerDependencies": {
60
59
  "three": ">=0.137"
61
60
  },
62
- "gitHead": "44d95634496b40d88cb84a6bc48462336c1b4e8e"
61
+ "gitHead": "dbd6adac0c78f237fd9c2eaaeee92c8c15c8368a"
63
62
  }