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.
package/wireface.js CHANGED
@@ -168,10 +168,25 @@
168
168
  overlayTracksMesh: true,
169
169
  moodTransitionTime: 0.6,
170
170
  lineColor: '#ffffff', pupilColor: '#ffffff',
171
+ // Per-feature minimal-line overrides. null = inherit lineColor (backward
172
+ // compat with v1.0.x presets). Each feature can be hidden individually
173
+ // even when the master `minimal` is on. Each has its own thickness
174
+ // multiplier on top of the global `lineThickness`.
175
+ mouthColor: null, eyeColor: null, noseColor: null,
176
+ minimalMouth: true, minimalEyes: true, minimalNose: true, minimalBrows: true,
177
+ mouthLineThickness: 1.0, eyeLineThickness: 1.0, noseLineThickness: 1.0, browLineThickness: 1.0,
171
178
  baseColor: '#ffffff', fadeColor: '#000000', depthFade: 0.0,
179
+ // exponent applied to the per-vertex fade weight. >1 darkens the back
180
+ // faster (so silhouette edges actually reach fadeColor in wire mode);
181
+ // <1 brightens it. 1.0 = linear, original behavior.
182
+ depthFadeCurve: 1.0,
172
183
  irisColor: '#000000', irisSize: 1.6,
173
184
  browColor: '#ffffff',
174
185
  jawExtend: 0.0, mouthGrow: 0.0,
186
+ // experimental — static z push of upper-mouth and lower-jaw regions for
187
+ // animal / crocodile-mouth distortions. Stack on top of jawExtend (which
188
+ // is jawOpen-driven). Default 0 = current behavior.
189
+ upperJawProtrude: 0.0, lowerJawProtrude: 0.0,
175
190
  cameraView: 'three-q', // initial view
176
191
  };
177
192
 
@@ -272,49 +287,83 @@
272
287
  wireMat.alpha = 1;
273
288
  wireMat.useVertexColor = true;
274
289
 
275
- const minimalMat = new BABYLON.StandardMaterial('minimalMat', scene);
276
- minimalMat.emissiveColor = new BABYLON.Color3(1, 1, 1);
277
- minimalMat.disableLighting = true;
278
- minimalMat.specularColor = new BABYLON.Color3(0, 0, 0);
279
-
280
- const browMat = new BABYLON.StandardMaterial('browMat', scene);
281
- browMat.emissiveColor = new BABYLON.Color3(1, 1, 1);
282
- browMat.disableLighting = true;
283
- browMat.specularColor = new BABYLON.Color3(0, 0, 0);
290
+ /* one material per minimal-line feature so each can have its own color
291
+ independent of the others. lineColor is the shared fallback; if a
292
+ per-feature color (mouthColor/eyeColor/noseColor) is null the feature
293
+ inherits lineColor at apply time. */
294
+ function makeMinimalMat(name) {
295
+ const m = new BABYLON.StandardMaterial(name, scene);
296
+ m.emissiveColor = new BABYLON.Color3(1, 1, 1);
297
+ m.disableLighting = true;
298
+ m.specularColor = new BABYLON.Color3(0, 0, 0);
299
+ return m;
300
+ }
301
+ const mouthMat = makeMinimalMat('mouthMat');
302
+ const eyeMat = makeMinimalMat('eyeMat');
303
+ const noseMat = makeMinimalMat('noseMat');
304
+ const browMat = makeMinimalMat('browMat');
305
+ // legacy alias — some downstream code still references minimalMat
306
+ const minimalMat = mouthMat;
284
307
 
285
308
  const minimalGroup = new BABYLON.TransformNode('minimal', scene);
286
309
  minimalGroup.parent = faceRoot;
287
310
 
