reze-engine 0.50.6 → 0.50.7

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.
Files changed (57) hide show
  1. package/dist/_dbg-loader.mjs +1100 -0
  2. package/dist/physics-debug.d.ts +30 -0
  3. package/dist/physics-debug.d.ts.map +1 -0
  4. package/dist/physics-debug.js +526 -0
  5. package/dist/shaders/materials/body.d.ts +2 -0
  6. package/dist/shaders/materials/body.d.ts.map +1 -0
  7. package/dist/shaders/materials/body.js +95 -0
  8. package/dist/shaders/materials/cloth_rough.d.ts +2 -0
  9. package/dist/shaders/materials/cloth_rough.d.ts.map +1 -0
  10. package/dist/shaders/materials/cloth_rough.js +69 -0
  11. package/dist/shaders/materials/cloth_smooth.d.ts +2 -0
  12. package/dist/shaders/materials/cloth_smooth.d.ts.map +1 -0
  13. package/dist/shaders/materials/cloth_smooth.js +61 -0
  14. package/dist/shaders/materials/default.d.ts +2 -0
  15. package/dist/shaders/materials/default.d.ts.map +1 -0
  16. package/dist/shaders/materials/default.js +43 -0
  17. package/dist/shaders/materials/eye.d.ts +2 -0
  18. package/dist/shaders/materials/eye.d.ts.map +1 -0
  19. package/dist/shaders/materials/eye.js +60 -0
  20. package/dist/shaders/materials/face.d.ts +2 -0
  21. package/dist/shaders/materials/face.d.ts.map +1 -0
  22. package/dist/shaders/materials/face.js +95 -0
  23. package/dist/shaders/materials/hair.d.ts +2 -0
  24. package/dist/shaders/materials/hair.d.ts.map +1 -0
  25. package/dist/shaders/materials/hair.js +90 -0
  26. package/dist/shaders/materials/metal.d.ts +2 -0
  27. package/dist/shaders/materials/metal.d.ts.map +1 -0
  28. package/dist/shaders/materials/metal.js +77 -0
  29. package/dist/shaders/materials/mmd_classic.d.ts +2 -0
  30. package/dist/shaders/materials/mmd_classic.d.ts.map +1 -0
  31. package/dist/shaders/materials/mmd_classic.js +66 -0
  32. package/dist/shaders/materials/stockings.d.ts +2 -0
  33. package/dist/shaders/materials/stockings.d.ts.map +1 -0
  34. package/dist/shaders/materials/stockings.js +122 -0
  35. package/dist/shaders/passes/physics-debug.d.ts +2 -0
  36. package/dist/shaders/passes/physics-debug.d.ts.map +1 -0
  37. package/dist/shaders/passes/physics-debug.js +69 -0
  38. package/dist/vmd-writer.d.ts +11 -6
  39. package/dist/vmd-writer.d.ts.map +1 -1
  40. package/dist/vmd-writer.js +35 -17
  41. package/package.json +1 -1
  42. package/src/vmd-writer.ts +36 -16
  43. package/dist/physics/autofit.d.ts +0 -147
  44. package/dist/physics/autofit.d.ts.map +0 -1
  45. package/dist/physics/autofit.js +0 -501
  46. package/dist/shaders/passes/field-blit.d.ts +0 -26
  47. package/dist/shaders/passes/field-blit.d.ts.map +0 -1
  48. package/dist/shaders/passes/field-blit.js +0 -65
  49. package/dist/shaders/passes/ground-noise.d.ts +0 -7
  50. package/dist/shaders/passes/ground-noise.d.ts.map +0 -1
  51. package/dist/shaders/passes/ground-noise.js +0 -88
  52. package/dist/shaders/passes/sim.d.ts +0 -34
  53. package/dist/shaders/passes/sim.d.ts.map +0 -1
  54. package/dist/shaders/passes/sim.js +0 -169
  55. package/dist/shaders/score-api.d.ts +0 -10
  56. package/dist/shaders/score-api.d.ts.map +0 -1
  57. package/dist/shaders/score-api.js +0 -114
