@automovie/ingest 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +37 -2
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.d.ts +5 -0
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js +8 -0
- package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js.map +1 -0
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.d.ts +5 -0
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js +15 -0
- package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js.map +1 -0
- package/lib/AutoMovieExternalModelIngestProfile.d.ts +11 -0
- package/lib/AutoMovieExternalModelIngestProfile.js +3 -0
- package/lib/AutoMovieExternalModelIngestProfile.js.map +1 -0
- package/lib/AutoMovieExternalMotionAdoptionDecision.d.ts +11 -0
- package/lib/AutoMovieExternalMotionAdoptionDecision.js +3 -0
- package/lib/AutoMovieExternalMotionAdoptionDecision.js.map +1 -0
- package/lib/AutoMovieGltfMotionInterpretationProfile.d.ts +9 -0
- package/lib/AutoMovieGltfMotionInterpretationProfile.js +3 -0
- package/lib/AutoMovieGltfMotionInterpretationProfile.js.map +1 -0
- package/lib/IAutoMovieExternalModelInspection.d.ts +48 -0
- package/lib/IAutoMovieExternalModelInspection.js +3 -0
- package/lib/IAutoMovieExternalModelInspection.js.map +1 -0
- package/lib/IAutoMovieExternalModelResource.d.ts +18 -0
- package/lib/IAutoMovieExternalModelResource.js +3 -0
- package/lib/IAutoMovieExternalModelResource.js.map +1 -0
- package/lib/IAutoMovieExternalMotionAdoption.d.ts +23 -0
- package/lib/IAutoMovieExternalMotionAdoption.js +3 -0
- package/lib/IAutoMovieExternalMotionAdoption.js.map +1 -0
- package/lib/IAutoMovieExternalMotionBoneMapping.d.ts +15 -0
- package/lib/IAutoMovieExternalMotionBoneMapping.js +3 -0
- package/lib/IAutoMovieExternalMotionBoneMapping.js.map +1 -0
- package/lib/IAutoMovieExternalMotionInspection.d.ts +25 -0
- package/lib/IAutoMovieExternalMotionInspection.js +3 -0
- package/lib/IAutoMovieExternalMotionInspection.js.map +1 -0
- package/lib/IAutoMovieExternalMotionNativeDecision.d.ts +20 -0
- package/lib/IAutoMovieExternalMotionNativeDecision.js +3 -0
- package/lib/IAutoMovieExternalMotionNativeDecision.js.map +1 -0
- package/lib/IAutoMovieExternalMotionNativeHandoff.d.ts +18 -0
- package/lib/IAutoMovieExternalMotionNativeHandoff.js +3 -0
- package/lib/IAutoMovieExternalMotionNativeHandoff.js.map +1 -0
- package/lib/IAutoMovieExternalMotionNodeInspection.d.ts +21 -0
- package/lib/IAutoMovieExternalMotionNodeInspection.js +3 -0
- package/lib/IAutoMovieExternalMotionNodeInspection.js.map +1 -0
- package/lib/IAutoMovieExternalMotionRetargetDecision.d.ts +24 -0
- package/lib/IAutoMovieExternalMotionRetargetDecision.js +3 -0
- package/lib/IAutoMovieExternalMotionRetargetDecision.js.map +1 -0
- package/lib/IAutoMovieExternalMotionRetargetHandoff.d.ts +22 -0
- package/lib/IAutoMovieExternalMotionRetargetHandoff.js +3 -0
- package/lib/IAutoMovieExternalMotionRetargetHandoff.js.map +1 -0
- package/lib/IAutoMovieExternalMotionSource.d.ts +18 -0
- package/lib/IAutoMovieExternalMotionSource.js +3 -0
- package/lib/IAutoMovieExternalMotionSource.js.map +1 -0
- package/lib/IAutoMovieIngestResult.d.ts +17 -0
- package/lib/IAutoMovieIngestResult.js +3 -0
- package/lib/IAutoMovieIngestResult.js.map +1 -0
- package/lib/adoptAutoMovieExternalMotion.d.ts +32 -0
- package/lib/adoptAutoMovieExternalMotion.js +215 -0
- package/lib/adoptAutoMovieExternalMotion.js.map +1 -0
- package/lib/audio/IAutoMovieDecodedProductionAudioAsset.d.ts +28 -0
- package/lib/audio/IAutoMovieDecodedProductionAudioAsset.js +3 -0
- package/lib/audio/IAutoMovieDecodedProductionAudioAsset.js.map +1 -0
- package/lib/audio/IAutoMovieProductionAudioProcessing.d.ts +18 -0
- package/lib/audio/IAutoMovieProductionAudioProcessing.js +3 -0
- package/lib/audio/IAutoMovieProductionAudioProcessing.js.map +1 -0
- package/lib/audio/IAutoMovieProductionWaveSourceFormat.d.ts +39 -0
- package/lib/audio/IAutoMovieProductionWaveSourceFormat.js +3 -0
- package/lib/audio/IAutoMovieProductionWaveSourceFormat.js.map +1 -0
- package/lib/audio/decodeProductionAudioAsset.d.ts +33 -0
- package/lib/audio/decodeProductionAudioAsset.js +257 -0
- package/lib/audio/decodeProductionAudioAsset.js.map +1 -0
- package/lib/audio/index.d.ts +4 -0
- package/lib/audio/index.js +21 -0
- package/lib/audio/index.js.map +1 -0
- package/lib/decodeAutoMoviePpmImage.d.ts +30 -0
- package/lib/decodeAutoMoviePpmImage.js +84 -0
- package/lib/decodeAutoMoviePpmImage.js.map +1 -0
- package/lib/humanoidSkeleton.d.ts +24 -0
- package/lib/humanoidSkeleton.js +80 -0
- package/lib/humanoidSkeleton.js.map +1 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +40 -0
- package/lib/index.js.map +1 -0
- package/lib/ingestDocument.d.ts +23 -0
- package/lib/ingestDocument.js +173 -0
- package/lib/ingestDocument.js.map +1 -0
- package/lib/inspectAutoMovieExternalModelBytes.d.ts +32 -0
- package/lib/inspectAutoMovieExternalModelBytes.js +219 -0
- package/lib/inspectAutoMovieExternalModelBytes.js.map +1 -0
- package/lib/internal/COMPONENT_BYTES.d.ts +2 -0
- package/lib/internal/COMPONENT_BYTES.js +13 -0
- package/lib/internal/COMPONENT_BYTES.js.map +1 -0
- package/lib/internal/IAccessorSource.d.ts +16 -0
- package/lib/internal/IAccessorSource.js +3 -0
- package/lib/internal/IAccessorSource.js.map +1 -0
- package/lib/internal/IExternalModelAccessorReader.d.ts +9 -0
- package/lib/internal/IExternalModelAccessorReader.js +3 -0
- package/lib/internal/IExternalModelAccessorReader.js.map +1 -0
- package/lib/internal/IHumanoidSlot.d.ts +15 -0
- package/lib/internal/IHumanoidSlot.js +3 -0
- package/lib/internal/IHumanoidSlot.js.map +1 -0
- package/lib/internal/IParsedContainer.d.ts +16 -0
- package/lib/internal/IParsedContainer.js +3 -0
- package/lib/internal/IParsedContainer.js.map +1 -0
- package/lib/internal/SHAPE_COMPONENTS.d.ts +6 -0
- package/lib/internal/SHAPE_COMPONENTS.js +25 -0
- package/lib/internal/SHAPE_COMPONENTS.js.map +1 -0
- package/lib/internal/accessorElementByteLength.d.ts +12 -0
- package/lib/internal/accessorElementByteLength.js +28 -0
- package/lib/internal/accessorElementByteLength.js.map +1 -0
- package/lib/internal/accessorReader.d.ts +16 -0
- package/lib/internal/accessorReader.js +52 -0
- package/lib/internal/accessorReader.js.map +1 -0
- package/lib/internal/accessorValues.d.ts +18 -0
- package/lib/internal/accessorValues.js +38 -0
- package/lib/internal/accessorValues.js.map +1 -0
- package/lib/internal/collectExternalResources.d.ts +13 -0
- package/lib/internal/collectExternalResources.js +51 -0
- package/lib/internal/collectExternalResources.js.map +1 -0
- package/lib/internal/compareCodeUnits.d.ts +12 -0
- package/lib/internal/compareCodeUnits.js +17 -0
- package/lib/internal/compareCodeUnits.js.map +1 -0
- package/lib/internal/composeLocalTransform.d.ts +21 -0
- package/lib/internal/composeLocalTransform.js +53 -0
- package/lib/internal/composeLocalTransform.js.map +1 -0
- package/lib/internal/decodeDataUri.d.ts +14 -0
- package/lib/internal/decodeDataUri.js +61 -0
- package/lib/internal/decodeDataUri.js.map +1 -0
- package/lib/internal/decodeGlb.d.ts +13 -0
- package/lib/internal/decodeGlb.js +56 -0
- package/lib/internal/decodeGlb.js.map +1 -0
- package/lib/internal/decodeJson.d.ts +12 -0
- package/lib/internal/decodeJson.js +77 -0
- package/lib/internal/decodeJson.js.map +1 -0
- package/lib/internal/fileExtension.d.ts +12 -0
- package/lib/internal/fileExtension.js +21 -0
- package/lib/internal/fileExtension.js.map +1 -0
- package/lib/internal/finiteTuple.d.ts +14 -0
- package/lib/internal/finiteTuple.js +29 -0
- package/lib/internal/finiteTuple.js.map +1 -0
- package/lib/internal/gltfHumanoidBones.d.ts +15 -0
- package/lib/internal/gltfHumanoidBones.js +39 -0
- package/lib/internal/gltfHumanoidBones.js.map +1 -0
- package/lib/internal/humanoidBoneOfName.d.ts +18 -0
- package/lib/internal/humanoidBoneOfName.js +67 -0
- package/lib/internal/humanoidBoneOfName.js.map +1 -0
- package/lib/internal/inspectExternalModelHierarchy.d.ts +12 -0
- package/lib/internal/inspectExternalModelHierarchy.js +51 -0
- package/lib/internal/inspectExternalModelHierarchy.js.map +1 -0
- package/lib/internal/inspectExternalMotion.d.ts +23 -0
- package/lib/internal/inspectExternalMotion.js +152 -0
- package/lib/internal/inspectExternalMotion.js.map +1 -0
- package/lib/internal/inspectExternalMotionNodes.d.ts +15 -0
- package/lib/internal/inspectExternalMotionNodes.js +58 -0
- package/lib/internal/inspectExternalMotionNodes.js.map +1 -0
- package/lib/internal/integerIndex.d.ts +12 -0
- package/lib/internal/integerIndex.js +23 -0
- package/lib/internal/integerIndex.js.map +1 -0
- package/lib/internal/integerIndices.d.ts +12 -0
- package/lib/internal/integerIndices.js +23 -0
- package/lib/internal/integerIndices.js.map +1 -0
- package/lib/internal/nonNegativeInteger.d.ts +12 -0
- package/lib/internal/nonNegativeInteger.js +22 -0
- package/lib/internal/nonNegativeInteger.js.map +1 -0
- package/lib/internal/object.d.ts +12 -0
- package/lib/internal/object.js +21 -0
- package/lib/internal/object.js.map +1 -0
- package/lib/internal/optionalArray.d.ts +12 -0
- package/lib/internal/optionalArray.js +18 -0
- package/lib/internal/optionalArray.js.map +1 -0
- package/lib/internal/optionalObject.d.ts +12 -0
- package/lib/internal/optionalObject.js +18 -0
- package/lib/internal/optionalObject.js.map +1 -0
- package/lib/internal/optionalStringArray.d.ts +12 -0
- package/lib/internal/optionalStringArray.js +22 -0
- package/lib/internal/optionalStringArray.js.map +1 -0
- package/lib/internal/positiveInteger.d.ts +12 -0
- package/lib/internal/positiveInteger.js +22 -0
- package/lib/internal/positiveInteger.js.map +1 -0
- package/lib/internal/readMotionAccessor.d.ts +15 -0
- package/lib/internal/readMotionAccessor.js +41 -0
- package/lib/internal/readMotionAccessor.js.map +1 -0
- package/lib/internal/requiredArray.d.ts +12 -0
- package/lib/internal/requiredArray.js +21 -0
- package/lib/internal/requiredArray.js.map +1 -0
- package/lib/internal/uniqueStrings.d.ts +12 -0
- package/lib/internal/uniqueStrings.js +18 -0
- package/lib/internal/uniqueStrings.js.map +1 -0
- package/lib/internal/validNodeIndex.d.ts +12 -0
- package/lib/internal/validNodeIndex.js +20 -0
- package/lib/internal/validNodeIndex.js.map +1 -0
- package/lib/internal/validateAccessorRange.d.ts +14 -0
- package/lib/internal/validateAccessorRange.js +37 -0
- package/lib/internal/validateAccessorRange.js.map +1 -0
- package/lib/internal/validateHumanoidSkinning.d.ts +20 -0
- package/lib/internal/validateHumanoidSkinning.js +91 -0
- package/lib/internal/validateHumanoidSkinning.js.map +1 -0
- package/lib/internal/validatePayloadClosure.d.ts +21 -0
- package/lib/internal/validatePayloadClosure.js +74 -0
- package/lib/internal/validatePayloadClosure.js.map +1 -0
- package/lib/internal/validateSparseAccessor.d.ts +14 -0
- package/lib/internal/validateSparseAccessor.js +50 -0
- package/lib/internal/validateSparseAccessor.js.map +1 -0
- package/lib/internal/vrmHumanoidBones.d.ts +15 -0
- package/lib/internal/vrmHumanoidBones.js +132 -0
- package/lib/internal/vrmHumanoidBones.js.map +1 -0
- package/lib/isAutoMovieExternalModelIngestProfile.d.ts +18 -0
- package/lib/isAutoMovieExternalModelIngestProfile.js +24 -0
- package/lib/isAutoMovieExternalModelIngestProfile.js.map +1 -0
- package/package.json +45 -3
- package/src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts +7 -0
- package/src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts +21 -0
- package/src/AutoMovieExternalModelIngestProfile.ts +15 -0
- package/src/AutoMovieExternalMotionAdoptionDecision.ts +14 -0
- package/src/AutoMovieGltfMotionInterpretationProfile.ts +10 -0
- package/src/IAutoMovieExternalModelInspection.ts +62 -0
- package/src/IAutoMovieExternalModelResource.ts +20 -0
- package/src/IAutoMovieExternalMotionAdoption.ts +30 -0
- package/src/IAutoMovieExternalMotionBoneMapping.ts +17 -0
- package/src/IAutoMovieExternalMotionInspection.ts +32 -0
- package/src/IAutoMovieExternalMotionNativeDecision.ts +25 -0
- package/src/IAutoMovieExternalMotionNativeHandoff.ts +22 -0
- package/src/IAutoMovieExternalMotionNodeInspection.ts +26 -0
- package/src/IAutoMovieExternalMotionRetargetDecision.ts +31 -0
- package/src/IAutoMovieExternalMotionRetargetHandoff.ts +28 -0
- package/src/IAutoMovieExternalMotionSource.ts +20 -0
- package/src/IAutoMovieIngestResult.ts +19 -0
- package/src/adoptAutoMovieExternalMotion.ts +387 -0
- package/src/audio/IAutoMovieDecodedProductionAudioAsset.ts +35 -0
- package/src/audio/IAutoMovieProductionAudioProcessing.ts +21 -0
- package/src/audio/IAutoMovieProductionWaveSourceFormat.ts +50 -0
- package/src/audio/decodeProductionAudioAsset.ts +451 -0
- package/src/audio/index.ts +4 -0
- package/src/decodeAutoMoviePpmImage.ts +103 -0
- package/src/humanoidSkeleton.ts +105 -0
- package/src/index.ts +23 -0
- package/src/ingestDocument.ts +242 -0
- package/src/inspectAutoMovieExternalModelBytes.ts +346 -0
- package/src/internal/COMPONENT_BYTES.ts +12 -0
- package/src/internal/IAccessorSource.ts +18 -0
- package/src/internal/IExternalModelAccessorReader.ts +12 -0
- package/src/internal/IHumanoidSlot.ts +17 -0
- package/src/internal/IParsedContainer.ts +18 -0
- package/src/internal/SHAPE_COMPONENTS.ts +27 -0
- package/src/internal/accessorElementByteLength.ts +24 -0
- package/src/internal/accessorReader.ts +76 -0
- package/src/internal/accessorValues.ts +35 -0
- package/src/internal/collectExternalResources.ts +69 -0
- package/src/internal/compareCodeUnits.ts +15 -0
- package/src/internal/composeLocalTransform.ts +56 -0
- package/src/internal/decodeDataUri.ts +70 -0
- package/src/internal/decodeGlb.ts +70 -0
- package/src/internal/decodeJson.ts +76 -0
- package/src/internal/fileExtension.ts +18 -0
- package/src/internal/finiteTuple.ts +33 -0
- package/src/internal/gltfHumanoidBones.ts +48 -0
- package/src/internal/humanoidBoneOfName.ts +75 -0
- package/src/internal/inspectExternalModelHierarchy.ts +61 -0
- package/src/internal/inspectExternalMotion.ts +292 -0
- package/src/internal/inspectExternalMotionNodes.ts +81 -0
- package/src/internal/integerIndex.ts +28 -0
- package/src/internal/integerIndices.ts +24 -0
- package/src/internal/nonNegativeInteger.ts +22 -0
- package/src/internal/object.ts +22 -0
- package/src/internal/optionalArray.ts +17 -0
- package/src/internal/optionalObject.ts +20 -0
- package/src/internal/optionalStringArray.ts +22 -0
- package/src/internal/positiveInteger.ts +22 -0
- package/src/internal/readMotionAccessor.ts +60 -0
- package/src/internal/requiredArray.ts +19 -0
- package/src/internal/uniqueStrings.ts +16 -0
- package/src/internal/validNodeIndex.ts +19 -0
- package/src/internal/validateAccessorRange.ts +53 -0
- package/src/internal/validateHumanoidSkinning.ts +152 -0
- package/src/internal/validatePayloadClosure.ts +116 -0
- package/src/internal/validateSparseAccessor.ts +109 -0
- package/src/internal/vrmHumanoidBones.ts +176 -0
- package/src/isAutoMovieExternalModelIngestProfile.ts +28 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Manifest-owned identity of the exact external motion bytes the author chose.
|
|
3
|
+
*
|
|
4
|
+
* Adoption compares path and byte length with the inspection and checks digest spelling. The digest remains the manifest owner's claim: equal path and length alone do not prove equal byte content, so that owner must bind the digest to the resident bytes before inspection.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/design.md#principled-representation Manifest path, digest and length identify the declared source; adoption proves path/length agreement and digest syntax, while digest-to-resident-byte binding remains the inventory caller's responsibility.
|
|
7
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface The identity is its own record because the production inventory builds it from the manifest independently of the inspection, and the adoption copies it unchanged into the receipt.
|
|
8
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts Ingest never hashes the bytes itself; the digest format is checked and the hash stays the manifest's claim, which the documentation does not overstate as verified.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation Each property states the constraint adoption enforces on it: non-blank and equal path, the `sha256:` digest spelling, and a positive safe-integer length equal to the inspection's.
|
|
10
|
+
*/
|
|
11
|
+
export interface IAutoMovieExternalMotionSource {
|
|
12
|
+
/** Manifest path; it must be non-blank and equal the inspected path. */
|
|
13
|
+
path: string;
|
|
14
|
+
|
|
15
|
+
/** `sha256:` plus 64 lowercase hex digits, pinned by the production manifest. */
|
|
16
|
+
digest: string;
|
|
17
|
+
|
|
18
|
+
/** Resident byte count; a positive safe integer equal to the inspected one. */
|
|
19
|
+
byteLength: number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IAutoMovieClip, IAutoMovieNode } from "@automovie/interface";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The core node graph and clips one parsed glTF/GLB document maps to.
|
|
5
|
+
*
|
|
6
|
+
* Ids are positional: node `node_{i}` is the document's `i`-th node, clip `clip_{i}` its `i`-th animation, and mesh, camera and skin references are the decimal index of that resource in its root list. The ids are therefore stable for one document revision and never collide when names repeat, but they do not survive a re-export that reorders the lists.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/development/design.md#principled-representation Positional ids follow glTF's own index-based references, so a node, clip, mesh, camera or skin id equals its index in the document's lists and cross-references resolve without name lookup.
|
|
9
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface The result is the two lists the engine already consumes, nodes and clips, with no wrapper around either.
|
|
10
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts The documentation states that positional ids do not survive a re-export that reorders the lists rather than presenting them as content identity.
|
|
11
|
+
* @evidence contracts/development/common.md#meaningful-documentation The comments give the id scheme for every referenced resource, the parent meaning of each node, and the order, looping and duration meaning of each clip.
|
|
12
|
+
*/
|
|
13
|
+
export interface IAutoMovieIngestResult {
|
|
14
|
+
/** Every glTF node in document order as a core node whose `parent` names the node that lists it as a child, or `null` for a root. */
|
|
15
|
+
nodes: IAutoMovieNode[];
|
|
16
|
+
|
|
17
|
+
/** One non-looping clip per glTF animation in document order, its tracks in channel order and its duration the latest keyframe time in seconds. */
|
|
18
|
+
clips: IAutoMovieClip[];
|
|
19
|
+
}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import { SHA256_DIGEST_PATTERN } from "@automovie/engine";
|
|
2
|
+
import type {
|
|
3
|
+
AutoMovieHumanoidBone,
|
|
4
|
+
IAutoMovieBone,
|
|
5
|
+
IAutoMovieClip,
|
|
6
|
+
IAutoMovieSkeleton,
|
|
7
|
+
IAutoMovieTrack,
|
|
8
|
+
IAutoMovieTransform,
|
|
9
|
+
} from "@automovie/interface";
|
|
10
|
+
|
|
11
|
+
import { AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE } from "./AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE";
|
|
12
|
+
import type { AutoMovieExternalMotionAdoptionDecision } from "./AutoMovieExternalMotionAdoptionDecision";
|
|
13
|
+
import type { IAutoMovieExternalModelInspection } from "./IAutoMovieExternalModelInspection";
|
|
14
|
+
import type { IAutoMovieExternalMotionAdoption } from "./IAutoMovieExternalMotionAdoption";
|
|
15
|
+
import type { IAutoMovieExternalMotionBoneMapping } from "./IAutoMovieExternalMotionBoneMapping";
|
|
16
|
+
import type { IAutoMovieExternalMotionInspection } from "./IAutoMovieExternalMotionInspection";
|
|
17
|
+
import type { IAutoMovieExternalMotionNativeHandoff } from "./IAutoMovieExternalMotionNativeHandoff";
|
|
18
|
+
import type { IAutoMovieExternalMotionNodeInspection } from "./IAutoMovieExternalMotionNodeInspection";
|
|
19
|
+
import type { IAutoMovieExternalMotionRetargetDecision } from "./IAutoMovieExternalMotionRetargetDecision";
|
|
20
|
+
import type { IAutoMovieExternalMotionRetargetHandoff } from "./IAutoMovieExternalMotionRetargetHandoff";
|
|
21
|
+
import type { IAutoMovieExternalMotionSource } from "./IAutoMovieExternalMotionSource";
|
|
22
|
+
import { compareCodeUnits } from "./internal/compareCodeUnits";
|
|
23
|
+
import { composeLocalTransform } from "./internal/composeLocalTransform";
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Select one inspected take and validate the author's native or retarget decision without fetching bytes, choosing a provider or inferring a rig.
|
|
27
|
+
*
|
|
28
|
+
* The inspection must come from the `gltf-motion-v1` profile under the glTF meter, right-handed, Y-up interpretation, and the source must repeat its path and byte length with a lowercase SHA-256 digest. Every track of the selected take must target a mapped node, translation only on the node mapped to `hips`, and never scale or weights, because humanoid motion carries neither. Each mapped bone's parent and rest in the declared source rig must equal what the inspected hierarchy implies: the nearest mapped ancestor and the node's local TRS composed through every unmapped helper between them. The comparison is exact, so an author computes the rest from the inspected transforms rather than retyping rounded values. The first violation throws with the field it concerns.
|
|
29
|
+
*
|
|
30
|
+
* The caller supplies an unmodified inspector result and binds the digest to the resident bytes; adoption checks digest spelling, not a hash. Rig admission here requires a non-blank id, unique bone names and `hips`, but basis comparisons cover only mapped bones and do not validate constraints or unmapped rests. Helper TRS composition follows fixed floating-point arithmetic and drops shear when a helper's non-uniform scale does not commute with a child rotation; exact agreement proves agreement with that representation, not exact affine geometry.
|
|
31
|
+
*
|
|
32
|
+
* @param props.inspection Inspection of the exact source bytes.
|
|
33
|
+
* @param props.source Manifest identity of those bytes.
|
|
34
|
+
* @param props.decision The author's use of one take.
|
|
35
|
+
* @returns A receipt that shares no objects with its inputs.
|
|
36
|
+
*
|
|
37
|
+
* @evidence contracts/development/implementation.md#principled-implementation Path and byte length compare with caller-supplied inspected facts, while the digest is checked only for spelling. Sets establish mapping uniqueness, and each mapped basis is recomputed by nearest-mapped-ancestor walks and fixed-order `composeLocalTransform` arithmetic; binary64 rounding and discarded shear remain, and constraints and unmapped rests receive no basis check.
|
|
38
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Identity/selection, rig binding and retarget-only fields have separate local owners; humanoid import shares transform composition and the engine validation owner supplies the common SHA-256 spelling predicate.
|
|
39
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No take, rig, bone or path is special-cased; the runtime mode check exists for untyped callers, and the digest regular expression is the manifest's documented `sha256:` format rather than a fixture value.
|
|
40
|
+
* @evidence contracts/development/common.md#meaningful-documentation The documentation distinguishes digest spelling from byte authentication, mapped-basis checks from complete rig admission, and exact arithmetic agreement from affine exactness; it also gives supported channels, first-refusal behavior and ownership of receipt copies.
|
|
41
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Copy cost follows the selected take's tracks/keyframes and source-rig size; hash-map setup follows the mapping and node counts. Mapping size M adds O(M log M) prefix-scanning node-id comparisons plus text-dependent identity/hash work; mapped bones times helper-chain lengths drive basis walks, and take lookup scans the declared take inventory without an assumed population bound.
|
|
42
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Adoption validates one decision against one inspection per call and shares no work across calls; the inspection it reads is already the caller's reused result.
|
|
43
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The temporary maps and sets die with the call; the receipt retains copies of the take, rig and mapping proportional to their size and is owned by the caller, with no handle or task.
|
|
44
|
+
*/
|
|
45
|
+
export const adoptAutoMovieExternalMotion: (props: {
|
|
46
|
+
/** Unmodified result of inspecting the source's exact resident bytes. */
|
|
47
|
+
inspection: IAutoMovieExternalModelInspection;
|
|
48
|
+
|
|
49
|
+
/** Manifest identity whose digest-to-byte binding the caller establishes. */
|
|
50
|
+
source: IAutoMovieExternalMotionSource;
|
|
51
|
+
|
|
52
|
+
/** Explicit take, rig and mapping, with retarget fields in retarget mode. */
|
|
53
|
+
decision: AutoMovieExternalMotionAdoptionDecision;
|
|
54
|
+
}) => IAutoMovieExternalMotionAdoption = (props: {
|
|
55
|
+
/** Unmodified result of inspecting the source's exact resident bytes. */
|
|
56
|
+
inspection: IAutoMovieExternalModelInspection;
|
|
57
|
+
|
|
58
|
+
/** Manifest identity whose digest-to-byte binding the caller establishes. */
|
|
59
|
+
source: IAutoMovieExternalMotionSource;
|
|
60
|
+
|
|
61
|
+
/** Explicit take, rig and mapping, with retarget fields in retarget mode. */
|
|
62
|
+
decision: AutoMovieExternalMotionAdoptionDecision;
|
|
63
|
+
}): IAutoMovieExternalMotionAdoption => {
|
|
64
|
+
if (props.inspection.profile !== "gltf-motion-v1")
|
|
65
|
+
throw new Error(
|
|
66
|
+
'External motion adoption requires the "gltf-motion-v1" inspection profile.',
|
|
67
|
+
);
|
|
68
|
+
const motion: IAutoMovieExternalMotionInspection | undefined =
|
|
69
|
+
props.inspection.motion;
|
|
70
|
+
if (motion === undefined)
|
|
71
|
+
throw new Error("External source has no inspected motion takes.");
|
|
72
|
+
if (motion.interpretation !== AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE)
|
|
73
|
+
throw new Error(
|
|
74
|
+
`External motion interpretation "${String(motion.interpretation)}" is unsupported.`,
|
|
75
|
+
);
|
|
76
|
+
if (props.source.path.trim().length === 0)
|
|
77
|
+
throw new Error("External motion source path must be non-blank.");
|
|
78
|
+
if (props.source.path !== motion.path)
|
|
79
|
+
throw new Error(
|
|
80
|
+
`External motion source path "${props.source.path}" does not match inspected path "${motion.path}".`,
|
|
81
|
+
);
|
|
82
|
+
if (
|
|
83
|
+
Number.isSafeInteger(props.source.byteLength) === false ||
|
|
84
|
+
props.source.byteLength <= 0 ||
|
|
85
|
+
props.source.byteLength !== motion.byteLength
|
|
86
|
+
)
|
|
87
|
+
throw new Error(
|
|
88
|
+
`External motion source byteLength ${props.source.byteLength} does not match inspected byteLength ${motion.byteLength}.`,
|
|
89
|
+
);
|
|
90
|
+
if (SHA256_DIGEST_PATTERN.test(props.source.digest) === false)
|
|
91
|
+
throw new Error(
|
|
92
|
+
`External motion source digest "${props.source.digest}" must be a lowercase SHA-256 digest.`,
|
|
93
|
+
);
|
|
94
|
+
const decision: AutoMovieExternalMotionAdoptionDecision = props.decision;
|
|
95
|
+
if (decision.mode !== "native" && decision.mode !== "retarget")
|
|
96
|
+
throw new Error(
|
|
97
|
+
`Unsupported external motion adoption mode "${String((decision as { mode: unknown }).mode)}".`,
|
|
98
|
+
);
|
|
99
|
+
const selected: IAutoMovieClip | undefined = motion.takes.find(
|
|
100
|
+
(take: IAutoMovieClip): boolean => take.id === decision.take,
|
|
101
|
+
);
|
|
102
|
+
if (selected === undefined)
|
|
103
|
+
throw new Error(
|
|
104
|
+
`External motion take "${decision.take}" is not present in the inspected source.`,
|
|
105
|
+
);
|
|
106
|
+
const binding: Pick<
|
|
107
|
+
IAutoMovieExternalMotionNativeHandoff,
|
|
108
|
+
"sourceRig" | "mapping"
|
|
109
|
+
> = validateMotionBinding({
|
|
110
|
+
decision,
|
|
111
|
+
take: selected,
|
|
112
|
+
nodes: motion.nodes,
|
|
113
|
+
});
|
|
114
|
+
const source: IAutoMovieExternalMotionSource = { ...props.source };
|
|
115
|
+
const take: IAutoMovieClip = cloneClip(selected);
|
|
116
|
+
if (decision.mode === "native")
|
|
117
|
+
return {
|
|
118
|
+
source,
|
|
119
|
+
mode: "native",
|
|
120
|
+
take,
|
|
121
|
+
handoff: { mode: "native", ...binding },
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
source,
|
|
125
|
+
mode: "retarget",
|
|
126
|
+
take,
|
|
127
|
+
handoff: {
|
|
128
|
+
mode: "retarget",
|
|
129
|
+
...binding,
|
|
130
|
+
...validateRetargetDecision(decision),
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const validateMotionBinding: (props: {
|
|
136
|
+
decision: AutoMovieExternalMotionAdoptionDecision;
|
|
137
|
+
take: IAutoMovieClip;
|
|
138
|
+
nodes: IAutoMovieExternalMotionNodeInspection[];
|
|
139
|
+
}) => Pick<
|
|
140
|
+
IAutoMovieExternalMotionNativeHandoff,
|
|
141
|
+
"sourceRig" | "mapping"
|
|
142
|
+
> = (props: {
|
|
143
|
+
decision: AutoMovieExternalMotionAdoptionDecision;
|
|
144
|
+
take: IAutoMovieClip;
|
|
145
|
+
nodes: IAutoMovieExternalMotionNodeInspection[];
|
|
146
|
+
}): Pick<IAutoMovieExternalMotionNativeHandoff, "sourceRig" | "mapping"> => {
|
|
147
|
+
const sourceRig: IAutoMovieSkeleton = props.decision.sourceRig;
|
|
148
|
+
if (sourceRig.id.trim().length === 0)
|
|
149
|
+
throw new Error("External motion source rig id must be non-blank.");
|
|
150
|
+
if (sourceRig.bones.length === 0)
|
|
151
|
+
throw new Error("External motion source rig has no bones.");
|
|
152
|
+
|
|
153
|
+
const sourceBones: Map<AutoMovieHumanoidBone, IAutoMovieBone> = new Map<
|
|
154
|
+
AutoMovieHumanoidBone,
|
|
155
|
+
IAutoMovieBone
|
|
156
|
+
>();
|
|
157
|
+
for (const bone of sourceRig.bones) {
|
|
158
|
+
if (sourceBones.has(bone.bone))
|
|
159
|
+
throw new Error(
|
|
160
|
+
`External motion source rig duplicates bone "${bone.bone}".`,
|
|
161
|
+
);
|
|
162
|
+
sourceBones.set(bone.bone, bone);
|
|
163
|
+
}
|
|
164
|
+
if (sourceBones.has("hips") === false)
|
|
165
|
+
throw new Error(
|
|
166
|
+
'External motion source rig is missing required bone "hips".',
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
const mapping: IAutoMovieExternalMotionBoneMapping[] = props.decision.mapping;
|
|
170
|
+
if (mapping.length === 0)
|
|
171
|
+
throw new Error("External motion semantic mapping must not be empty.");
|
|
172
|
+
const availableNodes: Map<string, IAutoMovieExternalMotionNodeInspection> =
|
|
173
|
+
new Map<string, IAutoMovieExternalMotionNodeInspection>(
|
|
174
|
+
props.nodes.map(
|
|
175
|
+
(
|
|
176
|
+
node: IAutoMovieExternalMotionNodeInspection,
|
|
177
|
+
): [string, IAutoMovieExternalMotionNodeInspection] => [node.id, node],
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
const nodeToBone: Map<string, AutoMovieHumanoidBone> = new Map<
|
|
181
|
+
string,
|
|
182
|
+
AutoMovieHumanoidBone
|
|
183
|
+
>();
|
|
184
|
+
const mappedBones: Set<AutoMovieHumanoidBone> =
|
|
185
|
+
new Set<AutoMovieHumanoidBone>();
|
|
186
|
+
for (const entry of mapping) {
|
|
187
|
+
if (availableNodes.has(entry.node) === false)
|
|
188
|
+
throw new Error(
|
|
189
|
+
`External motion mapping node "${entry.node}" is not present in the inspected source.`,
|
|
190
|
+
);
|
|
191
|
+
if (sourceBones.has(entry.bone) === false)
|
|
192
|
+
throw new Error(
|
|
193
|
+
`External motion mapping bone "${entry.bone}" is absent from source rig "${sourceRig.id}".`,
|
|
194
|
+
);
|
|
195
|
+
if (nodeToBone.has(entry.node))
|
|
196
|
+
throw new Error(
|
|
197
|
+
`External motion mapping duplicates node "${entry.node}".`,
|
|
198
|
+
);
|
|
199
|
+
if (mappedBones.has(entry.bone))
|
|
200
|
+
throw new Error(
|
|
201
|
+
`External motion mapping duplicates bone "${entry.bone}".`,
|
|
202
|
+
);
|
|
203
|
+
nodeToBone.set(entry.node, entry.bone);
|
|
204
|
+
mappedBones.add(entry.bone);
|
|
205
|
+
}
|
|
206
|
+
for (const track of props.take.tracks) {
|
|
207
|
+
if (track.channel.kind !== "node")
|
|
208
|
+
throw new Error(
|
|
209
|
+
"External motion semantic conversion supports only node tracks.",
|
|
210
|
+
);
|
|
211
|
+
const bone: AutoMovieHumanoidBone | undefined = nodeToBone.get(
|
|
212
|
+
track.channel.node,
|
|
213
|
+
);
|
|
214
|
+
if (bone === undefined)
|
|
215
|
+
throw new Error(
|
|
216
|
+
`External motion track node "${track.channel.node}" has no explicit semantic mapping.`,
|
|
217
|
+
);
|
|
218
|
+
if (track.channel.path === "translation" && bone !== "hips")
|
|
219
|
+
throw new Error(
|
|
220
|
+
`External motion translation for node "${track.channel.node}" must map to hips.`,
|
|
221
|
+
);
|
|
222
|
+
if (track.channel.path === "scale" || track.channel.path === "weights")
|
|
223
|
+
throw new Error(
|
|
224
|
+
`External motion ${track.channel.path} channel for node "${track.channel.node}" is unsupported by humanoid motion conversion.`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
for (const entry of mapping) {
|
|
228
|
+
const bone: IAutoMovieBone = sourceBones.get(entry.bone)!;
|
|
229
|
+
const expected: {
|
|
230
|
+
parent: AutoMovieHumanoidBone | null;
|
|
231
|
+
rest: IAutoMovieTransform;
|
|
232
|
+
} = inspectedBoneBasis(
|
|
233
|
+
availableNodes.get(entry.node)!,
|
|
234
|
+
availableNodes,
|
|
235
|
+
nodeToBone,
|
|
236
|
+
);
|
|
237
|
+
if (bone.parent !== expected.parent)
|
|
238
|
+
throw new Error(
|
|
239
|
+
`External motion source rig bone "${entry.bone}" parent ${JSON.stringify(bone.parent)} does not match inspected parent ${JSON.stringify(expected.parent)}.`,
|
|
240
|
+
);
|
|
241
|
+
assertTransformMatches(entry.bone, bone.rest, expected.rest);
|
|
242
|
+
}
|
|
243
|
+
return {
|
|
244
|
+
sourceRig: cloneSkeleton(sourceRig),
|
|
245
|
+
mapping: mapping
|
|
246
|
+
.map(
|
|
247
|
+
(
|
|
248
|
+
entry: IAutoMovieExternalMotionBoneMapping,
|
|
249
|
+
): IAutoMovieExternalMotionBoneMapping => ({ ...entry }),
|
|
250
|
+
)
|
|
251
|
+
.sort(
|
|
252
|
+
(
|
|
253
|
+
left: IAutoMovieExternalMotionBoneMapping,
|
|
254
|
+
right: IAutoMovieExternalMotionBoneMapping,
|
|
255
|
+
): number => compareCodeUnits(left.node, right.node),
|
|
256
|
+
),
|
|
257
|
+
};
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/** The parent and rest a mapped node implies: walk to the nearest mapped ancestor, then fold every unmapped helper's TRS into the node's own, nearest helper first. A node without a mapped ancestor keeps its local TRS. */
|
|
261
|
+
const inspectedBoneBasis: (
|
|
262
|
+
node: IAutoMovieExternalMotionNodeInspection,
|
|
263
|
+
nodes: Map<string, IAutoMovieExternalMotionNodeInspection>,
|
|
264
|
+
nodeToBone: Map<string, AutoMovieHumanoidBone>,
|
|
265
|
+
) => { parent: AutoMovieHumanoidBone | null; rest: IAutoMovieTransform } = (
|
|
266
|
+
node: IAutoMovieExternalMotionNodeInspection,
|
|
267
|
+
nodes: Map<string, IAutoMovieExternalMotionNodeInspection>,
|
|
268
|
+
nodeToBone: Map<string, AutoMovieHumanoidBone>,
|
|
269
|
+
): { parent: AutoMovieHumanoidBone | null; rest: IAutoMovieTransform } => {
|
|
270
|
+
const helpers: IAutoMovieExternalMotionNodeInspection[] = [];
|
|
271
|
+
let parentId: string | null = node.parent;
|
|
272
|
+
while (parentId !== null) {
|
|
273
|
+
const mappedParent: AutoMovieHumanoidBone | undefined =
|
|
274
|
+
nodeToBone.get(parentId);
|
|
275
|
+
if (mappedParent !== undefined) {
|
|
276
|
+
let rest: IAutoMovieTransform = node.transform;
|
|
277
|
+
for (const helper of helpers)
|
|
278
|
+
rest = composeLocalTransform(helper.transform, rest);
|
|
279
|
+
return { parent: mappedParent, rest };
|
|
280
|
+
}
|
|
281
|
+
const parent: IAutoMovieExternalMotionNodeInspection = nodes.get(parentId)!;
|
|
282
|
+
helpers.push(parent);
|
|
283
|
+
parentId = parent.parent;
|
|
284
|
+
}
|
|
285
|
+
return { parent: null, rest: node.transform };
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
const assertTransformMatches: (
|
|
289
|
+
bone: AutoMovieHumanoidBone,
|
|
290
|
+
actual: IAutoMovieTransform,
|
|
291
|
+
expected: IAutoMovieTransform,
|
|
292
|
+
) => void = (
|
|
293
|
+
bone: AutoMovieHumanoidBone,
|
|
294
|
+
actual: IAutoMovieTransform,
|
|
295
|
+
expected: IAutoMovieTransform,
|
|
296
|
+
): void => {
|
|
297
|
+
const components: Array<[string, number, number]> = [
|
|
298
|
+
["translation.x", actual.translation.x, expected.translation.x],
|
|
299
|
+
["translation.y", actual.translation.y, expected.translation.y],
|
|
300
|
+
["translation.z", actual.translation.z, expected.translation.z],
|
|
301
|
+
["rotation.x", actual.rotation.x, expected.rotation.x],
|
|
302
|
+
["rotation.y", actual.rotation.y, expected.rotation.y],
|
|
303
|
+
["rotation.z", actual.rotation.z, expected.rotation.z],
|
|
304
|
+
["rotation.w", actual.rotation.w, expected.rotation.w],
|
|
305
|
+
["scale.x", actual.scale.x, expected.scale.x],
|
|
306
|
+
["scale.y", actual.scale.y, expected.scale.y],
|
|
307
|
+
["scale.z", actual.scale.z, expected.scale.z],
|
|
308
|
+
];
|
|
309
|
+
for (const [path, value, inspected] of components)
|
|
310
|
+
if (value !== inspected)
|
|
311
|
+
throw new Error(
|
|
312
|
+
`External motion source rig bone "${bone}" rest ${path} ${value} does not match inspected value ${inspected}.`,
|
|
313
|
+
);
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
const validateRetargetDecision: (
|
|
317
|
+
decision: IAutoMovieExternalMotionRetargetDecision,
|
|
318
|
+
) => Pick<
|
|
319
|
+
IAutoMovieExternalMotionRetargetHandoff,
|
|
320
|
+
"target" | "translationScale"
|
|
321
|
+
> = (
|
|
322
|
+
decision: IAutoMovieExternalMotionRetargetDecision,
|
|
323
|
+
): Pick<
|
|
324
|
+
IAutoMovieExternalMotionRetargetHandoff,
|
|
325
|
+
"target" | "translationScale"
|
|
326
|
+
> => {
|
|
327
|
+
if (decision.target.trim().length === 0)
|
|
328
|
+
throw new Error("External motion target identity must be non-blank.");
|
|
329
|
+
if (
|
|
330
|
+
Number.isFinite(decision.translationScale) === false ||
|
|
331
|
+
decision.translationScale <= 0
|
|
332
|
+
)
|
|
333
|
+
throw new Error(
|
|
334
|
+
`External motion translationScale must be finite and positive, but was ${decision.translationScale}.`,
|
|
335
|
+
);
|
|
336
|
+
return {
|
|
337
|
+
target: decision.target,
|
|
338
|
+
translationScale: decision.translationScale,
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const cloneClip: (clip: IAutoMovieClip) => IAutoMovieClip = (
|
|
343
|
+
clip: IAutoMovieClip,
|
|
344
|
+
): IAutoMovieClip => ({
|
|
345
|
+
...clip,
|
|
346
|
+
tracks: clip.tracks.map(
|
|
347
|
+
(track: IAutoMovieTrack): IAutoMovieTrack => ({
|
|
348
|
+
...track,
|
|
349
|
+
channel: { ...track.channel },
|
|
350
|
+
times: [...track.times],
|
|
351
|
+
values: [...track.values],
|
|
352
|
+
}),
|
|
353
|
+
),
|
|
354
|
+
});
|
|
355
|
+
const cloneSkeleton: (skeleton: IAutoMovieSkeleton) => IAutoMovieSkeleton = (
|
|
356
|
+
skeleton: IAutoMovieSkeleton,
|
|
357
|
+
): IAutoMovieSkeleton => ({
|
|
358
|
+
id: skeleton.id,
|
|
359
|
+
bones: skeleton.bones.map(
|
|
360
|
+
(bone: IAutoMovieBone): IAutoMovieBone => ({
|
|
361
|
+
...bone,
|
|
362
|
+
rest: {
|
|
363
|
+
translation: { ...bone.rest.translation },
|
|
364
|
+
rotation: { ...bone.rest.rotation },
|
|
365
|
+
scale: { ...bone.rest.scale },
|
|
366
|
+
},
|
|
367
|
+
constraint:
|
|
368
|
+
bone.constraint === null
|
|
369
|
+
? null
|
|
370
|
+
: {
|
|
371
|
+
...bone.constraint,
|
|
372
|
+
flexion:
|
|
373
|
+
bone.constraint.flexion === null
|
|
374
|
+
? null
|
|
375
|
+
: { ...bone.constraint.flexion },
|
|
376
|
+
abduction:
|
|
377
|
+
bone.constraint.abduction === null
|
|
378
|
+
? null
|
|
379
|
+
: { ...bone.constraint.abduction },
|
|
380
|
+
twist:
|
|
381
|
+
bone.constraint.twist === null
|
|
382
|
+
? null
|
|
383
|
+
: { ...bone.constraint.twist },
|
|
384
|
+
},
|
|
385
|
+
}),
|
|
386
|
+
),
|
|
387
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { IAutoMovieProductionAudioProcessing } from "./IAutoMovieProductionAudioProcessing";
|
|
2
|
+
import type { IAutoMovieProductionWaveSourceFormat } from "./IAutoMovieProductionWaveSourceFormat";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One decoded WAVE source: its declared facts, the processing applied, and mono samples available to a caller's mixer.
|
|
6
|
+
*
|
|
7
|
+
* The `source*` facts and `durationSeconds` describe the file before downmix and resampling, because a render plan records them as the asset's identity; only `samples` and `processing` describe the output. Reporting the output as the source would let a resampled asset claim the plan's rate and hide a duration disagreement.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/development/design.md#principled-representation Source envelope facts, processing lineage and sample storage remain separate so consumers can compare declared source/output relationships. The Float32Array carries no rate metadata and this record cannot independently prove that its samples were generated at the declared rate.
|
|
10
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface Source facts, processing and samples are three named parts of one decoder result instead of separate return paths, and the render package reuses the two nested types as its wave identity.
|
|
11
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts The decoder fills repeated source fields and `sourceFormat` from the same parsed values; this structural type neither correlates independently supplied records nor authenticates mutable sample bytes.
|
|
12
|
+
* @evidence contracts/development/common.md#meaningful-documentation The comments state which fields describe the file and which the output, the units of rate and duration, and that samples are finite mono values at the requested rate.
|
|
13
|
+
*/
|
|
14
|
+
export interface IAutoMovieDecodedProductionAudioAsset {
|
|
15
|
+
/** Source rate in samples per second, before resampling. */
|
|
16
|
+
sourceSampleRate: number;
|
|
17
|
+
|
|
18
|
+
/** Source channel count, 1 or 2, before the mono downmix. */
|
|
19
|
+
sourceChannels: number;
|
|
20
|
+
|
|
21
|
+
/** Number of complete sample frames in the source `data` chunk. */
|
|
22
|
+
sourceFrames: number;
|
|
23
|
+
|
|
24
|
+
/** Source runtime in seconds, `sourceFrames / sourceSampleRate`. */
|
|
25
|
+
durationSeconds: number;
|
|
26
|
+
|
|
27
|
+
/** The file's own format declaration as parsed. */
|
|
28
|
+
sourceFormat: IAutoMovieProductionWaveSourceFormat;
|
|
29
|
+
|
|
30
|
+
/** The downmix and resampling applied to produce `samples`. */
|
|
31
|
+
processing: IAutoMovieProductionAudioProcessing;
|
|
32
|
+
|
|
33
|
+
/** Finite mono samples in [-1, 1] for PCM sources at `processing.outputSampleRate`; a new buffer the caller owns. */
|
|
34
|
+
samples: Float32Array;
|
|
35
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The deterministic conversion `decodeProductionAudioAsset` applied to turn a WAVE source into mono mixer input, recorded so a render plan can check it against the source format it claims.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/design.md#principled-representation Stage kind, downmix coefficients and requested output rate let the render identity validator compare declared processing with source channels and rate; the record does not prove sample contents or specify a general resampling algorithm independently of the decoder.
|
|
5
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface One flat record names the stage combination and its parameters; the render package's wave identity validator reads these four fields and nothing else.
|
|
6
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts Literal channel and stage vocabulary constrain names, but independent fields and numeric arrays do not enforce stage/rate/matrix correlation; the decoder produces those relations and the render wave-identity validator checks them.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation The comments give the stage order, the output channel and rate meaning, and the row-by-column orientation and only values of the downmix matrix.
|
|
8
|
+
*/
|
|
9
|
+
export interface IAutoMovieProductionAudioProcessing {
|
|
10
|
+
/** Stages applied, in source order: `copy` for mono at the target rate, `downmix` for stereo at the target rate, `resample` for mono at another rate, and `downmix-resample` for stereo at another rate. */
|
|
11
|
+
kind: "copy" | "downmix" | "resample" | "downmix-resample";
|
|
12
|
+
|
|
13
|
+
/** Mixer-facing channel count; the decoder always folds to mono. */
|
|
14
|
+
outputChannels: 1;
|
|
15
|
+
|
|
16
|
+
/** Output rate in samples per second, the rate the caller requested. */
|
|
17
|
+
outputSampleRate: number;
|
|
18
|
+
|
|
19
|
+
/** Downmix coefficients with one row per output channel and one column per source channel: `[[1]]` for mono and `[[0.5, 0.5]]` for stereo. */
|
|
20
|
+
matrix: readonly (readonly number[])[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exact supported WAVE declaration before processing.
|
|
3
|
+
*
|
|
4
|
+
* These are the file's own facts, read from its format envelope and never inferred from its channel count: an extensible header names its speakers through `dwChannelMask` and its encoding through the full SubFormat GUID, while a legacy header carries the default mono front-center or stereo front-left/front-right semantics and says so in `layout.source`. The literal unions are the decoder's whole supported subset, so a value outside them was refused rather than recorded.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/design.md#principled-representation Each field mirrors a WAVEFORMATEX or WAVEFORMATEXTENSIBLE field the decoder reads, with the layout source and mask recording whether the speakers came from `dwChannelMask` or from the legacy default.
|
|
7
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface One record keeps the envelope facts apart from the processing lineage, which lets the render plan validate a source identity separately from the conversion applied to it.
|
|
8
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts Closed unions constrain each vocabulary independently, while numeric ranges and encoding/precision/channel/layout/GUID relations remain producer invariants checked by the decoder and render wave-identity validator, not guarantees of this erased type.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation The comments state where each fact comes from, which header spelling sets the mask and GUID, and that the literal unions are the supported subset.
|
|
10
|
+
*/
|
|
11
|
+
export interface IAutoMovieProductionWaveSourceFormat {
|
|
12
|
+
/** Media-family discriminant; WAVE is the only decoded family. */
|
|
13
|
+
kind: "wave";
|
|
14
|
+
|
|
15
|
+
/** Format-envelope spelling: `wave-format-ex` for a legacy tag, or `wave-format-extensible` for tag `0xFFFE` with a cbSize of at least 22. */
|
|
16
|
+
header: "wave-format-ex" | "wave-format-extensible";
|
|
17
|
+
|
|
18
|
+
/** Sample encoding: little-endian signed 16-bit PCM or 32-bit IEEE float. */
|
|
19
|
+
encoding: "pcm-s16le" | "float-f32le";
|
|
20
|
+
|
|
21
|
+
/** Bits each encoded channel sample occupies (`wBitsPerSample`). */
|
|
22
|
+
containerBits: 16 | 32;
|
|
23
|
+
|
|
24
|
+
/** Meaningful bits inside the container; `wValidBitsPerSample` for an extensible header, otherwise the container size. Always equal to `containerBits`, since partial precision is refused. */
|
|
25
|
+
validBits: 16 | 32;
|
|
26
|
+
|
|
27
|
+
/** Source rate in samples per second, before any resampling. */
|
|
28
|
+
sampleRate: number;
|
|
29
|
+
|
|
30
|
+
/** Source channel count, before the mono downmix. */
|
|
31
|
+
channels: 1 | 2;
|
|
32
|
+
|
|
33
|
+
/** Ordered speaker semantics and where they were declared. */
|
|
34
|
+
layout: {
|
|
35
|
+
/** Mono or stereo, matching `channels`. */
|
|
36
|
+
kind: "mono" | "stereo";
|
|
37
|
+
|
|
38
|
+
/** Speakers in channel order. */
|
|
39
|
+
speakers: ["front-center"] | ["front-left", "front-right"];
|
|
40
|
+
|
|
41
|
+
/** `channel-mask` when an extensible header declared the speakers, `legacy-default` when a legacy header implied them. */
|
|
42
|
+
source: "legacy-default" | "channel-mask";
|
|
43
|
+
|
|
44
|
+
/** The declared `dwChannelMask` (`0x4` mono, `0x3` stereo), or `null` for a legacy header, which has none. */
|
|
45
|
+
mask: number | null;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Lowercase canonical SubFormat GUID text of an extensible header, or `null` for a legacy header, which has none. */
|
|
49
|
+
subFormatGuid: string | null;
|
|
50
|
+
}
|