288
- /* ─── 4a. parametric warp (u,v) → 3D face surface ─── */
311
+ /* ─── 4a. parametric warp: grid (u,v) → face surface (x,y,z) ───
312
+ Ported verbatim from the v011 editor. Uses an elliptical taper so the
313
+ silhouette is oval, not rectangular. Then layers feature bumps (eye
314
+ sockets, brow ridge, nose, mouth, cheeks) as gaussian falloffs in
315
+ xRel/yRel space (xRel = (u-0.5)*2, yRel = (0.5-v)*2). This shape's
316
+ z-range (≈0.10..0.30) is what lets depthFade produce a visible
317
+ gradient instead of pinning the silhouette to black. */
289
318
  function warpToFace(u, v) {
290
- const xRel = (u - 0.5) * 2;
291
- const yRel = (0.5 - v) * 2;
319
+ const xRel = (u - 0.5) * 2; // -1..1 left to right
320
+ const yRel = (0.5 - v) * 2; // 1..-1 top to bottom
321
+
322
+ // strong elliptical taper — boundary of the grid maps to an oval
292
323
  const yNorm = yRel * 0.95;
293
324
  const ovalT = Math.max(0, 1 - yNorm * yNorm);
294
- const x = xRel * Math.sqrt(ovalT) * 0.80;
295
- const y = yRel * 0.95;
296
- let z = (Math.cos(xRel * Math.PI * 0.5)) * (Math.cos(yRel * Math.PI * 0.5)) * 0.18;
297
- // nose ridge
298
- const nU = 0.50, nV = 0.50;
299
- const dn = Math.hypot((u-nU), (v-nV)) / 0.16;
300
- if (dn < 1.6) z += (1 - Math.min(1, dn)) * 0.085;
301
- // brow ridge
302
- const dbL = Math.hypot((u-0.30), (v-0.27)) / 0.10;
303
- const dbR = Math.hypot((u-0.70), (v-0.27)) / 0.10;
304
- if (dbL < 1.6) z += (1 - Math.min(1, dbL)) * 0.020;
305
- if (dbR < 1.6) z += (1 - Math.min(1, dbR)) * 0.020;
306
- // eye sockets recess
307
- const deL = Math.hypot((u-0.30)/0.085, (v-0.40)/0.045);
308
- const deR = Math.hypot((u-0.70)/0.085, (v-0.40)/0.045);
309
- if (deL < 1.5) z -= (1 - Math.min(1, deL)) * 0.030 * config.eyeDepth;
310
- if (deR < 1.5) z -= (1 - Math.min(1, deR)) * 0.030 * config.eyeDepth;
311
- // chin protrusion
312
- if (v > 0.85) z += (v - 0.85) * 0.6 * 0.10 * Math.max(0, 1 - Math.abs(xRel) * 1.2);
313
- // cheek bulge
314
- const cheekL = Math.hypot((u-0.22)/0.10, (v-0.62)/0.08);
315
- const cheekR = Math.hypot((u-0.78)/0.10, (v-0.62)/0.08);
316
- if (cheekL < 1.6) z += (1 - Math.min(1, cheekL)) * 0.018;
317
- if (cheekR < 1.6) z += (1 - Math.min(1, cheekR)) * 0.018;
325
+ const widthAtY = Math.sqrt(ovalT) * 0.80;
326
+ let x = xRel * widthAtY;
327
+
328
+ // y stays linear; chin extends + forehead squashes
329
+ let y = yRel * 1.0;
330
+ if (yRel < -0.4) y = -0.4 + (yRel + 0.4) * 1.55;
331
+ if (yRel > 0.7) y = 0.7 + (yRel - 0.7) * 0.45;
332
+
333
+ // base z bulge — quadratic falloff from center
334
+ let z = (1 - xRel*xRel * 0.55 - yRel*yRel * 0.55) * 0.22;
335
+ if (z < -0.05) z = -0.05;
336
+
337
+ // eye sockets recess (gaussian — broad and bowl-shaped).
338
+ // Centered at yRel=0.20 → UV v=0.40 to align with the eye opening
339
+ // (eye-hole puncture, minimal-line eyelid overlay, eye_blink shapes
340
+ // are all at v=0.40). Original v011 used yRel=0.30 which placed the
341
+ // bowl above the eye opening.
342
+ const eyeY = 0.20;
343
+ const eyeL_d = ((xRel + 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
344
+ const eyeR_d = ((xRel - 0.45) / 0.30) ** 2 + ((yRel - eyeY) / 0.18) ** 2;
345
+ const eyeRecess = 0.045 * config.eyeDepth;
346
+ z -= eyeRecess * Math.exp(-eyeL_d);
347
+ z -= eyeRecess * Math.exp(-eyeR_d);
348
+
349
+ // brow ridge bumps forward
350
+ const brow_d = (xRel / 0.7) ** 2 + ((yRel - 0.55) / 0.10) ** 2;
351
+ z += 0.045 * Math.exp(-brow_d);
352
+
353
+ // nose — the dominant z bump
354
+ const nose_d = (xRel / 0.18) ** 2 + ((yRel - 0.05) / 0.40) ** 2;
355
+ z += 0.22 * Math.exp(-nose_d);
356
+
357
+ // mouth area pushed slightly forward
358
+ const mouth_d = (xRel / 0.55) ** 2 + ((yRel + 0.45) / 0.20) ** 2;
359
+ z += 0.06 * Math.exp(-mouth_d);
360
+
361
+ // cheekbones
362
+ const cheekL_d = ((xRel + 0.55) / 0.30) ** 2 + ((yRel - 0.05) / 0.28) ** 2;
363
+ const cheekR_d = ((xRel - 0.55) / 0.30) ** 2 + ((yRel - 0.05) / 0.28) ** 2;
364
+ z += 0.04 * Math.exp(-cheekL_d);
365
+ z += 0.04 * Math.exp(-cheekR_d);
366
+
318
367
  return V(x, y, z);
319
368
  }
320
369
 
@@ -585,9 +634,9 @@
585
634
  const spread = config.spread;
586
635
  const p = computeMouthParams();
587
636
  // mouth
588
- applyShape(disp, SHAPES.mouth_jaw_drop, p.jaw, spread);
589
- applyShape(disp, SHAPES.mouth_open_lower, p.open, spread);
590
- applyShape(disp, SHAPES.mouth_open_upper, p.open, spread);
637
+ applyShape(disp, SHAPES.mouth_jaw_drop, p.jaw, spread);
638
+ applyShape(disp, SHAPES.mouth_open_lower, p.open, spread);
639
+ applyShape(disp, SHAPES.mouth_open_upper, p.open * 0.4, spread);
591
640
  const sm = p.smile;
592
641
  if (sm > 0) { applyShape(disp, SHAPES.mouth_smile_L, sm, spread); applyShape(disp, SHAPES.mouth_smile_R, sm, spread); }
593
642
  else if (sm < 0) { applyShape(disp, SHAPES.mouth_frown_L, -sm, spread); applyShape(disp, SHAPES.mouth_frown_R, -sm, spread); }
@@ -611,10 +660,16 @@
611
660
  // brows
612
661
  applyShape(disp, SHAPES.brow_inner_L, state.browInnerUp, spread);
613
662
  applyShape(disp, SHAPES.brow_inner_R, state.browInnerUp, spread);
614
- applyShape(disp, SHAPES.brow_outer_L, Math.max(0, state.browOuterUp), spread);
615
- applyShape(disp, SHAPES.brow_outer_R, Math.max(0, state.browOuterUp), spread);
616
- applyShape(disp, SHAPES.brow_down_L, state.browDown + Math.max(0,-state.browOuterUp), spread);
617
- applyShape(disp, SHAPES.brow_down_R, state.browDown + Math.max(0,-state.browOuterUp), spread);
663
+ // v011: browOuterUp >= 0 lifts outer brow; < 0 drives brow_down at 0.6x
664
+ if (state.browOuterUp >= 0) {
665
+ applyShape(disp, SHAPES.brow_outer_L, state.browOuterUp, spread);
666
+ applyShape(disp, SHAPES.brow_outer_R, state.browOuterUp, spread);
667
+ } else {
668
+ applyShape(disp, SHAPES.brow_down_L, -state.browOuterUp * 0.6, spread);
669
+ applyShape(disp, SHAPES.brow_down_R, -state.browOuterUp * 0.6, spread);
670
+ }
671
+ applyShape(disp, SHAPES.brow_down_L, state.browDown, spread);
672
+ applyShape(disp, SHAPES.brow_down_R, state.browDown, spread);
618
673
  // nose
619
674
  applyShape(disp, SHAPES.nose_sneer_L, state.noseSneer, spread);
620
675
  applyShape(disp, SHAPES.nose_sneer_R, state.noseSneer, spread);
@@ -704,6 +759,45 @@
704
759
  }
705
760
  }
