@plupin/character 0.3.0 → 0.5.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/dist/three.js CHANGED
@@ -3,37 +3,49 @@ import {
3
3
  BLOB_RADIUS,
4
4
  BLOB_SEAT,
5
5
  blobRadiusAt,
6
- buildBlobGeometry
7
- } from "./chunk-dpb0rnw9.js";
6
+ buildBlobGeometry,
7
+ buildFigureHeadGeometry,
8
+ buildFigureTorsoGeometry,
9
+ figureHeadMetrics,
10
+ figureHeadRadiusAt,
11
+ figureTorsoPoint,
12
+ figureTorsoRadiusAt,
13
+ figureTorsoSpan
14
+ } from "./chunk-x8f5p1qg.js";
8
15
  import {
9
16
  ANIME_FACE_SIZE,
10
17
  ANIME_FACE_UV,
11
18
  drawAnimeFace
12
- } from "./chunk-09c5tps4.js";
19
+ } from "./chunk-ewkkvpte.js";
13
20
  import {
21
+ BODY_PRESETS,
22
+ EMOTES,
14
23
  RAGDOLL_JOINTS,
15
24
  createRagdoll,
16
25
  emoteOf
17
- } from "./chunk-yd5zzkkg.js";
26
+ } from "./chunk-s083mv4f.js";
18
27
  import {
28
+ WEARABLES,
19
29
  hairVolume,
20
30
  isHairKey,
31
+ isWearKey,
21
32
  wearSlotOf
22
- } from "./chunk-60p135hw.js";
33
+ } from "./chunk-kf7f1tdx.js";
23
34
  import {
24
35
  boneSkin,
25
36
  clampBodyScale,
26
37
  clampPlupBody,
27
38
  nativePartOf,
28
39
  scaleBone
29
- } from "./chunk-sa2r1cxz.js";
40
+ } from "./chunk-phwn2cn7.js";
30
41
  import {
42
+ AUTHORED_CLIPS,
31
43
  RIGS,
32
44
  clipLift,
33
45
  mergePoses,
34
46
  resolvePose,
35
47
  sampleClip
36
- } from "./chunk-g1c0wdcj.js";
48
+ } from "./chunk-wryfx2sg.js";
37
49
  import {
38
50
  BODY_HEIGHT,
39
51
  BODY_SHAPES,
@@ -41,8 +53,9 @@ import {
41
53
  FACE_COLUMN,
42
54
  FACE_ROW,
43
55
  SKIN_PALETTE,
44
- faceStamp
45
- } from "./chunk-kber92gm.js";
56
+ faceStamp,
57
+ isHighResFace
58
+ } from "./chunk-nx2wbkfn.js";
46
59
  import {
47
60
  FACE_STAMP_PALETTE
48
61
  } from "./chunk-aa5nstet.js";
@@ -63,6 +76,7 @@ import {
63
76
  CanvasTexture as CanvasTexture2,
64
77
  CapsuleGeometry,
65
78
  Color as Color2,
79
+ CylinderGeometry as CylinderGeometry2,
66
80
  DoubleSide,
67
81
  Group as Group2,
68
82
  Mesh as Mesh2,
@@ -112,6 +126,26 @@ import {
112
126
  TorusGeometry,
113
127
  Vector2
114
128
  } from "three";
129
+ var DEFAULT_ZONES = {
130
+ bottomY: 0.04,
131
+ hipY: 0.14,
132
+ waistY: 0.26,
133
+ bustY: 0.36,
134
+ shoulderY: 0.42,
135
+ neckY: 0.28
136
+ };
137
+ function zonesOf(kit) {
138
+ return kit.zones ?? DEFAULT_ZONES;
139
+ }
140
+ function surfaceOf(kit) {
141
+ if (kit.surfaceAt)
142
+ return kit.surfaceAt;
143
+ const R = kit.radiusAt;
144
+ return (y, phi, grow = 0) => {
145
+ const r = R(y) + grow;
146
+ return { x: Math.sin(phi) * r, z: Math.cos(phi) * r * DEPTH };
147
+ };
148
+ }
115
149
  var DEPTH = BLOB_RADIUS.z / BLOB_RADIUS.x;
116
150
  var TOP = BLOB_HEIGHT;
117
151
  var EYES_Y = 0.53;
@@ -735,131 +769,179 @@ function bow(kit) {
735
769
  };
736
770
  });
737
771
  }
