reze-engine 0.41.2 → 0.41.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/model.d.ts CHANGED
@@ -47,6 +47,12 @@ export interface Bone {
47
47
  appendRatio?: number;
48
48
  appendRotate?: boolean;
49
49
  appendMove?: boolean;
50
+ /** 軸制限: this bone rotates ONLY about this axis (the twist bones use it). */
51
+ fixedAxis?: [number, number, number];
52
+ /** 変形階層: MMD poses whole layers in order, not bones in array order.
53
+ * Parsed but not yet honoured — distinct from Model's `deformOrder`, which is
54
+ * this engine's parent-before-child traversal. */
55
+ deformLayer?: number;
50
56
  ikTargetIndex?: number;
51
57
  ikIteration?: number;
52
58
  ikLimitAngle?: number;
@@ -233,6 +239,8 @@ export declare class Model {
233
239
  /** Called by Engine when registering the model; enables loadVmd to resolve relative paths for folder uploads. */
234
240
  setAssetContext(reader: AssetReader, basePath: string): void;
235
241
  constructor(vertexData: Float32Array<ArrayBuffer>, indexData: Uint32Array<ArrayBuffer>, textures: Texture[], materials: Material[], skeleton: Skeleton, skinning: Skinning, morphing: Morphing, rigidbodies?: Rigidbody[], joints?: Joint[], loadWarnings?: string[]);
242
+ /** 軸制限 bones and their normalised axes — see applyFixedAxes. */
243
+ private fixedAxisBones;
236
244
  private initializeRuntimeSkeleton;
237
245
  private initializeIKRuntime;
238
246
  private buildDeformOrder;
@@ -247,6 +255,26 @@ export declare class Model {
247
255
  * Stages are the reason this exists: a door or a lift is rigged as a bone
248
256
  * morph and there is no VMD anywhere that drives it.
249
257
  */
258
+ /**
259
+ * Take the last frame's bone-morph offsets back off, before any pose source
260
+ * runs.
261
+ *
262
+ * This cannot live at the top of applyBoneMorphs, which is where it used to
263
+ * be. A pose source writes only the bones its clip keys, and it writes them
264
+ * from the clip — so restoring afterwards overwrote the freshly animated pose
265
+ * with a snapshot taken a frame earlier, and the re-snapshot immediately
266
+ * below then saved that same stale value again. The result was not a drift or
267
+ * a lag: every bone any bone morph touched stayed pinned to the first frame
268
+ * the model was posed at, permanently, and at ANY weight — the restore ran
269
+ * over the touched set before the weight test, so a morph sitting at 0 froze
270
+ * its bones just as hard as one at 1.
271
+ *
272
+ * It reads as "the arms don't animate" because arms are what these morphs
273
+ * touch: character models routinely ship T-Pose / A-Pose / ShouderBlend /
274
+ * ElbowBlend adjusters on 腕 and ひじ, and nothing else in the rig is a
275
+ * comparably popular bone-morph target.
276
+ */
277
+ private undoBoneMorphs;
250
278
  private applyBoneMorphs;
251
279
  /** True (once) when effective morph weights changed — the engine re-derives
252
280
  * material-morph uniforms from it. Separate from the GPU vertex path's flag
@@ -420,6 +448,25 @@ export declare class Model {
420
448
  private sampleBoneTrackInto;
421
449
  /** Sample one morph track at `frame` (linear weight lerp). Returns NaN for an empty track. */
422
450
  private sampleMorphTrack;
451
+ /**
452
+ * Hold 軸制限 bones to their own axis.
453
+ *
454
+ * A twist bone (腕捩 / 手捩) exists to rotate about the length of the limb and
455
+ * nothing else, and PMX says so by giving it a fixed axis. A VMD still keys it
456
+ * with a full quaternion, so without the constraint the bone bends as well as
457
+ * twists — and because the elbow is parented to 腕捩 and 腕捩1..3 inherit a
458
+ * fraction of it, that error is carried into the whole forearm and multiplied
459
+ * three ways down the arm. It is the most visible thing on the model.
460
+ *
461
+ * Projecting the quaternion's vector part onto the axis and renormalising is
462
+ * what keeps the twist and drops everything else; the same operation MMD and
463
+ * every faithful runtime performs.
464
+ *
465
+ * Applied to the STORED local rotation rather than inside a matrix path,
466
+ * because the append children read that array directly: constrain it once and
467
+ * the bone, its inheritors and a hand-posed gizmo all agree.
468
+ */
469
+ private applyFixedAxes;
423
470
  private applyPoseFromClip;
424
471
  /** Weighted N-clip pose blend. Rotations accumulate by hemisphere-aligned weighted
425
472
  * sum then normalize (nlerp generalized to N inputs); VMD-space translations lerp.
@@ -1 +1 @@
1
- {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI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E,OAAO,CAAA;KAAE,GAAG,OAAO;IAoBjF,KAAK,IAAI,IAAI;IAIb,IAAI,IAAI,IAAI;IAOZ;;uEAEmE;IACnE,cAAc,IAAI,IAAI;IAQtB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAM3B,oBAAoB,IAAI,iBAAiB;IAazC,OAAO,CAAC,MAAM,CAAC,UAAU;IAWzB,OAAO,CAAC,iBAAiB;IAczB;;;;;;OAMG;IACH,OAAO,CAAC,UAAU,CAAoB;IAEtC;8EAC0E;IAC1E,OAAO,CAAC,eAAe;IAevB;;;;8BAI0B;IAC1B,OAAO,CAAC,mBAAmB;IA2C3B,8FAA8F;IAC9F,OAAO,CAAC,gBAAgB;IAkBxB;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,iBAAiB;IAiCzB;;;;yEAIqE;IACrE,OAAO,CAAC,gBAAgB;IAuIxB;sFACkF;IAClF,OAAO,CAAC,YAAY;IAmDpB;;2EAEuE;IACvE,OAAO,CAAC,cAAc;IA0CtB;;;;;;;;;OASG;IACH,MAAM,IAAI,OAAO;IAiBjB,qDAAqD;IACrD,OAAO,CAAC,eAAe;IAQvB,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,UAAO,GAAG,OAAO;IAoEpD,OAAO,CAAC,aAAa;IAyCrB,OAAO,CAAC,aAAa,CAAyB;IAI9C,OAAO,CAAC,4BAA4B;IAsHpC,oBAAoB,IAAI,IAAI;CAqF7B"}
package/dist/model.js CHANGED
@@ -151,6 +151,8 @@ export class Model {
151
151
  this.blendGenCounter = 0;
152
152
  this.assetReader = null;
153
153
  this.assetBasePath = "";
154
+ /** 軸制限 bones and their normalised axes — see applyFixedAxes. */
155
+ this.fixedAxisBones = [];
154
156
  // When true, update() skips applyPoseFromClip, so whatever was last written to
155
157
  // localRotations / localTranslations persists across frames. Used by gizmo drag
156
158
  // and other direct-manipulation flows to prevent the currently-shown clip from
@@ -201,6 +203,19 @@ export class Model {
201
203
  localTranslations[i] = Vec3.zeros();
202
204
  worldMatrices[i] = Mat4.identity();
203
205
  }
206
+ // 軸制限 bones, gathered once and normalised. A standard rig has four —
207
+ // the two arm twists and the two wrist twists — so this is a four-element
208
+ // walk per pose rather than a branch on every bone.
209
+ this.fixedAxisBones = [];
210
+ for (let i = 0; i < boneCount; i++) {
211
+ const a = this.skeleton.bones[i].fixedAxis;
212
+ if (!a)
213
+ continue;
214
+ const len = Math.hypot(a[0], a[1], a[2]);
215
+ if (len < 1e-8)
216
+ continue;
217
+ this.fixedAxisBones.push({ index: i, x: a[0] / len, y: a[1] / len, z: a[2] / len });
218
+ }
204
219
  this.runtimeSkeleton = {
205
220
  localRotations,
206
221
  localTranslations,
@@ -372,19 +387,42 @@ export class Model {
372
387
  * Stages are the reason this exists: a door or a lift is rigged as a bone
373
388
  * morph and there is no VMD anywhere that drives it.
374
389
  */
390
+ /**
391
+ * Take the last frame's bone-morph offsets back off, before any pose source
392
+ * runs.
393
+ *
394
+ * This cannot live at the top of applyBoneMorphs, which is where it used to
395
+ * be. A pose source writes only the bones its clip keys, and it writes them
396
+ * from the clip — so restoring afterwards overwrote the freshly animated pose
397
+ * with a snapshot taken a frame earlier, and the re-snapshot immediately
398
+ * below then saved that same stale value again. The result was not a drift or
399
+ * a lag: every bone any bone morph touched stayed pinned to the first frame
400
+ * the model was posed at, permanently, and at ANY weight — the restore ran
401
+ * over the touched set before the weight test, so a morph sitting at 0 froze
402
+ * its bones just as hard as one at 1.
403
+ *
404
+ * It reads as "the arms don't animate" because arms are what these morphs
405
+ * touch: character models routinely ship T-Pose / A-Pose / ShouderBlend /
406
+ * ElbowBlend adjusters on 腕 and ひじ, and nothing else in the rig is a
407
+ * comparably popular bone-morph target.
408
+ */
409
+ undoBoneMorphs() {
410
+ if (!this.boneMorphApplied)
411
+ return;
412
+ for (let i = 0; i < this.boneMorphBones.length; i++) {
413
+ const b = this.boneMorphBones[i];
414
+ this.runtimeSkeleton.localRotations[b].set(this.boneMorphRestoreR[i]);
415
+ this.runtimeSkeleton.localTranslations[b].set(this.boneMorphRestoreT[i]);
416
+ }
417
+ this.boneMorphApplied = false;
418
+ }
375
419
  applyBoneMorphs() {
376
420
  if (this.boneMorphPlan.length === 0)
377
421
  return;
378
- // Undo the previous application first. With a clip running this is a no-op
379
- // in effect the pose source already overwrote these bones but a stage
380
- // has no clip, so without it the same offset would be re-added every frame.
381
- if (this.boneMorphApplied) {
382
- for (let i = 0; i < this.boneMorphBones.length; i++) {
383
- const b = this.boneMorphBones[i];
384
- this.runtimeSkeleton.localRotations[b].set(this.boneMorphRestoreR[i]);
385
- this.runtimeSkeleton.localTranslations[b].set(this.boneMorphRestoreT[i]);
386
- }
387
- }
422
+ // Snapshot the pose as the sources left it, so undoBoneMorphs can hand these
423
+ // bones back unmorphed at the top of the next frame. The two halves are a
424
+ // pair: without the undo a stage which has no clip to rewrite its bones —
425
+ // would compound the same offset every frame.
388
426
  for (let i = 0; i < this.boneMorphBones.length; i++) {
389
427
  const b = this.boneMorphBones[i];
390
428
  this.boneMorphRestoreR[i].set(this.runtimeSkeleton.localRotations[b]);
@@ -1513,6 +1551,38 @@ export class Model {
1513
1551
  (frameB.frame > frameA.frame ? (clampedFrame - frameA.frame) / (frameB.frame - frameA.frame) : 0)
1514
1552
  : frameA.weight;
1515
1553
  }
1554
+ /**
1555
+ * Hold 軸制限 bones to their own axis.
1556
+ *
1557
+ * A twist bone (腕捩 / 手捩) exists to rotate about the length of the limb and
1558
+ * nothing else, and PMX says so by giving it a fixed axis. A VMD still keys it
1559
+ * with a full quaternion, so without the constraint the bone bends as well as
1560
+ * twists — and because the elbow is parented to 腕捩 and 腕捩1..3 inherit a
1561
+ * fraction of it, that error is carried into the whole forearm and multiplied
1562
+ * three ways down the arm. It is the most visible thing on the model.
1563
+ *
1564
+ * Projecting the quaternion's vector part onto the axis and renormalising is
1565
+ * what keeps the twist and drops everything else; the same operation MMD and
1566
+ * every faithful runtime performs.
1567
+ *
1568
+ * Applied to the STORED local rotation rather than inside a matrix path,
1569
+ * because the append children read that array directly: constrain it once and
1570
+ * the bone, its inheritors and a hand-posed gizmo all agree.
1571
+ */
1572
+ applyFixedAxes() {
1573
+ for (const a of this.fixedAxisBones) {
1574
+ const q = this.runtimeSkeleton.localRotations[a.index];
1575
+ const dot = q.x * a.x + q.y * a.y + q.z * a.z;
1576
+ const x = a.x * dot;
1577
+ const y = a.y * dot;
1578
+ const z = a.z * dot;
1579
+ const len = Math.sqrt(x * x + y * y + z * z + q.w * q.w);
1580
+ if (len > 1e-8) {
1581
+ const inv = 1 / len;
1582
+ q.setXYZW(x * inv, y * inv, z * inv, q.w * inv);
1583
+ }
1584
+ }
1585
+ }
1516
1586
  applyPoseFromClip(clip, frame) {
1517
1587
  if (!clip)
1518
1588
  return;
@@ -1532,6 +1602,7 @@ export class Model {
1532
1602
  this.runtimeSkeleton.localRotations[boneIdx].set(_animSlerp);
1533
1603
  this.runtimeSkeleton.localTranslations[boneIdx].set(localTranslation);
1534
1604
  }
1605
+ this.applyFixedAxes();
1535
1606
  for (const [morphName, keyFrames] of clip.morphTracks.entries()) {
1536
1607
  const weight = this.sampleMorphTrack(morphName, keyFrames, frame, this.morphTrackIndices);
1537
1608
  if (Number.isNaN(weight))
@@ -1680,6 +1751,7 @@ export class Model {
1680
1751
  this.runtimeSkeleton.localRotations[i].set(_blendQ);
1681
1752
  this.runtimeSkeleton.localTranslations[i].set(localTranslation);
1682
1753
  }
1754
+ this.applyFixedAxes();
1683
1755
  const morphCount = morphAcc.length;
1684
1756
  for (let i = 0; i < morphCount; i++) {
1685
1757
  if (morphGen[i] !== gen)
@@ -1835,6 +1907,11 @@ export class Model {
1835
1907
  const evWatch = this.clipEvents.size > 0 ? this.animationState.getCurrentAnimation() : null;
1836
1908
  const evPrevFrame = evWatch !== null ? this.animationState.getCurrentFrame() : 0;
1837
1909
  this.animationState.update(deltaTime);
1910
+ // Hand the pose sources their bones unmorphed. A bone morph is an offset on
1911
+ // top of the pose, so last frame's offset has to come off before this
1912
+ // frame's pose goes on — taking it off afterwards is what froze every
1913
+ // morph-touched bone at its first posed frame.
1914
+ this.undoBoneMorphs();
1838
1915
  if (!this.clipApplySuspended) {
1839
1916
  if (this.oneShot !== null) {
1840
1917
  this.applyOneShot(deltaTime);
@@ -1956,7 +2033,9 @@ export class Model {
1956
2033
  let addLocalTx = 0, addLocalTy = 0, addLocalTz = 0;
1957
2034
  // Handle append transformations (same logic as computeWorldMatrices)
1958
2035
  const appendParentIdx = b.appendParentIndex;
1959
- const hasAppend = b.appendRotate &&
2036
+ // `|| appendMove`: a move-only append (no rotation) was skipped altogether,
2037
+ // because the guard demanded appendRotate before either branch could run.
2038
+ const hasAppend = (b.appendRotate || b.appendMove) &&
1960
2039
  appendParentIdx !== undefined &&
1961
2040
  appendParentIdx >= 0 &&
1962
2041
  appendParentIdx < bones.length;
@@ -1982,12 +2061,15 @@ export class Model {
1982
2061
  scratchQuat[0].setXYZW(ax, ay, az, aw);
1983
2062
  scratchQuat[2].setIdentity();
1984
2063
  Quat.slerpInto(scratchQuat[2], scratchQuat[0], absRatio, scratchQuat[1]);
1985
- // finalRot = slerpResult * finalRot (rotation composition as quat mul)
2064
+ // MMD composes the append on the RIGHT: own animated rotation first, then
2065
+ // the inherited one (saba's `r = r * appendRotate`). We had it on the
2066
+ // left, which is a different rotation whenever a bone carries BOTH its
2067
+ // own key and an append — the twist bones, if a motion keys them.
1986
2068
  const sx = scratchQuat[1].x, sy = scratchQuat[1].y, sz = scratchQuat[1].z, sw = scratchQuat[1].w;
1987
- const nx = sw * fx + sx * fw + sy * fz - sz * fy;
1988
- const ny = sw * fy - sx * fz + sy * fw + sz * fx;
1989
- const nz = sw * fz + sx * fy - sy * fx + sz * fw;
1990
- const nw = sw * fw - sx * fx - sy * fy - sz * fz;
2069
+ const nx = fw * sx + fx * sw + fy * sz - fz * sy;
2070
+ const ny = fw * sy - fx * sz + fy * sw + fz * sx;
2071
+ const nz = fw * sz + fx * sy - fy * sx + fz * sw;
2072
+ const nw = fw * sw - fx * sx - fy * sy - fz * sz;
1991
2073
  fx = nx;
1992
2074
  fy = ny;
1993
2075
  fz = nz;
@@ -2036,7 +2118,7 @@ export class Model {
2036
2118
  let fx = boneRot.x, fy = boneRot.y, fz = boneRot.z, fw = boneRot.w;
2037
2119
  let addLocalTx = 0, addLocalTy = 0, addLocalTz = 0;
2038
2120
  const appendParentIdx = b.appendParentIndex;
2039
- const hasAppend = b.appendRotate && appendParentIdx !== undefined && appendParentIdx >= 0 && appendParentIdx < boneCount;
2121
+ const hasAppend = (b.appendRotate || b.appendMove) && appendParentIdx !== undefined && appendParentIdx >= 0 && appendParentIdx < boneCount;
2040
2122
  if (hasAppend) {
2041
2123
  const ratio = b.appendRatio === undefined ? 1 : Math.max(-1, Math.min(1, b.appendRatio));
2042
2124
  const hasRatio = Math.abs(ratio) > 1e-6;
@@ -2054,12 +2136,15 @@ export class Model {
2054
2136
  scratchQuat[0].setXYZW(ax, ay, az, aw);
2055
2137
  scratchQuat[2].setIdentity();
2056
2138
  Quat.slerpInto(scratchQuat[2], scratchQuat[0], absRatio, scratchQuat[1]);
2057
- // finalRot = slerpResult * finalRot (quat mul)
2139
+ // MMD composes the append on the RIGHT: own animated rotation first, then
2140
+ // the inherited one (saba's `r = r * appendRotate`). We had it on the
2141
+ // left, which is a different rotation whenever a bone carries BOTH its
2142
+ // own key and an append — the twist bones, if a motion keys them.
2058
2143
  const sx = scratchQuat[1].x, sy = scratchQuat[1].y, sz = scratchQuat[1].z, sw = scratchQuat[1].w;
2059
- const nx = sw * fx + sx * fw + sy * fz - sz * fy;
2060
- const ny = sw * fy - sx * fz + sy * fw + sz * fx;
2061
- const nz = sw * fz + sx * fy - sy * fx + sz * fw;
2062
- const nw = sw * fw - sx * fx - sy * fy - sz * fz;
2144
+ const nx = fw * sx + fx * sw + fy * sz - fz * sy;
2145
+ const ny = fw * sy - fx * sz + fy * sw + fz * sx;
2146
+ const nz = fw * sz + fx * sy - fy * sx + fz * sw;
2147
+ const nw = fw * sw - fx * sx - fy * sy - fz * sz;
2063
2148
  fx = nx;
2064
2149
  fy = ny;
2065
2150
  fz = nz;
@@ -1 +1 @@
1
- {"version":3,"file":"pmx-loader.d.ts","sourceRoot":"","sources":["../src/pmx-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAcN,MAAM,SAAS,CAAA;AAGhB,OAAO,EAA0B,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAEzE,qBAAa,SAAS;IACpB,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAAI;IACpB,OAAO,CAAC,mBAAmB,CAAI;IAC/B,OAAO,CAAC,eAAe,CAAI;IAC3B,OAAO,CAAC,gBAAgB,CAAI;IAC5B,OAAO,CAAC,iBAAiB,CAAI;IAC7B,OAAO,CAAC,aAAa,CAAI;IACzB,OAAO,CAAC,cAAc,CAAI;IAC1B,OAAO,CAAC,kBAAkB,CAAI;IAC9B,OAAO,CAAC,QAAQ,CAAgB;IAChC,OAAO,CAAC,SAAS,CAAiB;IAClC,OAAO,CAAC,KAAK,CAAa;IAC1B,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,QAAQ,CAA0B;IAC1C,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,WAAW,CAAY;IAC/B,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,QAAQ,CAAe;IAE/B,OAAO;IAQP,OAAO,CAAC,IAAI;WAMC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IAI9C,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,KAAK;WAIpC,cAAc,CAAC,MAAM,EAAE,WA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
304
304
  const parentIndex = this.getNonVertexIndex(this.boneIndexSize);
305
- this.getInt32(); // transform order (skip)
305
+ const deformLayer = this.getInt32(); // 変形階層
306
306
  const flags = this.getUint16();
307
307
  // Tail: bone index or offset vector3
308
308
  if ((flags & FLAG_TAIL_IS_BONE) !== 0) {
@@ -325,11 +325,10 @@ export class PmxLoader {
325
325
  appendRotate = (flags & FLAG_APPEND_ROTATE) !== 0;
326
326
  appendMove = (flags & FLAG_APPEND_MOVE) !== 0;
327
327
  }
328
- // Axis limit
328
+ // Axis limit (軸制限)
329
+ let fixedAxis = undefined;
329
330
  if ((flags & FLAG_AXIS_LIMIT) !== 0) {
330
- this.getFloat32();
331
- this.getFloat32();
332
- this.getFloat32();
331
+ fixedAxis = [this.getFloat32(), this.getFloat32(), this.getFloat32()];
333
332
  }
334
333
  // Local axis (two vectors x and z)
335
334
  if ((flags & FLAG_LOCAL_AXIS) !== 0) {
@@ -392,6 +391,8 @@ export class PmxLoader {
392
391
  appendRatio,
393
392
  appendRotate,
394
393
  appendMove,
394
+ fixedAxis,
395
+ deformLayer,
395
396
  ikTargetIndex,
396
397
  ikIteration,
397
398
  ikLimitAngle,
@@ -411,6 +412,8 @@ export class PmxLoader {
411
412
  appendRatio: a.appendRatio,
412
413
  appendRotate: a.appendRotate,
413
414
  appendMove: a.appendMove,
415
+ fixedAxis: a.fixedAxis,
416
+ deformLayer: a.deformLayer,
414
417
  ikTargetIndex: a.ikTargetIndex,
415
418
  ikIteration: a.ikIteration,
416
419
  ikLimitAngle: a.ikLimitAngle,
@@ -0,0 +1,13 @@
1
+ import type { DecodedImage } from "./tga-loader";
2
+ /** True when these bytes are a PSD/PSB, by magic rather than by file extension. */
3
+ export declare function isPsd(buffer: ArrayBuffer): boolean;
4
+ /**
5
+ * Decode a PSD's composite to RGBA8.
6
+ *
7
+ * RGB, grayscale, indexed and duotone at 8 or 16 bits per channel, raw or RLE —
8
+ * which is every texture that has actually turned up. CMYK and Lab throw: they
9
+ * need a colour conversion that would be guesswork without a profile, and a
10
+ * silently wrong-coloured texture is worse than a missing one.
11
+ */
12
+ export declare function decodePsd(buffer: ArrayBuffer): DecodedImage;
13
+ //# sourceMappingURL=psd-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psd-loader.d.ts","sourceRoot":"","sources":["../src/psd-loader.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAsBhD,mFAAmF;AACnF,wBAAgB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAElD;AA2BD;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,YAAY,CAuH3D"}
@@ -0,0 +1,192 @@
1
+ // PSD → RGBA8, from the merged composite.
2
+ //
3
+ // MMD texture packs are often shipped as the artist's working files, so a
4
+ // material's texture path points at a .psd that no browser will decode. The
5
+ // layers are none of our business — Photoshop writes a flattened composite of
6
+ // the whole document at the end of the file, which is exactly the image the
7
+ // artist saw, so that is what this reads.
8
+ //
9
+ // (A file saved with "Maximize Compatibility" off has no useful composite. There
10
+ // is nothing to be done about that here beyond failing clearly: reconstructing it
11
+ // would mean compositing every layer, blend mode and clipping group — a Photoshop,
12
+ // not a texture loader.)
13
+ const MAGIC = 0x38425053; // "8BPS", big-endian — PSD is big-endian throughout
14
+ var ColorMode;
15
+ (function (ColorMode) {
16
+ ColorMode[ColorMode["Bitmap"] = 0] = "Bitmap";
17
+ ColorMode[ColorMode["Grayscale"] = 1] = "Grayscale";
18
+ ColorMode[ColorMode["Indexed"] = 2] = "Indexed";
19
+ ColorMode[ColorMode["RGB"] = 3] = "RGB";
20
+ ColorMode[ColorMode["CMYK"] = 4] = "CMYK";
21
+ ColorMode[ColorMode["Multichannel"] = 7] = "Multichannel";
22
+ ColorMode[ColorMode["Duotone"] = 8] = "Duotone";
23
+ ColorMode[ColorMode["Lab"] = 9] = "Lab";
24
+ })(ColorMode || (ColorMode = {}));
25
+ const MODE_NAMES = {
26
+ [ColorMode.Bitmap]: "bitmap",
27
+ [ColorMode.CMYK]: "CMYK",
28
+ [ColorMode.Multichannel]: "multichannel",
29
+ [ColorMode.Lab]: "Lab",
30
+ };
31
+ /** True when these bytes are a PSD/PSB, by magic rather than by file extension. */
32
+ export function isPsd(buffer) {
33
+ return buffer.byteLength >= 26 && new DataView(buffer).getUint32(0, false) === MAGIC;
34
+ }
35
+ /**
36
+ * PackBits, one row at a time.
37
+ *
38
+ * `end` bounds the row rather than the buffer: the row-length table says how many
39
+ * compressed bytes this row occupies, and trusting the control bytes past that
40
+ * would let one malformed row eat the next one's data.
41
+ */
42
+ function unpackBits(src, start, end, dst, at, limit) {
43
+ let i = start;
44
+ let o = at;
45
+ while (i < end && o < limit) {
46
+ const n = (src[i++] << 24) >> 24; // to signed
47
+ if (n >= 0) {
48
+ const count = Math.min(n + 1, limit - o, end - i);
49
+ for (let k = 0; k < count; k++)
50
+ dst[o++] = src[i++];
51
+ }
52
+ else if (n !== -128) {
53
+ // -128 is a no-op by the spec, not a run of 129.
54
+ const count = Math.min(1 - n, limit - o);
55
+ const b = src[i++];
56
+ for (let k = 0; k < count; k++)
57
+ dst[o++] = b;
58
+ }
59
+ }
60
+ return o;
61
+ }
62
+ /**
63
+ * Decode a PSD's composite to RGBA8.
64
+ *
65
+ * RGB, grayscale, indexed and duotone at 8 or 16 bits per channel, raw or RLE —
66
+ * which is every texture that has actually turned up. CMYK and Lab throw: they
67
+ * need a colour conversion that would be guesswork without a profile, and a
68
+ * silently wrong-coloured texture is worse than a missing one.
69
+ */
70
+ export function decodePsd(buffer) {
71
+ const v = new DataView(buffer);
72
+ if (buffer.byteLength < 26 || v.getUint32(0, false) !== MAGIC)
73
+ throw new Error("not a PSD");
74
+ const version = v.getUint16(4, false); // 1 = PSD, 2 = PSB
75
+ if (version !== 1 && version !== 2)
76
+ throw new Error(`PSD unsupported version ${version}`);
77
+ const channels = v.getUint16(12, false);
78
+ const height = v.getUint32(14, false);
79
+ const width = v.getUint32(18, false);
80
+ const depth = v.getUint16(22, false);
81
+ const mode = v.getUint16(24, false);
82
+ if (width <= 0 || height <= 0)
83
+ throw new Error(`PSD bad dimensions ${width}x${height}`);
84
+ if (depth !== 8 && depth !== 16)
85
+ throw new Error(`PSD unsupported bit depth ${depth}`);
86
+ if (mode in MODE_NAMES)
87
+ throw new Error(`PSD unsupported colour mode: ${MODE_NAMES[mode]}`);
88
+ // Three variable-length sections stand between the header and the pixels. Only
89
+ // the indexed palette is worth reading; the rest is skipped by its length.
90
+ let p = 26;
91
+ const colorDataLen = v.getUint32(p, false);
92
+ const colorData = p + 4;
93
+ p = colorData + colorDataLen;
94
+ p += 4 + v.getUint32(p, false); // image resources
95
+ // PSB states this length in 8 bytes. Only the low word can matter — the high
96
+ // one would mean a layer section larger than 4GB.
97
+ if (version === 2) {
98
+ p += 8 + v.getUint32(p + 4, false);
99
+ }
100
+ else {
101
+ p += 4 + v.getUint32(p, false);
102
+ }
103
+ if (p + 2 > buffer.byteLength)
104
+ throw new Error("PSD truncated before the composite");
105
+ const compression = v.getUint16(p, false);
106
+ p += 2;
107
+ // Only the channels that carry colour, plus one alpha. A PSD can hold spot and
108
+ // mask channels past those; they are stored after, so ignoring them is a matter
109
+ // of not reading that far.
110
+ const colourChannels = mode === ColorMode.RGB ? 3 : 1;
111
+ const hasAlpha = channels > colourChannels;
112
+ const used = colourChannels + (hasAlpha ? 1 : 0);
113
+ if (channels < colourChannels)
114
+ throw new Error(`PSD has ${channels} channel(s), expected ${colourChannels}`);
115
+ const bytesPerSample = depth === 16 ? 2 : 1;
116
+ const planeSamples = width * height;
117
+ const planeBytes = planeSamples * bytesPerSample;
118
+ const planes = new Uint8Array(used * planeBytes);
119
+ if (compression === 0) {
120
+ const need = used * planeBytes;
121
+ if (p + need > buffer.byteLength)
122
+ throw new Error("PSD truncated composite");
123
+ planes.set(new Uint8Array(buffer, p, need));
124
+ }
125
+ else if (compression === 1) {
126
+ // A table of per-row compressed lengths for EVERY channel comes first,
127
+ // including the channels being skipped — so the table is read in full even
128
+ // though only the first `used` channels' rows are decoded.
129
+ const countBytes = version === 2 ? 4 : 2;
130
+ const tableBytes = channels * height * countBytes;
131
+ if (p + tableBytes > buffer.byteLength)
132
+ throw new Error("PSD truncated row table");
133
+ const rowLengths = new Uint32Array(channels * height);
134
+ for (let i = 0; i < rowLengths.length; i++) {
135
+ rowLengths[i] = countBytes === 2 ? v.getUint16(p + i * 2, false) : v.getUint32(p + i * 4, false);
136
+ }
137
+ const src = new Uint8Array(buffer);
138
+ let at = p + tableBytes;
139
+ for (let c = 0; c < channels; c++) {
140
+ for (let y = 0; y < height; y++) {
141
+ const len = rowLengths[c * height + y];
142
+ if (at + len > buffer.byteLength)
143
+ throw new Error("PSD truncated composite");
144
+ if (c < used) {
145
+ const rowStart = c * planeBytes + y * width * bytesPerSample;
146
+ unpackBits(src, at, at + len, planes, rowStart, rowStart + width * bytesPerSample);
147
+ }
148
+ at += len;
149
+ }
150
+ }
151
+ }
152
+ else {
153
+ // 2 and 3 are the Zip codes. They appear on layer data, effectively never on
154
+ // the composite, and inflating would mean shipping a decompressor.
155
+ throw new Error(`PSD unsupported compression ${compression}`);
156
+ }
157
+ // 16-bit samples are big-endian; the high byte is the 8-bit value.
158
+ const sample = (plane, i) => depth === 16 ? planes[plane * planeBytes + i * 2] : planes[plane * planeBytes + i];
159
+ const rgba = new Uint8Array(planeSamples * 4);
160
+ if (mode === ColorMode.Indexed) {
161
+ // The palette is the colour mode data: 256 reds, then 256 greens, then blues.
162
+ if (colorDataLen < 768)
163
+ throw new Error("PSD indexed image has no palette");
164
+ const pal = new Uint8Array(buffer, colorData, 768);
165
+ for (let i = 0; i < planeSamples; i++) {
166
+ const idx = sample(0, i);
167
+ rgba[i * 4] = pal[idx];
168
+ rgba[i * 4 + 1] = pal[256 + idx];
169
+ rgba[i * 4 + 2] = pal[512 + idx];
170
+ rgba[i * 4 + 3] = hasAlpha ? sample(1, i) : 255;
171
+ }
172
+ return { rgba, width, height };
173
+ }
174
+ for (let i = 0; i < planeSamples; i++) {
175
+ if (mode === ColorMode.RGB) {
176
+ rgba[i * 4] = sample(0, i);
177
+ rgba[i * 4 + 1] = sample(1, i);
178
+ rgba[i * 4 + 2] = sample(2, i);
179
+ }
180
+ else {
181
+ // Grayscale and duotone: one plane across all three. Duotone's ink colours
182
+ // live in the colour mode data, and the spec's own advice is to treat the
183
+ // data as grayscale — which is what every other reader does.
184
+ const g = sample(0, i);
185
+ rgba[i * 4] = g;
186
+ rgba[i * 4 + 1] = g;
187
+ rgba[i * 4 + 2] = g;
188
+ }
189
+ rgba[i * 4 + 3] = hasAlpha ? sample(colourChannels, i) : 255;
190
+ }
191
+ return { rgba, width, height };
192
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reze-engine",
3
- "version": "0.41.2",
3
+ "version": "0.41.4",
4
4
  "description": "A lightweight WebGPU engine for real-time 3D MMD/PMX model rendering",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",