706
761
 
762
+ /* Static jaw-protrude passes — push the upper-mouth and lower-jaw
763
+ regions forward (z+) independent of jawOpen. Used together they
764
+ form the snout / animal / crocodile-mouth distortion. Each is a
765
+ smooth tent ramp in v-space:
766
+ - upper: peaks at v=0.62 (just above the mouth), tapers off by
767
+ v=0.45 (top) and v=0.72 (mouth line)
768
+ - lower: peaks at v=0.85 (chin tip), tapers off by v=0.70 (mouth)
769
+ and v=1.0 (bottom of grid)
770
+ Magnitude is `protrude * 0.18` for both — at amt=3 (slider max),
771
+ lower jaw juts forward ~0.54 z-units which is comparable to the
772
+ nose tip's z=0.22, giving a clearly elongated jaw silhouette. */
773
+ function applyUpperJawProtrude(disp) {
774
+ const amt = config.upperJawProtrude;
775
+ if (amt < 0.001) return;
776
+ const push = amt * 0.18;
777
+ for (let i = 0; i < baseUVs.length; i++) {
778
+ const v = baseUVs[i].v;
779
+ if (v < 0.45 || v > 0.72) continue;
780
+ // tent: 0 at edges, 1 at v=0.62
781
+ const w = v < 0.62 ? (v - 0.45) / 0.17 : (0.72 - v) / 0.10;
782
+ disp[i].z += push * w;
783
+ }
784
+ }
785
+ function applyLowerJawProtrude(disp) {
786
+ const amt = config.lowerJawProtrude;
787
+ if (amt < 0.001) return;
788
+ const push = amt * 0.18;
789
+ for (let i = 0; i < baseUVs.length; i++) {
790
+ const v = baseUVs[i].v;
791
+ if (v < 0.70) continue;
792
+ // tent: 0 at v=0.70, 1 at v=0.85, tapers to 0.5 at v=1.0
793
+ let w;
794
+ if (v < 0.85) w = (v - 0.70) / 0.15;
795
+ else w = 1 - (v - 0.85) / 0.30; // ramp down past chin tip
796
+ if (w < 0) w = 0;
797
+ disp[i].z += push * w;
798
+ }
799
+ }
800
+
707
801
  function applyMouthAnchors(disp) {
708
802
  if (!config.mouthAnchor) return;
709
803
  const p = computeMouthParams();
@@ -866,12 +960,18 @@
866
960
  return out;
867
961
  }
