@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,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readMotionAccessor = void 0;
|
|
4
|
+
const SHAPE_COMPONENTS_1 = require("./SHAPE_COMPONENTS");
|
|
5
|
+
const accessorReader_1 = require("./accessorReader");
|
|
6
|
+
const object_1 = require("./object");
|
|
7
|
+
/**
|
|
8
|
+
* Read a finite non-sparse FLOAT accessor into caller-owned motion values.
|
|
9
|
+
*
|
|
10
|
+
* The source inventories and byte ranges are already admitted. The requested SCALAR, VEC3 or VEC4 shape must match an accessor with a buffer view, FLOAT components and no sparse overrides. Every component is copied in element order and checked finite; a mismatch or non-finite value throws with the supplied path.
|
|
11
|
+
*
|
|
12
|
+
* @evidence contracts/development/implementation.md#principled-implementation Shape and FLOAT storage are checked before stride-aware component reads; every copied numeric value must be finite.
|
|
13
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Motion-specific shape admission stays here while shared reader code owns buffer view, stride and little-endian decoding.
|
|
14
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Sparse or normalized integer motion data is not coerced into the profile's exact FLOAT interpretation.
|
|
15
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments state source admission premises, permitted shapes, finite-value refusal and flat element/component order.
|
|
16
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Count times shape width drives time and output space; one reader and DataView serve the entire accessor copy.
|
|
17
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work The inspector caches this complete decoded accessor by index and expected shape within one immutable input revision.
|
|
18
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The output array belongs to its caller; the reader's borrowed payload reference ends when decoding completes.
|
|
19
|
+
*/
|
|
20
|
+
const readMotionAccessor = (source, accessorIndex, expectedType, path) => {
|
|
21
|
+
const accessor = (0, object_1.object)(source.accessors[accessorIndex], `accessors[${accessorIndex}]`);
|
|
22
|
+
if (accessor.componentType !== 5126 ||
|
|
23
|
+
accessor.type !== expectedType ||
|
|
24
|
+
accessor.bufferView === undefined ||
|
|
25
|
+
accessor.sparse !== undefined)
|
|
26
|
+
throw new Error(`${path} must resolve to a non-sparse FLOAT ${expectedType} accessor.`);
|
|
27
|
+
const width = SHAPE_COMPONENTS_1.SHAPE_COMPONENTS[expectedType];
|
|
28
|
+
const count = accessor.count;
|
|
29
|
+
const read = (0, accessorReader_1.accessorReader)(source, accessorIndex, `Motion accessor ${accessorIndex}`);
|
|
30
|
+
const values = new Array(count * width);
|
|
31
|
+
for (let element = 0; element < count; ++element)
|
|
32
|
+
for (let component = 0; component < width; ++component) {
|
|
33
|
+
const value = read(element, component);
|
|
34
|
+
if (Number.isFinite(value) === false)
|
|
35
|
+
throw new Error(`${path} contains a non-finite value.`);
|
|
36
|
+
values[element * width + component] = value;
|
|
37
|
+
}
|
|
38
|
+
return values;
|
|
39
|
+
};
|
|
40
|
+
exports.readMotionAccessor = readMotionAccessor;
|
|
41
|
+
//# sourceMappingURL=readMotionAccessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readMotionAccessor.js","sourceRoot":"","sources":["../../src/internal/readMotionAccessor.ts"],"names":[],"mappings":";;;AAEA,yDAAsD;AACtD,qDAAkD;AAClD,qCAAkC;AAElC;;;;;;;;;;;;GAYG;AACI,MAAM,kBAAkB,GAKf,CACd,MAAuB,EACvB,aAAqB,EACrB,YAAwC,EACxC,IAAY,EACF,EAAE;IACZ,MAAM,QAAQ,GAA4B,IAAA,eAAM,EAC9C,MAAM,CAAC,SAAS,CAAC,aAAa,CAAC,EAC/B,aAAa,aAAa,GAAG,CAC9B,CAAC;IACF,IACE,QAAQ,CAAC,aAAa,KAAK,IAAI;QAC/B,QAAQ,CAAC,IAAI,KAAK,YAAY;QAC9B,QAAQ,CAAC,UAAU,KAAK,SAAS;QACjC,QAAQ,CAAC,MAAM,KAAK,SAAS;QAE7B,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,uCAAuC,YAAY,YAAY,CACvE,CAAC;IACJ,MAAM,KAAK,GAAW,mCAAgB,CAAC,YAAY,CAAE,CAAC;IACtD,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAe,CAAC;IAC/C,MAAM,IAAI,GAAiC,IAAA,+BAAc,EACvD,MAAM,EACN,aAAa,EACb,mBAAmB,aAAa,EAAE,CACnC,CAAC;IACF,MAAM,MAAM,GAAa,IAAI,KAAK,CAAS,KAAK,GAAG,KAAK,CAAC,CAAC;IAC1D,KAAK,IAAI,OAAO,GAAW,CAAC,EAAE,OAAO,GAAG,KAAK,EAAE,EAAE,OAAO;QACtD,KAAK,IAAI,SAAS,GAAW,CAAC,EAAE,SAAS,GAAG,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC;YAC/D,MAAM,KAAK,GAAW,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC/C,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,KAAK;gBAClC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,+BAA+B,CAAC,CAAC;YAC1D,MAAM,CAAC,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC,GAAG,KAAK,CAAC;QAC9C,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAxCW,QAAA,kBAAkB,GAAlB,kBAAkB,CAwC7B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Require an actual JSON array at a named external-document path.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/implementation.md#principled-implementation Array.isArray admits only array values; rejected inputs report their owning JSON path.
|
|
5
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One shape gate centralizes array identity for structural, motion and skin inspection.
|
|
6
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Objects, null and array-looking values are refused rather than coerced into synthetic inventories.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states input identity, path-named failure and that admitted arrays are borrowed unchanged.
|
|
8
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One Array.isArray check is constant-time without scanning or copying elements.
|
|
9
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All optional-array handling delegates this same identity check when a value is present.
|
|
10
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The helper allocates no collection and returns the caller's existing array reference.
|
|
11
|
+
*/
|
|
12
|
+
export declare const requiredArray: (value: unknown, path: string) => unknown[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requiredArray = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Require an actual JSON array at a named external-document path.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation Array.isArray admits only array values; rejected inputs report their owning JSON path.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One shape gate centralizes array identity for structural, motion and skin inspection.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Objects, null and array-looking values are refused rather than coerced into synthetic inventories.
|
|
10
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states input identity, path-named failure and that admitted arrays are borrowed unchanged.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One Array.isArray check is constant-time without scanning or copying elements.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work All optional-array handling delegates this same identity check when a value is present.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The helper allocates no collection and returns the caller's existing array reference.
|
|
14
|
+
*/
|
|
15
|
+
const requiredArray = (value, path) => {
|
|
16
|
+
if (Array.isArray(value) === false)
|
|
17
|
+
throw new Error(`${path} must be an array.`);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
exports.requiredArray = requiredArray;
|
|
21
|
+
//# sourceMappingURL=requiredArray.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredArray.js","sourceRoot":"","sources":["../../src/internal/requiredArray.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAAgD,CACxE,KAAc,EACd,IAAY,EACD,EAAE;IACb,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK;QAChC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,oBAAoB,CAAC,CAAC;IAC/C,OAAO,KAAkB,CAAC;AAC5B,CAAC,CAAC;AAPW,QAAA,aAAa,GAAb,aAAa,CAOxB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return distinct strings in deterministic JavaScript code-unit order.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/implementation.md#principled-implementation A Set preserves exact string equality before the shared comparator imposes canonical ordering.
|
|
5
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Deduplication and ordering form one inventory operation used by the external-extension report.
|
|
6
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Case, whitespace and Unicode normalization are preserved rather than merging near-match extension identities.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation The description states exact equality, code-unit ordering and caller ownership of the result array.
|
|
8
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms N inputs cause N expected Set operations over exact strings; U unique values need O(U log U) comparisons, each scanning the compared shared prefix, plus text-dependent string identity/hash work and O(U) collection space.
|
|
9
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A single Set performs deduplication before sorting; mutable input arrays prevent safe retained identity caching.
|
|
10
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources One temporary Set and returned U-element array are allocated; no input collection is retained after return.
|
|
11
|
+
*/
|
|
12
|
+
export declare const uniqueStrings: (values: string[]) => string[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueStrings = void 0;
|
|
4
|
+
const compareCodeUnits_1 = require("./compareCodeUnits");
|
|
5
|
+
/**
|
|
6
|
+
* Return distinct strings in deterministic JavaScript code-unit order.
|
|
7
|
+
*
|
|
8
|
+
* @evidence contracts/development/implementation.md#principled-implementation A Set preserves exact string equality before the shared comparator imposes canonical ordering.
|
|
9
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Deduplication and ordering form one inventory operation used by the external-extension report.
|
|
10
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Case, whitespace and Unicode normalization are preserved rather than merging near-match extension identities.
|
|
11
|
+
* @evidence contracts/development/common.md#meaningful-documentation The description states exact equality, code-unit ordering and caller ownership of the result array.
|
|
12
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms N inputs cause N expected Set operations over exact strings; U unique values need O(U log U) comparisons, each scanning the compared shared prefix, plus text-dependent string identity/hash work and O(U) collection space.
|
|
13
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work A single Set performs deduplication before sorting; mutable input arrays prevent safe retained identity caching.
|
|
14
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources One temporary Set and returned U-element array are allocated; no input collection is retained after return.
|
|
15
|
+
*/
|
|
16
|
+
const uniqueStrings = (values) => [...new Set(values)].sort(compareCodeUnits_1.compareCodeUnits);
|
|
17
|
+
exports.uniqueStrings = uniqueStrings;
|
|
18
|
+
//# sourceMappingURL=uniqueStrings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uniqueStrings.js","sourceRoot":"","sources":["../../src/internal/uniqueStrings.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAEtD;;;;;;;;;;GAUG;AACI,MAAM,aAAa,GAAmC,CAC3D,MAAgB,EACN,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,mCAAgB,CAAC,CAAC;AAFtD,QAAA,aAAa,GAAb,aAAa,CAEyC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recognize a safe integer inside a zero-based inventory.
|
|
3
|
+
*
|
|
4
|
+
* @evidence contracts/development/implementation.md#principled-implementation Number type, safe-integer identity and half-open bounds determine resolvable node or array references.
|
|
5
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The boolean predicate separates recognition from integerIndex's field-specific throwing behavior.
|
|
6
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Nonnumeric, negative, fractional and unsafe values remain false without coercion or fallback.
|
|
7
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states accepted bounds, safe precision and the nonthrowing recognition role.
|
|
8
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Four scalar predicates cost constant time independent of inventory size.
|
|
9
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Throwing index admission and VRM mapping reuse the same recognition semantics.
|
|
10
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The predicate retains no inventory references and acquires no resource.
|
|
11
|
+
*/
|
|
12
|
+
export declare const validNodeIndex: (value: unknown, length: number) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validNodeIndex = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Recognize a safe integer inside a zero-based inventory.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation Number type, safe-integer identity and half-open bounds determine resolvable node or array references.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The boolean predicate separates recognition from integerIndex's field-specific throwing behavior.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Nonnumeric, negative, fractional and unsafe values remain false without coercion or fallback.
|
|
10
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states accepted bounds, safe precision and the nonthrowing recognition role.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Four scalar predicates cost constant time independent of inventory size.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Throwing index admission and VRM mapping reuse the same recognition semantics.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The predicate retains no inventory references and acquires no resource.
|
|
14
|
+
*/
|
|
15
|
+
const validNodeIndex = (value, length) => typeof value === "number" &&
|
|
16
|
+
Number.isSafeInteger(value) &&
|
|
17
|
+
value >= 0 &&
|
|
18
|
+
value < length;
|
|
19
|
+
exports.validNodeIndex = validNodeIndex;
|
|
20
|
+
//# sourceMappingURL=validNodeIndex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validNodeIndex.js","sourceRoot":"","sources":["../../src/internal/validNodeIndex.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;GAUG;AACI,MAAM,cAAc,GAAgD,CACzE,KAAc,EACd,MAAc,EACL,EAAE,CACX,OAAO,KAAK,KAAK,QAAQ;IACzB,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;IAC3B,KAAK,IAAI,CAAC;IACV,KAAK,GAAG,MAAM,CAAC;AAPJ,QAAA,cAAc,GAAd,cAAc,CAOV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admit one accessor's dense byte extent using its component shape and stride.
|
|
3
|
+
*
|
|
4
|
+
* The caller has admitted component type, shape, positive count, nonnegative offset and referenced view. Dense storage requires offset + (count - 1) * stride + paddedElementBytes to fit the view and stride to cover one element. Missing dense storage is accepted only when a sparse declaration exists, whose own gate checks its ranges; this gate does not check component alignment or payload values.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/implementation.md#principled-implementation Count, zero-default byte offset and padded element size determine final extent; validated buffer views bound the resulting range.
|
|
7
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Dense range arithmetic belongs here and shared element sizing supplies matrix-column padding without another table.
|
|
8
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An accessor lacking both a buffer view and sparse payload is refused; no fallback data is synthesized.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments give the dense extent formula, sparse-only allowance and prevalidated metadata premise.
|
|
10
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Constant-time arithmetic resolves one view and shape without visiting accessor elements.
|
|
11
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Padded element sizing is shared with sparse validation and component readers; no computed payload values are cached.
|
|
12
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The gate borrows metadata for the duration of one call and owns no reader or resident bytes.
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateAccessorRange: (accessor: Record<string, unknown>, index: number, bufferViews: unknown[]) => void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAccessorRange = void 0;
|
|
4
|
+
const accessorElementByteLength_1 = require("./accessorElementByteLength");
|
|
5
|
+
const object_1 = require("./object");
|
|
6
|
+
/**
|
|
7
|
+
* Admit one accessor's dense byte extent using its component shape and stride.
|
|
8
|
+
*
|
|
9
|
+
* The caller has admitted component type, shape, positive count, nonnegative offset and referenced view. Dense storage requires offset + (count - 1) * stride + paddedElementBytes to fit the view and stride to cover one element. Missing dense storage is accepted only when a sparse declaration exists, whose own gate checks its ranges; this gate does not check component alignment or payload values.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/development/implementation.md#principled-implementation Count, zero-default byte offset and padded element size determine final extent; validated buffer views bound the resulting range.
|
|
12
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Dense range arithmetic belongs here and shared element sizing supplies matrix-column padding without another table.
|
|
13
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An accessor lacking both a buffer view and sparse payload is refused; no fallback data is synthesized.
|
|
14
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments give the dense extent formula, sparse-only allowance and prevalidated metadata premise.
|
|
15
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Constant-time arithmetic resolves one view and shape without visiting accessor elements.
|
|
16
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Padded element sizing is shared with sparse validation and component readers; no computed payload values are cached.
|
|
17
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The gate borrows metadata for the duration of one call and owns no reader or resident bytes.
|
|
18
|
+
*/
|
|
19
|
+
const validateAccessorRange = (accessor, index, bufferViews) => {
|
|
20
|
+
if (accessor.bufferView === undefined) {
|
|
21
|
+
if (accessor.sparse === undefined)
|
|
22
|
+
throw new Error(`accessors[${index}] needs a bufferView or a complete sparse payload.`);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const view = (0, object_1.object)(bufferViews[accessor.bufferView], `bufferViews[${accessor.bufferView}]`);
|
|
26
|
+
const element = (0, accessorElementByteLength_1.accessorElementByteLength)(accessor.componentType, accessor.type);
|
|
27
|
+
const stride = view.byteStride ?? element;
|
|
28
|
+
if (stride < element)
|
|
29
|
+
throw new Error(`accessors[${index}] element size ${element} exceeds bufferView byteStride ${stride}.`);
|
|
30
|
+
const offset = accessor.byteOffset ?? 0;
|
|
31
|
+
const count = accessor.count;
|
|
32
|
+
const end = offset + (count - 1) * stride + element;
|
|
33
|
+
if (end > view.byteLength)
|
|
34
|
+
throw new Error(`accessors[${index}] requires ${end} bytes inside a bufferView of ${String(view.byteLength)} bytes.`);
|
|
35
|
+
};
|
|
36
|
+
exports.validateAccessorRange = validateAccessorRange;
|
|
37
|
+
//# sourceMappingURL=validateAccessorRange.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateAccessorRange.js","sourceRoot":"","sources":["../../src/internal/validateAccessorRange.ts"],"names":[],"mappings":";;;AAAA,2EAAwE;AACxE,qCAAkC;AAElC;;;;;;;;;;;;GAYG;AACI,MAAM,qBAAqB,GAItB,CACV,QAAiC,EACjC,KAAa,EACb,WAAsB,EAChB,EAAE;IACR,IAAI,QAAQ,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;QACtC,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;YAC/B,MAAM,IAAI,KAAK,CACb,aAAa,KAAK,oDAAoD,CACvE,CAAC;QACJ,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAA4B,IAAA,eAAM,EAC1C,WAAW,CAAC,QAAQ,CAAC,UAAoB,CAAC,EAC1C,eAAe,QAAQ,CAAC,UAAoB,GAAG,CAChD,CAAC;IACF,MAAM,OAAO,GAAW,IAAA,qDAAyB,EAC/C,QAAQ,CAAC,aAAuB,EAChC,QAAQ,CAAC,IAAc,CACxB,CAAC;IACF,MAAM,MAAM,GAAY,IAAI,CAAC,UAAiC,IAAI,OAAO,CAAC;IAC1E,IAAI,MAAM,GAAG,OAAO;QAClB,MAAM,IAAI,KAAK,CACb,aAAa,KAAK,kBAAkB,OAAO,kCAAkC,MAAM,GAAG,CACvF,CAAC;IACJ,MAAM,MAAM,GAAY,QAAQ,CAAC,UAAiC,IAAI,CAAC,CAAC;IACxE,MAAM,KAAK,GAAW,QAAQ,CAAC,KAAe,CAAC;IAC/C,MAAM,GAAG,GAAW,MAAM,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC;IAC5D,IAAI,GAAG,GAAI,IAAI,CAAC,UAAqB;QACnC,MAAM,IAAI,KAAK,CACb,aAAa,KAAK,cAAc,GAAG,iCAAiC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,SAAS,CACrG,CAAC;AACN,CAAC,CAAC;AApCW,QAAA,qBAAqB,GAArB,qBAAqB,CAoChC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { IAccessorSource } from "./IAccessorSource";
|
|
2
|
+
/**
|
|
3
|
+
* Check complete mesh/skin bindings and collect joints actually receiving positive weights.
|
|
4
|
+
*
|
|
5
|
+
* Matched VEC4 joints/weights and POSITION counts drive each vertex read. Negative components throw before a finite positive sum establishes weighted coverage. This pass reads only JOINTS_0/WEIGHTS_0; it does not enforce weight-sum normalization, uniqueness of nonzero influences or complete coverage of additional joint sets, and does not establish anatomical validity.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation Matched VEC4 joint/weight counts drive each vertex read; individual negative weights throw before a finite positive sum establishes coverage.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Mesh/skin pairs own weight admission, while the shared accessor reader owns stride, numeric decoding and resident views.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Negative weights cannot be hidden by cancellation with positive weights; malformed bindings throw without guessed or clamped influences.
|
|
10
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states nonnegative influence admission, positive finite total and the unresolved normalization/additional-set limits of this coverage pass.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Cost is O(N plus unique bound mesh/skin vertex counts), with four weight reads and up to four joint-index reads per vertex, using expected constant-time membership sets.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Repeated nodes binding the identical mesh/skin pair reuse completed checks within immutable synchronous inspection only.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The per-call pair set and weighted-joint set scale with bindings and joints; no mesh bytes or running resources survive.
|
|
14
|
+
*/
|
|
15
|
+
export declare const validateHumanoidSkinning: (props: {
|
|
16
|
+
nodes: unknown[];
|
|
17
|
+
meshes: unknown[];
|
|
18
|
+
skins: unknown[];
|
|
19
|
+
source: IAccessorSource;
|
|
20
|
+
}) => Set<number>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateHumanoidSkinning = void 0;
|
|
4
|
+
const accessorReader_1 = require("./accessorReader");
|
|
5
|
+
const integerIndex_1 = require("./integerIndex");
|
|
6
|
+
const object_1 = require("./object");
|
|
7
|
+
const requiredArray_1 = require("./requiredArray");
|
|
8
|
+
/**
|
|
9
|
+
* Check complete mesh/skin bindings and collect joints actually receiving positive weights.
|
|
10
|
+
*
|
|
11
|
+
* Matched VEC4 joints/weights and POSITION counts drive each vertex read. Negative components throw before a finite positive sum establishes weighted coverage. This pass reads only JOINTS_0/WEIGHTS_0; it does not enforce weight-sum normalization, uniqueness of nonzero influences or complete coverage of additional joint sets, and does not establish anatomical validity.
|
|
12
|
+
*
|
|
13
|
+
* @evidence contracts/development/implementation.md#principled-implementation Matched VEC4 joint/weight counts drive each vertex read; individual negative weights throw before a finite positive sum establishes coverage.
|
|
14
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Mesh/skin pairs own weight admission, while the shared accessor reader owns stride, numeric decoding and resident views.
|
|
15
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Negative weights cannot be hidden by cancellation with positive weights; malformed bindings throw without guessed or clamped influences.
|
|
16
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose states nonnegative influence admission, positive finite total and the unresolved normalization/additional-set limits of this coverage pass.
|
|
17
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Cost is O(N plus unique bound mesh/skin vertex counts), with four weight reads and up to four joint-index reads per vertex, using expected constant-time membership sets.
|
|
18
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Repeated nodes binding the identical mesh/skin pair reuse completed checks within immutable synchronous inspection only.
|
|
19
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The per-call pair set and weighted-joint set scale with bindings and joints; no mesh bytes or running resources survive.
|
|
20
|
+
*/
|
|
21
|
+
const validateHumanoidSkinning = (props) => {
|
|
22
|
+
let skinnedPrimitiveCount = 0;
|
|
23
|
+
const weightedNodes = new Set();
|
|
24
|
+
// Instanced characters bind the same mesh and skin on several nodes; the
|
|
25
|
+
// weights are the same, so each pair is read once.
|
|
26
|
+
const checkedBindings = new Set();
|
|
27
|
+
props.nodes.forEach((value, nodeIndex) => {
|
|
28
|
+
const node = (0, object_1.object)(value, `nodes[${nodeIndex}]`);
|
|
29
|
+
if (node.skin === undefined)
|
|
30
|
+
return;
|
|
31
|
+
if (node.mesh === undefined)
|
|
32
|
+
throw new Error(`nodes[${nodeIndex}] binds a skin without a render mesh.`);
|
|
33
|
+
const skinIndex = node.skin;
|
|
34
|
+
const meshIndex = node.mesh;
|
|
35
|
+
const binding = `${meshIndex}:${skinIndex}`;
|
|
36
|
+
if (checkedBindings.has(binding))
|
|
37
|
+
return;
|
|
38
|
+
checkedBindings.add(binding);
|
|
39
|
+
const joints = (0, requiredArray_1.requiredArray)((0, object_1.object)(props.skins[skinIndex], `skins[${skinIndex}]`).joints, `skins[${skinIndex}].joints`);
|
|
40
|
+
const mesh = (0, object_1.object)(props.meshes[meshIndex], `meshes[${meshIndex}]`);
|
|
41
|
+
(0, requiredArray_1.requiredArray)(mesh.primitives, `meshes[${meshIndex}].primitives`).forEach((primitiveValue, primitiveIndex) => {
|
|
42
|
+
const path = `meshes[${meshIndex}].primitives[${primitiveIndex}]`;
|
|
43
|
+
const primitive = (0, object_1.object)(primitiveValue, path);
|
|
44
|
+
const attributes = (0, object_1.object)(primitive.attributes, `${path}.attributes`);
|
|
45
|
+
(0, integerIndex_1.integerIndex)(attributes.JOINTS_0, props.source.accessors.length, `${path}.attributes.JOINTS_0`, true);
|
|
46
|
+
(0, integerIndex_1.integerIndex)(attributes.WEIGHTS_0, props.source.accessors.length, `${path}.attributes.WEIGHTS_0`, true);
|
|
47
|
+
const jointIndex = attributes.JOINTS_0;
|
|
48
|
+
const weightIndex = attributes.WEIGHTS_0;
|
|
49
|
+
const position = (0, object_1.object)(props.source.accessors[attributes.POSITION], `accessors[${attributes.POSITION}]`);
|
|
50
|
+
const jointAccessor = (0, object_1.object)(props.source.accessors[jointIndex], `accessors[${jointIndex}]`);
|
|
51
|
+
const weightAccessor = (0, object_1.object)(props.source.accessors[weightIndex], `accessors[${weightIndex}]`);
|
|
52
|
+
if (jointAccessor.type !== "VEC4" ||
|
|
53
|
+
(jointAccessor.componentType !== 5121 &&
|
|
54
|
+
jointAccessor.componentType !== 5123) ||
|
|
55
|
+
weightAccessor.type !== "VEC4" ||
|
|
56
|
+
(weightAccessor.componentType !== 5126 &&
|
|
57
|
+
weightAccessor.componentType !== 5121 &&
|
|
58
|
+
weightAccessor.componentType !== 5123) ||
|
|
59
|
+
(weightAccessor.componentType !== 5126 &&
|
|
60
|
+
weightAccessor.normalized !== true) ||
|
|
61
|
+
jointAccessor.count !== position.count ||
|
|
62
|
+
weightAccessor.count !== position.count)
|
|
63
|
+
throw new Error(`Skinned primitive ${meshIndex}:${primitiveIndex} needs count-matched JOINTS_0 and normalized WEIGHTS_0 VEC4 accessors.`);
|
|
64
|
+
const readWeight = (0, accessorReader_1.accessorReader)(props.source, weightIndex, `Skin accessor ${weightIndex}`);
|
|
65
|
+
const readJoint = (0, accessorReader_1.accessorReader)(props.source, jointIndex, `Skin accessor ${jointIndex}`);
|
|
66
|
+
for (let vertex = 0; vertex < position.count; ++vertex) {
|
|
67
|
+
let weightSum = 0;
|
|
68
|
+
for (let component = 0; component < 4; ++component) {
|
|
69
|
+
const weight = readWeight(vertex, component);
|
|
70
|
+
if (weight < 0)
|
|
71
|
+
throw new Error(`Skinned primitive ${meshIndex}:${primitiveIndex} vertex ${vertex} component ${component} has negative skin weight ${weight}.`);
|
|
72
|
+
weightSum += weight;
|
|
73
|
+
if (weight > 0 === false)
|
|
74
|
+
continue;
|
|
75
|
+
const joint = readJoint(vertex, component);
|
|
76
|
+
if (Number.isSafeInteger(joint) === false || joint >= joints.length)
|
|
77
|
+
throw new Error(`Skinned primitive ${meshIndex}:${primitiveIndex} vertex ${vertex} cites joint ${joint} outside skin ${skinIndex}.`);
|
|
78
|
+
weightedNodes.add(joints[joint]);
|
|
79
|
+
}
|
|
80
|
+
if (Number.isFinite(weightSum) === false || weightSum <= 0)
|
|
81
|
+
throw new Error(`Skinned primitive ${meshIndex}:${primitiveIndex} vertex ${vertex} has no positive skin weight.`);
|
|
82
|
+
}
|
|
83
|
+
++skinnedPrimitiveCount;
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
if (skinnedPrimitiveCount === 0)
|
|
87
|
+
throw new Error("Humanoid profiles require at least one mesh node with a complete skin binding.");
|
|
88
|
+
return weightedNodes;
|
|
89
|
+
};
|
|
90
|
+
exports.validateHumanoidSkinning = validateHumanoidSkinning;
|
|
91
|
+
//# sourceMappingURL=validateHumanoidSkin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CAC/H,CAAC;oBACJ,SAAS,IAAI,MAAM,CAAC;oBACpB,IAAI,MAAM,GAAG,CAAC,KAAK,KAAK;wBAAE,SAAS;oBACnC,MAAM,KAAK,GAAW,SAAS,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;oBACnD,IAAI,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,KAAK,IAAI,KAAK,IAAI,MAAM,CAAC,MAAM;wBACjE,MAAM,IAAI,KAAK,CACb,qBAAqB,SAAS,IAAI,cAAc,WAAW,MAAM,gBAAgB,KAAK,iBAAiB,SAAS,GAAG,CACpH,CAAC;oBACJ,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAW,CAAC,CAAC;gBAC7C,CAAC;gBACD,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,KAAK,IAAI,SAAS,IAAI,CAAC;oBACxD,MAAM,IAAI,KAAK,CACb,qBAAqB,SAAS,IAAI,cAAc,WAAW,MAAM,+BAA+B,CACjG,CAAC;YACN,CAAC;YACD,EAAE,qBAAqB,CAAC;QAC1B,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,IAAI,qBAAqB,KAAK,CAAC;QAC7B,MAAM,IAAI,KAAK,CACb,gFAAgF,CACjF,CAAC;IACJ,OAAO,aAAa,CAAC;AACvB,CAAC,CAAC;AAnIW,QAAA,wBAAwB,GAAxB,wBAAwB,CAmInC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bind every declared glTF buffer and image to its exact resident payload.
|
|
3
|
+
*
|
|
4
|
+
* The caller has admitted declared counts, lengths, views and URI shapes. Only buffer zero in a GLB/VRM container may borrow BIN, with at most three pad bytes; URI buffers require exact declared lengths, and views must fit declared and resident extents. Each external URI entry invokes the caller resolver independently, without network access here; data URIs decode locally and URI images need nonempty bytes. Returned buffer references live with the synchronous inspector, while image formats and sparse contents remain uninspected.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/implementation.md#principled-implementation GLB buffer zero owns BIN with at most three pad bytes; URI buffers require exact lengths and views fit declared and resident bounds.
|
|
7
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One payload owner sequences buffer binding, orphan-BIN checks, view bounds and image presence before profile decoding.
|
|
8
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Missing sidecars throw; resolver effects occur per declared entry and are not silently deduplicated or replaced.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments state read-only resident bytes, URI resolver responsibility, padding limits and no network fetch.
|
|
10
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Work follows buffer/view/image counts and encoded data-URI bytes, plus the caller's complete resolver work for each declared external URI entry; repeated URIs repeat callback effects, borrowed payloads avoid copies, and data URIs allocate decoded arrays.
|
|
11
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each resolved buffer is reused by its accessors inside the call; callback effects prohibit caching by URI without caller guarantees.
|
|
12
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The inspector owns the temporary payload list and decoded data-URI arrays only for the call; sidecar buffers remain borrowed.
|
|
13
|
+
*/
|
|
14
|
+
export declare const validatePayloadClosure: (props: {
|
|
15
|
+
format: "gltf" | "glb" | "vrm";
|
|
16
|
+
bin: Uint8Array | null;
|
|
17
|
+
buffers: unknown[];
|
|
18
|
+
bufferViews: unknown[];
|
|
19
|
+
images: unknown[];
|
|
20
|
+
resolveResource?: (uri: string) => Uint8Array | null;
|
|
21
|
+
}) => Uint8Array[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePayloadClosure = void 0;
|
|
4
|
+
const decodeDataUri_1 = require("./decodeDataUri");
|
|
5
|
+
const object_1 = require("./object");
|
|
6
|
+
/**
|
|
7
|
+
* Bind every declared glTF buffer and image to its exact resident payload.
|
|
8
|
+
*
|
|
9
|
+
* The caller has admitted declared counts, lengths, views and URI shapes. Only buffer zero in a GLB/VRM container may borrow BIN, with at most three pad bytes; URI buffers require exact declared lengths, and views must fit declared and resident extents. Each external URI entry invokes the caller resolver independently, without network access here; data URIs decode locally and URI images need nonempty bytes. Returned buffer references live with the synchronous inspector, while image formats and sparse contents remain uninspected.
|
|
10
|
+
*
|
|
11
|
+
* @evidence contracts/development/implementation.md#principled-implementation GLB buffer zero owns BIN with at most three pad bytes; URI buffers require exact lengths and views fit declared and resident bounds.
|
|
12
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure One payload owner sequences buffer binding, orphan-BIN checks, view bounds and image presence before profile decoding.
|
|
13
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Missing sidecars throw; resolver effects occur per declared entry and are not silently deduplicated or replaced.
|
|
14
|
+
* @evidence contracts/development/common.md#meaningful-documentation Comments state read-only resident bytes, URI resolver responsibility, padding limits and no network fetch.
|
|
15
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Work follows buffer/view/image counts and encoded data-URI bytes, plus the caller's complete resolver work for each declared external URI entry; repeated URIs repeat callback effects, borrowed payloads avoid copies, and data URIs allocate decoded arrays.
|
|
16
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each resolved buffer is reused by its accessors inside the call; callback effects prohibit caching by URI without caller guarantees.
|
|
17
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The inspector owns the temporary payload list and decoded data-URI arrays only for the call; sidecar buffers remain borrowed.
|
|
18
|
+
*/
|
|
19
|
+
const validatePayloadClosure = (props) => {
|
|
20
|
+
const payloads = props.buffers.map((value, index) => {
|
|
21
|
+
const buffer = (0, object_1.object)(value, `buffers[${index}]`);
|
|
22
|
+
const length = buffer.byteLength;
|
|
23
|
+
if (buffer.uri === undefined) {
|
|
24
|
+
if (props.format === "gltf" || index !== 0)
|
|
25
|
+
throw new Error(`buffers[${index}] cannot use the GLB BIN chunk in this container.`);
|
|
26
|
+
if (props.bin === null)
|
|
27
|
+
throw new Error(`buffers[${index}] declares ${length} bytes but the GLB has no BIN chunk.`);
|
|
28
|
+
if (props.bin.byteLength < length || props.bin.byteLength > length + 3)
|
|
29
|
+
throw new Error(`GLB BIN chunk length ${props.bin.byteLength} does not cover buffers[${index}].byteLength ${length} with at most three padding bytes.`);
|
|
30
|
+
return props.bin;
|
|
31
|
+
}
|
|
32
|
+
const uri = buffer.uri;
|
|
33
|
+
if (uri.startsWith("data:")) {
|
|
34
|
+
const bytes = (0, decodeDataUri_1.decodeDataUri)(uri, `buffers[${index}].uri`);
|
|
35
|
+
if (bytes.byteLength !== length)
|
|
36
|
+
throw new Error(`buffers[${index}] data URI has ${bytes.byteLength} bytes, not declared byteLength ${length}.`);
|
|
37
|
+
return bytes;
|
|
38
|
+
}
|
|
39
|
+
const bytes = props.resolveResource?.(uri) ?? null;
|
|
40
|
+
if (bytes === null)
|
|
41
|
+
throw new Error(`External buffer "${uri}" has no builder-resolved resident bytes.`);
|
|
42
|
+
if (bytes.byteLength !== length)
|
|
43
|
+
throw new Error(`External buffer "${uri}" has ${bytes.byteLength} bytes, not declared byteLength ${length}.`);
|
|
44
|
+
return bytes;
|
|
45
|
+
});
|
|
46
|
+
if (props.bin !== null && props.buffers.length === 0)
|
|
47
|
+
throw new Error("GLB contains a BIN chunk but declares no buffer.");
|
|
48
|
+
if (props.bin !== null &&
|
|
49
|
+
(0, object_1.object)(props.buffers[0], "buffers[0]").uri !== undefined)
|
|
50
|
+
throw new Error("GLB BIN chunk is orphaned because buffers[0] declares an external URI.");
|
|
51
|
+
props.bufferViews.forEach((value, index) => {
|
|
52
|
+
const view = (0, object_1.object)(value, `bufferViews[${index}]`);
|
|
53
|
+
const bufferIndex = view.buffer;
|
|
54
|
+
const offset = view.byteOffset ?? 0;
|
|
55
|
+
const length = view.byteLength;
|
|
56
|
+
const declared = (0, object_1.object)(props.buffers[bufferIndex], `buffers[${bufferIndex}]`).byteLength;
|
|
57
|
+
if (offset + length > declared ||
|
|
58
|
+
offset + length > payloads[bufferIndex].byteLength)
|
|
59
|
+
throw new Error(`bufferViews[${index}] range ${offset}..${offset + length} exceeds buffers[${bufferIndex}].byteLength ${declared}.`);
|
|
60
|
+
});
|
|
61
|
+
props.images.forEach((value, index) => {
|
|
62
|
+
const image = (0, object_1.object)(value, `images[${index}]`);
|
|
63
|
+
if (typeof image.uri !== "string")
|
|
64
|
+
return;
|
|
65
|
+
const bytes = image.uri.startsWith("data:")
|
|
66
|
+
? (0, decodeDataUri_1.decodeDataUri)(image.uri, `images[${index}].uri`)
|
|
67
|
+
: (props.resolveResource?.(image.uri) ?? null);
|
|
68
|
+
if (bytes === null || bytes.byteLength === 0)
|
|
69
|
+
throw new Error(`External image "${image.uri}" has no non-empty builder-resolved resident bytes.`);
|
|
70
|
+
});
|
|
71
|
+
return payloads;
|
|
72
|
+
};
|
|
73
|
+
exports.validatePayloadClosure = validatePayloadClosure;
|
|
74
|
+
//# sourceMappingURL=validatePayloadClosure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatePayloadClosure.js","sourceRoot":"","sources":["../../src/internal/validatePayloadClosure.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,qCAAkC;AAElC;;;;;;;;;;;;GAYG;AACI,MAAM,sBAAsB,GAOd,CAAC,KAOrB,EAAgB,EAAE;IACjB,MAAM,QAAQ,GAAiB,KAAK,CAAC,OAAO,CAAC,GAAG,CAC9C,CAAC,KAAc,EAAE,KAAa,EAAc,EAAE;QAC5C,MAAM,MAAM,GAA4B,IAAA,eAAM,EAC5C,KAAK,EACL,WAAW,KAAK,GAAG,CACpB,CAAC;QACF,MAAM,MAAM,GAAW,MAAM,CAAC,UAAoB,CAAC;QACnD,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,IAAI,KAAK,KAAK,CAAC;gBACxC,MAAM,IAAI,KAAK,CACb,WAAW,KAAK,mD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,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC;YAC5D,CAAC,CAAC,IAAA,6BAAa,EAAC,KAAK,CAAC,GAAG,EAAE,UAAU,KAAK,OAAO,CAAC;YAClD,CAAC,CAAC,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC;QACjD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,UAAU,KAAK,CAAC;YAC1C,MAAM,IAAI,KAAK,CACb,mBAAmB,KAAK,CAAC,GAAG,qDAAqD,CAClF,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAnGW,QAAA,sBAAsB,GAAtB,sBAAsB,CAmGjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Admit sparse accessor byte ranges within validated glTF buffer views.
|
|
3
|
+
*
|
|
4
|
+
* Absent sparse metadata does nothing. Present metadata needs a positive count no greater than accessor count, valid index/value views, unsigned byte/short/int indices and nonnegative zero-default offsets. Both tightly packed extents must fit their views; index ordering, index values and sparse payload values are not decoded, and skin/motion readers reject sparse accessors separately.
|
|
5
|
+
*
|
|
6
|
+
* @evidence contracts/development/implementation.md#principled-implementation Sparse count cannot exceed accessor count; unsigned index widths and padded matrix element sizes determine both payload ranges.
|
|
7
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The sparse gate owns count, index format and subview range checks while shared element sizing owns matrix padding.
|
|
8
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Sparse layout is checked structurally but skin/motion consumers explicitly refuse sparse reading rather than inventing dense values.
|
|
9
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose explains admitted view indices, zero-default offsets, count bounds and consumer limitations.
|
|
10
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One sparse accessor requires constant-size field checks and two range calculations independent of sparse element count.
|
|
11
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Subview metadata is read once per sparse payload; no byte decoding is performed or cached here.
|
|
12
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The range gate creates temporary metadata references only and retains no payload, reader or handle.
|
|
13
|
+
*/
|
|
14
|
+
export declare const validateSparseAccessor: (accessor: Record<string, unknown>, index: number, bufferViews: unknown[]) => void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateSparseAccessor = void 0;
|
|
4
|
+
const COMPONENT_BYTES_1 = require("./COMPONENT_BYTES");
|
|
5
|
+
const accessorElementByteLength_1 = require("./accessorElementByteLength");
|
|
6
|
+
const integerIndex_1 = require("./integerIndex");
|
|
7
|
+
const nonNegativeInteger_1 = require("./nonNegativeInteger");
|
|
8
|
+
const object_1 = require("./object");
|
|
9
|
+
const positiveInteger_1 = require("./positiveInteger");
|
|
10
|
+
/**
|
|
11
|
+
* Admit sparse accessor byte ranges within validated glTF buffer views.
|
|
12
|
+
*
|
|
13
|
+
* Absent sparse metadata does nothing. Present metadata needs a positive count no greater than accessor count, valid index/value views, unsigned byte/short/int indices and nonnegative zero-default offsets. Both tightly packed extents must fit their views; index ordering, index values and sparse payload values are not decoded, and skin/motion readers reject sparse accessors separately.
|
|
14
|
+
*
|
|
15
|
+
* @evidence contracts/development/implementation.md#principled-implementation Sparse count cannot exceed accessor count; unsigned index widths and padded matrix element sizes determine both payload ranges.
|
|
16
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure The sparse gate owns count, index format and subview range checks while shared element sizing owns matrix padding.
|
|
17
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Sparse layout is checked structurally but skin/motion consumers explicitly refuse sparse reading rather than inventing dense values.
|
|
18
|
+
* @evidence contracts/development/common.md#meaningful-documentation Prose explains admitted view indices, zero-default offsets, count bounds and consumer limitations.
|
|
19
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms One sparse accessor requires constant-size field checks and two range calculations independent of sparse element count.
|
|
20
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Subview metadata is read once per sparse payload; no byte decoding is performed or cached here.
|
|
21
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources The range gate creates temporary metadata references only and retains no payload, reader or handle.
|
|
22
|
+
*/
|
|
23
|
+
const validateSparseAccessor = (accessor, index, bufferViews) => {
|
|
24
|
+
if (accessor.sparse === undefined)
|
|
25
|
+
return;
|
|
26
|
+
const sparse = (0, object_1.object)(accessor.sparse, `accessors[${index}].sparse`);
|
|
27
|
+
(0, positiveInteger_1.positiveInteger)(sparse.count, `accessors[${index}].sparse.count`);
|
|
28
|
+
if (sparse.count > accessor.count)
|
|
29
|
+
throw new Error(`accessors[${index}].sparse.count exceeds the accessor count.`);
|
|
30
|
+
const indices = (0, object_1.object)(sparse.indices, `accessors[${index}].sparse.indices`);
|
|
31
|
+
const values = (0, object_1.object)(sparse.values, `accessors[${index}].sparse.values`);
|
|
32
|
+
(0, integerIndex_1.integerIndex)(indices.bufferView, bufferViews.length, `accessors[${index}].sparse.indices.bufferView`, true);
|
|
33
|
+
(0, integerIndex_1.integerIndex)(values.bufferView, bufferViews.length, `accessors[${index}].sparse.values.bufferView`, true);
|
|
34
|
+
if (indices.componentType !== 5121 &&
|
|
35
|
+
indices.componentType !== 5123 &&
|
|
36
|
+
indices.componentType !== 5125)
|
|
37
|
+
throw new Error(`accessors[${index}].sparse.indices.componentType must be unsigned byte, short or int.`);
|
|
38
|
+
const count = sparse.count;
|
|
39
|
+
validateSubViewRange(bufferViews, indices.bufferView, indices.byteOffset ?? 0, count * COMPONENT_BYTES_1.COMPONENT_BYTES.get(indices.componentType), `accessors[${index}].sparse.indices`);
|
|
40
|
+
validateSubViewRange(bufferViews, values.bufferView, values.byteOffset ?? 0, count *
|
|
41
|
+
(0, accessorElementByteLength_1.accessorElementByteLength)(accessor.componentType, accessor.type), `accessors[${index}].sparse.values`);
|
|
42
|
+
};
|
|
43
|
+
exports.validateSparseAccessor = validateSparseAccessor;
|
|
44
|
+
const validateSubViewRange = (bufferViews, viewIndex, offset, length, path) => {
|
|
45
|
+
(0, nonNegativeInteger_1.nonNegativeInteger)(offset, `${path}.byteOffset`);
|
|
46
|
+
const view = (0, object_1.object)(bufferViews[viewIndex], `bufferViews[${viewIndex}]`);
|
|
47
|
+
if (offset + length > view.byteLength)
|
|
48
|
+
throw new Error(`${path} exceeds its bufferView range.`);
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=validateSparseAccessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateSparseAccessor.js","sourceRoot":"","sources":["../../src/internal/validateSparseAccessor.ts"],"names":[],"mappings":";;;AAAA,uDAAoD;AACpD,2EAAwE;AACxE,iDAA8C;AAC9C,6DAA0D;AAC1D,qCAAkC;AAClC,uDAAoD;AAEpD;;;;;;;;;;;;GAYG;AACI,MAAM,sBAAsB,GAIvB,CACV,QAAiC,EACjC,KAAa,EACb,WAAsB,EAChB,EAAE;IACR,IAAI,QAAQ,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO;IAC1C,MAAM,MAAM,GAA4B,IAAA,eAAM,EAC5C,QAAQ,CAAC,MAAM,EACf,aAAa,KAAK,UAAU,CAC7B,CAAC;IACF,IAAA,iCAAe,EAAC,MAAM,CAAC,KAAK,EAAE,aAAa,KAAK,gBAAgB,CAAC,CAAC;IAClE,IAAK,MAAM,CAAC,KAAgB,GAAI,QAAQ,CAAC,KAAgB;QACvD,MAAM,IAAI,KAAK,CACb,aAAa,KAAK,4CAA4C,CAC/D,CAAC;IACJ,MAAM,OAAO,GAA4B,IAAA,eAAM,EAC7C,MAAM,CAAC,OAAO,EACd,aAAa,KAAK,kBAAkB,CACrC,CAAC;IACF,MAAM,MAAM,GAA4B,IAAA,eAAM,EAC5C,MAAM,CAAC,MAAM,EACb,aAAa,KAAK,iBAAiB,CACpC,CAAC;IACF,IAAA,2B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CAAC,UAAqB;QAC/C,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,gCAAgC,CAAC,CAAC;AAC7D,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { IHumanoidSlot } from "./IHumanoidSlot";
|
|
2
|
+
/**
|
|
3
|
+
* Read declared VRM humanoid mappings using version-specific thumb migration.
|
|
4
|
+
*
|
|
5
|
+
* VRMC_vrm takes precedence when both metadata families exist and emits recognized bone keys in code-unit order; VRM 0.x retains array order, migrates thumb names and rejects duplicate slots. Unknown names and invalid node indices throw, and absent metadata returns an empty list. VRMC_vrm is interpreted with 1.0 thumb names even for 1.0-beta declarations; this pass does not validate a complete VRM schema, unique target nodes or skin weights.
|
|
6
|
+
*
|
|
7
|
+
* @evidence contracts/development/implementation.md#principled-implementation VRMC_vrm uses named 1.0 slots and valid node indices; VRM 0.x maps renamed thumb slots and rejects duplicates.
|
|
8
|
+
* @evidence contracts/development/implementation.md#clear-and-simple-structure Version branching, thumb migration and the closed humanoid vocabulary stay with this metadata owner.
|
|
9
|
+
* @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts Unknown or dangling mappings throw; VRMC_vrm beta thumb conventions remain an explicit unresolved interpretation limit.
|
|
10
|
+
* @evidence contracts/development/common.md#meaningful-documentation The comment states metadata version branching, node references, ordering and unsupported beta interpretation.
|
|
11
|
+
* @evidence contracts/development/implementation.md#efficient-algorithms Work follows mapping entries and name text; 1.0 metadata enumerates B keys before O(B log B) prefix-scanning comparisons, while 0.x uses expected constant-time slot lookups after name admission.
|
|
12
|
+
* @evidence contracts/development/implementation.md#reuse-equivalent-work Each metadata mapping is resolved once during its inspector call; mutable documents prevent persistent equivalence caching.
|
|
13
|
+
* @evidence contracts/development/implementation.md#bound-retention-and-release-resources Result slot records scale with declared mappings; temporary entries and uniqueness sets die on return or throw.
|
|
14
|
+
*/
|
|
15
|
+
export declare const vrmHumanoidBones: (document: Record<string, unknown>, nodes: unknown[]) => IHumanoidSlot[];
|