package/src/vmd-writer.ts CHANGED
@@ -103,10 +103,17 @@ export class VMDWriter {
103
103
  MODEL_NAME_SIZE +
104
104
  4 + totalBoneFrames * BONE_FRAME_SIZE +
105
105
  4 + totalMorphFrames * MORPH_FRAME_SIZE +
106
- // Camera, light and self-shadow counts, then the IK block. Written only
107
- // when there is IK state to carry: a plain motion stays byte-identical to
108
- // what this writer produced before.
109
- (ikFrames.length > 0 ? 4 * 4 + ikSize : 0)
106
+ // Camera, light, self-shadow and IK counts, ALWAYS — 16 bytes even when
107
+ // every one of them is zero.
108
+ //
109
+ // A VMD's sections are positional: a reader reaches each block by walking
110
+ // every count before it. Writing these only when there was IK state to
111
+ // carry left an ordinary motion ending right after the morph block, so
112
+ // anything looking for the sections that follow read past the end of the
113
+ // file and took whatever it found. MMD's own motion files carry all five
114
+ // counts unconditionally; so do ours now.
115
+ 4 * 4 +
116
+ ikSize
110
117
 
111
118
  const buffer = new ArrayBuffer(size)
112
119
  const view = new DataView(buffer)
@@ -170,12 +177,14 @@ export class VMDWriter {
170
177
  }
171
178
  }
172
179
 
