wireface 1.0.1 → 1.1.0

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.
@@ -271,89 +271,99 @@
271
271
  </div>
272
272
  </div>
273
273
 
274
+ <!-- ─── MESH ─────────────────────────────────────────────── -->
274
275
  <div class="panel">
275
- <h3>render <span class="num">mesh</span></h3>
276
-
276
+ <h3>mesh <span class="num">geo</span></h3>
277
277
  <div class="ctl"><div class="ctl-name">cols</div><div class="ctl-bar" data-rcfg="meshCols" data-min="5" data-max="21" data-step="2"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="meshCols">7</div></div>
278
278
  <div class="ctl"><div class="ctl-name">rows</div><div class="ctl-bar" data-rcfg="meshRows" data-min="7" data-max="25" data-step="2"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="meshRows">9</div></div>
279
- <div class="ctl"><div class="ctl-name">nose</div><div class="ctl-bar" data-rcfg="scaleNose" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleNose">1.00</div></div>
280
- <div class="ctl"><div class="ctl-name">eyes</div><div class="ctl-bar" data-rcfg="scaleEyes" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleEyes">1.00</div></div>
281
- <div class="ctl"><div class="ctl-name">mouth</div><div class="ctl-bar" data-rcfg="scaleMouth" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleMouth">1.00</div></div>
282
279
  <div class="ctl"><div class="ctl-name">react</div><div class="ctl-bar" data-rcfg="reactivity" data-min="0" data-max="0.6" data-step="0.02"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="reactivity">0.25</div></div>
283
280
  <div class="ctl"><div class="ctl-name">spread</div><div class="ctl-bar" data-rcfg="spread" data-min="0.5" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="spread">1.00</div></div>
284
- <div class="ctl"><div class="ctl-name">mouth ⊘</div><div class="ctl-bar" data-rcfg="mouthHoleSize" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="mouthHoleSize">1.00</div></div>
285
- <div class="ctl"><div class="ctl-name">eye depth</div><div class="ctl-bar" data-rcfg="eyeDepth" data-min="0" data-max="5" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="eyeDepth">1.00</div></div>
286
- <div class="ctl"><div class="ctl-name">line ━</div><div class="ctl-bar" data-rcfg="lineThickness" data-min="0.4" data-max="3.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="lineThickness">1.00</div></div>
281
+ <div class="ctl"><div class="ctl-name">scale nose</div><div class="ctl-bar" data-rcfg="scaleNose" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleNose">1.00</div></div>
282
+ <div class="ctl"><div class="ctl-name">scale eyes</div><div class="ctl-bar" data-rcfg="scaleEyes" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleEyes">1.00</div></div>
283
+ <div class="ctl"><div class="ctl-name">scale mouth</div><div class="ctl-bar" data-rcfg="scaleMouth" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="scaleMouth">1.00</div></div>
284
+ <div class="toggle-row"><span>show mesh</span><div class="toggle on" data-toggle="meshVisible"></div></div>
285
+ <div class="toggle-row"><span>fragment (oval clip)</span><div class="toggle" data-toggle="fragment"></div></div>
286
+ </div>
287
+
288
+ <!-- ─── MOUTH ────────────────────────────────────────────── -->
289
+ <div class="panel">
290
+ <h3>mouth <span class="num">shape</span></h3>
291
+ <div class="ctl"><div class="ctl-name">hole size</div><div class="ctl-bar" data-rcfg="mouthHoleSize" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="mouthHoleSize">1.00</div></div>
287
292
  <div class="ctl"><div class="ctl-name">lip y-amp</div><div class="ctl-bar" data-rcfg="lipVertAmp" data-min="0.5" data-max="4.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="lipVertAmp">1.60</div></div>
288
293
  <div class="ctl"><div class="ctl-name">lip close</div><div class="ctl-bar" data-rcfg="lipPressForce" data-min="0" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="lipPressForce">1.00</div></div>
294
+ <div class="ctl"><div class="ctl-name">mouth grow</div><div class="ctl-bar" data-rcfg="mouthGrow" data-min="0" data-max="1.5" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="mouthGrow">0.00</div></div>
295
+ <div class="toggle-row"><span>mouth hole</span><div class="toggle on" data-toggle="mouthHole"></div></div>
296
+ <div class="toggle-row"><span>mouth anchor</span><div class="toggle on" data-toggle="mouthAnchor"></div></div>
297
+ </div>
289
298
 
