@pmndrs/viverse 0.2.7 → 0.2.8

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.
@@ -24,6 +24,19 @@ const position = new Vector3();
24
24
  const nonVrmRotationOffset = new Quaternion().setFromEuler(new Euler(0, Math.PI, 0));
25
25
  //TODO: currently assumes the model is not yet transformed - loaded for the first time
26
26
  export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement) {
27
+ clip.tracks = clip.tracks.filter((track) => {
28
+ if (track instanceof QuaternionKeyframeTrack) {
29
+ return true;
30
+ }
31
+ const [clipBoneName, propertyName] = track.name.split('.');
32
+ if (propertyName != 'position') {
33
+ return false;
34
+ }
35
+ if (clipBoneName == 'hips' || clipBoneName == 'root') {
36
+ return true;
37
+ }
38
+ return false;
39
+ });
27
40
  let restRoot;
28
41
  let restRootParent;
29
42
  if (!(model instanceof VRM)) {
@@ -127,12 +140,6 @@ export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement)
127
140
  track.name = trackName;
128
141
  }
129
142
  else if (track instanceof VectorKeyframeTrack) {
130
- if (clipBoneName != 'hips' && clipBoneName != 'root') {
131
- continue;
132
- }
133
- if (propertyName != 'position') {
134
- continue;
135
- }
136
143
  for (let i = 0; i < track.values.length; i += 3) {
137
144
  position.fromArray(track.values, i);
138
145
  if (clipSceneHips?.parent != null) {
@@ -143,6 +150,11 @@ export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement)
143
150
  position.multiplyScalar(clipSceneHips.parent.matrixWorld.getMaxScaleOnAxis());
144
151
  }
145
152
  }
153
+ const modelBone = model.scene.getObjectByName(`rest_${clipBoneName}`);
154
+ if (modelBone != null) {
155
+ modelBone.updateMatrixWorld();
156
+ position.divideScalar(modelBone.matrixWorld.getMaxScaleOnAxis());
157
+ }
146
158
  position.multiplyScalar(positionScale);
147
159
  if (!(model instanceof VRM) && clipBoneName === 'hips') {
148
160
  position.applyQuaternion(nonVrmRotationOffset);
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "three": "*"
23
23
  },
24
- "version": "0.2.7",
24
+ "version": "0.2.8",
25
25
  "type": "module",
26
26
  "dependencies": {
27
27
  "@pixiv/three-vrm": "^3.4.2",