868
962
 
869
- function makeTube(name, points, radius, instance) {
870
- const r = instance ? radius : radius * config.lineThickness;
963
+ /* makeTube creates a new tube OR updates an existing one in-place.
964
+ Final radius = baseRadius * featureMul * config.lineThickness — applied
965
+ in BOTH new and instance forms. Babylon's CreateTube instance-form
966
+ applies opts.radius every call (it does not preserve the radius from
967
+ construction), so updateMinimal MUST pass the current featureMul each
968
+ frame or the tube collapses to (base × 1 × lineThickness). */
969
+ function makeTube(name, points, radius, mat, featureMul, instance) {
970
+ const r = radius * (featureMul == null ? 1 : featureMul) * config.lineThickness;
871
971
  const opts = { path: points, radius: r, tessellation: 6, updatable: true };
872
972
  if (instance) opts.instance = instance;
873
973
  const tube = BABYLON.MeshBuilder.CreateTube(name, opts, scene);
874
- if (!instance) { tube.material = minimalMat; tube.parent = minimalGroup; }
974
+ if (!instance) { tube.material = mat || mouthMat; tube.parent = minimalGroup; }
875
975
  return tube;
876
976
  }
877
977
 
@@ -964,39 +1064,44 @@
964
1064
  if (noseLeftMesh) { noseLeftMesh.dispose(); noseLeftMesh = null; }
965
1065
  if (noseRightMesh) { noseRightMesh.dispose(); noseRightMesh = null; }
966
1066
  const { upper, lower } = mouthLipPaths();
967
- mouthUpperMesh = makeTube('mouth_u', upper, 0.010);
968
- mouthLowerMesh = makeTube('mouth_l', lower, 0.010);
1067
+ mouthUpperMesh = makeTube('mouth_u', upper, 0.010, mouthMat, config.mouthLineThickness);
1068
+ mouthLowerMesh = makeTube('mouth_l', lower, 0.010, mouthMat, config.mouthLineThickness);
969
1069
  for (const eye of eyeData) {
970
- const u = makeTube('eye_' + eye.side + '_u', eyePath(eye, true), 0.0085);
971
- const l = makeTube('eye_' + eye.side + '_l', eyePath(eye, false), 0.0085);
1070
+ const u = makeTube('eye_' + eye.side + '_u', eyePath(eye, true), 0.0085, eyeMat, config.eyeLineThickness);
1071
+ const l = makeTube('eye_' + eye.side + '_l', eyePath(eye, false), 0.0085, eyeMat, config.eyeLineThickness);
972
1072
  eyeMeshes.push({ eye, upper: u, lower: l });
973
1073
  }
974
1074
  for (const brow of browData) {
975
- const m = makeTube('brow_' + brow.side, browPath(brow), 0.011);
976
- m.material = browMat;
1075
+ const m = makeTube('brow_' + brow.side, browPath(brow), 0.011, browMat, config.browLineThickness);
977
1076
  browMeshes.push({ brow, mesh: m });
978
1077
  }
979
1078
  const np = nosePaths();
980
- noseBridgeMesh = makeTube('nose_b', np.bridge, 0.009);
981
- noseLeftMesh = makeTube('nose_l', np.leftN, 0.0085);
982
- noseRightMesh = makeTube('nose_r', np.rightN, 0.0085);
1079
+ noseBridgeMesh = makeTube('nose_b', np.bridge, 0.009, noseMat, config.noseLineThickness);
1080
+ noseLeftMesh = makeTube('nose_l', np.leftN, 0.0085, noseMat, config.noseLineThickness);
1081
+ noseRightMesh = makeTube('nose_r', np.rightN, 0.0085, noseMat, config.noseLineThickness);
983
1082
  applyMinimalVisibility();
1083
+ applyMinimalSubVisibility();
984
1084
  }
