wireface 1.0.2 → 1.1.1
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/README.md +56 -1
- package/dist/wireface.js +190 -41
- package/dist/wireface.min.js +1 -1
- package/examples/editor.html +280 -117
- package/examples/playground.html +147 -0
- package/package.json +1 -1
- package/wireface.js +190 -41
package/examples/editor.html
CHANGED
|
@@ -271,89 +271,99 @@
|
|
|
271
271
|
</div>
|
|
272
272
|
</div>
|
|
273
273
|
|
|
274
|
+
<!-- ─── MESH ─────────────────────────────────────────────── -->
|
|
274
275
|
<div class="panel">
|
|
275
|
-
<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">
|
|
285
|
-
<div class="ctl"><div class="ctl-name">
|
|
286
|
-
<div class="ctl"><div class="ctl-name">
|
|
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
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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="
|
|
353
|
-
<div class="color-row"><div class="ctl-name">
|
|
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
|
|
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">
|
|
@@ -563,6 +573,13 @@ function computeMouthParams() {
|
|
|
563
573
|
const canvas = document.getElementById('renderCanvas');
|
|
564
574
|
const engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true, antialias: true });
|
|
565
575
|
const scene = new BABYLON.Scene(engine);
|
|
576
|
+
// v1.1.1: use right-handed coordinate system so the face's +Z forward (built
|
|
577
|
+
// by warpToFace) naturally points at the default ArcRotateCamera. Removes
|
|
578
|
+
// the need for a 180° Y-flip at the faceRoot to make front view correct, and
|
|
579
|
+
// fixes the "profile shows back of head" bug — view alphas now map to the
|
|
580
|
+
// natural side of the face, as the user requested ("find a way to ... relax
|
|
581
|
+
// those on init so we can use view as designed").
|
|
582
|
+
scene.useRightHandedSystem = true;
|
|
566
583
|
scene.clearColor = new BABYLON.Color4(0, 0, 0, 1);
|
|
567
584
|
|
|
568
585
|
/* camera — orbit around the face */
|
|
@@ -627,6 +644,7 @@ const renderConfig = {
|
|
|
627
644
|
// v006:
|
|
628
645
|
mouthHole: true, // cut a real puncture at the mouth (for lip-sync visibility)
|
|
629
646
|
mouthHoleSize: 1.0, // multiplier on mouth puncture ellipse radii [0.4, 2.0]
|
|
647
|
+
eyeHoleSize: 1.0, // v1.1: multiplier on eye puncture ellipse radii [0.4, 2.0]
|
|
630
648
|
eyeHoles: false, // cut eye-socket punctures (optional)
|
|
631
649
|
eyeDepth: 1.0, // multiplier on warpToFace eye recess [0, 2.5]
|
|
632
650
|
// v007:
|
|
@@ -650,6 +668,14 @@ const renderConfig = {
|
|
|
650
668
|
browColor: '#ffffff', // brow tube color separate from lineColor
|
|
651
669
|
jawExtend: 0.0, // z-forward push of lower face when jaw opens [0, 3]
|
|
652
670
|
mouthGrow: 0.0, // extra scaling of mouth region as it opens [0, 1.5]
|
|
671
|
+
// v1.1 — experimental
|
|
672
|
+
depthFadeCurve: 1.0, // exponent on depth-fade weight [0.3, 3]
|
|
673
|
+
upperJawProtrude: 0.0, // static z push of upper-mouth region [0, 3]
|
|
674
|
+
lowerJawProtrude: 0.0, // static z push of lower jaw / chin [0, 3]
|
|
675
|
+
// per-feature minimal-line overrides (null = inherit lineColor)
|
|
676
|
+
mouthColor: null, eyeColor: null, noseColor: null,
|
|
677
|
+
minimalMouth: true, minimalEyes: true, minimalNose: true, minimalBrows: true,
|
|
678
|
+
mouthLineThickness: 1.0, eyeLineThickness: 1.0, noseLineThickness: 1.0, browLineThickness: 1.0,
|
|
653
679
|
};
|
|
654
680
|
|
|
655
681
|
/* per-channel gain knobs — multiplier applied to each channel value when
|
|
@@ -726,7 +752,8 @@ function warpToFace(u, v) {
|
|
|
726
752
|
if (z < -0.05) z = -0.05;
|
|
727
753
|
|
|
728
754
|
// eye sockets recess (small but visible)
|
|
729
|
-
|
|
755
|
+
// v1.1: align eye-recess centre with eye-opening / eyelid overlay (v=0.40)
|
|
756
|
+
const eyeY = 0.20;
|
|
730
757
|
const eyeL_d = ((xRel + 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
|
|
731
758
|
const eyeR_d = ((xRel - 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
|
|
732
759
|
const eyeRecess = 0.045 * renderConfig.eyeDepth;
|
|
@@ -926,8 +953,11 @@ function rebuildMesh() {
|
|
|
926
953
|
const cutMouth = renderConfig.mouthHole;
|
|
927
954
|
|
|
928
955
|
// eye sockets puncture (optional)
|
|
929
|
-
|
|
930
|
-
|
|
956
|
+
// v1.1: bumped base ellipse to 0.105 × 0.075 + eyeHoleSize multiplier so
|
|
957
|
+
// toggling "eye holes" actually produces a visible cut at typical mesh
|
|
958
|
+
// densities (matches the lib).
|
|
959
|
+
const eyeRU = 0.105 * renderConfig.eyeHoleSize, eyeRV = 0.075 * renderConfig.eyeHoleSize;
|
|
960
|
+
const eyeLU = 0.30, eyeLV = 0.40;
|
|
931
961
|
const eyeRU2 = 0.70, eyeRV2 = 0.40;
|
|
932
962
|
const cutEyes = renderConfig.eyeHoles;
|
|
933
963
|
|
|
@@ -1121,6 +1151,36 @@ function applyMouthGrow(disp) {
|
|
|
1121
1151
|
}
|
|
1122
1152
|
}
|
|
1123
1153
|
|
|
1154
|
+
/* v1.1: static jaw-protrude passes — push upper-mouth and lower-jaw regions
|
|
1155
|
+
forward independent of jawOpen. Used together they form the snout / animal
|
|
1156
|
+
/ crocodile-mouth distortion. Both default 0 so existing behavior is
|
|
1157
|
+
unchanged. */
|
|
1158
|
+
function applyUpperJawProtrude(disp) {
|
|
1159
|
+
const amt = renderConfig.upperJawProtrude;
|
|
1160
|
+
if (amt < 0.001) return;
|
|
1161
|
+
const push = amt * 0.18;
|
|
1162
|
+
for (let i = 0; i < baseUVs.length; i++) {
|
|
1163
|
+
const v = baseUVs[i].v;
|
|
1164
|
+
if (v < 0.45 || v > 0.72) continue;
|
|
1165
|
+
const w = v < 0.62 ? (v - 0.45) / 0.17 : (0.72 - v) / 0.10;
|
|
1166
|
+
disp[i].z += push * w;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
function applyLowerJawProtrude(disp) {
|
|
1170
|
+
const amt = renderConfig.lowerJawProtrude;
|
|
1171
|
+
if (amt < 0.001) return;
|
|
1172
|
+
const push = amt * 0.18;
|
|
1173
|
+
for (let i = 0; i < baseUVs.length; i++) {
|
|
1174
|
+
const v = baseUVs[i].v;
|
|
1175
|
+
if (v < 0.70) continue;
|
|
1176
|
+
let w;
|
|
1177
|
+
if (v < 0.85) w = (v - 0.70) / 0.15;
|
|
1178
|
+
else w = 1 - (v - 0.85) / 0.30;
|
|
1179
|
+
if (w < 0) w = 0;
|
|
1180
|
+
disp[i].z += push * w;
|
|
1181
|
+
}
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1124
1184
|
/* apply mouth anchor — drives ring vertices to match the lip-curve formula */
|
|
1125
1185
|
function applyMouthAnchors(disp) {
|
|
1126
1186
|
if (!renderConfig.mouthAnchor) return;
|
|
@@ -1426,8 +1486,10 @@ function updateFace() {
|
|
|
1426
1486
|
computeMorphs(_dispBuf);
|
|
1427
1487
|
if (renderConfig.reactivity > 0) couple(_dispBuf, renderConfig.reactivity);
|
|
1428
1488
|
applyFeatureScales(_dispBuf);
|
|
1429
|
-
applyJawExtension(_dispBuf);
|
|
1430
|
-
applyMouthGrow(_dispBuf);
|
|
1489
|
+
applyJawExtension(_dispBuf); // v011: z-forward push of lower face on jaw open
|
|
1490
|
+
applyMouthGrow(_dispBuf); // v011: scale mouth region outward proportional to openness
|
|
1491
|
+
applyUpperJawProtrude(_dispBuf); // v1.1: static upper-jaw push
|
|
1492
|
+
applyLowerJawProtrude(_dispBuf); // v1.1: static lower-jaw push (crocodile-mouth)
|
|
1431
1493
|
applyMouthAnchors(_dispBuf);
|
|
1432
1494
|
applyEyeAnchors(_dispBuf);
|
|
1433
1495
|
|
|
@@ -1446,11 +1508,13 @@ function updateFace() {
|
|
|
1446
1508
|
if (renderConfig.depthFade > 0.001 && _baseRGB && _fadeRGB) {
|
|
1447
1509
|
const zRange = (_zMax - _zMin) || 1;
|
|
1448
1510
|
const f = renderConfig.depthFade;
|
|
1511
|
+
const curve = renderConfig.depthFadeCurve > 0 ? renderConfig.depthFadeCurve : 1;
|
|
1449
1512
|
for (let i = 0; i < baseVertices.length; i++) {
|
|
1450
|
-
// currentZ from already-updated _posBuf
|
|
1451
1513
|
const z = _posBuf[3*i + 2];
|
|
1452
|
-
|
|
1453
|
-
|
|
1514
|
+
let t = (_zMax - z) / zRange;
|
|
1515
|
+
if (t < 0) t = 0; else if (t > 1) t = 1;
|
|
1516
|
+
if (curve !== 1) t = Math.pow(t, curve);
|
|
1517
|
+
t *= f;
|
|
1454
1518
|
_colBuf[4*i ] = _baseRGB[0] * (1 - t) + _fadeRGB[0] * t;
|
|
1455
1519
|
_colBuf[4*i+1] = _baseRGB[1] * (1 - t) + _fadeRGB[1] * t;
|
|
1456
1520
|
_colBuf[4*i+2] = _baseRGB[2] * (1 - t) + _fadeRGB[2] * t;
|
|
@@ -1502,17 +1566,21 @@ rebuildPupils();
|
|
|
1502
1566
|
the same channel state as the mesh so deformations stay synchronized.
|
|
1503
1567
|
Toggleable via renderConfig.minimal. */
|
|
1504
1568
|
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1569
|
+
/* v1.1: one material per minimal-line feature so each can have its own color.
|
|
1570
|
+
lineColor is the shared fallback; per-feature overrides (mouthColor /
|
|
1571
|
+
eyeColor / noseColor) are null by default = inherit lineColor. */
|
|
1572
|
+
function makeMinimalMat(name) {
|
|
1573
|
+
const m = new BABYLON.StandardMaterial(name, scene);
|
|
1574
|
+
m.emissiveColor = new BABYLON.Color3(1, 1, 1);
|
|
1575
|
+
m.disableLighting = true;
|
|
1576
|
+
m.specularColor = new BABYLON.Color3(0, 0, 0);
|
|
1577
|
+
return m;
|
|
1578
|
+
}
|
|
1579
|
+
const mouthMat = makeMinimalMat('mouthMat');
|
|
1580
|
+
const eyeMat = makeMinimalMat('eyeMat');
|
|
1581
|
+
const noseMat = makeMinimalMat('noseMat');
|
|
1582
|
+
const browMat = makeMinimalMat('browMat');
|
|
1583
|
+
const minimalMat = mouthMat; // legacy alias
|
|
1516
1584
|
|
|
1517
1585
|
const minimalGroup = new BABYLON.TransformNode('minimal', scene);
|
|
1518
1586
|
minimalGroup.parent = faceRoot;
|
|
@@ -1578,13 +1646,17 @@ function smoothPath(controls, samples = 18) {
|
|
|
1578
1646
|
return out;
|
|
1579
1647
|
}
|
|
1580
1648
|
|
|
1581
|
-
function makeTube(name, points, radius, instance) {
|
|
1582
|
-
|
|
1649
|
+
function makeTube(name, points, radius, mat, featureMul, instance) {
|
|
1650
|
+
// Final radius = base × featureMul × lineThickness — applied in BOTH new
|
|
1651
|
+
// and instance forms. Babylon's CreateTube instance-form applies
|
|
1652
|
+
// opts.radius every call (does not preserve construction radius), so
|
|
1653
|
+
// updateMinimal MUST pass the current featureMul each frame.
|
|
1654
|
+
const r = radius * (featureMul == null ? 1 : featureMul) * renderConfig.lineThickness;
|
|
1583
1655
|
const opts = { path: points, radius: r, tessellation: 6, updatable: true };
|
|
1584
1656
|
if (instance) opts.instance = instance;
|
|
1585
1657
|
const tube = BABYLON.MeshBuilder.CreateTube(name, opts, scene);
|
|
1586
1658
|
if (!instance) {
|
|
1587
|
-
tube.material =
|
|
1659
|
+
tube.material = mat || mouthMat;
|
|
1588
1660
|
tube.parent = minimalGroup;
|
|
1589
1661
|
}
|
|
1590
1662
|
return tube;
|
|
@@ -1695,48 +1767,60 @@ function rebuildMinimalLines() {
|
|
|
1695
1767
|
if (noseRightMesh) { noseRightMesh.dispose(); noseRightMesh = null; }
|
|
1696
1768
|
|
|
1697
1769
|
const { upper, lower } = mouthLipPaths();
|
|
1698
|
-
mouthUpperMesh = makeTube('mouth_u', upper, 0.010);
|
|
1699
|
-
mouthLowerMesh = makeTube('mouth_l', lower, 0.010);
|
|
1770
|
+
mouthUpperMesh = makeTube('mouth_u', upper, 0.010, mouthMat, renderConfig.mouthLineThickness);
|
|
1771
|
+
mouthLowerMesh = makeTube('mouth_l', lower, 0.010, mouthMat, renderConfig.mouthLineThickness);
|
|
1700
1772
|
|
|
1701
1773
|
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);
|
|
1774
|
+
const u = makeTube('eye_' + eye.side + '_u', eyePath(eye, true), 0.0085, eyeMat, renderConfig.eyeLineThickness);
|
|
1775
|
+
const l = makeTube('eye_' + eye.side + '_l', eyePath(eye, false), 0.0085, eyeMat, renderConfig.eyeLineThickness);
|
|
1704
1776
|
eyeMeshes.push({ eye, upper: u, lower: l });
|
|
1705
1777
|
}
|
|
1706
1778
|
|
|
1707
1779
|
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
|
|
1780
|
+
const m = makeTube('brow_' + brow.side, browPath(brow), 0.011, browMat, renderConfig.browLineThickness);
|
|
1710
1781
|
browMeshes.push({ brow, mesh: m });
|
|
1711
1782
|
}
|
|
1712
1783
|
|
|
1713
1784
|
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);
|
|
1785
|
+
noseBridgeMesh = makeTube('nose_b', np.bridge, 0.009, noseMat, renderConfig.noseLineThickness);
|
|
1786
|
+
noseLeftMesh = makeTube('nose_l', np.leftN, 0.0085, noseMat, renderConfig.noseLineThickness);
|
|
1787
|
+
noseRightMesh = makeTube('nose_r', np.rightN, 0.0085, noseMat, renderConfig.noseLineThickness);
|
|
1788
|
+
applyMinimalSubVisibility();
|
|
1717
1789
|
}
|
|
1718
1790
|
|
|
1719
1791
|
rebuildMinimalLines();
|
|
1720
1792
|
|
|
1721
1793
|
function updateMinimal() {
|
|
1722
|
-
//
|
|
1794
|
+
// Babylon's CreateTube instance-form applies opts.radius every call —
|
|
1795
|
+
// it doesn't preserve the radius from construction. So we MUST pass the
|
|
1796
|
+
// current per-feature thickness multiplier on every frame, otherwise the
|
|
1797
|
+
// tube collapses back to (base × 1 × lineThickness) and the per-feature
|
|
1798
|
+
// slider has no visible effect (only one frame after rebuildMinimalLines).
|
|
1723
1799
|
const mp = mouthLipPaths();
|
|
1724
|
-
makeTube('', mp.upper, 0.010, mouthUpperMesh);
|
|
1725
|
-
makeTube('', mp.lower, 0.010, mouthLowerMesh);
|
|
1726
|
-
// eyes
|
|
1800
|
+
makeTube('', mp.upper, 0.010, null, renderConfig.mouthLineThickness, mouthUpperMesh);
|
|
1801
|
+
makeTube('', mp.lower, 0.010, null, renderConfig.mouthLineThickness, mouthLowerMesh);
|
|
1727
1802
|
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);
|
|
1803
|
+
makeTube('', eyePath(em.eye, true), 0.0085, null, renderConfig.eyeLineThickness, em.upper);
|
|
1804
|
+
makeTube('', eyePath(em.eye, false), 0.0085, null, renderConfig.eyeLineThickness, em.lower);
|
|
1730
1805
|
}
|
|
1731
|
-
// brows
|
|
1732
1806
|
for (const bm of browMeshes) {
|
|
1733
|
-
makeTube('', browPath(bm.brow), 0.011, bm.mesh);
|
|
1807
|
+
makeTube('', browPath(bm.brow), 0.011, null, renderConfig.browLineThickness, bm.mesh);
|
|
1734
1808
|
}
|
|
1735
|
-
// nose
|
|
1736
1809
|
const np = nosePaths();
|
|
1737
|
-
makeTube('', np.bridge, 0.009, noseBridgeMesh);
|
|
1738
|
-
makeTube('', np.leftN, 0.0085, noseLeftMesh);
|
|
1739
|
-
makeTube('', np.rightN, 0.0085, noseRightMesh);
|
|
1810
|
+
makeTube('', np.bridge, 0.009, null, renderConfig.noseLineThickness, noseBridgeMesh);
|
|
1811
|
+
makeTube('', np.leftN, 0.0085, null, renderConfig.noseLineThickness, noseLeftMesh);
|
|
1812
|
+
makeTube('', np.rightN, 0.0085, null, renderConfig.noseLineThickness, noseRightMesh);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1815
|
+
function applyMinimalSubVisibility() {
|
|
1816
|
+
const setVis = (m, v) => { if (m) m.isVisible = v; };
|
|
1817
|
+
setVis(mouthUpperMesh, !!renderConfig.minimalMouth);
|
|
1818
|
+
setVis(mouthLowerMesh, !!renderConfig.minimalMouth);
|
|
1819
|
+
for (const em of eyeMeshes) { setVis(em.upper, !!renderConfig.minimalEyes); setVis(em.lower, !!renderConfig.minimalEyes); }
|
|
1820
|
+
for (const bm of browMeshes) setVis(bm.mesh, !!renderConfig.minimalBrows);
|
|
1821
|
+
setVis(noseBridgeMesh, !!renderConfig.minimalNose);
|
|
1822
|
+
setVis(noseLeftMesh, !!renderConfig.minimalNose);
|
|
1823
|
+
setVis(noseRightMesh, !!renderConfig.minimalNose);
|
|
1740
1824
|
}
|
|
1741
1825
|
|
|
1742
1826
|
function applyMinimalVisibility() {
|
|
@@ -2459,9 +2543,10 @@ function setRcfgVal(key, val) {
|
|
|
2459
2543
|
const max = parseFloat(def.dataset.max);
|
|
2460
2544
|
const step = parseFloat(def.dataset.step) || 0.01;
|
|
2461
2545
|
let v = Math.max(min, Math.min(max, val));
|
|
2462
|
-
|
|
2463
|
-
//
|
|
2464
|
-
|
|
2546
|
+
// snap to step relative to min — fixes odd-only sliders (cols/rows, step=2,
|
|
2547
|
+
// min=5/7) where previously `Math.round(9/2)*2 = 10 → +1 = 11`, shifting
|
|
2548
|
+
// every saved odd value up by 2 on reload.
|
|
2549
|
+
v = min + Math.round((v - min) / step) * step;
|
|
2465
2550
|
renderConfig[key] = v;
|
|
2466
2551
|
// update fill bar
|
|
2467
2552
|
const fill = def.querySelector('.fill');
|
|
@@ -2470,8 +2555,10 @@ function setRcfgVal(key, val) {
|
|
|
2470
2555
|
const lbl = document.querySelector(`[data-rcfg-val="${key}"]`);
|
|
2471
2556
|
if (lbl) lbl.textContent = (step >= 1) ? String(Math.round(v)) : v.toFixed(2);
|
|
2472
2557
|
// side-effects
|
|
2473
|
-
if (key === 'meshCols' || key === 'meshRows' || key === 'eyeDepth' ||
|
|
2474
|
-
|
|
2558
|
+
if (key === 'meshCols' || key === 'meshRows' || key === 'eyeDepth' ||
|
|
2559
|
+
key === 'mouthHoleSize' || key === 'eyeHoleSize') rebuildMesh();
|
|
2560
|
+
if (key === 'lineThickness' || key === 'mouthLineThickness' || key === 'eyeLineThickness' ||
|
|
2561
|
+
key === 'noseLineThickness' || key === 'browLineThickness') {
|
|
2475
2562
|
rebuildMinimalLines();
|
|
2476
2563
|
// edges renderer width is mutable; just nudge it without dispose/recreate
|
|
2477
2564
|
if (mesh && mesh._edgesRenderer) mesh.edgesWidth = 4 * renderConfig.lineThickness;
|
|
@@ -2492,15 +2579,35 @@ function setRcfgVal(key, val) {
|
|
|
2492
2579
|
}
|
|
2493
2580
|
}
|
|
2494
2581
|
|
|
2495
|
-
/* color pickers — line + pupil + v011: base / fade / iris / brow */
|
|
2582
|
+
/* color pickers — line + pupil + v011: base / fade / iris / brow + v1.1: per-feature */
|
|
2496
2583
|
function applyLineColor(hex) {
|
|
2497
2584
|
renderConfig.lineColor = hex;
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2585
|
+
const c = BABYLON.Color3.FromHexString(hex);
|
|
2586
|
+
// mouth/eye/nose mats inherit lineColor unless their per-feature override is non-null
|
|
2587
|
+
if (!renderConfig.mouthColor && mouthMat) mouthMat.emissiveColor = c;
|
|
2588
|
+
if (!renderConfig.eyeColor && eyeMat) eyeMat.emissiveColor = c;
|
|
2589
|
+
if (!renderConfig.noseColor && noseMat) noseMat.emissiveColor = c;
|
|
2501
2590
|
const lbl = document.getElementById('color-line-val');
|
|
2502
2591
|
if (lbl) lbl.textContent = hex.replace('#', '').toUpperCase().slice(0, 3);
|
|
2503
2592
|
}
|
|
2593
|
+
function applyMouthColor(hex) {
|
|
2594
|
+
renderConfig.mouthColor = hex || null;
|
|
2595
|
+
if (mouthMat) mouthMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
|
|
2596
|
+
const lbl = document.getElementById('color-mouth-val');
|
|
2597
|
+
if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
|
|
2598
|
+
}
|
|
2599
|
+
function applyEyeColor(hex) {
|
|
2600
|
+
renderConfig.eyeColor = hex || null;
|
|
2601
|
+
if (eyeMat) eyeMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
|
|
2602
|
+
const lbl = document.getElementById('color-eye-val');
|
|
2603
|
+
if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
|
|
2604
|
+
}
|
|
2605
|
+
function applyNoseColor(hex) {
|
|
2606
|
+
renderConfig.noseColor = hex || null;
|
|
2607
|
+
if (noseMat) noseMat.emissiveColor = BABYLON.Color3.FromHexString(hex || renderConfig.lineColor);
|
|
2608
|
+
const lbl = document.getElementById('color-nose-val');
|
|
2609
|
+
if (lbl) lbl.textContent = (hex || renderConfig.lineColor).replace('#', '').toUpperCase().slice(0, 3);
|
|
2610
|
+
}
|
|
2504
2611
|
function applyPupilColor(hex) {
|
|
2505
2612
|
renderConfig.pupilColor = hex;
|
|
2506
2613
|
if (typeof pupilMat !== 'undefined' && pupilMat) {
|
|
@@ -2552,11 +2659,19 @@ function applyBrowColor(hex) {
|
|
|
2552
2659
|
['color-fade', 'fadeColor', applyFadeColor],
|
|
2553
2660
|
['color-iris', 'irisColor', applyIrisColor],
|
|
2554
2661
|
['color-brow', 'browColor', applyBrowColor],
|
|
2662
|
+
// v1.1: per-feature minimal-line colors. Default value seeded from
|
|
2663
|
+
// lineColor so the picker shows the inherited color, but user clicking
|
|
2664
|
+
// the picker sets the per-feature override.
|
|
2665
|
+
['color-mouth', 'mouthColor', applyMouthColor],
|
|
2666
|
+
['color-eye', 'eyeColor', applyEyeColor],
|
|
2667
|
+
['color-nose', 'noseColor', applyNoseColor],
|
|
2555
2668
|
];
|
|
2556
2669
|
for (const [id, key, fn] of wires) {
|
|
2557
2670
|
const el = document.getElementById(id);
|
|
2558
2671
|
if (!el) continue;
|
|
2559
|
-
|
|
2672
|
+
// for null per-feature colors, seed picker from lineColor so the swatch
|
|
2673
|
+
// reflects the inherited render color
|
|
2674
|
+
el.value = renderConfig[key] || renderConfig.lineColor || '#ffffff';
|
|
2560
2675
|
el.addEventListener('input', () => fn(el.value));
|
|
2561
2676
|
fn(el.value);
|
|
2562
2677
|
}
|
|
@@ -2606,6 +2721,10 @@ document.querySelectorAll('[data-toggle]').forEach(t => {
|
|
|
2606
2721
|
case 'flipFace': applyFaceFlip(); break;
|
|
2607
2722
|
case 'meshVisible': applyMeshVisibility(); break;
|
|
2608
2723
|
case 'minimal': applyMinimalVisibility(); break;
|
|
2724
|
+
case 'minimalMouth':
|
|
2725
|
+
case 'minimalEyes':
|
|
2726
|
+
case 'minimalNose':
|
|
2727
|
+
case 'minimalBrows': applyMinimalSubVisibility(); break;
|
|
2609
2728
|
case 'mouthAnchor': /* takes effect next frame */ break;
|
|
2610
2729
|
case 'eyeAnchor': /* takes effect next frame */ break;
|
|
2611
2730
|
case 'overlayTracksMesh': /* takes effect next frame */ break;
|
|
@@ -2689,6 +2808,12 @@ function applyPreset(p) {
|
|
|
2689
2808
|
document.querySelectorAll('[data-mode]').forEach(b => b.classList.toggle('on', b.dataset.mode === renderConfig.mode));
|
|
2690
2809
|
applyRenderMode();
|
|
2691
2810
|
applyMeshVisibility(); applyMinimalVisibility();
|
|
2811
|
+
// v1.0.x: applyPreset previously updated renderConfig.glow + the toggle's
|
|
2812
|
+
// visual state, but never re-applied glow.intensity — so the GlowLayer
|
|
2813
|
+
// would stay at whatever intensity the user had set last via the toggle
|
|
2814
|
+
// button, regardless of the preset's glow value. Sync it here.
|
|
2815
|
+
if (typeof glow !== 'undefined' && glow) glow.intensity = renderConfig.glow ? 0.85 : 0;
|
|
2816
|
+
if (typeof rebuildPupils === 'function') rebuildPupils(); // pickup pupils:false from preset
|
|
2692
2817
|
// colors
|
|
2693
2818
|
if (p.lineColor) {
|
|
2694
2819
|
const lc = document.getElementById('color-line'); if (lc) lc.value = p.lineColor;
|
|
@@ -2715,6 +2840,44 @@ function applyPreset(p) {
|
|
|
2715
2840
|
const el = document.getElementById('color-brow'); if (el) el.value = p.renderConfig.browColor;
|
|
2716
2841
|
applyBrowColor(p.renderConfig.browColor);
|
|
2717
2842
|
}
|
|
2843
|
+
// v1.1: per-feature minimal-line colors (null = inherit lineColor; non-null overrides)
|
|
2844
|
+
if (p.renderConfig) {
|
|
2845
|
+
const perFeat = [
|
|
2846
|
+
['mouthColor', 'color-mouth', applyMouthColor],
|
|
2847
|
+
['eyeColor', 'color-eye', applyEyeColor],
|
|
2848
|
+
['noseColor', 'color-nose', applyNoseColor],
|
|
2849
|
+
];
|
|
2850
|
+
for (const [k, id, fn] of perFeat) {
|
|
2851
|
+
if (k in p.renderConfig) {
|
|
2852
|
+
const el = document.getElementById(id);
|
|
2853
|
+
const swatch = p.renderConfig[k] || p.renderConfig.lineColor || '#ffffff';
|
|
2854
|
+
if (el) el.value = swatch;
|
|
2855
|
+
fn(p.renderConfig[k]); // null falls back to lineColor inside the setter
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
// v1.1: per-feature visibility + thickness — sliders pick up via setRcfgVal
|
|
2860
|
+
// when iterating renderConfig keys above (numeric path). Toggles update via
|
|
2861
|
+
// the data-toggle initialization. Now refresh visibility + rebuild tubes
|
|
2862
|
+
// so the new state actually takes effect.
|
|
2863
|
+
applyMinimalSubVisibility();
|
|
2864
|
+
if (p.renderConfig && (
|
|
2865
|
+
'mouthLineThickness' in p.renderConfig || 'eyeLineThickness' in p.renderConfig ||
|
|
2866
|
+
'noseLineThickness' in p.renderConfig || 'browLineThickness' in p.renderConfig)) {
|
|
2867
|
+
rebuildMinimalLines();
|
|
2868
|
+
}
|
|
2869
|
+
// v1.1 fix: boolean fields (fragment / mouthHole / eyeHoles / pupils) are
|
|
2870
|
+
// assigned via direct property write inside the iteration loop, which does
|
|
2871
|
+
// NOT trigger the corresponding rebuild. The mesh therefore reflects the
|
|
2872
|
+
// PREVIOUS state of those flags. Force a full geometric rebuild now to
|
|
2873
|
+
// sync everything with the loaded config. Cheap (single-shot) and ensures
|
|
2874
|
+
// a preset roundtrip is faithful.
|
|
2875
|
+
if (p.renderConfig) {
|
|
2876
|
+
if (typeof rebuildMesh === 'function') rebuildMesh();
|
|
2877
|
+
if (typeof rebuildPupils === 'function') rebuildPupils();
|
|
2878
|
+
if (typeof rebuildMinimalLines === 'function') rebuildMinimalLines();
|
|
2879
|
+
if (typeof applyMinimalSubVisibility === 'function') applyMinimalSubVisibility();
|
|
2880
|
+
}
|
|
2718
2881
|
// channel gains (knobs)
|
|
2719
2882
|
if (p.channelGainSliders) {
|
|
2720
2883
|
for (const ch of CHANNEL_NAMES) {
|