ara3d 0.1.0 → 0.3.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.
Files changed (123) hide show
  1. package/README.md +38 -8
  2. package/dist/cli.js +5 -5
  3. package/dist/embed.js +16579 -0
  4. package/dist/index.js +1877 -0
  5. package/dist/types/packages/cli/src/embed.d.ts +43 -0
  6. package/dist/types/packages/cli/src/index.d.ts +109 -0
  7. package/dist/types/packages/cli/src/library/colors.d.ts +9 -0
  8. package/dist/types/packages/cli/src/library/generate.d.ts +40 -0
  9. package/dist/types/packages/cli/src/library/sequence.d.ts +14 -0
  10. package/dist/types/packages/cli/src/library/worker.d.ts +22 -0
  11. package/dist/types/src/app/character-assist.d.ts +73 -0
  12. package/dist/types/src/app/share.d.ts +19 -0
  13. package/dist/types/src/core/anim/boarding.d.ts +4 -0
  14. package/dist/types/src/core/anim/clips/actions.d.ts +9 -0
  15. package/dist/types/src/core/anim/clips/aerial.d.ts +7 -0
  16. package/dist/types/src/core/anim/clips/basic.d.ts +4 -0
  17. package/dist/types/src/core/anim/clips/climbing.d.ts +37 -0
  18. package/dist/types/src/core/anim/clips/combat.d.ts +6 -0
  19. package/dist/types/src/core/anim/clips/cover.d.ts +19 -0
  20. package/dist/types/src/core/anim/clips/dodge.d.ts +8 -0
  21. package/dist/types/src/core/anim/clips/emotes.d.ts +21 -0
  22. package/dist/types/src/core/anim/clips/everyday.d.ts +15 -0
  23. package/dist/types/src/core/anim/clips/faces.d.ts +11 -0
  24. package/dist/types/src/core/anim/clips/gait.d.ts +17 -0
  25. package/dist/types/src/core/anim/clips/gunshot.d.ts +8 -0
  26. package/dist/types/src/core/anim/clips/helpers.d.ts +26 -0
  27. package/dist/types/src/core/anim/clips/index.d.ts +8 -0
  28. package/dist/types/src/core/anim/clips/interaction.d.ts +18 -0
  29. package/dist/types/src/core/anim/clips/lying.d.ts +8 -0
  30. package/dist/types/src/core/anim/clips/melee.d.ts +3 -0
  31. package/dist/types/src/core/anim/clips/mocap-data.d.ts +6 -0
  32. package/dist/types/src/core/anim/clips/reactions.d.ts +34 -0
  33. package/dist/types/src/core/anim/clips/recorded.d.ts +12 -0
  34. package/dist/types/src/core/anim/clips/runner.d.ts +10 -0
  35. package/dist/types/src/core/anim/clips/shooter.d.ts +15 -0
  36. package/dist/types/src/core/anim/clips/speech.d.ts +10 -0
  37. package/dist/types/src/core/anim/clips/swimming.d.ts +17 -0
  38. package/dist/types/src/core/anim/clips/types.d.ts +152 -0
  39. package/dist/types/src/core/anim/clips/vehicles.d.ts +28 -0
  40. package/dist/types/src/core/anim/evaluate.d.ts +188 -0
  41. package/dist/types/src/core/anim/mocap.d.ts +120 -0
  42. package/dist/types/src/core/anim/quat.d.ts +14 -0
  43. package/dist/types/src/core/anim/riding-weapons.d.ts +13 -0
  44. package/dist/types/src/core/anim/stage.d.ts +5 -0
  45. package/dist/types/src/core/assets.d.ts +114 -0
  46. package/dist/types/src/core/face.d.ts +56 -0
  47. package/dist/types/src/core/garments/bags.d.ts +2 -0
  48. package/dist/types/src/core/garments/beach.d.ts +9 -0
  49. package/dist/types/src/core/garments/body.d.ts +70 -0
  50. package/dist/types/src/core/garments/catalog.d.ts +8 -0
  51. package/dist/types/src/core/garments/drape.d.ts +86 -0
  52. package/dist/types/src/core/garments/dress-shoes.d.ts +7 -0
  53. package/dist/types/src/core/garments/earpiece.d.ts +2 -0
  54. package/dist/types/src/core/garments/gowns.d.ts +2 -0
  55. package/dist/types/src/core/garments/gulf.d.ts +2 -0
  56. package/dist/types/src/core/garments/heels.d.ts +8 -0
  57. package/dist/types/src/core/garments/index.d.ts +36 -0
  58. package/dist/types/src/core/garments/kit.d.ts +173 -0
  59. package/dist/types/src/core/garments/last.d.ts +78 -0
  60. package/dist/types/src/core/garments/layering.d.ts +4 -0
  61. package/dist/types/src/core/garments/necklaces.d.ts +2 -0
  62. package/dist/types/src/core/garments/outfit-cut.d.ts +30 -0
  63. package/dist/types/src/core/garments/prison.d.ts +2 -0
  64. package/dist/types/src/core/garments/project.d.ts +61 -0
  65. package/dist/types/src/core/garments/ring.d.ts +100 -0
  66. package/dist/types/src/core/garments/sets.d.ts +41 -0
  67. package/dist/types/src/core/garments/shell.d.ts +37 -0
  68. package/dist/types/src/core/garments/sheriff.d.ts +2 -0
  69. package/dist/types/src/core/garments/shirts.d.ts +31 -0
  70. package/dist/types/src/core/garments/sneakers.d.ts +7 -0
  71. package/dist/types/src/core/garments/street.d.ts +2 -0
  72. package/dist/types/src/core/garments/suit.d.ts +2 -0
  73. package/dist/types/src/core/garments/swimwear.d.ts +2 -0
  74. package/dist/types/src/core/garments/textures.d.ts +53 -0
  75. package/dist/types/src/core/garments/wrist.d.ts +2 -0
  76. package/dist/types/src/core/garments/yoruba.d.ts +2 -0
  77. package/dist/types/src/core/geometry.d.ts +31 -0
  78. package/dist/types/src/core/human.d.ts +42 -0
  79. package/dist/types/src/core/looks/hair.d.ts +64 -0
  80. package/dist/types/src/core/looks/index.d.ts +38 -0
  81. package/dist/types/src/core/looks/jewelry.d.ts +20 -0
  82. package/dist/types/src/core/looks/mouth.d.ts +12 -0
  83. package/dist/types/src/core/looks/overlay.d.ts +42 -0
  84. package/dist/types/src/core/looks/tattoos.d.ts +11 -0
  85. package/dist/types/src/core/looks/textures.d.ts +8 -0
  86. package/dist/types/src/core/math.d.ts +29 -0
  87. package/dist/types/src/core/mesh.d.ts +75 -0
  88. package/dist/types/src/core/morph.d.ts +11 -0
  89. package/dist/types/src/core/pack.d.ts +7 -0
  90. package/dist/types/src/core/params.d.ts +103 -0
  91. package/dist/types/src/core/props/bicycle.d.ts +26 -0
  92. package/dist/types/src/core/props/carry.d.ts +67 -0
  93. package/dist/types/src/core/props/helicopter-layout.d.ts +11 -0
  94. package/dist/types/src/core/props/horse-gait.d.ts +11 -0
  95. package/dist/types/src/core/props/parachute.d.ts +14 -0
  96. package/dist/types/src/core/props/stage-props.d.ts +23 -0
  97. package/dist/types/src/core/props/vehicle-actions.d.ts +23 -0
  98. package/dist/types/src/core/props/vehicle-bodies.d.ts +5 -0
  99. package/dist/types/src/core/props/vehicle-car.d.ts +2 -0
  100. package/dist/types/src/core/props/vehicle-doors.d.ts +2 -0
  101. package/dist/types/src/core/props/vehicle-helicopter.d.ts +2 -0
  102. package/dist/types/src/core/props/vehicle-horse.d.ts +2 -0
  103. package/dist/types/src/core/props/vehicle-kit.d.ts +61 -0
  104. package/dist/types/src/core/props/vehicle-land.d.ts +3 -0
  105. package/dist/types/src/core/props/vehicle-merge.d.ts +3 -0
  106. package/dist/types/src/core/props/vehicle-motion.d.ts +104 -0
  107. package/dist/types/src/core/props/vehicle-special.d.ts +3 -0
  108. package/dist/types/src/core/props/vehicle-stunt.d.ts +16 -0
  109. package/dist/types/src/core/props/vehicle-water.d.ts +2 -0
  110. package/dist/types/src/core/props/vehicle.d.ts +49 -0
  111. package/dist/types/src/core/props/vehicles.d.ts +60 -0
  112. package/dist/types/src/core/props/weapons.d.ts +21 -0
  113. package/dist/types/src/core/rig/poses.d.ts +7 -0
  114. package/dist/types/src/core/rig/rig.d.ts +75 -0
  115. package/dist/types/src/core/rig/skeletons.d.ts +33 -0
  116. package/dist/types/src/core/rig/socket.d.ts +21 -0
  117. package/dist/types/src/core/skin-rough.d.ts +11 -0
  118. package/dist/types/src/export/fbx.d.ts +10 -0
  119. package/dist/types/src/export/glb.d.ts +9 -0
  120. package/dist/types/src/export/index.d.ts +22 -0
  121. package/dist/types/src/export/obj.d.ts +6 -0
  122. package/dist/types/src/export/plan.d.ts +63 -0
  123. package/package.json +13 -4
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Shoe lasts: the shared body of a closed shoe, designed as a shoe rather than wrapped round the
3
+ * foot's surface. In each foot's frame (x along the foot, z across, y up) the upper is a loft of
4
+ * rounded cross-sections sized to contain the foot with a margin (so toes never show), rising
5
+ * from a rounded toe box over the instep to the collar at the back. Soles follow the same outline.
6
+ */
7
+ import type { PolyMesh } from '../geometry';
8
+ import { type Vec3 } from '../math';
9
+ import { type Body } from './body';
10
+ export interface LastOpts {
11
+ /** Side margin round the foot. */
12
+ margin: number;
13
+ /** Toe box height (at least), above the bottom of the foot. */
14
+ toeH: number;
15
+ /** Clearance over the top of the foot. */
16
+ instep: number;
17
+ /** Length past the toes and behind the heel. */
18
+ toe: number;
19
+ heel: number;
20
+ /** How far the collar rises above the ankle joint (it always covers the foot). */
21
+ collarRise: number;
22
+ /** Toe shape: where along the shoe (0..1) the toe starts rounding off. */
23
+ toeFrom: number;
24
+ /**
25
+ * A low-cut shoe (a loafer): the upper is cut down to this height above the bottom of the foot
26
+ * from the heel to `throat` (0..1 along the shoe), where it rises into the vamp. The foot shows
27
+ * above it.
28
+ */
29
+ topline?: {
30
+ h: number;
31
+ throat: number;
32
+ };
33
+ }
34
+ export interface Last {
35
+ rings: Vec3[][];
36
+ /** Rings (N + 1 along the foot) and points per ring (M). */
37
+ N: number;
38
+ M: number;
39
+ /** Foot frame: origin, along, across. */
40
+ fa: Vec3;
41
+ X: Vec3;
42
+ Z: Vec3;
43
+ world(x: number, y: number, z: number): Vec3;
44
+ /** Bottom of the foot. */
45
+ minY: number;
46
+ /** Shoe extent along the foot. */
47
+ sx0: number;
48
+ sx1: number;
49
+ zLo: number[];
50
+ zHi: number[];
51
+ collarY: number;
52
+ /** Lower-leg points near the collar. */
53
+ legLow: Vec3[];
54
+ foot: Vec3[];
55
+ /** Middle of the foot (skin lookup for the rigid shoe). */
56
+ mid: Vec3;
57
+ upper: PolyMesh;
58
+ /** The cut edge round a low-cut shoe's opening, from one side of the throat round the heel to the other. */
59
+ rim: Vec3[];
60
+ }
61
+ export declare function last(b: Body, s: number, o: LastOpts): Last | null;
62
+ /**
63
+ * The sole's outline `margin` outside the foot, rounded at the toe and heel (by `toeRound` and
64
+ * `heelRound` amounts): `level(y, inset)` gives it at height y, pulled in by `inset`.
65
+ */
66
+ export declare function soleOutline(l: Last, margin: number, toeRound?: number): {
67
+ level: (y: number, inset: number) => Vec3[];
68
+ zMid: number;
69
+ centre: Vec3;
70
+ };
71
+ /** A flat cap closing a ring (facing up or down). */
72
+ export declare function capRing(r: Vec3[], up: boolean): PolyMesh;
73
+ /** Point on the upper at (fractional) ring ri and angle index k, `lift` off the surface. */
74
+ export declare function surfaceAt(l: Last, ri: number, k: number, lift: number): Vec3;
75
+ /** Skin lookup for rigid shoes: every vertex follows the middle of its own foot. */
76
+ export declare function rigidFeet(m: PolyMesh, mids: Vec3[]): Float32Array;
77
+ /** Body faces of the feet (hidden inside closed shoes), or only those wholly below `below` (low-cut shoes). */
78
+ export declare function feetMask(b: Body, fv: Uint32Array, below?: number): Uint8Array;
@@ -0,0 +1,4 @@
1
+ import { type Body } from './body';
2
+ import { type GPart } from './kit';
3
+ /** `tops` and `jackets`: which of `parts` are the top's and the jacket's (updated in place). */
4
+ export declare function layerUnderJacket(body: Body, parts: GPart[], tops: Set<GPart>, jackets: Set<GPart>): void;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const NECKLACES: GarmentDef[];
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Garments cut from a MakeHuman outfit: the outfit is fitted to the body and rigged like any
3
+ * outfit, then only the pieces wanted (its UV islands, e.g. a suit's shirt but not its jeans) are
4
+ * kept and retextured with a generated pattern on the outfit's own UVs, keeping its normal map
5
+ * (folds and seams).
6
+ */
7
+ import type { PolyMesh } from '../geometry';
8
+ import type { Material } from '../mesh';
9
+ import { type FittedOutfit, type GarmentStyle, type GCtx } from './kit';
10
+ export interface Island {
11
+ u0: number;
12
+ u1: number;
13
+ v0: number;
14
+ v1: number;
15
+ }
16
+ /** The faces of an outfit whose UV island passes `keep` (judged by the island's UV bounds). */
17
+ export declare function keepIslands(m: PolyMesh, keep: (b: Island) => boolean): PolyMesh;
18
+ /**
19
+ * Body faces (in `regions`) under a piece cut from outfit `o`: every corner on the outfit's delete
20
+ * list and within `reach` of the piece. (The delete list alone covers everything the outfit's
21
+ * full set of pieces did, such as the chest under a suit's shirt front.)
22
+ */
23
+ export declare function outfitCovers(g: GCtx, o: FittedOutfit, m: PolyMesh, regions: number[], reach?: number): Uint8Array;
24
+ /** Upper-body regions a shirt covers. */
25
+ export declare const SHIRT_REGIONS: (1 | 2 | 4 | 5)[];
26
+ /**
27
+ * The outfit's surface in a generated pattern: `repeat` tiles of it across the outfit's UV atlas,
28
+ * with the outfit's normal map.
29
+ */
30
+ export declare function outfitCloth(g: GCtx, o: FittedOutfit, name: string, st: GarmentStyle, repeat: number, extra?: Partial<Material>): Material;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const PRISON: GarmentDef[];
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Projected patches: garment pieces designed as a flat grid (front view, back view or from below)
3
+ * and laid onto the body by casting rays along an axis. Edges follow the designed outline exactly,
4
+ * at any resolution, instead of the base mesh's faces (see shell.ts for fitted, body-face garments).
5
+ */
6
+ import type { PolyMesh } from '../geometry';
7
+ import type { Vec3 } from '../math';
8
+ import { type Body } from './body';
9
+ /** Axis the rays travel along: 'front' casts toward -Z (hits the front), 'back' toward +Z, 'below' toward +Y, 'above' toward -Y. */
10
+ export type CastDir = 'front' | 'back' | 'below' | 'above';
11
+ /** Casts rays at a set of body faces along one axis; a uniform grid over the other two axes. */
12
+ export declare class Caster {
13
+ readonly dir: CastDir;
14
+ private cells;
15
+ private tris;
16
+ private readonly u;
17
+ private readonly w;
18
+ private readonly d;
19
+ private readonly sign;
20
+ private readonly cell;
21
+ /**
22
+ * Casts at body faces (`keep` picks them) or, given a mesh, at all its polygons (a garment
23
+ * already built, to lay things on top of it).
24
+ */
25
+ constructor(src: Body | PolyMesh, faceVerts: Uint32Array | null, keep: (face: number) => boolean, dir: CastDir);
26
+ /**
27
+ * First surface hit for the ray through (a, b) on the two cross axes (x, y for front/back;
28
+ * x, z for below). Returns the point, the face's normal (toward the ray's origin side) and the face.
29
+ */
30
+ hit(a: number, b: number): {
31
+ p: Vec3;
32
+ n: Vec3;
33
+ face: number;
34
+ } | null;
35
+ }
36
+ /** Outward direction (away from the body) for each cast direction. */
37
+ export declare const OUTWARD: Record<CastDir, Vec3>;
38
+ /**
39
+ * Smooth a grid of surface points a little (cloth bridges small dips; edges stay on the outline;
40
+ * nothing sinks below the skin) and lift it off the skin along its normals (turned to face
41
+ * `outward`) by `offset`.
42
+ */
43
+ export declare function liftGrid(grid: Vec3[][], offset: number, outward: Vec3, smooth?: number): Vec3[][];
44
+ /** A quad mesh over a grid of points, with arc-length UVs tiling every `tile` metres. */
45
+ export declare function gridMesh(g: Vec3[][], tile: number): PolyMesh;
46
+ /** Points along the outline of a grid (its boundary loop), for piping and strings. */
47
+ export declare function gridOutline(grid: Vec3[][]): Vec3[];
48
+ /**
49
+ * Rays from a point inside the body outward (a radial projection): patches cast this way wrap
50
+ * round curved parts (the side of a breast) smoothly instead of grazing them from the front.
51
+ */
52
+ export declare class RadialCaster {
53
+ private tris;
54
+ constructor(body: Body, faceVerts: Uint32Array, keep: (face: number) => boolean);
55
+ /** The farthest surface along the ray from `o` in direction `d` (the outer skin): point, normal and body face. */
56
+ hit(o: Vec3, d: Vec3): {
57
+ p: Vec3;
58
+ n: Vec3;
59
+ face: number;
60
+ } | null;
61
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Ring-based garment geometry. A "hull ring" is the convex cross-section of a
3
+ * set of body vertices on a plane, pushed outward: the natural shape of
4
+ * anything wrapped around the body (wrappers, belts, straps, collars, cuffs,
5
+ * headbands). Plus small props: beads, shells, pouches, cards.
6
+ */
7
+ import { type PolyMesh } from '../geometry';
8
+ import type { Vec3 } from '../math';
9
+ export declare const v3: {
10
+ add: (a: Vec3, b: Vec3) => Vec3;
11
+ sub: (a: Vec3, b: Vec3) => Vec3;
12
+ scale: (a: Vec3, s: number) => Vec3;
13
+ madd: (a: Vec3, b: Vec3, s: number) => Vec3;
14
+ dot: (a: Vec3, b: Vec3) => number;
15
+ cross: (a: Vec3, b: Vec3) => Vec3;
16
+ len: (a: Vec3) => number;
17
+ norm: (a: Vec3) => Vec3;
18
+ lerp: (a: Vec3, b: Vec3, t: number) => Vec3;
19
+ };
20
+ export interface Plane {
21
+ origin: Vec3;
22
+ normal: Vec3;
23
+ /** In-plane reference direction for angle 0 (projected). Default: +Z, or +X if parallel. */
24
+ ref?: Vec3;
25
+ }
26
+ export interface RingOpts {
27
+ /** Half-thickness of the slab of points considered (decimetres). */
28
+ slab: number;
29
+ samples: number;
30
+ /** Outward offset (decimetres), optionally varying with angle. */
31
+ offset: number | ((angle: number) => number);
32
+ /** Angle range; default full circle starting at the back (seam at the back). */
33
+ arc?: [number, number];
34
+ /** Shift the in-plane centre (decimetres along u, w). */
35
+ centreShift?: [number, number];
36
+ }
37
+ /**
38
+ * Convex cross-section ring of `points` on a plane. Angles: 0 = plane ref
39
+ * direction (front), +PI/2 = n x ref. Returns `samples` points (+1 for arcs).
40
+ */
41
+ export declare function hullRing(points: Vec3[], pl: Plane, o: RingOpts): Vec3[] | null;
42
+ /**
43
+ * Loft through rings of equal length. `closedAround`: rings are closed loops;
44
+ * `closedAcross`: last ring connects back to the first (solid straps).
45
+ */
46
+ export declare function loftRings(rings: Vec3[][], o: {
47
+ closedAround: boolean;
48
+ closedAcross?: boolean;
49
+ tileU?: number;
50
+ tileV?: number;
51
+ uRepeats?: number;
52
+ }): PolyMesh;
53
+ /** Flip all faces if they mostly face toward `centre` (so normals point outward). */
54
+ export declare function orientOutward(m: PolyMesh, centre: Vec3): PolyMesh;
55
+ /** Merge several PolyMeshes into one. */
56
+ export declare function merge(parts: (PolyMesh | null | undefined)[]): PolyMesh | null;
57
+ /**
58
+ * A solid band (belt, strap, cuff) around the body: rings on parallel planes
59
+ * across its width, outer surface plus a slightly smaller inner surface.
60
+ */
61
+ export declare function solidBand(points: Vec3[], pl: Plane, width: number, thickness: number, offset: number, o: {
62
+ samples: number;
63
+ slab?: number;
64
+ arc?: [number, number];
65
+ tileU?: number;
66
+ uRepeats?: number;
67
+ steps?: number;
68
+ }): PolyMesh | null;
69
+ interface Frame {
70
+ o: Vec3;
71
+ x: Vec3;
72
+ y: Vec3;
73
+ z: Vec3;
74
+ }
75
+ /** Frame from an origin, a "forward" (z) and an "up" hint (y). */
76
+ export declare function frameOf(o: Vec3, forward: Vec3, up: Vec3): Frame;
77
+ /** UV sphere / ellipsoid with radii (rx, ry, rz) in the frame. All corners map to `uv`. */
78
+ export declare function ellipsoid(f: Frame, r: Vec3, uv: [number, number], seg?: number, rings?: number): PolyMesh;
79
+ /** Rounded box (a subdivided cube) with half-sizes (hx, hy, hz); planar UVs. */
80
+ export declare function roundedBox(f: Frame, h: Vec3, round?: number): PolyMesh;
81
+ /** Flat card from `base` along `dir` (length) with `width` across `side`; UV 0..1. */
82
+ export declare function card(base: Vec3, dir: Vec3, side: Vec3, length: number, width: number, taper?: number, segs?: number): PolyMesh;
83
+ /** Points spaced evenly (by arc length) along a closed or open polyline. */
84
+ export declare function along(poly: Vec3[], spacing: number, closed: boolean): {
85
+ p: Vec3;
86
+ tangent: Vec3;
87
+ i: number;
88
+ }[];
89
+ /** Thin round cord along a polyline. */
90
+ export declare function cord(poly: Vec3[], radius: number, closed: boolean, sides?: number): PolyMesh;
91
+ /** Farthest crossing of a closed ring (in the horizontal plane) along a ray from c in direction d. */
92
+ export declare function rayRing(ring: Vec3[], c: Vec3, d: Vec3): number | null;
93
+ /**
94
+ * The longest chain of a mesh's boundary edges (an open edge such as a neckline) among those whose
95
+ * ends pass `keep`, in order; closed loops come back with the first point repeated.
96
+ */
97
+ export declare function boundaryChain(m: PolyMesh, keep: (p: Vec3) => boolean): Vec3[];
98
+ /** A flat strap (webbing) along a polyline, lying on a surface with the given normals: width w. */
99
+ export declare function ribbon(line: Vec3[], normals: Vec3[], w: number, th: number): PolyMesh;
100
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Outfit sets: a top and a bottom worn together (with suggested extras), listed with the full
3
+ * outfits. The pieces either share the set's pattern and colours, or keep their own.
4
+ */
5
+ import type { HumanParams } from '../params';
6
+ import type { GarmentDef } from './kit';
7
+ import type { CarryId } from '../props/carry';
8
+ /** Outfits that pair a top and a bottom (and suggested extras), listed with the full outfits. */
9
+ export interface OutfitSet {
10
+ id: string;
11
+ label: string;
12
+ top: string;
13
+ /** Worn over the top: a suit jacket. */
14
+ jacket?: string;
15
+ bottom: string;
16
+ /** Added when the set is picked (can be removed afterwards). */
17
+ accessories: string[];
18
+ shoes?: string;
19
+ /** Bag (see props/carry). */
20
+ carry?: CarryId;
21
+ hat?: string;
22
+ /**
23
+ * Patterns offered for the whole set (first = default) and default colours, shared by the top
24
+ * and bottom, or by the jacket and bottom when there is a jacket (a suit; the shirt keeps its
25
+ * own). Without them each piece keeps its own pattern and colours (e.g. a tee and jeans).
26
+ */
27
+ patterns?: GarmentDef['patterns'];
28
+ color?: string;
29
+ color2?: string;
30
+ }
31
+ type Styles = HumanParams['garmentStyles'];
32
+ /** The pieces of a set that share its pattern and colours: a suit's jacket and trousers, otherwise top and bottom. */
33
+ export declare const sharedPieces: (set: OutfitSet) => string[];
34
+ /**
35
+ * The garment styles a set dresses with: a shared set applies its pattern and colours (and any
36
+ * the user picked for the set) to its shared pieces, and a matching gele unless it has its own.
37
+ */
38
+ export declare function setStyles(set: OutfitSet, styles: Styles): Styles;
39
+ export declare const OUTFIT_SETS: OutfitSet[];
40
+ export declare const setById: Map<string, OutfitSet>;
41
+ export {};
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Fitted garments grown from the body surface: select body faces by a
3
+ * coverage predicate, push them out along the normals, and close the open
4
+ * hems with a rim so the cloth has visible thickness.
5
+ */
6
+ import type { PolyMesh } from '../geometry';
7
+ import { type Body, type VInfo } from './body';
8
+ export interface ShellSpec {
9
+ covers: (v: VInfo, p: [number, number, number]) => boolean;
10
+ /** Offset from the skin in decimetres (may vary per vertex, e.g. looser at the hem). */
11
+ offset: number | ((v: VInfo, p: [number, number, number]) => number);
12
+ /** Texture tile size in metres. */
13
+ tile?: number;
14
+ /** Laplacian relaxation passes: cloth bridges over small skin detail. */
15
+ relax?: number;
16
+ /**
17
+ * Depth of the hem's turned-in edge. By default the rim runs back down to the skin (right for
18
+ * fitted clothes); loose clothes set a small depth so their edges read as thin fabric.
19
+ */
20
+ hemDepth?: number;
21
+ /** Leave the hems open (no rim), for garments that continue the surface from a hem. */
22
+ noRim?: boolean;
23
+ }
24
+ /** Collects face-varying UVs with value de-duplication. */
25
+ export declare class UVs {
26
+ readonly data: number[];
27
+ private keys;
28
+ add(u: number, v: number): number;
29
+ }
30
+ /** Tiling UV for a body vertex: angle around its region axis, distance along it. */
31
+ export declare function bodyUV(body: Body, v: number, tile: number): [number, number];
32
+ export interface ShellResult {
33
+ mesh: PolyMesh;
34
+ /** Body-face mask covered by this shell (for hiding skin underneath). */
35
+ covered: Uint8Array;
36
+ }
37
+ export declare function buildShell(body: Body, faceVerts: Uint32Array, spec: ShellSpec): ShellResult | null;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const SHERIFF: GarmentDef[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Shirts: a V neckline cut and a button placket (used by the prison jumpsuit's top), and the
3
+ * resort shirt, cut from a MakeHuman suit and printed.
4
+ */
5
+ import { type PolyMesh } from '../geometry';
6
+ import type { Material } from '../mesh';
7
+ import { type Body, type VInfo } from './body';
8
+ import { type GarmentDef, type GCtx, type GPart } from './kit';
9
+ /** A V neckline: its point's trunk height (tt), and half-width at the base of the neck (fraction of the shoulder width). */
10
+ export interface VOpts {
11
+ ttV: number;
12
+ vw: number;
13
+ }
14
+ /** Where the V neckline (and a slightly lowered back neck) is cut out of a shirt's shell. */
15
+ export declare function vNeck(b: Body, o: VOpts): (v: VInfo) => boolean;
16
+ export interface PlacketOpts {
17
+ /** Trunk height (tt) of the V's point, where the placket starts. */
18
+ ttV: number;
19
+ /** Buttons below the V, and their spacing (decimetres). */
20
+ buttons: number;
21
+ spacing: number;
22
+ /** Trunk height (tt) the placket runs down to. */
23
+ placketTo: number;
24
+ buttonColor: string;
25
+ }
26
+ /**
27
+ * The button placket below the V of a shirt whose shell is `top`, with its buttons. A shirt
28
+ * tucked in stops where the bottom (already dressed, in `g.worn`) covers it.
29
+ */
30
+ export declare function placket(g: GCtx, top: PolyMesh, m: Material, o: PlacketOpts): GPart[];
31
+ export declare const SHIRTS: GarmentDef[];
@@ -0,0 +1,7 @@
1
+ import { type GarmentDef, type GarmentStyle, type GCtx, type GPart } from './kit';
2
+ /**
3
+ * `st`: the upper's finish (smooth leather, or worn canvas) and colour; color2 tints the sole
4
+ * (a worn pair's sole is grubby too).
5
+ */
6
+ export declare function sneakers(g: GCtx, st: GarmentStyle): GPart[];
7
+ export declare const SNEAKERS: GarmentDef;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const STREET: GarmentDef[];
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const SUIT: GarmentDef[];
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const SWIMWEAR: GarmentDef[];
@@ -0,0 +1,53 @@
1
+ export declare function encodePNG(w: number, h: number, rgba: Uint8Array, alpha: boolean, level?: 1 | 3 | 6 | 9): Uint8Array;
2
+ /** Same as encodePNG, using the platform's native zlib (CompressionStream) when available: several times faster on big images. */
3
+ export declare function encodePNGAsync(w: number, h: number, rgba: Uint8Array, alpha: boolean): Promise<Uint8Array>;
4
+ export type RGB = [number, number, number];
5
+ export declare const rgb: (hex: string) => RGB;
6
+ export interface TexOut {
7
+ color: Uint8Array;
8
+ normal?: Uint8Array;
9
+ alpha: boolean;
10
+ }
11
+ /** Fill a texture from a per-pixel function returning colour, alpha (0..1) and height. */
12
+ export declare function render(size: number, fn: (u: number, v: number) => {
13
+ c: RGB;
14
+ a?: number;
15
+ h?: number;
16
+ }, wantAlpha: boolean, normalStrength?: number): TexOut;
17
+ /** As render, for a w x h texture (u across, v down). */
18
+ export declare function renderRect(w: number, h: number, fn: (u: number, v: number) => {
19
+ c: RGB;
20
+ a?: number;
21
+ h?: number;
22
+ }, wantAlpha: boolean, normalStrength?: number): TexOut;
23
+ export type Pattern = 'solid' | 'camo' | 'kente' | 'asooke' | 'ankara' | 'shuka' | 'leather' | 'hide' | 'leopard' | 'fur' | 'techwear' | 'molle' | 'tattered' | 'beadbands' | 'khaki' | 'adire' | 'adire_panel' | 'ankara_floral' | 'ankara_web' | 'lace' | 'damask' | 'pleated' | 'foil' | 'straw' | 'denim' | 'rib' | 'jersey' | 'nappa' | 'workwear' | 'tropical' | 'linen' | 'suiting' | 'patent' | 'shemagh' | 'satin' | 'striped';
24
+ export declare const PATTERNS: Pattern[];
25
+ /**
26
+ * A pattern texture. `repeat`: how many times the pattern tiles across the texture each way (for
27
+ * an atlas whose UVs span a whole garment, such as a MakeHuman outfit's): one 256 px tile, copied.
28
+ */
29
+ /** A hex colour scaled by `k` (below 1 darker). */
30
+ export declare const shade: (hex: string, k: number) => string;
31
+ export declare function makePattern(p: Pattern, c1: string, c2: string, seed?: number, repeat?: number): TexOut;
32
+ /** Colour swatch strip for beads: N cells across u. */
33
+ export declare function palette(colors: string[]): TexOut;
34
+ /** Feather card texture (alpha): white/black barred vane. */
35
+ export declare function featherTexture(c1: string, c2: string): TexOut;
36
+ /**
37
+ * Unwrapped wash for one jeans leg (both legs share it): u runs round the leg (0.5 = front,
38
+ * 0.75 = outer side, 0.25 = inseam, 0 / 1 = back), v from the crotch (0) down to the hem (1).
39
+ * Indigo c1 worn toward c2 on the front of the thighs and knees, whiskers at the top, honeycomb
40
+ * behind the knee, roped side seams with topstitching on the outer one, and a worn hem.
41
+ */
42
+ export declare function jeansLegTexture(c1: string, c2: string, seed?: number): TexOut;
43
+ /**
44
+ * Stencilled block letters (alpha mask) for print on workwear: `text` in c1, worn through in places.
45
+ * Supports the letters the garments use (D, O, C).
46
+ */
47
+ /**
48
+ * A shirt-and-tie atlas: the shirt in `shirt` (a fine weave), and inside the polygon `tie` (in
49
+ * 0..1 texture coordinates, y down) the tie in `tieColor`, plain or with `stripe` repp stripes,
50
+ * shaded darker toward its edges so it reads rounded.
51
+ */
52
+ export declare function shirtTieTexture(size: number, tie: [number, number][], shirt: string, tieColor: string, stripe: string | null): TexOut;
53
+ export declare function stencilText(text: string, c1: string, seed?: number): TexOut;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const WRIST: GarmentDef[];
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const YORUBA: GarmentDef[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Polygon-mesh helpers: compaction, Catmull-Clark subdivision, normals, and
3
+ * conversion to per-vertex (UV-split) arrays.
4
+ */
5
+ /** Up to 4 bone influences per vertex. */
6
+ export interface Skin {
7
+ j: Uint16Array;
8
+ w: Float32Array;
9
+ }
10
+ /** A polygon mesh with face-varying UVs (as in OBJ). */
11
+ export interface PolyMesh {
12
+ positions: Float32Array;
13
+ faceSizes: Uint8Array;
14
+ faceVerts: Uint32Array;
15
+ faceUVs: Uint32Array;
16
+ uvs: Float32Array;
17
+ /** Skin weights, once assigned. */
18
+ skin?: Skin;
19
+ /** Base-mesh vertex each vertex was derived from (-1 = none), for weight transfer. */
20
+ ref?: Int32Array;
21
+ /** Blend-shape offsets: one array (vertex count * 3) per face shape, in the same order everywhere. */
22
+ morphs?: Float32Array[];
23
+ }
24
+ /** Blend weighted source influences into the top 4, normalised. */
25
+ export declare function blendInfluences(acc: Map<number, number>, j: Uint16Array, w: Float32Array, o: number): void;
26
+ /** Keep only faces passing `keep` and vertices they use. */
27
+ export declare function compact(m: PolyMesh, keep?: (f: number, corners: Uint32Array) => boolean): PolyMesh;
28
+ /** One level of Catmull-Clark subdivision. Boundaries use the crease rules; UVs are interpolated linearly. */
29
+ export declare function subdivide(m: PolyMesh): PolyMesh;
30
+ /** Smooth, angle-weighted vertex normals. */
31
+ export declare function vertexNormals(m: PolyMesh): Float32Array;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Builds a complete character: morphed body + fitted proxies (eyes, brows,
3
+ * lashes, hair, clothes, shoes, hat) + skeleton, as one multi-material mesh.
4
+ */
5
+ import type { AssetLibrary, CatalogItem } from './assets';
6
+ import { type Rig } from './rig/rig';
7
+ import { type WeaponId, type WeaponPart } from './props/weapons';
8
+ import { type Q } from './anim/quat';
9
+ import { type MeshData } from './mesh';
10
+ import { type HumanParams } from './params';
11
+ export interface Character {
12
+ params: HumanParams;
13
+ mesh: MeshData;
14
+ /** Skeleton + bind pose (absent when rigging is off). */
15
+ rig?: Rig;
16
+ /** Held weapon: its parts in the weapon frame and the weapon -> WeaponR socket rotation. */
17
+ weapon?: {
18
+ id: WeaponId;
19
+ rot: Q;
20
+ parts: WeaponPart[];
21
+ };
22
+ /** Standing height in metres (body, without hair/hat). */
23
+ height: number;
24
+ /** Facial blend shapes in the mesh (names and the expression's resting weights), if exported. */
25
+ face?: {
26
+ names: string[];
27
+ defaults: number[];
28
+ };
29
+ }
30
+ /** Pick the skin texture closest to the character's ethnicity, sex and age. */
31
+ export declare function autoSkin(p: HumanParams, skins: CatalogItem[]): CatalogItem;
32
+ export interface BuildOptions {
33
+ /** Called as the build moves through its stages (for progress UI). */
34
+ onStage?: (stage: string) => void;
35
+ }
36
+ export declare function buildHuman(lib: AssetLibrary, p: HumanParams, opts?: BuildOptions): Promise<Character>;
37
+ /** Texture files referenced by a mesh. */
38
+ export declare function textureFiles(mesh: MeshData): string[];
39
+ /** The character without its held weapon (the weapon parts are the last mesh groups). */
40
+ export declare function meshWithoutWeapon(ch: Character): MeshData;
41
+ /** The held weapon as a standalone prop in WeaponR socket space: attach it to that bone with zero offset. */
42
+ export declare function weaponPropMesh(ch: Character): MeshData | undefined;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Procedural hair: shaved / buzzed scalps and stubble (painted into the skin
3
+ * overlay), plus geometry for punk spikes, cornrows, box braids, beards and
4
+ * buzz cuts (hair cards). Masks are defined on the unmorphed base body (decimetres) and
5
+ * looked up per vertex, so they follow every head shape; geometry is built on
6
+ * the morphed body.
7
+ */
8
+ import { type Body } from '../garments/body';
9
+ import type { PolyMesh } from '../geometry';
10
+ import { type Vec3 } from '../math';
11
+ import type { Layer } from './overlay';
12
+ export declare const HAIRSTYLES: readonly [{
13
+ readonly id: 'buzz';
14
+ readonly name: 'Buzz cut';
15
+ }, {
16
+ readonly id: 'mohawk';
17
+ readonly name: 'Punk mohawk';
18
+ }, {
19
+ readonly id: 'cornrows';
20
+ readonly name: 'Cornrows';
21
+ }, {
22
+ readonly id: 'box_braids';
23
+ readonly name: 'Box braids';
24
+ }];
25
+ export type HairstyleId = (typeof HAIRSTYLES)[number]['id'];
26
+ export declare const isProceduralHair: (id: string) => id is HairstyleId;
27
+ export declare const FACIAL_HAIR: readonly ['none', 'stubble', 'mustache', 'mustache_stubble', 'goatee', 'short_beard', 'full_beard'];
28
+ export type FacialHairId = (typeof FACIAL_HAIR)[number];
29
+ export declare const FACIAL_HAIR_LABELS: Record<FacialHairId, string>;
30
+ /** Scalp coverage 0..1 at a base-body point. */
31
+ export declare function scalpMask(p: Vec3): number;
32
+ /**
33
+ * Facial hair coverage 0..1 at a base-body point (head + neck). For 'mustache_stubble' this is
34
+ * the mustache (its cards); the stubble round it uses the stubble mask.
35
+ */
36
+ export declare function beardMask(p: Vec3, style: FacialHairId, region: number): number;
37
+ /** Overlay paint for the scalp (buzzed / shaved) and facial stubble under any beard. */
38
+ export declare function hairLayers(hairstyle: string, facial: FacialHairId, color: string, beardColor: string): Layer[];
39
+ export interface HeadCtx {
40
+ base: Body;
41
+ coords: Float32Array;
42
+ normals: Float32Array;
43
+ regions: Uint8Array;
44
+ faceVerts: Uint32Array;
45
+ seed: number;
46
+ /** Fewer hair cards (low detail). */
47
+ low: boolean;
48
+ /** Base faces under headwear: no hair cards grow there. */
49
+ underHat?: Uint8Array;
50
+ }
51
+ /** Punk liberty spikes along the crest. */
52
+ export declare function spikes(c: HeadCtx): PolyMesh | undefined;
53
+ /** Cornrows: braids running straight back over the scalp. */
54
+ export declare function cornrows(c: HeadCtx): PolyMesh | undefined;
55
+ /** Box braids: many small braids from a grid of parts, hanging to about chin / neck length. */
56
+ export declare function boxBraids(c: HeadCtx, stopY: number): PolyMesh | undefined;
57
+ /** Beard / mustache hair cards rooted on the face. */
58
+ export declare function beardCards(c: HeadCtx, style: FacialHairId): PolyMesh | undefined;
59
+ /**
60
+ * Buzz cut: very short hair cards (5–9 mm) over the painted scalp. They stand up and curl a
61
+ * little, so the hairline and the head's outline get soft fuzz instead of a flat painted edge.
62
+ * About 8k triangles at medium detail; none at low detail (game LOD), where the painted scalp is enough.
63
+ */
64
+ export declare function buzzCards(c: HeadCtx): PolyMesh | undefined;