import type { Document, Scene } from '@gltf-transform/core'; import { type HelixConstraint } from './vrmConstraints'; /** * Keep `helixConstraints` true across the rig-fix's re-pose. * * The importer records every constraint against the pose the file was authored in: a rotation constraint carries the * source and destination WORLD rest orientations (`srcRest`, `dstRest`), a roll constraint a world axis. The rig-fix then * re-binds the arms onto the platform A-pose (`normalizeBindPose`) and may move joints (`normalizeRestJoints`): the * source joint's world rest turns by some D and the numbers recorded above go stale. Two things then break. * * - A destination that rides the SAME limb (a roll helper under the forearm) turns with it, but its recorded axis does * not, so the twist is taken about a stale direction. * - A destination that is NOT under the source (Seed-san's robot arm: `robo_upper_armL` copies `upperarm_l`, and hangs * off the back, not the arm) keeps its authored pose. Its skinned geometry still stands out in a T while the * body's arm hangs, and, because a rotation constraint applies only the source's CHANGE from rest, it stays that way * for every clip. * * So: capture the world rest of every node a constraint names before the re-pose, and after it (a) turn each rotation * destination by the same D as its source, then bake the skins whose bind no longer equals rest (`bakeRestSkin`) so the * geometry follows, and (b) rotate `srcRest`, `dstRest` and `axis` by the D of the node they describe, which keeps the * runtime's frame algebra (all conjugation by `srcRest⁻¹ · rigRest`) exactly as it was before the re-pose. */ type Q = [number, number, number, number]; export interface ConstraintRestSnapshot { /** Per scene that carries the block (and every other scene, by name): world rest of each constraint-named node. */ worlds: Map>; constraints: HelixConstraint[]; } export interface ConstraintRestReport { /** Constraints whose recorded rest numbers were rotated by their node's re-pose. */ updated: number; /** Destination nodes turned to follow their source (across every scene that has them). */ followed: number; /** Skins baked so geometry weighted to a followed destination moves with it. */ skinsBaked: number; } /** Call before any stage that re-poses joints. `null` when the document carries no constraints. */ export declare function captureConstraintRest(document: Document): ConstraintRestSnapshot | null; /** Call after the re-pose (and before anything that only translates, like the ground lift). */ export declare function followConstraintRest(document: Document, snapshot: ConstraintRestSnapshot | null): ConstraintRestReport; export {};