reze-engine 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/engine.d.ts CHANGED
@@ -114,7 +114,7 @@ export declare class Engine {
114
114
  private setupCamera;
115
115
  private setupLighting;
116
116
  private setAmbientColor;
117
- loadAnimation(url: string, audioUrl?: string): Promise<void>;
117
+ loadAnimation(url: string): Promise<void>;
118
118
  playAnimation(): void;
119
119
  stopAnimation(): void;
120
120
  pauseAnimation(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAMnC,MAAM,MAAM,aAAa,GAAG;IAC1B,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,YAAY,CAAC,EAAE,IAAI,CAAA;CACpB,CAAA;AAED,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB;AAQD,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,OAAO,CAAmB;IAClC,OAAO,CAAC,kBAAkB,CAAmB;IAC7C,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,mBAAmB,CAAY;IACvC,OAAO,CAAC,gBAAgB,CAAuB;IAC/C,OAAO,CAAC,cAAc,CAAe;IACrC,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,YAAY,CAAY;IAChC,OAAO,CAAC,WAAW,CAAC,CAAW;IAC/B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,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM;IAKnE,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM;IAI5E,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI;IAQ9E,OAAO,CAAC,kBAAkB;YAQZ,iBAAiB;YA0GjB,cAAc;YAiNd,qBAAqB;IAmCnC,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,UAAU;IA6CX,MAAM;IA+Eb,OAAO,CAAC,UAAU;IAmGlB,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,eAAe;IAmBvB,OAAO,CAAC,mBAAmB;IAW3B,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,WAAW;CA0BpB"}
package/dist/engine.js CHANGED
@@ -1119,8 +1119,8 @@ export class Engine {
1119
1119
  this.lightData[2] = color.z;
1120
1120
  this.lightData[3] = 0.0; // Padding for vec3f alignment
1121
1121
  }
1122
- async loadAnimation(url, audioUrl) {
1123
- await this.player.loadVmd(url, audioUrl);
1122
+ async loadAnimation(url) {
1123
+ await this.player.loadVmd(url);
1124
1124
  this.hasAnimation = true;
1125
1125
  // Show first frame (time 0) immediately
1126
1126
  if (this.currentModel) {
package/dist/ik.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { Vec3 } from "./math";
2
+ import type { Skeleton } from "./model";
3
+ export interface IKLink {
4
+ boneIndex: number;
5
+ hasLimit: boolean;
6
+ minAngle?: Vec3;
7
+ maxAngle?: Vec3;
8
+ }
9
+ export interface IKChain {
10
+ targetBoneIndex: number;
11
+ effectorBoneIndex: number;
12
+ iterationCount: number;
13
+ rotationConstraint: number;
14
+ links: IKLink[];
15
+ enabled: boolean;
16
+ }
17
+ export declare class IK {
18
+ private chains;
19
+ private computeWorldMatricesCallback?;
20
+ private lastTargetPositions;
21
+ private convergedChains;
22
+ private ikRotations;
23
+ constructor(chains?: IKChain[]);
24
+ setComputeWorldMatricesCallback(callback: () => void): void;
25
+ getChains(): IKChain[];
26
+ enableChain(targetBoneName: string, enabled: boolean): void;
27
+ solve(skeleton: Skeleton, localRotations: Float32Array, localTranslations: Float32Array, worldMatrices: Float32Array): void;
28
+ private solveCCD;
29
+ private applyAngleConstraints;
30
+ private computeWorldMatrices;
31
+ }
32
+ //# sourceMappingURL=ik.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ik.d.ts","sourceRoot":"","sources":["../src/ik.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,IAAI,EAAQ,MAAM,QAAQ,CAAA;AACzC,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,SAAS,CAAA;AAE7C,MAAM,WAAW,MAAM;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,IAAI,CAAA;IACf,QAAQ,CAAC,EAAE,IAAI,CAAA;CAChB;AAED,MAAM,WAAW,OAAO;IACtB,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,cAAc,EAAE,MAAM,CAAA;IACtB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,qBAAa,EAAE;IACb,OAAO,CAAC,MAAM,CAAW;IACzB,OAAO,CAAC,4BAA4B,CAAC,CAAY;IAEjD,OAAO,CAAC,mBAAmB,CAA+B;IAE1D,OAAO,CAAC,eAAe,CAAyB;IAEhD,OAAO,CAAC,WAAW,CAA+B;gBAEtC,MAAM,GAAE,OAAO,EAAO;IAMlC,+BAA+B,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI;IAI3D,SAAS,IAAI,OAAO,EAAE;IAKtB,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAU3D,KAAK,CACH,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,YAAY,EAC5B,iBAAiB,EAAE,YAAY,EAC/B,aAAa,EAAE,YAAY,GAC1B,IAAI;IA2FP,OAAO,CAAC,QAAQ;IAqLhB,OAAO,CAAC,qBAAqB;IAe7B,OAAO,CAAC,oBAAoB;CAsG7B"}
package/dist/ik.js ADDED
@@ -0,0 +1,337 @@
1
+ import { Quat, Vec3, Mat4 } from "./math";
2
+ export class IK {
3
+ constructor(chains = []) {
4
+ // Track last target positions to detect movement
5
+ this.lastTargetPositions = new Map();
6
+ // Track convergence state for each chain (true = converged, skip solving)
7
+ this.convergedChains = new Set();
8
+ // Accumulated IK rotations for each bone (boneIndex -> quaternion)
9
+ this.ikRotations = new Map();
10
+ this.chains = chains;
11
+ }
12
+ // Set the callback to use Model's computeWorldMatrices
13
+ // The callback doesn't need parameters since Model uses its own runtime state
14
+ setComputeWorldMatricesCallback(callback) {
15
+ this.computeWorldMatricesCallback = callback;
16
+ }
17
+ getChains() {
18
+ return this.chains;
19
+ }
20
+ // Enable/disable IK chain by target bone name
21
+ enableChain(targetBoneName, enabled) {
22
+ // Chains are identified by target bone index, but we need to find by name
23
+ // This will be called from Model which has bone name lookup
24
+ for (const chain of this.chains) {
25
+ // We'll need to pass bone names or use indices - for now, this is a placeholder
26
+ // The actual implementation will be in Model class
27
+ }
28
+ }
29
+ // Main IK solve method - modifies bone local rotations in-place
30
+ solve(skeleton, localRotations, localTranslations, worldMatrices) {
31
+ if (this.chains.length === 0)
32
+ return;
33
+ const boneCount = skeleton.bones.length;
34
+ // Reset accumulated IK rotations for all chain bones (as per reference)
35
+ for (const chain of this.chains) {
36
+ for (const link of chain.links) {
37
+ const boneIdx = link.boneIndex;
38
+ if (boneIdx >= 0 && boneIdx < boneCount) {
39
+ this.ikRotations.set(boneIdx, new Quat(0, 0, 0, 1));
40
+ }
41
+ }
42
+ }
43
+ // Use Model's computeWorldMatrices if available (it uses the same arrays)
44
+ // Otherwise fall back to simplified version
45
+ if (this.computeWorldMatricesCallback) {
46
+ this.computeWorldMatricesCallback();
47
+ }
48
+ else {
49
+ // Fallback to simplified version (shouldn't happen in normal usage)
50
+ this.computeWorldMatrices(skeleton, localRotations, localTranslations, worldMatrices);
51
+ }
52
+ // Solve each IK chain
53
+ for (const chain of this.chains) {
54
+ if (!chain.enabled)
55
+ continue;
56
+ const targetBoneIdx = chain.targetBoneIndex;
57
+ const effectorBoneIdx = chain.effectorBoneIndex;
58
+ if (targetBoneIdx < 0 || targetBoneIdx >= boneCount || effectorBoneIdx < 0 || effectorBoneIdx >= boneCount) {
59
+ continue;
60
+ }
61
+ // Get target position (world position of target bone)
62
+ // In MMD, the target bone is the bone that should reach a specific position
63
+ // The target bone's current world position is where we want the effector to reach
64
+ const targetWorldMatIdx = targetBoneIdx * 16;
65
+ const targetWorldMat = new Mat4(worldMatrices.subarray(targetWorldMatIdx, targetWorldMatIdx + 16));
66
+ const targetPos = targetWorldMat.getPosition();
67
+ // Check if target has moved (detect any movement, even small)
68
+ const lastTargetPos = this.lastTargetPositions.get(targetBoneIdx);
69
+ let targetMoved = false;
70
+ if (!lastTargetPos) {
71
+ // First time seeing this target, initialize position and always solve
72
+ this.lastTargetPositions.set(targetBoneIdx, new Vec3(targetPos.x, targetPos.y, targetPos.z));
73
+ targetMoved = true;
74
+ }
75
+ else {
76
+ const targetMoveDistance = targetPos.subtract(lastTargetPos).length();
77
+ targetMoved = targetMoveDistance > 0.001; // Detect any movement > 0.001 units (0.1mm)
78
+ }
79
+ // Get current effector position
80
+ const effectorWorldMatIdx = effectorBoneIdx * 16;
81
+ const effectorWorldMat = new Mat4(worldMatrices.subarray(effectorWorldMatIdx, effectorWorldMatIdx + 16));
82
+ const effectorPos = effectorWorldMat.getPosition();
83
+ // Check distance to target
84
+ const distanceToTarget = effectorPos.subtract(targetPos).length();
85
+ // If target moved, always clear convergence and solve
86
+ if (targetMoved) {
87
+ this.convergedChains.delete(targetBoneIdx);
88
+ this.lastTargetPositions.set(targetBoneIdx, new Vec3(targetPos.x, targetPos.y, targetPos.z));
89
+ // Always solve when target moves, regardless of distance
90
+ }
91
+ else if (distanceToTarget < 0.1) {
92
+ // Target hasn't moved and we're already close, skip solving
93
+ if (!this.convergedChains.has(targetBoneIdx)) {
94
+ this.convergedChains.add(targetBoneIdx);
95
+ }
96
+ continue;
97
+ }
98
+ // Otherwise, solve (target hasn't moved but effector is far from target)
99
+ // Solve using CCD
100
+ // Note: In PMX, links are stored from effector toward root
101
+ // So links[0] is the effector, links[links.length-1] is closest to root
102
+ this.solveCCD(chain, skeleton, localRotations, localTranslations, worldMatrices, targetPos);
103
+ // Recompute world matrices after IK adjustments
104
+ if (this.computeWorldMatricesCallback) {
105
+ this.computeWorldMatricesCallback();
106
+ }
107
+ else {
108
+ this.computeWorldMatrices(skeleton, localRotations, localTranslations, worldMatrices);
109
+ }
110
+ }
111
+ }
112
+ // Cyclic Coordinate Descent IK solver (based on saba MMD implementation)
113
+ solveCCD(chain, skeleton, localRotations, localTranslations, worldMatrices, targetPos) {
114
+ const bones = skeleton.bones;
115
+ const iterationCount = chain.iterationCount;
116
+ const rotationConstraint = chain.rotationConstraint;
117
+ const links = chain.links;
118
+ if (links.length === 0)
119
+ return;
120
+ const effectorBoneIdx = chain.effectorBoneIndex;
121
+ // Get effector position
122
+ const effectorWorldMatIdx = effectorBoneIdx * 16;
123
+ const effectorWorldMat = new Mat4(worldMatrices.subarray(effectorWorldMatIdx, effectorWorldMatIdx + 16));
124
+ let effectorPos = effectorWorldMat.getPosition();
125
+ // Check initial distance - only skip if extremely close (numerical precision threshold)
126
+ const initialDistanceSq = effectorPos.subtract(targetPos).lengthSquared();
127
+ if (initialDistanceSq < 1.0e-10) {
128
+ this.convergedChains.add(chain.targetBoneIndex);
129
+ return;
130
+ }
131
+ const halfIteration = iterationCount >> 1;
132
+ for (let iter = 0; iter < iterationCount; iter++) {
133
+ const useAxis = iter < halfIteration;
134
+ for (let linkIdx = 0; linkIdx < links.length; linkIdx++) {
135
+ const link = links[linkIdx];
136
+ const jointBoneIdx = link.boneIndex;
137
+ if (jointBoneIdx < 0 || jointBoneIdx >= bones.length)
138
+ continue;
139
+ const bone = bones[jointBoneIdx];
140
+ // Get joint world position
141
+ const jointWorldMatIdx = jointBoneIdx * 16;
142
+ const jointWorldMat = new Mat4(worldMatrices.subarray(jointWorldMatIdx, jointWorldMatIdx + 16));
143
+ const jointPos = jointWorldMat.getPosition();
144
+ // Vectors: from joint to target and effector (REVERSED from typical CCD!)
145
+ // This matches the reference implementation
146
+ const chainTargetVector = jointPos.subtract(targetPos).normalize();
147
+ const chainIkVector = jointPos.subtract(effectorPos).normalize();
148
+ // Rotation axis: cross product
149
+ const chainRotationAxis = chainTargetVector.cross(chainIkVector);
150
+ const axisLenSq = chainRotationAxis.lengthSquared();
151
+ // Skip if axis is too small (vectors are parallel)
152
+ if (axisLenSq < 1.0e-8)
153
+ continue;
154
+ const chainRotationAxisNorm = chainRotationAxis.normalize();
155
+ // Get parent's world rotation matrix (rotation part only)
156
+ let parentWorldRot;
157
+ if (bone.parentIndex >= 0 && bone.parentIndex < bones.length) {
158
+ const parentWorldMatIdx = bone.parentIndex * 16;
159
+ const parentWorldMat = new Mat4(worldMatrices.subarray(parentWorldMatIdx, parentWorldMatIdx + 16));
160
+ parentWorldRot = parentWorldMat.toQuat();
161
+ }
162
+ else {
163
+ parentWorldRot = new Quat(0, 0, 0, 1);
164
+ }
165
+ // Transform rotation axis to parent's local space
166
+ // Invert parent rotation: parentWorldRot^-1
167
+ const parentWorldRotInv = parentWorldRot.conjugate();
168
+ // Transform axis: parentWorldRotInv * axis (as vector)
169
+ const localAxis = parentWorldRotInv.rotateVec(chainRotationAxisNorm).normalize();
170
+ // Calculate angle between vectors
171
+ const dot = Math.max(-1.0, Math.min(1.0, chainTargetVector.dot(chainIkVector)));
172
+ const angle = Math.min(rotationConstraint * (linkIdx + 1), Math.acos(dot));
173
+ // Create rotation quaternion from axis and angle
174
+ // q = (sin(angle/2) * axis, cos(angle/2))
175
+ const halfAngle = angle * 0.5;
176
+ const sinHalf = Math.sin(halfAngle);
177
+ const cosHalf = Math.cos(halfAngle);
178
+ const rotationFromAxis = new Quat(localAxis.x * sinHalf, localAxis.y * sinHalf, localAxis.z * sinHalf, cosHalf).normalize();
179
+ // Get accumulated ikRotation for this bone (or identity if first time)
180
+ let accumulatedIkRot = this.ikRotations.get(jointBoneIdx) || new Quat(0, 0, 0, 1);
181
+ // Accumulate rotation: ikRotation = rotationFromAxis * ikRotation
182
+ // Reference: ikRotation.multiplyToRef(chainBone.ikChainInfo!.ikRotation, chainBone.ikChainInfo!.ikRotation)
183
+ // This means: ikRotation = rotationFromAxis * accumulatedIkRot
184
+ accumulatedIkRot = rotationFromAxis.multiply(accumulatedIkRot);
185
+ this.ikRotations.set(jointBoneIdx, accumulatedIkRot);
186
+ // Get current local rotation
187
+ const qi = jointBoneIdx * 4;
188
+ const currentLocalRot = new Quat(localRotations[qi], localRotations[qi + 1], localRotations[qi + 2], localRotations[qi + 3]);
189
+ // Reference: ikRotation.multiplyToRef(chainBone.ikChainInfo!.localRotation, ikRotation)
190
+ // This means: tempRot = accumulatedIkRot * currentLocalRot
191
+ let tempRot = accumulatedIkRot.multiply(currentLocalRot);
192
+ // Apply angle constraints if specified (on the combined rotation)
193
+ if (link.hasLimit && link.minAngle && link.maxAngle) {
194
+ tempRot = this.applyAngleConstraints(tempRot, link.minAngle, link.maxAngle);
195
+ }
196
+ // Reference: ikRotation.multiplyToRef(invertedLocalRotation, ikRotation)
197
+ // This means: accumulatedIkRot = tempRot * currentLocalRot^-1
198
+ // But we need the new local rotation, not the accumulated IK rotation
199
+ // The new local rotation should be: newLocalRot such that accumulatedIkRot * newLocalRot = tempRot
200
+ // So: newLocalRot = accumulatedIkRot^-1 * tempRot
201
+ // But wait, the reference updates ikRotation, not localRotation directly...
202
+ // Actually, looking at the reference, it seems like ikRotation is used to compute the final rotation
203
+ // Let me try a different approach: the reference applies constraints to (ikRotation * localRotation)
204
+ // then extracts the new ikRotation, but we need the new localRotation
205
+ // Actually, I think the issue is that we should apply: newLocalRot = tempRot (the constrained result)
206
+ // But we need to extract what the new local rotation should be
207
+ // If tempRot = accumulatedIkRot * currentLocalRot (after constraints)
208
+ // Then: newLocalRot = accumulatedIkRot^-1 * tempRot
209
+ const accumulatedIkRotInv = accumulatedIkRot.conjugate();
210
+ let newLocalRot = accumulatedIkRotInv.multiply(tempRot);
211
+ // Update local rotation
212
+ const normalized = newLocalRot.normalize();
213
+ localRotations[qi] = normalized.x;
214
+ localRotations[qi + 1] = normalized.y;
215
+ localRotations[qi + 2] = normalized.z;
216
+ localRotations[qi + 3] = normalized.w;
217
+ // Update accumulated IK rotation as per reference
218
+ const localRotInv = currentLocalRot.conjugate();
219
+ accumulatedIkRot = tempRot.multiply(localRotInv);
220
+ this.ikRotations.set(jointBoneIdx, accumulatedIkRot);
221
+ // Update world matrices after this link adjustment (only once per link, not per bone)
222
+ if (this.computeWorldMatricesCallback) {
223
+ this.computeWorldMatricesCallback();
224
+ }
225
+ else {
226
+ this.computeWorldMatrices(skeleton, localRotations, localTranslations, worldMatrices);
227
+ }
228
+ // Update effector position for next link
229
+ const updatedEffectorMat2 = new Mat4(worldMatrices.subarray(effectorWorldMatIdx, effectorWorldMatIdx + 16));
230
+ effectorPos = updatedEffectorMat2.getPosition();
231
+ // Early exit if converged (check against original target position)
232
+ const currentDistanceSq = effectorPos.subtract(targetPos).lengthSquared();
233
+ if (currentDistanceSq < 1.0e-10) {
234
+ this.convergedChains.add(chain.targetBoneIndex);
235
+ return;
236
+ }
237
+ }
238
+ // Check convergence at end of iteration
239
+ const finalEffectorMat = new Mat4(worldMatrices.subarray(effectorWorldMatIdx, effectorWorldMatIdx + 16));
240
+ const finalEffectorPos = finalEffectorMat.getPosition();
241
+ const finalDistanceSq = finalEffectorPos.subtract(targetPos).lengthSquared();
242
+ if (finalDistanceSq < 1.0e-10) {
243
+ this.convergedChains.add(chain.targetBoneIndex);
244
+ break;
245
+ }
246
+ }
247
+ }
248
+ // Apply angle constraints to local rotation (Euler angle limits)
249
+ applyAngleConstraints(localRot, minAngle, maxAngle) {
250
+ // Convert quaternion to Euler angles
251
+ const euler = localRot.toEuler();
252
+ // Clamp each Euler angle component
253
+ let clampedX = Math.max(minAngle.x, Math.min(maxAngle.x, euler.x));
254
+ let clampedY = Math.max(minAngle.y, Math.min(maxAngle.y, euler.y));
255
+ let clampedZ = Math.max(minAngle.z, Math.min(maxAngle.z, euler.z));
256
+ // Convert back to quaternion (ZXY order, left-handed)
257
+ return Quat.fromEuler(clampedX, clampedY, clampedZ);
258
+ }
259
+ // Compute world matrices from local rotations and translations
260
+ // This matches Model.computeWorldMatrices logic (including append transforms)
261
+ computeWorldMatrices(skeleton, localRotations, localTranslations, worldMatrices) {
262
+ const bones = skeleton.bones;
263
+ const boneCount = bones.length;
264
+ const computed = new Array(boneCount).fill(false);
265
+ const computeWorld = (i) => {
266
+ if (computed[i])
267
+ return;
268
+ const bone = bones[i];
269
+ if (bone.parentIndex >= boneCount) {
270
+ console.warn(`[IK] bone ${i} parent out of range: ${bone.parentIndex}`);
271
+ }
272
+ const qi = i * 4;
273
+ const ti = i * 3;
274
+ // Get local rotation
275
+ let rotateM = Mat4.fromQuat(localRotations[qi], localRotations[qi + 1], localRotations[qi + 2], localRotations[qi + 3]);
276
+ let addLocalTx = 0, addLocalTy = 0, addLocalTz = 0;
277
+ // Handle append transforms (same as Model.computeWorldMatrices)
278
+ const appendParentIdx = bone.appendParentIndex;
279
+ const hasAppend = bone.appendRotate && appendParentIdx !== undefined && appendParentIdx >= 0 && appendParentIdx < boneCount;
280
+ if (hasAppend) {
281
+ const ratio = bone.appendRatio === undefined ? 1 : Math.max(-1, Math.min(1, bone.appendRatio));
282
+ const hasRatio = Math.abs(ratio) > 1e-6;
283
+ if (hasRatio) {
284
+ const apQi = appendParentIdx * 4;
285
+ const apTi = appendParentIdx * 3;
286
+ if (bone.appendRotate) {
287
+ let ax = localRotations[apQi];
288
+ let ay = localRotations[apQi + 1];
289
+ let az = localRotations[apQi + 2];
290
+ const aw = localRotations[apQi + 3];
291
+ const absRatio = ratio < 0 ? -ratio : ratio;
292
+ if (ratio < 0) {
293
+ ax = -ax;
294
+ ay = -ay;
295
+ az = -az;
296
+ }
297
+ const identityQuat = new Quat(0, 0, 0, 1);
298
+ const appendQuat = new Quat(ax, ay, az, aw);
299
+ const result = Quat.slerp(identityQuat, appendQuat, absRatio);
300
+ rotateM = Mat4.fromQuat(result.x, result.y, result.z, result.w).multiply(rotateM);
301
+ }
302
+ if (bone.appendMove) {
303
+ const appendRatio = bone.appendRatio ?? 1;
304
+ addLocalTx = localTranslations[apTi] * appendRatio;
305
+ addLocalTy = localTranslations[apTi + 1] * appendRatio;
306
+ addLocalTz = localTranslations[apTi + 2] * appendRatio;
307
+ }
308
+ }
309
+ }
310
+ // Get bone's own translation
311
+ const boneTx = localTranslations[ti];
312
+ const boneTy = localTranslations[ti + 1];
313
+ const boneTz = localTranslations[ti + 2];
314
+ // Build local matrix: bindTranslation + rotation + (bone translation + append translation)
315
+ const localM = Mat4.identity().translateInPlace(bone.bindTranslation[0], bone.bindTranslation[1], bone.bindTranslation[2]);
316
+ const transM = Mat4.identity().translateInPlace(boneTx + addLocalTx, boneTy + addLocalTy, boneTz + addLocalTz);
317
+ const localMatrix = localM.multiply(rotateM).multiply(transM);
318
+ const worldOffset = i * 16;
319
+ if (bone.parentIndex >= 0) {
320
+ const p = bone.parentIndex;
321
+ if (!computed[p])
322
+ computeWorld(p);
323
+ const parentOffset = p * 16;
324
+ const parentWorldMat = new Mat4(worldMatrices.subarray(parentOffset, parentOffset + 16));
325
+ const worldMat = parentWorldMat.multiply(localMatrix);
326
+ worldMatrices.set(worldMat.values, worldOffset);
327
+ }
328
+ else {
329
+ worldMatrices.set(localMatrix.values, worldOffset);
330
+ }
331
+ computed[i] = true;
332
+ };
333
+ // Process all bones
334
+ for (let i = 0; i < boneCount; i++)
335
+ computeWorld(i);
336
+ }
337
+ }
package/dist/math.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare class Vec3 {
7
7
  add(other: Vec3): Vec3;
8
8
  subtract(other: Vec3): Vec3;
9
9
  length(): number;
10
+ lengthSquared(): number;
10
11
  normalize(): Vec3;
11
12
  cross(other: Vec3): Vec3;
12
13
  dot(other: Vec3): number;
@@ -1 +1 @@
1
- {"version":3,"file":"math.d.ts","sourceRoot":"","sources":["../src/math.ts"],"names":[],"mappings":"AACA,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED,qBAAa,IAAI;IACf,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;gBAEG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAM3C,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAItB,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAI3B,MAAM,IAAI,MAAM;IAIhB,SAAS,IAAI,IAAI;IAMjB,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAQxB,GAAG,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM;IAIxB,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,IAAI,IAAI;CAGd;AAED,qBAAa,IAAI;IACf,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;gBAEG,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;IAOtD,GAAG,CAAC,KAAK,EAAE,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;IAMvB,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI;IA4BhF,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,GAAG,IAAI;IA4BtD,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI;IAqB3B,MAAM,CAAC,cAAc,CACnB,CAAC,EAAE,YAAY,EACf,OAAO,EAAE,MAAM,EACf,CAAC,EAAE,YAAY,EACf,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,MAAM,GAChB,IAAI;IAiBP,KAAK,IAAI,IAAI;IAIb,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAmCjE,MAAM,CAAC,oBAAoB,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,GAAG,IAAI;IASjE,WAAW,IAAI,IAAI;IAKnB,MAAM,IAAI,IAAI;IAKd,MAAM,CAAC,eAAe,CAAC,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA6C7D,WAAW,IAAI,IAAI;IAqBnB,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAY1D,OAAO,IAAI,IAAI;CA8DhB"}
package/dist/math.js CHANGED
@@ -17,6 +17,9 @@ export class Vec3 {
17
17
  length() {
18
18
  return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
19
19
  }
20
+ lengthSquared() {
21
+ return this.x * this.x + this.y * this.y + this.z * this.z;
22
+ }
20
23
  normalize() {
21
24
  const len = this.length();
22
25
  if (len === 0)
package/dist/player.d.ts CHANGED
@@ -20,23 +20,17 @@ export declare class Player {
20
20
  private startTime;
21
21
  private pausedTime;
22
22
  private pauseStartTime;
23
- private audioElement?;
24
- private audioUrl?;
25
- private audioLoaded;
26
23
  /**
27
- * Load VMD animation file and optionally audio
24
+ * Load VMD animation file
28
25
  */
29
- loadVmd(vmdUrl: string, audioUrl?: string): Promise<void>;
30
- /**
31
- * Load audio file
32
- */
33
- loadAudio(url: string): Promise<void>;
26
+ loadVmd(vmdUrl: string): Promise<void>;
34
27
  /**
35
28
  * Process frames into tracks
36
29
  */
37
30
  private processFrames;
38
31
  /**
39
32
  * Start or resume playback
33
+ * Note: For iOS, this should be called synchronously from a user interaction event
40
34
  */
41
35
  play(): void;
42
36
  /**
@@ -80,21 +74,5 @@ export declare class Player {
80
74
  * Check if paused
81
75
  */
82
76
  isPausedState(): boolean;
83
- /**
84
- * Check if has audio
85
- */
86
- hasAudio(): boolean;
87
- /**
88
- * Set audio volume (0.0 to 1.0)
89
- */
90
- setVolume(volume: number): void;
91
- /**
92
- * Mute audio
93
- */
94
- mute(): void;
95
- /**
96
- * Unmute audio
97
- */
98
- unmute(): void;
99
77
  }
100
78
  //# sourceMappingURL=player.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"player.d.ts","sourceRoot":"","sources":["../src/player.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAGnC,MAAM,WAAW,aAAa;IAC5B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAChC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IACnC,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAClC;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,MAAM,CAAA;IAChB,UAAU,EAAE,MAAM,CAAA;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