180
+ // Empty camera, light and self-shadow blocks, then the IK count — written
181
+ // whether or not there is IK state, so the file always ends on a complete
182
+ // section table.
183
+ for (let i = 0; i < 3; i++, offset += 4) view.setUint32(offset, 0, true)
184
+ view.setUint32(offset, ikFrames.length, true)
185
+ offset += 4
186
+
173
187
  if (ikFrames.length > 0) {
174
- // Empty camera, light and self-shadow blocks — a reader walking the file
175
- // in order has to pass through them to reach the IK block.
176
- for (let i = 0; i < 3; i++, offset += 4) view.setUint32(offset, 0, true)
177
- view.setUint32(offset, ikFrames.length, true)
178
- offset += 4
179
188
  for (const [frame, states] of ikFrames) {
180
189
  view.setUint32(offset, frame, true)
181
190
  offset += 4
@@ -197,12 +206,17 @@ export class VMDWriter {
197
206
  /**
198
207
  * A camera VMD: the shot's own file, with no model motion in it.
199
208
  *
200
- * Bone and morph counts are written as zero rather than omitted — the camera
201
- * block sits after them in the format, so a reader walking the file in order
202
- * (including this package's own parseCamera) has to pass through both to
203
- * reach it. Light, self-shadow and IK blocks are left off entirely; every
204
- * reader bounds-checks past the camera block, and MMD is happy with a file
205
- * that simply ends there.
209
+ * Every section count is written, including the empty ones. The format is
210
+ * positional, so a reader reaches each block by walking the counts before it —
211
+ * bone and morph to arrive at the camera block, and light, self-shadow and IK
212
+ * to leave it cleanly.
213
+ *
214
+ * The trailing three used to be omitted, on the theory that every reader
215
+ * bounds-checks past the camera block. They do not. This file type is
216
+ * カメラ・照明 — camera AND lighting — so MMD looks for the light block exactly
217
+ * where the file used to stop, read past the end, and lit the scene from
218
+ * whatever it found there. It reached users as a stray coloured light on a
219
+ * camera-only export.
206
220
  *
207
221
  * `frames` is sorted by frame on the way out: CameraAnimation binary-searches
208
222
  * the track it loads, and an out-of-order file would sample wrong rather than
@@ -210,7 +224,8 @@ export class VMDWriter {
210
224
  */
211
225
  writeCamera(frames: CameraKeyframe[]): ArrayBuffer {
212
226
  const sorted = [...frames].sort((a, b) => a.frame - b.frame)
213
- const size = HEADER_SIZE + MODEL_NAME_SIZE + 4 + 4 + 4 + sorted.length * CAMERA_FRAME_SIZE
227
+ const size =
228
+ HEADER_SIZE + MODEL_NAME_SIZE + 4 + 4 + 4 + sorted.length * CAMERA_FRAME_SIZE + 4 * 3
214
229
  const buffer = new ArrayBuffer(size)
215
230
  const view = new DataView(buffer)
216
231
  let offset = 0
@@ -249,6 +264,11 @@ export class VMDWriter {
249
264
  offset += 1
250
265
  }
251
266
 
267
+ // Light, self-shadow and IK/display counts. See the note above: the light
268
+ // block begins here, and leaving it off is what lit MMD from past the end
269
+ // of the file.
270
+ for (let i = 0; i < 3; i++, offset += 4) view.setUint32(offset, 0, true)
271
+
252
272
  return buffer
253
273
  }
254
274
  }
@@ -1,147 +0,0 @@
1
- import { type Rigidbody } from "./types";
2
- import type { Skinning } from "../model";
3
- /**
4
- * Supplementary colliders fitted to the mesh a PMX rigid body fails to cover.
5
- *
6
- * PMX body proxies are bodies of revolution — 下半身 is a capsule lying
7
- * transversely across the hips, so its cross-section is a circle. A pelvis seen
8
- * from the side is not a circle, and across every rig measured the butt sits
9
- * 0.18–0.71 units OUTSIDE that capsule while the front is flush or inside. That
10
- * gap is where a skirt goes through a character: the cloth is resting correctly
11
- * on the collider it was given, and the collider stops half a unit short of the
12
- * skin.
13
- *
14
- * A rest offset cannot close it (see RigidBodyStore.restOffset) — it is one
15
- * scalar on a radially symmetric shape, and the error is asymmetric. Measured
16
- * on 托特's run cycle, the offset that clears the butt is 0.5, which is simply
17
- * the size of the missing geometry, and at that value the skirt stands off the
18
- * front and hips by the same 0.5.
19
- *
20
- * So fit the missing piece instead: take each bone-following body's own skinned
21
- * vertices, find the ones that escape its shape in a concentrated lobe, and fit
22
- * a capsule to that lobe. That is the fix riggers apply by hand, derived from
23
- * the mesh rather than guessed.
24
- *
25
- * Measured on 托特's run cycle, counting butt vertices swallowed by a cloth
26
- * body: 32.4 per frame with nothing, 30.9 with a 0.02 rest offset, 12.4 with
27
- * this pass, 10.4 with both.
28
- */
29
- export interface AutoFitOptions {
30
- /** A vertex counts as protruding past this much (model units). Below it the
31
- * mesh is within authoring tolerance of the proxy and needs no help. */
32
- minProtrusion?: number;
33
- /**
34
- * Ignore vertices further out than this multiple of the source shape's
35
- * RADIUS (its smallest characteristic dimension).
36
- *
37
- * A coarse first cut at keeping hair and loose clothing out — anything
38
- * standing further off the proxy than the proxy is wide is not skin. The
39
- * discriminator that actually does the work is minConcentration.
40
- */
41
- maxProtrusionRatio?: number;
42
- /** Fewer protruding vertices than this and it is a spike, not a region. */
43
- minVertices?: number;
44
- /**
45
- * Per-axis quantile the fitted lobe's extent is clipped to, each end. A
46
- * handful of stray vertices (a weight-painting slip, a seam) would otherwise
47
- * stretch the capsule far past the surface everyone can see.
48
- */
49
- quantile?: number;
50
- /** Skip the fit unless the capsule actually reaches this far past what is
51
- * already covered — otherwise it adds solver rows for nothing. */
52
- minGain?: number;
53
- /** How tightly the kept lobe's outward directions must agree, 0–1. A loose
54
- * sanity check; the real discriminator is minConcentration. */
55
- minDirectionality?: number;
56
- /** Vertices outside the dominant lobe, by this cosine, are not part of the
57
- * feature being fitted. */
58
- lobeCos?: number;
59
- /**
60
- * How much deeper the fitted lobe must be than protrusion typically is on
61
- * this body, averaged over the vertices that protrude at all.
62
- *
63
- * This is the guard that separates "the proxy is missing a lobe" from "the
64
- * proxy is not a proxy for this mesh at all". A pelvis escapes its capsule by
65
- * 0.53 at the back and 0.14 at the front, so the back lobe stands well clear
66
- * of the average. Hair escapes the skull by a similar depth in every
67
- * direction, so its deepest lobe is no deeper than typical and the ratio sits
68
- * near 1. See the note at the meanProtrusion computation for what this
69
- * deliberately refuses to fit.
70
- *
71
- * Without it the pass fits the hairstyle — measured on 托特, 頭 reports
72
- * 3653 of 4669 vertices outside its capsule, and the fitted shape was a crate
73
- * around the whole head. No threshold on depth or vertex count tells those
74
- * two cases apart; concentration does.
75
- */
76
- minConcentration?: number;
77
- /**
78
- * How many capsules may be fitted to one body, each against what the previous
79
- * ones already cover.
80
- *
81
- * One capsule inscribed in a lobe does not fill it — on 托特's butt a single
82
- * fit removed 58% of the clipping and left the rest at the edges the capsule
83
- * could not reach. Each further pass re-measures protrusion against the
84
- * original shape UNION everything fitted so far, so it lands on whatever is
85
- * still exposed instead of re-fitting the same bulge.
86
- */
87
- maxShapesPerBody?: number;
88
- /**
89
- * Quantile of the lobe's perpendicular spread used as the capsule radius.
90
- *
91
- * The clip-versus-float dial, and the one to reach for if a result looks
92
- * wrong. Lower hugs the body: less standoff in idle, more clipping left. 1.0
93
- * encloses the lobe entirely, which is what produced a visibly hovering
94
- * skirt on 托特.
95
- */
96
- radiusQuantile?: number;
97
- /**
98
- * Fit only the deepest part of each lobe: points at least this fraction of
99
- * the lobe's own maximum protrusion.
100
- *
101
- * A lobe tapers to nothing at its edges, and a capsule sized to span the
102
- * whole thing has to be fat enough to reach the edges too. Fitting the deep
103
- * core keeps each capsule small and lets a later pass handle the shallows
104
- * with its own, which is both tighter and closer to what the surface is
105
- * actually doing.
106
- */
107
- lobeDepthFraction?: number;
108
- }
109
- /** What the pass decided for one source body — surfaced so a rig can be
110
- * inspected rather than silently rebuilt underneath its author. */
111
- export interface AutoFitResult {
112
- /** Index of the body in the input array that this supplements. */
113
- sourceIndex: number;
114
- sourceName: string;
115
- /** Vertices dominated by that body's bone, and how many were outside it. */
116
- vertexCount: number;
117
- protrudingCount: number;
118
- /** Furthest any kept vertex sat outside the source shape. */
119
- maxProtrusion: number;
120
- /** How far the fitted capsule reaches past what was already covered. */
121
- gain: number;
122
- /** Length of the kept lobe's mean outward direction, 0–1. */
123
- directionality: number;
124
- /** Lobe depth over the body's average protrusion. See minConcentration. */
125
- concentration: number;
126
- /**
127
- * Furthest the capsule's newly exposed surface sits from the skin it was
128
- * fitted to — the amount cloth resting on it will stand off the body at the
129
- * worst point, and the number to watch if a result looks puffy. Only the part
130
- * reaching outside the source shape is measured; the rest is buried.
131
- */
132
- overshoot: number;
133
- body: Rigidbody;
134
- }
135
- /**
136
- * Fit supplementary colliders for every bone-following body whose own mesh
137
- * escapes it.
138
- *
139
- * `vertices` is the model's interleaved vertex buffer (stride 8, position
140
- * first) and `skinning` its joints/weights — both in PMX bind pose, the same
141
- * space as `shapePosition` / `shapeRotation`, so nothing has to be skinned.
142
- *
143
- * Returns one entry per body it chose to supplement; the caller appends
144
- * `.body` to the rigid body list before constructing RezePhysics.
145
- */
146
- export declare function fitSupplementaryColliders(rigidbodies: Rigidbody[], vertices: Float32Array, skinning: Skinning, options?: AutoFitOptions): AutoFitResult[];
147
- //# sourceMappingURL=autofit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"autofit.d.ts","sourceRoot":"","sources":["../../src/physics/autofit.ts"],"names":[],"mappings":"AACA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAA;AACvE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,WAAW,cAAc;IAC7B;6EACyE;IACzE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,2EAA2E;IAC3E,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;uEACmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;oEACgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B;gCAC4B;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;;;;;;;;;;OAgBG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;;;;OASG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;CAC3B;AA2BD;oEACoE;AACpE,MAAM,WAAW,aAAa;IAC5B,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE,MAAM,CAAA;IAClB,4EAA4E;IAC5E,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,6DAA6D;IAC7D,aAAa,EAAE,MAAM,CAAA;IACrB,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,cAAc,EAAE,MAAM,CAAA;IACtB,2EAA2E;IAC3E,aAAa,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,SAAS,CAAA;CAChB;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CACvC,WAAW,EAAE,SAAS,EAAE,EACxB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,QAAQ,EAClB,OAAO,GAAE,cAAmB,GAC3B,aAAa,EAAE,CA4CjB"}