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.
- package/README.md +38 -8
- package/dist/cli.js +5 -5
- package/dist/embed.js +16579 -0
- package/dist/index.js +1877 -0
- package/dist/types/packages/cli/src/embed.d.ts +43 -0
- package/dist/types/packages/cli/src/index.d.ts +109 -0
- package/dist/types/packages/cli/src/library/colors.d.ts +9 -0
- package/dist/types/packages/cli/src/library/generate.d.ts +40 -0
- package/dist/types/packages/cli/src/library/sequence.d.ts +14 -0
- package/dist/types/packages/cli/src/library/worker.d.ts +22 -0
- package/dist/types/src/app/character-assist.d.ts +73 -0
- package/dist/types/src/app/share.d.ts +19 -0
- package/dist/types/src/core/anim/boarding.d.ts +4 -0
- package/dist/types/src/core/anim/clips/actions.d.ts +9 -0
- package/dist/types/src/core/anim/clips/aerial.d.ts +7 -0
- package/dist/types/src/core/anim/clips/basic.d.ts +4 -0
- package/dist/types/src/core/anim/clips/climbing.d.ts +37 -0
- package/dist/types/src/core/anim/clips/combat.d.ts +6 -0
- package/dist/types/src/core/anim/clips/cover.d.ts +19 -0
- package/dist/types/src/core/anim/clips/dodge.d.ts +8 -0
- package/dist/types/src/core/anim/clips/emotes.d.ts +21 -0
- package/dist/types/src/core/anim/clips/everyday.d.ts +15 -0
- package/dist/types/src/core/anim/clips/faces.d.ts +11 -0
- package/dist/types/src/core/anim/clips/gait.d.ts +17 -0
- package/dist/types/src/core/anim/clips/gunshot.d.ts +8 -0
- package/dist/types/src/core/anim/clips/helpers.d.ts +26 -0
- package/dist/types/src/core/anim/clips/index.d.ts +8 -0
- package/dist/types/src/core/anim/clips/interaction.d.ts +18 -0
- package/dist/types/src/core/anim/clips/lying.d.ts +8 -0
- package/dist/types/src/core/anim/clips/melee.d.ts +3 -0
- package/dist/types/src/core/anim/clips/mocap-data.d.ts +6 -0
- package/dist/types/src/core/anim/clips/reactions.d.ts +34 -0
- package/dist/types/src/core/anim/clips/recorded.d.ts +12 -0
- package/dist/types/src/core/anim/clips/runner.d.ts +10 -0
- package/dist/types/src/core/anim/clips/shooter.d.ts +15 -0
- package/dist/types/src/core/anim/clips/speech.d.ts +10 -0
- package/dist/types/src/core/anim/clips/swimming.d.ts +17 -0
- package/dist/types/src/core/anim/clips/types.d.ts +152 -0
- package/dist/types/src/core/anim/clips/vehicles.d.ts +28 -0
- package/dist/types/src/core/anim/evaluate.d.ts +188 -0
- package/dist/types/src/core/anim/mocap.d.ts +120 -0
- package/dist/types/src/core/anim/quat.d.ts +14 -0
- package/dist/types/src/core/anim/riding-weapons.d.ts +13 -0
- package/dist/types/src/core/anim/stage.d.ts +5 -0
- package/dist/types/src/core/assets.d.ts +114 -0
- package/dist/types/src/core/face.d.ts +56 -0
- package/dist/types/src/core/garments/bags.d.ts +2 -0
- package/dist/types/src/core/garments/beach.d.ts +9 -0
- package/dist/types/src/core/garments/body.d.ts +70 -0
- package/dist/types/src/core/garments/catalog.d.ts +8 -0
- package/dist/types/src/core/garments/drape.d.ts +86 -0
- package/dist/types/src/core/garments/dress-shoes.d.ts +7 -0
- package/dist/types/src/core/garments/earpiece.d.ts +2 -0
- package/dist/types/src/core/garments/gowns.d.ts +2 -0
- package/dist/types/src/core/garments/gulf.d.ts +2 -0
- package/dist/types/src/core/garments/heels.d.ts +8 -0
- package/dist/types/src/core/garments/index.d.ts +36 -0
- package/dist/types/src/core/garments/kit.d.ts +173 -0
- package/dist/types/src/core/garments/last.d.ts +78 -0
- package/dist/types/src/core/garments/layering.d.ts +4 -0
- package/dist/types/src/core/garments/necklaces.d.ts +2 -0
- package/dist/types/src/core/garments/outfit-cut.d.ts +30 -0
- package/dist/types/src/core/garments/prison.d.ts +2 -0
- package/dist/types/src/core/garments/project.d.ts +61 -0
- package/dist/types/src/core/garments/ring.d.ts +100 -0
- package/dist/types/src/core/garments/sets.d.ts +41 -0
- package/dist/types/src/core/garments/shell.d.ts +37 -0
- package/dist/types/src/core/garments/sheriff.d.ts +2 -0
- package/dist/types/src/core/garments/shirts.d.ts +31 -0
- package/dist/types/src/core/garments/sneakers.d.ts +7 -0
- package/dist/types/src/core/garments/street.d.ts +2 -0
- package/dist/types/src/core/garments/suit.d.ts +2 -0
- package/dist/types/src/core/garments/swimwear.d.ts +2 -0
- package/dist/types/src/core/garments/textures.d.ts +53 -0
- package/dist/types/src/core/garments/wrist.d.ts +2 -0
- package/dist/types/src/core/garments/yoruba.d.ts +2 -0
- package/dist/types/src/core/geometry.d.ts +31 -0
- package/dist/types/src/core/human.d.ts +42 -0
- package/dist/types/src/core/looks/hair.d.ts +64 -0
- package/dist/types/src/core/looks/index.d.ts +38 -0
- package/dist/types/src/core/looks/jewelry.d.ts +20 -0
- package/dist/types/src/core/looks/mouth.d.ts +12 -0
- package/dist/types/src/core/looks/overlay.d.ts +42 -0
- package/dist/types/src/core/looks/tattoos.d.ts +11 -0
- package/dist/types/src/core/looks/textures.d.ts +8 -0
- package/dist/types/src/core/math.d.ts +29 -0
- package/dist/types/src/core/mesh.d.ts +75 -0
- package/dist/types/src/core/morph.d.ts +11 -0
- package/dist/types/src/core/pack.d.ts +7 -0
- package/dist/types/src/core/params.d.ts +103 -0
- package/dist/types/src/core/props/bicycle.d.ts +26 -0
- package/dist/types/src/core/props/carry.d.ts +67 -0
- package/dist/types/src/core/props/helicopter-layout.d.ts +11 -0
- package/dist/types/src/core/props/horse-gait.d.ts +11 -0
- package/dist/types/src/core/props/parachute.d.ts +14 -0
- package/dist/types/src/core/props/stage-props.d.ts +23 -0
- package/dist/types/src/core/props/vehicle-actions.d.ts +23 -0
- package/dist/types/src/core/props/vehicle-bodies.d.ts +5 -0
- package/dist/types/src/core/props/vehicle-car.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-doors.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-helicopter.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-horse.d.ts +2 -0
- package/dist/types/src/core/props/vehicle-kit.d.ts +61 -0
- package/dist/types/src/core/props/vehicle-land.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-merge.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-motion.d.ts +104 -0
- package/dist/types/src/core/props/vehicle-special.d.ts +3 -0
- package/dist/types/src/core/props/vehicle-stunt.d.ts +16 -0
- package/dist/types/src/core/props/vehicle-water.d.ts +2 -0
- package/dist/types/src/core/props/vehicle.d.ts +49 -0
- package/dist/types/src/core/props/vehicles.d.ts +60 -0
- package/dist/types/src/core/props/weapons.d.ts +21 -0
- package/dist/types/src/core/rig/poses.d.ts +7 -0
- package/dist/types/src/core/rig/rig.d.ts +75 -0
- package/dist/types/src/core/rig/skeletons.d.ts +33 -0
- package/dist/types/src/core/rig/socket.d.ts +21 -0
- package/dist/types/src/core/skin-rough.d.ts +11 -0
- package/dist/types/src/export/fbx.d.ts +10 -0
- package/dist/types/src/export/glb.d.ts +9 -0
- package/dist/types/src/export/index.d.ts +22 -0
- package/dist/types/src/export/obj.d.ts +6 -0
- package/dist/types/src/export/plan.d.ts +63 -0
- package/package.json +13 -4
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Asset pack formats (produced by scripts/build-assets.ts from the CC0
|
|
3
|
+
* MakeHuman data) and a loader that works in both the browser and Node.
|
|
4
|
+
*/
|
|
5
|
+
import { type Pack } from './pack';
|
|
6
|
+
export interface AssetMaterial {
|
|
7
|
+
name: string;
|
|
8
|
+
color: string;
|
|
9
|
+
roughness: number;
|
|
10
|
+
metalness: number;
|
|
11
|
+
diffuse?: string;
|
|
12
|
+
normal?: string;
|
|
13
|
+
alpha: 'opaque' | 'mask' | 'blend';
|
|
14
|
+
doubleSided: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface BaseMeta {
|
|
17
|
+
vertexCount: number;
|
|
18
|
+
faceCount: number;
|
|
19
|
+
/** Skeleton joint name -> base-mesh vertex indices (joint position = their mean). */
|
|
20
|
+
joints: Record<string, number[]>;
|
|
21
|
+
bones: {
|
|
22
|
+
name: string;
|
|
23
|
+
parent: string | null;
|
|
24
|
+
head: string;
|
|
25
|
+
tail: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
export interface TargetsMeta {
|
|
29
|
+
/** 2 = values delta-coded per target and stored as low/high byte planes (see decodeTargets). */
|
|
30
|
+
format?: number;
|
|
31
|
+
/** name -> [entry offset, entry count, quantisation scale] */
|
|
32
|
+
targets: Record<string, [number, number, number]>;
|
|
33
|
+
}
|
|
34
|
+
/** Turn a format-2 targets pack back into idx/dx/dy/dz arrays (format 1 packs pass through). */
|
|
35
|
+
export declare function decodeTargets(p: Pack<TargetsMeta>): Pack<TargetsMeta>;
|
|
36
|
+
export type ProxyKind = 'body' | 'eyes' | 'eyebrows' | 'eyelashes' | 'hair' | 'outfit' | 'shoes' | 'hat' | 'teeth' | 'tongue';
|
|
37
|
+
export interface ProxyMeta {
|
|
38
|
+
id: string;
|
|
39
|
+
kind: ProxyKind;
|
|
40
|
+
zDepth: number;
|
|
41
|
+
/** Per-axis scale reference: [vertA, vertB, referenceDistance] or null. */
|
|
42
|
+
scale: ([number, number, number] | null)[];
|
|
43
|
+
material?: AssetMaterial;
|
|
44
|
+
vertexCount: number;
|
|
45
|
+
}
|
|
46
|
+
export interface CatalogItem {
|
|
47
|
+
id: string;
|
|
48
|
+
name: string;
|
|
49
|
+
tags: string[];
|
|
50
|
+
thumb?: string;
|
|
51
|
+
/** Proxy pack file (relative to assets/), for mesh assets. */
|
|
52
|
+
file?: string;
|
|
53
|
+
material?: AssetMaterial;
|
|
54
|
+
}
|
|
55
|
+
export interface Slider {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
/** Pairs of [min target, max target]; several pairs = symmetric left/right. null = no target on that side. */
|
|
59
|
+
targets: [string | null, string | null][];
|
|
60
|
+
/** Unipolar sliders run 0..1, bipolar -1..1. */
|
|
61
|
+
bipolar: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface SliderGroup {
|
|
64
|
+
category: string;
|
|
65
|
+
group: string;
|
|
66
|
+
sliders: Slider[];
|
|
67
|
+
}
|
|
68
|
+
export interface Catalog {
|
|
69
|
+
skins: CatalogItem[];
|
|
70
|
+
eyes: CatalogItem[];
|
|
71
|
+
eyebrows: CatalogItem[];
|
|
72
|
+
eyelashes: CatalogItem[];
|
|
73
|
+
hair: CatalogItem[];
|
|
74
|
+
outfits: CatalogItem[];
|
|
75
|
+
shoes: CatalogItem[];
|
|
76
|
+
hats: CatalogItem[];
|
|
77
|
+
bodies: CatalogItem[];
|
|
78
|
+
eyeMesh: string;
|
|
79
|
+
/** Teeth variants and the tongue (mouth interior). */
|
|
80
|
+
teeth: CatalogItem[];
|
|
81
|
+
tongue: CatalogItem;
|
|
82
|
+
sliders: SliderGroup[];
|
|
83
|
+
}
|
|
84
|
+
/** Where asset bytes come from: fetch() in the browser, the filesystem in Node. */
|
|
85
|
+
export interface AssetSource {
|
|
86
|
+
read(path: string): Promise<Uint8Array>;
|
|
87
|
+
/** URL usable by the viewer for textures (browser only). */
|
|
88
|
+
url?(path: string): string;
|
|
89
|
+
}
|
|
90
|
+
export declare function fetchSource(base?: string): AssetSource;
|
|
91
|
+
/** Loads and caches packs, catalog and textures. */
|
|
92
|
+
export declare class AssetLibrary {
|
|
93
|
+
readonly source: AssetSource;
|
|
94
|
+
catalog: Catalog;
|
|
95
|
+
base: Pack<BaseMeta>;
|
|
96
|
+
targets: Pack<TargetsMeta>;
|
|
97
|
+
private proxies;
|
|
98
|
+
private textures;
|
|
99
|
+
/** Textures generated at runtime (procedural garments), by file name. */
|
|
100
|
+
private generated;
|
|
101
|
+
private blobUrls;
|
|
102
|
+
registerTexture(name: string, data: Uint8Array): void;
|
|
103
|
+
hasTexture(name: string): boolean;
|
|
104
|
+
peekTexture(name: string): Uint8Array | undefined;
|
|
105
|
+
/** Names of all runtime-generated textures. */
|
|
106
|
+
generatedNames(): string[];
|
|
107
|
+
constructor(source: AssetSource);
|
|
108
|
+
init(): Promise<this>;
|
|
109
|
+
/** Catalog only (for UIs that delegate building to a worker). */
|
|
110
|
+
initCatalog(): Promise<this>;
|
|
111
|
+
proxy(file: string): Promise<Pack<ProxyMeta>>;
|
|
112
|
+
texture(name: string): Promise<Uint8Array>;
|
|
113
|
+
textureUrl(name: string): string;
|
|
114
|
+
}
|
|
@@ -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,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,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;
|