299
+ <!-- ─── EYES ─────────────────────────────────────────────── -->
300
+ <div class="panel">
301
+ <h3>eyes <span class="num">shape</span></h3>
302
+ <div class="ctl"><div class="ctl-name">depth</div><div class="ctl-bar" data-rcfg="eyeDepth" data-min="0" data-max="5" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="eyeDepth">1.00</div></div>
303
+ <div class="ctl"><div class="ctl-name">hole size</div><div class="ctl-bar" data-rcfg="eyeHoleSize" data-min="0.4" data-max="2.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="eyeHoleSize">1.00</div></div>
304
+ <div class="toggle-row"><span>eye holes</span><div class="toggle" data-toggle="eyeHoles"></div></div>
305
+ <div class="toggle-row"><span>eye anchor</span><div class="toggle" data-toggle="eyeAnchor"></div></div>
306
+ </div>
307
+
308
+ <!-- ─── JAW DISTORTION ───────────────────────────────────── -->
309
+ <div class="panel">
310
+ <h3>jaw <span class="num">distort</span></h3>
311
+ <div class="ctl"><div class="ctl-name">jaw extend</div><div class="ctl-bar" data-rcfg="jawExtend" data-min="0" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="jawExtend">0.00</div></div>
312
+ <div class="ctl"><div class="ctl-name">upper jaw fwd</div><div class="ctl-bar" data-rcfg="upperJawProtrude" data-min="0" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="upperJawProtrude">0.00</div></div>
313
+ <div class="ctl"><div class="ctl-name">lower jaw fwd</div><div class="ctl-bar" data-rcfg="lowerJawProtrude" data-min="0" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="lowerJawProtrude">0.00</div></div>
314
+ </div>
315
+
316
+ <!-- ─── OVERLAY (minimal-line) ───────────────────────────── -->
317
+ <div class="panel">
318
+ <h3>overlay <span class="num">lines</span></h3>
319
+ <div class="toggle-row"><span>minimal (master)</span><div class="toggle on" data-toggle="minimal"></div></div>
320
+ <div class="toggle-row"><span>overlay → mesh</span><div class="toggle on" data-toggle="overlayTracksMesh"></div></div>
321
+ <div class="ctl"><div class="ctl-name">global ━</div><div class="ctl-bar" data-rcfg="lineThickness" data-min="0.4" data-max="3.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="lineThickness">1.00</div></div>
322
+ <div class="label" style="font-size:9px;letter-spacing:0.18em;text-transform:uppercase;color:var(--dim);margin-top:10px;margin-bottom:4px;">per-feature</div>
323
+ <div class="toggle-row"><span>show mouth</span><div class="toggle on" data-toggle="minimalMouth"></div></div>
324
+ <div class="ctl"><div class="ctl-name">mouth ━</div><div class="ctl-bar" data-rcfg="mouthLineThickness" data-min="0.2" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="mouthLineThickness">1.00</div></div>
325
+ <div class="toggle-row"><span>show eyes</span><div class="toggle on" data-toggle="minimalEyes"></div></div>
326
+ <div class="ctl"><div class="ctl-name">eyes ━</div><div class="ctl-bar" data-rcfg="eyeLineThickness" data-min="0.2" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="eyeLineThickness">1.00</div></div>
327
+ <div class="toggle-row"><span>show nose</span><div class="toggle on" data-toggle="minimalNose"></div></div>
328
+ <div class="ctl"><div class="ctl-name">nose ━</div><div class="ctl-bar" data-rcfg="noseLineThickness" data-min="0.2" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="noseLineThickness">1.00</div></div>
329
+ <div class="toggle-row"><span>show brows</span><div class="toggle on" data-toggle="minimalBrows"></div></div>
330
+ <div class="ctl"><div class="ctl-name">brows ━</div><div class="ctl-bar" data-rcfg="browLineThickness" data-min="0.2" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="browLineThickness">1.00</div></div>
331
+ </div>
332
+
333
+ <!-- ─── STYLE ────────────────────────────────────────────── -->
334
+ <div class="panel">
335
+ <h3>style <span class="num">render</span></h3>
290
336
  <div class="seg-row">
291
337
  <button data-mode="wire" class="on">wire</button>
292
338
  <button data-mode="edges">edges</button>
293
339
  <button data-mode="shaded">shaded</button>
294
340
  </div>
341
+ <div class="toggle-row"><span>glow / highlights</span><div class="toggle" data-toggle="glow"></div></div>
342
+ <div class="toggle-row"><span>pupils</span><div class="toggle" data-toggle="pupils"></div></div>
343
+ <div class="toggle-row"><span>flip face 180°</span><div class="toggle on" data-toggle="flipFace"></div></div>
344
+ </div>
295
345
 
296
- <div class="toggle-row">
297
- <span>mouth puncture</span>
298
- <div class="toggle on" data-toggle="mouthHole"></div>
299
- </div>
300
- <div class="toggle-row">
301
- <span>mouth anchor</span>
302
- <div class="toggle on" data-toggle="mouthAnchor"></div>
303
- </div>
304
- <div class="toggle-row">
305
- <span>eye puncture</span>
306
- <div class="toggle" data-toggle="eyeHoles"></div>
307
- </div>
308
- <div class="toggle-row">
309
- <span>eye anchor</span>
310
- <div class="toggle" data-toggle="eyeAnchor"></div>
311
- </div>
312
- <div class="toggle-row">
313
- <span>overlay → mesh</span>
314
- <div class="toggle on" data-toggle="overlayTracksMesh"></div>
315
- </div>
316
- <div class="toggle-row">
317
- <span>flip face 180°</span>
318
- <div class="toggle on" data-toggle="flipFace"></div>
319
- </div>
320
- <div class="toggle-row">
321
- <span>show mesh</span>
322
- <div class="toggle on" data-toggle="meshVisible"></div>
323
- </div>
324
- <div class="toggle-row">
325
- <span>fragment (oval clip)</span>
326
- <div class="toggle" data-toggle="fragment"></div>
327
- </div>
328
- <div class="toggle-row">
329
- <span>minimal lines</span>
330
- <div class="toggle on" data-toggle="minimal"></div>
331
- </div>
332
- <div class="toggle-row">
333
- <span>glow / highlights</span>
334
- <div class="toggle" data-toggle="glow"></div>
335
- </div>
336
- <div class="toggle-row">
337
- <span>pupils</span>
338
- <div class="toggle" data-toggle="pupils"></div>
339
- </div>
340
-
341
- <div class="label" style="font-size:9px;letter-spacing:0.18em;text-transform:uppercase;color:var(--dim);margin-top:14px;margin-bottom:6px;">moods</div>
342
- <div class="ctl"><div class="ctl-name">mood time</div><div class="ctl-bar" data-rcfg="moodTransitionTime" data-min="0.05" data-max="5.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="moodTransitionTime">0.60</div></div>
343
-
344
- <div class="label" style="font-size:9px;letter-spacing:0.18em;text-transform:uppercase;color:var(--dim);margin-top:14px;margin-bottom:6px;">jaw + growth</div>
345
- <div class="ctl"><div class="ctl-name">jaw extend</div><div class="ctl-bar" data-rcfg="jawExtend" data-min="0" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="jawExtend">0.00</div></div>
346
- <div class="ctl"><div class="ctl-name">mouth grow</div><div class="ctl-bar" data-rcfg="mouthGrow" data-min="0" data-max="1.5" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="mouthGrow">0.00</div></div>
347
-
348
- <div class="label" style="font-size:9px;letter-spacing:0.18em;text-transform:uppercase;color:var(--dim);margin-top:14px;margin-bottom:6px;">colors</div>
346
+ <!-- ─── COLOURS ──────────────────────────────────────────── -->
347
+ <div class="panel">
348
+ <h3>colours <span class="num">style</span></h3>
349
349
  <div class="color-row"><div class="ctl-name">base</div><input type="color" id="color-base" value="#ffffff"><div class="ctl-val" id="color-base-val">FFF</div></div>
