/** * VRM springs → full `helix/dynamics@1` chains, built on the CONVERTED rig. * * ── WHY THIS IS A SECOND STEP ────────────────────────────────────────────────────────────────────────────────── * `vrmDynamics.ts` reads what the source DECLARES (which joints, which parameter values). What a chain needs * beyond that is geometry — the length of each bone, the point the last bone aims at, which children branch — * and that geometry belongs to the rig the avatar is shipping on, not to the file it came from: `conform` * rebuilds the local frames, the 0.x forward flip rotates everything, and the rig is renamed. A tail offset read * from the source JSON is in a frame that no longer exists in the output. So this runs on the final document. * * ── WHAT IT KEEPS THAT THE ROOT-ONLY CONVERSION LOST ─────────────────────────────────────────────────────────── * · Every joint. The engine walks a chain from `root` down the single-child line, so one manifest chain per * VRM spring (or per unbranched segment of a 0.x tree) simulates the WHOLE strand, not its first link. * · Per-joint values. Stiffness, drag and the collision radius are sampled along the chain as curves (the * contract's own mechanism, evenly spaced stops, at most 8), so a strand that is stiff at the scalp and * loose at the tip stays that way. Bone length enters the unit conversion per joint, because VRM's * stiffness is a rate relative to the bone it moves. * · The exact stopping point. A VRM 1.0 spring's last joint is only a tail. The chain excludes it and takes * its offset as the `endpoint`, so the last simulated bone aims where the source aimed it, and the extra * tip bone the old conversion simulated (which the reference leaves static) is gone. * · The 0.x tree. three-vrm simulates EVERY node under a group's roots. A branch point ends an engine chain, * so each unbranched segment becomes its own chain, anchored on the (also simulated) branch bone. * · The collision set that is nearest, not the first eight listed. A chain may test eight colliders; a VRoid * hair group references up to 28, so which eight decides whether hair passes through the shoulders. * * Everything here is deterministic and runs in the importer, in a test or in a browser. */ import type { Document } from '@gltf-transform/core'; import { type ImportedChain, type ImportedCollider, type VrmSpring } from './vrmDynamics'; /** Mirrors `DYNAMICS_LIMITS` in the engine's `DynamicsContract.ts`. A manifest over any of these is refused whole. */ export declare const DYNAMICS_CAPS: { readonly maxChains: 64; readonly maxJointsPerChain: 32; readonly maxJoints: 192; readonly maxColliders: 64; readonly maxCollidersPerChain: 8; readonly maxCollisionChecks: 1024; readonly maxCurveStops: 8; }; export type Curve = number | number[]; export interface ManifestChain { id: string; root: string; importance: ImportedChain['importance']; endpoint?: [number, number, number]; exclude?: string[]; stiffness: Curve; damping: Curve; inertia?: Curve; gravity?: number; gravityDir?: [number, number, number]; radius?: Curve; colliders?: string[]; } export interface SpringChainReport { springs: number; chains: number; joints: number; collisionChecks: number; /** Joints in the source springs that the converted rig has no bone for. */ missingJoints: number; droppedChains: string[]; /** Chains whose collider list was cut to the nearest N. */ collidersTrimmed: number; /** Springs that declare a `center`, with the chain ids they became: input for centre-space support. */ centred: Array<{ chain: string; center: string; }>; } export interface SpringChainContext { document: Document; /** Source node name → the name that node has in `document`, or undefined if it is gone. */ resolve(sourceName: string): string | undefined; /** Colliders already expressed on the converted rig (bone names and local frames final). */ colliders: readonly ImportedCollider[]; } /** How much of the anchor's motion a `center`-declaring chain carries. Single place to calibrate. */ export declare function centreInertia(_jointCount: number): number; /** * Compress per-joint values to a contract curve: one number when they are all equal, the exact list when it * fits in 8 stops, otherwise 8 stops resampled linearly along the chain. */ export declare function toCurve(values: readonly number[], decimals?: number): Curve; export declare function buildSpringChains(ctx: SpringChainContext, springs: readonly VrmSpring[]): { chains: ManifestChain[]; colliders: ImportedCollider[]; warnings: string[]; report: SpringChainReport; };