import type { Document } from '@gltf-transform/core'; /** * Conform-time vertex push-out — the SECOND line of defence against poke-through, for the cases a `hide` * op cannot fix. * * `bodyRegionHide.ts` removes the skin a garment fully covers, which is the right fix for a garment that * loosely bags a whole region (the Sinth Ascetic Pants case: pants that reach the ankle, hiding the whole * thigh/shin). It is the WRONG fix for a garment that is merely too tight at one edge — a hem, a cuff, a * waistband — because hiding the region would also hide the skin the garment does NOT cover (bare ankle * below a cropped trouser leg, bare wrist past a short sleeve). For that case the body must stay visible and * the GARMENT geometry has to move a little further from the skin instead. * * This step runs on the conformed garment mesh (after `conformToHelixRest`, in the same rest-pose space as * the host body) and the host body's own conformed mesh. For every garment vertex closer to the host * surface than `threshold` (measured along the host surface's own outward normal, so a vertex already * clear of the body is left alone and one merely GRAZING it is not overcorrected), it is pushed out along * that normal until it clears the body by `offset`. Vertices already at or beyond `offset` are untouched — * this only closes gaps, it never inflates a garment that already fits. * * ── WHY THIS IS CONSERVATIVE ──────────────────────────────────────────────────────────────────────────────── * - Only vertices within `threshold` of the body move at all; the overwhelming majority of a garment's * vertices (anywhere away from the skin-tight edges) are never touched, so the garment's silhouette away * from those edges is bit-for-bit identical to what conform already produced. * - The push distance is clamped to `maxPushOut` regardless of how deep a vertex is embedded, so a * badly-fit garment is not silently inflated into a different shape — a violation past the clamp should * fail the automated poke-through check (`pokethrough-check.mjs`) and get creator attention instead. * - Movement is along the BODY's outward normal at the nearest surface point, not the garment vertex's own * normal — stable even where the garment normal is noisy (thin cloth, near-tangent faces) because it is * anchored to the coarser, more reliable body surface. */ export interface PushOutOptions { /** * A garment vertex closer to the body than this (metres) is considered at risk and pushed out. Default * 4mm: the platform's canonical body scale is metres-real-world, and this is comfortably inside normal * cloth-to-skin clearance for a well-conformed garment while still catching genuine near-misses from * automatic weight transfer. Tune per item family if a garment's natural clearance is tighter (e.g. a * skin-suit) or looser (e.g. bulky outerwear). */ thresholdMeters?: number; /** How far past the body surface a corrected vertex ends up (metres). Default 2mm — a hairline gap that * reads as "not touching" up close without visibly separating the garment from the body at a distance. */ offsetMeters?: number; /** Hard clamp on how far any single vertex may move (metres). Default 15mm — beyond this the garment is * not merely tight, it is the wrong shape for the body, and moving it further would hide that rather * than surface it. */ maxPushOutMeters?: number; } export interface PushOutReport { /** Garment vertices examined across every mesh primitive. */ verticesExamined: number; /** Garment vertices that were within `thresholdMeters` of the body surface. */ verticesAtRisk: number; /** Of those, how many were actually moved (a vertex already exactly at `offsetMeters` needs no push). */ verticesPushed: number; /** Vertices where the required push exceeded `maxPushOutMeters` — moved only to the clamp, still flagged. */ verticesClamped: number; /** The largest correction actually applied, in metres. 0 if nothing needed moving. */ maxCorrectionMeters: number; } /** * Push garment vertices out of the host body surface where they are closer than `thresholdMeters`. Mutates * `garment`'s POSITION accessors in place (NORMAL is left untouched — the push distances are small enough * that re-lighting is not worth the extra pass, and a shading seam from a hairline offset is not visible at * platform LOD triangle counts). */ export declare function pushGarmentOutOfBody(garment: Document, hostBody: Document, options?: PushOutOptions): PushOutReport;