@automovie/ingest 0.0.0-stage → 0.0.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,15 @@
|
|
|
1
|
+
import type { AutoMovieHumanoidBone } from "@automovie/interface";
|
|
2
|
+
/**
|
|
3
|
+
* One normalized humanoid slot referencing an inspected glTF node index.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/development/design.md#principled-representation The semantic slot union and zero-based node index join metadata conventions to the same admitted node inventory.
|
|
6
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface One compact relation is shared by glTF name mapping and explicit VRM declarations.
|
|
7
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts A slot declaration does not establish positive skin weight; the separate coverage pass supplies that fact.
|
|
8
|
+
* @evidence contracts/development/common.md#meaningful-documentation Member comments identify normalized semantic meaning and index provenance, excluding weight certification.
|
|
9
|
+
*/
|
|
10
|
+
export interface IHumanoidSlot {
|
|
11
|
+
/** Normalized humanoid semantic slot declared or resolved by the current profile. */
|
|
12
|
+
bone: AutoMovieHumanoidBone;
|
|
13
|
+
/** Zero-based node index admitted against the current source document inventory. */
|
|
14
|
+
node: number;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IHumanoidSlot.js","sourceRoot":"","sources":["../../src/internal/IHumanoidSlot.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One decoded glTF/GLB container with parsed JSON and optional borrowed BIN view.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/design.md#principled-representation JSON owns parsed values while the optional BIN aliases the validated resident GLB chunk.
|
|
5
|
+
* @evidence contracts/development/design.md#minimal-and-owned-surface One framing result separates logical document facts from binary bytes before structural admission.
|
|
6
|
+
* @evidence contracts/development/design.md#prohibited-design-shortcuts A suffix-provided VRM label does not certify VRM metadata; the humanoid profile checks it separately.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation Members describe parsed JSON, container family and read-only optional BIN aliasing.
|
|
8
|
+
*/
|
|
9
|
+
export interface IParsedContainer {
|
|
10
|
+
/** Strictly parsed JSON document awaiting structural/profile admission. */
|
|
11
|
+
json: unknown;
|
|
12
|
+
/** Container family selected from the supported path suffix; metadata is checked separately. */
|
|
13
|
+
format: "gltf" | "glb" | "vrm";
|
|
14
|
+
/** Read-only view of the optional validated GLB BIN chunk, or null for absent binary payload. */
|
|
15
|
+
bin: Uint8Array | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IParsedContainer.js","sourceRoot":"","sources":["../../src/internal/IParsedContainer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component counts of glTF scalar, vector and matrix accessor shapes.
|
|
3
|
+
*
|
|
4
|
+
* The fixed glTF shape vocabulary defines scalar/vector width and square-matrix component counts used after shape admission. Dense ranges, motion arity and element sizing share this fixed seven-entry table; logical matrix counts do not replace physical column-padding rules.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SHAPE_COMPONENTS: Readonly<Record<string, number>>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHAPE_COMPONENTS = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Component counts of glTF scalar, vector and matrix accessor shapes.
|
|
6
|
+
*
|
|
7
|
+
* The fixed glTF shape vocabulary defines scalar/vector width and square-matrix component counts used after shape admission. Dense ranges, motion arity and element sizing share this fixed seven-entry table; logical matrix counts do not replace physical column-padding rules.
|
|
8
|
+
*/
|
|
9
|
+
exports.SHAPE_COMPONENTS = {
|
|
10
|
+
/** One logical scalar component. */
|
|
11
|
+
SCALAR: 1,
|
|
12
|
+
/** Two logical vector components. */
|
|
13
|
+
VEC2: 2,
|
|
14
|
+
/** Three logical vector components. */
|
|
15
|
+
VEC3: 3,
|
|
16
|
+
/** Four logical vector components. */
|
|
17
|
+
VEC4: 4,
|
|
18
|
+
/** Four logical matrix components, independent of byte-column padding. */
|
|
19
|
+
MAT2: 4,
|
|
20
|
+
/** Nine logical matrix components, independent of byte-column padding. */
|
|
21
|
+
MAT3: 9,
|
|
22
|
+
/** Sixteen logical matrix components. */
|
|
23
|
+
MAT4: 16,
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=SHAPE_COMPONENTS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SHAPE_COMPONENTS.js","sourceRoot":"","sources":["../../src/internal/SHAPE_COMPONENTS.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,gBAAgB,GAAqC;IAChE,oCAAoC;IACpC,MAAM,EAAE,CAAC;IAET,qCAAqC;IACrC,IAAI,EAAE,CAAC;IAEP,uCAAuC;IACvC,IAAI,EAAE,CAAC;IAEP,sCAAsC;IACtC,IAAI,EAAE,CAAC;IAEP,0EAA0E;IAC1E,IAAI,EAAE,CAAC;IAEP,0EAA0E;IAC1E,IAAI,EAAE,CAAC;IAEP,yCAAyC;IACzC,IAAI,EAAE,EAAE;CACT,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute glTF accessor element storage including matrix-column padding.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/implementation.md#principled-implementation Component byte width and logical shape count define dense size; MAT2/MAT3 narrow components pad each column to four bytes.
|
|
5
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One sizing owner serves dense, sparse and reader stride defaults so storage alignment rules have one representation.
|
|
6
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Padded matrix cases are glTF layout contracts rather than fixture corrections; shape/type admission is a required caller premise.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose distinguishes logical component count from physical bytes and names the column-alignment cases.
|
|
8
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Fixed shape lookup and at most three padding branches require constant time without reading elements.
|
|
9
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All accessor consumers reuse equivalent storage sizing from the same two fixed vocabulary tables.
|
|
10
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The function owns no arrays, byte views or retained state and returns one scalar size.
|
|
11
|
+
*/
|
|
12
|
+
export declare const accessorElementByteLength: (componentType: number, shape: string) => number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.accessorElementByteLength = void 0;
|
|
4
|
+
const COMPONENT_BYTES_1 = require("./COMPONENT_BYTES");
|
|
5
|
+
const SHAPE_COMPONENTS_1 = require("./SHAPE_COMPONENTS");
|
|
6
|
+
/**
|
|
7
|
+
* Compute glTF accessor element storage including matrix-column padding.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/development/implementation.md#principled-implementation Component byte width and logical shape count define dense size; MAT2/MAT3 narrow components pad each column to four bytes.
|
|
10
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One sizing owner serves dense, sparse and reader stride defaults so storage alignment rules have one representation.
|
|
11
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Padded matrix cases are glTF layout contracts rather than fixture corrections; shape/type admission is a required caller premise.
|
|
12
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose distinguishes logical component count from physical bytes and names the column-alignment cases.
|
|
13
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Fixed shape lookup and at most three padding branches require constant time without reading elements.
|
|
14
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All accessor consumers reuse equivalent storage sizing from the same two fixed vocabulary tables.
|
|
15
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The function owns no arrays, byte views or retained state and returns one scalar size.
|
|
16
|
+
*/
|
|
17
|
+
const accessorElementByteLength = (componentType, shape) => {
|
|
18
|
+
const component = COMPONENT_BYTES_1.COMPONENT_BYTES.get(componentType);
|
|
19
|
+
if (shape === "MAT2" && component === 1)
|
|
20
|
+
return 8;
|
|
21
|
+
if (shape === "MAT3" && component === 1)
|
|
22
|
+
return 12;
|
|
23
|
+
if (shape === "MAT3" && component === 2)
|
|
24
|
+
return 24;
|
|
25
|
+
return component * SHAPE_COMPONENTS_1.SHAPE_COMPONENTS[shape];
|
|
26
|
+
};
|
|
27
|
+
exports.accessorElementByteLength = accessorElementByteLength;
|
|
28
|
+
//# sourceMappingURL=accessorElementByteLength.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessorElementByteLength.js","sourceRoot":"","sources":["../../src/internal/accessorElementByteLength.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,yDAAsD;AAEtD;;;;;;;;;;GAUG;AACI,MAAM,yBAAyB,GAGxB,CAAC,aAAqB,EAAE,KAAa,EAAU,EAAE;IAC7D,MAAM,SAAS,GAAW,iCAAe,CAAC,GAAG,CAAC,aAAa,CAAE,CAAC;IAC9D,IAAI,KAAK,KAAK,MAAM,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAClD,IAAI,KAAK,KAAK,MAAM,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,IAAI,KAAK,KAAK,MAAM,IAAI,SAAS,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACnD,OAAO,SAAS,GAAG,mCAAgB,CAAC,KAAK,CAAE,CAAC;AAC9C,CAAC,CAAC;AATW,QAAA,yBAAyB,GAAzB,yBAAyB,CASpC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IAccessorSource } from "./IAccessorSource";
|
|
2
|
+
import type { IExternalModelAccessorReader } from "./IExternalModelAccessorReader";
|
|
3
|
+
/**
|
|
4
|
+
* Resolve one admitted accessor's resident component reader.
|
|
5
|
+
*
|
|
6
|
+
* The caller has already checked buffer indices, dense ranges and vector/scalar layout. Sparse storage and formats other than unsigned byte, unsigned short or FLOAT throw with the supplied role. Element and component indices are caller-owned bounds; the closure borrows the payload and decodes little-endian components, scaling normalized integers by 255 or 65535.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/development/implementation.md#principled-implementation Validated offsets/stride and unsigned byte/short or FLOAT formats define little-endian reads; normalized integers scale by their exact maximum.
|
|
9
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One closure owns DataView and addressing, shared by weight coverage and motion FLOAT decoding.
|
|
10
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Sparse overrides and unsupported component formats throw instead of being treated as dense data of another type.
|
|
11
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments give admitted formats, normalized scaling, element/component arguments and borrowed payload lifetime.
|
|
12
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Reader setup is constant time; each requested component costs one address calculation and one scalar DataView read.
|
|
13
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work One resolved view/stride/DataView serves every component of this accessor, avoiding repeated metadata resolution.
|
|
14
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned closure borrows one payload until its owning profile finishes; it retains no global reader cache or handle.
|
|
15
|
+
*/
|
|
16
|
+
export declare const accessorReader: (source: IAccessorSource, accessorIndex: number, role: string) => IExternalModelAccessorReader;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.accessorReader = void 0;
|
|
4
|
+
const COMPONENT_BYTES_1 = require("./COMPONENT_BYTES");
|
|
5
|
+
const accessorElementByteLength_1 = require("./accessorElementByteLength");
|
|
6
|
+
const object_1 = require("./object");
|
|
7
|
+
/**
|
|
8
|
+
* Resolve one admitted accessor's resident component reader.
|
|
9
|
+
*
|
|
10
|
+
* The caller has already checked buffer indices, dense ranges and vector/scalar layout. Sparse storage and formats other than unsigned byte, unsigned short or FLOAT throw with the supplied role. Element and component indices are caller-owned bounds; the closure borrows the payload and decodes little-endian components, scaling normalized integers by 255 or 65535.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/development/implementation.md#principled-implementation Validated offsets/stride and unsigned byte/short or FLOAT formats define little-endian reads; normalized integers scale by their exact maximum.
|
|
13
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One closure owns DataView and addressing, shared by weight coverage and motion FLOAT decoding.
|
|
14
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Sparse overrides and unsupported component formats throw instead of being treated as dense data of another type.
|
|
15
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments give admitted formats, normalized scaling, element/component arguments and borrowed payload lifetime.
|
|
16
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Reader setup is constant time; each requested component costs one address calculation and one scalar DataView read.
|
|
17
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work One resolved view/stride/DataView serves every component of this accessor, avoiding repeated metadata resolution.
|
|
18
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The returned closure borrows one payload until its owning profile finishes; it retains no global reader cache or handle.
|
|
19
|
+
*/
|
|
20
|
+
const accessorReader = (source, accessorIndex, role) => {
|
|
21
|
+
const accessor = (0, object_1.object)(source.accessors[accessorIndex], `accessors[${accessorIndex}]`);
|
|
22
|
+
if (accessor.sparse !== undefined)
|
|
23
|
+
throw new Error(`${role} may not use sparse overrides at the production ingest boundary.`);
|
|
24
|
+
const viewIndex = accessor.bufferView;
|
|
25
|
+
const bufferView = (0, object_1.object)(source.bufferViews[viewIndex], `bufferViews[${viewIndex}]`);
|
|
26
|
+
const type = accessor.componentType;
|
|
27
|
+
if (type !== 5121 && type !== 5123 && type !== 5126)
|
|
28
|
+
throw new Error(`${role} uses componentType ${type}, which this profile does not read.`);
|
|
29
|
+
const size = COMPONENT_BYTES_1.COMPONENT_BYTES.get(type);
|
|
30
|
+
const stride = bufferView.byteStride ??
|
|
31
|
+
(0, accessorElementByteLength_1.accessorElementByteLength)(type, accessor.type);
|
|
32
|
+
const base = (bufferView.byteOffset ?? 0) +
|
|
33
|
+
(accessor.byteOffset ?? 0);
|
|
34
|
+
const bytes = source.payloads[bufferView.buffer];
|
|
35
|
+
const data = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
36
|
+
const scale = accessor.normalized === true && type !== 5126
|
|
37
|
+
? type === 5121
|
|
38
|
+
? 1 / 255
|
|
39
|
+
: 1 / 65535
|
|
40
|
+
: 1;
|
|
41
|
+
return (element, component) => {
|
|
42
|
+
const offset = base + element * stride + component * size;
|
|
43
|
+
const value = type === 5121
|
|
44
|
+
? data.getUint8(offset)
|
|
45
|
+
: type === 5123
|
|
46
|
+
? data.getUint16(offset, true)
|
|
47
|
+
: data.getFloat32(offset, true);
|
|
48
|
+
return scale === 1 ? value : value * scale;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
exports.accessorReader = accessorReader;
|
|
52
|
+
//# sourceMappingURL=accessorReader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessorReader.js","sourceRoot":"","sources":["../../src/internal/accessorReader.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AAGpD,2EAAwE;AACxE,qCAAkC;AAElC;;;;;;;;;;;;GAYG;AACI,MAAM,cAAc,GAIS,CAClC,MAAuB,EACvB,aAAqB,EACrB,IAAY,EACkB,EAAE;IAChC,MAAM,QAAQ,GAA4B,IAAA,eAAM,EAC9C,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,EAC/B,aAAa,aAAa,GAAG,CAC9B,CAAC;IACF,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;QAC/B,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,kEAAkE,CAC1E,CAAC;IACJ,MAAM,SAAS,GAAW,QAAQ,CAAC,UAAoB,CAAC;IACxD,MAAM,UAAU,GAA4B,IAAA,eAAM,EAChD,MAAM,CAAC,WAAW,CAAC,SAAS,CAAC,EAC7B,eAAe,SAAS,GAAG,CAC5B,CAAC;IACF,MAAM,IAAI,GAAW,QAAQ,CAAC,aAAuB,CAAC;IACtD,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI;QACjD,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,uBAAuB,IAAI,qCAAqC,CACxE,CAAC;IACJ,MAAM,IAAI,GAAW,iCAAe,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC;IAChD,MAAM,MAAM,GACT,UAAU,CAAC,UAAiC;QAC7C,IAAA,qDAAyB,EAAC,IAAI,EAAE,QA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3
|
+
* Read a parsed glTF accessor as plain numbers in the values it means.
|
|
4
|
+
*
|
|
5
|
+
* A normalized integer accessor stores `round(value * max)`, which glTF allows for animation outputs (rotation and weights) and, under `KHR_mesh_quantization`, for positions and morph deltas. Copying its raw array would hand consumers 32767 where the file means 1, so such an accessor is decoded element by element through `Accessor.getElement`, which applies glTF's decoding (`max(c / max, -1)` for signed and `c / max` for unsigned components). Every other accessor, including non-normalized quantized integers whose scale lives in the node transform, is copied verbatim.
|
|
6
|
+
*
|
|
7
|
+
* @param accessor Accessor whose data is resident in the parsed document.
|
|
8
|
+
* @returns A new flat array in element order, or `null` when the accessor holds no array data; the caller supplies a valid accessor layout.
|
|
9
|
+
*
|
|
10
|
+
* @evidence contracts/development/implementation.md#principled-implementation glTF defines normalized integer decoding per component type, and `Accessor.getElement` applies exactly that, so the helper delegates normalized accessors to it and copies any other accessor verbatim with `Array.from`.
|
|
11
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One helper serves node animation import and face template import, the two places that copy accessor data into plain number arrays.
|
|
12
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Non-normalized quantized integers are deliberately copied raw because their scale lives in the node transform, and no component type is special-cased beyond glTF's own normalization flag.
|
|
13
|
+
* @evidence contracts/development/common.md#meaningful-documentation The documentation states which accessors glTF lets be normalized, the decoding formulas, the raw-copy case and its reason, the result layout, and what `null` means.
|
|
14
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Linear in count times element size, with one plain-number result array and one reused element buffer for normalized data; Array.from copies the resident typed array into plain numbers for the non-normalized path.
|
|
15
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call creates an independent array; shared animation samplers are deliberately read again per track, and mutable Document data prevents a retained cache without a caller-owned invalidation contract.
|
|
16
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The element buffer is released on return; the result array, proportional to the accessor's component count, is owned by the caller and nothing is retained by the helper.
|
|
17
|
+
*/
|
|
18
|
+
export declare const accessorValues: (accessor: Accessor) => number[] | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.accessorValues = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Read a parsed glTF accessor as plain numbers in the values it means.
|
|
6
|
+
*
|
|
7
|
+
* A normalized integer accessor stores `round(value * max)`, which glTF allows for animation outputs (rotation and weights) and, under `KHR_mesh_quantization`, for positions and morph deltas. Copying its raw array would hand consumers 32767 where the file means 1, so such an accessor is decoded element by element through `Accessor.getElement`, which applies glTF's decoding (`max(c / max, -1)` for signed and `c / max` for unsigned components). Every other accessor, including non-normalized quantized integers whose scale lives in the node transform, is copied verbatim.
|
|
8
|
+
*
|
|
9
|
+
* @param accessor Accessor whose data is resident in the parsed document.
|
|
10
|
+
* @returns A new flat array in element order, or `null` when the accessor holds no array data; the caller supplies a valid accessor layout.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/development/implementation.md#principled-implementation glTF defines normalized integer decoding per component type, and `Accessor.getElement` applies exactly that, so the helper delegates normalized accessors to it and copies any other accessor verbatim with `Array.from`.
|
|
13
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One helper serves node animation import and face template import, the two places that copy accessor data into plain number arrays.
|
|
14
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Non-normalized quantized integers are deliberately copied raw because their scale lives in the node transform, and no component type is special-cased beyond glTF's own normalization flag.
|
|
15
|
+
* @evidence contracts/development/common.md#meaningful-documentation The documentation states which accessors glTF lets be normalized, the decoding formulas, the raw-copy case and its reason, the result layout, and what `null` means.
|
|
16
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Linear in count times element size, with one plain-number result array and one reused element buffer for normalized data; Array.from copies the resident typed array into plain numbers for the non-normalized path.
|
|
17
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Each call creates an independent array; shared animation samplers are deliberately read again per track, and mutable Document data prevents a retained cache without a caller-owned invalidation contract.
|
|
18
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The element buffer is released on return; the result array, proportional to the accessor's component count, is owned by the caller and nothing is retained by the helper.
|
|
19
|
+
*/
|
|
20
|
+
const accessorValues = (accessor) => {
|
|
21
|
+
const array = accessor.getArray();
|
|
22
|
+
if (array === null)
|
|
23
|
+
return null;
|
|
24
|
+
if (accessor.getNormalized() === false)
|
|
25
|
+
return Array.from(array);
|
|
26
|
+
const width = accessor.getElementSize();
|
|
27
|
+
const count = accessor.getCount();
|
|
28
|
+
const values = new Array(count * width);
|
|
29
|
+
const element = new Array(width);
|
|
30
|
+
for (let index = 0; index < count; ++index) {
|
|
31
|
+
accessor.getElement(index, element);
|
|
32
|
+
for (let component = 0; component < width; ++component)
|
|
33
|
+
values[index * width + component] = element[component];
|
|
34
|
+
}
|
|
35
|
+
return values;
|
|
36
|
+
};
|
|
37
|
+
exports.accessorValues = accessorValues;
|
|
38
|
+
//# sourceMappingURL=accessorValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessorValues.js","sourceRoot":"","sources":["../../src/internal/accessorValues.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;GAeG;AACI,MAAM,cAAc,GAA4C,CACrE,QAAkB,EACD,EAAE;IACnB,MAAM,KAAK,GAAqC,QAAQ,CAAC,QAAQ,EAAE,CAAC;IACpE,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,QAAQ,CAAC,aAAa,EAAE,KAAK,KAAK;QAAE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACjE,MAAM,KAAK,GAAW,QAAQ,CAAC,cAAc,EAAE,CAAC;IAChD,MAAM,KAAK,GAAW,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAa,IAAI,KAAK,CAAS,KAAK,GAAG,KAAK,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAa,IAAI,KAAK,CAAS,KAAK,CAAC,CAAC;IACnD,KAAK,IAAI,KAAK,GAAW,CAAC,EAAE,KAAK,GAAG,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC;QACnD,QAAQ,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACpC,KAAK,IAAI,SAAS,GAAW,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,SAAS;YAC5D,MAAM,CAAC,KAAK,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAE,CAAC;IAC5D,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAhBW,QAAA,cAAc,GAAd,cAAc,CAgBzB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IAutoMovieExternalModelResource } from "../IAutoMovieExternalModelResource";
|
|
2
|
+
/**
|
|
3
|
+
* Collect exact sidecar URI identities without decoding their payloads.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/development/implementation.md#principled-implementation Buffers preserve declared byte lengths; images carry null lengths, while repeated URIs must agree on role and buffer extent.
|
|
6
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One URI-keyed map owns conflict detection and deterministic resource ordering shared by every ingest profile.
|
|
7
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Data URIs are excluded, conflicting roles/lengths throw, and URI spelling is preserved rather than normalized into aliases.
|
|
8
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose identifies exact URI ownership, buffer/image length meaning, conflict behavior and code-unit ordering.
|
|
9
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms B buffers and I images cause B+I expected map operations over exact URI strings; U distinct resources require O(U log U) comparisons, each scanning at most the compared shared prefix, with string identity/hash work dependent on URI text.
|
|
10
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work One map coordinates exact URI conflict checks and the final unique inventory; repeated declarations replace their scalar row, while byte resolution remains a separate effectful payload owner.
|
|
11
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Only U scalar resource records survive in the result; the temporary map retains no resident sidecar bytes.
|
|
12
|
+
*/
|
|
13
|
+
export declare const collectExternalResources: (buffers: unknown[], images: unknown[]) => IAutoMovieExternalModelResource[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectExternalResources = void 0;
|
|
4
|
+
const compareCodeUnits_1 = require("./compareCodeUnits");
|
|
5
|
+
const object_1 = require("./object");
|
|
6
|
+
const externalUri = (value, path) => {
|
|
7
|
+
if (value === undefined)
|
|
8
|
+
return null;
|
|
9
|
+
if (typeof value !== "string" || value.length === 0)
|
|
10
|
+
throw new Error(`${path} must be a non-empty URI string.`);
|
|
11
|
+
return value.startsWith("data:") ? null : value;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Collect exact sidecar URI identities without decoding their payloads.
|
|
15
|
+
*
|
|
16
|
+
* @evidence contracts/development/implementation.md#principled-implementation Buffers preserve declared byte lengths; images carry null lengths, while repeated URIs must agree on role and buffer extent.
|
|
17
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One URI-keyed map owns conflict detection and deterministic resource ordering shared by every ingest profile.
|
|
18
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Data URIs are excluded, conflicting roles/lengths throw, and URI spelling is preserved rather than normalized into aliases.
|
|
19
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose identifies exact URI ownership, buffer/image length meaning, conflict behavior and code-unit ordering.
|
|
20
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms B buffers and I images cause B+I expected map operations over exact URI strings; U distinct resources require O(U log U) comparisons, each scanning at most the compared shared prefix, with string identity/hash work dependent on URI text.
|
|
21
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work One map coordinates exact URI conflict checks and the final unique inventory; repeated declarations replace their scalar row, while byte resolution remains a separate effectful payload owner.
|
|
22
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Only U scalar resource records survive in the result; the temporary map retains no resident sidecar bytes.
|
|
23
|
+
*/
|
|
24
|
+
const collectExternalResources = (buffers, images) => {
|
|
25
|
+
const byUri = new Map();
|
|
26
|
+
buffers.forEach((value, index) => {
|
|
27
|
+
const buffer = (0, object_1.object)(value, `buffers[${index}]`);
|
|
28
|
+
const uri = externalUri(buffer.uri, `buffers[${index}].uri`);
|
|
29
|
+
if (uri === null)
|
|
30
|
+
return;
|
|
31
|
+
const byteLength = buffer.byteLength;
|
|
32
|
+
const prior = byUri.get(uri);
|
|
33
|
+
if (prior !== undefined &&
|
|
34
|
+
(prior.kind !== "buffer" || prior.byteLength !== byteLength))
|
|
35
|
+
throw new Error(`External URI "${uri}" is declared with conflicting resource roles or lengths.`);
|
|
36
|
+
byUri.set(uri, { uri, kind: "buffer", byteLength });
|
|
37
|
+
});
|
|
38
|
+
images.forEach((value, index) => {
|
|
39
|
+
const image = (0, object_1.object)(value, `images[${index}]`);
|
|
40
|
+
const uri = externalUri(image.uri, `images[${index}].uri`);
|
|
41
|
+
if (uri === null)
|
|
42
|
+
return;
|
|
43
|
+
const prior = byUri.get(uri);
|
|
44
|
+
if (prior !== undefined && prior.kind !== "image")
|
|
45
|
+
throw new Error(`External URI "${uri}" is declared as both a buffer and an image.`);
|
|
46
|
+
byUri.set(uri, { uri, kind: "image", byteLength: null });
|
|
47
|
+
});
|
|
48
|
+
return [...byUri.values()].sort((left, right) => (0, compareCodeUnits_1.compareCodeUnits)(left.uri, right.uri));
|
|
49
|
+
};
|
|
50
|
+
exports.collectExternalResources = collectExternalResources;
|
|
51
|
+
//# sourceMappingURL=collectExternalResources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collectExternalResources.js","sourceRoot":"","sources":["../../src/internal/collectExternalResources.ts"],"names":[],"mappings":";;;AACA,yDAAsD;AACtD,qCAAkC;AAElC,MAAM,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OAAO,CAAC,CAAC,KAAc,EAAE,KAAa,EAAQ,EAAE;QACrD,MAAM,KAAK,GAA4B,IAAA,eAAM,EAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC,CAAC;QACzE,MAAM,GAAG,GAAkB,WAAW,CAAC,KAAK,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC,CAAC;QAC1E,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO;QACzB,MAAM,KAAK,GAAgD,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC1E,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,KAAK,OAAO;YAC/C,MAAM,IAAI,KAAK,CACb,iBAAiB,GAAG,8CAA8C,CACnE,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAC7B,CACE,IAAqC,EACrC,KAAsC,EAC9B,EAAE,CAAC,IAAA,mCAAgB,EAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,CACnD,CAAC;AACJ,CAAC,CAAC;AA3CW,QAAA,wBAAwB,GAAxB,wBAAwB,CA2CnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compare two exact strings in deterministic JavaScript code-unit order.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/implementation.md#principled-implementation Relational string comparison produces negative, zero or positive ordering without locale-dependent collation.
|
|
5
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One shared comparator serves canonical resource, extension and semantic-mapping inventories.
|
|
6
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No locale, case folding or numeric-suffix convention changes identifier identity.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation The description defines exact code-unit order and equality semantics for canonical sorting.
|
|
8
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Comparison scans at most the shared prefix length with constant extra space.
|
|
9
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All ingest inventory sorts reuse the same ordering rule rather than different locale comparators.
|
|
10
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The comparator allocates no retained arrays, collation handles or comparison cache.
|
|
11
|
+
*/
|
|
12
|
+
export declare const compareCodeUnits: (left: string, right: string) => number;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareCodeUnits = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compare two exact strings in deterministic JavaScript code-unit order.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation Relational string comparison produces negative, zero or positive ordering without locale-dependent collation.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One shared comparator serves canonical resource, extension and semantic-mapping inventories.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts No locale, case folding or numeric-suffix convention changes identifier identity.
|
|
10
|
+
* @evidence contracts/development/common.md#meaningful-documentation The description defines exact code-unit order and equality semantics for canonical sorting.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Comparison scans at most the shared prefix length with constant extra space.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All ingest inventory sorts reuse the same ordering rule rather than different locale comparators.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The comparator allocates no retained arrays, collation handles or comparison cache.
|
|
14
|
+
*/
|
|
15
|
+
const compareCodeUnits = (left, right) => Number(left > right) - Number(left < right);
|
|
16
|
+
exports.compareCodeUnits = compareCodeUnits;
|
|
17
|
+
//# sourceMappingURL=compareCodeUnits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compareCodeUnits.js","sourceRoot":"","sources":["../../src/internal/compareCodeUnits.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,gBAAgB,GAA4C,CACvE,IAAY,EACZ,KAAa,EACL,EAAE,CAAC,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AAH5C,QAAA,gBAAgB,GAAhB,gBAAgB,CAG4B"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { IAutoMovieTransform } from "@automovie/interface";
|
|
2
|
+
/**
|
|
3
|
+
* Compose a parent-local TRS over a child-local TRS into one local transform.
|
|
4
|
+
*
|
|
5
|
+
* Folding a skipped helper node into the bone beneath it needs this, so the emitted rest stays relative to the nearest kept ancestor. The result is the standard rig decomposition `t = t_p + R_p (s_p * t_c)`, `r = r_p r_c`, `s = s_p * s_c` with component-wise scale products. With unit quaternions, translation follows affine composition and rotation and scale match its TRS representation when the parent scale commutes with the child rotation, as a uniform parent scale or an identity child rotation does. Otherwise the product contains shear that this TRS representation drops. Floating-point rounding remains, and a non-unit parent quaternion invalidates the rotation formula rather than applying a uniform scale.
|
|
6
|
+
*
|
|
7
|
+
* The arithmetic order is fixed, so the same inputs produce bit-identical output, which lets an external-motion source rig be compared with exact equality against the inspected basis.
|
|
8
|
+
*
|
|
9
|
+
* @param parent Transform of the node nearer the root.
|
|
10
|
+
* @param child Transform expressed in `parent`'s space.
|
|
11
|
+
* @returns A new transform expressing `child` in the space `parent` lives in.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/development/implementation.md#principled-implementation Translation applies parent scale, unit-quaternion rotation through `v + w t + q x t` with `t = 2 q x v`, then offset; rotation uses the Hamilton product and scale is component-wise. In real arithmetic this represents the affine product when parent scale commutes with child rotation; binary64 rounding remains, and other products discard shear.
|
|
14
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Humanoid import and motion adoption share one composition function, with callers responsible for the unit-quaternion premise.
|
|
15
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The fixed scalar arithmetic permits exact recomputation of an inspected basis within this pipeline; it neither normalizes quaternions nor repairs shear or non-finite inputs.
|
|
16
|
+
* @evidence contracts/development/common.md#meaningful-documentation The documentation states why helpers are folded, the formula, when it is exact and what it drops, the unit-rotation premise, and that fixed arithmetic order makes exact comparison reproducible.
|
|
17
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Fixed scalar arithmetic allocates one transform with three component records and no intermediate vectors, independent of rig size.
|
|
18
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A constant-time pure function has nothing worth caching; callers fold each helper once per bone.
|
|
19
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function retains nothing; its single result object belongs to the caller.
|
|
20
|
+
*/
|
|
21
|
+
export declare const composeLocalTransform: (parent: IAutoMovieTransform, child: IAutoMovieTransform) => IAutoMovieTransform;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.composeLocalTransform = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Compose a parent-local TRS over a child-local TRS into one local transform.
|
|
6
|
+
*
|
|
7
|
+
* Folding a skipped helper node into the bone beneath it needs this, so the emitted rest stays relative to the nearest kept ancestor. The result is the standard rig decomposition `t = t_p + R_p (s_p * t_c)`, `r = r_p r_c`, `s = s_p * s_c` with component-wise scale products. With unit quaternions, translation follows affine composition and rotation and scale match its TRS representation when the parent scale commutes with the child rotation, as a uniform parent scale or an identity child rotation does. Otherwise the product contains shear that this TRS representation drops. Floating-point rounding remains, and a non-unit parent quaternion invalidates the rotation formula rather than applying a uniform scale.
|
|
8
|
+
*
|
|
9
|
+
* The arithmetic order is fixed, so the same inputs produce bit-identical output, which lets an external-motion source rig be compared with exact equality against the inspected basis.
|
|
10
|
+
*
|
|
11
|
+
* @param parent Transform of the node nearer the root.
|
|
12
|
+
* @param child Transform expressed in `parent`'s space.
|
|
13
|
+
* @returns A new transform expressing `child` in the space `parent` lives in.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/development/implementation.md#principled-implementation Translation applies parent scale, unit-quaternion rotation through `v + w t + q x t` with `t = 2 q x v`, then offset; rotation uses the Hamilton product and scale is component-wise. In real arithmetic this represents the affine product when parent scale commutes with child rotation; binary64 rounding remains, and other products discard shear.
|
|
16
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Humanoid import and motion adoption share one composition function, with callers responsible for the unit-quaternion premise.
|
|
17
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The fixed scalar arithmetic permits exact recomputation of an inspected basis within this pipeline; it neither normalizes quaternions nor repairs shear or non-finite inputs.
|
|
18
|
+
* @evidence contracts/development/common.md#meaningful-documentation The documentation states why helpers are folded, the formula, when it is exact and what it drops, the unit-rotation premise, and that fixed arithmetic order makes exact comparison reproducible.
|
|
19
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Fixed scalar arithmetic allocates one transform with three component records and no intermediate vectors, independent of rig size.
|
|
20
|
+
* @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work A constant-time pure function has nothing worth caching; callers fold each helper once per bone.
|
|
21
|
+
* @evidenceExclude contracts/development/implementation.md#bound-retention-and-release-resources The function retains nothing; its single result object belongs to the caller.
|
|
22
|
+
*/
|
|
23
|
+
const composeLocalTransform = (parent, child) => {
|
|
24
|
+
const q = parent.rotation;
|
|
25
|
+
const vx = parent.scale.x * child.translation.x;
|
|
26
|
+
const vy = parent.scale.y * child.translation.y;
|
|
27
|
+
const vz = parent.scale.z * child.translation.z;
|
|
28
|
+
// v' = v + w t + q x t with t = 2 (q x v), the unit-quaternion rotation.
|
|
29
|
+
const tx = 2 * (q.y * vz - q.z * vy);
|
|
30
|
+
const ty = 2 * (q.z * vx - q.x * vz);
|
|
31
|
+
const tz = 2 * (q.x * vy - q.y * vx);
|
|
32
|
+
const r = child.rotation;
|
|
33
|
+
return {
|
|
34
|
+
translation: {
|
|
35
|
+
x: parent.translation.x + (vx + q.w * tx + (q.y * tz - q.z * ty)),
|
|
36
|
+
y: parent.translation.y + (vy + q.w * ty + (q.z * tx - q.x * tz)),
|
|
37
|
+
z: parent.translation.z + (vz + q.w * tz + (q.x * ty - q.y * tx)),
|
|
38
|
+
},
|
|
39
|
+
rotation: {
|
|
40
|
+
x: q.w * r.x + q.x * r.w + q.y * r.z - q.z * r.y,
|
|
41
|
+
y: q.w * r.y - q.x * r.z + q.y * r.w + q.z * r.x,
|
|
42
|
+
z: q.w * r.z + q.x * r.y - q.y * r.x + q.z * r.w,
|
|
43
|
+
w: q.w * r.w - q.x * r.x - q.y * r.y - q.z * r.z,
|
|
44
|
+
},
|
|
45
|
+
scale: {
|
|
46
|
+
x: parent.scale.x * child.scale.x,
|
|
47
|
+
y: parent.scale.y * child.scale.y,
|
|
48
|
+
z: parent.scale.z * child.scale.z,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
exports.composeLocalTransform = composeLocalTransform;
|
|
53
|
+
//# sourceMappingURL=composeLocalTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composeLocalTransform.js","sourceRoot":"","sources":["../../src/internal/composeLocalTransform.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,qBAAqB,GAGP,CACzB,MAA2B,EAC3B,KAA0B,EACL,EAAE;IACvB,MAAM,CAAC,GAAoC,MAAM,CAAC,QAAQ,CAAC;IAC3D,MAAM,EAAE,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,MAAM,EAAE,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;IACxD,MAAM,EAAE,GAA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AC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChD,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChD,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAChD,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACjD;QACD,KAAK,EAAE;YACL,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;YACjC,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;SAClC;KACF,CAAC;AACJ,CAAC,CAAC;AAlCW,QAAA,qBAAqB,GAArB,qBAAqB,CAkChC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decode an RFC 2397 data URI into exact payload octets.
|
|
3
|
+
*
|
|
4
|
+
* Canonical base64 spelling includes zero unused padding bits under RFC 4648 section 3.5 (https://www.rfc-editor.org/rfc/rfc4648.html#section-3.5); complete percent-octet escapes determine bytes, and literal Unicode chunks are encoded as UTF-8.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/implementation.md#principled-implementation Base64 terminal sextets have four zero low bits before two padding characters or two zero low bits before one; the terminal alphabet subsets encode those RFC 4648 canonical conditions. Complete percent-octet escapes and UTF-8 literal chunks define the other payload lane.
|
|
7
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One decoder owns both data-URI payload lanes shared by buffer and image closure.
|
|
8
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Malformed base64 and incomplete escapes throw with the field path instead of permissive byte repair.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose explains metadata/base64 selection, percent octets, Unicode literals and caller-owned output.
|
|
10
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Metadata and payload text drive O(N) work over URI length; percent chunks plus final concatenation retain O(N) temporary bytes, while base64 also creates an intermediate binary string.
|
|
11
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each declared data URI is decoded during its own payload admission; resolver effects and mutable sources are not cached.
|
|
12
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Decoded arrays transfer to the inspector's call-local payload owner; chunk arrays and encoded literals die on return.
|
|
13
|
+
*/
|
|
14
|
+
export declare const decodeDataUri: (uri: string, path: string) => Uint8Array;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodeDataUri = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Decode an RFC 2397 data URI into exact payload octets.
|
|
6
|
+
*
|
|
7
|
+
* Canonical base64 spelling includes zero unused padding bits under RFC 4648 section 3.5 (https://www.rfc-editor.org/rfc/rfc4648.html#section-3.5); complete percent-octet escapes determine bytes, and literal Unicode chunks are encoded as UTF-8.
|
|
8
|
+
*
|
|
9
|
+
* @evidence contracts/development/implementation.md#principled-implementation Base64 terminal sextets have four zero low bits before two padding characters or two zero low bits before one; the terminal alphabet subsets encode those RFC 4648 canonical conditions. Complete percent-octet escapes and UTF-8 literal chunks define the other payload lane.
|
|
10
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One decoder owns both data-URI payload lanes shared by buffer and image closure.
|
|
11
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Malformed base64 and incomplete escapes throw with the field path instead of permissive byte repair.
|
|
12
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose explains metadata/base64 selection, percent octets, Unicode literals and caller-owned output.
|
|
13
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Metadata and payload text drive O(N) work over URI length; percent chunks plus final concatenation retain O(N) temporary bytes, while base64 also creates an intermediate binary string.
|
|
14
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each declared data URI is decoded during its own payload admission; resolver effects and mutable sources are not cached.
|
|
15
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Decoded arrays transfer to the inspector's call-local payload owner; chunk arrays and encoded literals die on return.
|
|
16
|
+
*/
|
|
17
|
+
const decodeDataUri = (uri, path) => {
|
|
18
|
+
const comma = uri.indexOf(",");
|
|
19
|
+
if (comma < 5)
|
|
20
|
+
throw new Error(`${path} is not a complete data URI.`);
|
|
21
|
+
const metadata = uri.slice(5, comma);
|
|
22
|
+
const payload = uri.slice(comma + 1);
|
|
23
|
+
try {
|
|
24
|
+
if (metadata.split(";").includes("base64")) {
|
|
25
|
+
if (payload.length % 4 !== 0 ||
|
|
26
|
+
/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$/u.test(payload) === false)
|
|
27
|
+
throw new Error("base64 payload is not canonical");
|
|
28
|
+
const binary = atob(payload);
|
|
29
|
+
const bytes = new Uint8Array(binary.length);
|
|
30
|
+
for (let index = 0; index < binary.length; ++index)
|
|
31
|
+
bytes[index] = binary.charCodeAt(index);
|
|
32
|
+
return bytes;
|
|
33
|
+
}
|
|
34
|
+
const encoder = new TextEncoder();
|
|
35
|
+
const chunks = [];
|
|
36
|
+
let literal = 0;
|
|
37
|
+
for (let index = 0; index < payload.length; ++index) {
|
|
38
|
+
if (payload.charCodeAt(index) !== 0x25)
|
|
39
|
+
continue;
|
|
40
|
+
const hex = payload.slice(index + 1, index + 3);
|
|
41
|
+
if (/^[0-9A-Fa-f]{2}$/u.test(hex) === false)
|
|
42
|
+
throw new Error("percent escape is incomplete");
|
|
43
|
+
chunks.push(encoder.encode(payload.slice(literal, index)), Uint8Array.of(Number.parseInt(hex, 16)));
|
|
44
|
+
index += 2;
|
|
45
|
+
literal = index + 1;
|
|
46
|
+
}
|
|
47
|
+
chunks.push(encoder.encode(payload.slice(literal)));
|
|
48
|
+
const output = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.byteLength, 0));
|
|
49
|
+
let offset = 0;
|
|
50
|
+
for (const chunk of chunks) {
|
|
51
|
+
output.set(chunk, offset);
|
|
52
|
+
offset += chunk.byteLength;
|
|
53
|
+
}
|
|
54
|
+
return output;
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
throw new Error(`${path} has an invalid data payload: ${error.message}.`);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
exports.decodeDataUri = decodeDataUri;
|
|
61
|
+
//# sourceMappingURL=decodeDataUri.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decodeDataUri.js","sourceRoot":"","sources":["../../src/internal/decodeDataUri.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;GAYG;AACI,MAAM,aAAa,GAA8C,CACtE,GAAW,EACX,IAAY,EACA,EAAE;IACd,MAAM,KAAK,GAAW,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACvC,IAAI,KAAK,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,8BAA8B,C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K,KAAK;gBACzC,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAClD,MAAM,CAAC,IAAI,CACT,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,EAC7C,UAAU,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CACxC,CAAC;YACF,KAAK,IAAI,CAAC,CAAC;YACX,OAAO,GAAG,KAAK,GAAG,CAAC,CAAC;QACtB,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACpD,MAAM,MAAM,GAAe,IAAI,UAAU,CACvC,MAAM,CAAC,MAAM,CACX,CAAC,KAAa,EAAE,KAAiB,EAAU,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,EACtE,CAAC,CACF,CACF,CAAC;QACF,IAAI,MAAM,GAAW,CAAC,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC;QAC7B,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,iCAAkC,KAAe,CAAC,OAAO,GAAG,CACpE,CAAC;IACJ,CAAC;AACH,CAAC,CAAC;AAxDW,QAAA,aAAa,GAAb,aAAa,CAwDxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { IParsedContainer } from "./IParsedContainer";
|
|
2
|
+
/**
|
|
3
|
+
* Decode one GLB 2.0 container's mandatory JSON and optional BIN chunk.
|
|
4
|
+
*
|
|
5
|
+
* @evidence contracts/development/implementation.md#principled-implementation Magic, version, exact length, four-byte chunk alignment and JSON-first ordering establish the container; BIN remains a read-only input view.
|
|
6
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Container framing belongs here while strict JSON and duplicate-member checks belong to the shared JSON decoder.
|
|
7
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Unexpected or repeated trailing chunks and invalid extents throw rather than truncating or guessing a payload.
|
|
8
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments give version/alignment rules, optional BIN aliasing and suffix-provided VRM container identity.
|
|
9
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Header/chunk scanning is O(chunk count); JSON decoding is O(JSON bytes), and BIN bytes are not copied.
|
|
10
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work The same decoded JSON owner serves both GLB and plain glTF; one BIN view is reused by downstream payload readers.
|
|
11
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The parsed result borrows BIN bytes only during synchronous inspection; JSON objects and view references are call-local.
|
|
12
|
+
*/
|
|
13
|
+
export declare const decodeGlb: (bytes: Uint8Array, vrmExtension: boolean) => IParsedContainer;
|