@carbonenginejs/runtime-resource 0.7.0 → 0.9.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.
Files changed (59) hide show
  1. package/NOTICE +1 -1
  2. package/README.md +67 -537
  3. package/dist/formats/dds/core/bc6h.js +288 -0
  4. package/dist/formats/dds/core/bc6h.js.map +1 -0
  5. package/dist/formats/dds/core/bc7.js +251 -0
  6. package/dist/formats/dds/core/bc7.js.map +1 -0
  7. package/dist/formats/dds/core/helpers.js +6 -3
  8. package/dist/formats/dds/core/helpers.js.map +1 -1
  9. package/dist/formats/gr2/CjsGr2Format.js +46 -0
  10. package/dist/formats/gr2/CjsGr2Format.js.map +1 -0
  11. package/dist/formats/gr2/core/CjsFormatGr2.js +273 -0
  12. package/dist/formats/gr2/core/CjsFormatGr2.js.map +1 -0
  13. package/dist/formats/gr2/core/bitknit2.js +280 -0
  14. package/dist/formats/gr2/core/bitknit2.js.map +1 -0
  15. package/dist/formats/gr2/core/curves.js +1047 -0
  16. package/dist/formats/gr2/core/curves.js.map +1 -0
  17. package/dist/formats/gr2/core/gsf.js +72 -0
  18. package/dist/formats/gr2/core/gsf.js.map +1 -0
  19. package/dist/formats/gr2/core/helpers.js +332 -0
  20. package/dist/formats/gr2/core/helpers.js.map +1 -0
  21. package/dist/formats/gr2/core/json.js +622 -0
  22. package/dist/formats/gr2/core/json.js.map +1 -0
  23. package/dist/formats/gr2/core/oodle1.js +388 -0
  24. package/dist/formats/gr2/core/oodle1.js.map +1 -0
  25. package/dist/formats/gr2/core/reader.js +617 -0
  26. package/dist/formats/gr2/core/reader.js.map +1 -0
  27. package/dist/formats/gr2/core/tangents.js +48 -0
  28. package/dist/formats/gr2/core/tangents.js.map +1 -0
  29. package/dist/formats/gr2/core/targets.js +351 -0
  30. package/dist/formats/gr2/core/targets.js.map +1 -0
  31. package/dist/formats/gr2/index.js +3 -0
  32. package/dist/formats/gr2/index.js.map +1 -0
  33. package/dist/formats/index.js +7 -0
  34. package/dist/formats/index.js.map +1 -1
  35. package/dist/index.js +1 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js +22 -0
  38. package/dist/resources/Tr2TexturePipelineStepGenerateMips.js.map +1 -0
  39. package/dist/resources/TriGeometryRes.js +24 -1
  40. package/dist/resources/TriGeometryRes.js.map +1 -1
  41. package/docs/README.md +69 -0
  42. package/docs/architecture.md +86 -0
  43. package/docs/concepts/resource-lifecycle.md +217 -0
  44. package/docs/formats/README.md +104 -0
  45. package/{FORMAT-PROVENANCE.md → docs/formats/provenance.md} +34 -5
  46. package/docs/formats/stl.md +37 -0
  47. package/docs/formats/wwise.md +44 -0
  48. package/docs/reference/events.md +92 -0
  49. package/docs/reference/motherlode-cache.md +244 -0
  50. package/docs/reference/queues.md +102 -0
  51. package/docs/reference/reload.md +107 -0
  52. package/docs/reference/texture-arrays.md +113 -0
  53. package/docs/reference/texture-pipeline.md +53 -0
  54. package/docs/roadmap.md +104 -0
  55. package/format-notices/gr2/LICENSE +21 -0
  56. package/format-notices/gr2/NOTICE +60 -0
  57. package/format-notices/gr2/THIRD-PARTY-NOTICES.md +93 -0
  58. package/package.json +51 -50
  59. package/resource-lifecycle.md +0 -679
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tr2TexturePipelineStepGenerateMips.js","sources":["../../../src/resources/Tr2TexturePipelineStepGenerateMips.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepGenerateMips.h\n// Marker step: Carbon registers the class with zero attributes; the mip\n// generation itself happens where the pipeline is executed.\nimport { type } from \"@carbonenginejs/core-types/schema\";\nimport { CjsModel } from \"@carbonenginejs/core-types/model\";\n\n/** Tr2TexturePipelineStepGenerateMips (resources) - attribute-free Blue marker class. */\n@type.define({ className: \"Tr2TexturePipelineStepGenerateMips\", family: \"resources\" })\nexport class Tr2TexturePipelineStepGenerateMips extends CjsModel\n{\n}\n"],"names":["_Tr2TexturePipelineSt","Tr2TexturePipelineStepGenerateMips","CjsModel","_initClass","_applyDecs","type","define","className","family","c"],"mappings":";;;;;;AAMA;AAAA,IAAAA;AACA,MAAAC,kCAAA,SACwDC,QAAQ,CAChE;AAAA,EAAA;IAAA,CAAAF,qBAAA,EAAAG,UAAA,CAAA,GAAAC,cAAA,CAAA,IAAA,EAAA,CAFCC,IAAI,CAACC,MAAM,CAAC;AAAEC,MAAAA,SAAS,EAAE,oCAAoC;AAAEC,MAAAA,MAAM,EAAE;AAAY,KAAC,CAAC,CAAA,EAAA,EAAA,EAAA,CAAA,EAAA,MAAA,EAC9BN,QAAQ,CAAA,CAAAO,CAAA;AAAA;AAAA,EAAA;IAAAN,UAAA,EAAA;AAAA;AAEhE;;;;"}
@@ -21,7 +21,7 @@ new class extends _identity {
21
21
  } = _applyDecs2311(this, [type.define({
22
22
  className: "TriGeometryRes",
23
23
  family: "resources"
24
- })], [[[io, io.readwrite, type, type.boolean], 16, "forceLod"], [[io, io.readwrite, type, type.int32], 16, "forcedLodIndex"], [[io, io.readwrite, type, type.string], 16, "name"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAnimationCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshAreaCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshName"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshAreaName"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAreaBoundingBox"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBoundingBox"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBoundingSphere"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "CalculateBoundingBoxFromTransform"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "RecalculateBoundingSphere"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "Reload"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "GetIntersectionPointNormalBone"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "GetAreaIntersectionPointNormalBone"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshVertexElements"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "SaveMesh"]], 0, void 0, _CjsResource));
24
+ })], [[[io, io.readwrite, type, type.boolean], 16, "forceLod"], [[io, io.readwrite, type, type.int32], 16, "forcedLodIndex"], [[io, io.readwrite, type, type.string], 16, "name"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAnimationCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetSkeletonCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetSkeletonData"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshAreaCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshName"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshAreaName"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAreaBoundingBox"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBoundingBox"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBoundingSphere"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "CalculateBoundingBoxFromTransform"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "RecalculateBoundingSphere"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "Reload"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "GetIntersectionPointNormalBone"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "GetAreaIntersectionPointNormalBone"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshVertexElements"], [[carbon, carbon.method, impl, impl.notImplemented], 18, "SaveMesh"]], 0, void 0, _CjsResource));
25
25
  }
26
26
  forceLod = (_initProto(this), _init_forceLod(this, false));
27
27
  forcedLodIndex = (_init_extra_forceLod(this), _init_forcedLodIndex(this, -1));
@@ -77,6 +77,29 @@ new class extends _identity {
77
77
  return this.GetPayload()?.animations?.length || 0;
78
78
  }
79
79
 
80
+ /**
81
+ * Get skeleton count from the CPU geometry payload.
82
+ *
83
+ * @returns {number}
84
+ */
85
+ GetSkeletonCount() {
86
+ return this.GetPayload()?.skeletons?.length || 0;
87
+ }
88
+
89
+ /**
90
+ * Get one resource-owned skeleton from the CPU geometry payload.
91
+ *
92
+ * @param {number} skeletonIndex
93
+ * @returns {*}
94
+ */
95
+ GetSkeletonData(skeletonIndex = 0) {
96
+ const index = Number(skeletonIndex);
97
+ if (!Number.isInteger(index) || index < 0) {
98
+ return null;
99
+ }
100
+ return this.GetPayload()?.skeletons?.[index] || null;
101
+ }
102
+
80
103
  /**
81
104
  * Get mesh area count from a CPU geometry payload mesh.
82
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"TriGeometryRes.js","sources":["../../../src/resources/TriGeometryRes.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TriGeometryRes.h\n// Source: trinity/trinity/Resources/TriGeometryRes.cpp\n// Source: trinity/trinity/Resources/TriGeometryRes_Blue.cpp\nimport { carbon, impl, io, type } from \"@carbonenginejs/core-types/schema\";\nimport { CjsResource } from \"../CjsResource.js\";\nimport {\n AssertResourcePayloadArray,\n AssertResourcePayloadObject,\n CarbonStubError,\n ResourcePayloadError\n} from \"./resourceBoundary.js\";\n\n/**\n * TriGeometryRes resource record.\n *\n * Geometry payload facts live here. Engine-gpu decides if and how they become\n * device buffers, vertex declarations, or draw-time state.\n */\n@type.define({ className: \"TriGeometryRes\", family: \"resources\" })\nexport class TriGeometryRes extends CjsResource\n{\n\n @io.readwrite\n @type.boolean\n forceLod = false;\n\n @io.readwrite\n @type.int32\n forcedLodIndex = -1;\n\n @io.readwrite\n @type.string\n name = \"\";\n\n constructor(values = null)\n {\n super();\n this.SetValues(values || {}, {\n markDirty: false,\n skipUpdate: true,\n skipEvents: true\n });\n }\n\n /**\n * Attach a plain geometry payload.\n *\n * @param {object|null} payload\n * @param {object|null} options\n * @returns {TriGeometryRes}\n */\n SetPayload(payload = null, options = null)\n {\n if (payload === null)\n {\n super.SetPayload(null);\n return this;\n }\n AssertResourcePayloadObject(\"TriGeometryRes\", payload);\n AssertResourcePayloadArray(\"TriGeometryRes\", payload, \"meshes\");\n for (const field of [ \"skeletons\", \"animations\" ])\n {\n if (payload[field] !== undefined && !Array.isArray(payload[field]))\n {\n throw ResourcePayloadError(\"TriGeometryRes\", \"Expected an array when provided.\", field);\n }\n }\n super.SetPayload(payload);\n this.SetValues(options || {});\n return this;\n }\n\n /**\n * Get mesh count from the CPU geometry payload.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMeshCount()\n {\n return this.GetPayload()?.meshes?.length || 0;\n }\n\n /**\n * Get animation count from the CPU geometry payload.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetAnimationCount()\n {\n return this.GetPayload()?.animations?.length || 0;\n }\n\n /**\n * Get mesh area count from a CPU geometry payload mesh.\n *\n * @param {number} meshIndex\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMeshAreaCount(meshIndex = 0)\n {\n const mesh = this.GetPayload()?.meshes?.[meshIndex];\n return mesh?.areas?.length || 0;\n }\n\n /**\n * Get mesh name from a CPU geometry payload.\n *\n * @param {number} meshIndex\n * @returns {string}\n */\n @carbon.method\n @impl.adapted\n GetMeshName(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.name || \"\";\n }\n\n /**\n * Get mesh area name from a CPU geometry payload.\n *\n * @param {number} meshIndex\n * @param {number} areaIndex\n * @returns {string}\n */\n @carbon.method\n @impl.adapted\n GetMeshAreaName(meshIndex = 0, areaIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.areas?.[areaIndex]?.name || \"\";\n }\n\n /**\n * Get area bounding box from geometry payload data.\n *\n * @param {number} meshIndex\n * @param {number} areaIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetAreaBoundingBox(meshIndex = 0, areaIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.areas?.[areaIndex]?.bounds || null;\n }\n\n /**\n * Get mesh bounding box from geometry payload data.\n * TODO: Should have a box3 as an argument, and write the result to that box3\n *\n * @param {number} meshIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetBoundingBox(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.bounds || this.GetPayload()?.bounds || null;\n }\n\n /**\n * Get mesh bounding sphere from geometry payload data.\n * TODO: Should have a sph4 as an argument, and write the result to that sph4\n *\n * @param {number} meshIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetBoundingSphere(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.sphere || this.GetPayload()?.sphere || null;\n }\n\n /**\n * Calculate a transformed bounding box for a mesh.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n CalculateBoundingBoxFromTransform()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"CalculateBoundingBoxFromTransform\");\n }\n\n /**\n * Recalculate bounding sphere data.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n RecalculateBoundingSphere()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"RecalculateBoundingSphere\");\n }\n\n /**\n * Reload this geometry resource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n Reload() {\n throw CarbonStubError(\"TriGeometryRes\", \"Reload\");\n }\n\n /**\n * Intersect a ray with this geometry resource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n GetIntersectionPointNormalBone()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"GetIntersectionPointNormalBone\");\n }\n\n /**\n * Intersect a ray with a single mesh area.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n GetAreaIntersectionPointNormalBone()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"GetAreaIntersectionPointNormalBone\");\n }\n\n /**\n * Get vertex element descriptors for a mesh.\n *\n * @param {number} meshIndex\n * @returns {Array<*>}\n */\n @carbon.method\n @impl.adapted\n GetMeshVertexElements(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.vertexElements || [];\n }\n\n /**\n * Save a mesh to a Granny file.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n SaveMesh()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"SaveMesh\");\n }\n\n static payload = \"geometry\";\n\n}\n"],"names":["_TriGeometryRes","_identity","TriGeometryRes","CjsResource","e","_init_forceLod","_init_extra_forceLod","_init_forcedLodIndex","_init_extra_forcedLodIndex","_init_name","_init_extra_name","_initProto","c","_initClass","_applyDecs","type","define","className","family","io","readwrite","boolean","int32","string","carbon","method","impl","adapted","notImplemented","forceLod","forcedLodIndex","name","constructor","values","SetValues","markDirty","skipUpdate","skipEvents","SetPayload","payload","options","AssertResourcePayloadObject","AssertResourcePayloadArray","field","undefined","Array","isArray","ResourcePayloadError","GetMeshCount","GetPayload","meshes","length","GetAnimationCount","animations","GetMeshAreaCount","meshIndex","mesh","areas","GetMeshName","GetMeshAreaName","areaIndex","GetAreaBoundingBox","bounds","GetBoundingBox","GetBoundingSphere","sphere","CalculateBoundingBoxFromTransform","CarbonStubError","RecalculateBoundingSphere","Reload","GetIntersectionPointNormalBone","GetAreaIntersectionPointNormalBone","GetMeshVertexElements","vertexElements","SaveMesh"],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAA;AAAA,IAAA,cAAAC,SAAA,CAAA;AAAA,EAAA,QAMA,MAAAC,cAAA,SACoCC,YAAW,CAC/C;AAAA,IAAA;AAAA,MAAA,CAAA;AAAAC,QAAAA,CAAA,EAAA,CAAAC,cAAA,EAAAC,oBAAA,EAAAC,oBAAA,EAAAC,0BAAA,EAAAC,UAAA,EAAAC,gBAAA,EAAAC,UAAA,CAAA;QAAAC,CAAA,EAAA,CAAAZ,eAAA,EAAAa,UAAA;AAAA,OAAA,GAAAC,cAAA,CAAA,IAAA,EAAA,CAFCC,I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AAGEC,IAAAA,QAAQA,GACR;AACE,MAAA,MAAMP,eAAe,CAAC,gBAAgB,EAAE,UAAU,CAAC;AACrD,IAAA;GAID;AAFQ5B,EAAAA,OAAO,GAAG,UAAU;EAACP,WAAAA,GAAA;IAAA,KAAA,CAAAhC,eAAA,GAAAa,UAAA,EAAA;AAAA,EAAA;AAAA,CAAA,EAAA;;;;"}
1
+ {"version":3,"file":"TriGeometryRes.js","sources":["../../../src/resources/TriGeometryRes.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TriGeometryRes.h\n// Source: trinity/trinity/Resources/TriGeometryRes.cpp\n// Source: trinity/trinity/Resources/TriGeometryRes_Blue.cpp\nimport { carbon, impl, io, type } from \"@carbonenginejs/core-types/schema\";\nimport { CjsResource } from \"../CjsResource.js\";\nimport {\n AssertResourcePayloadArray,\n AssertResourcePayloadObject,\n CarbonStubError,\n ResourcePayloadError\n} from \"./resourceBoundary.js\";\n\n/**\n * TriGeometryRes resource record.\n *\n * Geometry payload facts live here. Engine-gpu decides if and how they become\n * device buffers, vertex declarations, or draw-time state.\n */\n@type.define({ className: \"TriGeometryRes\", family: \"resources\" })\nexport class TriGeometryRes extends CjsResource\n{\n\n @io.readwrite\n @type.boolean\n forceLod = false;\n\n @io.readwrite\n @type.int32\n forcedLodIndex = -1;\n\n @io.readwrite\n @type.string\n name = \"\";\n\n constructor(values = null)\n {\n super();\n this.SetValues(values || {}, {\n markDirty: false,\n skipUpdate: true,\n skipEvents: true\n });\n }\n\n /**\n * Attach a plain geometry payload.\n *\n * @param {object|null} payload\n * @param {object|null} options\n * @returns {TriGeometryRes}\n */\n SetPayload(payload = null, options = null)\n {\n if (payload === null)\n {\n super.SetPayload(null);\n return this;\n }\n AssertResourcePayloadObject(\"TriGeometryRes\", payload);\n AssertResourcePayloadArray(\"TriGeometryRes\", payload, \"meshes\");\n for (const field of [ \"skeletons\", \"animations\" ])\n {\n if (payload[field] !== undefined && !Array.isArray(payload[field]))\n {\n throw ResourcePayloadError(\"TriGeometryRes\", \"Expected an array when provided.\", field);\n }\n }\n super.SetPayload(payload);\n this.SetValues(options || {});\n return this;\n }\n\n /**\n * Get mesh count from the CPU geometry payload.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMeshCount()\n {\n return this.GetPayload()?.meshes?.length || 0;\n }\n\n /**\n * Get animation count from the CPU geometry payload.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetAnimationCount()\n {\n return this.GetPayload()?.animations?.length || 0;\n }\n\n /**\n * Get skeleton count from the CPU geometry payload.\n *\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetSkeletonCount()\n {\n return this.GetPayload()?.skeletons?.length || 0;\n }\n\n /**\n * Get one resource-owned skeleton from the CPU geometry payload.\n *\n * @param {number} skeletonIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetSkeletonData(skeletonIndex = 0)\n {\n const index = Number(skeletonIndex);\n\n if (!Number.isInteger(index) || index < 0)\n {\n return null;\n }\n\n return this.GetPayload()?.skeletons?.[index] || null;\n }\n\n /**\n * Get mesh area count from a CPU geometry payload mesh.\n *\n * @param {number} meshIndex\n * @returns {number}\n */\n @carbon.method\n @impl.adapted\n GetMeshAreaCount(meshIndex = 0)\n {\n const mesh = this.GetPayload()?.meshes?.[meshIndex];\n return mesh?.areas?.length || 0;\n }\n\n /**\n * Get mesh name from a CPU geometry payload.\n *\n * @param {number} meshIndex\n * @returns {string}\n */\n @carbon.method\n @impl.adapted\n GetMeshName(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.name || \"\";\n }\n\n /**\n * Get mesh area name from a CPU geometry payload.\n *\n * @param {number} meshIndex\n * @param {number} areaIndex\n * @returns {string}\n */\n @carbon.method\n @impl.adapted\n GetMeshAreaName(meshIndex = 0, areaIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.areas?.[areaIndex]?.name || \"\";\n }\n\n /**\n * Get area bounding box from geometry payload data.\n *\n * @param {number} meshIndex\n * @param {number} areaIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetAreaBoundingBox(meshIndex = 0, areaIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.areas?.[areaIndex]?.bounds || null;\n }\n\n /**\n * Get mesh bounding box from geometry payload data.\n * TODO: Should have a box3 as an argument, and write the result to that box3\n *\n * @param {number} meshIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetBoundingBox(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.bounds || this.GetPayload()?.bounds || null;\n }\n\n /**\n * Get mesh bounding sphere from geometry payload data.\n * TODO: Should have a sph4 as an argument, and write the result to that sph4\n *\n * @param {number} meshIndex\n * @returns {*}\n */\n @carbon.method\n @impl.adapted\n GetBoundingSphere(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.sphere || this.GetPayload()?.sphere || null;\n }\n\n /**\n * Calculate a transformed bounding box for a mesh.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n CalculateBoundingBoxFromTransform()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"CalculateBoundingBoxFromTransform\");\n }\n\n /**\n * Recalculate bounding sphere data.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n RecalculateBoundingSphere()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"RecalculateBoundingSphere\");\n }\n\n /**\n * Reload this geometry resource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n Reload() {\n throw CarbonStubError(\"TriGeometryRes\", \"Reload\");\n }\n\n /**\n * Intersect a ray with this geometry resource.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n GetIntersectionPointNormalBone()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"GetIntersectionPointNormalBone\");\n }\n\n /**\n * Intersect a ray with a single mesh area.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n GetAreaIntersectionPointNormalBone()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"GetAreaIntersectionPointNormalBone\");\n }\n\n /**\n * Get vertex element descriptors for a mesh.\n *\n * @param {number} meshIndex\n * @returns {Array<*>}\n */\n @carbon.method\n @impl.adapted\n GetMeshVertexElements(meshIndex = 0)\n {\n return this.GetPayload()?.meshes?.[meshIndex]?.vertexElements || [];\n }\n\n /**\n * Save a mesh to a Granny file.\n *\n * @throws {Error}\n */\n @carbon.method\n @impl.notImplemented\n SaveMesh()\n {\n throw CarbonStubError(\"TriGeometryRes\", \"SaveMesh\");\n }\n\n static payload = \"geometry\";\n\n}\n"],"names":["_TriGeometryRes","_identity","TriGeometryRes","CjsResource","e","_init_forceLod","_init_extra_forceLod","_init_forcedLodIndex","_init_extra_forcedLodIndex","_init_name","_init_extra_name","_initProto","c","_initClass","_applyDecs","type","define","className","family","io","readwrite","boolean","int32","string","carbon","method","impl","adapted","notImplemented","forceLod","forcedLodIndex","name","constructor","values","SetValues","markDirty","skipUpdate","skipEvents","SetPayload","payload","options","AssertResourcePayloadObject","AssertResourcePayloadArray","field","undefined","Array","isArray","ResourcePayloadError","GetMeshCount","GetPayload","meshes","length","GetAnimationCount","animations","GetSkeletonCount","skeletons","GetSkeletonData","skeletonIndex","index","Number","isInteger","GetMeshAreaCount","meshIndex","mesh","areas","GetMeshName","GetMeshAreaName","areaIndex","GetAreaBoundingBox","bounds","GetBoundingBox","GetBoundingSphere","sphere","CalculateBoundingBoxFromTransform","CarbonStubError","RecalculateBoundingSphere","Reload","GetIntersectionPointNormalBone","GetAreaIntersectionPointNormalBone","GetMeshVertexElements","vertexElements","SaveMesh"],"mappings":";;;;;;;AAYA;AACA;AACA;AACA;AACA;AACA;AALA,IAAAA;AAAA,IAAA,cAAAC,SAAA,CAAA;AAAA,EAAA,QAMA,MAAAC,cAAA,SACoCC,YAAW,CAC/C;AAAA,IAAA;AAAA,MAAA,CAAA;AAAAC,QAAAA,CAAA,EAAA,CAAAC,cAAA,EAAAC,oBAAA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}
package/docs/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Package documentation
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource`
5
+ Audience: Users and integrators
6
+ Summary: Documentation home for the GPU-free resource lifecycle, cache, format, and object-loading package.
7
+
8
+ ## Purpose
9
+
10
+ `@carbonenginejs/runtime-resource` owns the GPU-free resource layer of
11
+ CarbonEngineJS: resource identity and state, the MotherLode cache, semantic
12
+ resource classes, registered format readers, source adapters, and the queued
13
+ CPU load/publication pipeline. It stops at a published CPU payload; engine
14
+ packages realize that payload into backend objects.
15
+
16
+ ## Use this package when
17
+
18
+ - you need Carbon-shaped resource loading (`res:/` paths, requirement/emit
19
+ selection, `Ready()`/`GetObject()`) without choosing a GPU backend;
20
+ - you need one of the non-shader format readers as a tree-shakeable subpath
21
+ (`@carbonenginejs/runtime-resource/formats/<name>`);
22
+ - you are writing an engine adapter that consumes published CPU payloads and
23
+ needs the documented retention, reload, and texture-array contracts.
24
+
25
+ ## Where it fits
26
+
27
+ - Foundations consumed: `@carbonenginejs/core-types` (event emitter, model
28
+ contracts) and `@carbonenginejs/core-math` where formats need math values.
29
+ - Normal consumers: `runtime-core` (configures and exposes a `CjsResMan`),
30
+ `runtime-trinity` and `runtime-sof` (request GPU-free objects), and engine
31
+ packages (`engine-webgpu`, future WebGL engines) that realize prepared
32
+ resources.
33
+ - Owned responsibility: resource identity, cache, CPU payload lifecycle,
34
+ format selection and conversion, and load/publication queues.
35
+ - Owned elsewhere: WebGL/WebGPU realization, device budgets, and device-loss
36
+ recovery belong to engine packages; shader formats belong to the dedicated
37
+ shader format packages.
38
+
39
+ ## Start here
40
+
41
+ - [Architecture and boundaries](architecture.md)
42
+ - [Resource lifecycle concepts](concepts/resource-lifecycle.md)
43
+ - [Format subpaths](formats/README.md)
44
+
45
+ ## Documentation map
46
+
47
+ - [architecture.md](architecture.md): package boundary, relationships, and the
48
+ GPU-free split.
49
+ - [concepts/resource-lifecycle.md](concepts/resource-lifecycle.md): states,
50
+ the load/prepare split, and the request workflow.
51
+ - [reference/motherlode-cache.md](reference/motherlode-cache.md): canonical
52
+ identity, byte-budget cache, payload retention, and purge contracts.
53
+ - [reference/reload.md](reference/reload.md): the candidate-first atomic
54
+ reload contract.
55
+ - [reference/queues.md](reference/queues.md): queued CPU load, publication,
56
+ registration, and the `Wait()` fence.
57
+ - [reference/texture-arrays.md](reference/texture-arrays.md): texture-array
58
+ proxies, update generations, and adapter commits.
59
+ - [reference/texture-pipeline.md](reference/texture-pipeline.md):
60
+ `Tr2TexturePipeline` CPU steps and `Tr2TextureLodManager` membership.
61
+ - [reference/events.md](reference/events.md): the `CjsEventEmitter` contract
62
+ and event memory rules.
63
+ - [formats/README.md](formats/README.md): format import map and per-format
64
+ output notes.
65
+ - [formats/wwise.md](formats/wwise.md): Wwise soundbank and media readers.
66
+ - [formats/stl.md](formats/stl.md): STL geometry export.
67
+ - [formats/provenance.md](formats/provenance.md): format ownership, fork
68
+ provenance, and retained snapshots.
69
+ - [roadmap.md](roadmap.md): approved future direction that is not implemented.
@@ -0,0 +1,86 @@
1
+ # Architecture and boundaries
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource`
5
+ Audience: Users and integrators
6
+ Summary: Defines the GPU-free boundary this package owns and how engine and runtime packages relate to it.
7
+
8
+ ## The GPU-free split
9
+
10
+ `runtime-resource` owns the GPU-free half of the Carbon resource lifecycle:
11
+
12
+ ```text
13
+ EMPTY -> REQUESTED/LOADING -> LOADED
14
+ ```
15
+
16
+ Engine adapters own device realization:
17
+
18
+ ```text
19
+ LOADED -> PREPARING -> PREPARED
20
+ ```
21
+
22
+ The package selects and runs registered non-shader readers, hydrates or
23
+ returns the promised CPU outcome, and stores lifecycle state, cache entries,
24
+ and loaded payloads. It never creates WebGL/WebGPU textures, buffers, shader
25
+ modules, pipelines, or bind groups, and it never inspects backend capability.
26
+ A realization failure destroys its candidate and returns the resource to
27
+ `LOADED` without discarding the valid CPU payload.
28
+
29
+ This deliberately differs from Carbon and ccpwgl, whose resource classes live
30
+ inside an engine that can prepare GPU objects directly. Keeping the
31
+ format/resource layer reusable means stopping before GPU work; see
32
+ [resource lifecycle concepts](concepts/resource-lifecycle.md) for the
33
+ historical mapping.
34
+
35
+ ## What the package owns
36
+
37
+ - `CjsResource` state and Carbon-style resource methods.
38
+ - `CjsMotherLode` canonical identity, explicit replacement results, activity
39
+ and lock metadata, deterministic payload/adapter cleanup, and cache stats.
40
+ - `CjsResMan` semantic resource construction, registered-format selection,
41
+ concurrency-limited source loading, staged prepare queues, layered
42
+ source/read/resource deduplication, object loader dispatch, and prefetch.
43
+ - `CjsTextureArrayRes` and `CjsTextureParameterProxy` for material-facing,
44
+ frame-coalesced texture-array inputs.
45
+ - Raw `CjsEventEmitter` (from `core-types/model`) for manager/runtime events
46
+ without requiring `CjsModel` inheritance.
47
+ - Path normalization, extension helpers, and source adapters for memory and
48
+ `fetch`.
49
+ - Plain reader/converter payload objects with focused shared validators.
50
+ - Canonical Carbon resource classes that validate and hold CPU payloads
51
+ privately: `TriTextureRes`, `TriGeometryRes`, `Tr2EffectRes`, `Tr2ImageRes`,
52
+ `TriGrannyRes`, `Tr2GrannyStateRes`, and `Tr2LightProfileRes`.
53
+ - `Tr2TexturePipeline` CPU-only texture steps and `Tr2TextureLodManager`
54
+ membership.
55
+ - Opaque engine-owned subobject slots for backend adapters.
56
+ - Non-shader format implementations as explicit tree-shakeable subpaths under
57
+ `@carbonenginejs/runtime-resource/formats/<name>`.
58
+
59
+ ## What the package does not own
60
+
61
+ - WebGL/WebGPU realization, allocations, upload accounting, device budgets,
62
+ capability limits, and device-loss recovery (engine packages).
63
+ - Shader formats (`format-dxbc`, `format-hlsl`, `format-webgl`,
64
+ `format-webgpu` remain separate packages).
65
+ - AudioBuffer construction, playback, or audio manager behavior.
66
+
67
+ ## Package relationships
68
+
69
+ - `runtime-core` may configure and expose a `CjsResMan`, but does not own its
70
+ implementation.
71
+ - `runtime-trinity` and `runtime-sof` may request GPU-free objects and
72
+ resources without selecting an engine.
73
+ - `engine-webgpu` and future WebGL engines consume loaded resources and own
74
+ all backend allocations, preparation, replacement, and destruction.
75
+
76
+ Concrete formats are not imported or registered by the package root; see
77
+ [formats/README.md](formats/README.md) for the import rule and map.
78
+
79
+ ## Source layout
80
+
81
+ Authoring source is decorated JavaScript; published output is built ESM in
82
+ `npm/dist`. Completed Carbon data classes live with maintained source under
83
+ `src/resources`; `src/generated` is reserved for unresolved active ports and
84
+ is currently absent. Native shapes that JavaScript replaces or does not use
85
+ are retained only under `src/dropped`, with their disposition documented
86
+ there, and are never exported or bundled.
@@ -0,0 +1,217 @@
1
+ # Resource lifecycle
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource`
5
+ Audience: Users and integrators
6
+ Summary: Explains resource states, the load/prepare split, and how a resource request flows from path to published CPU payload.
7
+
8
+ ## Carbon and ccpwgl background
9
+
10
+ Carbon's resource model separates load from prepare. The source schemas expose
11
+ resource classes through `BlueAsyncRes`, and Carbon notes distinguish
12
+ background load work from main-thread/device prepare work.
13
+
14
+ ccpwgl makes that split visible in `Tw2Resource`:
15
+
16
+ ```text
17
+ NO_INIT -> REQUESTED -> LOADED -> PREPARED
18
+ ```
19
+
20
+ Additional terminal or cleanup states include `ERROR`, `UNLOADED`, and
21
+ `PURGED`. The important behavior is:
22
+
23
+ - `Tw2ResMan.LoadResource()` requests a resource.
24
+ - The raw fetch resolves.
25
+ - `Tw2Resource.OnLoaded()` marks bytes or source data as loaded.
26
+ - The resource is queued for prepare.
27
+ - The manager tick later calls `res.Prepare(data)`.
28
+ - The concrete resource calls `OnPrepared()` after prepare work succeeds.
29
+
30
+ Some ccpwgl concrete `Prepare()` implementations also create WebGL objects.
31
+ That is a historical engine/runtime coupling, not the boundary CarbonEngineJS
32
+ keeps; see [architecture](../architecture.md).
33
+
34
+ ## CarbonEngineJS states
35
+
36
+ ```text
37
+ EMPTY -> REQUESTED/LOADING -> LOADED (runtime-resource)
38
+ LOADED -> PREPARING -> PREPARED (engine adapters)
39
+ ```
40
+
41
+ - `EMPTY`: resource identity exists, but no payload has been read.
42
+ - `REQUESTED`: the resource is waiting on a queued or shared source load.
43
+ - `LOADING`: source bytes are available and CPU reader/format work is active.
44
+ - `LOADED`: CPU payload or hydrated object graph exists.
45
+ - `PREPARING`: an engine adapter is realizing backend-owned resources.
46
+ - `PREPARED`: preparation completed successfully and the resource is usable.
47
+ - `FAILED`: CPU loading, conversion, validation, or publication failed before
48
+ a valid payload was published.
49
+ - `UNLOADED`: resource payload was released.
50
+ - `PURGED`: an inactivity or recorded-byte cache policy evicted the resource
51
+ from active ownership. Ordinary replacement, `Delete()`, `Clear()`,
52
+ `ClearCached()`, and shutdown clean owned payloads/adapters but preserve the
53
+ detached handle's last valid state.
54
+
55
+ `CjsResMan.LoadObject()` queues one deduplicated background source operation
56
+ per source/path and limits active source operations with
57
+ `maxConcurrentLoads`. After bytes arrive, object construction is split into
58
+ separate main-queue items (`reader/format conversion -> publish`). Publication
59
+ moves the resource to `LOADED`, then stops. ResMan never performs backend
60
+ realization or marks the resource `PREPARED`/`GOOD`. See
61
+ [reference/queues.md](../reference/queues.md) for the queue contract and
62
+ [reference/motherlode-cache.md](../reference/motherlode-cache.md) for
63
+ identity, retention, and release behavior.
64
+
65
+ ## Request workflow
66
+
67
+ The normal direct resource-path flow is:
68
+
69
+ ```text
70
+ Application / runtime object
71
+ |
72
+ | requests "res:/model/ship.gr2"
73
+ | with optional per-request overrides
74
+ v
75
+ +-----------------------------------------------+
76
+ | CjsLibrary |
77
+ | |
78
+ | - starts from registered default behavior |
79
+ | - considers registered capability reports |
80
+ | - chooses requirement / emit / format |
81
+ | - applies explicit request overrides |
82
+ +-----------------------------------------------+
83
+ |
84
+ | path + resolved request options
85
+ v
86
+ +-----------------------------------------------+
87
+ | CjsResMan.GetResource(path, options) |
88
+ | |
89
+ | - normalize source path and extension |
90
+ | - resolve the promised output tag |
91
+ +-----------------------------------------------+
92
+ |
93
+ v
94
+ +-----------------------------------------------+
95
+ | CjsMotherLode.Lookup(resolved key) |
96
+ +-----------------------------------------------+
97
+ |
98
+ +--- cache hit ------------------------------+
99
+ | |
100
+ | reuse the CjsResource and any active |
101
+ | load/build operation |
102
+ | |
103
+ `--- cache miss -----------------------------+
104
+ | |
105
+ | resolve class from requirement |
106
+ | construct + Initialize() |
107
+ | insert into CjsMotherLode |
108
+ v |
109
+ new CjsResource -------------------------------+
110
+ |
111
+ | Ready() / GetObject()
112
+ v
113
+ +===============================================+
114
+ | BACKGROUND LOAD QUEUE |
115
+ | |
116
+ | - mark resource REQUESTED |
117
+ | - share one source operation per source/path |
118
+ | - obey maxConcurrentLoads |
119
+ | - source.Read(path) |
120
+ +===============================================+
121
+ |
122
+ | source bytes
123
+ v
124
+ +===============================================+
125
+ | MAIN PREPARE QUEUE |
126
+ | |
127
+ | every box below is a separately budgeted item |
128
+ +===============================================+
129
+ |
130
+ v
131
+ +-----------------------------------------------+
132
+ | Read stage |
133
+ | |
134
+ | current object loader for extension? |
135
+ | yes -> call it |
136
+ | no -> resolve registered formats by |
137
+ | bytes + request options |
138
+ +-----------------------------------------------+
139
+ |
140
+ | plain payload / hydrated object
141
+ v
142
+ +-----------------------------------------------+
143
+ | Publish stage |
144
+ | |
145
+ | semantic resource -> SetPayload(payload) |
146
+ | generic resource -> SetPayload(value) |
147
+ | object aliases payload |
148
+ +-----------------------------------------------+
149
+ |
150
+ +--- validation failure --------------------+
151
+ | |
152
+ | resource -> FAILED |
153
+ | Ready() rejects |
154
+ | |
155
+ `--- publication succeeds -----------------+
156
+ |
157
+ | resource -> LOADED
158
+ v
159
+ CjsLibrary returns
160
+ the built CjsResource/object
161
+ ```
162
+
163
+ Device realization is a separate continuation selected outside ResMan. It can
164
+ run again after adapter eviction or device loss while the CPU payload remains
165
+ resident:
166
+
167
+ ```text
168
+ CjsResource LOADED
169
+ |
170
+ | selected engine adapter
171
+ v
172
+ PREPARING
173
+ |
174
+ | create candidate -> verify current target -> synchronous attach
175
+ v
176
+ PREPARED
177
+
178
+ failure: destroy candidate -> LOADED (CPU payload retained)
179
+ ```
180
+
181
+ ## Retention model
182
+
183
+ ccpwgl keeps every resource in `Tw2MotherLode` until it is explicitly cleared
184
+ or auto-purged, and its `IsGood()` implicitly calls `KeepAlive()`, so many
185
+ read/check paths keep resources resident. CarbonEngineJS is deliberately more
186
+ explicit:
187
+
188
+ - `IsGood()`, `IsPrepared()`, and `HasLoaded()` remain pure state checks.
189
+ - `KeepAlive()` and `KeepPayloadAlive()` are the explicit liveness operations.
190
+ - `Lock()` / `Unlock()` maintain a non-underflowing count and prevent identity
191
+ and payload eviction during a sweep.
192
+ - MotherLode tracks separate identity and CPU-payload frame/time observations.
193
+ - `CjsMotherLode.PurgeInactive()` scans only when explicitly requested and
194
+ never infers JavaScript reachability. `CjsResMan.Update()` may request it
195
+ only under an explicitly configured automatic policy.
196
+
197
+ The CPU/GPU split adds an axis that ccpwgl blurs: CPU payload memory and
198
+ device memory are different budgets. Retention therefore distinguishes:
199
+
200
+ - resource identity: path, extension, state, error summary, lightweight
201
+ metadata;
202
+ - CPU payload: plain reader/converter objects, hydrated object graphs, decoded
203
+ typed arrays;
204
+ - adapter payload: WebGL/WebGPU textures, buffers, shader modules, pipelines.
205
+
206
+ Identity and lightweight metadata stay resident while CPU payloads and adapter
207
+ payloads release independently. Engine adapters own adapter-resource
208
+ destruction; runtime-resource provides lifecycle hooks and opaque adapter
209
+ slots so cleanup has a consistent place to run. The exact contracts live in
210
+ [reference/motherlode-cache.md](../reference/motherlode-cache.md).
211
+
212
+ ## Related documentation
213
+
214
+ - [Architecture and boundaries](../architecture.md)
215
+ - [MotherLode identity, cache, and retention](../reference/motherlode-cache.md)
216
+ - [Candidate-first atomic reload](../reference/reload.md)
217
+ - [Queues and the Wait fence](../reference/queues.md)
@@ -0,0 +1,104 @@
1
+ # Format subpaths
2
+
3
+ Status: Evolving
4
+ Scope: `@carbonenginejs/runtime-resource/formats`
5
+ Audience: Users and integrators
6
+ Summary: Maps every non-shader format subpath and records cross-format output conventions.
7
+
8
+ ## Import rule
9
+
10
+ Concrete formats are never imported or registered by the package root. Each
11
+ format is an explicit tree-shakeable subpath, registered by the caller:
12
+
13
+ ```js
14
+ import { CjsResMan } from "@carbonenginejs/runtime-resource";
15
+ import { CjsMp4Format } from "@carbonenginejs/runtime-resource/formats/mp4";
16
+
17
+ const resMan = new CjsResMan().Register({
18
+ source,
19
+ formats: [ CjsMp4Format ]
20
+ });
21
+
22
+ const resource = resMan.GetResource("res:/video/intro.mp4");
23
+ const video = await resource.Ready();
24
+ ```
25
+
26
+ Formats return plain payload objects. Semantic resource classes apply them
27
+ through `SetPayload()`, validate their own required fields, and throw
28
+ `CJS_RESOURCE_PAYLOAD_INVALID` before replacing a previously valid payload.
29
+ `GetPayload()`, `HasPayload()`, and `ReleasePayload()` manage transient CPU
30
+ retention without introducing a parallel DTO class hierarchy.
31
+
32
+ ## Format map
33
+
34
+ | Format | Class | Import |
35
+ |---|---|---|
36
+ | Black (`.black`) | `CjsBlackFormat` | `@carbonenginejs/runtime-resource/formats/black` |
37
+ | Wwise soundbank (`.bnk`) | `CjsBnkFormat` | `@carbonenginejs/runtime-resource/formats/bnk` |
38
+ | CMF (`.cmf`) | `CjsCmfFormat` | `@carbonenginejs/runtime-resource/formats/cmf` |
39
+ | DDS (`.dds`) | `CjsDdsFormat` | `@carbonenginejs/runtime-resource/formats/dds` |
40
+ | FBX (`.fbx`) | `CjsFbxFormat` | `@carbonenginejs/runtime-resource/formats/fbx` |
41
+ | FLAC (`.flac`) | `CjsFlacFormat` | `@carbonenginejs/runtime-resource/formats/flac` |
42
+ | GIF (`.gif`) | `CjsGifFormat` | `@carbonenginejs/runtime-resource/formats/gif` |
43
+ | glTF (`.gltf`/`.glb`) | `CjsGltfFormat` | `@carbonenginejs/runtime-resource/formats/gltf` |
44
+ | Granny GR2/GSF (`.gr2`/`.gsf`) | `CjsGr2Format` | `@carbonenginejs/runtime-resource/formats/gr2` |
45
+ | JPEG (`.jpg`/`.jpeg`) | `CjsJpegFormat` | `@carbonenginejs/runtime-resource/formats/jpeg` |
46
+ | MP3 (`.mp3`) | `CjsMp3Format` | `@carbonenginejs/runtime-resource/formats/mp3` |
47
+ | MP4 (`.mp4`) | `CjsMp4Format` | `@carbonenginejs/runtime-resource/formats/mp4` |
48
+ | OBJ (`.obj`) | `CjsObjFormat` | `@carbonenginejs/runtime-resource/formats/obj` |
49
+ | Ogg (`.ogg`) | `CjsOggFormat` | `@carbonenginejs/runtime-resource/formats/ogg` |
50
+ | PNG (`.png`) | `CjsPngFormat` | `@carbonenginejs/runtime-resource/formats/png` |
51
+ | Red (`.red`) | `CjsRedFormat` | `@carbonenginejs/runtime-resource/formats/red` |
52
+ | STL (`.stl`) | `CjsStlFormat` | `@carbonenginejs/runtime-resource/formats/stl` |
53
+ | TGA (`.tga`) | `CjsTgaFormat` | `@carbonenginejs/runtime-resource/formats/tga` |
54
+ | WAV (`.wav`) | `CjsWavFormat` | `@carbonenginejs/runtime-resource/formats/wav` |
55
+ | WebM (`.webm`) | `CjsWebmFormat` | `@carbonenginejs/runtime-resource/formats/webm` |
56
+ | WebP (`.webp`) | `CjsWebpFormat` | `@carbonenginejs/runtime-resource/formats/webp` |
57
+ | Wwise media (`.wem`) | `CjsWemFormat` | `@carbonenginejs/runtime-resource/formats/wem` |
58
+ | YAML (`.yaml`/`.yml`) | `CjsYamlFormat` | `@carbonenginejs/runtime-resource/formats/yaml` |
59
+
60
+ Detailed pages: [Wwise soundbanks and media](wwise.md),
61
+ [STL export](stl.md). Ownership history, retained snapshots, and donor
62
+ licensing are recorded in [provenance.md](provenance.md).
63
+
64
+ ## Granny GR2/GSF
65
+
66
+ `CjsGr2Format` reads `.gr2` geometry/skeleton/animation graphs and `.gsf`
67
+ (GState) profiles with no native tooling: section decompression (None,
68
+ Oodle1, and the clean-room BitKnit2 decoder), reflected type-tree walking,
69
+ GR2 JSON emission, optional curve decompression, CCP packed tangent-frame
70
+ unpacking, and caller-class hydration (`emit: "gr2"`/`"cmf"` with a
71
+ `classes` map). It was migrated from `@carbonenginejs/format-gr2` after that
72
+ package's 2026-07-24 MIT relicense; the frozen donor repository documents
73
+ the reader API and JSON graph in detail, and this copy preserves its
74
+ behavior and test surface.
75
+
76
+ ## Red output markers
77
+
78
+ Red payload output reserves configurable type, ID, reference, and sequence
79
+ values markers (`_type`, `_id`, `_reference`, and `_values` by default).
80
+ Repeated or cyclic sequences use an ID-bearing values envelope; unique
81
+ sequences remain arrays. Authored fields may not collide with active markers,
82
+ so remap the marker options when those names are real data. Disabling the
83
+ reference marker preserves actual JavaScript identity; cyclic output in that
84
+ mode is intentionally not JSON-serializable.
85
+
86
+ ## DDS decoded fallback
87
+
88
+ Decoded DDS fallback currently has a narrower contract than native DDS
89
+ texture output. `emit: "rgba"` returns one canonical 2D surface decoded from
90
+ the first DDS subresource; it does not preserve stored mip levels, cube
91
+ faces, array layers, or volume slices. Consumers may use it for ordinary 2D
92
+ fallback when the engine owns any required mip generation, but must not infer
93
+ decoded multi-subresource support from a successful RGBA probe. A future
94
+ richer decoded-texture contract must be introduced explicitly rather than
95
+ overloading the current RGBA fields.
96
+
97
+ The software path includes BC1-BC5 and BC7 as RGBA8, plus signed and unsigned
98
+ BC6H as linear `Float32Array` RGBA without clamping HDR values. These block
99
+ decoders are implemented in-project with no codec package.
100
+
101
+ ## Related documentation
102
+
103
+ - [Queues, publication, and registration](../reference/queues.md)
104
+ - [Format ownership and fork provenance](provenance.md)