772
+ function fittedPatch(kit, from, to, grow, angle = (_y, t) => t * Math.PI * 2, rows = 20, columns = 48) {
773
+ const surf = surfaceOf(kit);
774
+ const positions = [];
775
+ const uvs = [];
776
+ const indices = [];
777
+ for (let i = 0;i <= rows; i += 1) {
778
+ const v = i / rows;
779
+ const y = from + (to - from) * v;
780
+ for (let j = 0;j <= columns; j += 1) {
781
+ const u = j / columns;
782
+ const phi = angle(y, u);
783
+ const g = typeof grow === "function" ? grow(v, phi) : grow;
784
+ const pt = surf(y, phi, g);
785
+ positions.push(pt.x, y, pt.z);
786
+ uvs.push(u, v);
787
+ }
788
+ }
789
+ for (let i = 0;i < rows; i += 1)
790
+ for (let j = 0;j < columns; j += 1) {
791
+ const a = i * (columns + 1) + j;
792
+ const b = a + columns + 1;
793
+ indices.push(a, a + 1, b, a + 1, b + 1, b);
794
+ }
795
+ const geometry = new BufferGeometry;
796
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
797
+ geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
798
+ geometry.setIndex(indices);
799
+ geometry.computeVertexNormals();
800
+ return geometry;
801
+ }
802
+ function aLineSkirtPatch(kit, bottom, top, flareOut, pleatCount, pleatAmp, rows = 10, columns = 64) {
803
+ const surf = surfaceOf(kit);
804
+ const z = zonesOf(kit);
805
+ const positions = [];
806
+ const uvs = [];
807
+ const indices = [];
808
+ for (let i = 0;i <= rows; i += 1) {
809
+ const v = i / rows;
810
+ const low = 1 - v;
811
+ const y = bottom + (top - bottom) * v;
812
+ for (let j = 0;j <= columns; j += 1) {
813
+ const u = j / columns;
814
+ const phi = u * Math.PI * 2;
815
+ const wPt = surf(top, phi, 0.022);
816
+ const hPt = surf(Math.max(z.hipY, bottom), phi, 0.028);
817
+ const bPt = surf(Math.max(y, z.bottomY), phi, 0.024);
818
+ const wR = Math.hypot(wPt.x, wPt.z);
819
+ const hR = Math.hypot(hPt.x, hPt.z);
820
+ const bR = Math.hypot(bPt.x, bPt.z);
821
+ const targetR = Math.max(bR, wR + (Math.max(hR - wR, 0.04) + flareOut) * low ** 0.85);
822
+ const phase = (phi / (Math.PI * 2) * pleatCount % 1 + 1) % 1;
823
+ const pleat = (Math.abs(phase * 2 - 1) - 0.5) * pleatAmp * low;
824
+ const r = targetR + pleat;
825
+ const baseR = bR || 1;
826
+ const scale = r / baseR;
827
+ positions.push(bPt.x * scale, y, bPt.z * scale);
828
+ uvs.push(u, v);
829
+ }
830
+ }
831
+ for (let i = 0;i < rows; i += 1)
832
+ for (let j = 0;j < columns; j += 1) {
833
+ const a = i * (columns + 1) + j;
834
+ const b = a + columns + 1;
835
+ indices.push(a, a + 1, b, a + 1, b + 1, b);
836
+ }
837
+ const geometry = new BufferGeometry;
838
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(positions), 3));
839
+ geometry.setAttribute("uv", new BufferAttribute(new Float32Array(uvs), 2));
840
+ geometry.setIndex(indices);
841
+ geometry.computeVertexNormals();
842
+ return geometry;
843
+ }
738
844
  function pleatedSkirt(kit) {
739
- const R = kit.radiusAt;
740
- return piece(kit, ({ add, keep, node }) => {
741
- const top = 0.31;
742
- const bottom = 0.03;
743
- const waist = R(top) + 0.018;
744
- const hem = R(0.12) + 0.12;
745
- const pleatsAround = 24;
746
- const geometry = new CylinderGeometry(waist, hem, top - bottom, pleatsAround * 4, 6, true);
845
+ const z = zonesOf(kit);
846
+ const surf = surfaceOf(kit);
847
+ return piece(kit, ({ add, keep }) => {
848
+ const top = kit.isFigure ? z.waistY + 0.02 : 0.25;
849
+ const bottom = kit.isFigure ? z.bottomY - 0.14 : 0.02;
850
+ const geometry = aLineSkirtPatch(kit, bottom, top, kit.isFigure ? 0.11 : 0.09, 22, 0.026, 10, 88);
747
851
  const position = geometry.attributes.position;
748
852
  const rest = Float32Array.from(position.array);
749
- const skirt = node({ at: [0, (top + bottom) / 2, 0], scale: [1, 1, DEPTH] });
750
- add(geometry, "#ffffff", { parent: skirt }, {
853
+ add(geometry, "#ffffff", {}, {
751
854
  map: keep(tartan("#c8323c", "#1b1f5e", "#f2d24b")),
752
855
  repeat: [6, 1.4],
753
856
  double: true,
754
857
  back: "#7d1d2a"
755
858
  });
756
- const trim = new TorusGeometry(hem, 0.012, 6, 96);
757
- const hemRing = add(trim, "#fbf8ff", { at: [0, -(top - bottom) / 2 + 0.002, 0], rotate: [Math.PI / 2, 0, 0], parent: skirt }, { outline: false });
758
- add(lathe([
759
- [waist - 0.004, top - 0.03],
760
- [waist + 0.012, top - 0.03],
761
- [waist + 0.012, top + 0.012],
762
- [waist - 0.004, top + 0.012]
763
- ], 64), "#1b1f5e", { scale: [1, 1, DEPTH] }, { outline: false });
764
- add(new SphereGeometry(0.018, 10, 8), "#f2c94c", { at: [0.09, top - 0.009, (waist + 0.004) * DEPTH] }, { sheen: 0.8, outline: false });
859
+ add(fittedPatch(kit, top - 0.032, top + 0.014, 0.028, (_y, t) => t * Math.PI * 2, 3, 48), "#1b1f5e", {}, { double: true, outline: false });
860
+ add(aLineSkirtPatch(kit, bottom, bottom + 0.028, kit.isFigure ? 0.114 : 0.094, 22, 0.026, 2, 88), "#fbf8ff", {}, { double: true, outline: false });
861
+ const frontBtn = surf(top - 0.008, 0.18, 0.034);
862
+ add(new SphereGeometry(0.016, 10, 8), "#f2c94c", { at: [frontBtn.x, top - 0.008, frontBtn.z] }, { sheen: 0.8, outline: false });
765
863
  const flare = new Spring(70, 6);
766
864
  const sway = new Spring(50, 5);
767
- const half = (top - bottom) / 2;
768
865
  return (clock, delta, raw) => {
769
866
  const motion = calm(raw);
770
- const out = flare.step(clamp(-motion.lift * 0.05, -0.04, 0.12), delta);
867
+ const out = flare.step(clamp(-motion.lift * 0.05, -0.04, 0.14), delta);
771
868
  const turn = sway.step(-motion.yaw * 0.05, delta);
772
869
  for (let i = 0;i < position.count; i += 1) {
773
870
  const x = rest[i * 3] ?? 0;
774
871
  const y = rest[i * 3 + 1] ?? 0;
775
- const z = rest[i * 3 + 2] ?? 0;
776
- const low = clamp((half - y) / (2 * half), 0, 1);
777
- const angle = Math.atan2(x, z);
778
- const phase = (angle / (Math.PI * 2) * pleatsAround % 1 + 1) % 1;
779
- const fold = 1 + (Math.abs(phase * 2 - 1) - 0.5) * 0.08 * low;
872
+ const z0 = rest[i * 3 + 2] ?? 0;
873
+ const low = clamp((top - y) / Math.max(0.05, top - bottom), 0, 1);
874
+ const angle = Math.atan2(x, z0);
780
875
  const spread = 1 + out * low * low;
781
876
  const lag = turn * low + Math.sin(clock * 2 + angle * 2) * 0.006 * low;
782
- const r = Math.hypot(x, z) * fold * spread;
877
+ const r = Math.hypot(x, z0) * spread;
783
878
  position.setXYZ(i, Math.sin(angle + lag) * r, y, Math.cos(angle + lag) * r);
784
879
  }
785
880
  position.needsUpdate = true;
786
881
  geometry.computeVertexNormals();
787
- hemRing.scale.setScalar(1 + out);
788
882
  };
789
883
  });
790
884
  }
791
885
  function tuxedo(kit) {
792
- const R = kit.radiusAt;
886
+ const z = zonesOf(kit);
887
+ const surf = surfaceOf(kit);
793
888
  return piece(kit, ({ add, keep, node }) => {
794
- const button = 0.15;
795
- const collar = 0.34;
796
- const open = (y) => y > button ? 0.16 + (y - button) / (collar - button) * 0.55 : 0.16 + (button - y) / button * 0.5;
797
- add(bodyPatch(R, 0.03, collar, 0.024, (y, t) => open(y) + t * (Math.PI * 2 - 2 * open(y))), "#1b1830", {}, { double: true, back: "#3b2a6b", sheen: 0.15 });
798
- add(bodyPatch(R, 0.05, collar - 0.01, 0.012, (y, t) => (t * 2 - 1) * (open(y) + 0.02), 18, 16), "#ffffff", {}, { map: keep(pleats()), repeat: [3, 1], outline: false });
889
+ const bottom = kit.isFigure ? z.hipY - 0.04 : 0.03;
890
+ const button = kit.isFigure ? z.waistY + 0.02 : 0.15;
891
+ const collar = kit.isFigure ? z.shoulderY + 0.04 : 0.34;
892
+ const bowY = kit.isFigure ? collar - 0.04 : COLLAR_Y;
893
+ const open = (y) => y > button ? 0.14 + (y - button) / Math.max(0.05, collar - button) * 0.52 : 0.14 + (button - y) / Math.max(0.05, button - bottom) * 0.42;
894
+ add(fittedPatch(kit, bottom, collar, 0.026, (y, t) => open(y) + t * (Math.PI * 2 - 2 * open(y))), "#1b1830", {}, { double: true, back: "#3b2a6b", sheen: 0.15 });
895
+ add(fittedPatch(kit, bottom + 0.02, collar - 0.01, 0.014, (y, t) => (t * 2 - 1) * (open(y) + 0.04), 16, 16), "#ffffff", {}, { map: keep(pleats()), repeat: [3, 1], outline: false });
799
896
  for (const side of [-1, 1])
800
- add(bodyPatch(R, button + 0.005, collar, 0.03, (y, t) => side * (open(y) + t * (0.05 + (y - button) / (collar - button) * 0.16)), 10, 4), "#3b3560", {}, { sheen: 0.6, double: true });
801
- const front = (y) => R(y) * DEPTH + 0.028;
897
+ add(fittedPatch(kit, button + 0.005, collar, 0.032, (y, t) => side * (open(y) + t * (0.05 + (y - button) / Math.max(0.05, collar - button) * 0.16)), 10, 4), "#3b3560", {}, { sheen: 0.6, double: true });
898
+ const frontZ = (y) => surf(y, 0, 0.028).z;
802
899
  const wing = new Shape;
803
- wing.moveTo(0, 0.012);
804
- wing.quadraticCurveTo(0.05, 0.05, 0.085, 0.04);
805
- wing.quadraticCurveTo(0.095, 0, 0.085, -0.04);
806
- wing.quadraticCurveTo(0.05, -0.05, 0, -0.012);
900
+ wing.moveTo(0, 0.01);
901
+ wing.quadraticCurveTo(0.042, 0.042, 0.072, 0.034);
902
+ wing.quadraticCurveTo(0.08, 0, 0.072, -0.034);
903
+ wing.quadraticCurveTo(0.042, -0.042, 0, -0.01);
807
904
  wing.closePath();
808
- const wingGeometry = slab(wing, 0.022, 0.008);
905
+ const wingGeometry = slab(wing, 0.018, 0.007);
809
906
  for (const side of [-1, 1])
810
907
  add(wingGeometry, "#14102e", {
811
- at: [side * 0.048, COLLAR_Y, front(COLLAR_Y) + 0.01],
908
+ at: [side * 0.042, bowY, frontZ(bowY) + 0.008],
812
909
  rotate: [0, side === 1 ? 0 : Math.PI, side * -0.06]
813
910
  }, { sheen: 0.55 });
814
- add(new SphereGeometry(0.024, 12, 10), "#2e2a4a", { at: [0, COLLAR_Y, front(COLLAR_Y) + 0.02], scale: [1, 1.2, 0.8] }, { sheen: 0.55 });
815
- const stud = new SphereGeometry(0.013, 10, 8);
816
- for (const y of [0.22, 0.18])
817
- add(stud, "#14102e", { at: [0, y, front(y) - 0.012] }, { sheen: 0.8, outline: false });
818
- add(new CylinderGeometry(0.02, 0.02, 0.01, 16), "#14102e", { at: [0, button, front(button) + 0.001], rotate: [Math.PI / 2, 0, 0] }, { sheen: 0.8 });
819
- const square = new Shape;
820
- square.moveTo(-0.035, 0);
821
- square.lineTo(-0.02, 0.04);
822
- square.lineTo(0, 0.02);
823
- square.lineTo(0.02, 0.045);
824
- square.lineTo(0.035, 0);
825
- square.closePath();
826
- const chest = 0.22;
827
- const chestAngle = 0.95;
828
- const reach = R(chest) + 0.03;
829
- add(slab(square, 0.006, 0.003), "#fbf8ff", {
830
- at: [Math.sin(chestAngle) * reach, chest, Math.cos(chestAngle) * reach * DEPTH],
831
- rotate: [0, chestAngle, 0]
832
- });
911
+ add(new SphereGeometry(0.02, 12, 10), "#2e2a4a", { at: [0, bowY, frontZ(bowY) + 0.016], scale: [1, 1.2, 0.8] }, { sheen: 0.55 });
912
+ add(new CylinderGeometry(0.018, 0.018, 0.01, 16), "#14102e", { at: [0, button, frontZ(button) + 0.002], rotate: [Math.PI / 2, 0, 0] }, { sheen: 0.8 });
833
913
  const tail = new Shape;
834
- tail.moveTo(-0.06, 0);
835
- tail.lineTo(0.06, 0);
836
- tail.quadraticCurveTo(0.07, -0.14, 0.035, -0.24);
837
- tail.lineTo(0, -0.2);
838
- tail.lineTo(-0.035, -0.24);
839
- tail.quadraticCurveTo(-0.07, -0.14, -0.06, 0);
914
+ tail.moveTo(-0.055, 0);
915
+ tail.lineTo(0.055, 0);
916
+ tail.quadraticCurveTo(0.065, -0.13, 0.032, -0.22);
917
+ tail.lineTo(0, -0.18);
918
+ tail.lineTo(-0.032, -0.22);
919
+ tail.quadraticCurveTo(-0.065, -0.13, -0.055, 0);
840
920
  const tailGeometry = slab(tail, 0.014, 0.006);
921
+ const backPt = surf(bottom + 0.06, Math.PI, 0.026);
841
922
  const tails = [-1, 1].map((side) => {
842
923
  const hang = node({
843
- at: [side * 0.08, 0.12, -(R(0.12) * DEPTH + 0.02)],
844
- rotate: [0, Math.PI + side * -0.2, 0]
924
+ at: [side * 0.07, bottom + 0.06, backPt.z],
925
+ rotate: [0, Math.PI + side * -0.18, 0]
845
926
  });
846
- add(tailGeometry, "#1b1830", { at: [0, -0.1, 0], parent: hang }, { sheen: 0.15 });
927
+ add(tailGeometry, "#1b1830", { at: [0, -0.09, 0], parent: hang }, { sheen: 0.15 });
847
928
  return { hang, spring: new Spring(60, 5), side };
848
929
  });
849
930
  return (clock, delta, raw) => {
850
931
  const motion = calm(raw);
851
932
  for (const t of tails) {
852
- const kick = t.spring.step(-0.15 + clamp(-motion.lift * 0.12, -0.3, 0.5) + Math.abs(motion.yaw) * 0.04, delta);
933
+ const kick = t.spring.step(-0.14 + clamp(-motion.lift * 0.12, -0.3, 0.5) + Math.abs(motion.yaw) * 0.04, delta);
853
934
  t.hang.rotation.x = kick + Math.sin(clock * 1.5 + t.side) * 0.02;
854
935
  }
855
936
  };
856
937
  });
857
938
  }
858
939
  function heroCape(kit) {
859
- const R = kit.radiusAt;
940
+ const z = zonesOf(kit);
941
+ const surf = surfaceOf(kit);
860
942
  return piece(kit, ({ add }) => {
861
- const top = 0.6;
862
- const bottom = 0;
943
+ const top = kit.isFigure ? z.shoulderY + 0.04 : 0.6;
944
+ const bottom = kit.isFigure ? -0.1 : 0;
863
945
  const across = Math.PI * 0.95;
864
946
  const columns = 22;
865
947
  const rows = 14;
@@ -887,11 +969,12 @@ function heroCape(kit) {
887
969
  const u = j / columns;
888
970
  const angle = Math.PI - across / 2 + across * u + lag * v * v;
889
971
  const ripple = Math.sin(u * 9 + clock * 2.4) * 0.025 * v * v;
890
- const r = R(Math.max(y, 0.2)) + 0.045 + v * 0.16 + out * v * v + ripple;
972
+ const sampleY = Math.max(y, z.hipY);
973
+ const pt = surf(sampleY, angle, 0.045 + v * 0.16 + out * v * v + ripple);
891
974
  const k = (i * (columns + 1) + j) * 3;
892
- positions[k] = Math.sin(angle) * r;
975
+ positions[k] = pt.x;
893
976
  positions[k + 1] = y + out * v * v * 0.1;
894
- positions[k + 2] = Math.cos(angle) * r * DEPTH;
977
+ positions[k + 2] = pt.z;
895
978
  }
896
979
  }
897
980
  geometry.attributes.position.needsUpdate = true;
@@ -899,11 +982,11 @@ function heroCape(kit) {
899
982
  };
900
983
  drape(0, 0, 0);
901
984
  add(geometry, "#c8323c", {}, { double: true, back: "#f2c94c", sheen: 0.2 });
902
- add(bodyPatch(R, top - 0.04, top + 0.07, 0.05, (_y, t) => Math.PI * 0.42 + t * (Math.PI * 2 - Math.PI * 0.84), 3, 24), "#9e1f2c", {}, { double: true, back: "#f2c94c" });
985
+ add(fittedPatch(kit, top - 0.04, top + 0.06, 0.045, (_y, t) => Math.PI * 0.42 + t * (Math.PI * 2 - Math.PI * 0.84), 3, 24), "#9e1f2c", {}, { double: true, back: "#f2c94c" });
903
986
  const clasp = new Shape;
904
987
  for (let i = 0;i < 10; i += 1) {
905
988
  const a = i / 10 * Math.PI * 2;
906
- const r = i % 2 ? 0.022 : 0.045;
989
+ const r = i % 2 ? 0.02 : 0.04;
907
990
  if (i === 0)
908
991
  clasp.moveTo(Math.sin(a) * r, Math.cos(a) * r);
909
992
  else
@@ -912,12 +995,9 @@ function heroCape(kit) {
912
995
  clasp.closePath();
913
996
  const star = slab(clasp, 0.012, 0.005);
914
997
  for (const side of [-1, 1]) {
915
- const angle = side * (Math.PI / 2 - 0.15);
916
- const r = R(top - 0.02) + 0.05;
917
- add(star, "#f2c94c", {
918
- at: [Math.sin(angle) * r, top - 0.02, Math.cos(angle) * r * DEPTH],
919
- rotate: [0, angle, 0]
920
- }, { sheen: 0.85 });
998
+ const angle = side * (Math.PI / 2 - 0.22);
999
+ const pt = surf(top - 0.02, angle, 0.04);
1000
+ add(star, "#f2c94c", { at: [pt.x, top - 0.02, pt.z], rotate: [0, angle, 0] }, { sheen: 0.85 });
921
1001
  }
922
1002
  const flare = new Spring(40, 4);
923
1003
  const trail = new Spring(35, 4);
@@ -929,24 +1009,23 @@ function heroCape(kit) {
929
1009
  });
930
1010
  }
931
1011
  function scarf(kit) {
932
- const R = kit.radiusAt;
1012
+ const z = zonesOf(kit);
1013
+ const surf = surfaceOf(kit);
933
1014
  return piece(kit, ({ add, keep, node }) => {
934
1015
  const wool = keep(knit("#e2574c", "#fbf8ff"));
935
- const ring = R(COLLAR_Y) + 0.03;
936
- add(new TorusGeometry(ring, 0.058, 14, 64), "#ffffff", { at: [0, COLLAR_Y, 0], rotate: [Math.PI / 2, 0, 0], scale: [1, DEPTH, 1.05] }, { map: wool, repeat: [14, 1] });
937
- const knotAngle = 0.55;
938
- const knotAt = [
939
- Math.sin(knotAngle) * (ring + 0.03),
940
- COLLAR_Y - 0.01,
941
- Math.cos(knotAngle) * (ring + 0.03) * DEPTH
942
- ];
943
- add(new SphereGeometry(0.06, 16, 12), "#ffffff", { at: knotAt, scale: [1, 0.85, 0.75] }, { map: wool, repeat: [3, 1] });
944
- const strip = new CylinderGeometry(0.05, 0.055, 0.26, 12, 6);
1016
+ const y = kit.isFigure ? z.neckY - 0.03 : COLLAR_Y;
1017
+ const r = Math.max(0.11, kit.radiusAt(y)) + 0.025;
1018
+ add(new TorusGeometry(r, kit.isFigure ? 0.048 : 0.058, 14, 64), "#ffffff", { at: [0, y, 0], rotate: [Math.PI / 2, 0, 0], scale: [1, DEPTH, 1.05] }, { map: wool, repeat: [14, 1] });
1019
+ const knotAngle = 0.52;
1020
+ const knotPt = surf(y, knotAngle, 0.045);
1021
+ const knotAt = [knotPt.x, y - 0.01, knotPt.z];
1022
+ add(new SphereGeometry(0.05, 16, 12), "#ffffff", { at: knotAt, scale: [1, 0.85, 0.75] }, { map: wool, repeat: [3, 1] });
1023
+ const strip = new CylinderGeometry(0.046, 0.05, 0.26, 12, 6);
945
1024
  strip.scale(1, 1, 0.35);
946
- const fringe = new CylinderGeometry(0.006, 0.004, 0.04, 5);
1025
+ const fringeGeo = new CylinderGeometry(0.006, 0.004, 0.04, 5);
947
1026
  const tails = [
948
1027
  { x: -0.01, tilt: 0.12, length: 1 },
949
- { x: 0.045, tilt: -0.05, length: 0.82 }
1028
+ { x: 0.042, tilt: -0.05, length: 0.82 }
950
1029
  ].map(({ x, tilt, length }) => {
951
1030
  const hang = node({
952
1031
  at: [knotAt[0] + x, knotAt[1] - 0.02, knotAt[2] + 0.02],
@@ -954,7 +1033,7 @@ function scarf(kit) {
954
1033
  });
955
1034
  add(strip, "#ffffff", { at: [0, -0.13 * length, 0], scale: [1, length, 1], parent: hang }, { map: wool, repeat: [2, 2] });
956
1035
  for (let i = 0;i < 5; i += 1)
957
- add(fringe, "#e2574c", { at: [-0.04 + i * 0.02, -0.26 * length - 0.02, 0], parent: hang }, { outline: false });
1036
+ add(fringeGeo, "#e2574c", { at: [-0.036 + i * 0.018, -0.26 * length - 0.02, 0], parent: hang }, { outline: false });
958
1037
  return { hang, tilt, spring: new Spring(55, 5, tilt) };
959
1038
  });
960
1039
  return (clock, delta, raw) => {
@@ -966,6 +1045,250 @@ function scarf(kit) {
966
1045
  };
967
1046
  });
968
1047
  }
1048
+ function ribbonDress(kit) {
1049
+ const z = zonesOf(kit);
1050
+ const surf = surfaceOf(kit);
1051
+ return piece(kit, ({ add, keep, node }) => {
1052
+ const bodiceTop = kit.isFigure ? z.bustY + 0.09 : 0.36;
1053
+ const waist = kit.isFigure ? z.waistY : 0.24;
1054
+ const hem = kit.isFigure ? z.bottomY - 0.16 : 0.02;
1055
+ add(fittedPatch(kit, waist, bodiceTop, 0.028, (_y, t) => t * Math.PI * 2, 20, 56), "#ff6fa8", {}, { double: true, back: "#c43f76", sheen: 0.32 });
1056
+ add(fittedPatch(kit, bodiceTop - 0.022, bodiceTop + 0.008, 0.033, (_y, t) => t * Math.PI * 2, 2, 56), "#fff7fb", {}, { double: true, outline: false });
1057
+ if (kit.isFigure) {
1058
+ for (const side of [-1, 1]) {
1059
+ const shPt = surf(z.shoulderY, side * 1.15, 0.015);
1060
+ add(new SphereGeometry(0.055, 14, 12), "#fff7fb", { at: [shPt.x, z.shoulderY - 0.02, shPt.z], scale: [1.1, 0.85, 1] }, { sheen: 0.25 });
1061
+ }
1062
+ }
1063
+ add(fittedPatch(kit, waist - 0.026, waist + 0.024, 0.032, (_y, t) => t * Math.PI * 2, 3, 56), "#fff7fb", {}, { double: true, sheen: 0.45 });
1064
+ const frontW = surf(waist, 0, 0.04);
1065
+ const bowNode = node({ at: [frontW.x, waist, frontW.z] });
1066
+ const loopGeo = new TorusGeometry(0.038, 0.013, 10, 20);
1067
+ for (const side of [-1, 1])
1068
+ add(loopGeo, "#ff3d8b", {
1069
+ at: [side * 0.04, 0, 0],
1070
+ rotate: [0, 0, side * 0.3],
1071
+ scale: [1.15, 0.72, 0.55],
1072
+ parent: bowNode
1073
+ }, { sheen: 0.5 });
1074
+ add(new SphereGeometry(0.018, 10, 8), "#ff3d8b", { parent: bowNode }, { sheen: 0.5 });
1075
+ const skirtGeo = aLineSkirtPatch(kit, hem, waist, kit.isFigure ? 0.14 : 0.1, 16, 0.02, 10, 72);
1076
+ const pos = skirtGeo.attributes.position;
1077
+ const rest = Float32Array.from(pos.array);
1078
+ add(skirtGeo, "#ff6fa8", {}, {
1079
+ map: keep(dots("#ff7eb6", "#ffe3f0")),
1080
+ repeat: [8, 3],
1081
+ double: true,
1082
+ back: "#ffe8f3",
1083
+ sheen: 0.22
1084
+ });
1085
+ add(aLineSkirtPatch(kit, hem - 0.032, hem + 0.025, kit.isFigure ? 0.145 : 0.105, 22, 0.016, 3, 72), "#fffaff", {}, { double: true, outline: false });
1086
+ const flare = new Spring(65, 5.5);
1087
+ return (clock, delta, raw) => {
1088
+ const motion = calm(raw);
1089
+ const out = flare.step(clamp(-motion.lift * 0.06, -0.03, 0.15), delta);
1090
+ for (let i = 0;i < pos.count; i += 1) {
1091
+ const x = rest[i * 3] ?? 0;
1092
+ const y = rest[i * 3 + 1] ?? 0;
1093
+ const z0 = rest[i * 3 + 2] ?? 0;
1094
+ const low = clamp((waist - y) / Math.max(0.05, waist - hem), 0, 1);
1095
+ const a = Math.atan2(x, z0);
1096
+ const r = Math.hypot(x, z0) * (1 + out * low * low + Math.sin(clock * 2.2 + a * 3) * 0.008 * low);
1097
+ pos.setXYZ(i, Math.sin(a) * r, y, Math.cos(a) * r);
1098
+ }
1099
+ pos.needsUpdate = true;
1100
+ skirtGeo.computeVertexNormals();
1101
+ };
1102
+ });
1103
+ }
1104
+ function cropHoodie(kit) {
1105
+ const z = zonesOf(kit);
1106
+ const surf = surfaceOf(kit);
1107
+ return piece(kit, ({ add, node }) => {
1108
+ const bottom = kit.isFigure ? z.waistY + 0.06 : 0.2;
1109
+ const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
1110
+ add(fittedPatch(kit, bottom, top, (v) => 0.03 + (1 - v) * 0.012, (_y, t) => t * Math.PI * 2, 18, 56), "#d8b8ff", {}, { double: true, back: "#8f6ec4", sheen: 0.1 });
1111
+ add(fittedPatch(kit, bottom - 0.022, bottom + 0.012, 0.036, (_y, t) => t * Math.PI * 2, 3, 56), "#fffaff", {}, { double: true, outline: false });
1112
+ const neckY = kit.isFigure ? z.neckY - 0.02 : top;
1113
+ const backPt = surf(neckY, Math.PI, 0.05);
1114
+ add(new SphereGeometry(kit.isFigure ? 0.12 : 0.16, 16, 12), "#c69eff", { at: [0, neckY - 0.01, backPt.z - 0.05], scale: [1.35, 0.72, 0.95] }, { sheen: 0.1 });
1115
+ if (kit.isFigure) {
1116
+ add(fittedPatch(kit, z.bottomY - 0.02, z.hipY + 0.09, 0.024, (_y, t) => t * Math.PI * 2, 12, 56), "#2c2448", {}, { double: true });
1117
+ }
1118
+ const frontNeck = surf(top - 0.02, 0, 0.04);
1119
+ const strings = [-1, 1].map((side) => {
1120
+ const hang = node({ at: [side * 0.042, top - 0.02, frontNeck.z] });
1121
+ add(new CylinderGeometry(0.008, 0.008, 0.14, 8), "#fffaff", { at: [0, -0.07, 0], parent: hang }, { outline: false });
1122
+ add(new SphereGeometry(0.013, 8, 8), "#ff7eb8", { at: [0, -0.14, 0], parent: hang }, { outline: false });
1123
+ return { hang, side, spring: new Spring(60, 4.5) };
1124
+ });
1125
+ return (clock, delta, raw) => {
1126
+ const motion = calm(raw);
1127
+ for (const s of strings) {
1128
+ s.hang.rotation.z = s.spring.step(-motion.yaw * 0.04 + Math.sin(clock * 2.1 + s.side) * 0.05, delta);
1129
+ s.hang.rotation.x = clamp(motion.lift * 0.08, -0.25, 0.35);
1130
+ }
1131
+ };
1132
+ });
1133
+ }
1134
+ function idolSet(kit) {
1135
+ const z = zonesOf(kit);
1136
+ const surf = surfaceOf(kit);
1137
+ return piece(kit, ({ add, node }) => {
1138
+ const topBottom = kit.isFigure ? z.waistY + 0.05 : 0.24;
1139
+ const topHigh = kit.isFigure ? z.shoulderY + 0.05 : 0.38;
1140
+ const skirtTop = kit.isFigure ? z.waistY - 0.01 : 0.22;
1141
+ const skirtBot = kit.isFigure ? z.bottomY - 0.12 : 0.02;
1142
+ add(fittedPatch(kit, topBottom, topHigh, 0.028, (_y, t) => t * Math.PI * 2, 16, 56), "#ffffff", {}, { double: true, sheen: 0.2 });
1143
+ add(fittedPatch(kit, topHigh - 0.1, topHigh + 0.01, 0.034, (_y, t) => t * Math.PI * 2, 6, 56), "#1f2b6c", {}, { double: true });
1144
+ add(fittedPatch(kit, topHigh - 0.09, topHigh - 0.075, 0.038, (_y, t) => t * Math.PI * 2, 2, 56), "#ffd84d", {}, { double: true, outline: false, sheen: 0.7 });
1145
+ const chest = surf(topHigh - 0.09, 0, 0.045);
1146
+ const bow2 = node({ at: [0, topHigh - 0.09, chest.z] });
1147
+ const loop = new TorusGeometry(0.038, 0.013, 10, 20);
1148
+ for (const side of [-1, 1]) {
1149
+ add(loop, "#ff3b6b", { at: [side * 0.038, 0, 0], scale: [1.15, 0.75, 0.5], parent: bow2 }, { sheen: 0.45 });
1150
+ add(new CylinderGeometry(0.015, 0.022, 0.095, 8), "#ff3b6b", {
1151
+ at: [side * 0.024, -0.055, 0],
1152
+ rotate: [0, 0, side * 0.24],
1153
+ scale: [1, 1, 0.3],
1154
+ parent: bow2
1155
+ }, { outline: false });
1156
+ }
1157
+ add(aLineSkirtPatch(kit, skirtBot, skirtTop, kit.isFigure ? 0.11 : 0.085, 22, 0.02, 8, 72), "#1f2b6c", {}, { double: true, back: "#ff6fa8" });
1158
+ add(aLineSkirtPatch(kit, skirtBot + 0.016, skirtBot + 0.038, kit.isFigure ? 0.105 : 0.08, 22, 0.018, 2, 72), "#ffd84d", {}, { double: true, outline: false, sheen: 0.75 });
1159
+ return;
1160
+ });
1161
+ }
1162
+ function streetJacket(kit) {
1163
+ const z = zonesOf(kit);
1164
+ const surf = surfaceOf(kit);
1165
+ return piece(kit, ({ add }) => {
1166
+ const bottom = kit.isFigure ? z.hipY - 0.04 : 0.04;
1167
+ const top = kit.isFigure ? z.shoulderY + 0.06 : 0.39;
1168
+ if (kit.isFigure) {
1169
+ add(fittedPatch(kit, z.bottomY - 0.03, z.waistY + 0.02, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#161622", {}, { double: true });
1170
+ }
1171
+ add(fittedPatch(kit, bottom + 0.02, top - 0.01, 0.026, (_y, t) => t * Math.PI * 2, 16, 48), "#181726", {}, { double: true });
1172
+ const gap = 0.34;
1173
+ add(fittedPatch(kit, bottom, top, (v) => 0.04 + (1 - v) * 0.008, (_y, t) => gap + t * (Math.PI * 2 - gap * 2), 18, 48), "#2c2f48", {}, { double: true, back: "#ff4f7a", sheen: 0.25 });
1174
+ for (const side of [-1, 1]) {
1175
+ add(fittedPatch(kit, bottom, top, 0.045, (_y, t) => side * (gap + t * 0.08), 12, 3), "#ff4f7a", {}, { double: true, outline: false });
1176
+ }
1177
+ add(fittedPatch(kit, top - 0.02, top + 0.065, 0.042, (_y, t) => gap * 1.1 + t * (Math.PI * 2 - gap * 2.2), 4, 32), "#1b1d2e", {}, { double: true, back: "#ff4f7a" });
1178
+ const chainY = kit.isFigure ? z.bustY + 0.04 : top - 0.08;
1179
+ const bead = new SphereGeometry(0.011, 8, 8);
1180
+ for (let i = -5;i <= 5; i += 1) {
1181
+ const phi = i * 0.08;
1182
+ const drop = Math.cos(i / 5 * Math.PI * 0.5) * 0.065;
1183
+ const pt = surf(chainY - drop, phi, 0.036);
1184
+ add(bead, "#e4ebff", { at: [pt.x, chainY - drop, pt.z] }, { sheen: 0.9, outline: false });
1185
+ }
1186
+ return;
1187
+ });
1188
+ }
1189
+ function blazerCoat(kit) {
1190
+ const z = zonesOf(kit);
1191
+ const surf = surfaceOf(kit);
1192
+ return piece(kit, ({ add }) => {
1193
+ const bottom = kit.isFigure ? z.hipY - 0.05 : 0.03;
1194
+ const waist = kit.isFigure ? z.waistY + 0.02 : 0.18;
1195
+ const top = kit.isFigure ? z.shoulderY + 0.05 : 0.37;
1196
+ const vOpen = (y) => y > waist ? 0.1 + (y - waist) / Math.max(0.05, top - waist) * 0.45 : 0.06;
1197
+ if (kit.isFigure) {
1198
+ add(fittedPatch(kit, z.bottomY - 0.03, z.waistY, 0.022, (_y, t) => t * Math.PI * 2, 10, 48), "#1c223c", {}, { double: true });
1199
+ }
1200
+ add(fittedPatch(kit, bottom + 0.02, top, 0.024, (_y, t) => t * Math.PI * 2, 16, 48), "#f8f9ff", {}, { double: true, outline: false });
1201
+ add(fittedPatch(kit, bottom, top, 0.036, (y, t) => vOpen(y) + t * (Math.PI * 2 - 2 * vOpen(y)), 18, 48), "#232b4f", {}, { double: true, back: "#3c4a7d", sheen: 0.18 });
1202
+ for (const side of [-1, 1]) {
1203
+ add(fittedPatch(kit, waist, top, 0.041, (y, t) => side * (vOpen(y) + t * 0.09), 10, 3), "#f2c94c", {}, { double: true, outline: false, sheen: 0.75 });
1204
+ }
1205
+ add(fittedPatch(kit, waist - 0.02, top - 0.02, 0.034, (y, t) => {
1206
+ const w = y > top - 0.07 ? 0.08 : 0.12 - (y - waist) / Math.max(0.05, top - waist) * 0.05;
1207
+ return (t * 2 - 1) * w;
1208
+ }, 10, 6), "#d6354a", {}, { double: true });
1209
+ const btn = new SphereGeometry(0.014, 8, 8);
1210
+ for (const by of [waist, waist - 0.065]) {
1211
+ const pt = surf(by, 0.16, 0.042);
1212
+ add(btn, "#f2c94c", { at: [pt.x, by, pt.z] }, { sheen: 0.85, outline: false });
1213
+ }
1214
+ return;
1215
+ });
1216
+ }
1217
+ function brawlerVest(kit) {
1218
+ const z = zonesOf(kit);
1219
+ const surf = surfaceOf(kit);
1220
+ return piece(kit, ({ add }) => {
1221
+ const bottom = kit.isFigure ? z.waistY - 0.08 : 0.05;
1222
+ const top = kit.isFigure ? z.shoulderY + 0.03 : 0.36;
1223
+ if (kit.isFigure) {
1224
+ add(fittedPatch(kit, z.bottomY - 0.04, z.waistY - 0.02, 0.026, (_y, t) => t * Math.PI * 2, 12, 48), "#2b2538", {}, { double: true });
1225
+ }
1226
+ add(fittedPatch(kit, bottom, top, (v) => 0.028 + (v > 0.7 ? 0.008 : 0), (_y, t) => t * Math.PI * 2, 20, 56), "#232030", {}, { double: true, sheen: 0.12 });
1227
+ add(fittedPatch(kit, (top + bottom) * 0.54, (top + bottom) * 0.65, 0.036, (_y, t) => t * Math.PI * 2, 4, 56), "#ff5733", {}, { double: true, outline: false });
1228
+ const beltY = kit.isFigure ? z.waistY - 0.04 : 0.14;
1229
+ add(fittedPatch(kit, beltY - 0.028, beltY + 0.028, 0.036, (_y, t) => t * Math.PI * 2, 3, 48), "#4a2b1d", {}, { double: true });
1230
+ const bucklePt = surf(beltY, 0, 0.045);
1231
+ add(new CylinderGeometry(0.032, 0.032, 0.016, 6), "#ffd24a", { at: [bucklePt.x, beltY, bucklePt.z], rotate: [Math.PI / 2, 0, 0] }, { sheen: 0.85 });
1232
+ return;
1233
+ });
1234
+ }
1235
+ function martialGi(kit) {
1236
+ const z = zonesOf(kit);
1237
+ const surf = surfaceOf(kit);
1238
+ return piece(kit, ({ add, node }) => {
1239
+ const bottom = kit.isFigure ? z.bottomY - 0.03 : 0.03;
1240
+ const waist = kit.isFigure ? z.waistY - 0.02 : 0.16;
1241
+ const top = kit.isFigure ? z.shoulderY + 0.04 : 0.37;
1242
+ const vOpen = (y) => y > waist ? 0.08 + (y - waist) / Math.max(0.05, top - waist) * 0.44 : 0;
1243
+ add(fittedPatch(kit, bottom, top, (v) => 0.032 + (1 - v) * 0.014, (y, t) => vOpen(y) + t * (Math.PI * 2 - 2 * vOpen(y)), 20, 56), "#f4f1ea", {}, { double: true, back: "#d8d1c5" });
1244
+ for (const side of [-1, 1]) {
1245
+ add(fittedPatch(kit, waist, top, 0.038, (y, t) => side * (vOpen(y) + t * 0.1), 10, 3), "#1b2042", {}, { double: true, outline: false });
1246
+ }
1247
+ add(fittedPatch(kit, waist - 0.032, waist + 0.032, 0.042, (_y, t) => t * Math.PI * 2, 4, 48), "#181624", {}, { double: true });
1248
+ const knotPt = surf(waist, 0, 0.052);
1249
+ add(new SphereGeometry(0.038, 12, 10), "#181624", { at: [knotPt.x, waist, knotPt.z] });
1250
+ const tailGeo = new CylinderGeometry(0.022, 0.028, 0.22, 8);
1251
+ tailGeo.scale(1, 1, 0.3);
1252
+ const tails = [-1, 1].map((side) => {
1253
+ const hang = node({
1254
+ at: [knotPt.x + side * 0.028, waist - 0.02, knotPt.z + 0.008],
1255
+ rotate: [0.08, 0, side * 0.24]
1256
+ });
1257
+ add(tailGeo, "#181624", { at: [0, -0.1, 0], parent: hang });
1258
+ return { hang, side, spring: new Spring(55, 5) };
1259
+ });
1260
+ return (clock, delta, raw) => {
1261
+ const motion = calm(raw);
1262
+ for (const t of tails) {
1263
+ t.hang.rotation.z = t.spring.step(t.side * 0.24 - motion.yaw * 0.04 + Math.sin(clock * 2 + t.side) * 0.04, delta);
1264
+ }
1265
+ };
1266
+ });
1267
+ }
1268
+ function chibiOveralls(kit) {
1269
+ const z = zonesOf(kit);
1270
+ const surf = surfaceOf(kit);
1271
+ return piece(kit, ({ add }) => {
1272
+ const bottom = kit.isFigure ? z.bottomY - 0.02 : 0.03;
1273
+ const waist = kit.isFigure ? z.waistY + 0.02 : 0.22;
1274
+ const top = kit.isFigure ? z.shoulderY + 0.04 : 0.36;
1275
+ add(fittedPatch(kit, waist - 0.02, top, 0.014, (_y, t) => t * Math.PI * 2, 12, 48), "#fff3d9", {}, { double: true, outline: false });
1276
+ add(fittedPatch(kit, bottom, waist + 0.03, 0.022, (_y, t) => t * Math.PI * 2, 12, 48), "#5b8ff9", {}, { double: true, back: "#3d66bf" });
1277
+ add(fittedPatch(kit, waist, top - 0.05, 0.026, (_y, t) => (t * 2 - 1) * 0.55, 8, 12), "#5b8ff9", {}, { double: true });
1278
+ for (const side of [-1, 1]) {
1279
+ add(fittedPatch(kit, top - 0.07, top + 0.02, 0.028, (_y, t) => side * (0.36 + t * 0.2), 6, 4), "#5b8ff9", {}, { double: true, outline: false });
1280
+ const btnPt = surf(top - 0.07, side * 0.44, 0.034);
1281
+ add(new SphereGeometry(0.018, 10, 8), "#ffd84d", { at: [btnPt.x, top - 0.07, btnPt.z] }, { sheen: 0.85 });
1282
+ }
1283
+ const pockPt = surf(waist + 0.06, 0, 0.033);
1284
+ add(new CylinderGeometry(0.045, 0.045, 0.012, 12), "#ffd84d", {
1285
+ at: [pockPt.x, waist + 0.06, pockPt.z],
1286
+ rotate: [Math.PI / 2, 0, 0],
1287
+ scale: [1.1, 1, 0.85]
1288
+ }, { sheen: 0.4, outline: false });
1289
+ return;
1290
+ });
1291
+ }
969
1292
  function sunglasses(kit) {
970
1293
  const R = kit.radiusAt;
971
1294
  return piece(kit, ({ add, keep }) => {
@@ -1009,6 +1332,14 @@ var BUILDERS = {
1009
1332
  "party-hat": partyHat,
1010
1333
  halo,
1011
1334
  bow,
1335
+ "ribbon-dress": ribbonDress,
1336
+ "crop-hoodie": cropHoodie,
1337
+ "idol-set": idolSet,
1338
+ "street-jacket": streetJacket,
1339
+ "blazer-coat": blazerCoat,
1340
+ "brawler-vest": brawlerVest,
1341
+ "martial-gi": martialGi,
1342
+ "chibi-overalls": chibiOveralls,
1012
1343
  "pleated-skirt": pleatedSkirt,
1013
1344
  tuxedo,
1014
1345
  "hero-cape": heroCape,
@@ -1021,6 +1352,18 @@ function buildGarment(key, kit) {
1021
1352
 
1022
1353
  // src/hair3d.ts
1023
1354
  var SKULL = new Vector3(0, BLOB_SEAT + 0.08, 0);
1355
+ var hexCh = (hex, i) => Number.parseInt(hex.slice(1 + i * 2, 3 + i * 2), 16);
1356
+ var tintHex = (a, b, t) => `#${[0, 1, 2].map((i) => Math.max(0, Math.min(255, Math.round(hexCh(a, i) + (hexCh(b, i) - hexCh(a, i)) * t))).toString(16).padStart(2, "0")).join("")}`;
1357
+ function resolvePalette(base, override) {
1358
+ if (!override || !/^#[0-9a-f]{6}$/i.test(override))
1359
+ return base;
1360
+ return {
1361
+ color: override,
1362
+ tip: tintHex(override, "#fff0f8", 0.34),
1363
+ inner: tintHex(override, "#1c1238", 0.42),
1364
+ ring: base.ring ?? 1
1365
+ };
1366
+ }
1024
1367
  var anime = (p, ring = p.ring ?? 1) => ({
1025
1368
  anime: { center: [SKULL.x, SKULL.y, SKULL.z], ring, tip: p.tip, inner: p.inner }
1026
1369
  });
@@ -1032,7 +1375,7 @@ var UP = new Vector3(0, 1, 0);
1032
1375
  var FORWARD = new Vector3(0, 0, 1);
1033
1376
  function clump(points, width, thickness, tip = 1, twist = 0) {
1034
1377
  const curve = new CatmullRomCurve3(points, false, "centripetal");
1035
- const segments = 24;
1378
+ const segments = 22;
1036
1379
  const sides = 10;
1037
1380
  const positions = [];
1038
1381
  const along = [];
@@ -1059,13 +1402,15 @@ function clump(points, width, thickness, tip = 1, twist = 0) {
1059
1402
  depth.multiplyScalar(Math.cos(turn)).addScaledVector(across, -Math.sin(turn));
1060
1403
  across.copy(a);
1061
1404
  }
1062
- const s = Math.max(1 - tip, (1 - t) ** 0.8) * (1 + 0.45 * Math.sin(Math.min(1, t * 1.6) * Math.PI));
1405
+ const taper = Math.max(1 - tip, (1 - t) ** 0.72);
1406
+ const swell = 1 + 0.48 * Math.sin(Math.min(1, t * 1.45) * Math.PI);
1407
+ const s = taper * swell;
1063
1408
  for (let m = 0;m <= sides; m += 1) {
1064
1409
  const a = m / sides * Math.PI * 2;
1065
1410
  const c = Math.cos(a);
1066
1411
  const n = Math.sin(a);
1067
1412
  const w = c * width * s;
1068
- const d = n * thickness * s * (0.3 + 0.7 * Math.abs(n));
1413
+ const d = n * thickness * s * (0.38 + 0.62 * Math.abs(n));
1069
1414
  positions.push(p.x + across.x * w + depth.x * d, p.y + across.y * w + depth.y * d, p.z + across.z * w + depth.z * d);
1070
1415
  along.push(t);
1071
1416
  }
@@ -1087,7 +1432,7 @@ function clump(points, width, thickness, tip = 1, twist = 0) {
1087
1432
  }
1088
1433
  const geometry = new BufferGeometry2;
1089
1434
  geometry.setAttribute("position", new BufferAttribute2(new Float32Array(positions), 3));
1090
- geometry.setAttribute("along", new BufferAttribute2(Float32Array.from(along), 1));
1435
+ geometry.setAttribute("along", new BufferAttribute2(new Float32Array(along), 1));
1091
1436
  geometry.setIndex(indices);
1092
1437
  geometry.computeVertexNormals();
1093
1438
  return { geometry, along: Float32Array.from(along), root: points[0] ?? new Vector3 };
@@ -1113,20 +1458,24 @@ function swinger(made) {
1113
1458
  made.geometry.computeVertexNormals();
1114
1459
  };
1115
1460
  }
1116
- function cap(radius, front, back, grow, part = 0) {
1461
+ function cap(radius, front, back, grow, part = 0, partLift = 0.03) {
1117
1462
  const rows = 18;
1118
1463
  const columns = 56;
1119
1464
  const positions = [];
1465
+ const along = [];
1120
1466
  const indices = [];
1121
1467
  for (let i = 0;i <= rows; i += 1) {
1122
1468
  const s = i / rows;
1123
1469
  for (let j = 0;j <= columns; j += 1) {
1124
1470
  const phi = j / columns * Math.PI * 2;
1125
1471
  const facing = (1 + Math.cos(phi - part)) / 2;
1126
- const line = back + (front - back) * facing ** 1.5;
1127
- const y = TOP + 0.01 - s * (TOP + 0.01 - line);
1128
- const p = onHead(radius, phi, y, grow * (0.7 + 0.3 * Math.sin(s * Math.PI * 0.6 + 0.4)));
1129
- positions.push(p.x, p.y + grow * 0.5 * (1 - s), p.z);
1472
+ const line = back + (front - back) * facing ** 1.45;
1473
+ const y = TOP + 0.015 - s * (TOP + 0.015 - line);
1474
+ const dPart = Math.sin(phi - part);
1475
+ const lobe = Math.abs(dPart) * (1 - s * 0.65) * partLift;
1476
+ const p = onHead(radius, phi, y, grow * (0.78 + 0.32 * Math.sin(s * Math.PI * 0.72 + 0.25)) + lobe);
1477
+ positions.push(p.x, p.y + grow * 0.55 * (1 - s) + lobe * 0.65, p.z);
1478
+ along.push(s * 0.45);
1130
1479
  }
1131
1480
  }
1132
1481
  for (let i = 0;i < rows; i += 1)
@@ -1137,6 +1486,7 @@ function cap(radius, front, back, grow, part = 0) {
1137
1486
  }
1138
1487
  const geometry = new BufferGeometry2;
1139
1488
  geometry.setAttribute("position", new BufferAttribute2(new Float32Array(positions), 3));
1489
+ geometry.setAttribute("along", new BufferAttribute2(new Float32Array(along), 1));
1140
1490
  geometry.setIndex(indices);
1141
1491
  geometry.computeVertexNormals();
1142
1492
  return geometry;
@@ -1145,59 +1495,81 @@ function add(b, p, made) {
1145
1495
  b.add(made.geometry, p.color, {}, anime(p));
1146
1496
  return made;
1147
1497
  }
1148
- function base(b, radius, p, front, back, grow, part = 0) {
1149
- b.add(cap(radius, front, back, grow, part), p.color, {}, { ...anime(p), double: true });
1498
+ function base(b, radius, p, front, back, grow, part = 0, partLift = 0.036) {
1499
+ b.add(cap(radius, Math.min(front, 0.64), Math.min(back, 0.36), grow * 1.24, part, partLift), p.color, {}, { ...anime(p), double: true });
1150
1500
  }
1151
1501
  function fringe(b, radius, p, bangs, part = 0) {
1502
+ const wBoost = 1.2;
1503
+ const yShift = -0.04;
1152
1504
  for (const bang of bangs) {
1153
1505
  const sweep = bang.sweep ?? 0;
1154
- const root = onHead(radius, part + bang.at * 0.4, TOP - 0.02, 0.03);
1155
- const crest = onHead(radius, bang.at * 0.75 + sweep * 0.2, 0.86, 0.085);
1156
- const fall = onHead(radius, bang.at + sweep * 0.55, 0.75, 0.07);
1157
- const end = onHead(radius, bang.at + sweep, bang.length, 0.05);
1158
- const made = clump([root, crest, fall, end], bang.width, bang.width * 0.34, bang.blunt ? 0.55 : 1);
1506
+ const mid = bang.midSweep ?? sweep * 0.48;
1507
+ const lift = bang.lift ?? 0;
1508
+ const flick = bang.flick ?? 0;
1509
+ const rootPhi = part + (bang.at - part) * 0.34;
1510
+ const root = onHead(radius, rootPhi, TOP - 0.01, 0.065 + lift * 0.4);
1511
+ const crest = onHead(radius, part + (bang.at - part) * 0.7 + mid * 0.28, 0.87, 0.14 + lift);
1512
+ const fall = onHead(radius, bang.at + mid, 0.7 + yShift * 0.5, 0.115 + lift * 0.85);
1513
+ const end = onHead(radius, bang.at + sweep, bang.length + yShift, 0.075 + lift * 0.45 + flick);
1514
+ const made = clump([root, crest, fall, end], bang.width * wBoost, bang.width * wBoost * 0.38, bang.blunt ? 0.56 : 1, bang.twist ?? sweep * 0.55);
1159
1515
  add(b, p, made);
1160
1516
  }
1161
1517
  }
1162
- function sidelocks(b, radius, p, end, width = 0.075, blunt = false) {
1518
+ function sidelocks(b, radius, p, end, width = 0.09, {
1519
+ blunt = false,
1520
+ flick = 0,
1521
+ curlIn = 0.22
1522
+ } = {}) {
1163
1523
  for (const side of [-1, 1]) {
1164
- const skew = side > 0 ? 0.03 : 0;
1165
- for (const [phi, drop, w] of [
1166
- [0.9, 0, width],
1167
- [1.12, 0.07, width * 0.8]
1168
- ]) {
1524
+ const skew = side > 0 ? 0.045 : -0.02;
1525
+ const layers = [
1526
+ [0.82, 0, width, 0.095],
1527
+ [1.04, 0.09, width * 0.88, 0.105],
1528
+ [0.7, 0.14, width * 0.46, 0.088]
1529
+ ];
1530
+ for (const [phi, drop, w, out] of layers) {
1169
1531
  const y = end + drop + skew;
1532
+ const endOut = blunt ? 0.075 : 0.078 + flick;
1170
1533
  const path = [
1171
- onHead(radius, side * (phi - 0.3), TOP - 0.06, 0.04),
1172
- onHead(radius, side * phi, 0.78, 0.085),
1173
- onHead(radius, side * (phi + 0.02), 0.56, 0.07),
1174
- onHead(radius, side * (phi - 0.05), y + 0.1, 0.06),
1175
- onHead(radius, side * (phi - (blunt ? 0.05 : 0.17)), y, blunt ? 0.06 : 0.075)
1534
+ onHead(radius, side * (phi - 0.28), TOP - 0.04, 0.055),
1535
+ onHead(radius, side * (phi + 0.04), 0.79, out + 0.02),
1536
+ onHead(radius, side * (phi + 0.06), 0.54, out),
1537
+ onHead(radius, side * (phi - (blunt ? 0.03 : curlIn * 0.5)), y + 0.12, out * 0.88 + flick * 0.35),
1538
+ onHead(radius, side * (phi - (blunt ? 0.04 : curlIn)), y, endOut)
1176
1539
  ];
1177
- add(b, p, clump(path, w, w * 0.4, blunt ? 0.6 : 1, side * 0.5));
1540
+ add(b, p, clump(path, w, w * 0.4, blunt ? 0.58 : 1, side * (blunt ? 0.2 : 0.55)));
1178
1541
  }
1179
1542
  }
1180
1543
  }
1544
+ function crownTufts(b, radius, p, tufts) {
1545
+ for (const [phi, y, len, liftOut, w] of tufts) {
1546
+ const root = onHead(radius, phi, y, 0.05);
1547
+ const out = onHead(radius, phi, y, 1).sub(root).normalize();
1548
+ const mid = root.clone().addScaledVector(out, liftOut).add(new Vector3(Math.sin(phi + 0.6) * 0.05, len * 0.35, Math.cos(phi + 0.6) * 0.03));
1549
+ const tip = mid.clone().addScaledVector(out, liftOut * 0.85).add(new Vector3(Math.sin(phi + 1.1) * 0.08, -len * 0.45, Math.cos(phi + 1.1) * 0.05));
1550
+ add(b, p, clump([root, mid, tip], w, w * 0.42, 1, Math.sin(phi) * 0.5));
1551
+ }
1552
+ }
1181
1553
  function strays(b, radius, p, at) {
1182
1554
  for (const [phi, y, length] of at) {
1183
- const root = onHead(radius, phi, y, 0.06);
1555
+ const root = onHead(radius, phi, y, 0.075);
1184
1556
  const out = onHead(radius, phi, y, 1).sub(root).normalize();
1185
1557
  const path = [
1186
1558
  root,
1187
- root.clone().addScaledVector(out, 0.05).add(new Vector3(0, -length * 0.4, 0)),
1188
- root.clone().addScaledVector(out, 0.07).add(new Vector3(Math.sin(phi * 3) * 0.03, -length, 0))
1559
+ root.clone().addScaledVector(out, 0.065).add(new Vector3(Math.cos(phi) * 0.025, -length * 0.35, 0)),
1560
+ root.clone().addScaledVector(out, 0.1).add(new Vector3(Math.sin(phi * 3.1) * 0.055, -length, Math.cos(phi * 2.3) * 0.03))
1189
1561
  ];
1190
- add(b, p, clump(path, 0.02, 0.009));
1562
+ add(b, p, clump(path, 0.028, 0.012, 1, 0.4));
1191
1563
  }
1192
1564
  }
1193
- function ahoge(b, p, lean = 1) {
1194
- const crown2 = new Vector3(0.02 * lean, TOP + 0.02, -0.02);
1565
+ function ahoge(b, p, lean = 1, size = 1) {
1566
+ const crown2 = new Vector3(0.02 * lean, TOP + 0.035, -0.02);
1195
1567
  const made = clump([
1196
1568
  crown2,
1197
- crown2.clone().add(new Vector3(0.02 * lean, 0.11, 0.03)),
1198
- crown2.clone().add(new Vector3(0.07 * lean, 0.17, 0.07)),
1199
- crown2.clone().add(new Vector3(0.12 * lean, 0.14, 0.1))
1200
- ], 0.032, 0.014);
1569
+ crown2.clone().add(new Vector3(0.03 * lean * size, 0.13 * size, 0.03)),
1570
+ crown2.clone().add(new Vector3(0.09 * lean * size, 0.19 * size, 0.08)),
1571
+ crown2.clone().add(new Vector3(0.15 * lean * size, 0.14 * size, 0.11))
1572
+ ], 0.038 * size, 0.016 * size);
1201
1573
  add(b, p, made);
1202
1574
  const swing = swinger(made);
1203
1575
  const spring = new Spring(60, 3);
@@ -1211,34 +1583,37 @@ function back(b, radius, p, {
1211
1583
  from,
1212
1584
  end,
1213
1585
  width,
1214
- wave = 0.04,
1586
+ wave = 0.05,
1215
1587
  curl = 0.08,
1588
+ flick = 0,
1216
1589
  blunt = false,
1217
- layers = 1
1590
+ layers = 2,
1591
+ spread = 0.08
1218
1592
  }) {
1219
1593
  const made = [];
1220
- const step = (Math.PI * 2 - from * 2) / (count - 1);
1221
- for (let n = 0;n < count * layers; n += 1) {
1222
- const layer = Math.floor(n / count);
1223
- const i = n % count;
1594
+ const step = (Math.PI * 2 - from * 2) / Math.max(1, count - 1);
1595
+ for (let layer = 0;layer < layers; layer += 1) {
1224
1596
  const under = layer < layers - 1;
1225
- if (under && i === count - 1)
1226
- continue;
1227
- const phi = from + i * step + (under ? step / 2 : 0);
1228
- const vary = i * 7 % 5 / 5;
1229
- const reach = blunt ? end : end - vary * 0.06;
1230
- const steps = 5;
1231
- const path = [onHead(radius, phi * 0.85, TOP - 0.02, 0.03)];
1232
- for (let k = 1;k <= steps; k += 1) {
1233
- const t = k / steps;
1234
- const y = TOP - 0.06 - (TOP - 0.06 - reach) * t;
1235
- const s = Math.sin(t * Math.PI * 1.5 + i * 0.7) * wave;
1236
- const gap = 0.05 + 0.05 * Math.sin(Math.min(1, t * 2) * Math.PI * 0.5) + t * 0.02 - (under ? 0.018 : 0);
1237
- const turn = t > 0.8 ? (phi < Math.PI ? -curl : curl) * (t - 0.8) * 5 : 0;
1238
- path.push(onHead(radius, phi + s + turn, Math.max(0.03, y), gap));
1239
- }
1240
- const twist = (i % 3 === 0 ? 0.9 : i % 3 === 1 ? -0.5 : 0.2) * (blunt ? 0.3 : 1);
1241
- made.push(add(b, p, clump(path, width * (0.85 + vary * 0.3), width * 0.36, blunt ? 0.55 : 1, twist)));
1597
+ const nLocks = under ? Math.max(1, count - 1) : count;
1598
+ for (let i = 0;i < nLocks; i += 1) {
1599
+ const jitter = ((i * 17 + layer * 13) % 7 / 7 - 0.5) * 0.07;
1600
+ const phi = from + i * step + (under ? step / 2 : 0) + jitter;
1601
+ const vary = (i * 7 + layer * 3) % 5 / 5;
1602
+ const reach = blunt ? end : end + (under ? -0.05 : 0.06) - vary * (0.09 + Math.abs(flick) * 0.35);
1603
+ const steps = 6;
1604
+ const path = [onHead(radius, phi * 0.85, TOP - 0.015, 0.045)];
1605
+ for (let k = 1;k <= steps; k += 1) {
1606
+ const t = k / steps;
1607
+ const y = TOP - 0.04 - (TOP - 0.04 - reach) * t;
1608
+ const s = Math.sin(t * Math.PI * 1.65 + i * 0.85 + layer) * wave;
1609
+ const outFlick = t > 0.65 ? flick * ((t - 0.65) / 0.35) ** 1.4 : 0;
1610
+ const gap = spread + 0.06 * Math.sin(Math.min(1, t * 1.9) * Math.PI * 0.5) + t * 0.035 + outFlick - (under ? 0.022 : 0);
1611
+ const turn = t > 0.72 ? (phi < Math.PI ? -curl : curl) * ((t - 0.72) / 0.28) : 0;
1612
+ path.push(onHead(radius, phi + s + turn, y, gap));
1613
+ }
1614
+ const twist = (i % 3 === 0 ? 0.85 : i % 3 === 1 ? -0.55 : 0.25) * (blunt ? 0.25 : 1);
1615
+ made.push(add(b, p, clump(path, width * (0.86 + vary * 0.34) * (under ? 1.08 : 0.92), width * 0.38, blunt ? 0.56 : 1, twist)));
1616
+ }
1242
1617
  }
1243
1618
  return made;
1244
1619
  }
@@ -1259,43 +1634,54 @@ var together = (...ticks) => (clock, delta, motion) => {
1259
1634
  for (const tick of ticks)
1260
1635
  tick?.(clock, delta, motion);
1261
1636
  };
1262
- function tail(radius, phi, tieY, length, spread, count = 4) {
1637
+ function tail(radius, phi, tieY, length, spread, count = 5) {
1263
1638
  const paths = [];
1264
1639
  for (let i = 0;i < count; i += 1) {
1265
1640
  const k = i / Math.max(1, count - 1) - 0.5;
1266
1641
  const fan = k * spread;
1267
- const path = [onHead(radius, phi, tieY, 0.05)];
1268
- const steps = 6;
1269
- const reach = length * (1 - Math.abs(k) * 0.18);
1642
+ const path = [onHead(radius, phi, tieY, 0.06)];
1643
+ const steps = 7;
1644
+ const reach = length * (1 - Math.abs(k) * 0.2 + i * 3 % 3 * 0.05);
1270
1645
  for (let n = 1;n <= steps; n += 1) {
1271
1646
  const t = n / steps;
1272
- const y = tieY + 0.06 * Math.sin(t * Math.PI) - reach * t ** 1.25;
1273
- const gap = 0.12 + 0.12 * Math.sin(Math.min(1, t * 1.8) * Math.PI * 0.5) + Math.abs(k) * 0.05;
1274
- const s = Math.sin(t * Math.PI * 1.6) * 0.08;
1275
- path.push(onHead(radius, phi + fan * (0.4 + t) + s * Math.sign(phi || 1), Math.max(0.02, y), gap));
1647
+ const y = tieY + 0.08 * Math.sin(t * Math.PI) - reach * t ** 1.18;
1648
+ const gap = 0.14 + 0.14 * Math.sin(Math.min(1, t * 1.8) * Math.PI * 0.5) + Math.abs(k) * 0.06 + t * 0.04;
1649
+ const s = Math.sin(t * Math.PI * 1.7 + i * 0.5) * 0.1;
1650
+ path.push(onHead(radius, phi + fan * (0.45 + t) + s * Math.sign(phi || 1), y, gap));
1276
1651
  }
1277
1652
  paths.push(path);
1278
1653
  }
1279
1654
  return paths;
1280
1655
  }
1656
+ function ringlet(origin, length, spiralR, turns, dir) {
1657
+ const pts = [];
1658
+ const steps = 16;
1659
+ for (let k = 0;k <= steps; k += 1) {
1660
+ const t = k / steps;
1661
+ const a = t * turns * Math.PI * 2 * dir;
1662
+ const r = spiralR * (0.35 + 0.75 * Math.sin(t * Math.PI * 0.85));
1663
+ pts.push(new Vector3(origin.x + Math.cos(a) * r + dir * t * 0.08, origin.y - t * length, origin.z + Math.sin(a) * r + t * 0.04));
1664
+ }
1665
+ return pts;
1666
+ }
1281
1667
  function ribbon(b, at, facing, color, size = 1) {
1282
1668
  const node = b.node({ at: [at.x, at.y, at.z], rotate: [0, facing, 0], scale: [size, size, size] });
1283
- const loop = new TorusGeometry2(0.05, 0.017, 10, 24);
1669
+ const loop = new TorusGeometry2(0.052, 0.018, 10, 24);
1284
1670
  for (const side of [-1, 1]) {
1285
1671
  b.add(loop, color, {
1286
- at: [side * 0.055, 0.008, 0],
1672
+ at: [side * 0.056, 0.008, 0],
1287
1673
  rotate: [0, 0, side * 0.35],
1288
- scale: [1.15, 0.72, 0.6],
1674
+ scale: [1.18, 0.74, 0.62],
1289
1675
  parent: node
1290
1676
  });
1291
1677
  const end = clump([
1292
1678
  new Vector3(side * 0.01, -0.01, 0.01),
1293
- new Vector3(side * 0.035, -0.06, 0.012),
1294
- new Vector3(side * 0.03, -0.11, 0.008)
1295
- ], 0.022, 0.006, 0.5);
1679
+ new Vector3(side * 0.038, -0.065, 0.014),
1680
+ new Vector3(side * 0.034, -0.13, 0.008)
1681
+ ], 0.024, 0.006, 0.5);
1296
1682
  b.add(end.geometry, color, { parent: node });
1297
1683
  }
1298
- b.add(new SphereGeometry2(0.024, 12, 10), color, { scale: [1, 1, 0.8], parent: node });
1684
+ b.add(new SphereGeometry2(0.026, 12, 10), color, { scale: [1, 1, 0.82], parent: node });
1299
1685
  }
1300
1686
  function clip(b, at, tilt, color) {
1301
1687
  const node = b.node({ at: [at.x, at.y, at.z], rotate: [0, Math.atan2(at.x, at.z), tilt] });
@@ -1304,61 +1690,356 @@ function clip(b, at, tilt, color) {
1304
1690
  b.add(bar, color, { rotate: [0, 0, -0.45], parent: node }, { sheen: 0.5 });
1305
1691
  }
1306
1692
  var HAIR = {
1307
- "fluffy-bob": {
1308
- palette: { color: "#8a5236", tip: "#e7a874", inner: "#5c3640" },
1693
+ "wolf-cut": {
1694
+ palette: { color: "#1d1d2e", tip: "#565985", inner: "#11101d", ring: 0.95 },
1309
1695
  build(b, radius, p) {
1310
- base(b, radius, p, 0.7, 0.38, 0.05);
1311
- const made = back(b, radius, p, {
1696
+ base(b, radius, p, 0.74, 0.42, 0.068, -0.18, 0.045);
1697
+ fringe(b, radius, p, [
1698
+ {
1699
+ at: -0.68,
1700
+ length: 0.46,
1701
+ width: 0.13,
1702
+ sweep: -0.22,
1703
+ midSweep: -0.06,
1704
+ lift: 0.01,
1705
+ flick: 0.02
1706
+ },
1707
+ { at: -0.34, length: 0.54, width: 0.135, sweep: -0.18, midSweep: -0.05 },
1708
+ { at: 0.08, length: 0.55, width: 0.14, sweep: 0.24, midSweep: 0.12 },
1709
+ { at: 0.48, length: 0.52, width: 0.13, sweep: 0.28, midSweep: 0.12, lift: 0.01 },
1710
+ { at: 0.74, length: 0.45, width: 0.12, sweep: 0.24, flick: 0.025 },
1711
+ { at: -0.14, length: 0.5, width: 0.065, sweep: 0.22, midSweep: 0.08, lift: 0.028 },
1712
+ { at: 0.24, length: 0.53, width: 0.058, sweep: -0.28, midSweep: -0.12, lift: 0.032 },
1713
+ { at: -0.48, length: 0.58, width: 0.055, sweep: 0.16, lift: 0.024 }
1714
+ ], -0.18);
1715
+ sidelocks(b, radius, p, 0.22, 0.095, { flick: 0.065, curlIn: 0.04 });
1716
+ const upper = back(b, radius, p, {
1717
+ count: 14,
1718
+ from: 1,
1719
+ end: 0.42,
1720
+ width: 0.15,
1721
+ wave: 0.06,
1722
+ flick: 0.11,
1723
+ layers: 1,
1724
+ spread: 0.1
1725
+ });
1726
+ const nape = back(b, radius, p, {
1727
+ count: 12,
1728
+ from: 1.22,
1729
+ end: 0.06,
1730
+ width: 0.125,
1731
+ wave: 0.08,
1732
+ flick: 0.16,
1733
+ layers: 2,
1734
+ spread: 0.08
1735
+ });
1736
+ crownTufts(b, radius, p, [
1737
+ [-0.45, TOP - 0.03, 0.22, 0.09, 0.075],
1738
+ [0.32, TOP - 0.02, 0.24, 0.1, 0.08],
1739
+ [1.35, TOP - 0.08, 0.26, 0.11, 0.085],
1740
+ [-1.55, TOP - 0.07, 0.25, 0.1, 0.08],
1741
+ [2.5, TOP - 0.06, 0.24, 0.11, 0.085],
1742
+ [-2.6, TOP - 0.05, 0.22, 0.09, 0.075]
1743
+ ]);
1744
+ strays(b, radius, p, [
1745
+ [0.82, 0.72, 0.18],
1746
+ [-0.88, 0.74, 0.16],
1747
+ [1.75, 0.56, 0.2],
1748
+ [-1.9, 0.52, 0.18]
1749
+ ]);
1750
+ return hangs([...upper, ...nape]);
1751
+ }
1752
+ },
1753
+ "curtain-ikemen": {
1754
+ palette: { color: "#281e2c", tip: "#6e4e60", inner: "#17101c", ring: 1.05 },
1755
+ build(b, radius, p) {
1756
+ base(b, radius, p, 0.76, 0.44, 0.065, 0.04, 0.048);
1757
+ fringe(b, radius, p, [
1758
+ {
1759
+ at: -0.14,
1760
+ length: 0.5,
1761
+ width: 0.13,
1762
+ sweep: -0.34,
1763
+ midSweep: -0.22,
1764
+ lift: 0.025,
1765
+ twist: -0.4
1766
+ },
1767
+ { at: -0.44, length: 0.48, width: 0.14, sweep: -0.2, midSweep: -0.14, lift: 0.015 },
1768
+ { at: -0.74, length: 0.42, width: 0.12, sweep: -0.1, flick: 0.02 },
1769
+ {
1770
+ at: 0.18,
1771
+ length: 0.52,
1772
+ width: 0.135,
1773
+ sweep: 0.32,
1774
+ midSweep: 0.2,
1775
+ lift: 0.025,
1776
+ twist: 0.4
1777
+ },
1778
+ { at: 0.48, length: 0.48, width: 0.14, sweep: 0.22, midSweep: 0.14, lift: 0.015 },
1779
+ { at: 0.76, length: 0.43, width: 0.12, sweep: 0.12, flick: 0.02 },
1780
+ { at: -0.02, length: 0.56, width: 0.055, sweep: -0.18, midSweep: -0.28, lift: 0.036 },
1781
+ { at: 0.09, length: 0.58, width: 0.05, sweep: 0.14, midSweep: 0.22, lift: 0.034 }
1782
+ ], 0.04);
1783
+ sidelocks(b, radius, p, 0.3, 0.085, { flick: 0.03, curlIn: 0.12 });
1784
+ const locks = back(b, radius, p, {
1785
+ count: 15,
1786
+ from: 1.08,
1787
+ end: 0.28,
1788
+ width: 0.14,
1789
+ wave: 0.04,
1790
+ flick: 0.06,
1791
+ layers: 2,
1792
+ spread: 0.09
1793
+ });
1794
+ crownTufts(b, radius, p, [
1795
+ [-0.3, TOP - 0.02, 0.18, 0.08, 0.075],
1796
+ [0.36, TOP - 0.02, 0.19, 0.085, 0.075],
1797
+ [2.2, TOP - 0.06, 0.2, 0.08, 0.07]
1798
+ ]);
1799
+ return hangs(locks);
1800
+ }
1801
+ },
1802
+ "messy-fluff": {
1803
+ palette: { color: "#e0e7f8", tip: "#9fb4f0", inner: "#8c9ac4", ring: 1 },
1804
+ build(b, radius, p) {
1805
+ base(b, radius, p, 0.74, 0.44, 0.075, -0.22, 0.05);
1806
+ fringe(b, radius, p, [
1807
+ { at: -0.64, length: 0.52, width: 0.13, sweep: -0.16, lift: 0.015 },
1808
+ { at: -0.34, length: 0.5, width: 0.135, sweep: 0.12, midSweep: -0.06, lift: 0.01 },
1809
+ { at: -0.04, length: 0.53, width: 0.13, sweep: -0.18, midSweep: 0.04, lift: 0.02 },
1810
+ { at: 0.28, length: 0.49, width: 0.14, sweep: 0.18, midSweep: 0.06, lift: 0.015 },
1811
+ { at: 0.62, length: 0.52, width: 0.125, sweep: 0.22, lift: 0.015 },
1812
+ {
1813
+ at: -0.2,
1814
+ length: 0.47,
1815
+ width: 0.062,
1816
+ sweep: 0.26,
1817
+ midSweep: 0.1,
1818
+ lift: 0.038,
1819
+ flick: 0.02
1820
+ },
1821
+ {
1822
+ at: 0.18,
1823
+ length: 0.48,
1824
+ width: 0.06,
1825
+ sweep: -0.24,
1826
+ midSweep: -0.1,
1827
+ lift: 0.04,
1828
+ flick: 0.02
1829
+ },
1830
+ { at: 0.52, length: 0.55, width: 0.055, sweep: -0.12, lift: 0.032 }
1831
+ ], -0.22);
1832
+ sidelocks(b, radius, p, 0.34, 0.088, { flick: 0.07, curlIn: 0.02 });
1833
+ const locks = back(b, radius, p, {
1312
1834
  count: 15,
1313
1835
  from: 1,
1314
- end: 0.36,
1315
- width: 0.13,
1316
- wave: 0.02,
1317
- curl: 0.18,
1318
- layers: 2
1836
+ end: 0.3,
1837
+ width: 0.15,
1838
+ wave: 0.055,
1839
+ flick: 0.13,
1840
+ layers: 2,
1841
+ spread: 0.1
1319
1842
  });
1843
+ crownTufts(b, radius, p, [
1844
+ [-0.65, TOP - 0.03, 0.24, 0.11, 0.085],
1845
+ [-0.08, TOP - 0.01, 0.26, 0.12, 0.085],
1846
+ [0.52, TOP - 0.02, 0.25, 0.11, 0.085],
1847
+ [1.25, TOP - 0.06, 0.26, 0.12, 0.09],
1848
+ [-1.35, TOP - 0.06, 0.25, 0.11, 0.085],
1849
+ [2.3, TOP - 0.05, 0.26, 0.11, 0.085],
1850
+ [-2.4, TOP - 0.05, 0.24, 0.1, 0.08]
1851
+ ]);
1852
+ return together(ahoge(b, p, 1, 1.1), hangs(locks));
1853
+ }
1854
+ },
1855
+ "silky-layers": {
1856
+ palette: { color: "#f2cfb4", tip: "#ff9ec8", inner: "#b87a86", ring: 1.1 },
1857
+ build(b, radius, p) {
1858
+ base(b, radius, p, 0.72, 0.4, 0.065, 0.22, 0.042);
1320
1859
  fringe(b, radius, p, [
1321
- { at: -0.62, length: 0.69, width: 0.09, sweep: -0.1 },
1322
- { at: -0.36, length: 0.62, width: 0.12 },
1323
- { at: -0.1, length: 0.66, width: 0.1, sweep: 0.04 },
1324
- { at: 0.14, length: 0.6, width: 0.125, sweep: 0.06 },
1325
- { at: 0.4, length: 0.65, width: 0.1, sweep: 0.08 },
1326
- { at: 0.65, length: 0.7, width: 0.085, sweep: 0.12 }
1860
+ { at: -0.68, length: 0.44, width: 0.12, sweep: -0.14, lift: 0.01 },
1861
+ { at: -0.36, length: 0.56, width: 0.1, sweep: -0.06, lift: 0.008 },
1862
+ { at: -0.06, length: 0.57, width: 0.085, sweep: 0.08, lift: 0.015 },
1863
+ { at: 0.22, length: 0.55, width: 0.095, sweep: 0.1, lift: 0.01 },
1864
+ { at: 0.52, length: 0.52, width: 0.11, sweep: 0.16, lift: 0.012 },
1865
+ { at: 0.74, length: 0.42, width: 0.115, sweep: 0.14, lift: 0.01 },
1866
+ { at: -0.22, length: 0.53, width: 0.048, sweep: 0.12, lift: 0.028 },
1867
+ { at: 0.1, length: 0.52, width: 0.046, sweep: -0.14, lift: 0.03 }
1868
+ ], 0.22);
1869
+ sidelocks(b, radius, p, -0.08, 0.1, { curlIn: 0.24, flick: 0.02 });
1870
+ const midLayer = back(b, radius, p, {
1871
+ count: 14,
1872
+ from: 1.05,
1873
+ end: 0.18,
1874
+ width: 0.15,
1875
+ wave: 0.06,
1876
+ flick: 0.07,
1877
+ layers: 1,
1878
+ spread: 0.1
1879
+ });
1880
+ const longFlow = back(b, radius, p, {
1881
+ count: 16,
1882
+ from: 1.12,
1883
+ end: -0.95,
1884
+ width: 0.16,
1885
+ wave: 0.09,
1886
+ curl: 0.14,
1887
+ layers: 2,
1888
+ spread: 0.09
1889
+ });
1890
+ strays(b, radius, p, [
1891
+ [0.78, 0.68, 0.2],
1892
+ [-0.82, 0.65, 0.22],
1893
+ [1.6, 0.45, 0.22],
1894
+ [-1.7, 0.4, 0.2]
1327
1895
  ]);
1328
- sidelocks(b, radius, p, 0.28);
1896
+ clip(b, onHead(radius, 0.62, 0.82, 0.12), -0.35, "#ff7eb8");
1897
+ return together(ahoge(b, p, -1, 0.9), hangs([...midLayer, ...longFlow]));
1898
+ }
1899
+ },
1900
+ "ojou-curls": {
1901
+ palette: { color: "#eca8dc", tip: "#b596ff", inner: "#9e5c9c", ring: 1.15 },
1902
+ build(b, radius, p) {
1903
+ base(b, radius, p, 0.72, 0.4, 0.065, -0.2, 0.044);
1904
+ fringe(b, radius, p, [
1905
+ { at: -0.64, length: 0.5, width: 0.125, sweep: -0.14, lift: 0.01 },
1906
+ { at: -0.34, length: 0.55, width: 0.12, sweep: -0.08 },
1907
+ { at: -0.02, length: 0.54, width: 0.115, sweep: 0.12, lift: 0.014 },
1908
+ { at: 0.3, length: 0.55, width: 0.12, sweep: 0.16 },
1909
+ { at: 0.62, length: 0.5, width: 0.12, sweep: 0.18, lift: 0.01 },
1910
+ { at: 0.14, length: 0.51, width: 0.052, sweep: -0.16, lift: 0.028 }
1911
+ ], -0.2);
1912
+ sidelocks(b, radius, p, 0.14, 0.09, { curlIn: 0.26 });
1913
+ const backLocks = back(b, radius, p, {
1914
+ count: 15,
1915
+ from: 1.15,
1916
+ end: -0.22,
1917
+ width: 0.15,
1918
+ wave: 0.08,
1919
+ curl: 0.16,
1920
+ layers: 2,
1921
+ spread: 0.09
1922
+ });
1923
+ const curls = [];
1924
+ for (const side of [-1, 1]) {
1925
+ const origin = onHead(radius, side * 1.18, 0.58, 0.12);
1926
+ curls.push(add(b, p, clump(ringlet(origin, 0.92, 0.095, 2.3, side), 0.1, 0.062, 1, side * 1.2)));
1927
+ curls.push(add(b, p, clump(ringlet(origin.clone().add(new Vector3(side * 0.04, -0.04, -0.06)), 0.78, 0.08, 2, -side), 0.075, 0.045, 1, -side * 0.9)));
1928
+ }
1929
+ ribbon(b, onHead(radius, Math.PI, 0.84, 0.12), Math.PI, "#ffffff", 1.55);
1930
+ return together(ahoge(b, p, 1, 0.85), hangs([...backLocks, ...curls]));
1931
+ }
1932
+ },
1933
+ "side-braid": {
1934
+ palette: { color: "#a45e3d", tip: "#f4c27c", inner: "#663628", ring: 1.05 },
1935
+ build(b, radius, p) {
1936
+ base(b, radius, p, 0.72, 0.42, 0.064, 0.26, 0.042);
1937
+ fringe(b, radius, p, [
1938
+ { at: -0.62, length: 0.48, width: 0.12, sweep: -0.14 },
1939
+ { at: -0.32, length: 0.54, width: 0.125, sweep: -0.16, lift: 0.01 },
1940
+ { at: 0, length: 0.55, width: 0.12, sweep: -0.18, lift: 0.016 },
1941
+ { at: 0.34, length: 0.56, width: 0.115, sweep: 0.18 },
1942
+ { at: 0.64, length: 0.5, width: 0.115, sweep: 0.22 },
1943
+ { at: 0.15, length: 0.52, width: 0.052, sweep: -0.22, lift: 0.03 }
1944
+ ], 0.26);
1945
+ sidelocks(b, radius, p, 0.16, 0.085, { curlIn: 0.24 });
1946
+ const backLocks = back(b, radius, p, {
1947
+ count: 13,
1948
+ from: 1.2,
1949
+ end: 0.32,
1950
+ width: 0.14,
1951
+ wave: 0.04,
1952
+ curl: 0.14,
1953
+ layers: 2,
1954
+ spread: 0.08
1955
+ });
1956
+ const braidGroup = b.node();
1957
+ const segments = 9;
1958
+ const plaitGeo = new SphereGeometry2(0.085, 14, 12);
1959
+ for (let k = 0;k < segments; k += 1) {
1960
+ const t = k / (segments - 1);
1961
+ const phi = 1.65 - t * 0.85;
1962
+ const y = 0.54 - t * 0.92;
1963
+ const out = 0.11 + t * 0.09;
1964
+ const pos = onHead(radius, phi, Math.max(0.05, y), out);
1965
+ const sideOff = (k % 2 ? 1 : -1) * 0.034;
1966
+ const scale = 1.05 - t * 0.42;
1967
+ b.add(plaitGeo, p.color, {
1968
+ at: [pos.x + sideOff * 0.7, y, pos.z + sideOff * 0.5],
1969
+ rotate: [0.3, phi, (k % 2 ? 1 : -1) * 0.45],
1970
+ scale: [scale * 1.1, scale * 0.78, scale * 0.85],
1971
+ parent: braidGroup
1972
+ }, anime(p, 0.7));
1973
+ }
1974
+ const tiePos = onHead(radius, 0.82, 0.08, 0.2);
1975
+ tiePos.y = -0.34;
1976
+ ribbon(b, tiePos, 0.6, "#ff789e", 1.15);
1977
+ const braidTip = add(b, p, clump([
1978
+ tiePos.clone(),
1979
+ tiePos.clone().add(new Vector3(0.02, -0.16, 0.04)),
1980
+ tiePos.clone().add(new Vector3(-0.02, -0.3, 0.06))
1981
+ ], 0.085, 0.045, 1, 0.4));
1982
+ return together(ahoge(b, p, -1, 0.85), hangs([...backLocks, braidTip]));
1983
+ }
1984
+ },
1985
+ "fluffy-bob": {
1986
+ palette: { color: "#8a5236", tip: "#eab07c", inner: "#5a323e" },
1987
+ build(b, radius, p) {
1988
+ base(b, radius, p, 0.71, 0.38, 0.066, -0.12, 0.04);
1989
+ const made = back(b, radius, p, {
1990
+ count: 16,
1991
+ from: 0.96,
1992
+ end: 0.28,
1993
+ width: 0.15,
1994
+ wave: 0.03,
1995
+ curl: 0.22,
1996
+ layers: 2,
1997
+ spread: 0.095
1998
+ });
1999
+ fringe(b, radius, p, [
2000
+ { at: -0.64, length: 0.54, width: 0.12, sweep: -0.14, lift: 0.01 },
2001
+ { at: -0.34, length: 0.54, width: 0.135, sweep: -0.05 },
2002
+ { at: -0.04, length: 0.57, width: 0.125, sweep: 0.08, lift: 0.012 },
2003
+ { at: 0.26, length: 0.53, width: 0.135, sweep: 0.1 },
2004
+ { at: 0.58, length: 0.54, width: 0.12, sweep: 0.16, lift: 0.01 },
2005
+ { at: -0.18, length: 0.52, width: 0.055, sweep: 0.16, lift: 0.028 },
2006
+ { at: 0.14, length: 0.52, width: 0.05, sweep: -0.12, lift: 0.03 }
2007
+ ], -0.12);
2008
+ sidelocks(b, radius, p, 0.2, 0.095, { curlIn: 0.26 });
1329
2009
  strays(b, radius, p, [
1330
- [0.6, 0.86, 0.12],
1331
- [-1.5, 0.8, 0.14],
1332
- [2.4, 0.84, 0.12]
2010
+ [0.64, 0.84, 0.14],
2011
+ [-1.5, 0.78, 0.16],
2012
+ [2.3, 0.8, 0.14]
1333
2013
  ]);
1334
- clip(b, onHead(radius, 0.55, 0.8, 0.1), -0.4, "#ffd84d");
2014
+ clip(b, onHead(radius, 0.58, 0.78, 0.12), -0.4, "#ffd84d");
1335
2015
  return together(ahoge(b, p), hangs(made));
1336
2016
  }
1337
2017
  },
1338
2018
  "twin-tails": {
1339
2019
  palette: { color: "#ff86b8", tip: "#b38cff", inner: "#d65a98" },
1340
2020
  build(b, radius, p) {
1341
- base(b, radius, p, 0.72, 0.44, 0.045);
2021
+ base(b, radius, p, 0.72, 0.44, 0.062, 0, 0.038);
1342
2022
  fringe(b, radius, p, [
1343
- { at: -0.55, length: 0.68, width: 0.1, sweep: -0.08 },
1344
- { at: -0.28, length: 0.62, width: 0.12 },
1345
- { at: 0, length: 0.65, width: 0.1, sweep: 0.03 },
1346
- { at: 0.27, length: 0.61, width: 0.12, sweep: 0.06 },
1347
- { at: 0.56, length: 0.69, width: 0.09, sweep: 0.1 }
2023
+ { at: -0.6, length: 0.54, width: 0.12, sweep: -0.12, lift: 0.01 },
2024
+ { at: -0.3, length: 0.55, width: 0.13, sweep: -0.04 },
2025
+ { at: 0.02, length: 0.57, width: 0.12, sweep: 0.06, lift: 0.012 },
2026
+ { at: 0.32, length: 0.54, width: 0.13, sweep: 0.09 },
2027
+ { at: 0.62, length: 0.55, width: 0.115, sweep: 0.14, lift: 0.01 },
2028
+ { at: -0.14, length: 0.52, width: 0.052, sweep: 0.14, lift: 0.028 }
1348
2029
  ]);
1349
- sidelocks(b, radius, p, 0.32, 0.065);
1350
- back(b, radius, p, { count: 10, from: 1.5, end: 0.5, width: 0.12, wave: 0.02 });
2030
+ sidelocks(b, radius, p, 0.24, 0.082, { curlIn: 0.24 });
2031
+ back(b, radius, p, { count: 12, from: 1.4, end: 0.46, width: 0.14, wave: 0.02, layers: 2 });
1351
2032
  const tails = [];
1352
2033
  for (const side of [-1, 1]) {
1353
2034
  const tieY = TOP - 0.1;
1354
- const tie = onHead(radius, side * 1.3, tieY, 0.07);
1355
- for (const path of tail(radius, side * 1.3, tieY, 0.95, 0.34, 6))
1356
- tails.push(add(b, p, clump(path, 0.12, 0.05, 1, side * 0.8)));
1357
- ribbon(b, tie.add(new Vector3(0, 0.02, 0.02)), side * 1.3, "#5bc8ff", 1.7);
2035
+ const tie = onHead(radius, side * 1.28, tieY, 0.085);
2036
+ for (const path of tail(radius, side * 1.28, tieY, 1.15, 0.38, 6))
2037
+ tails.push(add(b, p, clump(path, 0.135, 0.058, 1, side * 0.75)));
2038
+ ribbon(b, tie.add(new Vector3(0, 0.02, 0.02)), side * 1.28, "#5bc8ff", 1.75);
1358
2039
  }
1359
2040
  strays(b, radius, p, [
1360
- [0.75, 0.84, 0.1],
1361
- [-0.8, 0.83, 0.12]
2041
+ [0.75, 0.82, 0.13],
2042
+ [-0.8, 0.81, 0.15]
1362
2043
  ]);
1363
2044
  return together(ahoge(b, p, -1), hangs(tails));
1364
2045
  }
@@ -1366,33 +2047,34 @@ var HAIR = {
1366
2047
  "spiky-hero": {
1367
2048
  palette: { color: "#f6c945", tip: "#ff8a3d", inner: "#b07b1e" },
1368
2049
  build(b, radius, p) {
1369
- base(b, radius, p, 0.74, 0.5, 0.045);
2050
+ base(b, radius, p, 0.74, 0.48, 0.06, 0, 0.035);
1370
2051
  const spikes = [
1371
- [0, TOP - 0.04, 0.3, 0.6],
1372
- [0.55, TOP - 0.06, 0.28, 0.5],
1373
- [-0.55, TOP - 0.06, 0.28, 0.5],
1374
- [1.2, 0.8, 0.26, 0.35],
1375
- [-1.2, 0.8, 0.26, 0.35],
1376
- [1.9, 0.78, 0.24, 0.25],
1377
- [-1.9, 0.78, 0.24, 0.25],
1378
- [2.5, 0.8, 0.25, 0.3],
1379
- [-2.5, 0.8, 0.25, 0.3],
1380
- [Math.PI, 0.82, 0.26, 0.35],
2052
+ [0, TOP - 0.03, 0.3, 0.62],
2053
+ [0.52, TOP - 0.05, 0.28, 0.52],
2054
+ [-0.52, TOP - 0.05, 0.28, 0.52],
2055
+ [1.15, 0.8, 0.27, 0.36],
2056
+ [-1.15, 0.8, 0.27, 0.36],
2057
+ [1.85, 0.78, 0.25, 0.26],
2058
+ [-1.85, 0.78, 0.25, 0.26],
2059
+ [2.45, 0.78, 0.26, 0.3],
2060
+ [-2.45, 0.78, 0.26, 0.3],
2061
+ [Math.PI, 0.8, 0.27, 0.36],
1381
2062
  [2.9, TOP - 0.05, 0.3, 0.55],
1382
2063
  [-2.9, TOP - 0.05, 0.3, 0.55]
1383
2064
  ];
1384
2065
  for (const [phi, y, reach, up] of spikes) {
1385
- const length = reach * 1.45;
1386
- const root = onHead(radius, phi, y, 0.02);
2066
+ const length = reach * 1.48;
2067
+ const root = onHead(radius, phi, y, 0.03);
1387
2068
  const out = onHead(radius, phi, y, 1).sub(root).normalize();
1388
2069
  const tip = root.clone().addScaledVector(out, length * (1 - up)).addScaledVector(UP, length * up).add(new Vector3(0, 0, -length * 0.2));
1389
- const mid = root.clone().lerp(tip, 0.45).addScaledVector(out, 0.03);
1390
- add(b, p, clump([root, mid, tip], 0.14, 0.07));
2070
+ const mid = root.clone().lerp(tip, 0.45).addScaledVector(out, 0.035);
2071
+ add(b, p, clump([root, mid, tip], 0.15, 0.075));
1391
2072
  }
1392
2073
  fringe(b, radius, p, [
1393
- { at: -0.4, length: 0.66, width: 0.11, sweep: -0.12 },
1394
- { at: 0.02, length: 0.62, width: 0.13 },
1395
- { at: 0.42, length: 0.67, width: 0.11, sweep: 0.12 }
2074
+ { at: -0.52, length: 0.56, width: 0.125, sweep: -0.14 },
2075
+ { at: -0.16, length: 0.54, width: 0.135, sweep: -0.06, lift: 0.015 },
2076
+ { at: 0.18, length: 0.53, width: 0.135, sweep: 0.08, lift: 0.015 },
2077
+ { at: 0.52, length: 0.56, width: 0.12, sweep: 0.14 }
1396
2078
  ]);
1397
2079
  return;
1398
2080
  }
@@ -1400,7 +2082,7 @@ var HAIR = {
1400
2082
  afro: {
1401
2083
  palette: { color: "#3a271b", tip: "#8a5a38", inner: "#24170f", ring: 0.45 },
1402
2084
  build(b, radius, p) {
1403
- base(b, radius, p, 0.74, 0.4, 0.05);
2085
+ base(b, radius, p, 0.74, 0.4, 0.055);
1404
2086
  const puff = new SphereGeometry2(1, 18, 14);
1405
2087
  for (let i = 0;i < 46; i += 1) {
1406
2088
  const phi = i * 2.399963;
@@ -1416,68 +2098,87 @@ var HAIR = {
1416
2098
  }
1417
2099
  },
1418
2100
  "swoosh-quiff": {
1419
- palette: { color: "#5b3a86", tip: "#a98be0", inner: "#3a2358" },
2101
+ palette: { color: "#5b3a86", tip: "#b698f0", inner: "#372058" },
1420
2102
  build(b, radius, p) {
1421
- base(b, radius, p, 0.72, 0.42, 0.045, -0.4);
1422
- back(b, radius, p, { count: 12, from: 1.2, end: 0.5, width: 0.11, wave: 0.02 });
2103
+ base(b, radius, p, 0.73, 0.42, 0.065, -0.42, 0.045);
2104
+ const locks = back(b, radius, p, {
2105
+ count: 14,
2106
+ from: 1.1,
2107
+ end: 0.38,
2108
+ width: 0.135,
2109
+ wave: 0.03,
2110
+ flick: 0.06,
2111
+ layers: 2,
2112
+ spread: 0.085
2113
+ });
1423
2114
  fringe(b, radius, p, [
1424
- { at: -0.55, length: 0.74, width: 0.12, sweep: 0.5 },
1425
- { at: -0.3, length: 0.7, width: 0.14, sweep: 0.55 },
1426
- { at: -0.05, length: 0.66, width: 0.13, sweep: 0.6 },
1427
- { at: 0.2, length: 0.64, width: 0.11, sweep: 0.62 }
1428
- ], -0.4);
1429
- return ahoge(b, p, -1);
2115
+ { at: -0.6, length: 0.56, width: 0.13, sweep: 0.42, midSweep: 0.2, lift: 0.015 },
2116
+ { at: -0.32, length: 0.53, width: 0.145, sweep: 0.54, midSweep: 0.28, lift: 0.025 },
2117
+ { at: -0.02, length: 0.52, width: 0.14, sweep: 0.56, midSweep: 0.3, lift: 0.02 },
2118
+ { at: 0.28, length: 0.54, width: 0.125, sweep: 0.48, midSweep: 0.24, lift: 0.015 },
2119
+ { at: -0.15, length: 0.55, width: 0.058, sweep: 0.36, lift: 0.038 }
2120
+ ], -0.42);
2121
+ sidelocks(b, radius, p, 0.32, 0.08, { flick: 0.04, curlIn: 0.08 });
2122
+ crownTufts(b, radius, p, [
2123
+ [-0.35, TOP - 0.02, 0.2, 0.09, 0.08],
2124
+ [0.45, TOP - 0.03, 0.2, 0.09, 0.075]
2125
+ ]);
2126
+ return together(ahoge(b, p, -1), hangs(locks));
1430
2127
  }
1431
2128
  },
1432
2129
  "long-waves": {
1433
2130
  palette: { color: "#c25b30", tip: "#ffbf86", inner: "#7a2f2a" },
1434
2131
  build(b, radius, p) {
1435
- base(b, radius, p, 0.7, 0.4, 0.05, 0.3);
2132
+ base(b, radius, p, 0.71, 0.4, 0.065, 0.28, 0.042);
1436
2133
  fringe(b, radius, p, [
1437
- { at: -0.52, length: 0.66, width: 0.1, sweep: -0.1 },
1438
- { at: -0.24, length: 0.61, width: 0.125, sweep: -0.12 },
1439
- { at: 0.06, length: 0.64, width: 0.11, sweep: -0.14 },
1440
- { at: 0.36, length: 0.68, width: 0.1, sweep: -0.1 }
1441
- ], 0.3);
1442
- sidelocks(b, radius, p, 0.12, 0.085);
2134
+ { at: -0.58, length: 0.52, width: 0.12, sweep: -0.12 },
2135
+ { at: -0.26, length: 0.54, width: 0.135, sweep: -0.16, lift: 0.012 },
2136
+ { at: 0.06, length: 0.55, width: 0.125, sweep: -0.18, lift: 0.016 },
2137
+ { at: 0.38, length: 0.55, width: 0.12, sweep: 0.12 },
2138
+ { at: 0.64, length: 0.5, width: 0.11, sweep: 0.16 },
2139
+ { at: -0.1, length: 0.51, width: 0.052, sweep: -0.2, lift: 0.03 }
2140
+ ], 0.28);
2141
+ sidelocks(b, radius, p, -0.02, 0.095, { curlIn: 0.22 });
1443
2142
  const locks = back(b, radius, p, {
1444
- count: 16,
1445
- from: 1.15,
1446
- end: 0.05,
1447
- width: 0.13,
1448
- wave: 0.07,
1449
- curl: 0.12,
1450
- layers: 2
2143
+ count: 17,
2144
+ from: 1.12,
2145
+ end: -0.35,
2146
+ width: 0.15,
2147
+ wave: 0.085,
2148
+ curl: 0.14,
2149
+ layers: 2,
2150
+ spread: 0.09
1451
2151
  });
1452
2152
  strays(b, radius, p, [
1453
- [1.3, 0.7, 0.16],
1454
- [-2.2, 0.6, 0.18]
2153
+ [1.3, 0.68, 0.18],
2154
+ [-2.1, 0.58, 0.2]
1455
2155
  ]);
1456
- ribbon(b, onHead(radius, -0.95, 0.86, 0.1), -0.95, "#ffffff", 0.9);
2156
+ ribbon(b, onHead(radius, -0.95, 0.86, 0.115), -0.95, "#ffffff", 0.95);
1457
2157
  return hangs(locks);
1458
2158
  }
1459
2159
  },
1460
2160
  ponytail: {
1461
2161
  palette: { color: "#f0c96a", tip: "#fff1c2", inner: "#b98a3a" },
1462
2162
  build(b, radius, p) {
1463
- base(b, radius, p, 0.72, 0.55, 0.045, 0.2);
2163
+ base(b, radius, p, 0.72, 0.52, 0.06, 0.18, 0.036);
1464
2164
  fringe(b, radius, p, [
1465
- { at: -0.42, length: 0.68, width: 0.1, sweep: 0.15 },
1466
- { at: -0.14, length: 0.62, width: 0.12, sweep: 0.2 },
1467
- { at: 0.16, length: 0.65, width: 0.11, sweep: 0.24 },
1468
- { at: 0.44, length: 0.7, width: 0.09, sweep: 0.28 }
1469
- ]);
1470
- sidelocks(b, radius, p, 0.34, 0.06);
2165
+ { at: -0.5, length: 0.54, width: 0.12, sweep: 0.12 },
2166
+ { at: -0.18, length: 0.55, width: 0.13, sweep: 0.2, lift: 0.014 },
2167
+ { at: 0.16, length: 0.54, width: 0.125, sweep: 0.24, lift: 0.012 },
2168
+ { at: 0.48, length: 0.56, width: 0.11, sweep: 0.24 },
2169
+ { at: -0.02, length: 0.51, width: 0.05, sweep: 0.28, lift: 0.03 }
2170
+ ], 0.18);
2171
+ sidelocks(b, radius, p, 0.24, 0.075, { curlIn: 0.24 });
1471
2172
  const tieY = TOP + 0.01;
1472
- const locks = tail(radius, Math.PI, tieY, 0.85, 0.4, 6).map((path, i) => add(b, p, clump(path, 0.12, 0.05, 1, (i % 2 ? 1 : -1) * 0.7)));
1473
- ribbon(b, onHead(radius, Math.PI, tieY, 0.08), Math.PI, "#e2574c", 1.15);
2173
+ const locks = tail(radius, Math.PI, tieY, 1.05, 0.44, 6).map((path, i) => add(b, p, clump(path, 0.135, 0.055, 1, (i % 2 ? 1 : -1) * 0.7)));
2174
+ ribbon(b, onHead(radius, Math.PI, tieY, 0.095), Math.PI, "#e2574c", 1.25);
1474
2175
  return together(ahoge(b, p), hangs(locks));
1475
2176
  }
1476
2177
  },
1477
2178
  mohawk: {
1478
2179
  palette: { color: "#1fae8f", tip: "#a6f5dd", inner: "#127160" },
1479
2180
  build(b, radius, p) {
1480
- base(b, radius, { color: "#2a2440", tip: "#3a3260", inner: "#1d1830", ring: 0.25 }, 0.72, 0.4, 0.014);
2181
+ base(b, radius, { color: "#2a2440", tip: "#3a3260", inner: "#1d1830", ring: 0.25 }, 0.72, 0.4, 0.016);
1481
2182
  for (let i = 0;i < 8; i += 1) {
1482
2183
  const s = i / 7;
1483
2184
  const phi = s < 0.45 ? 0 : Math.PI;
@@ -1486,7 +2187,7 @@ var HAIR = {
1486
2187
  root.x = 0;
1487
2188
  const tip = root.clone().add(new Vector3(0, 0.22 - Math.abs(s - 0.4) * 0.14, 0)).add(new Vector3(0, 0, -0.08 - s * 0.05));
1488
2189
  const mid = root.clone().lerp(tip, 0.5).add(new Vector3(0, 0.02, 0.02));
1489
- add(b, p, clump([root, mid, tip], 0.03, 0.09));
2190
+ add(b, p, clump([root, mid, tip], 0.032, 0.095));
1490
2191
  }
1491
2192
  return;
1492
2193
  }
@@ -1494,64 +2195,69 @@ var HAIR = {
1494
2195
  "space-buns": {
1495
2196
  palette: { color: "#b9a6ff", tip: "#ffc2ec", inner: "#7d6ad1" },
1496
2197
  build(b, radius, p) {
1497
- base(b, radius, p, 0.72, 0.42, 0.045);
2198
+ base(b, radius, p, 0.72, 0.42, 0.06, 0, 0.036);
1498
2199
  fringe(b, radius, p, [
1499
- { at: -0.52, length: 0.66, width: 0.1 },
1500
- { at: -0.24, length: 0.62, width: 0.11, sweep: -0.04 },
1501
- { at: 0.04, length: 0.65, width: 0.12, sweep: 0.04 },
1502
- { at: 0.32, length: 0.62, width: 0.1, sweep: 0.06 },
1503
- { at: 0.58, length: 0.67, width: 0.09, sweep: 0.08 }
2200
+ { at: -0.56, length: 0.54, width: 0.12 },
2201
+ { at: -0.26, length: 0.55, width: 0.125, sweep: -0.05 },
2202
+ { at: 0.04, length: 0.56, width: 0.125, sweep: 0.05, lift: 0.012 },
2203
+ { at: 0.34, length: 0.54, width: 0.12, sweep: 0.08 },
2204
+ { at: 0.6, length: 0.55, width: 0.11, sweep: 0.1 },
2205
+ { at: -0.1, length: 0.52, width: 0.05, sweep: 0.12, lift: 0.028 }
1504
2206
  ]);
1505
- sidelocks(b, radius, p, 0.3, 0.055);
2207
+ sidelocks(b, radius, p, 0.22, 0.072, { curlIn: 0.24 });
1506
2208
  const tufts = [];
1507
2209
  for (const side of [-1, 1]) {
1508
- const at = onHead(radius, side * 0.9, TOP - 0.08, 0.1).add(new Vector3(0, 0.05, 0));
2210
+ const at = onHead(radius, side * 0.9, TOP - 0.08, 0.11).add(new Vector3(0, 0.05, 0));
1509
2211
  const coil = [];
1510
2212
  for (let k = 0;k <= 14; k += 1) {
1511
2213
  const a = k * 0.9;
1512
- const r = 0.11 - k * 0.004;
2214
+ const r = 0.115 - k * 0.004;
1513
2215
  coil.push(new Vector3(at.x + Math.cos(a) * r, at.y + (k / 14 - 0.5) * 0.12, at.z + Math.sin(a) * r));
1514
2216
  }
1515
- b.add(new SphereGeometry2(0.1, 20, 16), p.color, { at: [at.x, at.y, at.z] }, { anime: { center: [at.x, at.y, at.z], ring: 0.8, tip: p.tip, inner: p.inner } });
1516
- add(b, p, clump(coil, 0.06, 0.035, 0.7));
1517
- ribbon(b, at.clone().add(new Vector3(0, -0.07, 0.06)), side * 0.9, "#ffd84d", 0.8);
1518
- for (const path of tail(radius, side * 1.05, TOP - 0.16, 0.42, 0.22, 3))
1519
- tufts.push(add(b, p, clump(path, 0.075, 0.03)));
2217
+ b.add(new SphereGeometry2(0.105, 20, 16), p.color, { at: [at.x, at.y, at.z] }, { anime: { center: [at.x, at.y, at.z], ring: 0.8, tip: p.tip, inner: p.inner } });
2218
+ add(b, p, clump(coil, 0.065, 0.038, 0.7));
2219
+ ribbon(b, at.clone().add(new Vector3(0, -0.07, 0.06)), side * 0.9, "#ffd84d", 0.88);
2220
+ for (const path of tail(radius, side * 1.05, TOP - 0.16, 0.48, 0.24, 3))
2221
+ tufts.push(add(b, p, clump(path, 0.085, 0.034)));
1520
2222
  }
1521
2223
  return hangs(tufts);
1522
2224
  }
1523
2225
  },
1524
2226
  "hime-cut": {
1525
- palette: { color: "#2d2b52", tip: "#7b68d6", inner: "#1b1934", ring: 1.1 },
2227
+ palette: { color: "#262348", tip: "#7d68de", inner: "#16142e", ring: 1.1 },
1526
2228
  build(b, radius, p) {
1527
- base(b, radius, p, 0.72, 0.42, 0.05);
2229
+ base(b, radius, p, 0.72, 0.42, 0.065, 0, 0.036);
1528
2230
  fringe(b, radius, p, [
1529
- { at: -0.6, length: 0.66, width: 0.11, blunt: true },
1530
- { at: -0.36, length: 0.645, width: 0.12, blunt: true },
1531
- { at: -0.12, length: 0.64, width: 0.12, blunt: true },
1532
- { at: 0.12, length: 0.64, width: 0.12, blunt: true },
1533
- { at: 0.36, length: 0.645, width: 0.12, blunt: true },
1534
- { at: 0.6, length: 0.66, width: 0.11, blunt: true }
2231
+ { at: -0.62, length: 0.56, width: 0.125, blunt: true },
2232
+ { at: -0.37, length: 0.55, width: 0.135, blunt: true },
2233
+ { at: -0.12, length: 0.545, width: 0.135, blunt: true },
2234
+ { at: 0.12, length: 0.545, width: 0.135, blunt: true },
2235
+ { at: 0.37, length: 0.55, width: 0.135, blunt: true },
2236
+ { at: 0.62, length: 0.56, width: 0.125, blunt: true },
2237
+ { at: 0.24, length: 0.53, width: 0.042, sweep: 0.06, lift: 0.022 }
1535
2238
  ]);
1536
- sidelocks(b, radius, p, 0.36, 0.09, true);
2239
+ sidelocks(b, radius, p, 0.24, 0.1, { blunt: true });
1537
2240
  const locks = back(b, radius, p, {
1538
2241
  count: 18,
1539
- from: 1.3,
1540
- end: 0.04,
1541
- width: 0.13,
1542
- wave: 0.01,
2242
+ from: 1.24,
2243
+ end: -0.3,
2244
+ width: 0.145,
2245
+ wave: 0.015,
1543
2246
  curl: 0,
1544
2247
  blunt: true,
1545
- layers: 2
2248
+ layers: 2,
2249
+ spread: 0.085
1546
2250
  });
1547
- ribbon(b, onHead(radius, Math.PI, TOP - 0.02, 0.07), Math.PI, "#e8475f", 1.3);
2251
+ ribbon(b, onHead(radius, Math.PI, TOP - 0.02, 0.09), Math.PI, "#e8475f", 1.35);
1548
2252
  return hangs(locks);
1549
2253
  }
1550
2254
  }
1551
2255
  };
1552
2256
  function buildHair(key, kit) {
1553
2257
  const style = HAIR[key];
1554
- return piece(kit, (b) => style.build(b, kit.radiusAt, style.palette));
2258
+ const palette = resolvePalette(style.palette, kit.hairColor);
2259
+ const headR = kit.isFigure ? (y) => y < 0.08 ? Math.max(0.32, kit.radiusAt(0.22)) : kit.radiusAt(y) : kit.radiusAt;
2260
+ return piece(kit, (b) => style.build(b, headR, palette));
1555
2261
  }
1556
2262
 
1557
2263
  // src/dress.ts
@@ -1611,20 +2317,17 @@ uniform vec3 color;
1611
2317
  uniform vec3 backColor;
1612
2318
  uniform float sheen;
1613
2319
  void main() {
1614
- // An open shell (a skirt, a cape) is seen from inside too: its back faces light as front ones,
1615
- // in their own colour when it has a lining.
1616
2320
  vec3 n = normalize(vNormal) * (gl_FrontFacing ? 1.0 : -1.0);
1617
2321
  vec3 toLight = normalize(vec3(-0.35, 0.75, 0.55));
1618
2322
  float light = dot(n, toLight);
1619
- float band = light > 0.2 ? 1.0 : light > -0.3 ? 0.8 : 0.6;
2323
+ float band = light > 0.18 ? 1.0 : light > -0.28 ? 0.84 : 0.68;
1620
2324
  vec3 tint = gl_FrontFacing ? color : backColor;
1621
2325
  vec3 base = useMap > 0.5 ? texture2D(map, vUv).rgb * tint : tint;
1622
2326
  vec3 lit = base * band;
1623
- // Satin and metal: one hard highlight band, still a cartoon, never a smooth gradient.
1624
2327
  float glint = pow(max(dot(n, normalize(toLight + vec3(0.0, 0.0, 1.0))), 0.0), 36.0);
1625
2328
  if (sheen > 0.0 && glint > 0.45) lit = mix(lit, vec3(1.0), sheen);
1626
2329
  float rim = 1.0 - max(n.z, 0.0);
1627
- if (rim > 0.82 && n.y > -0.2) lit = mix(lit, vec3(1.0), 0.35);
2330
+ if (rim > 0.82 && n.y > -0.2) lit = mix(lit, vec3(1.0), 0.3);
1628
2331
  gl_FragColor = vec4(lit, 1.0);
1629
2332
  #include <colorspace_fragment>
1630
2333
  }`;
@@ -1640,10 +2343,9 @@ void main() {
1640
2343
  vec3 dome = normalize(position - center);
1641
2344
  vec3 real = length(normal) > 0.001 ? normalize(normal) : dome;
1642
2345
  vNormal = normalize(normalMatrix * real);
1643
- vDome = normalize(normalMatrix * normalize(mix(real, dome, 0.78)));
2346
+ vDome = normalize(normalMatrix * normalize(mix(real, dome, 0.74)));
1644
2347
  vDir = dome;
1645
2348
  vAlong = along;
1646
- // The side of a lock that faces the skull: the underside of a ribbon, seen where it twists.
1647
2349
  vInward = dot(real, dome);
1648
2350
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
1649
2351
  }`;
@@ -1659,45 +2361,50 @@ varying float vAlong;
1659
2361
  varying float vInward;
1660
2362
  void main() {
1661
2363
  vec3 n = normalize(vDome) * (gl_FrontFacing ? 1.0 : -1.0);
1662
- vec3 toLight = normalize(vec3(-0.35, 0.75, 0.55));
2364
+ vec3 toLight = normalize(vec3(-0.32, 0.78, 0.54));
1663
2365
  float light = dot(n, toLight);
1664
- // The colour runs towards the tips (an ombre), and the underside of a lock is its inner colour.
1665
- float toTip = smoothstep(0.35, 1.0, vAlong);
1666
- vec3 base = mix(color, tip, toTip);
1667
- base = mix(base, inner, smoothstep(-0.15, -0.55, vInward));
1668
- vec3 shadow = base * vec3(0.7, 0.62, 0.86);
1669
- vec3 deep = base * vec3(0.46, 0.4, 0.68);
1670
- vec3 lit = light > 0.12 ? base : light > -0.38 ? shadow : deep;
1671
- // Reflected light: the shaded side of the ends catches a little of the tip colour, so the hair
1672
- // looks like light passes through it rather than going flat.
1673
- if (light <= 0.12) lit = mix(lit, tip, 0.38 * toTip);
1674
- // The angel ring: a band round the skull, its edges zigzagging the way a drawn highlight does.
2366
+ // Root ambient occlusion + smooth ombre toward translucent-feeling tips + underside colour.
2367
+ float rootShade = mix(0.88, 1.0, smoothstep(0.0, 0.22, vAlong));
2368
+ float toTip = smoothstep(0.38, 1.0, vAlong);
2369
+ vec3 base = mix(color * rootShade, tip, toTip);
2370
+ base = mix(base, inner, smoothstep(-0.18, -0.58, vInward));
2371
+ vec3 shadow = base * vec3(0.74, 0.67, 0.88);
2372
+ vec3 deep = base * vec3(0.52, 0.46, 0.72);
2373
+ vec3 lit = light > 0.14 ? base : light > -0.34 ? shadow : deep;
2374
+ // Subtle light bounce through shaded tips
2375
+ if (light <= 0.14) lit = mix(lit, tip, 0.34 * toTip);
2376
+ // Organic broken glossy anime highlight band (smooth double-wave, NOT harsh sawtooth!)
1675
2377
  float around = atan(vDir.x, vDir.z);
1676
- float zig = abs(fract(around * 4.5) - 0.5) * 2.0;
1677
- float centre = 0.62 + (zig - 0.5) * 0.09;
1678
- float width = 0.05 * (0.5 + 0.5 * zig);
1679
- float onRing = step(abs(vDir.y - centre), width) * step(0.0, n.z) * step(0.0, light + 0.2) * (1.0 - toTip);
1680
- vec3 shine = mix(base, vec3(1.0, 0.98, 1.0), 0.5);
1681
- lit = mix(lit, shine, onRing * ring);
1682
- // A hard, thin rim on the lit side separates the hair from what is behind it.
2378
+ float wave = sin(around * 3.0 + 0.4) * 0.032 + sin(around * 7.0 - 0.8) * 0.014;
2379
+ float breakMask = smoothstep(-0.18, 0.25, sin(around * 5.0 + 1.1) + 0.35 * cos(around * 9.0));
2380
+ float centre = 0.56 + wave;
2381
+ float bandDist = abs(vDir.y - centre);
2382
+ float primary = (1.0 - smoothstep(0.022, 0.048, bandDist)) * breakMask;
2383
+ float secondary = (1.0 - smoothstep(0.008, 0.022, abs(vDir.y - (centre + 0.07)))) * (1.0 - breakMask * 0.5) * 0.55;
2384
+ float facingLit = smoothstep(-0.1, 0.25, n.z) * smoothstep(-0.15, 0.2, light) * (1.0 - toTip * 0.8);
2385
+ vec3 shine = mix(base, vec3(1.0, 0.98, 1.0), 0.44);
2386
+ lit = mix(lit, shine, clamp(primary + secondary, 0.0, 1.0) * facingLit * ring * 0.85);
2387
+ // Thin soft-cut rim separating hair silhouette from background
1683
2388
  float rim = 1.0 - max(normalize(vNormal).z, 0.0);
1684
- if (rim > 0.86 && n.y > 0.0) lit = mix(lit, vec3(1.0), 0.28);
2389
+ if (rim > 0.85 && n.y > -0.05) lit = mix(lit, mix(tip, vec3(1.0), 0.55), 0.28);
1685
2390
  gl_FragColor = vec4(lit, 1.0);
1686
2391
  #include <colorspace_fragment>
1687
2392
  }`;
1688
- function taperedHose(curve, muscle) {
1689
- const segments = 16;
1690
- const radial = 10;
1691
- const tube = new TubeGeometry(curve, segments, 0.046, radial);
2393
+ function taperedHose(curve, muscle, baseRadius = 0.046) {
2394
+ const segments = 24;
2395
+ const radial = 14;
2396
+ const tube = new TubeGeometry(curve, segments, baseRadius, radial);
1692
2397
  const position = tube.attributes.position;
1693
2398
  const centre = new Vector32;
2399
+ const strength = Math.max(0, muscle - 1);
2400
+ const slim = muscle < 1 ? 0.72 + 0.28 * muscle : 1;
1694
2401
  for (let i = 0;i <= segments; i += 1) {
1695
2402
  const t = i / segments;
1696
2403
  curve.getPointAt(t, centre);
1697
- const strength = Math.max(0, muscle - 1);
1698
- const biceps = 1 + strength * 1.1 * Math.exp(-(((t - 0.28) / 0.14) ** 2));
1699
- const forearm = 1 + strength * 0.8 * Math.exp(-(((t - 0.74) / 0.12) ** 2));
1700
- const k = (1.12 - 0.3 * t) * biceps * forearm;
2404
+ const deltoid = 1 + strength * 0.65 * Math.exp(-(((t - 0.06) / 0.17) ** 2));
2405
+ const biceps = 1 + strength * 0.78 * Math.exp(-(((t - 0.34) / 0.21) ** 2));
2406
+ const forearm = 1 + strength * 0.48 * Math.exp(-(((t - 0.7) / 0.19) ** 2));
2407
+ const k = (1.12 - 0.38 * t) * slim * deltoid * biceps * forearm;
1701
2408
  for (let j = 0;j <= radial; j += 1) {
1702
2409
  const v = i * (radial + 1) + j;
1703
2410
  position.setXYZ(v, centre.x + (position.getX(v) - centre.x) * k, centre.y + (position.getY(v) - centre.y) * k, centre.z + (position.getZ(v) - centre.z) * k);
@@ -1706,6 +2413,29 @@ function taperedHose(curve, muscle) {
1706
2413
  tube.computeVertexNormals();
1707
2414
  return tube;
1708
2415
  }
2416
+ function sculptedLeg(curve, hips, muscle) {
2417
+ const segments = 24;
2418
+ const radial = 14;
2419
+ const tube = new TubeGeometry(curve, segments, 0.095, radial);
2420
+ const position = tube.attributes.position;
2421
+ const centre = new Vector32;
2422
+ const thighScale = 0.88 + Math.max(0, hips - 0.85) * 0.52 + Math.max(0, muscle - 1) * 0.36;
2423
+ const calfScale = 0.78 + Math.max(0, muscle - 1) * 0.34 + Math.max(0, hips - 1) * 0.14;
2424
+ for (let i = 0;i <= segments; i += 1) {
2425
+ const t = i / segments;
2426
+ curve.getPointAt(t, centre);
2427
+ const upper = thighScale * Math.exp(-(((t - 0.1) / 0.32) ** 2));
2428
+ const calf = calfScale * 0.26 * Math.exp(-(((t - 0.65) / 0.18) ** 2));
2429
+ const base2 = 0.96 - 0.56 * t;
2430
+ const k = Math.max(0.36, base2 * (0.48 + 0.62 * upper) + calf * 0.4);
2431
+ for (let j = 0;j <= radial; j += 1) {
2432
+ const v = i * (radial + 1) + j;
2433
+ position.setXYZ(v, centre.x + (position.getX(v) - centre.x) * k, centre.y + (position.getY(v) - centre.y) * k, centre.z + (position.getZ(v) - centre.z) * k * 1.05);
2434
+ }
2435
+ }
2436
+ tube.computeVertexNormals();
2437
+ return tube;
2438
+ }
1709
2439
  function toon(options) {
1710
2440
  if (options.anime)
1711
2441
  return new ShaderMaterial({
@@ -1755,17 +2485,27 @@ void main() {
1755
2485
  }`
1756
2486
  });
1757
2487
  }
1758
- var channel = (hex, at) => Number.parseInt(hex.slice(at, at + 2), 16);
1759
- var shade = (hex, toward, amount) => `#${[1, 3, 5].map((at) => Math.round(channel(hex, at) + (toward - channel(hex, at)) * amount).toString(16).padStart(2, "0")).join("")}`;
1760
- function paintBody(canvas, color, face, skin, faceType) {
2488
+ function hexChannels(hex) {
2489
+ const bare = hex.startsWith("#") ? hex.slice(1) : hex;
2490
+ const full = bare.length === 3 || bare.length === 4 ? `${bare[0]}${bare[0]}${bare[1]}${bare[1]}${bare[2]}${bare[2]}` : bare.length === 6 || bare.length === 8 ? bare.slice(0, 6) : "";
2491
+ if (!/^[0-9a-f]{6}$/i.test(full))
2492
+ return [0, 0, 0];
2493
+ return [
2494
+ Number.parseInt(full.slice(0, 2), 16),
2495
+ Number.parseInt(full.slice(2, 4), 16),
2496
+ Number.parseInt(full.slice(4, 6), 16)
2497
+ ];
2498
+ }
2499
+ var shade = (hex, toward, amount) => `#${hexChannels(hex).map((value) => Math.max(0, Math.min(255, Math.round(value + (toward - value) * amount))).toString(16).padStart(2, "0")).join("")}`;
2500
+ function paintBody(canvas, color, face, skin, faceType, isFigure = false) {
1761
2501
  const ctx = canvas.getContext("2d");
1762
2502
  if (!ctx)
1763
2503
  return;
1764
2504
  const px = canvas.width / BODY_WIDTH;
1765
2505
  const base2 = color;
1766
- const light = shade(color, 255, 0.32);
1767
- const belly = shade(color, 255, 0.62);
1768
- const dark = shade(color, 0, 0.3);
2506
+ const light = shade(color, 255, 0.25);
2507
+ const belly = isFigure ? shade(color, 255, 0.1) : shade(color, 255, 0.62);
2508
+ const dark = shade(color, 0, 0.2);
1769
2509
  const palette = {
1770
2510
  ...SKIN_PALETTE,
1771
2511
  B: color,
@@ -1774,24 +2514,29 @@ function paintBody(canvas, color, face, skin, faceType) {
1774
2514
  };
1775
2515
  for (let y = 0;y < BODY_HEIGHT; y += 1) {
1776
2516
  for (let x = 0;x < BODY_WIDTH; x += 1) {
1777
- const drawn = skin?.body[y]?.[x];
2517
+ const drawn = !isFigure ? skin?.body[y]?.[x] : undefined;
1778
2518
  if (drawn) {
1779
2519
  ctx.fillStyle = palette[drawn] ?? color;
1780
2520
  ctx.fillRect(x * px, y * px, px, px);
1781
2521
  continue;
1782
2522
  }
1783
2523
  let fill = base2;
1784
- if (y >= 16)
1785
- fill = belly;
1786
- else if (y === 15)
1787
- fill = light;
1788
- else if (x >= 29 && x <= 35)
1789
- fill = dark;
2524
+ if (isFigure) {
2525
+ if (x >= 30 && x <= 35)
2526
+ fill = shade(color, 0, 0.08);
2527
+ } else {
2528
+ if (y >= 16)
2529
+ fill = belly;
2530
+ else if (y === 15)
2531
+ fill = light;
2532
+ else if (x >= 29 && x <= 35)
2533
+ fill = dark;
2534
+ }
1790
2535
  ctx.fillStyle = fill;
1791
2536
  ctx.fillRect(x * px, y * px, px, px);
1792
2537
  }
1793
2538
  }
1794
- if (!skin) {
2539
+ if (!skin && !isFigure) {
1795
2540
  ctx.fillStyle = shade(color, 255, 0.8);
1796
2541
  for (const [x, y] of [
1797
2542
  [19, 4],
@@ -1802,9 +2547,10 @@ function paintBody(canvas, color, face, skin, faceType) {
1802
2547
  ])
1803
2548
  ctx.fillRect(x * px, y * px, px, px);
1804
2549
  }
1805
- if ((skin?.faceType ?? faceType) === "anime")
2550
+ const resolvedFaceType = skin?.faceType ?? faceType;
2551
+ if (isHighResFace(resolvedFaceType))
1806
2552
  return;
1807
- const stamp = stampFor(face, skin?.faceType ?? faceType ?? "dot");
2553
+ const stamp = stampFor(face, resolvedFaceType ?? "dot");
1808
2554
  stamp.forEach((row, dy) => {
1809
2555
  for (let dx = 0;dx < row.length; dx += 1) {
1810
2556
  const key = row[dx] ?? ".";
@@ -1816,9 +2562,10 @@ function paintBody(canvas, color, face, skin, faceType) {
1816
2562
  }
1817
2563
  });
1818
2564
  }
1819
- function animeDecal(faceType, face, eyeColor) {
1820
- if (faceType !== "anime")
2565
+ function animeDecal(faceType, face, eyeColor, isFigure = false) {
2566
+ if (!isHighResFace(faceType))
1821
2567
  return null;
2568
+ const style = faceType;
1822
2569
  const canvas = document.createElement("canvas");
1823
2570
  canvas.width = ANIME_FACE_SIZE.width;
1824
2571
  canvas.height = ANIME_FACE_SIZE.height;
@@ -1826,7 +2573,7 @@ function animeDecal(faceType, face, eyeColor) {
1826
2573
  const map = new CanvasTexture2(canvas);
1827
2574
  map.colorSpace = SRGBColorSpace2;
1828
2575
  map.anisotropy = 4;
1829
- const { u0, u1, v0, v1 } = ANIME_FACE_UV;
2576
+ const { u0, u1, v0, v1 } = isFigure ? ANIME_FACE_UV : { u0: 0.07, u1: 0.43, v0: 0.37, v1: 0.7 };
1830
2577
  map.repeat.set(1 / (u1 - u0), 1 / (v1 - v0));
1831
2578
  map.offset.set(-u0 / (u1 - u0), -v0 / (v1 - v0));
1832
2579
  const material = new MeshBasicMaterial2({
@@ -1839,71 +2586,161 @@ function animeDecal(faceType, face, eyeColor) {
1839
2586
  const draw = (next) => {
1840
2587
  if (!ctx)
1841
2588
  return;
1842
- drawAnimeFace(ctx, next, eyeColor);
2589
+ drawAnimeFace(ctx, next, eyeColor, style);
1843
2590
  map.needsUpdate = true;
1844
2591
  };
1845
2592
  draw(face);
1846
2593
  return { material, draw };
1847
2594
  }
2595
+ var OUTFIT_LEG_COLOR = {
2596
+ "street-jacket": "#1a1a28",
2597
+ "blazer-coat": "#1e2542",
2598
+ tuxedo: "#181529",
2599
+ "brawler-vest": "#2c253b",
2600
+ "martial-gi": "#ede9e0",
2601
+ "chibi-overalls": "#5b8ff9"
2602
+ };
1848
2603
  var inkHull = null;
1849
2604
  var neonHull = null;
1850
2605
  var fineHull = null;
2606
+ var hairHull = null;
2607
+ var figureHull = null;
1851
2608
  function createPlup(options = {}) {
1852
2609
  inkHull ??= hull("#14102e", 0.022);
2610
+ figureHull ??= hull("#1b1438", 0.013);
1853
2611
  neonHull ??= hull("#b9a6ff", 0.04);
1854
- fineHull ??= hull("#14102e", 0.009);
2612
+ fineHull ??= hull("#191233", 0.007);
2613
+ hairHull ??= hull("#1c1433", 0.0045);
1855
2614
  const fine = fineHull;
1856
2615
  const ink = inkHull;
1857
2616
  const neon = neonHull;
2617
+ const figureInk = figureHull;
2618
+ const hairInk = hairHull;
1858
2619
  let color = options.color ?? "#3d7bff";
1859
2620
  let face = options.face ?? "smug";
1860
2621
  const skin = options.skin ?? null;
1861
2622
  const shape = BODY_SHAPES[options.shape ?? "plup"] ?? BODY_SHAPES.plup;
1862
2623
  const fit = plupProportions(shape, options.bodyScale);
1863
2624
  const build = clampPlupBody(options.body);
1864
- const silhouette = { shoulders: build.shoulders, waist: build.waist, hips: build.hips };
1865
- const legRaise = 0.16 * (build.legLength - 1);
2625
+ const isFigure = build.figure >= 0.5;
2626
+ const silhouette = {
2627
+ shoulders: build.shoulders,
2628
+ waist: build.waist,
2629
+ hips: build.hips,
2630
+ bust: build.bust,
2631
+ muscle: build.muscle,
2632
+ torsoHeight: build.torsoHeight,
2633
+ figure: build.figure
2634
+ };
2635
+ const span = figureTorsoSpan(build.torsoHeight);
2636
+ const legRaise = isFigure ? Math.max(0.14, 0.28 + 0.16 * (build.legLength - 1)) : Math.max(0, 0.16 * (build.legLength - 1));
1866
2637
  const canvas = document.createElement("canvas");
1867
2638
  canvas.width = BODY_WIDTH * 4;
1868
2639
  canvas.height = BODY_HEIGHT * 4;
1869
- paintBody(canvas, color, face, skin, options.faceType);
2640
+ paintBody(canvas, color, face, skin, options.faceType, isFigure);
1870
2641
  const texture = new CanvasTexture2(canvas);
1871
2642
  pixelArtFiltering(texture);
1872
2643
  texture.colorSpace = SRGBColorSpace2;
1873
2644
  texture.wrapS = RepeatWrapping2;
1874
2645
  texture.offset.x = (FACE_COLUMN + 4) / BODY_WIDTH - 0.25;
1875
- const anime2 = animeDecal(skin?.faceType ?? options.faceType, face, options.eyeColor);
2646
+ const anime2 = animeDecal(skin?.faceType ?? options.faceType, face, options.eyeColor, isFigure);
1876
2647
  const bodyMaterial = toon({ map: texture });
1877
- const limbMaterial = toon({ color: shade(color, 0, 0.12) });
1878
- const tipMaterial = toon({ color: shade(color, 0, 0.3) });
2648
+ const torsoMaterial = toon({ color });
2649
+ const limbMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
2650
+ const legMaterial = toon({ color: isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12) });
2651
+ const tipMaterial = toon({ color: isFigure ? shade(color, 0, 0.12) : shade(color, 0, 0.3) });
2652
+ const shoeMaterial = toon({ color: "#221a3a", sheen: 0.35 });
1879
2653
  const root = new Group2;
1880
2654
  const lifted = new Group2;
1881
2655
  root.add(lifted);
1882
- const geometry = buildBlobGeometry(silhouette);
2656
+ const headMetrics = figureHeadMetrics(build.headSize, build.torsoHeight);
2657
+ const geometry = isFigure ? buildFigureHeadGeometry() : buildBlobGeometry(silhouette);
2658
+ const torsoGeometry = isFigure ? buildFigureTorsoGeometry(silhouette) : null;
2659
+ const headGroup = new Group2;
1883
2660
  if (!options.model) {
1884
- const bodyMesh = new Mesh2(geometry, bodyMaterial);
1885
- const blobMeshes = [bodyMesh, new Mesh2(geometry, ink), new Mesh2(geometry, neon)];
1886
- for (const mesh of blobMeshes)
1887
- mesh.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
1888
- lifted.add(...blobMeshes);
1889
- if (anime2) {
1890
- const decal = new Mesh2(geometry, anime2.material);
1891
- decal.scale.copy(bodyMesh.scale).multiplyScalar(1.006);
1892
- decal.renderOrder = 1;
1893
- lifted.add(decal);
2661
+ if (isFigure && torsoGeometry) {
2662
+ const torsoMesh = new Mesh2(torsoGeometry, torsoMaterial);
2663
+ const torsoInk = new Mesh2(torsoGeometry, figureInk);
2664
+ lifted.add(torsoMesh, torsoInk);
2665
+ headGroup.position.set(0, headMetrics.originY, 0);
2666
+ headGroup.scale.setScalar(headMetrics.scale);
2667
+ const headMesh = new Mesh2(geometry, bodyMaterial);
2668
+ const headInk = new Mesh2(geometry, figureInk);
2669
+ headGroup.add(headMesh, headInk);
2670
+ if (anime2) {
2671
+ const decal = new Mesh2(geometry, anime2.material);
2672
+ decal.scale.setScalar(1.008);
2673
+ decal.renderOrder = 1;
2674
+ headGroup.add(decal);
2675
+ }
2676
+ lifted.add(headGroup);
2677
+ } else {
2678
+ const bodyMesh = new Mesh2(geometry, bodyMaterial);
2679
+ const blobMeshes = [bodyMesh, new Mesh2(geometry, ink), new Mesh2(geometry, neon)];
2680
+ for (const mesh of blobMeshes)
2681
+ mesh.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
2682
+ lifted.add(...blobMeshes);
2683
+ if (anime2) {
2684
+ const decal = new Mesh2(geometry, anime2.material);
2685
+ decal.scale.copy(bodyMesh.scale).multiplyScalar(1.006);
2686
+ decal.renderOrder = 1;
2687
+ lifted.add(decal);
2688
+ }
1894
2689
  }
1895
2690
  for (const mesh of lifted.children)
1896
2691
  mesh.raycast = () => {};
1897
2692
  }
1898
- const wearRoot = new Group2;
1899
- wearRoot.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
1900
- lifted.add(wearRoot);
2693
+ const headWearRoot = new Group2;
2694
+ const bodyWearRoot = new Group2;
2695
+ if (isFigure) {
2696
+ headGroup.add(headWearRoot);
2697
+ lifted.add(bodyWearRoot);
2698
+ } else {
2699
+ headWearRoot.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
2700
+ bodyWearRoot.scale.copy(headWearRoot.scale);
2701
+ lifted.add(headWearRoot, bodyWearRoot);
2702
+ }
1901
2703
  const worn = new Map;
1902
- const kit = {
1903
- radiusAt: (y) => blobRadiusAt(y, silhouette),
2704
+ const headKit = {
2705
+ radiusAt: (y) => isFigure ? figureHeadRadiusAt(y) : blobRadiusAt(y, silhouette),
1904
2706
  paint: (paint, more = {}) => toon({ ...more, color: paint }),
1905
- ink: fine
2707
+ ink: hairInk,
2708
+ hairColor: options.hairColor,
2709
+ isFigure
1906
2710
  };
2711
+ const bodyKit = {
2712
+ radiusAt: (y) => isFigure ? figureTorsoRadiusAt(y, silhouette) : blobRadiusAt(y, silhouette),
2713
+ surfaceAt: isFigure ? (y, phi, grow = 0) => {
2714
+ const pt = figureTorsoPoint(y, phi, silhouette);
2715
+ const len = Math.hypot(pt.x, pt.z) || 1;
2716
+ const nx = pt.x / len;
2717
+ const nz = pt.z / len;
2718
+ return { x: pt.x + nx * grow, z: pt.z + nz * grow };
2719
+ } : (y, phi, grow = 0) => {
2720
+ const r = blobRadiusAt(y, silhouette) + grow;
2721
+ return { x: Math.sin(phi) * r, z: Math.cos(phi) * r * (BLOB_RADIUS.z / BLOB_RADIUS.x) };
2722
+ },
2723
+ paint: (paint, more = {}) => toon({ ...more, color: paint }),
2724
+ ink: fine,
2725
+ hairColor: options.hairColor,
2726
+ isFigure,
2727
+ zones: isFigure ? {
2728
+ bottomY: span.minY,
2729
+ hipY: span.hipY + 0.05 * build.torsoHeight,
2730
+ waistY: span.waistY,
2731
+ bustY: span.bustY,
2732
+ shoulderY: span.shoulderY,
2733
+ neckY: span.maxY - 0.08 * build.torsoHeight
2734
+ } : {
2735
+ bottomY: 0.04,
2736
+ hipY: 0.14,
2737
+ waistY: 0.25,
2738
+ bustY: 0.35,
2739
+ shoulderY: 0.42,
2740
+ neckY: 0.27
2741
+ }
2742
+ };
2743
+ const isHeadPiece = (key) => isHairKey(key) || wearSlotOf(key) === "hat" || key === "sunglasses";
1907
2744
  let lastLift = 0;
1908
2745
  let lastYaw = 0;
1909
2746
  const setWear = (next) => {
@@ -1911,26 +2748,32 @@ function createPlup(options = {}) {
1911
2748
  for (const [key, piece2] of worn) {
1912
2749
  if (wanted.has(key))
1913
2750
  continue;
1914
- wearRoot.remove(piece2.object);
2751
+ headWearRoot.remove(piece2.object);
2752
+ bodyWearRoot.remove(piece2.object);
1915
2753
  piece2.dispose();
1916
2754
  worn.delete(key);
1917
2755
  }
1918
2756
  for (const key of wanted) {
1919
2757
  if (worn.has(key))
1920
2758
  continue;
2759
+ const onHead2 = isHeadPiece(key);
2760
+ const kit = onHead2 ? isHairKey(key) ? headKit : { ...headKit, ink: fine } : bodyKit;
1921
2761
  const piece2 = buildWear(key, kit);
1922
2762
  worn.set(key, piece2);
1923
- wearRoot.add(piece2.object);
2763
+ (onHead2 ? headWearRoot : bodyWearRoot).add(piece2.object);
1924
2764
  }
1925
2765
  const volume = Math.max(0, ...[...worn.keys()].filter(isHairKey).map(hairVolume));
1926
2766
  for (const [key, piece2] of worn)
1927
2767
  if (wearSlotOf(key) === "hat")
1928
2768
  piece2.object.position.y = volume;
2769
+ const pantHex = isFigure ? [...worn.keys()].map((k) => OUTFIT_LEG_COLOR[k]).find(Boolean) ?? shade(color, 0, 0.05) : shade(color, 0, 0.12);
2770
+ legMaterial.uniforms.color?.value?.set(pantHex);
2771
+ legMaterial.uniforms.backColor?.value?.set(pantHex);
1929
2772
  };
1930
2773
  setWear(options.wear ?? []);
1931
2774
  const limbGeometry = new CapsuleGeometry(0.075, 0.2, 4, 10);
1932
- const handGeometry = new SphereGeometry3(0.11, 12, 10);
1933
- const footGeometry = new SphereGeometry3(0.13, 12, 10);
2775
+ const handGeometry = new SphereGeometry3(isFigure ? 0.056 : 0.11, 12, 10);
2776
+ const footGeometry = new SphereGeometry3(isFigure ? 0.072 : 0.13, 12, 10);
1934
2777
  const pivots = {
1935
2778
  armL: new Group2,
1936
2779
  armR: new Group2,
@@ -1938,31 +2781,32 @@ function createPlup(options = {}) {
1938
2781
  legR: new Group2
1939
2782
  };
1940
2783
  const armGeometries = [];
1941
- const limb = (name, x, y, length, tip, flat, bow2 = 0) => {
2784
+ const limb = (name, x, y, length, tip, flat, bow2 = 0, legStyle = false) => {
1942
2785
  const pivot = pivots[name];
1943
2786
  pivot.position.set(x, y, 0);
1944
- const curve = bow2 ? new QuadraticBezierCurve3(new Vector32(0, 0.02, 0), new Vector32(bow2 * 0.09, -length * 0.5, 0.03), new Vector32(bow2 * 0.03, -length, 0.04)) : null;
1945
- const shaft = curve ? taperedHose(curve, build.muscle) : limbGeometry;
2787
+ const curve = bow2 ? new QuadraticBezierCurve3(new Vector32(0, 0.02, 0), new Vector32(bow2 * (legStyle ? 0.025 : 0.07), -length * 0.5, legStyle ? 0.02 : 0.03), new Vector32(bow2 * (legStyle ? 0.01 : 0.03), -length, legStyle ? 0.01 : 0.04)) : null;
2788
+ const shaft = curve ? legStyle ? sculptedLeg(curve, build.hips, build.muscle) : taperedHose(curve, build.muscle, isFigure ? 0.042 : 0.046) : limbGeometry;
1946
2789
  if (curve)
1947
2790
  armGeometries.push(shaft);
1948
- const tube = new Mesh2(shaft, limbMaterial);
2791
+ const tube = new Mesh2(shaft, flat ? legMaterial : limbMaterial);
1949
2792
  if (!curve) {
1950
2793
  tube.position.y = -length / 2;
1951
2794
  tube.scale.y = length / 0.35;
1952
2795
  }
1953
- const end = new Mesh2(tip, tipMaterial);
2796
+ const end = new Mesh2(tip, flat && isFigure ? shoeMaterial : tipMaterial);
1954
2797
  if (curve)
1955
2798
  end.position.copy(curve.getPoint(1));
1956
2799
  else
1957
2800
  end.position.y = -length;
1958
2801
  if (flat)
1959
- end.scale.set(1.15, 0.5, 1.7);
2802
+ end.scale.set(isFigure ? 1.05 : 1.15, isFigure ? 0.65 : 0.5, isFigure ? 1.65 : 1.7);
1960
2803
  else
1961
- end.scale.setScalar(0.85);
1962
- const inkTube = new Mesh2(shaft, ink);
2804
+ end.scale.setScalar(isFigure ? 0.95 + Math.max(0, build.muscle - 1) * 0.25 : 0.85);
2805
+ const outlineMat = isFigure ? figureInk : ink;
2806
+ const inkTube = new Mesh2(shaft, outlineMat);
1963
2807
  inkTube.position.copy(tube.position);
1964
2808
  inkTube.scale.copy(tube.scale);
1965
- const inkEnd = new Mesh2(tip, ink);
2809
+ const inkEnd = new Mesh2(tip, outlineMat);
1966
2810
  inkEnd.position.copy(end.position);
1967
2811
  inkEnd.scale.copy(end.scale);
1968
2812
  pivot.add(tube, end, inkTube, inkEnd);
@@ -1970,6 +2814,81 @@ function createPlup(options = {}) {
1970
2814
  mesh.raycast = () => {};
1971
2815
  lifted.add(pivot);
1972
2816
  };
2817
+ const subPivots = { elbowL: null, elbowR: null, kneeL: null, kneeR: null };
2818
+ let figureLegLen = 0.44;
2819
+ const articulatedArm = (name, elbowKey, x, y, length) => {
2820
+ const pivot = pivots[name];
2821
+ pivot.position.set(x, y, 0);
2822
+ const upperLen = length * 0.5;
2823
+ const lowerLen = length * 0.5;
2824
+ const mScale = build.muscle > 1 ? 1 + (build.muscle - 1) * 0.42 : 0.84 + build.muscle * 0.16;
2825
+ const rTop = 0.046 * mScale;
2826
+ const rMid = 0.04 * mScale;
2827
+ const rWrist = 0.03 * mScale;
2828
+ const upperGeo = new CylinderGeometry2(rTop, rMid, upperLen, 12, 1);
2829
+ upperGeo.translate(0, -upperLen / 2, 0);
2830
+ const jointGeo = new SphereGeometry3(rMid * 1.04, 10, 8);
2831
+ const lowerGeo = new CylinderGeometry2(rMid, rWrist, lowerLen, 12, 1);
2832
+ lowerGeo.translate(0, -lowerLen / 2, 0);
2833
+ armGeometries.push(upperGeo, jointGeo, lowerGeo);
2834
+ const upperMesh = new Mesh2(upperGeo, limbMaterial);
2835
+ const upperInk = new Mesh2(upperGeo, figureInk);
2836
+ const jointMesh = new Mesh2(jointGeo, limbMaterial);
2837
+ jointMesh.position.y = -upperLen;
2838
+ const elbow = new Group2;
2839
+ elbow.position.set(0, -upperLen, 0);
2840
+ const lowerMesh = new Mesh2(lowerGeo, limbMaterial);
2841
+ const lowerInk = new Mesh2(lowerGeo, figureInk);
2842
+ const hand = new Mesh2(handGeometry, tipMaterial);
2843
+ hand.position.y = -lowerLen;
2844
+ hand.scale.setScalar(0.92 + Math.max(0, build.muscle - 1) * 0.22);
2845
+ const handInk = new Mesh2(handGeometry, figureInk);
2846
+ handInk.position.copy(hand.position);
2847
+ handInk.scale.copy(hand.scale);
2848
+ elbow.add(lowerMesh, lowerInk, hand, handInk);
2849
+ pivot.add(upperMesh, upperInk, jointMesh, elbow);
2850
+ for (const m of [...pivot.children, ...elbow.children])
2851
+ m.raycast = () => {};
2852
+ subPivots[elbowKey] = elbow;
2853
+ lifted.add(pivot);
2854
+ };
2855
+ const articulatedLeg = (name, kneeKey, x, y, length) => {
2856
+ const pivot = pivots[name];
2857
+ pivot.position.set(x, y, 0);
2858
+ const upperLen = length * 0.52;
2859
+ const lowerLen = length * 0.48;
2860
+ const thighBoost = 1 + Math.max(0, build.hips - 1) * 0.36 + Math.max(0, build.muscle - 1) * 0.22;
2861
+ const compact = Math.min(1, 0.65 + 0.35 * build.torsoHeight);
2862
+ const rHip = 0.072 * thighBoost * compact;
2863
+ const rKnee = 0.048 * (0.85 + 0.15 * thighBoost) * compact;
2864
+ const rAnkle = 0.036 * compact;
2865
+ const thighGeo = new CylinderGeometry2(rHip, rKnee, upperLen, 12, 1);
2866
+ thighGeo.translate(0, -upperLen / 2, 0);
2867
+ const jointGeo = new SphereGeometry3(rKnee * 1.03, 10, 8);
2868
+ const shinGeo = new CylinderGeometry2(rKnee, rAnkle, lowerLen, 12, 1);
2869
+ shinGeo.translate(0, -lowerLen / 2, 0);
2870
+ armGeometries.push(thighGeo, jointGeo, shinGeo);
2871
+ const thighMesh = new Mesh2(thighGeo, legMaterial);
2872
+ const thighInk = new Mesh2(thighGeo, figureInk);
2873
+ const jointMesh = new Mesh2(jointGeo, legMaterial);
2874
+ jointMesh.position.y = -upperLen;
2875
+ const knee = new Group2;
2876
+ knee.position.set(0, -upperLen, 0);
2877
+ const shinMesh = new Mesh2(shinGeo, legMaterial);
2878
+ const shinInk = new Mesh2(shinGeo, figureInk);
2879
+ const shoe = new Mesh2(footGeometry, shoeMaterial);
2880
+ shoe.position.set(0, -lowerLen, 0.025 * compact);
2881
+ shoe.scale.set(1.02 * compact, 0.62 * compact, 1.58 * compact);
2882
+ const shoeInk = new Mesh2(footGeometry, figureInk);
2883
+ shoeInk.position.copy(shoe.position);
2884
+ shoeInk.scale.copy(shoe.scale);
2885
+ knee.add(shinMesh, shinInk, shoe, shoeInk);
2886
+ pivot.add(thighMesh, thighInk, jointMesh, knee);
2887
+ for (const m of [...pivot.children, ...knee.children])
2888
+ m.raycast = () => {};
2889
+ subPivots[kneeKey] = knee;
2890
+ lifted.add(pivot);
2891
+ };
1973
2892
  if (options.model) {
1974
2893
  lifted.add(options.model);
1975
2894
  for (const name of Object.keys(pivots)) {
@@ -1977,6 +2896,23 @@ function createPlup(options = {}) {
1977
2896
  if (found)
1978
2897
  pivots[name] = found;
1979
2898
  }
2899
+ } else if (isFigure) {
2900
+ const shPt = figureTorsoPoint(span.shoulderY, Math.PI / 2, silhouette);
2901
+ const shoulderX = Math.max(0.11, shPt.x * 0.92);
2902
+ const arm = 0.34 * build.armLength * (0.72 + 0.28 * build.torsoHeight);
2903
+ const hipAnchorY = span.hipY + 0.05 * build.torsoHeight;
2904
+ const hipPt = figureTorsoPoint(hipAnchorY, Math.PI / 2, silhouette);
2905
+ const hipX = Math.max(0.065, hipPt.x * 0.46);
2906
+ const leg = Math.max(0.24, legRaise + hipAnchorY - 0.02);
2907
+ figureLegLen = leg;
2908
+ articulatedArm("armL", "elbowL", -shoulderX, span.shoulderY, arm);
2909
+ articulatedArm("armR", "elbowR", shoulderX, span.shoulderY, arm);
2910
+ articulatedLeg("legL", "kneeL", -hipX, hipAnchorY, leg);
2911
+ articulatedLeg("legR", "kneeR", hipX, hipAnchorY, leg);
2912
+ pivots.armL.scale.set(fit.armWidth[0], 1, fit.armWidth[0]);
2913
+ pivots.armR.scale.set(fit.armWidth[1], 1, fit.armWidth[1]);
2914
+ pivots.legL.scale.set(fit.legWidth[0], 1, fit.legWidth[0]);
2915
+ pivots.legR.scale.set(fit.legWidth[1], 1, fit.legWidth[1]);
1980
2916
  } else {
1981
2917
  const torso = fit.girth / shape.x;
1982
2918
  const shoulderY = BLOB_HEIGHT * build.shoulderHeight;
@@ -2025,8 +2961,124 @@ function createPlup(options = {}) {
2025
2961
  let seconds = 0;
2026
2962
  let clock = 0;
2027
2963
  let lastDelta = 0;
2964
+ const danceKinematics = (active, t) => {
2965
+ const out = {
2966
+ elbowLx: -0.14,
2967
+ elbowLz: 0,
2968
+ elbowRx: -0.14,
2969
+ elbowRz: 0,
2970
+ kneeL: 0,
2971
+ kneeR: 0,
2972
+ hipX: 0,
2973
+ crouch: 0,
2974
+ squash: 0
2975
+ };
2976
+ if (typeof active !== "string")
2977
+ return out;
2978
+ const TAU = Math.PI * 2;
2979
+ const smooth01 = (v) => {
2980
+ const c = Math.max(0, Math.min(1, v));
2981
+ return c * c * (3 - 2 * c);
2982
+ };
2983
+ if (active === "brazil-funk") {
2984
+ const p = t % 1.6 / 1.6;
2985
+ const beat = 0.5 - 0.5 * Math.cos(p * TAU * 4);
2986
+ const sway = Math.sin(p * TAU * 2);
2987
+ out.elbowLx = -1.45 - 0.3 * Math.max(0, sway);
2988
+ out.elbowLz = 0.42 + 0.18 * sway;
2989
+ out.elbowRx = -1.45 - 0.3 * Math.max(0, -sway);
2990
+ out.elbowRz = -0.42 + 0.18 * sway;
2991
+ out.kneeL = 0.52 * beat + 0.18 * Math.max(0, sway);
2992
+ out.kneeR = 0.52 * beat + 0.18 * Math.max(0, -sway);
2993
+ out.hipX = sway * 0.11;
2994
+ out.crouch = 0.085 * beat;
2995
+ out.squash = -0.042 * beat + 0.018;
2996
+ } else if (active === "pacu-jalur") {
2997
+ const p = t % 2.4 / 2.4;
2998
+ const wave = Math.sin(p * TAU);
2999
+ const bounce = 0.5 - 0.5 * Math.cos(p * TAU * 2);
3000
+ out.elbowLx = -1.15 - 0.38 * wave;
3001
+ out.elbowLz = 0.35 + 0.38 * wave;
3002
+ out.elbowRx = -1.15 + 0.38 * wave;
3003
+ out.elbowRz = -0.35 + 0.38 * wave;
3004
+ out.kneeL = 0.52 + 0.22 * bounce + 0.12 * Math.max(0, wave);
3005
+ out.kneeR = 0.52 + 0.22 * bounce + 0.12 * Math.max(0, -wave);
3006
+ out.hipX = wave * 0.1;
3007
+ out.crouch = 0.095 + 0.055 * bounce;
3008
+ out.squash = -0.032 * bounce + 0.014;
3009
+ } else if (active === "velocity") {
3010
+ const p = t % 2 / 2;
3011
+ const hit1 = smooth01((p - 0.2) / 0.07) * (1 - smooth01((p - 0.46) / 0.12));
3012
+ const hit2 = smooth01((p - 0.63) / 0.07) * (1 - smooth01((p - 0.88) / 0.1));
3013
+ out.elbowLx = -0.55 - 1.15 * hit1 + 0.35 * hit2;
3014
+ out.elbowLz = 0.72 * hit1 - 0.15 * hit2;
3015
+ out.elbowRx = -0.55 - 1.15 * hit1 - 1.05 * hit2;
3016
+ out.elbowRz = -0.72 * hit1 - 0.55 * hit2;
3017
+ out.kneeL = 0.16 + 0.58 * hit1 + 0.22 * hit2;
3018
+ out.kneeR = 0.16 + 0.58 * hit1 + 0.34 * hit2;
3019
+ out.hipX = -0.08 * hit1 + 0.1 * hit2;
3020
+ out.crouch = 0.02 + 0.11 * hit1 + 0.04 * hit2;
3021
+ out.squash = -0.055 * hit1 + 0.028 * hit2;
3022
+ } else if (active === "griddy") {
3023
+ const p = t % 1.6 / 1.6;
3024
+ const goggles = 0.5 - 0.5 * Math.cos(p * TAU * 2);
3025
+ const step = Math.sin(p * TAU * 2);
3026
+ out.elbowLx = -0.25 - 1.85 * goggles;
3027
+ out.elbowLz = 0.46 * goggles;
3028
+ out.elbowRx = -0.25 - 1.85 * goggles;
3029
+ out.elbowRz = -0.46 * goggles;
3030
+ out.kneeL = 0.15 + 0.62 * Math.max(0, -step) + 0.18 * goggles;
3031
+ out.kneeR = 0.15 + 0.62 * Math.max(0, step) + 0.18 * goggles;
3032
+ out.hipX = step * 0.05;
3033
+ out.crouch = 0.045 + 0.055 * goggles;
3034
+ out.squash = -0.036 * goggles + 0.015;
3035
+ } else if (active === "floss") {
3036
+ const p = t % 1.6 / 1.6;
3037
+ const swing = Math.cos(p * TAU * 2);
3038
+ const beat = Math.abs(swing);
3039
+ out.elbowLx = -0.08;
3040
+ out.elbowRx = -0.08;
3041
+ out.kneeL = 0.2 + 0.16 * beat;
3042
+ out.kneeR = 0.2 + 0.16 * beat;
3043
+ out.hipX = -swing * 0.17;
3044
+ out.crouch = 0.035 * beat;
3045
+ out.squash = -0.026 * beat + 0.01;
3046
+ } else if (active === "caramel") {
3047
+ const p = t % 1.6 / 1.6;
3048
+ const sway = Math.cos(p * TAU);
3049
+ const beat = 0.5 - 0.5 * Math.cos(p * TAU * 2);
3050
+ const flap = Math.sin(p * TAU * 4) * 0.26;
3051
+ out.elbowLx = -0.35;
3052
+ out.elbowLz = -1.2 + flap;
3053
+ out.elbowRx = -0.35;
3054
+ out.elbowRz = 1.2 - flap;
3055
+ out.kneeL = 0.45 * (1 - beat) + 0.15 * Math.max(0, sway);
3056
+ out.kneeR = 0.45 * (1 - beat) + 0.15 * Math.max(0, -sway);
3057
+ out.hipX = -sway * 0.14;
3058
+ out.crouch = 0.075 * (1 - beat);
3059
+ out.squash = -0.042 * (1 - beat) + 0.024 * beat;
3060
+ } else if (active === "walk" || active === "run") {
3061
+ const rate = active === "run" ? 2.4 : 1.4;
3062
+ const stride = Math.sin(t * rate * TAU);
3063
+ const bend = active === "run" ? 0.95 : 0.42;
3064
+ out.elbowLx = -0.25 - Math.max(0, -stride) * bend;
3065
+ out.elbowRx = -0.25 - Math.max(0, stride) * bend;
3066
+ out.kneeL = Math.max(0, stride) * (active === "run" ? 0.95 : 0.55);
3067
+ out.kneeR = Math.max(0, -stride) * (active === "run" ? 0.95 : 0.55);
3068
+ } else if (active === "dance") {
3069
+ const beat = 0.5 - 0.5 * Math.cos(t * 2 * TAU);
3070
+ out.elbowLx = -0.65 - 0.35 * beat;
3071
+ out.elbowRx = -0.65 - 0.35 * beat;
3072
+ out.kneeL = 0.38 * beat;
3073
+ out.kneeR = 0.38 * beat;
3074
+ out.hipX = Math.sin(t * TAU) * 0.08;
3075
+ out.crouch = 0.05 * beat;
3076
+ }
3077
+ return out;
3078
+ };
2028
3079
  const apply = () => {
2029
3080
  const pose = resolvePose("plup", mergePoses(sampleClip(clip2, seconds), held));
3081
+ const kin = danceKinematics(clip2, seconds);
2030
3082
  const byAlias = {
2031
3083
  armL: "LeftArm",
2032
3084
  armR: "RightArm",
@@ -2039,16 +3091,34 @@ function createPlup(options = {}) {
2039
3091
  const clearance = name === "armL" ? fit.armClear[0] : name === "armR" ? -fit.armClear[1] : 0;
2040
3092
  const z = rotation?.z ?? 0;
2041
3093
  const side = name === "armL" ? -1 : name === "armR" ? 1 : 0;
2042
- const rest = options.model ? 0 : side * 0.42 * Math.max(0, 1 - Math.abs(z) / 1.4);
2043
- pivots[name].rotation.set(rotation?.x ?? 0, rotation?.y ?? 0, z + clearance + rest);
2044
- targets[name] = { x: rotation?.x ?? 0, z: z + clearance + rest };
3094
+ const restAngle = isFigure ? 0.14 : 0.42;
3095
+ const rest = options.model ? 0 : side * restAngle * Math.max(0, 1 - Math.abs(z) / 1.4);
3096
+ const kneeComp = isFigure && name === "legL" ? -kin.kneeL * 0.45 : isFigure && name === "legR" ? -kin.kneeR * 0.45 : 0;
3097
+ const rx = (rotation?.x ?? 0) + kneeComp;
3098
+ pivots[name].rotation.set(rx, rotation?.y ?? 0, z + clearance + rest);
3099
+ targets[name] = { x: rx, z: z + clearance + rest };
2045
3100
  }
3101
+ if (subPivots.elbowL)
3102
+ subPivots.elbowL.rotation.set(kin.elbowLx, 0, kin.elbowLz);
3103
+ if (subPivots.elbowR)
3104
+ subPivots.elbowR.rotation.set(kin.elbowRx, 0, kin.elbowRz);
3105
+ if (subPivots.kneeL)
3106
+ subPivots.kneeL.rotation.set(kin.kneeL, 0, 0);
3107
+ if (subPivots.kneeR)
3108
+ subPivots.kneeR.rotation.set(kin.kneeR, 0, 0);
2046
3109
  const body = pose.get("Body");
3110
+ const head = pose.get("Head");
2047
3111
  lifted.rotation.set(body?.x ?? 0, body?.y ?? 0, body?.z ?? 0);
2048
- const clipLiftY = legRaise + clipLift(clip2, seconds) * 0.32 * fit.lift;
2049
- const breath = Math.sin(clock * 3.2) * 0.018 * fit.squash;
2050
- lifted.scale.set(shape.x * fit.stature * (1 - breath), shape.y * fit.stature * (1 + breath), shape.x * fit.stature * (1 - breath));
2051
- lifted.position.y = clipLiftY;
3112
+ if (isFigure) {
3113
+ headGroup.rotation.set(head?.x ?? 0, head?.y ?? 0, head?.z ?? 0);
3114
+ }
3115
+ const crouchDrop = isFigure ? kin.crouch * (figureLegLen / 0.44) : kin.crouch * 0.4;
3116
+ const clipLiftY = Math.max(0, legRaise + clipLift(clip2, seconds) * 0.32 * fit.lift - crouchDrop);
3117
+ const breath = Math.sin(clock * 3.2) * (isFigure ? 0.01 : 0.018) * fit.squash;
3118
+ const sy = 1 + breath + kin.squash;
3119
+ const sxz = 1 / Math.sqrt(Math.max(0.75, sy));
3120
+ lifted.scale.set((isFigure ? 1 : shape.x) * fit.stature * sxz, (isFigure ? 1 : shape.y) * fit.stature * sy, (isFigure ? 1 : shape.x) * fit.stature * sxz);
3121
+ lifted.position.set(kin.hipX, clipLiftY, 0);
2052
3122
  if (ragdoll) {
2053
3123
  root.getWorldPosition(here);
2054
3124
  const step2 = Math.max(0.001, lastDelta);
@@ -2082,13 +3152,14 @@ function createPlup(options = {}) {
2082
3152
  piece2.tick?.(clock, lastDelta, motion);
2083
3153
  if (shadow) {
2084
3154
  const air = Math.min(1, (lifted.position.y - legRaise) / 0.5);
2085
- shadow.scale.set((1 - air * 0.3) * fit.stature * fit.girth, 0.02, (0.9 - air * 0.3) * fit.stature * fit.girth);
3155
+ const shadowR = isFigure ? 0.72 : 1;
3156
+ shadow.scale.set((1 - air * 0.3) * fit.stature * fit.girth * shadowR, 0.02, (0.9 - air * 0.3) * fit.stature * fit.girth * shadowR);
2086
3157
  shadow.material.opacity = 0.4 - air * 0.18;
2087
3158
  }
2088
3159
  };
2089
3160
  apply();
2090
3161
  const redraw = () => {
2091
- paintBody(canvas, color, face, skin, options.faceType);
3162
+ paintBody(canvas, color, face, skin, options.faceType, isFigure);
2092
3163
  texture.needsUpdate = true;
2093
3164
  anime2?.draw(face);
2094
3165
  };
@@ -2138,8 +3209,17 @@ function createPlup(options = {}) {
2138
3209
  return;
2139
3210
  color = next;
2140
3211
  redraw();
2141
- limbMaterial.uniforms.color = { value: new Color2(shade(color, 0, 0.12)) };
2142
- tipMaterial.uniforms.color = { value: new Color2(shade(color, 0, 0.3)) };
3212
+ torsoMaterial.uniforms.color?.value?.set(color);
3213
+ torsoMaterial.uniforms.backColor?.value?.set(color);
3214
+ const limbHex = isFigure ? shade(color, 0, 0.05) : shade(color, 0, 0.12);
3215
+ const pantHex = isFigure ? [...worn.keys()].map((k) => OUTFIT_LEG_COLOR[k]).find(Boolean) ?? limbHex : limbHex;
3216
+ const tipHex = isFigure ? shade(color, 0, 0.12) : shade(color, 0, 0.3);
3217
+ limbMaterial.uniforms.color?.value?.set(limbHex);
3218
+ limbMaterial.uniforms.backColor?.value?.set(limbHex);
3219
+ legMaterial.uniforms.color?.value?.set(pantHex);
3220
+ legMaterial.uniforms.backColor?.value?.set(pantHex);
3221
+ tipMaterial.uniforms.color?.value?.set(tipHex);
3222
+ tipMaterial.uniforms.backColor?.value?.set(tipHex);
2143
3223
  },
2144
3224
  setWear,
2145
3225
  update(delta) {
@@ -2151,6 +3231,7 @@ function createPlup(options = {}) {
2151
3231
  dispose() {
2152
3232
  setWear([]);
2153
3233
  geometry.dispose();
3234
+ torsoGeometry?.dispose();
2154
3235
  limbGeometry.dispose();
2155
3236
  for (const arm of armGeometries)
2156
3237
  arm.dispose();
@@ -2160,8 +3241,11 @@ function createPlup(options = {}) {
2160
3241
  anime2?.material.map?.dispose();
2161
3242
  anime2?.material.dispose();
2162
3243
  bodyMaterial.dispose();
3244
+ torsoMaterial.dispose();
2163
3245
  limbMaterial.dispose();
3246
+ legMaterial.dispose();
2164
3247
  tipMaterial.dispose();
3248
+ shoeMaterial.dispose();
2165
3249
  if (shadow) {
2166
3250
  shadow.geometry.dispose();
2167
3251
  shadow.material.dispose();
@@ -2296,7 +3380,25 @@ function createCharacter(rigId = "plup", look = { bodyColor: "#3d7bff" }, bodySc
2296
3380
  };
2297
3381
  }
2298
3382
  export {
3383
+ wearSlotOf,
3384
+ toon,
3385
+ isWearKey,
3386
+ isHighResFace,
3387
+ isHairKey,
3388
+ hairVolume,
3389
+ figureTorsoPoint,
3390
+ drawAnimeFace,
2299
3391
  createPlup,
2300
3392
  createCharacter,
2301
- buildWear
3393
+ buildWear,
3394
+ buildFigureTorsoGeometry,
3395
+ buildFigureHeadGeometry,
3396
+ buildBlobGeometry,
3397
+ blobRadiusAt,
3398
+ WEARABLES,
3399
+ EMOTES,
3400
+ BODY_PRESETS,
3401
+ AUTHORED_CLIPS,
3402
+ ANIME_FACE_UV,
3403
+ ANIME_FACE_SIZE
2302
3404
  };