reze-engine 0.68.31 → 0.68.32

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.
@@ -1 +1 @@
1
- {"version":3,"file":"jelly-eyes.d.ts","sourceRoot":"","sources":["../src/jelly-eyes.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,MAAM,WAAW,eAAe;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;8EAC0E;IAC1E,IAAI,CAAC,EAAE,OAAO,CAAA;IACd;gEAC4D;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AA4ND,qBAAa,SAAS;IACpB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;IAEf,OAAO,CAAC,KAAK,CAAI;IACjB,OAAO,CAAC,IAAI,CAAI;IAChB,OAAO,CAAC,OAAO,CAAa;IAE5B,OAAO,CAAC,QAAQ,CAAI;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiD;IACvE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAgC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkB;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,KAAK,CAAO;IAKpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2E;IAEnG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;IAE7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsE;IAC5F,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;gBAEpC,KAAK,EAAE,KA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O;IAKpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8B;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsD;IAC7E,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA2E;IAEnG,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,CAAA;IAE7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsE;IAC5F,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA2B;gBAEpC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,eAAe;IAoClD,wDAAwD;IACxD,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAoFpC,mEAAmE;IACnE,KAAK,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI;IAgD5B;6CACyC;IACzC,OAAO,CAAC,MAAM;IAad;iDAC6C;IAC7C,OAAO,CAAC,WAAW;CAkCpB;AAQD,sEAAsE;AACtE,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,GAAG,IAAI,CAEpD;AAiHD,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE3D"}
@@ -95,6 +95,15 @@ const ROLL_ZETA = Math.LN2 / HALF_LIFE / (2 * Math.PI * ROLL_HZ);
95
95
  // How much of the spring's swing about the expression angle shows: a
96
96
  // twenty-fifth of an iris radius past centre after a blink.
97
97
  const ROLL_SWING = 0.25;
98
+ // How long a held expression takes to stop pressing and rolling the iris, in
99
+ // seconds: the press and the roll answer the CHANGE of the lids, as the MME's
100
+ // spring does, never where they sit. A smile or a はぅ held through a chorus
101
+ // once kept the iris a fifth shorter and rolled down for as long as it held —
102
+ // on a squint that leaves the eyes open, the irises sank to the bottom of the
103
+ // eyes — and leftover weights of a few hundredths, summed, kept a neutral face
104
+ // pressed for good. A blink's own close is far quicker than this, so it still
105
+ // presses and rolls in full.
106
+ const HOLD_S = 0.3;
98
107
  const PUSH_ELASTIC = 0.04;
99
108
  // A highlight sheet by name, for rigs that keep it on its own material.
100
109
  const HIGHLIGHT = /ハイライト|ハイライト|高光|highlight|hilight|(^|[^a-z])hl([^a-z]|$)/i;
@@ -164,6 +173,8 @@ const SUBSTEP = 1 / 240;
164
173
  const SEEK = 0.25;
165
174
  const newState = () => ({
166
175
  closure: 0,
176
+ closureHeld: 0,
177
+ rollHeld: 0,
167
178
  prev: 0,
168
179
  speed: 0,
169
180
  trend: 0,
@@ -285,11 +296,18 @@ export class JellyEyes {
285
296
  s.lag[1] = s.look[1];
286
297
  s.lagV[0] = s.lagV[1] = 0;
287
298
  s.pulse = s.pulseV = 0;
288
- s.roll = this.roll[e];
299
+ s.closureHeld = s.closure;
300
+ s.rollHeld = this.roll[e];
301
+ s.roll = 0;
289
302
  s.rollV = 0;
290
303
  continue;
291
304
  }
292
305
  blink(s, dt);
306
+ if (dt > 0) {
307
+ const k = 1 - Math.exp(-dt / HOLD_S);
308
+ s.closureHeld += (s.closure - s.closureHeld) * k;
309
+ s.rollHeld += (this.roll[e] - s.rollHeld) * k;
310
+ }
293
311
  const steps = Math.ceil(dt / SUBSTEP);
294
312
  const h = steps > 0 ? dt / steps : 0;
295
313
  const pulseTarget = PULSE_MAX * knock;
@@ -298,7 +316,7 @@ export class JellyEyes {
298
316
  s.pulse += h * s.pulseV;
299
317
  s.squashV += h * spring(s.squash - squashTarget, s.squashV, SQUASH_HZ, SQUASH_ZETA);
300
318
  s.squash += h * s.squashV;
301
- s.rollV += h * spring(s.roll - this.roll[e], s.rollV, ROLL_HZ, ROLL_ZETA);
319
+ s.rollV += h * spring(s.roll - pressedRoll(this.roll[e], s.rollHeld), s.rollV, ROLL_HZ, ROLL_ZETA);
302
320
  s.roll += h * s.rollV;
303
321
  for (let k = 0; k < 2; k++) {
304
322
  s.lagV[k] += h * spring(s.lag[k] - s.look[k], s.lagV[k], LAG_HZ, LAG_ZETA);
@@ -331,7 +349,7 @@ export class JellyEyes {
331
349
  const vn = s.v / omega;
332
350
  const gain = (k) => SCALE_GAIN[k] * (x >= 0 ? 1 : REBOUND[k]);
333
351
  const kx = (1 + x * gain(0)) * (1 - 0.8 * s.squash + pulse);
334
- const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * s.closure) * (1 - s.squash + pulse);
352
+ const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * Math.max(0, s.closure - s.closureHeld)) * (1 - s.squash + pulse);
335
353
  o.set([rest.radius[0], rest.radius[1], s.closure, this.eyeBones[e]], 56 + e * 4);
336
354
  // [4]/[5]: scale across and down, the iris's twist, the highlight's turn.
337
355
  o.set([by(kx, 0.78, 1.25), by(ky, 0.7, 1.08), (x * TWIST_POS + vn * TWIST_VEL) * DEG * g, vn * HL_TURN * DEG * g], 64 + e * 4);
@@ -348,7 +366,7 @@ export class JellyEyes {
348
366
  // [8]/[9]: the roll's pivot and angle; [10]/[11]: the highlight's own
349
367
  // scale, and how far the iris comes forward (bind units).
350
368
  const pivot = rest.pivot;
351
- o.set(pivot ? [pivot[0], pivot[1], pivot[2], (this.roll[e] + (s.roll - this.roll[e]) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4);
369
+ o.set(pivot ? [pivot[0], pivot[1], pivot[2], (pressedRoll(this.roll[e], s.rollHeld) + (s.roll - pressedRoll(this.roll[e], s.rollHeld)) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4);
352
370
  const hs = (k) => Math.max(HL_SCALE_MIN, Math.min(HL_SCALE_MAX, 1 + x * HL_SCALE[k] * g));
353
371
  o.set([hs(0), hs(1), Math.min(Math.abs(x), SPRING_LIMIT) * PUSH_ELASTIC * r * g, 0], 88 + e * 4);
354
372
  }
@@ -404,6 +422,11 @@ export class JellyEyes {
404
422
  m.offset[1] = cap((dot(u, up) / Math.hypot(...up) / size) * INERTIA_GAIN);
405
423
  }
406
424
  }
425
+ /** The part of an expression's roll past where it has been held: the full
426
+ * angle while it arrives, nothing once it stays, nothing as it leaves. */
427
+ function pressedRoll(angle, held) {
428
+ return Math.sign(angle) * Math.max(0, Math.abs(angle) - Math.abs(held));
429
+ }
407
430
  /** Zero jelly[0..11] — strength 0 is what the shader reads as off. */
408
431
  export function clearJellyEyes(o) {
409
432
  o.fill(0, 48, 96);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reze-engine",
3
- "version": "0.68.31",
3
+ "version": "0.68.32",
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",
package/src/jelly-eyes.ts CHANGED
@@ -110,6 +110,15 @@ const ROLL_ZETA = Math.LN2 / HALF_LIFE / (2 * Math.PI * ROLL_HZ)
110
110
  // How much of the spring's swing about the expression angle shows: a
111
111
  // twenty-fifth of an iris radius past centre after a blink.
112
112
  const ROLL_SWING = 0.25
113
+ // How long a held expression takes to stop pressing and rolling the iris, in
114
+ // seconds: the press and the roll answer the CHANGE of the lids, as the MME's
115
+ // spring does, never where they sit. A smile or a はぅ held through a chorus
116
+ // once kept the iris a fifth shorter and rolled down for as long as it held —
117
+ // on a squint that leaves the eyes open, the irises sank to the bottom of the
118
+ // eyes — and leftover weights of a few hundredths, summed, kept a neutral face
119
+ // pressed for good. A blink's own close is far quicker than this, so it still
120
+ // presses and rolls in full.
121
+ const HOLD_S = 0.3
113
122
  const PUSH_ELASTIC = 0.04
114
123
  // A highlight sheet by name, for rigs that keep it on its own material.
115
124
  const HIGHLIGHT = /ハイライト|ハイライト|高光|highlight|hilight|(^|[^a-z])hl([^a-z]|$)/i
@@ -199,6 +208,10 @@ interface EyeState {
199
208
  // The roll (degrees) and its velocity, chasing the expressions' angle.
200
209
  roll: number
201
210
  rollV: number
211
+ // Where the lids and the expressions' angle have been HELD: followers HOLD_S
212
+ // behind them. The press and the roll are what is left past them.
213
+ closureHeld: number
214
+ rollHeld: number
202
215
  pulseV: number
203
216
  }
204
217
 
@@ -237,6 +250,8 @@ interface MorphShift {
237
250
 
238
251
  const newState = (): EyeState => ({
239
252
  closure: 0,
253
+ closureHeld: 0,
254
+ rollHeld: 0,
240
255
  prev: 0,
241
256
  speed: 0,
242
257
  trend: 0,
@@ -373,11 +388,18 @@ export class JellyEyes {
373
388
  s.lag[1] = s.look[1]
374
389
  s.lagV[0] = s.lagV[1] = 0
375
390
  s.pulse = s.pulseV = 0
376
- s.roll = this.roll[e]
391
+ s.closureHeld = s.closure
392
+ s.rollHeld = this.roll[e]
393
+ s.roll = 0
377
394
  s.rollV = 0
378
395
  continue
379
396
  }
380
397
  blink(s, dt)
398
+ if (dt > 0) {
399
+ const k = 1 - Math.exp(-dt / HOLD_S)
400
+ s.closureHeld += (s.closure - s.closureHeld) * k
401
+ s.rollHeld += (this.roll[e] - s.rollHeld) * k
402
+ }
381
403
  const steps = Math.ceil(dt / SUBSTEP)
382
404
  const h = steps > 0 ? dt / steps : 0
383
405
  const pulseTarget = PULSE_MAX * knock
@@ -386,7 +408,7 @@ export class JellyEyes {
386
408
  s.pulse += h * s.pulseV
387
409
  s.squashV += h * spring(s.squash - squashTarget, s.squashV, SQUASH_HZ, SQUASH_ZETA)
388
410
  s.squash += h * s.squashV
389
- s.rollV += h * spring(s.roll - this.roll[e], s.rollV, ROLL_HZ, ROLL_ZETA)
411
+ s.rollV += h * spring(s.roll - pressedRoll(this.roll[e], s.rollHeld), s.rollV, ROLL_HZ, ROLL_ZETA)
390
412
  s.roll += h * s.rollV
391
413
  for (let k = 0; k < 2; k++) {
392
414
  s.lagV[k] += h * spring(s.lag[k] - s.look[k], s.lagV[k], LAG_HZ, LAG_ZETA)
@@ -420,7 +442,7 @@ export class JellyEyes {
420
442
  const vn = s.v / omega
421
443
  const gain = (k: 0 | 1) => SCALE_GAIN[k] * (x >= 0 ? 1 : REBOUND[k])
422
444
  const kx = (1 + x * gain(0)) * (1 - 0.8 * s.squash + pulse)
423
- const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * s.closure) * (1 - s.squash + pulse)
445
+ const ky = (1 + x * gain(1)) * (1 - SQUEEZE_Y * Math.max(0, s.closure - s.closureHeld)) * (1 - s.squash + pulse)
424
446
  o.set([rest.radius[0], rest.radius[1], s.closure, this.eyeBones[e]], 56 + e * 4)
425
447
  // [4]/[5]: scale across and down, the iris's twist, the highlight's turn.
426
448
  o.set([by(kx, 0.78, 1.25), by(ky, 0.7, 1.08), (x * TWIST_POS + vn * TWIST_VEL) * DEG * g, vn * HL_TURN * DEG * g], 64 + e * 4)
@@ -440,7 +462,7 @@ export class JellyEyes {
440
462
  // [8]/[9]: the roll's pivot and angle; [10]/[11]: the highlight's own
441
463
  // scale, and how far the iris comes forward (bind units).
442
464
  const pivot = rest.pivot
443
- o.set(pivot ? [pivot[0], pivot[1], pivot[2], (this.roll[e] + (s.roll - this.roll[e]) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4)
465
+ o.set(pivot ? [pivot[0], pivot[1], pivot[2], (pressedRoll(this.roll[e], s.rollHeld) + (s.roll - pressedRoll(this.roll[e], s.rollHeld)) * ROLL_SWING) * DEG * g] : [0, 0, 0, 0], 80 + e * 4)
444
466
  const hs = (k: 0 | 1) => Math.max(HL_SCALE_MIN, Math.min(HL_SCALE_MAX, 1 + x * HL_SCALE[k] * g))
445
467
  o.set([hs(0), hs(1), Math.min(Math.abs(x), SPRING_LIMIT) * PUSH_ELASTIC * r * g, 0], 88 + e * 4)
446
468
  }
@@ -499,6 +521,12 @@ export class JellyEyes {
499
521
  }
500
522
  }
501
523
 
524
+ /** The part of an expression's roll past where it has been held: the full
525
+ * angle while it arrives, nothing once it stays, nothing as it leaves. */
526
+ function pressedRoll(angle: number, held: number): number {
527
+ return Math.sign(angle) * Math.max(0, Math.abs(angle) - Math.abs(held))
528
+ }
529
+
502
530
  /** Zero jelly[0..11] — strength 0 is what the shader reads as off. */
503
531
  export function clearJellyEyes(o: Float32Array): void {
504
532
  o.fill(0, 48, 96)