@pmndrs/viverse 0.1.16 → 0.1.17

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.
@@ -5,10 +5,8 @@ import { loadVrmModelMixamoAnimations as loadModelMixamoAnimations } from './mix
5
5
  import { scaleAnimationClipTime, trimAnimationClip } from './utils.js';
6
6
  import { loadVrmModelVrmaAnimations } from './vrma.js';
7
7
  import { cached } from '../utils.js';
8
- const parentWorldVector = new Vector3();
9
8
  const restRotationInverse = new Quaternion();
10
9
  const parentRestWorldRotation = new Quaternion();
11
- const parentRestWorldRotationInverse = new Quaternion();
12
10
  const quaternion = new Quaternion();
13
11
  const vector = new Vector3();
14
12
  const nonVrmRotationOffset = new Quaternion().setFromEuler(new Euler(0, Math.PI, 0));
@@ -18,7 +16,9 @@ export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement,
18
16
  throw new Error('Failed to determine hips bone name for VRM animation. Please check the bone map or animation file.');
19
17
  }
20
18
  const clipSceneHips = clipScene.getObjectByName(hipsBoneName);
21
- const vrmHipsPosition = model instanceof VRM ? model.humanoid.normalizedRestPose.hips?.position : clipSceneHips?.position;
19
+ const vrmHipsPosition = model instanceof VRM
20
+ ? model.humanoid.normalizedRestPose.hips?.position
21
+ : model.scene.getObjectByName('hips')?.position.toArray();
22
22
  if (clipSceneHips == null || vrmHipsPosition == null) {
23
23
  throw new Error('Failed to load VRM animation: missing animation hips object or VRM hips position.');
24
24
  }
@@ -32,14 +32,18 @@ export function fixModelAnimationClip(model, clip, clipScene, removeXZMovement,
32
32
  const vrmBoneName = boneMap?.[boneName] ?? boneName;
33
33
  const vrmNodeName = model instanceof VRM ? model.humanoid.getNormalizedBoneNode(vrmBoneName)?.name : vrmBoneName;
34
34
  const bone = clipScene.getObjectByName(boneName);
35
- if (vrmNodeName == null || bone == null || bone.parent == null) {
35
+ if (vrmNodeName == null || bone == null) {
36
36
  continue;
37
37
  }
38
- bone.getWorldQuaternion(restRotationInverse).invert();
39
- bone.parent.getWorldQuaternion(parentRestWorldRotation);
40
- parentRestWorldRotationInverse.copy(parentRestWorldRotation).invert();
41
- bone.parent.getWorldPosition(parentWorldVector);
42
38
  if (track instanceof QuaternionKeyframeTrack) {
39
+ if (bone.parent != null) {
40
+ bone.getWorldQuaternion(restRotationInverse).invert();
41
+ bone.parent.getWorldQuaternion(parentRestWorldRotation);
42
+ }
43
+ else {
44
+ restRotationInverse.identity();
45
+ parentRestWorldRotation.identity();
46
+ }
43
47
  // Store rotations of rest-pose.
44
48
  for (let i = 0; i < track.values.length; i += 4) {
45
49
  quaternion.fromArray(track.values, i);
package/package.json CHANGED
@@ -21,7 +21,7 @@
21
21
  "peerDependencies": {
22
22
  "three": "*"
23
23
  },
24
- "version": "0.1.16",
24
+ "version": "0.1.17",
25
25
  "type": "module",
26
26
  "dependencies": {
27
27
  "@pixiv/three-vrm": "^3.4.2",