985
1085
 
986
1086
  function updateMinimal() {
987
1087
  if (!mouthUpperMesh) return;
1088
+ // Babylon's CreateTube instance-form applies opts.radius EVERY call —
1089
+ // it doesn't preserve the radius from construction. So we must pass the
1090
+ // current per-feature thickness multiplier on every frame, otherwise
1091
+ // the tube collapses back to (base × 1 × lineThickness) and the
1092
+ // per-feature slider has no visible effect.
988
1093
  const mp = mouthLipPaths();
989
- makeTube('', mp.upper, 0.010, mouthUpperMesh);
990
- makeTube('', mp.lower, 0.010, mouthLowerMesh);
1094
+ makeTube('', mp.upper, 0.010, null, config.mouthLineThickness, mouthUpperMesh);
1095
+ makeTube('', mp.lower, 0.010, null, config.mouthLineThickness, mouthLowerMesh);
991
1096
  for (const em of eyeMeshes) {
992
- makeTube('', eyePath(em.eye, true), 0.0085, em.upper);
993
- makeTube('', eyePath(em.eye, false), 0.0085, em.lower);
1097
+ makeTube('', eyePath(em.eye, true), 0.0085, null, config.eyeLineThickness, em.upper);
1098
+ makeTube('', eyePath(em.eye, false), 0.0085, null, config.eyeLineThickness, em.lower);
994
1099
  }
995
- for (const bm of browMeshes) makeTube('', browPath(bm.brow), 0.011, bm.mesh);
1100
+ for (const bm of browMeshes) makeTube('', browPath(bm.brow), 0.011, null, config.browLineThickness, bm.mesh);
996
1101
  const np = nosePaths();
997
- makeTube('', np.bridge, 0.009, noseBridgeMesh);
998
- makeTube('', np.leftN, 0.0085, noseLeftMesh);
999
- makeTube('', np.rightN, 0.0085, noseRightMesh);
1102
+ makeTube('', np.bridge, 0.009, null, config.noseLineThickness, noseBridgeMesh);
1103
+ makeTube('', np.leftN, 0.0085, null, config.noseLineThickness, noseLeftMesh);
1104
+ makeTube('', np.rightN, 0.0085, null, config.noseLineThickness, noseRightMesh);
1000
1105
  }
1001
1106
 
1002
1107
  /* ── per-frame face update ── */
@@ -1017,6 +1122,8 @@
1017
1122
  applyFeatureScales(_dispBuf);
1018
1123
  applyJawExtension(_dispBuf);
1019
1124
  applyMouthGrow(_dispBuf);
1125
+ applyUpperJawProtrude(_dispBuf);
1126
+ applyLowerJawProtrude(_dispBuf);
1020
1127
  applyMouthAnchors(_dispBuf);
1021
1128
  applyEyeAnchors(_dispBuf);
