ara3d 0.0.0-stage → 0.2.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 (120) hide show
  1. package/README.md +40 -2
  2. package/dist/cli.js +57 -0
  3. package/dist/index.js +1806 -0
  4. package/dist/types/packages/cli/src/index.d.ts +89 -0
  5. package/dist/types/packages/cli/src/library/colors.d.ts +9 -0
  6. package/dist/types/packages/cli/src/library/generate.d.ts +40 -0
  7. package/dist/types/packages/cli/src/library/worker.d.ts +22 -0
  8. package/dist/types/src/app/character-assist.d.ts +73 -0
  9. package/dist/types/src/app/share.d.ts +19 -0
  10. package/dist/types/src/core/anim/boarding.d.ts +4 -0
  11. package/dist/types/src/core/anim/clips/actions.d.ts +9 -0
  12. package/dist/types/src/core/anim/clips/aerial.d.ts +7 -0
  13. package/dist/types/src/core/anim/clips/basic.d.ts +4 -0
  14. package/dist/types/src/core/anim/clips/climbing.d.ts +37 -0
  15. package/dist/types/src/core/anim/clips/combat.d.ts +6 -0
  16. package/dist/types/src/core/anim/clips/cover.d.ts +19 -0
  17. package/dist/types/src/core/anim/clips/dodge.d.ts +8 -0
  18. package/dist/types/src/core/anim/clips/emotes.d.ts +21 -0
  19. package/dist/types/src/core/anim/clips/everyday.d.ts +15 -0
  20. package/dist/types/src/core/anim/clips/faces.d.ts +11 -0
  21. package/dist/types/src/core/anim/clips/gait.d.ts +17 -0
  22. package/dist/types/src/core/anim/clips/gunshot.d.ts +8 -0
  23. package/dist/types/src/core/anim/clips/helpers.d.ts +26 -0
  24. package/dist/types/src/core/anim/clips/index.d.ts +8 -0
  25. package/dist/types/src/core/anim/clips/interaction.d.ts +18 -0
  26. package/dist/types/src/core/anim/clips/lying.d.ts +8 -0
  27. package/dist/types/src/core/anim/clips/melee.d.ts +3 -0
  28. package/dist/types/src/core/anim/clips/mocap-data.d.ts +6 -0
  29. package/dist/types/src/core/anim/clips/reactions.d.ts +34 -0
  30. package/dist/types/src/core/anim/clips/recorded.d.ts +12 -0
  31. package/dist/types/src/core/anim/clips/runner.d.ts +10 -0
  32. package/dist/types/src/core/anim/clips/shooter.d.ts +15 -0
  33. package/dist/types/src/core/anim/clips/speech.d.ts +10 -0
  34. package/dist/types/src/core/anim/clips/swimming.d.ts +17 -0
  35. package/dist/types/src/core/anim/clips/types.d.ts +152 -0
  36. package/dist/types/src/core/anim/clips/vehicles.d.ts +28 -0
  37. package/dist/types/src/core/anim/evaluate.d.ts +188 -0
  38. package/dist/types/src/core/anim/mocap.d.ts +120 -0
  39. package/dist/types/src/core/anim/quat.d.ts +14 -0
  40. package/dist/types/src/core/anim/riding-weapons.d.ts +13 -0
  41. package/dist/types/src/core/anim/stage.d.ts +5 -0
  42. package/dist/types/src/core/assets.d.ts +114 -0
  43. package/dist/types/src/core/face.d.ts +56 -0
  44. package/dist/types/src/core/garments/bags.d.ts +2 -0
  45. package/dist/types/src/core/garments/beach.d.ts +9 -0
  46. package/dist/types/src/core/garments/body.d.ts +70 -0
  47. package/dist/types/src/core/garments/catalog.d.ts +8 -0
  48. package/dist/types/src/core/garments/drape.d.ts +86 -0
  49. package/dist/types/src/core/garments/dress-shoes.d.ts +7 -0
  50. package/dist/types/src/core/garments/earpiece.d.ts +2 -0
  51. package/dist/types/src/core/garments/gowns.d.ts +2 -0
  52. package/dist/types/src/core/garments/gulf.d.ts +2 -0
  53. package/dist/types/src/core/garments/heels.d.ts +8 -0
  54. package/dist/types/src/core/garments/index.d.ts +36 -0
  55. package/dist/types/src/core/garments/kit.d.ts +173 -0
  56. package/dist/types/src/core/garments/last.d.ts +78 -0
  57. package/dist/types/src/core/garments/layering.d.ts +4 -0
  58. package/dist/types/src/core/garments/necklaces.d.ts +2 -0
  59. package/dist/types/src/core/garments/outfit-cut.d.ts +30 -0
  60. package/dist/types/src/core/garments/prison.d.ts +2 -0
  61. package/dist/types/src/core/garments/project.d.ts +61 -0
  62. package/dist/types/src/core/garments/ring.d.ts +100 -0
  63. package/dist/types/src/core/garments/sets.d.ts +41 -0
  64. package/dist/types/src/core/garments/shell.d.ts +37 -0
  65. package/dist/types/src/core/garments/sheriff.d.ts +2 -0
  66. package/dist/types/src/core/garments/shirts.d.ts +31 -0
  67. package/dist/types/src/core/garments/sneakers.d.ts +7 -0
  68. package/dist/types/src/core/garments/street.d.ts +2 -0
  69. package/dist/types/src/core/garments/suit.d.ts +2 -0
  70. package/dist/types/src/core/garments/swimwear.d.ts +2 -0
  71. package/dist/types/src/core/garments/textures.d.ts +53 -0
  72. package/dist/types/src/core/garments/wrist.d.ts +2 -0
  73. package/dist/types/src/core/garments/yoruba.d.ts +2 -0
  74. package/dist/types/src/core/geometry.d.ts +31 -0
  75. package/dist/types/src/core/human.d.ts +42 -0
  76. package/dist/types/src/core/looks/hair.d.ts +64 -0
  77. package/dist/types/src/core/looks/index.d.ts +38 -0
  78. package/dist/types/src/core/looks/jewelry.d.ts +20 -0
  79. package/dist/types/src/core/looks/mouth.d.ts +12 -0
  80. package/dist/types/src/core/looks/overlay.d.ts +42 -0
  81. package/dist/types/src/core/looks/tattoos.d.ts +11 -0
  82. package/dist/types/src/core/looks/textures.d.ts +8 -0
  83. package/dist/types/src/core/math.d.ts +29 -0
  84. package/dist/types/src/core/mesh.d.ts +75 -0
  85. package/dist/types/src/core/morph.d.ts +11 -0
  86. package/dist/types/src/core/pack.d.ts +7 -0
  87. package/dist/types/src/core/params.d.ts +103 -0
  88. package/dist/types/src/core/props/bicycle.d.ts +26 -0
  89. package/dist/types/src/core/props/carry.d.ts +67 -0
  90. package/dist/types/src/core/props/helicopter-layout.d.ts +11 -0
  91. package/dist/types/src/core/props/horse-gait.d.ts +11 -0
  92. package/dist/types/src/core/props/parachute.d.ts +14 -0
  93. package/dist/types/src/core/props/stage-props.d.ts +23 -0
  94. package/dist/types/src/core/props/vehicle-actions.d.ts +23 -0
  95. package/dist/types/src/core/props/vehicle-bodies.d.ts +5 -0
  96. package/dist/types/src/core/props/vehicle-car.d.ts +2 -0
  97. package/dist/types/src/core/props/vehicle-doors.d.ts +2 -0
  98. package/dist/types/src/core/props/vehicle-helicopter.d.ts +2 -0
  99. package/dist/types/src/core/props/vehicle-horse.d.ts +2 -0
  100. package/dist/types/src/core/props/vehicle-kit.d.ts +61 -0
  101. package/dist/types/src/core/props/vehicle-land.d.ts +3 -0
  102. package/dist/types/src/core/props/vehicle-merge.d.ts +3 -0
  103. package/dist/types/src/core/props/vehicle-motion.d.ts +104 -0
  104. package/dist/types/src/core/props/vehicle-special.d.ts +3 -0
  105. package/dist/types/src/core/props/vehicle-stunt.d.ts +16 -0
  106. package/dist/types/src/core/props/vehicle-water.d.ts +2 -0
  107. package/dist/types/src/core/props/vehicle.d.ts +49 -0
  108. package/dist/types/src/core/props/vehicles.d.ts +60 -0
  109. package/dist/types/src/core/props/weapons.d.ts +21 -0
  110. package/dist/types/src/core/rig/poses.d.ts +7 -0
  111. package/dist/types/src/core/rig/rig.d.ts +75 -0
  112. package/dist/types/src/core/rig/skeletons.d.ts +33 -0
  113. package/dist/types/src/core/rig/socket.d.ts +21 -0
  114. package/dist/types/src/core/skin-rough.d.ts +11 -0
  115. package/dist/types/src/export/fbx.d.ts +10 -0
  116. package/dist/types/src/export/glb.d.ts +9 -0
  117. package/dist/types/src/export/index.d.ts +22 -0
  118. package/dist/types/src/export/obj.d.ts +6 -0
  119. package/dist/types/src/export/plan.d.ts +63 -0
  120. package/package.json +21 -4
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Facial blend shapes and expressions, built from MakeHuman's CC0 expression targets
3
+ * (`targets/expression/units/<ethnicity>/*`). Each character gets the shapes blended by its
4
+ * ethnicity mix, so faces deform naturally on every head. Shape names follow Apple's ARKit
5
+ * convention where the MakeHuman target matches, so face-capture tools can drive them.
6
+ */
7
+ import type { AssetLibrary } from './assets';
8
+ import type { HumanParams } from './params';
9
+ export interface FaceShape {
10
+ name: string;
11
+ /** MakeHuman expression unit names and their weights. */
12
+ units: [string, number][];
13
+ }
14
+ export declare const FACE_SHAPES: FaceShape[];
15
+ export declare const FACE_SHAPE_NAMES: string[];
16
+ export type FaceWeights = Partial<Record<string, number>>;
17
+ export declare const EXPRESSIONS: readonly ['neutral', 'happy', 'laughing', 'angry', 'sad', 'crying', 'surprised', 'afraid', 'determined'];
18
+ export type ExpressionId = (typeof EXPRESSIONS)[number];
19
+ export declare const EXPRESSION_LABELS: Record<ExpressionId, string>;
20
+ export declare const EXPRESSION_WEIGHTS: Record<ExpressionId, FaceWeights>;
21
+ /** The shapes a character gets: all, or without the speech shapes (they come last, so the other
22
+ * shapes keep their indices). */
23
+ export declare function faceShapeNames(speech: boolean): string[];
24
+ /** Weights in `names` order (default: every shape). */
25
+ export declare function weightsArray(w: FaceWeights, names?: string[]): number[];
26
+ /**
27
+ * Per-shape vertex offsets on the base mesh (decimetres), blended by the character's ethnicity
28
+ * mix. Returns one Float32Array (vertexCount * 3) per shape in `names` (default: every shape).
29
+ */
30
+ export declare function faceDeltas(lib: AssetLibrary, p: HumanParams, names?: string[]): Float32Array[];
31
+ /** One face shape's offsets (see faceDeltas), by name. */
32
+ export declare function faceShapeDelta(lib: AssetLibrary, p: HumanParams, name: string): Float32Array;
33
+ /**
34
+ * Scale the blink shapes so weight 1 is "just closed" on this face. For each eye, rays from in
35
+ * front through the iris area must hit eyelid skin before the eyeball; a short search finds the
36
+ * weakest closure that covers them all (MakeHuman's full closure overshoots and folds the lid).
37
+ * Units: decimetres, face looking toward +Z. `eyes`: fitted eyeball mesh (both eyes).
38
+ */
39
+ export declare function calibrateBlinks(deltas: Float32Array[], coords: Float32Array, bodyQuads: Uint32Array, eyes: {
40
+ positions: Float32Array;
41
+ faceSizes: Uint8Array;
42
+ faceVerts: Uint32Array;
43
+ }): number[];
44
+ /**
45
+ * How much of the teeth shows from the front: rays over the teeth (finely spaced up and down) that hit a tooth
46
+ * in front of the face's front-facing skin (or through a gap between the lips). Units:
47
+ * decimetres, face toward +Z.
48
+ */
49
+ export declare function teethShowing(teeth: Float32Array, teethTris: Uint32Array, coords: Float32Array, bodyQuads: Uint32Array): number;
50
+ /**
51
+ * Close parted lips at rest so the teeth don't show with a neutral face. Some faces rest with the
52
+ * lips slightly apart; the upper lip is lowered (`upperUpOf`: the mouthUpperUp shape's offsets,
53
+ * applied negatively) by the least amount that hides the teeth from the front. Mutates `coords`
54
+ * and returns the amount used (0 when the lips already meet). `teethAt` fits the teeth to a face.
55
+ */
56
+ export declare function sealLips(coords: Float32Array, upperUpOf: () => Float32Array, teethAt: (coords: Float32Array) => Float32Array, teethTris: Uint32Array, bodyQuads: Uint32Array): number;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const BAGS: GarmentDef[];
@@ -0,0 +1,9 @@
1
+ import { type GarmentDef, type GCtx, type GPart } from './kit';
2
+ /**
3
+ * Flip-flops: a thick sole and a Y-shaped thong. A short post rises between the first two toes;
4
+ * from a knot on top of the foot two straps run over the instep down to the sole's edges. The
5
+ * straps are laid on the top of the foot by casting rays down onto it.
6
+ */
7
+ export declare function flipFlops(g: GCtx, color?: string, strap?: string): GPart[];
8
+ export declare const SLIDES: GarmentDef;
9
+ export declare const BEACH: GarmentDef[];
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Body coordinate system for procedural garments. Every body vertex gets a
3
+ * region (torso, upper arm...), a side, a position along its region's axis
4
+ * (t) and an angle around that axis (theta, 0 = front). Garments are defined
5
+ * against these, so they follow any morph.
6
+ *
7
+ * Units here are MakeHuman decimetres (1 cm = 0.1).
8
+ */
9
+ import type { Vec3 } from '../math';
10
+ export declare const REGION: {
11
+ readonly head: 0;
12
+ readonly neck: 1;
13
+ readonly torso: 2;
14
+ readonly hips: 3;
15
+ readonly upperarm: 4;
16
+ readonly lowerarm: 5;
17
+ readonly hand: 6;
18
+ readonly upperleg: 7;
19
+ readonly lowerleg: 8;
20
+ readonly foot: 9;
21
+ };
22
+ export type RegionName = keyof typeof REGION;
23
+ export declare const cm: (x: number) => number;
24
+ export interface VInfo {
25
+ region: number;
26
+ /** +1 = character's left (+X), -1 = right. */
27
+ side: number;
28
+ /**
29
+ * Position along the region axis. Torso/hips/neck share one vertical axis:
30
+ * 0 = hip joints, 1 = neck base (can go below 0 / above 1). Limbs: 0 at the
31
+ * proximal joint, 1 at the distal joint. Head: 0 = chin, 1 = crown.
32
+ */
33
+ t: number;
34
+ /** Angle around the axis, radians; 0 = front, +PI/2 = toward the character's left. */
35
+ theta: number;
36
+ /** Trunk coordinates for every vertex (same axis as torso t/theta), for necklines and armholes. */
37
+ tt: number;
38
+ tth: number;
39
+ /** Lateral distance from the body midline, decimetres. */
40
+ ax: number;
41
+ }
42
+ export interface Body {
43
+ coords: Float32Array;
44
+ normals: Float32Array;
45
+ regions: Uint8Array;
46
+ info: VInfo[];
47
+ joint(name: string): Vec3;
48
+ /** Key landmarks (decimetres). */
49
+ L: {
50
+ /** Shoulder joint lateral distance (decimetres). */
51
+ shoulderX: number;
52
+ hipY: number;
53
+ neckY: number;
54
+ torsoZ: number;
55
+ chinY: number;
56
+ crownY: number;
57
+ headZ: number;
58
+ };
59
+ /** Body vertex indices of a region (optionally one side). */
60
+ verts(region: number, side?: number): number[];
61
+ /** Limb axis endpoints for a region and side. */
62
+ axis(region: number, side: number): [Vec3, Vec3];
63
+ /** Vertex position as Vec3. */
64
+ p(v: number): Vec3;
65
+ }
66
+ export declare function makeBody(coords: Float32Array, normals: Float32Array, regions: Uint8Array, joints: Record<string, number[]>): Body;
67
+ /** Tileable-ish 3D hash noise in [0,1), for ragged hems and variation. */
68
+ export declare function hash3(x: number, y: number, z: number): number;
69
+ /** Smooth value noise in [0,1). */
70
+ export declare function noise3(x: number, y: number, z: number): number;
@@ -0,0 +1,8 @@
1
+ import { type GarmentDef, type GCtx, type GPart } from './kit';
2
+ export type { GarmentDef, GarmentStyle, GCtx, GPart, Slot } from './kit';
3
+ export declare const GARMENTS: GarmentDef[];
4
+ /** Sandals: a sole slab under each foot plus toe, instep and ankle straps. */
5
+ export declare function sandals(g: GCtx, color?: string): GPart[];
6
+ /** Boot shafts over the lower leg (worn with the "shoes03" boots asset). */
7
+ export declare function bootShafts(g: GCtx, color?: string): GPart[];
8
+ export declare const garmentById: Map<string, GarmentDef>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Hanging cloth: rings hung from a height down around the body (skirts, hems, trouser legs),
3
+ * blended into fitted bodices, and skinned loosely so they move with both legs; plus small shared
4
+ * helpers for limb tubes and hidden-skin masks.
5
+ */
6
+ import type { PolyMesh } from '../geometry';
7
+ import type { Vec3 } from '../math';
8
+ import type { Material } from '../mesh';
9
+ import { type Body, type VInfo } from './body';
10
+ import { type GCtx, type GPart } from './kit';
11
+ /** Knee and ankle heights. */
12
+ export declare const knee: (b: Body) => number;
13
+ export declare const ankle: (b: Body) => number;
14
+ /** Trunk and leg vertices: what hanging cloth (skirts, robes, tunic hems) drapes over. */
15
+ export declare const dressPts: (b: Body) => Vec3[];
16
+ export interface HangOpts {
17
+ offset: number;
18
+ /** Extra offset per decimetre of drop (A-line flare). */
19
+ flare?: number;
20
+ /** Allowed narrowing per decimetre, as a fraction (0 = the cloth never narrows going down); may vary with height. */
21
+ shrink?: number | ((y: number) => number);
22
+ /** Radial ripples: count around the ring and amplitude (grows from 0 at the top to full at the bottom). */
23
+ wave?: {
24
+ n: number;
25
+ amp: number;
26
+ phase?: number;
27
+ };
28
+ arc?: [number, number];
29
+ samples?: number;
30
+ tileV?: number;
31
+ uRepeats?: number;
32
+ /** Ring spacing (decimetres). */
33
+ step?: number;
34
+ }
35
+ /** Rings hanging from yTop to yBot around `src` (like the catalog's skirt, with taper, flare and ripples). */
36
+ export declare function hangRings(b: Body, src: Vec3[], yTop: number, yBot: number, o: HangOpts): Vec3[][] | null;
37
+ export declare function loftHang(rings: Vec3[][], b: Body, o?: Partial<HangOpts>): PolyMesh;
38
+ export declare function hang(b: Body, src: Vec3[], yTop: number, yBot: number, o: HangOpts): PolyMesh | null;
39
+ /**
40
+ * Push a fitted shell's trunk out toward the hull a hanging skirt is built on, blending in from
41
+ * yFrom down to yTo: the bodice then runs into the skirt without a step.
42
+ */
43
+ export declare function blendToHull(b: Body, mesh: PolyMesh, src: Vec3[], yFrom: number, yTo: number, offset: number): PolyMesh;
44
+ /** Body-face mask of faces whose corners all pass `test` (skin hidden under hanging cloth). */
45
+ export declare function hideMask(g: GCtx, test: (v: VInfo, y: number) => boolean): Uint8Array;
46
+ /** Rings around a limb along its axis from t0 to t1, with an offset profile over s in 0..1. */
47
+ export declare function limbTube(b: Body, region: number, side: number, t0: number, t1: number, off: (s: number, a: number) => number, steps?: number, samples?: number): Vec3[][] | null;
48
+ export declare function tubeMesh(rings: Vec3[][], centre: Vec3, tile?: number): PolyMesh;
49
+ /**
50
+ * Skin lookup for loose hanging cloth (skirts, robes, drapes): below the hips each vertex looks up
51
+ * its weights higher up and nearer the middle, so the cloth follows the hips and both thighs
52
+ * together instead of splitting between the legs.
53
+ */
54
+ export declare function looseSkin(b: Body, m: PolyMesh, pull?: number, squeeze?: number): Float32Array;
55
+ /** Hide the legs' skin under a skirt, from just below the hips to `margin` above its hem (feet and ankles stay). */
56
+ export declare function legsUnder(g: GCtx, hem: number, margin?: number): Uint8Array;
57
+ /** A hanging part with loose skinning. */
58
+ export declare function loosePart(b: Body, mesh: PolyMesh | null, material: Material, pull?: number, squeeze?: number, hides?: Uint8Array): GPart[];
59
+ export declare function part(mesh: PolyMesh | null, material: Material, extra?: Partial<GPart>): GPart[];
60
+ /** Lowest point of the trunk between the legs. */
61
+ export declare function crotchY(b: Body): number;
62
+ /** Lowest point of the feet (the floor under them, before any shoes lift the body). */
63
+ export declare function soleY(b: Body): number;
64
+ /**
65
+ * Trousers' seat over the tops of their legs: where the seat (a shell round the hips) overlaps a
66
+ * leg below `yTop`, it is pushed out over that leg's surface so the two meet without a step.
67
+ * Moves the seat's vertices in place.
68
+ */
69
+ export declare function seatOverLegs(seat: PolyMesh, legs: PolyMesh[], yTop: number): void;
70
+ export interface WideLegOpts {
71
+ /** Bunched folds where a long hem stacks over the shoe. */
72
+ stack?: boolean;
73
+ /** Tiling texture size (metres); without it the UVs unwrap the leg once (u: 0.5 front, 0.75 outer side; v: 0 top, 1 hem). */
74
+ tile?: number;
75
+ /** How far down the leg (0..1) it keeps following the thigh before easing out to its full width. */
76
+ flareFrom?: number;
77
+ }
78
+ /**
79
+ * One wide trouser leg (side s): it hangs from the thigh around an axis running down to the ankle,
80
+ * nearly straight, never closer to the leg than `ease`; soft irregular drape folds grow toward the
81
+ * hem. With `stack` the hem sits lower at the back and the fabric bunches over the shoe.
82
+ */
83
+ export declare function wideLeg(b: Body, s: number, yTop: number, yHem: number, o?: WideLegOpts): {
84
+ mesh: PolyMesh;
85
+ skinAt: Float32Array;
86
+ } | null;
@@ -0,0 +1,7 @@
1
+ import { type GarmentDef, type GarmentStyle, type GCtx, type GPart } from './kit';
2
+ /** `st`: the upper's finish and colour; color2 is the sole. */
3
+ export declare function loafers(g: GCtx, st: GarmentStyle): GPart[];
4
+ export declare const LOAFERS: GarmentDef;
5
+ /** Polished oxfords. `st`: the upper's finish and colour; color2 is the sole. */
6
+ export declare function oxfords(g: GCtx, st: GarmentStyle): GPart[];
7
+ export declare const OXFORDS: GarmentDef;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const EARPIECE: GarmentDef;
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const GOWNS: GarmentDef[];
@@ -0,0 +1,2 @@
1
+ import { type GarmentDef } from './kit';
2
+ export declare const GULF: GarmentDef[];
@@ -0,0 +1,8 @@
1
+ import { type GarmentDef } from './kit';
2
+ /**
3
+ * Arch both feet in place (MakeHuman decimetres): the foot pitches down about the ankle, the
4
+ * toes bend back about the ball of the foot so they rest flat, and the bottom of the shin follows
5
+ * a little for a smooth ankle.
6
+ */
7
+ export declare function archFeet(coords: Float32Array, regions: Uint8Array, joints: Record<string, number[]>): void;
8
+ export declare const HEELS: GarmentDef;
@@ -0,0 +1,36 @@
1
+ import type { AssetLibrary } from '../assets';
2
+ import { type HumanParams } from '../params';
3
+ import { type GarmentStyle, type GPart } from './catalog';
4
+ import type { FittedOutfit } from './kit';
5
+ import { type TexOut } from './textures';
6
+ export { GARMENTS, garmentById } from './catalog';
7
+ export type { GarmentDef } from './kit';
8
+ export { PATTERNS } from './textures';
9
+ export { archFeet } from './heels';
10
+ export { OUTFIT_SETS, setById, setStyles, sharedPieces, type OutfitSet } from './sets';
11
+ export interface Dressing {
12
+ top?: string;
13
+ jacket?: string;
14
+ bottom?: string;
15
+ underwear: boolean;
16
+ accessories: string[];
17
+ /** Built-in footwear, or a generated shoe's garment id (heels, sneakers, loafers). */
18
+ footwear?: 'sandals' | 'boots' | 'flipflops' | string;
19
+ styles: HumanParams['garmentStyles'];
20
+ }
21
+ /**
22
+ * What the character actually wears. Topless and bottomless (no underwear)
23
+ * are adult-only (18+): younger female characters always get a top, and every
24
+ * under-18 character keeps underwear (briefs, except under a floor-length gown, which covers them).
25
+ */
26
+ export declare function dressing(p: HumanParams): Dressing;
27
+ /** The MakeHuman outfits the dressed garments are cut from. */
28
+ export declare function outfitsUsed(d: Dressing): string[];
29
+ export declare function styleOf(id: string, styles: HumanParams['garmentStyles']): GarmentStyle;
30
+ /** Register a generated texture once (by key) and return its file names. */
31
+ export declare function genTexture(lib: AssetLibrary, key: string, make: () => TexOut): {
32
+ map: string;
33
+ normalMap?: string;
34
+ alpha: boolean;
35
+ };
36
+ export declare function buildGarments(lib: AssetLibrary, coords: Float32Array, normals: Float32Array, faceVerts: Uint32Array, d: Dressing, outfits?: Record<string, FittedOutfit>): GPart[];
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Shared garment toolkit: types, materials and the shape helpers (shells,
3
+ * hull-lofted skirts, limb bands, beads) that every garment builds on.
4
+ * Everything is in MakeHuman decimetres.
5
+ */
6
+ import type { PolyMesh } from '../geometry';
7
+ import type { Vec3 } from '../math';
8
+ import type { Material } from '../mesh';
9
+ import { type Body, type VInfo } from './body';
10
+ import { type Plane } from './ring';
11
+ import { type ShellSpec } from './shell';
12
+ import { type Pattern, type TexOut } from './textures';
13
+ /**
14
+ * 'jacket': worn over the top (the params' `jacket`). 'hat': picked in the Hat section (the params'
15
+ * `hat`), and 'bag' in the Props section (the params' `carry`), both built like an accessory.
16
+ */
17
+ export type Slot = 'top' | 'jacket' | 'bottom' | 'acc' | 'feet' | 'hat' | 'bag';
18
+ export interface GarmentStyle {
19
+ pattern: Pattern;
20
+ color: string;
21
+ color2: string;
22
+ }
23
+ export interface GarmentDef {
24
+ id: string;
25
+ label: string;
26
+ slot: Slot;
27
+ /** Patterns offered in the UI (first = default). */
28
+ patterns: Pattern[];
29
+ /** What the two colours are called in the UI (default Colour / Accent). */
30
+ colorLabels?: [string, string];
31
+ /** A floor-length dress: it covers everything briefs would, so none are added under it. */
32
+ fullLength?: boolean;
33
+ /** Only worn as part of an outfit set (not listed with the separate pieces), e.g. a suit's shirt front. */
34
+ setOnly?: boolean;
35
+ color: string;
36
+ color2: string;
37
+ /**
38
+ * A MakeHuman outfit whose fitted mesh the garment is cut from (`g.outfits[id]`), e.g. the shirt
39
+ * of a casual suit.
40
+ */
41
+ fromOutfit?: string;
42
+ /** Hides the skin it covers (opaque fitted garments). */
43
+ build(g: GCtx, st: GarmentStyle): GPart[];
44
+ }
45
+ export interface GPart {
46
+ mesh: PolyMesh;
47
+ material: Material;
48
+ /** Body-face mask whose skin should be hidden under this part. */
49
+ hides?: Uint8Array;
50
+ /** Covers the crown: hair above its lowest point is trimmed. */
51
+ headwear?: boolean;
52
+ /** Covers all the hair (a head tie): the hairstyle is left out. */
53
+ hidesHair?: boolean;
54
+ /** Body faces this part sits over without hiding them (a cap over the scalp): no hair grows there. */
55
+ over?: Uint8Array;
56
+ /** Touches the ground (soles): used for grounding. */
57
+ ground?: boolean;
58
+ /**
59
+ * A top's collar: never cut away under a jacket. It is laid over the jacket's collar, or with
60
+ * `collarUnder` (a clerical band) tucked inside it.
61
+ */
62
+ collar?: boolean;
63
+ collarUnder?: boolean;
64
+ /** Fitted cloth that should be subdivided in HD. */
65
+ smooth?: boolean;
66
+ /**
67
+ * Where to look up skin weights for each vertex (defaults to its position): loose cloth looks
68
+ * nearer the hips or torso so it doesn't follow a single leg or arm.
69
+ */
70
+ skinAt?: Float32Array;
71
+ /**
72
+ * Skin as a mix (instead of `skinAt`): each entry's weights are looked up at its own positions
73
+ * and mixed in by its per-vertex amount. Long cloth uses it to share smoothly between the hips
74
+ * and both legs, which a single lookup can only do by jumping from one leg to the other.
75
+ */
76
+ skinMix?: {
77
+ at: Float32Array;
78
+ amount: Float32Array;
79
+ }[];
80
+ }
81
+ export interface FittedOutfit {
82
+ mesh: PolyMesh;
83
+ /** Base-mesh vertices the whole outfit hides (MakeHuman's delete list). */
84
+ deleteVerts: Uint32Array;
85
+ /** Per vertex: the nearest body vertex (under it). */
86
+ ref: Uint32Array;
87
+ /** The outfit's own normal map (folds, seams), on its UVs. */
88
+ normalMap?: string;
89
+ }
90
+ export interface GCtx {
91
+ body: Body;
92
+ faceVerts: Uint32Array;
93
+ /** Registers a generated texture, returns its file name. */
94
+ texture(key: string, make: () => TexOut): {
95
+ map: string;
96
+ normalMap?: string;
97
+ alpha: boolean;
98
+ };
99
+ /** True when a top / bottom garment is worn (accessories sit a bit further out). */
100
+ layered: {
101
+ top: boolean;
102
+ bottom: boolean;
103
+ };
104
+ /** Briefs under wrappers / aprons / loincloths (always on for under-18 characters). */
105
+ underwear: boolean;
106
+ /** Vertices of the bottom and top already dressed, for things worn over them (necklaces lie on the top). */
107
+ worn?: Vec3[];
108
+ /** MakeHuman outfits fitted to the body (and rigged), for garments cut from them. */
109
+ outfits?: Record<string, FittedOutfit>;
110
+ /** Vertices of the jacket over the top, for things worn over everything (a backpack). */
111
+ jacket?: Vec3[];
112
+ }
113
+ export declare const Y: Vec3;
114
+ export declare const Z: Vec3;
115
+ export declare const clamp: (x: number, a: number, b: number) => number;
116
+ export declare function torsoY(b: Body, t: number): number;
117
+ export declare function points(b: Body, test: (v: VInfo, i: number) => boolean): Vec3[];
118
+ export declare const isTrunk: (v: VInfo) => boolean;
119
+ /** Trunk plus the shoulder tops and lower neck, which the weight-based regions split oddly. */
120
+ export declare const isUpper: (v: VInfo) => boolean;
121
+ export declare const isLegs: (v: VInfo) => boolean;
122
+ export declare function mat(name: string, tex: {
123
+ map: string;
124
+ normalMap?: string;
125
+ alpha: boolean;
126
+ } | null, o?: Partial<Material>): Material;
127
+ export declare function cloth(g: GCtx, name: string, st: GarmentStyle, o?: Partial<Material>): Material;
128
+ export declare const leatherStyle: (color?: string) => GarmentStyle;
129
+ export declare const GOLD: Partial<Material>;
130
+ export declare const STEEL: Partial<Material>;
131
+ export declare function shell(g: GCtx, spec: ShellSpec): import("./shell").ShellResult | null;
132
+ export declare function shellPart(g: GCtx, spec: ShellSpec, material: Material, hide?: boolean): GPart[];
133
+ /** Horizontal plane at torso parameter t. */
134
+ export declare const hplane: (b: Body, y: number) => Plane;
135
+ /** Point on a ring at angle a (rings span -PI..PI with `samples` points). */
136
+ export declare function ringAt(ring: Vec3[], a: number): {
137
+ p: Vec3;
138
+ out: Vec3;
139
+ tan: Vec3;
140
+ };
141
+ /**
142
+ * Hull-lofted skirt (wrappers, tunic skirts, aprons) from yTop down to yBot.
143
+ * Rings never get narrower going down, so the cloth hangs past the legs.
144
+ */
145
+ export declare function skirt(b: Body, yTop: number, yBot: number, offset: number, flare: number, arc?: [number, number], samples?: number, uv?: {
146
+ uRepeats?: number;
147
+ tileV?: number;
148
+ }): PolyMesh | null;
149
+ /** Solid band around a limb at parameter t. */
150
+ export declare function limbBand(b: Body, region: number, side: number, t: number, width: number, thick: number, offset: number, tileU?: number): PolyMesh | null;
151
+ /** Limb ring (for placing beads / fringe) at parameter t. */
152
+ export declare function limbRing(b: Body, region: number, side: number, t: number, offset: number, samples?: number): {
153
+ ring: Vec3[] | null;
154
+ dir: Vec3;
155
+ };
156
+ /** Diagonal strap plane from a shoulder (side s) to the opposite hip. */
157
+ export declare function strapPlane(b: Body, s: number, shoulderBias?: number): Plane;
158
+ export declare const strapPoints: (b: Body, s: number) => Vec3[];
159
+ /** Beads (or shells) along a polyline, coloured from a palette texture. */
160
+ export declare function beads(ring: Vec3[], closed: boolean, spacing: number, r: Vec3, colors: number, centre: Vec3): PolyMesh | null;
161
+ /** Briefs under wrappers, skirts and aprons (always on for under-18 characters). */
162
+ export declare function briefsUnder(g: GCtx): GPart[];
163
+ /**
164
+ * A flat sole under one foot (side s): the footprint outline pushed out by `margin`, with its top
165
+ * `rise` above the bottom of the foot (a midsole wrapping up the sides) and `thick` deep.
166
+ */
167
+ export declare function footSole(b: Body, s: number, thick: number, margin: number, rise?: number): PolyMesh | null;
168
+ /**
169
+ * Re-map a garment's UVs as a cylinder round a vertical axis at (cx, cz): u by angle, v by height,
170
+ * tiling every `tile` metres. Body-region UVs meet at seams between regions (torso to upper arm,
171
+ * hips to thigh) that show on fabrics with large features; one cylinder has a single seam, at the back.
172
+ */
173
+ export declare function cylinderUVs(m: PolyMesh, cx: number, cz: number, tile: number, circ?: number): PolyMesh;
@@ -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[];