import type { Document, Node } from '@gltf-transform/core'; import { type ExpressionSpec } from './expressionExport'; import type { VrmMetaOptions } from './exportVrm'; /** * What a VRM-imported HELIX avatar carries beyond `helixFace` / `helixDynamics`, read back into VRM 1.0. * * The VRM importer (`character/vrmCharacter.ts`) writes additive scene-extras blocks beside the strict * manifests: `helixAvatar.meta` (the file's own authorship and licence), `helixFaceExt` (multi-morph and custom * expressions, binary and override flags, bone lookAt), `helixDynamicsCenters` (a chain's centre-space bone) and * `helixConstraints` (roll and rotation constraints). Each is optional here: an avatar that never came from a * VRM has none of them and exports from the manifests alone. When present they are what makes * VRM -> HELIX -> VRM come back as the same avatar rather than a HELIX-flavoured one. */ /** The importer's normalised meta record (`helixAvatar.meta`). Fields are the file's own spellings. */ export interface ImportedVrmMeta { specVersion?: '0.x' | '1.0'; name?: string; version?: string; authors?: string[]; contactInformation?: string; copyrightInformation?: string; references?: string[]; licenseName?: string; licenseUrl?: string; otherLicenseUrl?: string; allowedUser?: string; violentUsage?: string | boolean; sexualUsage?: string | boolean; commercialUsage?: string; politicalOrReligiousUsage?: string | boolean; antisocialOrHateUsage?: string | boolean; creditNotation?: string; allowRedistribution?: boolean; modification?: string; } export type VrmMetaJson = VrmMetaOptions & { allowExcessivelyViolentUsage?: boolean; allowExcessivelySexualUsage?: boolean; allowPoliticalOrReligiousUsage?: boolean; allowAntisocialOrHateUsage?: boolean; }; /** * The importer's meta record -> VRM 1.0 `meta`. A 1.0 source passes through. A 0.x source is migrated the way * UniVRM migrates it, leaning to the narrower grant wherever 0.x is vaguer than 1.0: a 0.x commercial "Allow" * becomes `personalProfit` (not `corporation`), and anything but a Creative Commons licence forbids * redistribution and modification. A CC licence travels as `otherLicenseUrl`; `licenseUrl` must be the VRM * licence. Fields the record does not state are left out so the caller's defaults apply. */ export declare function metaFromImported(record: ImportedVrmMeta): VrmMetaJson; export interface FaceExtLike { version?: number; expressions?: Array<{ name: string; binds: Array<{ morph: string; weight: number; }>; binary?: boolean; overrideBlink?: 'block' | 'blend'; overrideLookAt?: 'block' | 'blend'; overrideMouth?: 'block' | 'blend'; }>; lookAt?: { type: 'bone'; left?: string; right?: string; degrees: { inner: number; outer: number; up: number; down: number; }; }; } /** * Overlay `helixFaceExt` onto the manifest-derived expressions: an ext entry replaces the single-morph version of * the same expression (its binds are the file's own, several morphs at their own weights) and adds the binary and * override flags; `custom.` entries become VRM custom expressions under their original name. */ export declare function applyFaceExt(doc: Document, specs: ExpressionSpec[], ext: FaceExtLike, warnings: string[]): ExpressionSpec[]; /** VRM 1.0 bone `lookAt` from `helixFaceExt.lookAt`, plus the eye joints it needs as humanoid bones. */ export declare function boneLookAt(ext: FaceExtLike, byName: ReadonlyMap, joints: ReadonlySet, warnings: string[]): { lookAt: Record; leftEye: Node; rightEye: Node; } | null; export interface ConstraintLike { kind: 'roll' | 'rotation'; node: string; source: string; weight: number; axis?: [number, number, number]; } export interface ConstraintSpec { node: Node; source: Node; kind: 'roll' | 'rotation'; weight: number; rollAxis?: 'X' | 'Y' | 'Z'; } /** `helixConstraints` -> per-node `VRMC_node_constraint` specs. A roll about a non-principal axis has no VRM form. */ export declare function buildConstraints(list: readonly ConstraintLike[], byName: ReadonlyMap, warnings: string[]): ConstraintSpec[]; export declare function constraintJson(c: ConstraintSpec, indexOf: (n: Node) => number): Record;