import type { Vec3 } from './vehicleMath'; export interface PreviewRest { nv: number; boneNames: string[]; parents: number[]; /** Bind-pose world matrix per bone (column-major 4x4), null for a bone no skin uses. */ bind: Array; /** Bind-pose vertex positions, flat xyz. */ rest: Float32Array; /** Triangles, flat (merged over every drawn skinned mesh). */ index: Uint32Array; /** 4 bone ids (into boneNames) and 4 weights per vertex. */ skinIndex: Uint16Array; skinWeight: Float32Array; /** Names of the nodes the avatar's VRM node constraints drive (the GLB's `helixConstraints`), when the page exposes them. */ constraintNodes?: string[]; } export interface PreviewPose { /** Clip time (s). */ t: number; /** Posed vertex positions in the BODY frame (+Y up, +Z forward, +X the character's left), flat xyz. */ positions: Float32Array; /** World matrix (body frame, column-major) of each bone, in boneNames order. */ bones: number[][]; } export declare const AVATAR_PREVIEW_THRESHOLDS: { /** Forearm + hand surface (>= 0.6 weight on lowerarm/hand/fingers) lying more than `armDepthM` behind the nearest * torso/hip surface (>= 0.6 on pelvis/spine/thigh, within `armNearM`), as an area share AVERAGED over the walk cycle * (a hand brushing the hip at one phase is fine; arms that walk inside the body are inside most of the cycle). * Measured on the production page: good Base Male/Female 0, worst Pastel Cyberpunk 0.085 (arms bound at 20 deg, * pressed to the hips; peak 0.218), Brass 0.059; Cream Hoodie 1.0.6 0.180 (peak 0.259), Base Male arms-low fixture * 0.240, Cream Hoodie 1.0.8 0.000. */ armDepthM: number; armNearM: number; armInsideShareMax: number; /** Two sides of a hole: boundary vertices of the same connected surface, within 2 cm of each other at rest but at * least 7 edges apart along the surface. How far they separate in the walk (cm). Good max 0.8 (Iron Man); * Cream Hoodie 1.0.6 20.1 (the cut sleeve-to-torso bridge opening as the arm swings back). */ holePairRestM: number; holeMinHops: number; holeOpenMaxM: number; /** Geometry that is neither torso nor limb, between spine_01 and neck_01 height, standing behind / beside the torso's * own outline (cm, scaled to a 1.70 m body), in two classes: hung from the head (hair, ears) and everything else on * its own bones (capes, coat tails, accessories). Measured on the production page (held poses, dynamics settled): * good max Kemonomimi 28.1 (hair) / 21.8 (cape); Cream Hoodie 1.0.6 22.3 (its back hair rides on spine bones, so it * reads as the second class) — inside the good envelope, so 1.0.6's slab is the vision critic's to judge on the * motion.preview side frames; this catches gross outliers (the slab fixture: a plate 45 cm off the back). */ silhouetteHairMaxM: number; silhouetteClothMaxM: number; /** * A rigid part of a CONSTRAINT ASSEMBLY (a non-skeleton chain that carries VRM-node-constraint-driven nodes: Seed-san's robot * backpack, whose mast + pack + arms hang from one root and whose arms copy the body's own) is judged against the avatar's OWN * rest outline instead of the plain limit when that stands further off the torso: allowance = max(limit, rest stand-off + this). * The mast stands 35.7 cm off the back at rest in the VRM's own geometry (converted: 34.9..36.5 over the walk), so 35 cm was * judging the source, not the conversion. A part of such an assembly that LEAVES the body more than the source authored it * (rest + 3 cm) still fails; every other cloth keeps the plain limit, and so does hair. */ silhouetteRestToleranceM: number; /** A detached rest-mesh fragment longer than this, thin (area / extent^2 below `strandThinness`) and small (< 2 % of * the surface), is a stray strand. None in the good set. A triangle the walk stretches into a sliver (longest edge * > 4 cm and > 3x its rest length, < 4 mm tall) is recorded as evidence, not judged (good avatars reach 3). */ strandMinExtentM: number; strandThinness: number; strandMaxShare: number; /** ... and no vertex of it within this distance of any other surface (it floats). */ strandFloatM: number; /** Upper arm bound at least this far from straight down (deg). Base Female 36, worst good Pastel 19.6, Kemonomimi * (T-pose) 90; Cream Hoodie 1.0.6 13-15: the walk adducts ~24 deg from the clip's A-pose, so an arm bound that * close walks inside the body. */ upperarmAbductionMinDeg: number; /** Any other canonical bone's bind direction vs Base Female (deg). Good max: lowerarm 60 (T-pose), thigh/calf 36 * (Brass), foot 38 (Cream Hoodie), neck 14 (T-800). */ bindDeltaMaxDeg: Record; /** Neck lean (neck_01 -> head from vertical, sagittal, deg) and torso lean (pelvis -> spine_03) through the walk vs * Base Female (neck 18.9..23.1, torso 5.2..9.6). Good range: neck 6.8 (Ninja) .. 34.8 (T-800). */ neckLeanDeltaMaxDeg: number; torsoLeanDeltaMaxDeg: number; }; export declare const BASE_FEMALE_POSTURE: { neckLeanDeg: [number, number]; torsoLeanDeg: [number, number]; }; /** Base Female 1.3.1 bind directions (unit, model frame) of the canonical bone pairs. */ export declare const STANDARD_BIND_DIRECTIONS: Record; /** Per-vertex weight on bones whose name matches `re`. */ export declare function weightOn(rest: PreviewRest, re: RegExp): Float32Array; /** Name of each vertex's dominant bone. */ export declare function dominantBone(rest: PreviewRest): string[]; export declare function vertexAreas(P: Float32Array, I: Uint32Array, nv: number): Float64Array; export declare function vertexNormals(P: Float32Array, I: Uint32Array, nv: number): Float32Array; /** Uniform-grid nearest-neighbour index over a subset of points. */ export declare class PointGrid { private P; private cell; private cells; constructor(P: Float32Array, ids: ArrayLike, cell?: number); private key; /** Nearest indexed point within `radius` of (x,y,z): [index, distance] or [-1, Infinity]. */ nearest(x: number, y: number, z: number, radius: number): [number, number]; within(x: number, y: number, z: number, radius: number): number[]; } /** Weld vertices that share a rest position (UV/normal seams split them in glTF) into one topological vertex. */ export interface Welded { of: Int32Array; count: number; rep: Int32Array; tris: Int32Array; } export declare function weld(rest: Float32Array, index: Uint32Array, nv: number, tol?: number): Welded; export interface ArmsMeasure { measured: boolean; why?: string; insideShare: number; peakShare: number; phase: number | null; depthCm: number; forearmVerts: number; } /** Forearms/hands buried inside the torso/hips while walking (#3). */ export declare function measureArmsClear(rest: PreviewRest, poses: PreviewPose[]): ArmsMeasure; /** * Which spring lock (hair lock, skirt panel, tail: a chain of non-skeleton bones hung from the skeleton) each vertex is * driven by, from its dominant bone: the topmost non-skeleton bone of its chain, else -1 (a skeleton bone: the body). * Constraint-driven nodes are limbs, so they count as the body. */ export declare function lockOfVertex(rest: PreviewRest): Int32Array; /** Bones the VRM node constraints drive, and everything hung from them (a robot arm that copies the body's arm). */ export declare function constraintDrivenBones(rest: PreviewRest): boolean[]; /** * Bones of every non-skeleton chain that carries a constraint-driven node (the robot backpack's mast, pack and arm chains hang from * one root; its arms are driven by constraints that copy the body's). The constraint-driven nodes themselves are in * `constraintDrivenBones` (limbs, never judged); the rest of the chain is the assembly's rigid body. */ export declare function constraintAssemblyBones(rest: PreviewRest): boolean[]; export interface HoleMeasure { measured: boolean; why?: string; openCm: number; boundaryEdges: number; pairs: number; phase: number | null; at: Vec3 | null; } /** Holes in the surface that open as the limbs swing (#5): the two sides of a hole sit together at rest and part. */ export declare function measureSurfaceClosed(rest: PreviewRest, poses: PreviewPose[]): HoleMeasure; export interface SilhouetteMeasure { measured: boolean; why?: string; /** Worst over both classes (cm at 1.70 m). */ backCm: number; sideCm: number; /** Geometry hung from the head (hair, ears, hood strings: dominant bone `head`/`neck_*` or a non-skeleton bone below them). */ hairBackCm: number; hairSideCm: number; /** Everything else that is neither torso nor limb (capes, coat tails, tails, accessories on their own bones). */ clothBackCm: number; clothSideCm: number; /** * Parts of a constraint assembly (see `silhouetteRestToleranceM`): their worst stand-off over the walk, and on the avatar's REST * pose (cm at 1.70 m), which is the source's own geometry (the converter keeps the bind geometry). They are NOT in clothBackCm / * clothSideCm (those are every other cloth) but are in backCm / sideCm. Absent when the avatar has no such assembly. */ assemblyBackCm?: number; assemblySideCm?: number; restAssemblyBackCm?: number; restAssemblySideCm?: number; phase: number | null; heightM: number; } /** Per bone: is it hung from the head (the head, the neck, or a non-skeleton bone whose nearest skeleton ancestor is one)? */ export declare function headHungBones(rest: PreviewRest): boolean[]; /** Hair / cloth / accessories standing out of the torso's outline between the hips and the neck (#2). */ export declare function measureSilhouette(rest: PreviewRest, poses: PreviewPose[]): SilhouetteMeasure; export interface StrandMeasure { strands: Array<{ extentCm: number; areaCm2: number; at: Vec3; }>; components: number; posedSlivers: number; posedSliverMaxCm: number; posedSliverAt: Vec3 | null; } /** Stray strands on the rest mesh (#4), plus (evidence only) triangles the walk stretches into slivers. */ export declare function measureStrands(rest: PreviewRest, poses: PreviewPose[]): StrandMeasure; export interface BindMeasure { measured: boolean; why?: string; upperarmAbductionDeg: Record; deltaDeg: Record; } /** Each canonical bone's bind direction vs the standard skeleton (#6). */ export declare function measureBindPose(rest: PreviewRest): BindMeasure; export interface PostureMeasure { measured: boolean; why?: string; neckLeanDeg: [number, number] | null; torsoLeanDeg: [number, number] | null; } /** Head and torso lean through the walk (#7), read from the posed skeleton. */ export declare function measurePosture(rest: PreviewRest, poses: PreviewPose[]): PostureMeasure; export interface Judged { pass: boolean; detail: string; measured: Record; } export declare function judgeArmsClear(m: ArmsMeasure | null): Judged; export declare function judgeSurfaceClosed(m: HoleMeasure | null): Judged; /** * How far a constraint assembly's rigid body may stand off the torso on each axis (cm at 1.70 m): the plain limit, or the avatar's * own rest stand-off plus the tolerance where that is further out (the source authored it that far out and it follows the body). */ export declare function assemblyAllowanceCm(m: SilhouetteMeasure): { back: number; side: number; }; export declare function judgeSilhouette(m: SilhouetteMeasure | null): Judged; export declare function judgeStrands(m: StrandMeasure | null): Judged; export declare function judgeBindPose(m: BindMeasure | null): Judged; export declare function judgePosture(m: PostureMeasure | null): Judged; /** Phases at which each arm swings furthest back (hand furthest behind the pelvis), for the critic's frames. */ export declare function backswingPhases(rest: PreviewRest, poses: PreviewPose[]): { left: number | null; right: number | null; }; /** Body-frame bounds of every posed vertex over the given poses. */ export declare function posedBounds(poses: PreviewPose[]): { min: Vec3; max: Vec3; } | null;