@carbonenginejs/runtime-resource 0.8.0 → 0.9.1
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 -21
- package/NOTICE +31 -29
- package/README.md +67 -548
- package/dist/CjsMotherLode.js +1271 -1271
- package/dist/CjsResMan.js +3005 -3005
- package/dist/CjsResManQueue.js +214 -214
- package/dist/CjsResource.js +566 -566
- package/dist/CjsResourceSource.js +68 -59
- package/dist/CjsResourceSource.js.map +1 -1
- package/dist/_virtual/_rollupPluginBabelHelpers.js +153 -153
- package/dist/format/CjsBlueReader.js +269 -269
- package/dist/format/CjsFormat.js +197 -192
- package/dist/format/CjsFormat.js.map +1 -1
- package/dist/format/CjsReader.js +18 -18
- package/dist/format/CjsResourceProbe.js +277 -277
- package/dist/format/payloadContract.js +173 -173
- package/dist/formats/black/CjsBlackFormat.js +278 -278
- package/dist/formats/black/core/CjsBlackBinaryReader.js +157 -153
- package/dist/formats/black/core/CjsBlackBinaryReader.js.map +1 -1
- package/dist/formats/black/core/CjsBlackPropertyReaders.js +387 -382
- package/dist/formats/black/core/CjsBlackPropertyReaders.js.map +1 -1
- package/dist/formats/black/core/CjsBlackReader.js +639 -639
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js +437 -433
- package/dist/formats/black/core/CjsBlackSchemaRegistry.js.map +1 -1
- package/dist/formats/black/core/black-schema-v1-2026-07-23.json.js +4 -0
- package/dist/formats/black/core/black-schema-v1-2026-07-23.json.js.map +1 -0
- package/dist/formats/black/core/blackConstants.js +7 -7
- package/dist/formats/black/core/blackDefinitions.js +10 -10
- package/dist/formats/black/core/blackDefinitions.js.map +1 -1
- package/dist/formats/black/core/blackEnums.js +6 -6
- package/dist/formats/black/core/blackSchema.js +3 -3
- package/dist/formats/black/core/blackVersion.js +22 -22
- package/dist/formats/black/core/helpers.js +182 -182
- package/dist/formats/black/core/schema.js +4 -4
- package/dist/formats/black/index.js +2 -2
- package/dist/formats/bnk/CjsBnkFormat.js +125 -125
- package/dist/formats/bnk/core/graph.js +140 -140
- package/dist/formats/bnk/core/helpers.js +409 -409
- package/dist/formats/bnk/core/musicNodes.js +493 -489
- package/dist/formats/bnk/core/musicNodes.js.map +1 -1
- package/dist/formats/bnk/core/soundbanksInfo.js +246 -246
- package/dist/formats/bnk/index.js +2 -2
- package/dist/formats/cmf/CjsCmfFormat.js +497 -497
- package/dist/formats/cmf/core/binary.js +123 -118
- package/dist/formats/cmf/core/binary.js.map +1 -1
- package/dist/formats/cmf/core/buffers.js +233 -233
- package/dist/formats/cmf/core/constants.js +47 -47
- package/dist/formats/cmf/core/gr2Anim.js +453 -453
- package/dist/formats/cmf/core/helpers.js +287 -287
- package/dist/formats/cmf/core/pack.js +276 -276
- package/dist/formats/cmf/core/schema.js +364 -364
- package/dist/formats/cmf/core/shared.js +268 -268
- package/dist/formats/cmf/core/writer.js +517 -517
- package/dist/formats/cmf/index.js +2 -2
- package/dist/formats/dds/CjsDdsFormat.js +200 -193
- package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
- package/dist/formats/dds/core/bc6h.js +288 -288
- package/dist/formats/dds/core/bc7.js +256 -251
- package/dist/formats/dds/core/bc7.js.map +1 -1
- package/dist/formats/dds/core/helpers.js +815 -815
- package/dist/formats/dds/index.js +2 -2
- package/dist/formats/fbx/CjsFbxFormat.js +266 -266
- package/dist/formats/fbx/core/helpers.js +3911 -3901
- package/dist/formats/fbx/core/helpers.js.map +1 -1
- package/dist/formats/fbx/index.js +2 -2
- package/dist/formats/flac/CjsFlacFormat.js +93 -87
- package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
- package/dist/formats/flac/core/helpers.js +295 -295
- package/dist/formats/flac/index.js +2 -2
- package/dist/formats/gif/CjsGifFormat.js +92 -87
- package/dist/formats/gif/CjsGifFormat.js.map +1 -1
- package/dist/formats/gif/core/helpers.js +360 -360
- package/dist/formats/gif/index.js +2 -2
- package/dist/formats/gltf/CjsGltfFormat.js +290 -290
- package/dist/formats/gltf/core/helpers.js +292 -292
- package/dist/formats/gltf/core/json.js +79 -79
- package/dist/formats/gltf/core/parser.js +666 -666
- package/dist/formats/gltf/core/targets.js +163 -163
- package/dist/formats/gltf/index.js +2 -2
- package/dist/formats/gr2/CjsGr2Format.js +46 -0
- package/dist/formats/gr2/CjsGr2Format.js.map +1 -0
- package/dist/formats/gr2/core/CjsFormatGr2.js +273 -0
- package/dist/formats/gr2/core/CjsFormatGr2.js.map +1 -0
- package/dist/formats/gr2/core/bitknit2.js +280 -0
- package/dist/formats/gr2/core/bitknit2.js.map +1 -0
- package/dist/formats/gr2/core/curves.js +1047 -0
- package/dist/formats/gr2/core/curves.js.map +1 -0
- package/dist/formats/gr2/core/gsf.js +72 -0
- package/dist/formats/gr2/core/gsf.js.map +1 -0
- package/dist/formats/gr2/core/helpers.js +332 -0
- package/dist/formats/gr2/core/helpers.js.map +1 -0
- package/dist/formats/gr2/core/json.js +622 -0
- package/dist/formats/gr2/core/json.js.map +1 -0
- package/dist/formats/gr2/core/oodle1.js +388 -0
- package/dist/formats/gr2/core/oodle1.js.map +1 -0
- package/dist/formats/gr2/core/reader.js +617 -0
- package/dist/formats/gr2/core/reader.js.map +1 -0
- package/dist/formats/gr2/core/tangents.js +48 -0
- package/dist/formats/gr2/core/tangents.js.map +1 -0
- package/dist/formats/gr2/core/targets.js +351 -0
- package/dist/formats/gr2/core/targets.js.map +1 -0
- package/dist/formats/gr2/index.js +3 -0
- package/dist/formats/gr2/index.js.map +1 -0
- package/dist/formats/index.js +30 -23
- package/dist/formats/index.js.map +1 -1
- package/dist/formats/jpeg/CjsJpegFormat.js +212 -206
- package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
- package/dist/formats/jpeg/core/helpers.js +350 -350
- package/dist/formats/jpeg/core/jpeg.js +387 -377
- package/dist/formats/jpeg/core/jpeg.js.map +1 -1
- package/dist/formats/jpeg/index.js +2 -2
- package/dist/formats/mp3/CjsMp3Format.js +197 -192
- package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
- package/dist/formats/mp3/core/helpers.js +338 -338
- package/dist/formats/mp3/index.js +2 -2
- package/dist/formats/mp4/CjsMp4Format.js +197 -191
- package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
- package/dist/formats/mp4/core/helpers.js +449 -449
- package/dist/formats/mp4/index.js +2 -2
- package/dist/formats/obj/CjsObjFormat.js +253 -253
- package/dist/formats/obj/core/helpers.js +573 -573
- package/dist/formats/obj/core/json.js +64 -64
- package/dist/formats/obj/core/parser.js +321 -321
- package/dist/formats/obj/index.js +2 -2
- package/dist/formats/ogg/CjsOggFormat.js +94 -88
- package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
- package/dist/formats/ogg/core/helpers.js +387 -387
- package/dist/formats/ogg/core/imdct.js +178 -178
- package/dist/formats/ogg/core/vorbis.js +1004 -999
- package/dist/formats/ogg/core/vorbis.js.map +1 -1
- package/dist/formats/ogg/index.js +2 -2
- package/dist/formats/png/CjsPngFormat.js +201 -195
- package/dist/formats/png/CjsPngFormat.js.map +1 -1
- package/dist/formats/png/core/helpers.js +583 -583
- package/dist/formats/png/index.js +2 -2
- package/dist/formats/red/CjsRedFormat.js +261 -261
- package/dist/formats/red/core/CjsRedReader.js +194 -194
- package/dist/formats/red/core/blackDefinitions.js +3 -3
- package/dist/formats/red/core/helpers.js +139 -139
- package/dist/formats/red/core/redGraph.js +68 -68
- package/dist/formats/red/core/schema.js +4 -4
- package/dist/formats/red/index.js +2 -2
- package/dist/formats/stl/CjsStlFormat.js +365 -365
- package/dist/formats/stl/core/helpers.js +261 -261
- package/dist/formats/stl/core/json.js +51 -51
- package/dist/formats/stl/core/stl.js +634 -629
- package/dist/formats/stl/core/stl.js.map +1 -1
- package/dist/formats/stl/core/targets.js +163 -163
- package/dist/formats/stl/index.js +2 -2
- package/dist/formats/tga/CjsTgaFormat.js +197 -192
- package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
- package/dist/formats/tga/core/helpers.js +446 -446
- package/dist/formats/tga/index.js +2 -2
- package/dist/formats/wav/CjsWavFormat.js +198 -192
- package/dist/formats/wav/CjsWavFormat.js.map +1 -1
- package/dist/formats/wav/core/helpers.js +328 -328
- package/dist/formats/wav/index.js +2 -2
- package/dist/formats/webm/CjsWebmFormat.js +197 -191
- package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
- package/dist/formats/webm/core/helpers.js +537 -537
- package/dist/formats/webm/index.js +2 -2
- package/dist/formats/webp/CjsWebpFormat.js +91 -86
- package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
- package/dist/formats/webp/core/helpers.js +214 -214
- package/dist/formats/webp/index.js +2 -2
- package/dist/formats/wem/CjsWemFormat.js +242 -241
- package/dist/formats/wem/CjsWemFormat.js.map +1 -1
- package/dist/formats/wem/core/bitStream.js +259 -259
- package/dist/formats/wem/core/codebookLibrary.js +164 -164
- package/dist/formats/wem/core/helpers.js +417 -417
- package/dist/formats/wem/core/packedCodebooksAotuv603.js +30 -30
- package/dist/formats/wem/core/ptadpcm.js +77 -77
- package/dist/formats/wem/core/resolve.js +121 -121
- package/dist/formats/wem/core/wemToOgg.js +485 -485
- package/dist/formats/wem/index.js +2 -2
- package/dist/formats/yaml/CjsYamlFormat.js +89 -83
- package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
- package/dist/formats/yaml/core/CjsYamlReader.js +311 -305
- package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
- package/dist/formats/yaml/core/helpers.js +160 -160
- package/dist/formats/yaml/index.js +2 -2
- package/dist/index.js +49 -48
- package/dist/index.js.map +1 -1
- package/dist/resourcePath.js +18 -18
- package/dist/resourceStates.js +9 -9
- package/dist/resources/AudioGeometryResData.js +47 -47
- package/dist/resources/GStateBindingCallbackData.js +31 -31
- package/dist/resources/MeshDecalData.js +37 -37
- package/dist/resources/MeshDecalLodData.js +34 -34
- package/dist/resources/Tr2EffectRes.js +71 -71
- package/dist/resources/Tr2GrannyIntersectionResult.js +60 -60
- package/dist/resources/Tr2GrannyStateRes.js +44 -44
- package/dist/resources/Tr2ImageRes.js +114 -114
- package/dist/resources/Tr2LightProfileRes.js +40 -40
- package/dist/resources/Tr2MaterialArea.js +34 -34
- package/dist/resources/Tr2MaterialMesh.js +31 -31
- package/dist/resources/Tr2MaterialRes.js +34 -34
- package/dist/resources/Tr2ShaderPermutation.js +43 -43
- package/dist/resources/Tr2TextureLodManager.js +80 -80
- package/dist/resources/Tr2TextureLodUpdateRequest.js +37 -37
- package/dist/resources/Tr2TexturePackChannel.js +37 -37
- package/dist/resources/Tr2TexturePipeline.js +52 -52
- package/dist/resources/Tr2TexturePipelineParams.js +34 -34
- package/dist/resources/Tr2TexturePipelineStepCompress.js +40 -40
- package/dist/resources/Tr2TexturePipelineStepGenerateMips.js +22 -0
- package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
- package/dist/resources/Tr2TexturePipelineStepLimitSize.js +34 -34
- package/dist/resources/Tr2TexturePipelineStepLoad.js +31 -31
- package/dist/resources/Tr2TexturePipelineStepPack.js +43 -43
- package/dist/resources/TriGeometryRes.js +239 -239
- package/dist/resources/TriGeometryResAreaData.js +59 -59
- package/dist/resources/TriGeometryResJointData.js +38 -38
- package/dist/resources/TriGeometryResLodData.js +88 -88
- package/dist/resources/TriGeometryResMeshData.js +63 -63
- package/dist/resources/TriGeometryResSkeletonData.js +34 -34
- package/dist/resources/TriGrannyRes.js +43 -43
- package/dist/resources/TriJointBinding.js +38 -38
- package/dist/resources/TriMorphTargetGeometryConstants.js +46 -46
- package/dist/resources/TriRtGeometryConstants.js +88 -88
- package/dist/resources/TriTextureRes.js +304 -304
- package/dist/resources/enums.js +18 -18
- package/dist/resources/resourceBoundary.js +47 -47
- package/dist/resources/texturePipelineBehavior.js +308 -308
- package/dist/texture/CjsTextureArrayRes.js +406 -406
- package/dist/texture/CjsTextureParameterProxy.js +133 -133
- package/docs/README.md +73 -0
- package/docs/architecture.md +86 -0
- package/docs/concepts/resource-lifecycle.md +217 -0
- package/docs/formats/README.md +105 -0
- package/docs/formats/gr2.md +161 -0
- package/{FORMAT-PROVENANCE.md → docs/formats/provenance.md} +173 -155
- package/docs/formats/stl.md +37 -0
- package/docs/formats/wwise.md +44 -0
- package/docs/reference/classes/README.md +33 -0
- package/docs/reference/classes/core.md +106 -0
- package/docs/reference/classes/dropped.md +46 -0
- package/docs/reference/classes/formats.md +522 -0
- package/docs/reference/classes/resources.md +346 -0
- package/docs/reference/classes/texture.md +26 -0
- package/docs/reference/events.md +92 -0
- package/docs/reference/motherlode-cache.md +244 -0
- package/docs/reference/queues.md +102 -0
- package/docs/reference/reload.md +107 -0
- package/docs/reference/texture-arrays.md +113 -0
- package/docs/reference/texture-pipeline.md +53 -0
- package/docs/roadmap.md +104 -0
- package/format-notices/black/LICENSE +21 -21
- package/format-notices/black/NOTICE +47 -47
- package/format-notices/bnk/LICENSE +21 -21
- package/format-notices/bnk/NOTICE +20 -20
- package/format-notices/cmf/LICENSE +21 -21
- package/format-notices/cmf/NOTICE +36 -36
- package/format-notices/dds/LICENSE +21 -21
- package/format-notices/dds/NOTICE +14 -14
- package/format-notices/fbx/LICENSE +21 -21
- package/format-notices/fbx/NOTICE +14 -14
- package/format-notices/flac/LICENSE +21 -21
- package/format-notices/flac/NOTICE +14 -14
- package/format-notices/gif/LICENSE +21 -21
- package/format-notices/gif/NOTICE +14 -14
- package/format-notices/gltf/LICENSE +21 -21
- package/format-notices/gltf/NOTICE +27 -27
- package/format-notices/gr2/LICENSE +21 -0
- package/format-notices/gr2/NOTICE +60 -0
- package/format-notices/gr2/THIRD-PARTY-NOTICES.md +93 -0
- package/format-notices/jpeg/LICENSE +21 -21
- package/format-notices/jpeg/NOTICE +14 -14
- package/format-notices/mp3/LICENSE +21 -21
- package/format-notices/mp3/NOTICE +14 -14
- package/format-notices/mp4/LICENSE +21 -21
- package/format-notices/mp4/NOTICE +14 -14
- package/format-notices/obj/LICENSE +21 -21
- package/format-notices/obj/NOTICE +26 -26
- package/format-notices/ogg/LICENSE +21 -21
- package/format-notices/ogg/NOTICE +28 -28
- package/format-notices/png/LICENSE +21 -21
- package/format-notices/png/NOTICE +14 -14
- package/format-notices/red/LICENSE +21 -21
- package/format-notices/red/NOTICE +31 -31
- package/format-notices/stl/LICENSE +21 -21
- package/format-notices/stl/NOTICE +21 -21
- package/format-notices/tga/LICENSE +21 -21
- package/format-notices/tga/NOTICE +14 -14
- package/format-notices/wav/LICENSE +21 -21
- package/format-notices/wav/NOTICE +14 -14
- package/format-notices/webm/LICENSE +21 -21
- package/format-notices/webm/NOTICE +14 -14
- package/format-notices/webp/LICENSE +21 -21
- package/format-notices/webp/NOTICE +14 -14
- package/format-notices/wem/LICENSE +57 -57
- package/format-notices/wem/NOTICE +33 -33
- package/format-notices/yaml/LICENSE +21 -21
- package/format-notices/yaml/NOTICE +44 -44
- package/package.json +52 -51
- package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js +0 -4
- package/dist/formats/black/core/black-schema-v1-2026-07-11.json.js.map +0 -1
- package/resource-lifecycle.md +0 -679
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curves.js","sources":["../../../../../src/formats/gr2/core/curves.js"],"sourcesContent":["/**\n * Granny animation-curve decompression helpers\n * `decodeCurve(curveJson, dimension)` takes a GR2 JSON curve object in the\n * shape emitted by PrintCurve2 and returns explicit knots and controls.\n */\n\n/** Format id for raw float keyframes with implicit knots. */\nexport const FORMAT_DA_KEYFRAMES_32F = 0;\n\n/** Format id for uncompressed float knots and float controls. */\nexport const FORMAT_DA_K32F_C32F = 1;\n\n/** Format id for an identity transform curve. */\nexport const FORMAT_DA_IDENTITY = 2;\n\n/** Format id for a constant float control vector. */\nexport const FORMAT_DA_CONSTANT_32F = 3;\n\n/** Format id for a constant vec3 control. */\nexport const FORMAT_D3_CONSTANT_32F = 4;\n\n/** Format id for a constant quaternion control. */\nexport const FORMAT_D4_CONSTANT_32F = 5;\n\n/** Format id for uint16 DaK packed knots and controls. */\nexport const FORMAT_DA_K16U_C16U = 6;\n\n/** Format id for uint8 DaK packed knots and controls. */\nexport const FORMAT_DA_K8U_C8U = 7;\n\n/** Format id for uint16 normalized quaternion curves with 15-bit controls. */\nexport const FORMAT_D4N_K16U_C15U = 8;\n\n/** Format id for uint8 normalized quaternion curves with 7-bit controls. */\nexport const FORMAT_D4N_K8U_C7U = 9;\n\n/** Format id for uint16 vec3 position curves. */\nexport const FORMAT_D3_K16U_C16U = 10;\n\n/** Format id for uint8 vec3 position curves. */\nexport const FORMAT_D3_K8U_C8U = 11;\n\n/** Format id for uint16 uniform scale/shear curves. */\nexport const FORMAT_D9I1_K16U_C16U = 12;\n\n/** Format id for uint16 per-axis scale/shear curves. */\nexport const FORMAT_D9I3_K16U_C16U = 13;\n\n/** Format id for uint8 uniform scale/shear curves. */\nexport const FORMAT_D9I1_K8U_C8U = 14;\n\n/** Format id for uint8 per-axis scale/shear curves. */\nexport const FORMAT_D9I3_K8U_C8U = 15;\n\n/** Format id for float D3I1 line-parameterized vec3 curves. */\nexport const FORMAT_D3I1_K32F_C32F = 16;\n\n/** Format id for uint16 D3I1 line-parameterized vec3 curves. */\nexport const FORMAT_D3I1_K16U_C16U = 17;\n\n/** Format id for uint8 D3I1 line-parameterized vec3 curves. */\nexport const FORMAT_D3I1_K8U_C8U = 18;\n\n/**\n * Granny curve format ids keyed by descriptive uppercase names.\n */\nexport const CURVE_FORMATS = Object.freeze({\n DA_KEYFRAMES_32F: FORMAT_DA_KEYFRAMES_32F,\n DA_K32F_C32F: FORMAT_DA_K32F_C32F,\n DA_IDENTITY: FORMAT_DA_IDENTITY,\n DA_CONSTANT_32F: FORMAT_DA_CONSTANT_32F,\n D3_CONSTANT_32F: FORMAT_D3_CONSTANT_32F,\n D4_CONSTANT_32F: FORMAT_D4_CONSTANT_32F,\n DA_K16U_C16U: FORMAT_DA_K16U_C16U,\n DA_K8U_C8U: FORMAT_DA_K8U_C8U,\n D4N_K16U_C15U: FORMAT_D4N_K16U_C15U,\n D4N_K8U_C7U: FORMAT_D4N_K8U_C7U,\n D3_K16U_C16U: FORMAT_D3_K16U_C16U,\n D3_K8U_C8U: FORMAT_D3_K8U_C8U,\n D9I1_K16U_C16U: FORMAT_D9I1_K16U_C16U,\n D9I3_K16U_C16U: FORMAT_D9I3_K16U_C16U,\n D9I1_K8U_C8U: FORMAT_D9I1_K8U_C8U,\n D9I3_K8U_C8U: FORMAT_D9I3_K8U_C8U,\n D3I1_K32F_C32F: FORMAT_D3I1_K32F_C32F,\n D3I1_K16U_C16U: FORMAT_D3I1_K16U_C16U,\n D3I1_K8U_C8U: FORMAT_D3I1_K8U_C8U\n});\n\n/**\n * Float32 rounding helper used to mirror the reference curve decoders.\n *\n * The reference implementation stores every decoded value into Float32Array\n * buffers, so this helper applies the same rounding at each write.\n */\nexport const fr = Math.fround;\n\n/**\n * Granny stores 1/knotScale as the top 16 bits of the float only\n * (\"OneOverKnotScaleTrunc\"). Reconstruct the float32.\n * @param {number} oneOverKnotScaleTrunc uint16\n * @returns {number}\n */\nexport function knotScaleFromTrunc(oneOverKnotScaleTrunc)\n{\n const u = new Uint32Array([ oneOverKnotScaleTrunc << 16 ]);\n return new Float32Array(u.buffer)[0];\n}\n\n/**\n * Expand the leading `count` entries of a knotsControls array into knots.\n * @param {ArrayLike<number>} knotsControls\n * @param {number} count\n * @param {number} scale divisor (1/knotScale)\n * @returns {number[]}\n */\nexport function knotsFromControls(knotsControls, count, scale)\n{\n const out = new Array(count);\n for (let i = 0; i < count; i++)\n {\n out[i] = fr(knotsControls[i] / scale);\n }\n return out;\n}\n\n/**\n * Knots via the truncated knot scale.\n *\n * @param {ArrayLike<number>} knotsControls Packed knot/control array.\n * @param {number} count Number of knots at the front of `knotsControls`.\n * @param {number} oneOverKnotScaleTrunc Truncated reciprocal knot scale.\n * @returns {number[]} Decoded knot times.\n */\nexport function knotsFromControlsTrunc(knotsControls, count, oneOverKnotScaleTrunc)\n{\n return knotsFromControls(knotsControls, count, knotScaleFromTrunc(oneOverKnotScaleTrunc));\n}\n\n/**\n * Identity control vector for a track dimension.\n * @param {number} dimension 3 (position), 4 (quaternion) or 9 (mat3)\n * @returns {number[]}\n */\nexport function identityControls(dimension)\n{\n switch (dimension)\n {\n case 3:\n return [ 0, 0, 0 ];\n\n case 4:\n return [ 0, 0, 0, 1 ];\n\n case 9:\n return [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\n default:\n throw new Error(`gr2reader: invalid curve dimension ${dimension}`);\n }\n}\n\n/**\n * Ensure a divisibility relation holds; throws with a descriptive error.\n *\n * @param {number} numerator Value expected to divide evenly.\n * @param {number} divisor Divisor to check against.\n * @param {string} what Human-readable operation name for the error message.\n * @returns {number} Exact quotient.\n * @throws {Error} If the quotient is not an integer.\n */\nexport function exactDiv(numerator, divisor, what)\n{\n const v = numerator / divisor;\n if (!Number.isInteger(v))\n {\n throw new Error(`gr2reader: curve ${what}: ${numerator} is not divisible by ${divisor}`);\n }\n return v;\n}\n\n/**\n * Decode raw keyframe controls with implicit knots `0..n-1`.\n *\n * @param {object} c Curve object with `controls` and optional `dimension`.\n * @param {number} dimension Fallback control-vector width.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeDaKeyframes32f(c, dimension)\n{\n const\n dim = c.dimension || dimension,\n controls = c.controls || [],\n count = exactDiv(controls.length, dim, \"DaKeyframes32f controls/dimension\"),\n knots = new Array(count);\n for (let i = 0; i < count; i++)\n {\n knots[i] = i;\n }\n return { knots, controls: controls.map(fr), dimension: dim };\n}\n\n/**\n * Decode uncompressed float knots and float controls.\n *\n * @param {object} c Curve object with `knots` and `controls`.\n * @param {number} dimension Fallback control-vector width when no knots exist.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeDaK32fC32f(c, dimension)\n{\n const\n knots = (c.knots || []).map(fr),\n controls = (c.controls || []).map(fr),\n dim = knots.length ? exactDiv(controls.length, knots.length, \"DaK32fC32f controls/knots\") : dimension;\n return { knots, controls, dimension: dim };\n}\n\n/**\n * Decode an identity transform curve for the requested track dimension.\n *\n * @param {object} c Curve object with optional `dimension`.\n * @param {number} dimension Fallback control-vector width.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeDaIdentity(c, dimension)\n{\n const dim = c.dimension || dimension;\n return { knots: [ 0 ], controls: identityControls(dim), dimension: dim };\n}\n\n/**\n * Decode a constant float control vector.\n *\n * @param {object} c Curve object with `controls`.\n * @param {number} dimension Fallback control-vector width.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeDaConstant32f(c, dimension)\n{\n const controls = (c.controls || []).map(fr);\n return { knots: [ 0 ], controls, dimension: controls.length || dimension };\n}\n\n/**\n * Decode a constant vec3 control.\n *\n * @param {object} c Curve object with optional `controls`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD3Constant32f(c)\n{\n const controls = (c.controls || [ 0, 0, 0 ]).slice(0, 3).map(fr);\n return { knots: [ 0 ], controls, dimension: 3 };\n}\n\n/**\n * Decode a constant quaternion control.\n *\n * @param {object} c Curve object with optional `controls`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD4Constant32f(c)\n{\n const controls = (c.controls || [ 0, 0, 0, 1 ]).slice(0, 4).map(fr);\n return { knots: [ 0 ], controls, dimension: 4 };\n}\n\n/**\n * Decode a DaK packed knot/control curve using uint16 payload values.\n *\n * @param {object} c Curve object with `knotsControls`, `controlScaleOffsets`,\n * and `oneOverKnotScaleTrunc`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeDaK(c)\n{\n const\n so = c.controlScaleOffsets || [],\n kc = c.knotsControls || [],\n dim = exactDiv(so.length, 2, \"DaK controlScaleOffsets/2\"),\n count = exactDiv(kc.length, dim + 1, \"DaK knotsControls/(dim+1)\"),\n knots = knotsFromControlsTrunc(kc, count, c.oneOverKnotScaleTrunc),\n controls = new Array(count * dim);\n for (let i = 0; i < count; i++)\n {\n for (let x = 0; x < dim; x++)\n {\n controls[i * dim + x] = fr(kc[count + i * dim + x] * so[x] + so[dim + x]);\n }\n }\n return { knots, controls, dimension: dim };\n}\n\n/** Scale lookup table for D4n normalized quaternion controls. */\nexport const D4N_SCALE_TABLE = new Float32Array([\n 1.4142135, 0.70710677, 0.35355338, 0.35355338,\n 0.35355338, 0.17677669, 0.17677669, 0.17677669,\n -1.4142135, -0.70710677, -0.35355338, -0.35355338,\n -0.35355338, -0.17677669, -0.17677669, -0.17677669\n]);\n\n/** Offset lookup table for D4n normalized quaternion controls. */\nexport const D4N_OFFSET_TABLE = new Float32Array([\n -0.70710677, -0.35355338, -0.53033006, -0.17677669,\n 0.17677669, -0.17677669, -0.088388346, 0.0,\n 0.70710677, 0.35355338, 0.53033006, 0.17677669,\n -0.17677669, 0.17677669, 0.088388346, -0.0\n]);\n\n/**\n * Decode one 16-bit control triple into a quaternion (matches ccpwgl\n * Gr2CurveDataD4nK16uC15u.GetQuatFromControl).\n *\n * @param {number[]} out Mutable quaternion output buffer.\n * @param {number} a First packed control value.\n * @param {number} b Second packed control value.\n * @param {number} c Third packed control value.\n * @param {ArrayLike<number>} scales Four scale values selected from the table.\n * @param {ArrayLike<number>} offsets Four offset values selected from the table.\n * @returns {number[]} The same `out` quaternion buffer.\n */\nexport function quatFromControl16(out, a, b, c, scales, offsets)\n{\n const\n swizzle1 = ((b & 0x8000) >> 14) | (c >> 15),\n swizzle2 = (swizzle1 + 1) & 3,\n swizzle3 = (swizzle2 + 1) & 3,\n swizzle4 = (swizzle3 + 1) & 3;\n\n const\n dataA = (a & 0x7fff) * scales[swizzle2] + offsets[swizzle2],\n dataB = (b & 0x7fff) * scales[swizzle3] + offsets[swizzle3],\n dataC = (c & 0x7fff) * scales[swizzle4] + offsets[swizzle4];\n\n let dataD = Math.sqrt(Math.max(0, 1 - (dataA * dataA + dataB * dataB + dataC * dataC)));\n if ((a & 0x8000) !== 0) dataD = -dataD;\n\n out[swizzle2] = fr(dataA);\n out[swizzle3] = fr(dataB);\n out[swizzle4] = fr(dataC);\n out[swizzle1] = fr(dataD);\n return out;\n}\n\n/** Scale-table multiplier for D4n 16-bit knot / 15-bit control curves. */\nexport const D4N_SCALE_TABLE_MULTIPLIER_16 = 0.000030518509;\n\n/**\n * Decode a D4n normalized quaternion curve using a supplied control decoder.\n *\n * @param {object} c Curve object with `knotsControls`, `scaleOffsetTableEntries`,\n * and `oneOverKnotScale`.\n * @param {Function} quatFromControl Function that expands one packed control\n * triple into a quaternion.\n * @param {number} scaleTableMultiplier Multiplier for selected scale table entries.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD4n(c, quatFromControl, scaleTableMultiplier)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 4, \"D4n knotsControls/4\"),\n knots = knotsFromControls(kc, count, c.oneOverKnotScale);\n\n const\n selector = c.scaleOffsetTableEntries >>> 0,\n scales = new Float32Array([\n D4N_SCALE_TABLE[(selector >> 0) & 0x0f] * scaleTableMultiplier,\n D4N_SCALE_TABLE[(selector >> 4) & 0x0f] * scaleTableMultiplier,\n D4N_SCALE_TABLE[(selector >> 8) & 0x0f] * scaleTableMultiplier,\n D4N_SCALE_TABLE[(selector >> 12) & 0x0f] * scaleTableMultiplier\n ]),\n offsets = new Float32Array([\n D4N_OFFSET_TABLE[(selector >> 0) & 0x0f],\n D4N_OFFSET_TABLE[(selector >> 4) & 0x0f],\n D4N_OFFSET_TABLE[(selector >> 8) & 0x0f],\n D4N_OFFSET_TABLE[(selector >> 12) & 0x0f]\n ]);\n\n const\n controls = new Array(count * 4),\n quat = [ 0, 0, 0, 1 ];\n\n for (let i = 0; i < count; i++)\n {\n quatFromControl(quat, kc[count + i * 3], kc[count + i * 3 + 1], kc[count + i * 3 + 2], scales, offsets);\n controls[i * 4] = quat[0];\n controls[i * 4 + 1] = quat[1];\n controls[i * 4 + 2] = quat[2];\n controls[i * 4 + 3] = quat[3];\n }\n\n return { knots, controls, dimension: 4 };\n}\n\n/**\n * Decode a D4n curve using 16-bit knots and 15-bit quaternion controls.\n *\n * @param {object} c Curve object with packed quaternion data.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD4nK16uC15u(c)\n{\n return decodeD4n(c, quatFromControl16, D4N_SCALE_TABLE_MULTIPLIER_16);\n}\n\n/** Scale-table multiplier for D4n 8-bit knot / 7-bit control curves. */\nexport const D4N_SCALE_TABLE_MULTIPLIER_8 = 0.0078740157;\n\n/**\n * Decode one 8-bit control triple into a quaternion.\n *\n * @param {number[]} out Mutable quaternion output buffer.\n * @param {number} a First packed control value.\n * @param {number} b Second packed control value.\n * @param {number} c Third packed control value.\n * @param {ArrayLike<number>} scales Four scale values selected from the table.\n * @param {ArrayLike<number>} offsets Four offset values selected from the table.\n * @returns {number[]} The same `out` quaternion buffer.\n */\nexport function quatFromControl8(out, a, b, c, scales, offsets)\n{\n const\n swizzle1 = ((b & 0x80) >> 6) | ((c & 0x80) >> 7),\n swizzle2 = (swizzle1 + 1) & 3,\n swizzle3 = (swizzle2 + 1) & 3,\n swizzle4 = (swizzle3 + 1) & 3;\n\n const\n dataA = (a & 0x7f) * scales[swizzle2] + offsets[swizzle2],\n dataB = (b & 0x7f) * scales[swizzle3] + offsets[swizzle3],\n dataC = (c & 0x7f) * scales[swizzle4] + offsets[swizzle4];\n\n let dataD = Math.sqrt(Math.max(0, 1 - (dataA * dataA + dataB * dataB + dataC * dataC)));\n if ((a & 0x80) !== 0) dataD = -dataD;\n\n out[swizzle2] = fr(dataA);\n out[swizzle3] = fr(dataB);\n out[swizzle4] = fr(dataC);\n out[swizzle1] = fr(dataD);\n return out;\n}\n\n/**\n * Decode a D4n curve using 8-bit knots and 7-bit quaternion controls.\n *\n * @param {object} c Curve object with packed quaternion data.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD4nK8uC7u(c)\n{\n return decodeD4n(c, quatFromControl8, D4N_SCALE_TABLE_MULTIPLIER_8);\n}\n\n/**\n * Decode a D3K packed vec3 curve using uint16 payload values.\n *\n * @param {object} c Curve object with `knotsControls`, `controlScales`,\n * `controlOffsets`, and `oneOverKnotScaleTrunc`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD3K(c)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 4, \"D3K knotsControls/4\"),\n knots = knotsFromControlsTrunc(kc, count, c.oneOverKnotScaleTrunc),\n scales = c.controlScales,\n offsets = c.controlOffsets,\n controls = new Array(count * 3);\n\n for (let i = 0; i < count; i++)\n {\n for (let x = 0; x < 3; x++)\n {\n controls[i * 3 + x] = fr(kc[count + i * 3 + x] * scales[x] + offsets[x]);\n }\n }\n\n return { knots, controls, dimension: 3 };\n}\n\n/**\n * Decode a D9I1 uniform scale/shear curve.\n *\n * @param {object} c Curve object with `knotsControls`, scalar scale/offset\n * fields, and `oneOverKnotScaleTrunc`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD9I1(c)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 2, \"D9I1 knotsControls/2\"),\n knots = knotsFromControlsTrunc(kc, count, c.oneOverKnotScaleTrunc);\n\n const\n scale = Array.isArray(c.controlScales) ? c.controlScales[0] : c.controlScale,\n offset = Array.isArray(c.controlOffsets) ? c.controlOffsets[0] : c.controlOffset,\n controls = new Array(count * 9).fill(0);\n\n for (let i = 0; i < count; i++)\n {\n const s = fr(kc[count + i] * scale + offset);\n controls[i * 9] = s;\n controls[i * 9 + 4] = s;\n controls[i * 9 + 8] = s;\n }\n\n return { knots, controls, dimension: 9 };\n}\n\n/**\n * Decode a D9I3 per-axis scale/shear curve.\n *\n * @param {object} c Curve object with `knotsControls`, `controlScales`,\n * `controlOffsets`, and `oneOverKnotScaleTrunc`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD9I3(c)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 4, \"D9I3 knotsControls/4\"),\n knots = knotsFromControlsTrunc(kc, count, c.oneOverKnotScaleTrunc),\n scales = c.controlScales,\n offsets = c.controlOffsets,\n controls = new Array(count * 9).fill(0);\n\n for (let i = 0; i < count; i++)\n {\n controls[i * 9] = fr(kc[count + i * 3] * scales[0] + offsets[0]);\n controls[i * 9 + 4] = fr(kc[count + i * 3 + 1] * scales[1] + offsets[1]);\n controls[i * 9 + 8] = fr(kc[count + i * 3 + 2] * scales[2] + offsets[2]);\n }\n\n return { knots, controls, dimension: 9 };\n}\n\n/**\n * Expand one scalar per knot into vec3 controls for the D3I1 family.\n *\n * @param {ArrayLike<number>} kc Packed knots followed by scalar controls.\n * @param {number} count Number of knots and scalar controls.\n * @param {ArrayLike<number>} scales vec3 component scales.\n * @param {ArrayLike<number>} offsets vec3 component offsets.\n * @returns {number[]} Flat vec3 controls.\n */\nexport function d3I1Controls(kc, count, scales, offsets)\n{\n const controls = new Array(count * 3);\n\n for (let i = 0; i < count; i++)\n {\n const v = kc[count + i];\n controls[i * 3] = fr(v * scales[0] + offsets[0]);\n controls[i * 3 + 1] = fr(v * scales[1] + offsets[1]);\n controls[i * 3 + 2] = fr(v * scales[2] + offsets[2]);\n }\n\n return controls;\n}\n\n/**\n * Decode a D3I1 curve with float knots and scalar float controls.\n *\n * @param {object} c Curve object with `knotsControls`, `controlScales`, and\n * `controlOffsets`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD3I1K32fC32f(c)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 2, \"D3I1K32f knotsControls/2\"),\n knots = new Array(count);\n\n for (let i = 0; i < count; i++)\n {\n knots[i] = fr(kc[i]);\n }\n\n return {\n knots,\n controls: d3I1Controls(kc, count, c.controlScales, c.controlOffsets),\n dimension: 3\n };\n}\n\n/**\n * Decode a D3I1 curve with uint knots and scalar controls.\n *\n * @param {object} c Curve object with `knotsControls`, `controlScales`,\n * `controlOffsets`, and `oneOverKnotScaleTrunc`.\n * @returns {{knots: number[], controls: number[], dimension: number}} Decoded curve.\n */\nexport function decodeD3I1u(c)\n{\n const\n kc = c.knotsControls || [],\n count = exactDiv(kc.length, 2, \"D3I1 knotsControls/2\"),\n knots = knotsFromControlsTrunc(kc, count, c.oneOverKnotScaleTrunc);\n\n return {\n knots,\n controls: d3I1Controls(kc, count, c.controlScales, c.controlOffsets),\n dimension: 3\n };\n}\n\n/**\n * Decode format 6, DaK16uC16u.\n *\n * @type {typeof decodeDaK}\n */\nexport const decodeDaK16uC16u = decodeDaK;\n\n/**\n * Decode format 7, DaK8uC8u.\n *\n * @type {typeof decodeDaK}\n */\nexport const decodeDaK8uC8u = decodeDaK;\n\n/**\n * Decode format 10, D3K16uC16u.\n *\n * @type {typeof decodeD3K}\n */\nexport const decodeD3K16uC16u = decodeD3K;\n\n/**\n * Decode format 11, D3K8uC8u.\n *\n * @type {typeof decodeD3K}\n */\nexport const decodeD3K8uC8u = decodeD3K;\n\n/**\n * Decode format 12, D9I1K16uC16u.\n *\n * @type {typeof decodeD9I1}\n */\nexport const decodeD9I1K16uC16u = decodeD9I1;\n\n/**\n * Decode format 14, D9I1K8uC8u.\n *\n * @type {typeof decodeD9I1}\n */\nexport const decodeD9I1K8uC8u = decodeD9I1;\n\n/**\n * Decode format 13, D9I3K16uC16u.\n *\n * @type {typeof decodeD9I3}\n */\nexport const decodeD9I3K16uC16u = decodeD9I3;\n\n/**\n * Decode format 15, D9I3K8uC8u.\n *\n * @type {typeof decodeD9I3}\n */\nexport const decodeD9I3K8uC8u = decodeD9I3;\n\n/**\n * Decode format 17, D3I1K16uC16u.\n *\n * @type {typeof decodeD3I1u}\n */\nexport const decodeD3I1K16uC16u = decodeD3I1u;\n\n/**\n * Decode format 18, D3I1K8uC8u.\n *\n * @type {typeof decodeD3I1u}\n */\nexport const decodeD3I1K8uC8u = decodeD3I1u;\n\n/**\n * Curve object as emitted inside GR2 JSON transform tracks.\n *\n * @typedef {object} CurveJson\n * @property {number} format Granny animation-curve format id.\n * @property {number} degree Curve degree from the Granny curve header.\n * @property {number[]} [knots] Explicit knot times when already decompressed.\n * @property {number[]} [controls] Explicit control values when already decoded.\n * @property {number} [dimension] Control vector width.\n * @property {string} [error] Emitter error marker for unsupported raw curves.\n */\n\n/**\n * Explicit curve data returned by {@link decodeCurve}.\n *\n * controls is a flat array in knot-major order:\n * controls[knotIndex * dimension + componentIndex].\n *\n * @typedef {object} DecodedCurve\n * @property {number[]} knots Knot times, non-decreasing.\n * @property {number[]} controls Flat control values.\n * @property {number} degree Curve degree.\n * @property {number} dimension Control vector width.\n */\n\n/**\n * Track dimension accepted by Granny transform curves.\n *\n * @typedef {1|3|4|9} TransformCurveDimension\n */\n\n/**\n * Decoder table ordered by Granny curve format id.\n *\n * Each entry exposes the numeric format and the function used by\n * {@link decodeCurve}.\n */\nexport const CURVE_DECODERS = Object.freeze([\n Object.freeze({ format: FORMAT_DA_KEYFRAMES_32F, decode: decodeDaKeyframes32f }),\n Object.freeze({ format: FORMAT_DA_K32F_C32F, decode: decodeDaK32fC32f }),\n Object.freeze({ format: FORMAT_DA_IDENTITY, decode: decodeDaIdentity }),\n Object.freeze({ format: FORMAT_DA_CONSTANT_32F, decode: decodeDaConstant32f }),\n Object.freeze({ format: FORMAT_D3_CONSTANT_32F, decode: decodeD3Constant32f }),\n Object.freeze({ format: FORMAT_D4_CONSTANT_32F, decode: decodeD4Constant32f }),\n Object.freeze({ format: FORMAT_DA_K16U_C16U, decode: decodeDaK16uC16u }),\n Object.freeze({ format: FORMAT_DA_K8U_C8U, decode: decodeDaK8uC8u }),\n Object.freeze({ format: FORMAT_D4N_K16U_C15U, decode: decodeD4nK16uC15u }),\n Object.freeze({ format: FORMAT_D4N_K8U_C7U, decode: decodeD4nK8uC7u }),\n Object.freeze({ format: FORMAT_D3_K16U_C16U, decode: decodeD3K16uC16u }),\n Object.freeze({ format: FORMAT_D3_K8U_C8U, decode: decodeD3K8uC8u }),\n Object.freeze({ format: FORMAT_D9I1_K16U_C16U, decode: decodeD9I1K16uC16u }),\n Object.freeze({ format: FORMAT_D9I3_K16U_C16U, decode: decodeD9I3K16uC16u }),\n Object.freeze({ format: FORMAT_D9I1_K8U_C8U, decode: decodeD9I1K8uC8u }),\n Object.freeze({ format: FORMAT_D9I3_K8U_C8U, decode: decodeD9I3K8uC8u }),\n Object.freeze({ format: FORMAT_D3I1_K32F_C32F, decode: decodeD3I1K32fC32f }),\n Object.freeze({ format: FORMAT_D3I1_K16U_C16U, decode: decodeD3I1K16uC16u }),\n Object.freeze({ format: FORMAT_D3I1_K8U_C8U, decode: decodeD3I1K8uC8u })\n]);\n\nfor (let i = 0; i < CURVE_DECODERS.length; i++)\n{\n if (CURVE_DECODERS[i].format !== i)\n {\n throw new Error(`gr2reader: curve decoder table corrupt at format ${i}`);\n }\n}\n\n/**\n * Decode a GR2 JSON curve object into explicit knots/controls.\n *\n * @param {CurveJson} curveJson Curve as emitted in GR2 JSON.\n * @param {TransformCurveDimension} dimension Track dimension: position = 3, orientation = 4, scaleShear = 9.\n * @returns {DecodedCurve} Explicit knots and flat control values.\n * @throws {Error} If the curve is missing a numeric format, the format is not\n * supported, or the decoded dimension conflicts with the requested dimension.\n */\nexport function decodeCurve(curveJson, dimension)\n{\n if (!curveJson || typeof curveJson.format !== \"number\")\n {\n throw new Error(\"gr2reader: decodeCurve requires a curve object with a numeric format\");\n }\n\n const dec = CURVE_DECODERS[curveJson.format];\n if (!dec)\n {\n throw new Error(`gr2reader: unsupported granny curve format ${curveJson.format}`);\n }\n\n const { knots, controls, dimension: dim } = dec.decode(curveJson, dimension);\n if (dimension && dim && dim !== dimension)\n {\n throw new Error(\n `gr2reader: curve format ${curveJson.format} decoded dimension ${dim} does not match track dimension ${dimension}`);\n }\n\n return {\n knots,\n controls,\n degree: curveJson.degree | 0,\n dimension: dim || dimension\n };\n}\n\n/**\n * Copy one decoded control point into an output buffer.\n *\n * @param {ArrayLike<number> & { [index: number]: number }} out Mutable output buffer.\n * @param {DecodedCurve} curve Decoded curve.\n * @param {number} index Control point index.\n * @returns {ArrayLike<number>} The same output buffer.\n */\nfunction copyControl(out, curve, index)\n{\n const\n dim = curve.dimension,\n offset = index * dim;\n\n for (let i = 0; i < dim; i++)\n {\n out[i] = curve.controls[offset + i];\n }\n\n return out;\n}\n\n/**\n * Locate the first knot strictly greater than time, matching the existing\n * runtime curve evaluator's step/segment selection.\n *\n * @param {number[]} knots Decoded knot times.\n * @param {number} time Sample time.\n * @returns {number} Knot index.\n */\nfunction findKnotIndex(knots, time)\n{\n let low = 0;\n let high = knots.length - 1;\n\n while (low < high)\n {\n const mid = (low + high) >> 1;\n if (knots[mid] > time) high = mid;\n else low = mid + 1;\n }\n\n return low;\n}\n\n/**\n * Sample Carbon's raw keyframed Granny curves (`DaKeyframes32f`).\n *\n * @param {ArrayLike<number> & { [index: number]: number }} out Mutable output buffer.\n * @param {DecodedCurve} curve Decoded curve.\n * @param {number} time Sample time.\n * @param {number} duration Animation duration.\n * @returns {ArrayLike<number>} The same output buffer.\n */\nfunction sampleKeyframedCurve(out, curve, time, duration)\n{\n const count = curve.controls.length / curve.dimension;\n const frame = duration > 0 ? Math.trunc(count * time / duration) : 0;\n return copyControl(out, curve, Math.max(0, Math.min(count - 1, frame)));\n}\n\n/**\n * Sample a decoded degree-one curve.\n *\n * @param {ArrayLike<number> & { [index: number]: number }} out Mutable output buffer.\n * @param {DecodedCurve} curve Decoded curve.\n * @param {number} time Sample time.\n * @param {boolean} cycle Whether the owning track cycles.\n * @param {number} duration Animation duration.\n * @param {number} knot Selected knot index.\n * @returns {ArrayLike<number>} The same output buffer.\n */\nfunction sampleLinearCurve(out, curve, time, cycle, duration, knot)\n{\n const\n knots = curve.knots,\n count = knots.length,\n dim = curve.dimension,\n knot0 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1;\n\n let\n start = knots[knot0],\n end = knots[knot],\n localTime = time;\n\n if (cycle && end < start)\n {\n end += duration;\n }\n\n if (cycle && localTime < start)\n {\n localTime += duration;\n }\n\n const t = end !== start ? (localTime - start) / (end - start) : 0;\n const p0 = knot0 * dim;\n const p1 = knot * dim;\n\n for (let i = 0; i < dim; i++)\n {\n out[i] = curve.controls[p0 + i] * (1 - t) + curve.controls[p1 + i] * t;\n }\n\n return out;\n}\n\n/**\n * Sample the quadratic decoded curves emitted by modern Granny animation data.\n *\n * @param {ArrayLike<number> & { [index: number]: number }} out Mutable output buffer.\n * @param {DecodedCurve} curve Decoded curve.\n * @param {number} time Sample time.\n * @param {boolean} cycle Whether the owning track cycles.\n * @param {number} duration Animation duration.\n * @param {number} knot Selected knot index.\n * @returns {ArrayLike<number>} The same output buffer.\n */\nfunction sampleQuadraticCurve(out, curve, time, cycle, duration, knot)\n{\n const\n knots = curve.knots,\n count = knots.length,\n dim = curve.dimension,\n k2 = cycle ? (knot + count - 2) % count : knot === 0 ? 0 : Math.max(0, knot - 2),\n k1 = cycle ? (knot + count - 1) % count : knot === 0 ? 0 : knot - 1;\n\n let\n ti2 = knots[k2],\n ti1 = knots[k1],\n ti = knots[knot],\n tiNext = knots[(knot + 1) % count],\n localTime = time;\n\n if (ti2 > ti)\n {\n ti += duration;\n tiNext += duration;\n localTime += duration;\n }\n\n if (ti1 > ti)\n {\n ti += duration;\n tiNext += duration;\n localTime += duration;\n }\n\n if (tiNext < ti)\n {\n tiNext += duration;\n }\n\n const\n d0 = ti - ti1,\n d1a = ti - ti2,\n d1b = tiNext - ti1,\n l0 = d0 !== 0 ? (localTime - ti1) / d0 : 0,\n l1a = d1a !== 0 ? (localTime - ti2) / d1a : 0,\n l1b = d1b !== 0 ? (localTime - ti1) / d1b : 0;\n\n let c2 = (l1a + l0) - l0 * l1a;\n const\n ci = l0 * l1b,\n c1 = c2 - ci;\n c2 = 1 - c2;\n\n const\n p0 = k2 * dim,\n p1 = k1 * dim,\n p2 = knot * dim;\n\n for (let i = 0; i < dim; i++)\n {\n out[i] = c2 * curve.controls[p0 + i] +\n c1 * curve.controls[p1 + i] +\n ci * curve.controls[p2 + i];\n }\n\n return out;\n}\n\n/**\n * Sample a decoded Granny curve into a caller-provided output buffer.\n *\n * This works only on decoded `{ knots, controls, degree, dimension }` data.\n * Packed Granny curve parsing remains the responsibility of `decodeCurve`.\n *\n * @param {ArrayLike<number> & { [index: number]: number }} out Mutable output buffer.\n * @param {DecodedCurve} curve Decoded curve.\n * @param {number} time Sample time.\n * @param {boolean} [cycle=false] Whether the owning track cycles.\n * @param {number} [duration=0] Animation duration.\n * @param {{ keyframed?: boolean }} [options] Sampling options.\n * @returns {ArrayLike<number>} The same output buffer.\n */\nexport function sampleDecodedCurve(out, curve, time, cycle = false, duration = 0, options = {})\n{\n if (!curve || !curve.knots || !curve.controls || !curve.dimension)\n {\n return out;\n }\n\n const\n knots = curve.knots,\n count = knots.length,\n dim = curve.dimension,\n controlCount = curve.controls.length / dim;\n\n if (!count || !controlCount)\n {\n return out;\n }\n\n if (options.keyframed)\n {\n return sampleKeyframedCurve(out, curve, time, duration);\n }\n\n const knot = findKnotIndex(knots, time);\n if (curve.degree <= 0 || count === 1 || controlCount === 1)\n {\n return copyControl(out, curve, Math.min(knot, controlCount - 1));\n }\n\n if (curve.degree === 1)\n {\n return sampleLinearCurve(out, curve, time, cycle, duration || knots[count - 1], knot);\n }\n\n return sampleQuadraticCurve(out, curve, time, cycle, duration || knots[count - 1], knot);\n}\n\n/**\n * Decode the three curves of every transform track of a GR2 JSON object in\n * place. Adds knots, controls and dimension to each curve object; all raw\n * compressed fields are left untouched.\n *\n * @param {object} json GR2 JSON root object to mutate.\n * @returns {object} The same object, for chaining.\n */\nexport function decompressAnimationCurves(json)\n{\n for (const anim of json.animations || [])\n {\n for (const tg of anim.trackGroups || [])\n {\n for (const tt of tg.transformTracks || [])\n {\n decorate(tt.orientation, 4);\n decorate(tt.position, 3);\n decorate(tt.scaleShear, 9);\n }\n }\n }\n\n return json;\n}\n\n/**\n * Decode and attach explicit curve data to a transform-track curve object.\n *\n * @param {CurveJson|undefined|null} curve Curve object to decorate in place.\n * @param {TransformCurveDimension} dimension Expected track dimension.\n * @returns {void}\n */\nfunction decorate(curve, dimension)\n{\n if (!curve || typeof curve.format !== \"number\" || curve.error) return;\n const d = decodeCurve(curve, dimension);\n curve.knots = d.knots;\n curve.controls = d.controls;\n curve.dimension = d.dimension;\n}\n\n/**\n * Frozen convenience namespace for animation-curve decoding helpers.\n *\n * The same constants and functions are also exported directly from curves.js.\n */\nexport const curves = Object.freeze({\n FORMAT_DA_KEYFRAMES_32F,\n FORMAT_DA_K32F_C32F,\n FORMAT_DA_IDENTITY,\n FORMAT_DA_CONSTANT_32F,\n FORMAT_D3_CONSTANT_32F,\n FORMAT_D4_CONSTANT_32F,\n FORMAT_DA_K16U_C16U,\n FORMAT_DA_K8U_C8U,\n FORMAT_D4N_K16U_C15U,\n FORMAT_D4N_K8U_C7U,\n FORMAT_D3_K16U_C16U,\n FORMAT_D3_K8U_C8U,\n FORMAT_D9I1_K16U_C16U,\n FORMAT_D9I3_K16U_C16U,\n FORMAT_D9I1_K8U_C8U,\n FORMAT_D9I3_K8U_C8U,\n FORMAT_D3I1_K32F_C32F,\n FORMAT_D3I1_K16U_C16U,\n FORMAT_D3I1_K8U_C8U,\n FORMATS: CURVE_FORMATS,\n DECODERS: CURVE_DECODERS,\n D4N_SCALE_TABLE,\n D4N_OFFSET_TABLE,\n D4N_SCALE_TABLE_MULTIPLIER_16,\n D4N_SCALE_TABLE_MULTIPLIER_8,\n decode: decodeCurve,\n decodeCurve,\n sample: sampleDecodedCurve,\n sampleDecodedCurve,\n decompress: decompressAnimationCurves,\n decompressAnimationCurves,\n knotScaleFromTrunc,\n knotsFromControls,\n knotsFromControlsTrunc,\n identityControls,\n exactDiv,\n decodeDaKeyframes32f,\n decodeDaK32fC32f,\n decodeDaIdentity,\n decodeDaConstant32f,\n decodeD3Constant32f,\n decodeD4Constant32f,\n decodeDaK,\n decodeDaK16uC16u,\n decodeDaK8uC8u,\n quatFromControl16,\n quatFromControl8,\n decodeD4n,\n decodeD4nK16uC15u,\n decodeD4nK8uC7u,\n decodeD3K,\n decodeD3K16uC16u,\n decodeD3K8uC8u,\n decodeD9I1,\n decodeD9I1K16uC16u,\n decodeD9I1K8uC8u,\n decodeD9I3,\n decodeD9I3K16uC16u,\n decodeD9I3K8uC8u,\n d3I1Controls,\n decodeD3I1K32fC32f,\n decodeD3I1u,\n decodeD3I1K16uC16u,\n decodeD3I1K8uC8u\n});\n"],"names":["FORMAT_DA_KEYFRAMES_32F","FORMAT_DA_K32F_C32F","FORMAT_DA_IDENTITY","FORMAT_DA_CONSTANT_32F","FORMAT_D3_CONSTANT_32F","FORMAT_D4_CONSTANT_32F","FORMAT_DA_K16U_C16U","FORMAT_DA_K8U_C8U","FORMAT_D4N_K16U_C15U","FORMAT_D4N_K8U_C7U","FORMAT_D3_K16U_C16U","FORMAT_D3_K8U_C8U","FORMAT_D9I1_K16U_C16U","FORMAT_D9I3_K16U_C16U","FORMAT_D9I1_K8U_C8U","FORMAT_D9I3_K8U_C8U","FORMAT_D3I1_K32F_C32F","FORMAT_D3I1_K16U_C16U","FORMAT_D3I1_K8U_C8U","CURVE_FORMATS","Object","freeze","DA_KEYFRAMES_32F","DA_K32F_C32F","DA_IDENTITY","DA_CONSTANT_32F","D3_CONSTANT_32F","D4_CONSTANT_32F","DA_K16U_C16U","DA_K8U_C8U","D4N_K16U_C15U","D4N_K8U_C7U","D3_K16U_C16U","D3_K8U_C8U","D9I1_K16U_C16U","D9I3_K16U_C16U","D9I1_K8U_C8U","D9I3_K8U_C8U","D3I1_K32F_C32F","D3I1_K16U_C16U","D3I1_K8U_C8U","fr","Math","fround","knotScaleFromTrunc","oneOverKnotScaleTrunc","u","Uint32Array","Float32Array","buffer","knotsFromControls","knotsControls","count","scale","out","Array","i","knotsFromControlsTrunc","identityControls","dimension","Error","exactDiv","numerator","divisor","what","v","Number","isInteger","decodeDaKeyframes32f","c","dim","controls","length","knots","map","decodeDaK32fC32f","decodeDaIdentity","decodeDaConstant32f","decodeD3Constant32f","slice","decodeD4Constant32f","decodeDaK","so","controlScaleOffsets","kc","x","D4N_SCALE_TABLE","D4N_OFFSET_TABLE","quatFromControl16","a","b","scales","offsets","swizzle1","swizzle2","swizzle3","swizzle4","dataA","dataB","dataC","dataD","sqrt","max","D4N_SCALE_TABLE_MULTIPLIER_16","decodeD4n","quatFromControl","scaleTableMultiplier","oneOverKnotScale","selector","scaleOffsetTableEntries","quat","decodeD4nK16uC15u","D4N_SCALE_TABLE_MULTIPLIER_8","quatFromControl8","decodeD4nK8uC7u","decodeD3K","controlScales","controlOffsets","decodeD9I1","isArray","controlScale","offset","controlOffset","fill","s","decodeD9I3","d3I1Controls","decodeD3I1K32fC32f","decodeD3I1u","decodeDaK16uC16u","decodeDaK8uC8u","decodeD3K16uC16u","decodeD3K8uC8u","decodeD9I1K16uC16u","decodeD9I1K8uC8u","decodeD9I3K16uC16u","decodeD9I3K8uC8u","decodeD3I1K16uC16u","decodeD3I1K8uC8u","CURVE_DECODERS","format","decode","decodeCurve","curveJson","dec","degree","copyControl","curve","index","findKnotIndex","time","low","high","mid","sampleKeyframedCurve","duration","frame","trunc","min","sampleLinearCurve","cycle","knot","knot0","start","end","localTime","t","p0","p1","sampleQuadraticCurve","k2","k1","ti2","ti1","ti","tiNext","d0","d1a","d1b","l0","l1a","l1b","c2","ci","c1","p2","sampleDecodedCurve","options","controlCount","keyframed","decompressAnimationCurves","json","anim","animations","tg","trackGroups","tt","transformTracks","decorate","orientation","position","scaleShear","error","d","curves","FORMATS","DECODERS","sample","decompress"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA;AACO,MAAMA,uBAAuB,GAAG;;AAEvC;AACO,MAAMC,mBAAmB,GAAG;;AAEnC;AACO,MAAMC,kBAAkB,GAAG;;AAElC;AACO,MAAMC,sBAAsB,GAAG;;AAEtC;AACO,MAAMC,sBAAsB,GAAG;;AAE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kB;EAC1BA,kBAAkB;AAClBsB,EAAAA,UAAU,EAAElB,yBAAyB;EACrCA,yBAAyB;EACzBlJ,kBAAkB;EAClBM,iBAAiB;EACjBO,sBAAsB;EACtBC,gBAAgB;EAChBG,QAAQ;EACRO,oBAAoB;EACpBO,gBAAgB;EAChBC,gBAAgB;EAChBC,mBAAmB;EACnBC,mBAAmB;EACnBE,mBAAmB;EACnBC,SAAS;EACTgD,gBAAgB;EAChBC,cAAc;EACd1C,iBAAiB;EACjByB,gBAAgB;EAChBT,SAAS;EACTO,iBAAiB;EACjBG,eAAe;EACfC,SAAS;EACTgB,gBAAgB;EAChBC,cAAc;EACdd,UAAU;EACVe,kBAAkB;EAClBC,gBAAgB;EAChBT,UAAU;EACVU,kBAAkB;EAClBC,gBAAgB;EAChBV,YAAY;EACZC,kBAAkB;EAClBC,WAAW;EACXS,kBAAkB;AAClBC,EAAAA;AACJ,CAAC;;;;"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Granny State semantic helpers.
|
|
3
|
+
*
|
|
4
|
+
* GSF uses the ordinary Granny container and reflected type tree. These
|
|
5
|
+
* helpers classify and project the reflected GState root without introducing
|
|
6
|
+
* a second container reader.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
function collectGr2References(value, seen = new Set(), output = new Set()) {
|
|
10
|
+
if (!value || typeof value !== "object" || seen.has(value)) return output;
|
|
11
|
+
seen.add(value);
|
|
12
|
+
for (const [key, child] of Object.entries(value)) {
|
|
13
|
+
if (typeof child === "string" && /file|path|source/i.test(key) && /\.gr2(?:;|$)/i.test(child)) {
|
|
14
|
+
output.add(child);
|
|
15
|
+
} else if (child && typeof child === "object") {
|
|
16
|
+
collectGr2References(child, seen, output);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return output;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Whether a reflected Granny result has the GState root schema. */
|
|
23
|
+
function isGsfRaw(raw) {
|
|
24
|
+
return !!raw?.fileInfo?.StateMachine && Array.isArray(raw.fileInfo?.AnimationSets);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Project a reflected Granny result into a stable GSF-facing document. */
|
|
28
|
+
function projectGsf(raw) {
|
|
29
|
+
if (!isGsfRaw(raw)) throw new Error("format-gr2: expected Granny State root schema");
|
|
30
|
+
const root = raw.fileInfo;
|
|
31
|
+
return {
|
|
32
|
+
format: "gsf",
|
|
33
|
+
container: {
|
|
34
|
+
family: "granny",
|
|
35
|
+
revision: raw.version,
|
|
36
|
+
sectionCount: raw.secCount
|
|
37
|
+
},
|
|
38
|
+
character: {
|
|
39
|
+
modelNameHint: root.ModelNameHint ?? null,
|
|
40
|
+
modelIndexHint: root.ModelIndexHint ?? -1,
|
|
41
|
+
retargetSourceModelNameHint: root.RetargetSourceModelNameHint ?? null,
|
|
42
|
+
retargetSourceModelIndexHint: root.RetargetSourceModelIndexHint ?? -1
|
|
43
|
+
},
|
|
44
|
+
stateMachine: root.StateMachine,
|
|
45
|
+
animationSlots: root.AnimationSlots,
|
|
46
|
+
animationSets: root.AnimationSets.map((set, index) => ({
|
|
47
|
+
index,
|
|
48
|
+
sourceFileReferences: [...collectGr2References(set)],
|
|
49
|
+
raw: set
|
|
50
|
+
})),
|
|
51
|
+
uniqueTokenCount: root.NumUniqueTokenized ?? 0,
|
|
52
|
+
editorData: root.EditorData ?? null,
|
|
53
|
+
extendedData: root.ExtendedData ?? null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Build a lightweight GSF support and dependency summary. */
|
|
58
|
+
function inspectGsfRaw(raw) {
|
|
59
|
+
const value = projectGsf(raw);
|
|
60
|
+
return {
|
|
61
|
+
format: "gsf",
|
|
62
|
+
supported: true,
|
|
63
|
+
revision: value.container.revision,
|
|
64
|
+
sectionCount: value.container.sectionCount,
|
|
65
|
+
animationSlotCount: value.animationSlots.length,
|
|
66
|
+
animationSetCount: value.animationSets.length,
|
|
67
|
+
animationFileReferences: [...new Set(value.animationSets.flatMap(set => set.sourceFileReferences))]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { inspectGsfRaw, isGsfRaw, projectGsf };
|
|
72
|
+
//# sourceMappingURL=gsf.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gsf.js","sources":["../../../../../src/formats/gr2/core/gsf.js"],"sourcesContent":["/**\n * Granny State semantic helpers.\n *\n * GSF uses the ordinary Granny container and reflected type tree. These\n * helpers classify and project the reflected GState root without introducing\n * a second container reader.\n */\n\nfunction collectGr2References(value, seen = new Set(), output = new Set())\n{\n if (!value || typeof value !== \"object\" || seen.has(value)) return output;\n seen.add(value);\n\n for (const [ key, child ] of Object.entries(value))\n {\n if (typeof child === \"string\" && /file|path|source/i.test(key) && /\\.gr2(?:;|$)/i.test(child))\n {\n output.add(child);\n }\n else if (child && typeof child === \"object\")\n {\n collectGr2References(child, seen, output);\n }\n }\n\n return output;\n}\n\n/** Whether a reflected Granny result has the GState root schema. */\nexport function isGsfRaw(raw)\n{\n return !!raw?.fileInfo?.StateMachine && Array.isArray(raw.fileInfo?.AnimationSets);\n}\n\n/** Project a reflected Granny result into a stable GSF-facing document. */\nexport function projectGsf(raw)\n{\n if (!isGsfRaw(raw)) throw new Error(\"format-gr2: expected Granny State root schema\");\n\n const root = raw.fileInfo;\n return {\n format: \"gsf\",\n container: {\n family: \"granny\",\n revision: raw.version,\n sectionCount: raw.secCount\n },\n character: {\n modelNameHint: root.ModelNameHint ?? null,\n modelIndexHint: root.ModelIndexHint ?? -1,\n retargetSourceModelNameHint: root.RetargetSourceModelNameHint ?? null,\n retargetSourceModelIndexHint: root.RetargetSourceModelIndexHint ?? -1\n },\n stateMachine: root.StateMachine,\n animationSlots: root.AnimationSlots,\n animationSets: root.AnimationSets.map((set, index) => ({\n index,\n sourceFileReferences: [ ...collectGr2References(set) ],\n raw: set\n })),\n uniqueTokenCount: root.NumUniqueTokenized ?? 0,\n editorData: root.EditorData ?? null,\n extendedData: root.ExtendedData ?? null\n };\n}\n\n/** Build a lightweight GSF support and dependency summary. */\nexport function inspectGsfRaw(raw)\n{\n const value = projectGsf(raw);\n return {\n format: \"gsf\",\n supported: true,\n revision: value.container.revision,\n sectionCount: value.container.sectionCount,\n animationSlotCount: value.animationSlots.length,\n animationSetCount: value.animationSets.length,\n animationFileReferences: [ ...new Set(value.animationSets.flatMap(set => set.sourceFileReferences)) ]\n };\n}\n\n"],"names":["collectGr2References","value","seen","Set","output","has","add","key","child","Object","entries","test","isGsfRaw","raw","fileInfo","StateMachine","Array","isArray","AnimationSets","projectGsf","Error","root","format","container","family","revision","version","sectionCount","secCount","character","modelNameHint","ModelNameHint","modelIndexHint","ModelIndexHint","retargetSourceModelNameHint","RetargetSourceModelNameHint","retargetSourceModelIndexHint","RetargetSourceModelIndexHint","stateMachine","animationSlots","AnimationSlots","animationSets","map","set","index","sourceFileReferences","uniqueTokenCount","NumUniqueTokenized","editorData","EditorData","extendedData","ExtendedData","inspectGsfRaw","supported","animationSlotCount","length","animationSetCount","animationFileReferences","flatMap"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoBA,CAACC,KAAK,EAAEC,IAAI,GAAG,IAAIC,GAAG,EAAE,EAAEC,MAAM,GAAG,IAAID,GAAG,EAAE,EACzE;AACI,EAAA,IAAI,CAACF,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAIC,IAAI,CAACG,GAAG,CAACJ,KAAK,CAAC,EAAE,OAAOG,MAAM;AACzEF,EAAAA,IAAI,CAACI,GAAG,CAACL,KAAK,CAAC;AAEf,EAAA,KAAK,MAAM,CAAEM,GAAG,EAAEC,KAAK,CAAE,IAAIC,MAAM,CAACC,OAAO,CAACT,KAAK,CAAC,EAClD;AACI,IAAA,IAAI,OAAOO,KAAK,KAAK,QAAQ,IAAI,mBAAmB,CAACG,IAAI,CAACJ,GAAG,CAAC,IAAI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,GAAG,CAAC,CAACC,GAAG,EAAEC,KAAK,MAAM;MACnDA,KAAK;AACLC,MAAAA,oBAAoB,EAAE,CAAE,GAAG7C,oBAAoB,CAAC2C,GAAG,CAAC,CAAE;AACtD9B,MAAAA,GAAG,EAAE8B;AACT,KAAC,CAAC,CAAC;AACHG,IAAAA,gBAAgB,EAAEzB,IAAI,CAAC0B,kBAAkB,IAAI,CAAC;AAC9CC,IAAAA,UAAU,EAAE3B,IAAI,CAAC4B,UAAU,IAAI,IAAI;AACnCC,IAAAA,YAAY,EAAE7B,IAAI,CAAC8B,YAAY,IAAI;GACtC;AACL;;AAEA;AACO,SAASC,aAAaA,CAACvC,GAAG,EACjC;AACI,EAAA,MAAMZ,KAAK,GAAGkB,UAAU,CAACN,GAAG,CAAC;EAC7B,OAAO;AACHS,IAAAA,MAAM,EAAE,KAAK;AACb+B,IAAAA,SAAS,EAAE,IAAI;AACf5B,IAAAA,QAAQ,EAAExB,KAAK,CAACsB,SAAS,CAACE,QAAQ;AAClCE,IAAAA,YAAY,EAAE1B,KAAK,CAACsB,SAAS,CAACI,YAAY;AAC1C2B,IAAAA,kBAAkB,EAAErD,KAAK,CAACsC,cAAc,CAACgB,MAAM;AAC/CC,IAAAA,iBAAiB,EAAEvD,KAAK,CAACwC,aAAa,CAACc,MAAM;AAC7CE,IAAAA,uBAAuB,EAAE,CAAE,GAAG,IAAItD,GAAG,CAACF,KAAK,CAACwC,aAAa,CAACiB,OAAO,CAACf,GAAG,IAAIA,GAAG,CAACE,oBAAoB,CAAC,CAAC;GACtG;AACL;;;;"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { readGr2Raw } from './reader.js';
|
|
2
|
+
import { CLASS_KEYS as CLASS_KEYS$1, emitJson } from './json.js';
|
|
3
|
+
import { tangents } from './tangents.js';
|
|
4
|
+
import { decompressAnimationCurves } from './curves.js';
|
|
5
|
+
import { CMF_CLASS_KEYS, hydrateCmf, buildCmfFromShared } from './targets.js';
|
|
6
|
+
|
|
7
|
+
const CLASS_KEYS = Object.freeze(Array.from(new Set([...CLASS_KEYS$1, ...CMF_CLASS_KEYS])));
|
|
8
|
+
const OUTPUT_JSON = "json";
|
|
9
|
+
const OUTPUT_GR2 = "gr2";
|
|
10
|
+
const OUTPUT_GR2_JSON = "gr2Json";
|
|
11
|
+
const OUTPUT_CMF = "cmf";
|
|
12
|
+
const OUTPUT_RAW = "raw";
|
|
13
|
+
const DEFAULT_VALUES = Object.freeze({
|
|
14
|
+
emit: OUTPUT_JSON,
|
|
15
|
+
decompressCurves: false,
|
|
16
|
+
unpackTangents: false,
|
|
17
|
+
rebuildMissingNormals: false,
|
|
18
|
+
rebuildMissingTangents: false,
|
|
19
|
+
rebuildMissingBiNormals: false,
|
|
20
|
+
classes: Object.freeze({})
|
|
21
|
+
});
|
|
22
|
+
const OPTION_KEYS = new Set(["emit", "decompressCurves", "unpackTangents", "rebuildMissingNormals", "rebuildMissingTangents", "rebuildMissingBiNormals", "classes"]);
|
|
23
|
+
function normalizeEmit(emit) {
|
|
24
|
+
if (emit === undefined || emit === OUTPUT_JSON) return OUTPUT_JSON;
|
|
25
|
+
if (emit === OUTPUT_GR2_JSON) return OUTPUT_GR2_JSON;
|
|
26
|
+
if (emit === OUTPUT_GR2) return OUTPUT_GR2;
|
|
27
|
+
if (emit === OUTPUT_CMF) return OUTPUT_CMF;
|
|
28
|
+
if (emit === OUTPUT_RAW) return OUTPUT_RAW;
|
|
29
|
+
throw new Error(`CjsFormatGr2 unknown emit value "${emit}"`);
|
|
30
|
+
}
|
|
31
|
+
function hasOwn(value, key) {
|
|
32
|
+
return Object.prototype.hasOwnProperty.call(value, key);
|
|
33
|
+
}
|
|
34
|
+
function classMap(values) {
|
|
35
|
+
return values && values.classes ? values.classes : {};
|
|
36
|
+
}
|
|
37
|
+
function cloneValues(values) {
|
|
38
|
+
return {
|
|
39
|
+
emit: values.emit,
|
|
40
|
+
decompressCurves: values.decompressCurves,
|
|
41
|
+
unpackTangents: values.unpackTangents,
|
|
42
|
+
rebuildMissingNormals: values.rebuildMissingNormals,
|
|
43
|
+
rebuildMissingTangents: values.rebuildMissingTangents,
|
|
44
|
+
rebuildMissingBiNormals: values.rebuildMissingBiNormals,
|
|
45
|
+
classes: {
|
|
46
|
+
...classMap(values)
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function assertKnownOptions(options) {
|
|
51
|
+
for (const key of Object.keys(options)) {
|
|
52
|
+
if (!OPTION_KEYS.has(key)) {
|
|
53
|
+
throw new TypeError(`CjsFormatGr2 unknown option "${key}"`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function validateBoolean(name, value) {
|
|
58
|
+
if (typeof value !== "boolean") {
|
|
59
|
+
throw new TypeError(`CjsFormatGr2 ${name} option must be true or false`);
|
|
60
|
+
}
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
function validateRule(name, value) {
|
|
64
|
+
if (typeof value === "boolean" || typeof value === "function") return value;
|
|
65
|
+
throw new TypeError(`CjsFormatGr2 ${name} option must be true, false, or a function`);
|
|
66
|
+
}
|
|
67
|
+
function validateClassKey(key) {
|
|
68
|
+
if (!CLASS_KEYS.includes(key)) {
|
|
69
|
+
throw new Error(`CjsFormatGr2 unknown class type "${key}"`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function validateClass(type, Class) {
|
|
73
|
+
validateClassKey(type);
|
|
74
|
+
if (typeof Class !== "function") {
|
|
75
|
+
throw new TypeError(`CjsFormatGr2 class "${type}" must be a constructor`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function mergeClasses(values, classes) {
|
|
79
|
+
if (!classes || typeof classes !== "object") {
|
|
80
|
+
throw new TypeError("CjsFormatGr2 classes option must be an object");
|
|
81
|
+
}
|
|
82
|
+
const next = {
|
|
83
|
+
...values.classes
|
|
84
|
+
};
|
|
85
|
+
for (const [type, Class] of Object.entries(classes)) {
|
|
86
|
+
validateClass(type, Class);
|
|
87
|
+
next[type] = Class;
|
|
88
|
+
}
|
|
89
|
+
values.classes = next;
|
|
90
|
+
}
|
|
91
|
+
function optionValue(options, keys) {
|
|
92
|
+
for (const key of keys) {
|
|
93
|
+
if (hasOwn(options, key)) return options[key];
|
|
94
|
+
}
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
function normalizeValues(base = DEFAULT_VALUES, options = {}) {
|
|
98
|
+
if (!options || typeof options !== "object") {
|
|
99
|
+
throw new TypeError("CjsFormatGr2 options must be an object");
|
|
100
|
+
}
|
|
101
|
+
assertKnownOptions(options);
|
|
102
|
+
const values = cloneValues(base);
|
|
103
|
+
if (hasOwn(options, "emit")) values.emit = normalizeEmit(options.emit);
|
|
104
|
+
if (hasOwn(options, "decompressCurves")) {
|
|
105
|
+
values.decompressCurves = validateBoolean("decompressCurves", options.decompressCurves);
|
|
106
|
+
}
|
|
107
|
+
const unpackTangents = optionValue(options, ["unpackTangents"]);
|
|
108
|
+
if (unpackTangents !== undefined) {
|
|
109
|
+
values.unpackTangents = validateRule("unpackTangents", unpackTangents);
|
|
110
|
+
}
|
|
111
|
+
const rebuildMissingNormals = optionValue(options, ["rebuildMissingNormals"]);
|
|
112
|
+
if (rebuildMissingNormals !== undefined) {
|
|
113
|
+
values.rebuildMissingNormals = validateRule("rebuildMissingNormals", rebuildMissingNormals);
|
|
114
|
+
}
|
|
115
|
+
const rebuildMissingTangents = optionValue(options, ["rebuildMissingTangents"]);
|
|
116
|
+
if (rebuildMissingTangents !== undefined) {
|
|
117
|
+
values.rebuildMissingTangents = validateRule("rebuildMissingTangents", rebuildMissingTangents);
|
|
118
|
+
}
|
|
119
|
+
const rebuildMissingBiNormals = optionValue(options, ["rebuildMissingBiNormals"]);
|
|
120
|
+
if (rebuildMissingBiNormals !== undefined) {
|
|
121
|
+
values.rebuildMissingBiNormals = validateRule("rebuildMissingBiNormals", rebuildMissingBiNormals);
|
|
122
|
+
}
|
|
123
|
+
if (hasOwn(options, "classes")) {
|
|
124
|
+
mergeClasses(values, options.classes);
|
|
125
|
+
}
|
|
126
|
+
if ((values.emit === OUTPUT_GR2 || values.emit === OUTPUT_CMF) && !hasClasses(values.classes)) {
|
|
127
|
+
throw new TypeError(`CjsFormatGr2 emit "${values.emit}" requires explicit classes`);
|
|
128
|
+
}
|
|
129
|
+
return values;
|
|
130
|
+
}
|
|
131
|
+
function hasClasses(classes) {
|
|
132
|
+
return !!classes && Object.values(classes).some(Class => typeof Class === "function");
|
|
133
|
+
}
|
|
134
|
+
function isRawGr2Result(value) {
|
|
135
|
+
return !!value && typeof value === "object" && "fileInfo" in value && typeof value.version === "number";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Normalizes GR2 input into a Uint8Array. readGr2Raw indexes `.buffer`,
|
|
140
|
+
* `.byteOffset`, `.byteLength` and calls `.subarray()`, so a raw
|
|
141
|
+
* ArrayBuffer (e.g. from `fetch(...).then(r => r.arrayBuffer())`, which
|
|
142
|
+
* is how ccpwgl's resource loader supplies bytes) must be wrapped in a
|
|
143
|
+
* view before it reaches readGr2Raw, not passed straight through.
|
|
144
|
+
*
|
|
145
|
+
* @param {Uint8Array|ArrayBuffer|Buffer|DataView} input GR2 bytes.
|
|
146
|
+
* @returns {Uint8Array} A Uint8Array view over the same bytes.
|
|
147
|
+
*/
|
|
148
|
+
function toBytes(input) {
|
|
149
|
+
if (input instanceof Uint8Array) return input;
|
|
150
|
+
if (typeof ArrayBuffer !== "undefined" && input instanceof ArrayBuffer) return new Uint8Array(input);
|
|
151
|
+
if (ArrayBuffer.isView(input)) return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
|
|
152
|
+
throw new TypeError("CjsFormatGr2: input must be GR2 bytes (Uint8Array, Buffer, DataView or ArrayBuffer)");
|
|
153
|
+
}
|
|
154
|
+
function readRawInput(input) {
|
|
155
|
+
return isRawGr2Result(input) ? input : readGr2Raw(toBytes(input));
|
|
156
|
+
}
|
|
157
|
+
function meshName(mesh, meshIndex) {
|
|
158
|
+
return mesh && mesh.name ? `"${mesh.name}"` : `#${meshIndex}`;
|
|
159
|
+
}
|
|
160
|
+
function vertexChannel(mesh, channel) {
|
|
161
|
+
return mesh && mesh.vertex && mesh.vertex[channel];
|
|
162
|
+
}
|
|
163
|
+
function hasVertexChannel(mesh, channel) {
|
|
164
|
+
const value = vertexChannel(mesh, channel);
|
|
165
|
+
return !!value && value.length > 0;
|
|
166
|
+
}
|
|
167
|
+
function requireVertexChannel(mesh, meshIndex, channel, feature) {
|
|
168
|
+
const value = vertexChannel(mesh, channel);
|
|
169
|
+
if (!value || value.length === 0) {
|
|
170
|
+
throw new Error(`CjsFormatGr2 ${feature} requires mesh.vertex.${channel} for mesh ${meshName(mesh, meshIndex)}`);
|
|
171
|
+
}
|
|
172
|
+
return value;
|
|
173
|
+
}
|
|
174
|
+
function triangleFaces(mesh, meshIndex, feature) {
|
|
175
|
+
const faces = [];
|
|
176
|
+
for (const group of mesh.indices || []) {
|
|
177
|
+
if (group && group.faces) faces.push(...group.faces);
|
|
178
|
+
}
|
|
179
|
+
if (faces.length === 0) {
|
|
180
|
+
throw new Error(`CjsFormatGr2 ${feature} requires triangle indices for mesh ${meshName(mesh, meshIndex)}`);
|
|
181
|
+
}
|
|
182
|
+
return faces;
|
|
183
|
+
}
|
|
184
|
+
function shouldApplyMeshRule(reader, rule, context) {
|
|
185
|
+
const fullContext = {
|
|
186
|
+
reader,
|
|
187
|
+
...context
|
|
188
|
+
};
|
|
189
|
+
if (typeof rule === "function") {
|
|
190
|
+
const result = rule(fullContext);
|
|
191
|
+
if (typeof result !== "boolean") {
|
|
192
|
+
throw new TypeError(`CjsFormatGr2 ${context.feature} rule must return true or false`);
|
|
193
|
+
}
|
|
194
|
+
return result;
|
|
195
|
+
}
|
|
196
|
+
return rule;
|
|
197
|
+
}
|
|
198
|
+
function unpackMeshTangents(reader, json, raw, values) {
|
|
199
|
+
for (let meshIndex = 0; meshIndex < (json.meshes || []).length; meshIndex++) {
|
|
200
|
+
const mesh = json.meshes[meshIndex];
|
|
201
|
+
if (shouldApplyMeshRule(reader, values.unpackTangents, {
|
|
202
|
+
options: values,
|
|
203
|
+
raw,
|
|
204
|
+
json,
|
|
205
|
+
mesh,
|
|
206
|
+
meshIndex,
|
|
207
|
+
feature: "unpackTangents",
|
|
208
|
+
channel: "tangent"
|
|
209
|
+
})) {
|
|
210
|
+
tangents.unpack(mesh);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function rebuildMeshNormals(mesh, meshIndex) {
|
|
215
|
+
const positions = requireVertexChannel(mesh, meshIndex, "position", "rebuildMissingNormals"),
|
|
216
|
+
faces = triangleFaces(mesh, meshIndex, "rebuildMissingNormals");
|
|
217
|
+
mesh.vertex.normal = Array.from(tangents.generateNormals(positions, faces));
|
|
218
|
+
}
|
|
219
|
+
function rebuildMeshTangents(mesh, meshIndex) {
|
|
220
|
+
const positions = requireVertexChannel(mesh, meshIndex, "position", "rebuildMissingTangents"),
|
|
221
|
+
normals = requireVertexChannel(mesh, meshIndex, "normal", "rebuildMissingTangents"),
|
|
222
|
+
uvs = requireVertexChannel(mesh, meshIndex, "texcoord0", "rebuildMissingTangents"),
|
|
223
|
+
faces = triangleFaces(mesh, meshIndex, "rebuildMissingTangents");
|
|
224
|
+
mesh.vertex.tangent = Array.from(tangents.generateTangents(positions, normals, uvs, faces));
|
|
225
|
+
}
|
|
226
|
+
function rebuildMeshBiNormals(mesh, meshIndex) {
|
|
227
|
+
const normals = requireVertexChannel(mesh, meshIndex, "normal", "rebuildMissingBiNormals"),
|
|
228
|
+
tangentValues = requireVertexChannel(mesh, meshIndex, "tangent", "rebuildMissingBiNormals");
|
|
229
|
+
mesh.vertex.binormal = tangents.generateBiNormals(normals, tangentValues);
|
|
230
|
+
}
|
|
231
|
+
function rebuildMissingMeshData(reader, json, raw, values) {
|
|
232
|
+
for (let meshIndex = 0; meshIndex < (json.meshes || []).length; meshIndex++) {
|
|
233
|
+
const mesh = json.meshes[meshIndex];
|
|
234
|
+
if (!hasVertexChannel(mesh, "normal") && shouldApplyMeshRule(reader, values.rebuildMissingNormals, {
|
|
235
|
+
options: values,
|
|
236
|
+
raw,
|
|
237
|
+
json,
|
|
238
|
+
mesh,
|
|
239
|
+
meshIndex,
|
|
240
|
+
feature: "rebuildMissingNormals",
|
|
241
|
+
channel: "normal"
|
|
242
|
+
})) {
|
|
243
|
+
rebuildMeshNormals(mesh, meshIndex);
|
|
244
|
+
}
|
|
245
|
+
if (!hasVertexChannel(mesh, "tangent") && shouldApplyMeshRule(reader, values.rebuildMissingTangents, {
|
|
246
|
+
options: values,
|
|
247
|
+
raw,
|
|
248
|
+
json,
|
|
249
|
+
mesh,
|
|
250
|
+
meshIndex,
|
|
251
|
+
feature: "rebuildMissingTangents",
|
|
252
|
+
channel: "tangent"
|
|
253
|
+
})) {
|
|
254
|
+
rebuildMeshTangents(mesh, meshIndex);
|
|
255
|
+
}
|
|
256
|
+
if (!hasVertexChannel(mesh, "binormal") && shouldApplyMeshRule(reader, values.rebuildMissingBiNormals, {
|
|
257
|
+
options: values,
|
|
258
|
+
raw,
|
|
259
|
+
json,
|
|
260
|
+
mesh,
|
|
261
|
+
meshIndex,
|
|
262
|
+
feature: "rebuildMissingBiNormals",
|
|
263
|
+
channel: "binormal"
|
|
264
|
+
})) {
|
|
265
|
+
rebuildMeshBiNormals(mesh, meshIndex);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function processMeshData(reader, json, raw, values) {
|
|
270
|
+
unpackMeshTangents(reader, json, raw, values);
|
|
271
|
+
rebuildMissingMeshData(reader, json, raw, values);
|
|
272
|
+
}
|
|
273
|
+
function buildJson(reader, raw, values) {
|
|
274
|
+
const json = emitJson(raw.fileInfo, raw.version, {
|
|
275
|
+
classes: values.emit === OUTPUT_GR2 || (values.emit === OUTPUT_JSON || values.emit === OUTPUT_GR2_JSON) && hasClasses(values.classes) ? values.classes : {}
|
|
276
|
+
});
|
|
277
|
+
if (values.decompressCurves) {
|
|
278
|
+
decompressAnimationCurves(json);
|
|
279
|
+
}
|
|
280
|
+
processMeshData(reader, json, raw, values);
|
|
281
|
+
return json;
|
|
282
|
+
}
|
|
283
|
+
function readWithValues(reader, input, values) {
|
|
284
|
+
const parsed = readRawInput(input);
|
|
285
|
+
if (values.emit === OUTPUT_RAW) return parsed;
|
|
286
|
+
const json = buildJson(reader, parsed, values);
|
|
287
|
+
return values.emit === OUTPUT_CMF ? hydrateCmf(buildCmfFromShared(json), values.classes, {
|
|
288
|
+
source: values.source
|
|
289
|
+
}) : json;
|
|
290
|
+
}
|
|
291
|
+
function toJsonValue(value, seen = new WeakSet()) {
|
|
292
|
+
if (value === null || typeof value !== "object") return value;
|
|
293
|
+
if (ArrayBuffer.isView(value)) return Array.from(value, item => toJsonValue(item, seen));
|
|
294
|
+
if (Array.isArray(value)) return value.map(item => toJsonValue(item, seen));
|
|
295
|
+
if (seen.has(value)) {
|
|
296
|
+
throw new TypeError("CjsFormatGr2.toJSON cannot convert circular data");
|
|
297
|
+
}
|
|
298
|
+
if (typeof value.toJSON === "function") {
|
|
299
|
+
seen.add(value);
|
|
300
|
+
const json = toJsonValue(value.toJSON(), seen);
|
|
301
|
+
seen.delete(value);
|
|
302
|
+
return json;
|
|
303
|
+
}
|
|
304
|
+
seen.add(value);
|
|
305
|
+
const out = {};
|
|
306
|
+
for (const key of Object.keys(value)) {
|
|
307
|
+
out[key] = toJsonValue(value[key], seen);
|
|
308
|
+
}
|
|
309
|
+
seen.delete(value);
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
function inspectRawGr2Result(parsed) {
|
|
313
|
+
const fileInfo = parsed.fileInfo || {},
|
|
314
|
+
count = value => Array.isArray(value) ? value.filter(Boolean).length : 0;
|
|
315
|
+
return {
|
|
316
|
+
reader: "CjsFormatGr2",
|
|
317
|
+
format: "gr2",
|
|
318
|
+
version: parsed.version | 0,
|
|
319
|
+
sectionCount: parsed.secCount | 0,
|
|
320
|
+
source: fileInfo.FromFileName ?? "",
|
|
321
|
+
counts: {
|
|
322
|
+
meshes: count(fileInfo.Meshes),
|
|
323
|
+
models: count(fileInfo.Models),
|
|
324
|
+
animations: count(fileInfo.Animations),
|
|
325
|
+
materials: count(fileInfo.Materials),
|
|
326
|
+
textures: count(fileInfo.Textures)
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export { CLASS_KEYS, DEFAULT_VALUES, OUTPUT_CMF, OUTPUT_GR2, OUTPUT_GR2_JSON, OUTPUT_JSON, OUTPUT_RAW, inspectRawGr2Result, normalizeValues, readRawInput, readWithValues, toJsonValue, validateClass, validateClassKey };
|
|
332
|
+
//# sourceMappingURL=helpers.js.map
|