350
350
  <div class="color-row"><div class="ctl-name">depth fade</div><input type="color" id="color-fade" value="#000000"><div class="ctl-val" id="color-fade-val">000</div></div>
351
351
  <div class="ctl"><div class="ctl-name">fade ░░</div><div class="ctl-bar" data-rcfg="depthFade" data-min="0" data-max="1" data-step="0.02"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="depthFade">0.00</div></div>
352
- <div class="color-row"><div class="ctl-name">line</div><input type="color" id="color-line" value="#ffffff"><div class="ctl-val" id="color-line-val">FFF</div></div>
353
- <div class="color-row"><div class="ctl-name">brow</div><input type="color" id="color-brow" value="#ffffff"><div class="ctl-val" id="color-brow-val">FFF</div></div>
352
+ <div class="ctl"><div class="ctl-name">fade curve</div><div class="ctl-bar" data-rcfg="depthFadeCurve" data-min="0.3" data-max="3" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="depthFadeCurve">1.00</div></div>
353
+ <div class="color-row"><div class="ctl-name">line (default)</div><input type="color" id="color-line" value="#ffffff"><div class="ctl-val" id="color-line-val">FFF</div></div>
354
+ <div class="color-row"><div class="ctl-name">mouth</div><input type="color" id="color-mouth" value="#ffffff"><div class="ctl-val" id="color-mouth-val">FFF</div></div>
355
+ <div class="color-row"><div class="ctl-name">eyes</div><input type="color" id="color-eye" value="#ffffff"><div class="ctl-val" id="color-eye-val">FFF</div></div>
356
+ <div class="color-row"><div class="ctl-name">nose</div><input type="color" id="color-nose" value="#ffffff"><div class="ctl-val" id="color-nose-val">FFF</div></div>
357
+ <div class="color-row"><div class="ctl-name">brow</div><input type="color" id="color-brow" value="#ffffff"><div class="ctl-val" id="color-brow-val">FFF</div></div>
354
358
  <div class="color-row"><div class="ctl-name">pupil</div><input type="color" id="color-pupil" value="#ffffff"><div class="ctl-val" id="color-pupil-val">FFF</div></div>
355
359
  <div class="color-row"><div class="ctl-name">iris</div><input type="color" id="color-iris" value="#000000"><div class="ctl-val" id="color-iris-val">000</div></div>
356
- <div class="ctl"><div class="ctl-name">iris ⊙</div><div class="ctl-bar" data-rcfg="irisSize" data-min="1" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="irisSize">1.60</div></div>
360
+ <div class="ctl"><div class="ctl-name">iris size</div><div class="ctl-bar" data-rcfg="irisSize" data-min="1" data-max="4" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="irisSize">1.60</div></div>
361
+ </div>
362
+
363
+ <!-- ─── MOOD ─────────────────────────────────────────────── -->
364
+ <div class="panel">
365
+ <h3>mood <span class="num">crossfade</span></h3>
366
+ <div class="ctl"><div class="ctl-name">mood time</div><div class="ctl-bar" data-rcfg="moodTransitionTime" data-min="0.05" data-max="5.0" data-step="0.05"><div class="fill"></div></div><div class="ctl-val" data-rcfg-val="moodTransitionTime">0.60</div></div>
357
367
  </div>
358
368
 
359
369
  <div class="panel">