1022
1129
  // write final positions
@@ -1026,12 +1133,20 @@
1026
1133
  _posBuf[3*i+2] = baseVertices[i].z + _dispBuf[i].z;
1027
1134
  }
1028
1135
  mesh.updateVerticesData(BABYLON.VertexBuffer.PositionKind, _posBuf);
1029
- // depth fade colors
1136
+ // depth fade colors. raw t = (zMax - z) / zRange, then exponentiated by
1137
+ // depthFadeCurve. >1 darkens back faster (so silhouette edges actually
1138
+ // hit fadeColor in wire mode despite line interpolation lifting them);
1139
+ // <1 brightens back. Then scaled by depthFade.
1030
1140
  if (config.depthFade > 0.001) {
1031
- const zRange = (_zMax - _zMin) || 1, f = config.depthFade;
1141
+ const zRange = (_zMax - _zMin) || 1;
1142
+ const f = config.depthFade;
1143
+ const curve = config.depthFadeCurve > 0 ? config.depthFadeCurve : 1;
1032
1144
  for (let i = 0; i < baseVertices.length; i++) {
1033
1145
  const z = _posBuf[3*i + 2];
1034
- const t = Math.max(0, Math.min(1, (_zMax - z) / zRange)) * f;
1146
+ let t = (_zMax - z) / zRange;
1147
+ if (t < 0) t = 0; else if (t > 1) t = 1;
1148
+ if (curve !== 1) t = Math.pow(t, curve);
1149
+ t *= f;
1035
1150
  _colBuf[4*i ] = _baseRGB[0] * (1 - t) + _fadeRGB[0] * t;
1036
1151
  _colBuf[4*i+1] = _baseRGB[1] * (1 - t) + _fadeRGB[1] * t;
1037
1152
  _colBuf[4*i+2] = _baseRGB[2] * (1 - t) + _fadeRGB[2] * t;
@@ -1247,10 +1362,44 @@
1247
1362
  }
1248
1363
  }
1249
1364
 
1250
- /* ── color application ── */
1365
+ /* ── color application ──
1366
+ Per-feature mouth/eye/nose materials inherit lineColor when their
1367
+ per-feature override is null. So applyLineColor pushes into all three
1368
+ inheriting materials; the per-feature setters override that. */
1251
1369
  function applyLineColor(hex) {
1252
1370
  config.lineColor = hex;
1253
- minimalMat.emissiveColor = BABYLON.Color3.FromHexString(hex);
1371
+ const c = BABYLON.Color3.FromHexString(hex);
1372
+ if (!config.mouthColor) mouthMat.emissiveColor = c;
1373
+ if (!config.eyeColor) eyeMat.emissiveColor = c;
1374
+ if (!config.noseColor) noseMat.emissiveColor = c;
1375
+ }
1376
+ function applyMouthColor(hex) {
1377
+ config.mouthColor = hex;
1378
+ mouthMat.emissiveColor = BABYLON.Color3.FromHexString(hex || config.lineColor);
1379
+ }
1380
+ function applyEyeColor(hex) {
1381
+ config.eyeColor = hex;
1382
+ eyeMat.emissiveColor = BABYLON.Color3.FromHexString(hex || config.lineColor);
1383
+ }
1384
+ function applyNoseColor(hex) {
1385
+ config.noseColor = hex;
1386
+ noseMat.emissiveColor = BABYLON.Color3.FromHexString(hex || config.lineColor);
1387
+ }
1388
+ function applyBrowColor(hex) {
1389
+ config.browColor = hex;
1390
+ browMat.emissiveColor = BABYLON.Color3.FromHexString(hex);
1391
+ }
1392
+ /* per-feature visibility — independent of master `minimal` (which still
1393
+ hides the whole minimalGroup). Each feature toggles its own meshes. */
1394
+ function applyMinimalSubVisibility() {
1395
+ const setVis = (m, v) => { if (m) m.isVisible = v; };
1396
+ setVis(mouthUpperMesh, !!config.minimalMouth);
1397
+ setVis(mouthLowerMesh, !!config.minimalMouth);
1398
+ for (const em of eyeMeshes) { setVis(em.upper, !!config.minimalEyes); setVis(em.lower, !!config.minimalEyes); }
1399
+ for (const bm of browMeshes) setVis(bm.mesh, !!config.minimalBrows);
1400
+ setVis(noseBridgeMesh, !!config.minimalNose);
1401
+ setVis(noseLeftMesh, !!config.minimalNose);
1402
+ setVis(noseRightMesh, !!config.minimalNose);
1254
1403
  }