@@ -627,6 +637,7 @@ const renderConfig = {
627
637
  // v006:
628
638
  mouthHole: true, // cut a real puncture at the mouth (for lip-sync visibility)
629
639
  mouthHoleSize: 1.0, // multiplier on mouth puncture ellipse radii [0.4, 2.0]
640
+ eyeHoleSize: 1.0, // v1.1: multiplier on eye puncture ellipse radii [0.4, 2.0]
630
641
  eyeHoles: false, // cut eye-socket punctures (optional)
631
642
  eyeDepth: 1.0, // multiplier on warpToFace eye recess [0, 2.5]
632
643
  // v007:
@@ -650,6 +661,14 @@ const renderConfig = {
650
661
  browColor: '#ffffff', // brow tube color separate from lineColor
651
662
  jawExtend: 0.0, // z-forward push of lower face when jaw opens [0, 3]
652
663
  mouthGrow: 0.0, // extra scaling of mouth region as it opens [0, 1.5]
664
+ // v1.1 — experimental
665
+ depthFadeCurve: 1.0, // exponent on depth-fade weight [0.3, 3]
666
+ upperJawProtrude: 0.0, // static z push of upper-mouth region [0, 3]
667
+ lowerJawProtrude: 0.0, // static z push of lower jaw / chin [0, 3]
668
+ // per-feature minimal-line overrides (null = inherit lineColor)
669
+ mouthColor: null, eyeColor: null, noseColor: null,
670
+ minimalMouth: true, minimalEyes: true, minimalNose: true, minimalBrows: true,
671
+ mouthLineThickness: 1.0, eyeLineThickness: 1.0, noseLineThickness: 1.0, browLineThickness: 1.0,
653
672
  };
654
673
 
655
674
  /* per-channel gain knobs — multiplier applied to each channel value when
@@ -726,7 +745,8 @@ function warpToFace(u, v) {
726
745
  if (z < -0.05) z = -0.05;
727
746
 
728
747
  // eye sockets recess (small but visible)
729
- const eyeY = 0.30;
748
+ // v1.1: align eye-recess centre with eye-opening / eyelid overlay (v=0.40)
749
+ const eyeY = 0.20;
730
750
  const eyeL_d = ((xRel + 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
731
751
  const eyeR_d = ((xRel - 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
732
752
  const eyeRecess = 0.045 * renderConfig.eyeDepth;
@@ -926,8 +946,11 @@ function rebuildMesh() {
926
946
  const cutMouth = renderConfig.mouthHole;
927
947
 
928
948
  // eye sockets puncture (optional)
929
- const eyeRU = 0.085, eyeRV = 0.045;
930
- const eyeLU = 0.30, eyeLV = 0.40;
949
+ // v1.1: bumped base ellipse to 0.105 × 0.075 + eyeHoleSize multiplier so
950
+ // toggling "eye holes" actually produces a visible cut at typical mesh
951
+ // densities (matches the lib).
952
+ const eyeRU = 0.105 * renderConfig.eyeHoleSize, eyeRV = 0.075 * renderConfig.eyeHoleSize;
953
+ const eyeLU = 0.30, eyeLV = 0.40;
931
954
  const eyeRU2 = 0.70, eyeRV2 = 0.40;
932
955
  const cutEyes = renderConfig.eyeHoles;
933
956
 
@@ -1121,6 +1144,36 @@ function applyMouthGrow(disp) {
1121
1144
  }
1122
1145
  }
1123
1146
 
1147
+ /* v1.1: static jaw-protrude passes — push upper-mouth and lower-jaw regions
1148
+ forward independent of jawOpen. Used together they form the snout / animal
1149
+ / crocodile-mouth distortion. Both default 0 so existing behavior is
1150
+ unchanged. */
1151
+ function applyUpperJawProtrude(disp) {
1152
+ const amt = renderConfig.upperJawProtrude;
1153
+ if (amt < 0.001) return;
1154
+ const push = amt * 0.18;
1155
+ for (let i = 0; i < baseUVs.length; i++) {
1156
+ const v = baseUVs[i].v;
1157
+ if (v < 0.45 || v > 0.72) continue;
1158
+ const w = v < 0.62 ? (v - 0.45) / 0.17 : (0.72 - v) / 0.10;
1159
+ disp[i].z += push * w;
1160
+ }
1161
+ }
1162
+ function applyLowerJawProtrude(disp) {
1163
+ const amt = renderConfig.lowerJawProtrude;
1164
+ if (amt < 0.001) return;
1165
+ const push = amt * 0.18;
1166
+ for (let i = 0; i < baseUVs.length; i++) {
1167
+ const v = baseUVs[i].v;
1168
+ if (v < 0.70) continue;
1169
+ let w;
1170
+ if (v < 0.85) w = (v - 0.70) / 0.15;
1171
+ else w = 1 - (v - 0.85) / 0.30;
1172
+ if (w < 0) w = 0;
1173
+ disp[i].z += push * w;
1174
+ }
1175
+ }
1176
+
1124
1177
  /* apply mouth anchor — drives ring vertices to match the lip-curve formula */
1125
1178
  function applyMouthAnchors(disp) {
1126
1179
  if (!renderConfig.mouthAnchor) return;
@@ -1426,8 +1479,10 @@ function updateFace() {
1426
1479
  computeMorphs(_dispBuf);
1427
1480
  if (renderConfig.reactivity > 0) couple(_dispBuf, renderConfig.reactivity);
1428
1481
  applyFeatureScales(_dispBuf);
1429
- applyJawExtension(_dispBuf); // v011: z-forward push of lower face on jaw open
1430
- applyMouthGrow(_dispBuf); // v011: scale mouth region outward proportional to openness
1482
+ applyJawExtension(_dispBuf); // v011: z-forward push of lower face on jaw open
1483
+ applyMouthGrow(_dispBuf); // v011: scale mouth region outward proportional to openness
1484
+ applyUpperJawProtrude(_dispBuf); // v1.1: static upper-jaw push
1485
+ applyLowerJawProtrude(_dispBuf); // v1.1: static lower-jaw push (crocodile-mouth)
1431
1486
  applyMouthAnchors(_dispBuf);
1432
1487
  applyEyeAnchors(_dispBuf);
1433
1488
 
@@ -1446,11 +1501,13 @@ function updateFace() {
1446
1501
  if (renderConfig.depthFade > 0.001 && _baseRGB && _fadeRGB) {
1447
1502
  const zRange = (_zMax - _zMin) || 1;
1448
1503
  const f = renderConfig.depthFade;
1504
+ const curve = renderConfig.depthFadeCurve > 0 ? renderConfig.depthFadeCurve : 1;
1449
1505
  for (let i = 0; i < baseVertices.length; i++) {
1450
- // currentZ from already-updated _posBuf
1451
1506
  const z = _posBuf[3*i + 2];
1452
- // t: 0 at front (max z), 1 at back (min z)
1453
- const t = Math.max(0, Math.min(1, (_zMax - z) / zRange)) * f;
1507
+ let t = (_zMax - z) / zRange;
1508
+ if (t < 0) t = 0; else if (t > 1) t = 1;
1509
+ if (curve !== 1) t = Math.pow(t, curve);
1510
+ t *= f;
1454
1511
  _colBuf[4*i ] = _baseRGB[0] * (1 - t) + _fadeRGB[0] * t;
1455
1512
  _colBuf[4*i+1] = _baseRGB[1] * (1 - t) + _fadeRGB[1] * t;
1456
1513
  _colBuf[4*i+2] = _baseRGB[2] * (1 - t) + _fadeRGB[2] * t;
@@ -1502,17 +1559,21 @@ rebuildPupils();
1502
1559
  the same channel state as the mesh so deformations stay synchronized.
1503
1560
  Toggleable via renderConfig.minimal. */
1504
1561
 
1505
- const minimalMat = new BABYLON.StandardMaterial('minimalMat', scene);
1506
- minimalMat.emissiveColor = new BABYLON.Color3(1, 1, 1);
1507
- minimalMat.disableLighting = true;
1508
- minimalMat.specularColor = new BABYLON.Color3(0, 0, 0);
1509
-
1510
- /* v011: separate material for brow tubes so they can have a distinct color
1511
- from the rest of the minimal-line overlay. Same render properties otherwise. */
1512
- const browMat = new BABYLON.StandardMaterial('browMat', scene);
1513
- browMat.emissiveColor = new BABYLON.Color3(1, 1, 1);
1514
- browMat.disableLighting = true;
1515
- browMat.specularColor = new BABYLON.Color3(0, 0, 0);
1562
+ /* v1.1: one material per minimal-line feature so each can have its own color.
1563
+ lineColor is the shared fallback; per-feature overrides (mouthColor /
1564
+ eyeColor / noseColor) are null by default = inherit lineColor. */
1565
+ function makeMinimalMat(name) {
1566
+ const m = new BABYLON.StandardMaterial(name, scene);
1567
+ m.emissiveColor = new BABYLON.Color3(1, 1, 1);
1568
+ m.disableLighting = true;
1569
+ m.specularColor = new BABYLON.Color3(0, 0, 0);
1570
+ return m;
1571
+ }
1572
+ const mouthMat = makeMinimalMat('mouthMat');
1573
+ const eyeMat = makeMinimalMat('eyeMat');
1574
+ const noseMat = makeMinimalMat('noseMat');
1575
+ const browMat = makeMinimalMat('browMat');
1576
+ const minimalMat = mouthMat; // legacy alias
1516
1577
 
1517
1578
  const minimalGroup = new BABYLON.TransformNode('minimal', scene);
1518
1579
  minimalGroup.parent = faceRoot;
@@ -1578,13 +1639,17 @@ function smoothPath(controls, samples = 18) {
1578
1639
  return out;
1579
1640
  }
1580
1641
 
1581
- function makeTube(name, points, radius, instance) {
1582
- const r = instance ? radius : radius * renderConfig.lineThickness;
1642
+ function makeTube(name, points, radius, mat, featureMul, instance) {
1643
+ // Final radius = base × featureMul × lineThickness — applied in BOTH new
1644
+ // and instance forms. Babylon's CreateTube instance-form applies
1645
+ // opts.radius every call (does not preserve construction radius), so
1646
+ // updateMinimal MUST pass the current featureMul each frame.
1647
+ const r = radius * (featureMul == null ? 1 : featureMul) * renderConfig.lineThickness;
1583
1648
  const opts = { path: points, radius: r, tessellation: 6, updatable: true };
1584
1649
  if (instance) opts.instance = instance;
1585
1650
  const tube = BABYLON.MeshBuilder.CreateTube(name, opts, scene);
1586
1651
  if (!instance) {
1587
- tube.material = minimalMat;
1652
+ tube.material = mat || mouthMat;
1588
1653
  tube.parent = minimalGroup;
1589
1654
  }
1590
1655
  return tube;
@@ -1695,48 +1760,60 @@ function rebuildMinimalLines() {
1695
1760
  if (noseRightMesh) { noseRightMesh.dispose(); noseRightMesh = null; }
1696
1761
 
1697
1762
  const { upper, lower } = mouthLipPaths();
1698
- mouthUpperMesh = makeTube('mouth_u', upper, 0.010);
1699
- mouthLowerMesh = makeTube('mouth_l', lower, 0.010);
1763
+ mouthUpperMesh = makeTube('mouth_u', upper, 0.010, mouthMat, renderConfig.mouthLineThickness);
1764
+ mouthLowerMesh = makeTube('mouth_l', lower, 0.010, mouthMat, renderConfig.mouthLineThickness);
1700
1765
 
1701
1766
  for (const eye of eyeData) {
1702
- const u = makeTube('eye_' + eye.side + '_u', eyePath(eye, true), 0.0085);
1703
- const l = makeTube('eye_' + eye.side + '_l', eyePath(eye, false), 0.0085);
1767
+ const u = makeTube('eye_' + eye.side + '_u', eyePath(eye, true), 0.0085, eyeMat, renderConfig.eyeLineThickness);
1768
+ const l = makeTube('eye_' + eye.side + '_l', eyePath(eye, false), 0.0085, eyeMat, renderConfig.eyeLineThickness);
1704
1769
  eyeMeshes.push({ eye, upper: u, lower: l });
1705
1770
  }
1706
1771
 
1707
1772
  for (const brow of browData) {
1708
- const m = makeTube('brow_' + brow.side, browPath(brow), 0.011);
1709
- m.material = browMat; // v011: brow color is separate from line color
1773
+ const m = makeTube('brow_' + brow.side, browPath(brow), 0.011, browMat, renderConfig.browLineThickness);
1710
1774
  browMeshes.push({ brow, mesh: m });
1711
1775
  }
1712
1776
 
1713
1777
  const np = nosePaths();
1714
- noseBridgeMesh = makeTube('nose_b', np.bridge, 0.009);
1715
- noseLeftMesh = makeTube('nose_l', np.leftN, 0.0085);
1716
- noseRightMesh = makeTube('nose_r', np.rightN, 0.0085);
1778
+ noseBridgeMesh = makeTube('nose_b', np.bridge, 0.009, noseMat, renderConfig.noseLineThickness);
1779
+ noseLeftMesh = makeTube('nose_l', np.leftN, 0.0085, noseMat, renderConfig.noseLineThickness);
1780
+ noseRightMesh = makeTube('nose_r', np.rightN, 0.0085, noseMat, renderConfig.noseLineThickness);
1781
+ applyMinimalSubVisibility();
1717
1782
  }
1718
1783
 
1719
1784
  rebuildMinimalLines();
1720
1785
 
1721
1786
  function updateMinimal() {
1722
- // mouth
1787
+ // Babylon's CreateTube instance-form applies opts.radius every call —
1788
+ // it doesn't preserve the radius from construction. So we MUST pass the
1789
+ // current per-feature thickness multiplier on every frame, otherwise the
1790
+ // tube collapses back to (base × 1 × lineThickness) and the per-feature
1791
+ // slider has no visible effect (only one frame after rebuildMinimalLines).
1723
1792
  const mp = mouthLipPaths();
1724
- makeTube('', mp.upper, 0.010, mouthUpperMesh);
1725
- makeTube('', mp.lower, 0.010, mouthLowerMesh);
1726
- // eyes
1793
+ makeTube('', mp.upper, 0.010, null, renderConfig.mouthLineThickness, mouthUpperMesh);
1794
+ makeTube('', mp.lower, 0.010, null, renderConfig.mouthLineThickness, mouthLowerMesh);
1727
1795
  for (const em of eyeMeshes) {
1728
- makeTube('', eyePath(em.eye, true), 0.0085, em.upper);
1729
- makeTube('', eyePath(em.eye, false), 0.0085, em.lower);
1796
+ makeTube('', eyePath(em.eye, true), 0.0085, null, renderConfig.eyeLineThickness, em.upper);
1797
+ makeTube('', eyePath(em.eye, false), 0.0085, null, renderConfig.eyeLineThickness, em.lower);
1730
1798
  }
1731
- // brows
1732
1799
  for (const bm of browMeshes) {
1733
- makeTube('', browPath(bm.brow), 0.011, bm.mesh);
1800
+ makeTube('', browPath(bm.brow), 0.011, null, renderConfig.browLineThickness, bm.mesh);
1734
1801
  }
1735
- // nose
1736
1802
  const np = nosePaths();
1737
- makeTube('', np.bridge, 0.009, noseBridgeMesh);
1738
- makeTube('', np.leftN, 0.0085, noseLeftMesh);
1739
- makeTube('', np.rightN, 0.0085, noseRightMesh);
1803
+ makeTube('', np.bridge, 0.009, null, renderConfig.noseLineThickness, noseBridgeMesh);
1804
+ makeTube('', np.leftN, 0.0085, null, renderConfig.noseLineThickness, noseLeftMesh);
1805
+ makeTube('', np.rightN, 0.0085, null, renderConfig.noseLineThickness, noseRightMesh);
1806
+ }
1807
+
1808
+ function applyMinimalSubVisibility() {
1809
+ const setVis = (m, v) => { if (m) m.isVisible = v; };
1810
+ setVis(mouthUpperMesh, !!renderConfig.minimalMouth);
1811
+ setVis(mouthLowerMesh, !!renderConfig.minimalMouth);
1812
+ for (const em of eyeMeshes) { setVis(em.upper, !!renderConfig.minimalEyes); setVis(em.lower, !!renderConfig.minimalEyes); }
1813
+ for (const bm of browMeshes) setVis(bm.mesh, !!renderConfig.minimalBrows);
1814
+ setVis(noseBridgeMesh, !!renderConfig.minimalNose);
1815
+ setVis(noseLeftMesh, !!renderConfig.minimalNose);
1816
+ setVis(noseRightMesh, !!renderConfig.minimalNose);
1740
1817
  }
1741
1818
 
1742
1819
  function applyMinimalVisibility() {
@@ -2459,9 +2536,10 @@ function setRcfgVal(key, val) {
2459
2536
  const max = parseFloat(def.dataset.max);
2460
2537
  const step = parseFloat(def.dataset.step) || 0.01;
2461
2538
  let v = Math.max(min, Math.min(max, val));
2462
- v = Math.round(v / step) * step;
2463
- // for integer-step (cols/rows), keep odd if step is 2
2464
- if (step === 2) v = Math.round(v); if (v % 2 === 0 && step === 2) v += 1;
2539
+ // snap to step relative to min — fixes odd-only sliders (cols/rows, step=2,
2540
+ // min=5/7) where previously `Math.round(9/2)*2 = 10 → +1 = 11`, shifting
2541
+ // every saved odd value up by 2 on reload.
2542
+ v = min + Math.round((v - min) / step) * step;
2465
2543
  renderConfig[key] = v;
2466
2544
  // update fill bar
2467
2545
  const fill = def.querySelector('.fill');
@@ -2470,8 +2548,10 @@ function setRcfgVal(key, val) {
2470
2548
  const lbl = document.querySelector(`[data-rcfg-val="${key}"]`);
2471
2549
  if (lbl) lbl.textContent = (step >= 1) ? String(Math.round(v)) : v.toFixed(2);
2472
2550
  // side-effects
2473
- if (key === 'meshCols' || key === 'meshRows' || key === 'eyeDepth' || key === 'mouthHoleSize') rebuildMesh();
2474
- if (key === 'lineThickness') {
2551
+ if (key === 'meshCols' || key === 'meshRows' || key === 'eyeDepth' ||
2552
+ key === 'mouthHoleSize' || key === 'eyeHoleSize') rebuildMesh();
2553
+ if (key === 'lineThickness' || key === 'mouthLineThickness' || key === 'eyeLineThickness' ||
2554
+ key === 'noseLineThickness' || key === 'browLineThickness') {
2475
2555
  rebuildMinimalLines();
2476
2556
  // edges renderer width is mutable; just nudge it without dispose/recreate
2477
2557
  if (mesh && mesh._edgesRenderer) mesh.edgesWidth = 4 * renderConfig.lineThickness;
@@ -2492,15 +2572,35 @@ function setRcfgVal(key, val) {
2492
2572
  }
2493
2573
  }
2494
2574
 
2495
- /* color pickers — line + pupil + v011: base / fade / iris / brow */
2575
+ /* color pickers — line + pupil + v011: base / fade / iris / brow + v1.1: per-feature */
2496
2576
  function applyLineColor(hex) {
2497
2577
  renderConfig.lineColor = hex;
2498
- if (typeof minimalMat !== 'undefined' && minimalMat) {
2499
- minimalMat.emissiveColor = BABYLON.Color3.FromHexString(hex);
2500
- }
2578
+ const c = BABYLON.Color3.FromHexString(hex);
2579
+ // mouth/eye/nose mats inherit lineColor unless their per-feature override is non-null
2580
+ if (!renderConfig.mouthColor && mouthMat) mouthMat.emissiveColor = c;
2581
+ if (!renderConfig.eyeColor && eyeMat) eyeMat.emissiveColor = c;
2582
+ if (!renderConfig.noseColor && noseMat) noseMat.emissiveColor = c;
2501
2583
  const lbl = document.getElementById('color-line-val');
2502
2584
  if (lbl) lbl.textContent = hex.replace('#', '').toUpperCase().slice(0, 3);
2503
2585
  }
2586
+ function applyMouthColor(hex) {
2587
+ renderConfig.mouthColor = hex || null;
2588
+ if (mouthMat) mouthMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
2589
+ const lbl = document.getElementById('color-mouth-val');
2590
+ if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
2591
+ }
2592
+ function applyEyeColor(hex) {
2593
+ renderConfig.eyeColor = hex || null;
2594
+ if (eyeMat) eyeMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
2595
+ const lbl = document.getElementById('color-eye-val');
2596
+ if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
2597
+ }
2598
+ function applyNoseColor(hex) {
2599
+ renderConfig.noseColor = hex || null;
2600
+ if (noseMat) noseMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
2601
+ const lbl = document.getElementById('color-nose-val');
2602
+ if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
2603
+ }
2504
2604
  function applyPupilColor(hex) {
2505
2605
  renderConfig.pupilColor = hex;
2506
2606
  if (typeof pupilMat !== 'undefined' && pupilMat) {
@@ -2552,11 +2652,19 @@ function applyBrowColor(hex) {
2552
2652
  ['color-fade', 'fadeColor', applyFadeColor],
2553
2653
  ['color-iris', 'irisColor', applyIrisColor],
2554
2654
  ['color-brow', 'browColor', applyBrowColor],
2655
+ // v1.1: per-feature minimal-line colors. Default value seeded from
2656
+ // lineColor so the picker shows the inherited color, but user clicking
2657
+ // the picker sets the per-feature override.
2658
+ ['color-mouth', 'mouthColor', applyMouthColor],
2659
+ ['color-eye', 'eyeColor', applyEyeColor],
2660
+ ['color-nose', 'noseColor', applyNoseColor],
2555
2661
  ];
2556
2662
  for (const [id, key, fn] of wires) {
2557
2663
  const el = document.getElementById(id);
2558
2664
  if (!el) continue;
2559
- el.value = renderConfig[key];
2665
+ // for null per-feature colors, seed picker from lineColor so the swatch
2666
+ // reflects the inherited render color
2667
+ el.value = renderConfig[key] || renderConfig.lineColor || '#ffffff';
2560
2668
  el.addEventListener('input', () => fn(el.value));
2561
2669
  fn(el.value);
2562
2670
  }
@@ -2606,6 +2714,10 @@ document.querySelectorAll('[data-toggle]').forEach(t => {
2606
2714
  case 'flipFace': applyFaceFlip(); break;
2607
2715
  case 'meshVisible': applyMeshVisibility(); break;
2608
2716
  case 'minimal': applyMinimalVisibility(); break;
2717
+ case 'minimalMouth':
2718
+ case 'minimalEyes':
2719
+ case 'minimalNose':
2720
+ case 'minimalBrows': applyMinimalSubVisibility(); break;
2609
2721
  case 'mouthAnchor': /* takes effect next frame */ break;
2610
2722
  case 'eyeAnchor': /* takes effect next frame */ break;
2611
2723
  case 'overlayTracksMesh': /* takes effect next frame */ break;
@@ -2689,6 +2801,12 @@ function applyPreset(p) {
2689
2801
  document.querySelectorAll('[data-mode]').forEach(b => b.classList.toggle('on', b.dataset.mode === renderConfig.mode));
2690
2802
  applyRenderMode();
2691
2803
  applyMeshVisibility(); applyMinimalVisibility();
2804
+ // v1.0.x: applyPreset previously updated renderConfig.glow + the toggle's
2805
+ // visual state, but never re-applied glow.intensity — so the GlowLayer
2806
+ // would stay at whatever intensity the user had set last via the toggle
2807
+ // button, regardless of the preset's glow value. Sync it here.
2808
+ if (typeof glow !== 'undefined' && glow) glow.intensity = renderConfig.glow ? 0.85 : 0;
2809
+ if (typeof rebuildPupils === 'function') rebuildPupils(); // pickup pupils:false from preset
2692
2810
  // colors
2693
2811
  if (p.lineColor) {
2694
2812
  const lc = document.getElementById('color-line'); if (lc) lc.value = p.lineColor;
@@ -2715,6 +2833,44 @@ function applyPreset(p) {
2715
2833
  const el = document.getElementById('color-brow'); if (el) el.value = p.renderConfig.browColor;
2716
2834
  applyBrowColor(p.renderConfig.browColor);
2717
2835
  }
2836
+ // v1.1: per-feature minimal-line colors (null = inherit lineColor; non-null overrides)
2837
+ if (p.renderConfig) {
2838
+ const perFeat = [
2839
+ ['mouthColor', 'color-mouth', applyMouthColor],
2840
+ ['eyeColor', 'color-eye', applyEyeColor],
2841
+ ['noseColor', 'color-nose', applyNoseColor],
2842
+ ];
2843
+ for (const [k, id, fn] of perFeat) {
2844
+ if (k in p.renderConfig) {
2845
+ const el = document.getElementById(id);
2846
+ const swatch = p.renderConfig[k] || p.renderConfig.lineColor || '#ffffff';
2847
+ if (el) el.value = swatch;
2848
+ fn(p.renderConfig[k]); // null falls back to lineColor inside the setter
2849
+ }
2850
+ }
2851
+ }
2852
+ // v1.1: per-feature visibility + thickness — sliders pick up via setRcfgVal
2853
+ // when iterating renderConfig keys above (numeric path). Toggles update via
2854
+ // the data-toggle initialization. Now refresh visibility + rebuild tubes
2855
+ // so the new state actually takes effect.
2856
+ applyMinimalSubVisibility();
2857
+ if (p.renderConfig && (
2858
+ 'mouthLineThickness' in p.renderConfig || 'eyeLineThickness' in p.renderConfig ||
2859
+ 'noseLineThickness' in p.renderConfig || 'browLineThickness' in p.renderConfig)) {
2860
+ rebuildMinimalLines();
2861
+ }
2862
+ // v1.1 fix: boolean fields (fragment / mouthHole / eyeHoles / pupils) are
2863
+ // assigned via direct property write inside the iteration loop, which does
2864
+ // NOT trigger the corresponding rebuild. The mesh therefore reflects the
2865
+ // PREVIOUS state of those flags. Force a full geometric rebuild now to
2866
+ // sync everything with the loaded config. Cheap (single-shot) and ensures
2867
+ // a preset roundtrip is faithful.
2868
+ if (p.renderConfig) {
2869
+ if (typeof rebuildMesh === 'function') rebuildMesh();
2870
+ if (typeof rebuildPupils === 'function') rebuildPupils();
2871
+ if (typeof rebuildMinimalLines === 'function') rebuildMinimalLines();
2872
+ if (typeof applyMinimalSubVisibility === 'function') applyMinimalSubVisibility();
2873
+ }
2718
2874
  // channel gains (knobs)
2719
2875
  if (p.channelGainSliders) {
2720
2876
  for (const ch of CHANNEL_NAMES) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wireface",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Minimal embeddable wireframe lipsync face renderer — drives expressive character profiles from voice or TTS audio in the browser.",
5
5
  "main": "wireface.js",
6
6
  "browser": "wireface.js",