1255
1404
  function applyPupilColor(hex) {
1256
1405
  config.pupilColor = hex;
@@ -1272,10 +1421,6 @@
1272
1421
  config.irisColor = hex;
1273
1422
  if (irisMat) irisMat.emissiveColor = BABYLON.Color3.FromHexString(hex);
1274
1423
  }
1275
- function applyBrowColor(hex) {
1276
- config.browColor = hex;
1277
- browMat.emissiveColor = BABYLON.Color3.FromHexString(hex);
1278
- }
1279
1424
 
1280
1425
  /* ── views ── */
1281
1426
  const VIEWS = {
@@ -1307,8 +1452,12 @@
1307
1452
  applyFadeColor(config.fadeColor);
1308
1453
  applyLineColor(config.lineColor);
1309
1454
  applyBrowColor(config.browColor);
1455
+ if (config.mouthColor) applyMouthColor(config.mouthColor);
1456
+ if (config.eyeColor) applyEyeColor(config.eyeColor);
1457
+ if (config.noseColor) applyNoseColor(config.noseColor);
1310
1458
  applyPupilColor(config.pupilColor);
1311
1459
  applyIrisColor(config.irisColor);
1460
+ applyMinimalSubVisibility();
1312
1461
  applyGlow();
1313
1462
  setView(config.cameraView);
1314
1463
 
@@ -1345,6 +1494,15 @@
1345
1494
  if (rc.eyeHoleSize !== undefined && rc.eyeHoleSize !== config.eyeHoleSize) needRebuild = true;
1346
1495
  if (rc.eyeDepth !== undefined && rc.eyeDepth !== config.eyeDepth) needRebuild = true;
1347
1496
 
1497
+ // any per-feature thickness change requires rebuilding the affected
1498
+ // tubes (CreateTube radius is fixed at construction)
1499
+ const featureThicknessChanged =
1500
+ rc.lineThickness !== undefined ||
1501
+ rc.mouthLineThickness !== undefined ||
1502
+ rc.eyeLineThickness !== undefined ||
1503
+ rc.noseLineThickness !== undefined ||
1504
+ rc.browLineThickness !== undefined;
1505
+
1348
1506
  Object.assign(config, rc);
1349
1507
  if (p.lineColor) applyLineColor(p.lineColor);
1350
1508
  if (p.pupilColor) applyPupilColor(p.pupilColor);
@@ -1354,6 +1512,9 @@
1354
1512
  if (rc.pupilColor) applyPupilColor(rc.pupilColor);
1355
1513
  if (rc.irisColor) applyIrisColor(rc.irisColor);
1356
1514
  if (rc.browColor) applyBrowColor(rc.browColor);
1515
+ if (rc.mouthColor !== undefined) applyMouthColor(rc.mouthColor);
1516
+ if (rc.eyeColor !== undefined) applyEyeColor(rc.eyeColor);
1517
+ if (rc.noseColor !== undefined) applyNoseColor(rc.noseColor);
1357
1518
 
1358
1519
  if (needRebuild) {
1359
1520
  rebuildMesh();
@@ -1365,10 +1526,15 @@
1365
1526
  applyFaceFlip();
1366
1527
  applyMeshVisibility();
1367
1528
  applyMinimalVisibility();
1368
- if (rc.lineThickness !== undefined) rebuildMinimalLines();
1529
+ if (featureThicknessChanged) rebuildMinimalLines();
1369
1530
  if (rc.irisSize !== undefined || rc.pupils !== undefined) rebuildPupils();
1370
1531
  if (rc.lipVertAmp !== undefined || rc.lipPressForce !== undefined) identifyAnchorRings();
1371
1532
  }
1533
+ // per-feature visibility toggles always apply (cheap; no rebuild)
1534
+ if (rc.minimalMouth !== undefined || rc.minimalEyes !== undefined ||
1535
+ rc.minimalNose !== undefined || rc.minimalBrows !== undefined) {
1536
+ applyMinimalSubVisibility();
1537
+ }
1372
1538
  if (rc.glow !== undefined) applyGlow();
1373
1539
  // channel gains
1374
1540
  if (p.channelGains) {