@carbonenginejs/runtime-resource 0.1.0 → 0.7.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 (186) hide show
  1. package/FORMAT-PROVENANCE.md +14 -5
  2. package/README.md +537 -241
  3. package/dist/CjsMotherLode.js +1244 -29
  4. package/dist/CjsMotherLode.js.map +1 -1
  5. package/dist/CjsResMan.js +2537 -272
  6. package/dist/CjsResMan.js.map +1 -1
  7. package/dist/CjsResource.js +218 -18
  8. package/dist/CjsResource.js.map +1 -1
  9. package/dist/format/CjsBlueReader.js +269 -0
  10. package/dist/format/CjsBlueReader.js.map +1 -0
  11. package/dist/format/CjsFormat.js +44 -30
  12. package/dist/format/CjsFormat.js.map +1 -1
  13. package/dist/format/CjsReader.js +18 -0
  14. package/dist/format/CjsReader.js.map +1 -0
  15. package/dist/format/CjsResourceProbe.js +12 -4
  16. package/dist/format/CjsResourceProbe.js.map +1 -1
  17. package/dist/formats/black/CjsBlackFormat.js +12 -6
  18. package/dist/formats/black/CjsBlackFormat.js.map +1 -1
  19. package/dist/formats/black/core/CjsBlackReader.js +27 -148
  20. package/dist/formats/black/core/CjsBlackReader.js.map +1 -1
  21. package/dist/formats/bnk/CjsBnkFormat.js +140 -147
  22. package/dist/formats/bnk/CjsBnkFormat.js.map +1 -1
  23. package/dist/formats/bnk/core/graph.js +140 -0
  24. package/dist/formats/bnk/core/graph.js.map +1 -0
  25. package/dist/formats/bnk/core/helpers.js +58 -3
  26. package/dist/formats/bnk/core/helpers.js.map +1 -1
  27. package/dist/formats/bnk/core/musicNodes.js +521 -0
  28. package/dist/formats/bnk/core/musicNodes.js.map +1 -0
  29. package/dist/formats/bnk/index.js +0 -1
  30. package/dist/formats/bnk/index.js.map +1 -1
  31. package/dist/formats/cmf/CjsCmfFormat.js +14 -8
  32. package/dist/formats/cmf/CjsCmfFormat.js.map +1 -1
  33. package/dist/formats/dds/CjsDdsFormat.js +12 -6
  34. package/dist/formats/dds/CjsDdsFormat.js.map +1 -1
  35. package/dist/formats/fbx/CjsFbxFormat.js +12 -6
  36. package/dist/formats/fbx/CjsFbxFormat.js.map +1 -1
  37. package/dist/formats/flac/CjsFlacFormat.js +10 -4
  38. package/dist/formats/flac/CjsFlacFormat.js.map +1 -1
  39. package/dist/formats/gif/CjsGifFormat.js +11 -5
  40. package/dist/formats/gif/CjsGifFormat.js.map +1 -1
  41. package/dist/formats/gltf/CjsGltfFormat.js +12 -6
  42. package/dist/formats/gltf/CjsGltfFormat.js.map +1 -1
  43. package/dist/formats/jpeg/CjsJpegFormat.js +11 -5
  44. package/dist/formats/jpeg/CjsJpegFormat.js.map +1 -1
  45. package/dist/formats/mp3/CjsMp3Format.js +11 -5
  46. package/dist/formats/mp3/CjsMp3Format.js.map +1 -1
  47. package/dist/formats/mp4/CjsMp4Format.js +10 -4
  48. package/dist/formats/mp4/CjsMp4Format.js.map +1 -1
  49. package/dist/formats/obj/CjsObjFormat.js +12 -6
  50. package/dist/formats/obj/CjsObjFormat.js.map +1 -1
  51. package/dist/formats/ogg/CjsOggFormat.js +9 -3
  52. package/dist/formats/ogg/CjsOggFormat.js.map +1 -1
  53. package/dist/formats/png/CjsPngFormat.js +11 -5
  54. package/dist/formats/png/CjsPngFormat.js.map +1 -1
  55. package/dist/formats/red/CjsRedFormat.js +19 -5
  56. package/dist/formats/red/CjsRedFormat.js.map +1 -1
  57. package/dist/formats/red/core/CjsRedReader.js +63 -70
  58. package/dist/formats/red/core/CjsRedReader.js.map +1 -1
  59. package/dist/formats/red/core/helpers.js +3 -0
  60. package/dist/formats/red/core/helpers.js.map +1 -1
  61. package/dist/formats/stl/CjsStlFormat.js +77 -16
  62. package/dist/formats/stl/CjsStlFormat.js.map +1 -1
  63. package/dist/formats/stl/core/helpers.js +4 -0
  64. package/dist/formats/stl/core/helpers.js.map +1 -1
  65. package/dist/formats/stl/core/stl.js +100 -15
  66. package/dist/formats/stl/core/stl.js.map +1 -1
  67. package/dist/formats/tga/CjsTgaFormat.js +11 -5
  68. package/dist/formats/tga/CjsTgaFormat.js.map +1 -1
  69. package/dist/formats/wav/CjsWavFormat.js +11 -5
  70. package/dist/formats/wav/CjsWavFormat.js.map +1 -1
  71. package/dist/formats/webm/CjsWebmFormat.js +10 -4
  72. package/dist/formats/webm/CjsWebmFormat.js.map +1 -1
  73. package/dist/formats/webp/CjsWebpFormat.js +9 -3
  74. package/dist/formats/webp/CjsWebpFormat.js.map +1 -1
  75. package/dist/formats/wem/CjsWemFormat.js +50 -6
  76. package/dist/formats/wem/CjsWemFormat.js.map +1 -1
  77. package/dist/formats/wem/core/helpers.js +84 -3
  78. package/dist/formats/wem/core/helpers.js.map +1 -1
  79. package/dist/formats/wem/core/ptadpcm.js +77 -0
  80. package/dist/formats/wem/core/ptadpcm.js.map +1 -0
  81. package/dist/formats/wem/core/resolve.js +121 -0
  82. package/dist/formats/wem/core/resolve.js.map +1 -0
  83. package/dist/formats/yaml/CjsYamlFormat.js +11 -5
  84. package/dist/formats/yaml/CjsYamlFormat.js.map +1 -1
  85. package/dist/formats/yaml/core/CjsYamlReader.js +3 -2
  86. package/dist/formats/yaml/core/CjsYamlReader.js.map +1 -1
  87. package/dist/index.js +28 -32
  88. package/dist/index.js.map +1 -1
  89. package/dist/{generated/resources → resources}/AudioGeometryResData.js +2 -2
  90. package/dist/resources/AudioGeometryResData.js.map +1 -0
  91. package/dist/{generated/resources → resources}/GStateBindingCallbackData.js +2 -2
  92. package/dist/resources/GStateBindingCallbackData.js.map +1 -0
  93. package/dist/{generated/resources → resources}/MeshDecalData.js +2 -2
  94. package/dist/resources/MeshDecalData.js.map +1 -0
  95. package/dist/{generated/resources → resources}/MeshDecalLodData.js +2 -2
  96. package/dist/resources/MeshDecalLodData.js.map +1 -0
  97. package/dist/resources/Tr2GrannyIntersectionResult.js +60 -0
  98. package/dist/resources/Tr2GrannyIntersectionResult.js.map +1 -0
  99. package/dist/{generated/resources → resources}/Tr2MaterialArea.js +2 -2
  100. package/dist/resources/Tr2MaterialArea.js.map +1 -0
  101. package/dist/{generated/resources → resources}/Tr2MaterialMesh.js +2 -2
  102. package/dist/resources/Tr2MaterialMesh.js.map +1 -0
  103. package/dist/{generated/resources → resources}/Tr2MaterialRes.js +2 -2
  104. package/dist/resources/Tr2MaterialRes.js.map +1 -0
  105. package/dist/{generated/resources → resources}/Tr2ShaderPermutation.js +2 -2
  106. package/dist/resources/Tr2ShaderPermutation.js.map +1 -0
  107. package/dist/{generated/resources → resources}/Tr2TextureLodManager.js +50 -10
  108. package/dist/resources/Tr2TextureLodManager.js.map +1 -0
  109. package/dist/{generated/resources → resources}/Tr2TextureLodUpdateRequest.js +2 -2
  110. package/dist/resources/Tr2TextureLodUpdateRequest.js.map +1 -0
  111. package/dist/{generated/resources → resources}/Tr2TexturePackChannel.js +2 -2
  112. package/dist/resources/Tr2TexturePackChannel.js.map +1 -0
  113. package/dist/resources/Tr2TexturePipeline.js +68 -0
  114. package/dist/resources/Tr2TexturePipeline.js.map +1 -0
  115. package/dist/{generated/resources → resources}/Tr2TexturePipelineParams.js +2 -2
  116. package/dist/resources/Tr2TexturePipelineParams.js.map +1 -0
  117. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepCompress.js +3 -3
  118. package/dist/resources/Tr2TexturePipelineStepCompress.js.map +1 -0
  119. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLimitSize.js +2 -2
  120. package/dist/resources/Tr2TexturePipelineStepLimitSize.js.map +1 -0
  121. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepLoad.js +2 -2
  122. package/dist/resources/Tr2TexturePipelineStepLoad.js.map +1 -0
  123. package/dist/{generated/resources → resources}/Tr2TexturePipelineStepPack.js +3 -3
  124. package/dist/resources/Tr2TexturePipelineStepPack.js.map +1 -0
  125. package/dist/{generated/resources → resources}/TriGeometryResAreaData.js +2 -2
  126. package/dist/resources/TriGeometryResAreaData.js.map +1 -0
  127. package/dist/{generated/resources → resources}/TriGeometryResJointData.js +2 -2
  128. package/dist/resources/TriGeometryResJointData.js.map +1 -0
  129. package/dist/{generated/resources → resources}/TriGeometryResLodData.js +2 -2
  130. package/dist/resources/TriGeometryResLodData.js.map +1 -0
  131. package/dist/{generated/resources → resources}/TriGeometryResMeshData.js +2 -2
  132. package/dist/resources/TriGeometryResMeshData.js.map +1 -0
  133. package/dist/{generated/resources → resources}/TriGeometryResSkeletonData.js +2 -2
  134. package/dist/resources/TriGeometryResSkeletonData.js.map +1 -0
  135. package/dist/{generated/resources → resources}/TriJointBinding.js +2 -2
  136. package/dist/resources/TriJointBinding.js.map +1 -0
  137. package/dist/{generated/resources → resources}/TriMorphTargetGeometryConstants.js +2 -2
  138. package/dist/resources/TriMorphTargetGeometryConstants.js.map +1 -0
  139. package/dist/{generated/resources → resources}/TriRtGeometryConstants.js +2 -2
  140. package/dist/resources/TriRtGeometryConstants.js.map +1 -0
  141. package/dist/resources/enums.js.map +1 -0
  142. package/dist/resources/texturePipelineBehavior.js +320 -0
  143. package/dist/resources/texturePipelineBehavior.js.map +1 -0
  144. package/format-notices/bnk/NOTICE +7 -4
  145. package/package.json +51 -51
  146. package/resource-lifecycle.md +262 -70
  147. package/dist/generated/resources/AudioGeometryResData.js.map +0 -1
  148. package/dist/generated/resources/CmfVertexReader.js +0 -46
  149. package/dist/generated/resources/CmfVertexReader.js.map +0 -1
  150. package/dist/generated/resources/GStateBindingCallbackData.js.map +0 -1
  151. package/dist/generated/resources/MeshDecalData.js.map +0 -1
  152. package/dist/generated/resources/MeshDecalLodData.js.map +0 -1
  153. package/dist/generated/resources/Tr2AsyncSave.js +0 -46
  154. package/dist/generated/resources/Tr2AsyncSave.js.map +0 -1
  155. package/dist/generated/resources/Tr2CmfContents.js +0 -37
  156. package/dist/generated/resources/Tr2CmfContents.js.map +0 -1
  157. package/dist/generated/resources/Tr2GrannyIntersectionResult.js +0 -58
  158. package/dist/generated/resources/Tr2GrannyIntersectionResult.js.map +0 -1
  159. package/dist/generated/resources/Tr2LoadPrepareFence.js +0 -37
  160. package/dist/generated/resources/Tr2LoadPrepareFence.js.map +0 -1
  161. package/dist/generated/resources/Tr2MaterialArea.js.map +0 -1
  162. package/dist/generated/resources/Tr2MaterialMesh.js.map +0 -1
  163. package/dist/generated/resources/Tr2MaterialRes.js.map +0 -1
  164. package/dist/generated/resources/Tr2ShaderPermutation.js.map +0 -1
  165. package/dist/generated/resources/Tr2TextureLodManager.js.map +0 -1
  166. package/dist/generated/resources/Tr2TextureLodUpdateRequest.js.map +0 -1
  167. package/dist/generated/resources/Tr2TexturePackChannel.js.map +0 -1
  168. package/dist/generated/resources/Tr2TexturePipeline.js +0 -44
  169. package/dist/generated/resources/Tr2TexturePipeline.js.map +0 -1
  170. package/dist/generated/resources/Tr2TexturePipelineParams.js.map +0 -1
  171. package/dist/generated/resources/Tr2TexturePipelineStepCompress.js.map +0 -1
  172. package/dist/generated/resources/Tr2TexturePipelineStepLimitSize.js.map +0 -1
  173. package/dist/generated/resources/Tr2TexturePipelineStepLoad.js.map +0 -1
  174. package/dist/generated/resources/Tr2TexturePipelineStepPack.js.map +0 -1
  175. package/dist/generated/resources/TriGeometryResAreaData.js.map +0 -1
  176. package/dist/generated/resources/TriGeometryResJointData.js.map +0 -1
  177. package/dist/generated/resources/TriGeometryResLodData.js.map +0 -1
  178. package/dist/generated/resources/TriGeometryResMeshData.js.map +0 -1
  179. package/dist/generated/resources/TriGeometryResSkeletonData.js.map +0 -1
  180. package/dist/generated/resources/TriJointBinding.js.map +0 -1
  181. package/dist/generated/resources/TriMorphTargetGeometryConstants.js.map +0 -1
  182. package/dist/generated/resources/TriRtGeometryConstants.js.map +0 -1
  183. package/dist/generated/resources/enums.js.map +0 -1
  184. package/dist/generated/resources/index.js +0 -32
  185. package/dist/generated/resources/index.js.map +0 -1
  186. /package/dist/{generated/resources → resources}/enums.js +0 -0
@@ -0,0 +1,320 @@
1
+ import { validateRgbaPayload } from '../format/payloadContract.js';
2
+ import { PixelFormat as PixelFormat$1 } from '@carbonenginejs/runtime-const/graphics';
3
+ import { PixelFormat } from '@carbonenginejs/runtime-const/render-context';
4
+
5
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp
6
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.cpp
7
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp
8
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp
9
+ // Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp
10
+ const STEP_LOAD = "Tr2TexturePipelineStepLoad";
11
+ const STEP_LIMIT_SIZE = "Tr2TexturePipelineStepLimitSize";
12
+ const STEP_COMPRESS = "Tr2TexturePipelineStepCompress";
13
+ const STEP_PACK = "Tr2TexturePipelineStepPack";
14
+ const PACK_FORMATS = new Set([PixelFormat.PIXEL_FORMAT_R8_UNORM, PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM, PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM]);
15
+
16
+ /**
17
+ * Collect Carbon texture-pipeline dependencies in std::set-equivalent order.
18
+ *
19
+ * @param {object[]} steps Pipeline steps.
20
+ * @returns {string[]} Sorted unique resource paths.
21
+ */
22
+ function GetTexturePipelineDependencies(steps) {
23
+ const dependencies = new Set();
24
+ for (const step of AssertSteps(steps)) {
25
+ const name = StepName(step);
26
+ if (name === STEP_LOAD) {
27
+ AddDependency(dependencies, step.path);
28
+ } else if (name === STEP_PACK) {
29
+ AddDependency(dependencies, step.r?.path);
30
+ AddDependency(dependencies, step.g?.path);
31
+ AddDependency(dependencies, step.b?.path);
32
+ AddDependency(dependencies, step.a?.path);
33
+ }
34
+ }
35
+ return [...dependencies].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
36
+ }
37
+
38
+ /**
39
+ * Execute the maintained JavaScript form of Carbon's CPU bitmap pipeline.
40
+ *
41
+ * @param {object[]} steps Pipeline steps.
42
+ * @param {{maxWidth:number,maxHeight:number}} params Caller size limits.
43
+ * @param {object|null} options Input resolution options.
44
+ * @returns {Promise<object>} Canonical RGBA payload.
45
+ */
46
+ async function ExecuteTexturePipeline(steps, params, options = null) {
47
+ const list = AssertSteps(steps);
48
+ if (!list.length) {
49
+ throw PipelineError("CJS_TEXTURE_PIPELINE_NO_STEPS", "Tr2TexturePipeline has no steps.");
50
+ }
51
+ const limits = {
52
+ maxWidth: AssertLimit(params?.maxWidth, "maxWidth"),
53
+ maxHeight: AssertLimit(params?.maxHeight, "maxHeight")
54
+ };
55
+ const settings = NormalizeOptions(options);
56
+ const inputs = new Map();
57
+ for (const path of GetTexturePipelineDependencies(list)) {
58
+ inputs.set(path, await ResolveInput(path, settings));
59
+ }
60
+ let bitmap = null;
61
+ for (const step of list) {
62
+ const name = StepName(step);
63
+ if (name === STEP_LOAD) {
64
+ bitmap = CloneBitmap(RequireInput(inputs, step.path));
65
+ } else if (name === STEP_LIMIT_SIZE) {
66
+ bitmap = LimitBitmap(RequireBitmap(bitmap), CombineLimits(step, limits));
67
+ } else if (name === STEP_COMPRESS) {
68
+ // Carbon's current implementation validates the bitmap and otherwise
69
+ // performs no compression work.
70
+ RequireBitmap(bitmap);
71
+ } else if (name === STEP_PACK) {
72
+ bitmap = PackBitmap(step, inputs);
73
+ } else {
74
+ throw PipelineError("CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED", `Unsupported texture pipeline step: ${name || "unknown"}.`);
75
+ }
76
+ }
77
+ bitmap = LimitBitmap(RequireBitmap(bitmap), limits);
78
+ return ToPayload(bitmap);
79
+ }
80
+ function AssertSteps(steps) {
81
+ if (!Array.isArray(steps)) {
82
+ throw new TypeError("Tr2TexturePipeline.steps must be an array.");
83
+ }
84
+ return steps;
85
+ }
86
+ function AssertLimit(value, name) {
87
+ if (!Number.isSafeInteger(value) || value < 0) {
88
+ throw new TypeError(`Tr2TexturePipeline ${name} must be a non-negative safe integer.`);
89
+ }
90
+ return value;
91
+ }
92
+ function NormalizeOptions(options) {
93
+ if (options === null || options === undefined) {
94
+ return {};
95
+ }
96
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
97
+ throw new TypeError("Tr2TexturePipeline options must be an object or null.");
98
+ }
99
+ if (options.load !== undefined && typeof options.load !== "function") {
100
+ throw new TypeError("Tr2TexturePipeline options.load must be a function.");
101
+ }
102
+ if (options.resMan !== undefined && typeof options.resMan?.GetObject !== "function") {
103
+ throw new TypeError("Tr2TexturePipeline options.resMan must provide GetObject().");
104
+ }
105
+ return options;
106
+ }
107
+ async function ResolveInput(path, options) {
108
+ let value;
109
+ if (options.inputs instanceof Map) {
110
+ value = options.inputs.get(path);
111
+ } else if (options.inputs && typeof options.inputs === "object") {
112
+ value = options.inputs[path];
113
+ }
114
+ if (value === undefined && options.load) {
115
+ value = await options.load(path);
116
+ }
117
+ if (value === undefined && options.resMan) {
118
+ value = await options.resMan.GetObject(path, {
119
+ ...(options.resourceOptions || {}),
120
+ requirement: "image",
121
+ emit: "rgba"
122
+ });
123
+ }
124
+ if (value === undefined) {
125
+ throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `No texture pipeline input was provided for ${path}.`);
126
+ }
127
+ const payload = typeof value?.GetPayload === "function" ? value.GetPayload() : value;
128
+ validateRgbaPayload(payload);
129
+ if (payload.pixelFormat !== PixelFormat$1.RGBA8_UNORM) {
130
+ throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Texture pipeline input ${path} must use rgba8unorm.`);
131
+ }
132
+ return FromPayload(payload);
133
+ }
134
+ function FromPayload(payload) {
135
+ const data = new Uint8Array(payload.width * payload.height * 4);
136
+ for (let y = 0; y < payload.height; y++) {
137
+ const sourceOffset = y * payload.strideBytes;
138
+ const targetOffset = y * payload.width * 4;
139
+ data.set(payload.data.subarray(sourceOffset, sourceOffset + payload.width * 4), targetOffset);
140
+ }
141
+ return {
142
+ width: payload.width,
143
+ height: payload.height,
144
+ data,
145
+ sourceFormat: payload.sourceFormat || "rgba",
146
+ colorSpace: payload.colorSpace,
147
+ alphaMode: payload.alphaMode,
148
+ metadata: payload.metadata || null
149
+ };
150
+ }
151
+ function ToPayload(bitmap) {
152
+ return {
153
+ payloadType: "rgba",
154
+ sourceFormat: bitmap.sourceFormat || "texture-pipeline",
155
+ width: bitmap.width,
156
+ height: bitmap.height,
157
+ pixelFormat: PixelFormat$1.RGBA8_UNORM,
158
+ data: bitmap.data,
159
+ strideBytes: bitmap.width * 4,
160
+ origin: "top-left",
161
+ colorSpace: bitmap.colorSpace || "unknown",
162
+ alphaMode: bitmap.alphaMode || "unknown",
163
+ ...(bitmap.metadata ? {
164
+ metadata: bitmap.metadata
165
+ } : {})
166
+ };
167
+ }
168
+ function CloneBitmap(bitmap) {
169
+ return {
170
+ ...bitmap,
171
+ data: new Uint8Array(bitmap.data),
172
+ metadata: bitmap.metadata && typeof bitmap.metadata === "object" ? {
173
+ ...bitmap.metadata
174
+ } : bitmap.metadata
175
+ };
176
+ }
177
+ function CombineLimits(step, params) {
178
+ return {
179
+ maxWidth: TightestLimit(AssertLimit(step.maxWidth ?? 0, "step.maxWidth"), params.maxWidth),
180
+ maxHeight: TightestLimit(AssertLimit(step.maxHeight ?? 0, "step.maxHeight"), params.maxHeight)
181
+ };
182
+ }
183
+ function TightestLimit(first, second) {
184
+ if (!first) return second;
185
+ if (!second) return first;
186
+ return Math.min(first, second);
187
+ }
188
+ function LimitBitmap(bitmap, limits) {
189
+ let result = bitmap;
190
+ while (limits.maxWidth && result.width > limits.maxWidth || limits.maxHeight && result.height > limits.maxHeight) {
191
+ result = Downsample2x2(result);
192
+ }
193
+ return result;
194
+ }
195
+ function Downsample2x2(bitmap) {
196
+ const width = Math.max(1, Math.floor(bitmap.width / 2));
197
+ const height = Math.max(1, Math.floor(bitmap.height / 2));
198
+ const data = new Uint8Array(width * height * 4);
199
+ for (let y = 0; y < height; y++) {
200
+ for (let x = 0; x < width; x++) {
201
+ const counts = [0, 0, 0, 0];
202
+ let samples = 0;
203
+ for (let oy = 0; oy < 2; oy++) {
204
+ for (let ox = 0; ox < 2; ox++) {
205
+ const sourceX = Math.min(bitmap.width - 1, x * 2 + ox);
206
+ const sourceY = Math.min(bitmap.height - 1, y * 2 + oy);
207
+ const source = (sourceY * bitmap.width + sourceX) * 4;
208
+ for (let channel = 0; channel < 4; channel++) {
209
+ counts[channel] += bitmap.data[source + channel];
210
+ }
211
+ samples++;
212
+ }
213
+ }
214
+ const target = (y * width + x) * 4;
215
+ for (let channel = 0; channel < 4; channel++) {
216
+ data[target + channel] = Math.round(counts[channel] / samples);
217
+ }
218
+ }
219
+ }
220
+ return {
221
+ ...bitmap,
222
+ width,
223
+ height,
224
+ data
225
+ };
226
+ }
227
+ function PackBitmap(step, inputs) {
228
+ // The generated schema records the enum's zero value, while Carbon's
229
+ // constructor initializes this step to B8G8R8A8_UNORM.
230
+ const format = step.format === PixelFormat.PIXEL_FORMAT_UNKNOWN ? PixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM : step.format;
231
+ if (!PACK_FORMATS.has(format)) {
232
+ throw PipelineError("CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED", `Unsupported Carbon pack pixel format: ${String(format)}.`);
233
+ }
234
+ const descriptors = [step.r, step.g, step.b, step.a];
235
+ const sources = descriptors.map(channel => channel?.path ? RequireInput(inputs, channel.path) : null);
236
+ const first = sources.find(Boolean);
237
+ const width = first?.width || 4;
238
+ const height = first?.height || 4;
239
+ for (const source of sources) {
240
+ if (source && (source.width !== width || source.height !== height)) {
241
+ throw PipelineError("CJS_TEXTURE_PIPELINE_SIZE_MISMATCH", "Texture pipeline pack inputs must have identical dimensions.");
242
+ }
243
+ }
244
+ const data = new Uint8Array(width * height * 4);
245
+ const isR8 = format === PixelFormat.PIXEL_FORMAT_R8_UNORM;
246
+ const isX8 = format === PixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM;
247
+ for (let pixel = 0; pixel < width * height; pixel++) {
248
+ const values = descriptors.map((channel, index) => ReadPackChannel(sources[index], channel, pixel));
249
+ const target = pixel * 4;
250
+ if (isR8) {
251
+ data[target] = values[0];
252
+ data[target + 3] = 255;
253
+ } else {
254
+ data[target] = values[0];
255
+ data[target + 1] = values[1];
256
+ data[target + 2] = values[2];
257
+ data[target + 3] = isX8 ? 255 : values[3];
258
+ }
259
+ }
260
+ return {
261
+ width,
262
+ height,
263
+ data,
264
+ sourceFormat: "texture-pipeline",
265
+ colorSpace: first?.colorSpace || "unknown",
266
+ alphaMode: isX8 || isR8 ? "opaque" : "unknown",
267
+ metadata: {
268
+ carbonPixelFormat: format
269
+ }
270
+ };
271
+ }
272
+ function ReadPackChannel(source, descriptor, pixel) {
273
+ if (!source) {
274
+ return AssertByte(descriptor?.fill ?? 0, "fill");
275
+ }
276
+ const channel = AssertByte(descriptor?.channel ?? 0, "channel");
277
+ if (channel > 3) {
278
+ throw new RangeError("Tr2TexturePackChannel.channel must be between 0 and 3.");
279
+ }
280
+ // Carbon's exposed chooser encodes RED=2 and BLUE=0 for BGRA host
281
+ // bitmaps. Translate those values to this package's canonical RGBA input.
282
+ const rgbaChannel = channel === 0 ? 2 : channel === 2 ? 0 : channel;
283
+ return source.data[pixel * 4 + rgbaChannel];
284
+ }
285
+ function AssertByte(value, name) {
286
+ if (!Number.isInteger(value) || value < 0 || value > 255) {
287
+ throw new RangeError(`Tr2TexturePackChannel.${name} must be an integer from 0 to 255.`);
288
+ }
289
+ return value;
290
+ }
291
+ function RequireInput(inputs, path) {
292
+ const value = inputs.get(String(path || ""));
293
+ if (!value) {
294
+ throw PipelineError("CJS_TEXTURE_PIPELINE_INPUT_MISSING", `Texture pipeline input is unavailable: ${String(path || "")}.`);
295
+ }
296
+ return value;
297
+ }
298
+ function RequireBitmap(bitmap) {
299
+ if (!bitmap) {
300
+ throw PipelineError("CJS_TEXTURE_PIPELINE_BITMAP_INVALID", "Texture pipeline step requires a valid input bitmap.");
301
+ }
302
+ return bitmap;
303
+ }
304
+ function AddDependency(dependencies, value) {
305
+ const path = String(value || "");
306
+ if (path) {
307
+ dependencies.add(path);
308
+ }
309
+ }
310
+ function StepName(step) {
311
+ return step?.constructor?.name || step?.className || "";
312
+ }
313
+ function PipelineError(code, message) {
314
+ const error = new Error(message);
315
+ error.code = code;
316
+ return error;
317
+ }
318
+
319
+ export { ExecuteTexturePipeline, GetTexturePipelineDependencies };
320
+ //# sourceMappingURL=texturePipelineBehavior.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"texturePipelineBehavior.js","sources":["../../../src/resources/texturePipelineBehavior.js"],"sourcesContent":["// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipeline.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLoad.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepLimitSize.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepCompress.cpp\r\n// Source: trinity/trinity/Resources/TexturePipeline/Tr2TexturePipelineStepPack.cpp\r\nimport { validateRgbaPayload } from \"../format/payloadContract.js\";\r\nimport { PixelFormat as PayloadPixelFormat } from \"@carbonenginejs/runtime-const/graphics\";\r\nimport { PixelFormat as CarbonPixelFormat } from \"@carbonenginejs/runtime-const/render-context\";\r\n\r\nconst STEP_LOAD = \"Tr2TexturePipelineStepLoad\";\r\nconst STEP_LIMIT_SIZE = \"Tr2TexturePipelineStepLimitSize\";\r\nconst STEP_COMPRESS = \"Tr2TexturePipelineStepCompress\";\r\nconst STEP_PACK = \"Tr2TexturePipelineStepPack\";\r\nconst PACK_FORMATS = new Set([\r\n CarbonPixelFormat.PIXEL_FORMAT_R8_UNORM,\r\n CarbonPixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM,\r\n CarbonPixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM\r\n]);\r\n\r\n/**\r\n * Collect Carbon texture-pipeline dependencies in std::set-equivalent order.\r\n *\r\n * @param {object[]} steps Pipeline steps.\r\n * @returns {string[]} Sorted unique resource paths.\r\n */\r\nexport function GetTexturePipelineDependencies(steps)\r\n{\r\n const dependencies = new Set();\r\n for (const step of AssertSteps(steps))\r\n {\r\n const name = StepName(step);\r\n if (name === STEP_LOAD)\r\n {\r\n AddDependency(dependencies, step.path);\r\n }\r\n else if (name === STEP_PACK)\r\n {\r\n AddDependency(dependencies, step.r?.path);\r\n AddDependency(dependencies, step.g?.path);\r\n AddDependency(dependencies, step.b?.path);\r\n AddDependency(dependencies, step.a?.path);\r\n }\r\n }\r\n return [ ...dependencies ].sort((a, b) => a < b ? -1 : a > b ? 1 : 0);\r\n}\r\n\r\n/**\r\n * Execute the maintained JavaScript form of Carbon's CPU bitmap pipeline.\r\n *\r\n * @param {object[]} steps Pipeline steps.\r\n * @param {{maxWidth:number,maxHeight:number}} params Caller size limits.\r\n * @param {object|null} options Input resolution options.\r\n * @returns {Promise<object>} Canonical RGBA payload.\r\n */\r\nexport async function ExecuteTexturePipeline(steps, params, options = null)\r\n{\r\n const list = AssertSteps(steps);\r\n if (!list.length)\r\n {\r\n throw PipelineError(\"CJS_TEXTURE_PIPELINE_NO_STEPS\", \"Tr2TexturePipeline has no steps.\");\r\n }\r\n const limits = {\r\n maxWidth: AssertLimit(params?.maxWidth, \"maxWidth\"),\r\n maxHeight: AssertLimit(params?.maxHeight, \"maxHeight\")\r\n };\r\n const settings = NormalizeOptions(options);\r\n const inputs = new Map();\r\n for (const path of GetTexturePipelineDependencies(list))\r\n {\r\n inputs.set(path, await ResolveInput(path, settings));\r\n }\r\n\r\n let bitmap = null;\r\n for (const step of list)\r\n {\r\n const name = StepName(step);\r\n if (name === STEP_LOAD)\r\n {\r\n bitmap = CloneBitmap(RequireInput(inputs, step.path));\r\n }\r\n else if (name === STEP_LIMIT_SIZE)\r\n {\r\n bitmap = LimitBitmap(RequireBitmap(bitmap), CombineLimits(step, limits));\r\n }\r\n else if (name === STEP_COMPRESS)\r\n {\r\n // Carbon's current implementation validates the bitmap and otherwise\r\n // performs no compression work.\r\n RequireBitmap(bitmap);\r\n }\r\n else if (name === STEP_PACK)\r\n {\r\n bitmap = PackBitmap(step, inputs);\r\n }\r\n else\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_STEP_UNSUPPORTED\",\r\n `Unsupported texture pipeline step: ${name || \"unknown\"}.`\r\n );\r\n }\r\n }\r\n\r\n bitmap = LimitBitmap(RequireBitmap(bitmap), limits);\r\n return ToPayload(bitmap);\r\n}\r\n\r\nfunction AssertSteps(steps)\r\n{\r\n if (!Array.isArray(steps))\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline.steps must be an array.\");\r\n }\r\n return steps;\r\n}\r\n\r\nfunction AssertLimit(value, name)\r\n{\r\n if (!Number.isSafeInteger(value) || value < 0)\r\n {\r\n throw new TypeError(`Tr2TexturePipeline ${name} must be a non-negative safe integer.`);\r\n }\r\n return value;\r\n}\r\n\r\nfunction NormalizeOptions(options)\r\n{\r\n if (options === null || options === undefined)\r\n {\r\n return {};\r\n }\r\n if (!options || typeof options !== \"object\" || Array.isArray(options))\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options must be an object or null.\");\r\n }\r\n if (options.load !== undefined && typeof options.load !== \"function\")\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options.load must be a function.\");\r\n }\r\n if (options.resMan !== undefined && typeof options.resMan?.GetObject !== \"function\")\r\n {\r\n throw new TypeError(\"Tr2TexturePipeline options.resMan must provide GetObject().\");\r\n }\r\n return options;\r\n}\r\n\r\nasync function ResolveInput(path, options)\r\n{\r\n let value;\r\n if (options.inputs instanceof Map)\r\n {\r\n value = options.inputs.get(path);\r\n }\r\n else if (options.inputs && typeof options.inputs === \"object\")\r\n {\r\n value = options.inputs[path];\r\n }\r\n if (value === undefined && options.load)\r\n {\r\n value = await options.load(path);\r\n }\r\n if (value === undefined && options.resMan)\r\n {\r\n value = await options.resMan.GetObject(path, {\r\n ...(options.resourceOptions || {}),\r\n requirement: \"image\",\r\n emit: \"rgba\"\r\n });\r\n }\r\n if (value === undefined)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_INPUT_MISSING\",\r\n `No texture pipeline input was provided for ${path}.`\r\n );\r\n }\r\n const payload = typeof value?.GetPayload === \"function\" ? value.GetPayload() : value;\r\n validateRgbaPayload(payload);\r\n if (payload.pixelFormat !== PayloadPixelFormat.RGBA8_UNORM)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED\",\r\n `Texture pipeline input ${path} must use rgba8unorm.`\r\n );\r\n }\r\n return FromPayload(payload);\r\n}\r\n\r\nfunction FromPayload(payload)\r\n{\r\n const data = new Uint8Array(payload.width * payload.height * 4);\r\n for (let y = 0; y < payload.height; y++)\r\n {\r\n const sourceOffset = y * payload.strideBytes;\r\n const targetOffset = y * payload.width * 4;\r\n data.set(payload.data.subarray(sourceOffset, sourceOffset + payload.width * 4), targetOffset);\r\n }\r\n return {\r\n width: payload.width,\r\n height: payload.height,\r\n data,\r\n sourceFormat: payload.sourceFormat || \"rgba\",\r\n colorSpace: payload.colorSpace,\r\n alphaMode: payload.alphaMode,\r\n metadata: payload.metadata || null\r\n };\r\n}\r\n\r\nfunction ToPayload(bitmap)\r\n{\r\n return {\r\n payloadType: \"rgba\",\r\n sourceFormat: bitmap.sourceFormat || \"texture-pipeline\",\r\n width: bitmap.width,\r\n height: bitmap.height,\r\n pixelFormat: PayloadPixelFormat.RGBA8_UNORM,\r\n data: bitmap.data,\r\n strideBytes: bitmap.width * 4,\r\n origin: \"top-left\",\r\n colorSpace: bitmap.colorSpace || \"unknown\",\r\n alphaMode: bitmap.alphaMode || \"unknown\",\r\n ...(bitmap.metadata ? { metadata: bitmap.metadata } : {})\r\n };\r\n}\r\n\r\nfunction CloneBitmap(bitmap)\r\n{\r\n return {\r\n ...bitmap,\r\n data: new Uint8Array(bitmap.data),\r\n metadata: bitmap.metadata && typeof bitmap.metadata === \"object\"\r\n ? { ...bitmap.metadata }\r\n : bitmap.metadata\r\n };\r\n}\r\n\r\nfunction CombineLimits(step, params)\r\n{\r\n return {\r\n maxWidth: TightestLimit(AssertLimit(step.maxWidth ?? 0, \"step.maxWidth\"), params.maxWidth),\r\n maxHeight: TightestLimit(AssertLimit(step.maxHeight ?? 0, \"step.maxHeight\"), params.maxHeight)\r\n };\r\n}\r\n\r\nfunction TightestLimit(first, second)\r\n{\r\n if (!first) return second;\r\n if (!second) return first;\r\n return Math.min(first, second);\r\n}\r\n\r\nfunction LimitBitmap(bitmap, limits)\r\n{\r\n let result = bitmap;\r\n while ((limits.maxWidth && result.width > limits.maxWidth)\r\n || (limits.maxHeight && result.height > limits.maxHeight))\r\n {\r\n result = Downsample2x2(result);\r\n }\r\n return result;\r\n}\r\n\r\nfunction Downsample2x2(bitmap)\r\n{\r\n const width = Math.max(1, Math.floor(bitmap.width / 2));\r\n const height = Math.max(1, Math.floor(bitmap.height / 2));\r\n const data = new Uint8Array(width * height * 4);\r\n for (let y = 0; y < height; y++)\r\n {\r\n for (let x = 0; x < width; x++)\r\n {\r\n const counts = [ 0, 0, 0, 0 ];\r\n let samples = 0;\r\n for (let oy = 0; oy < 2; oy++)\r\n {\r\n for (let ox = 0; ox < 2; ox++)\r\n {\r\n const sourceX = Math.min(bitmap.width - 1, x * 2 + ox);\r\n const sourceY = Math.min(bitmap.height - 1, y * 2 + oy);\r\n const source = (sourceY * bitmap.width + sourceX) * 4;\r\n for (let channel = 0; channel < 4; channel++)\r\n {\r\n counts[channel] += bitmap.data[source + channel];\r\n }\r\n samples++;\r\n }\r\n }\r\n const target = (y * width + x) * 4;\r\n for (let channel = 0; channel < 4; channel++)\r\n {\r\n data[target + channel] = Math.round(counts[channel] / samples);\r\n }\r\n }\r\n }\r\n return { ...bitmap, width, height, data };\r\n}\r\n\r\nfunction PackBitmap(step, inputs)\r\n{\r\n // The generated schema records the enum's zero value, while Carbon's\r\n // constructor initializes this step to B8G8R8A8_UNORM.\r\n const format = step.format === CarbonPixelFormat.PIXEL_FORMAT_UNKNOWN\r\n ? CarbonPixelFormat.PIXEL_FORMAT_B8G8R8A8_UNORM\r\n : step.format;\r\n if (!PACK_FORMATS.has(format))\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_FORMAT_UNSUPPORTED\",\r\n `Unsupported Carbon pack pixel format: ${String(format)}.`\r\n );\r\n }\r\n const descriptors = [ step.r, step.g, step.b, step.a ];\r\n const sources = descriptors.map(channel => channel?.path\r\n ? RequireInput(inputs, channel.path)\r\n : null);\r\n const first = sources.find(Boolean);\r\n const width = first?.width || 4;\r\n const height = first?.height || 4;\r\n for (const source of sources)\r\n {\r\n if (source && (source.width !== width || source.height !== height))\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_SIZE_MISMATCH\",\r\n \"Texture pipeline pack inputs must have identical dimensions.\"\r\n );\r\n }\r\n }\r\n\r\n const data = new Uint8Array(width * height * 4);\r\n const isR8 = format === CarbonPixelFormat.PIXEL_FORMAT_R8_UNORM;\r\n const isX8 = format === CarbonPixelFormat.PIXEL_FORMAT_B8G8R8X8_UNORM;\r\n for (let pixel = 0; pixel < width * height; pixel++)\r\n {\r\n const values = descriptors.map((channel, index) => ReadPackChannel(\r\n sources[index],\r\n channel,\r\n pixel\r\n ));\r\n const target = pixel * 4;\r\n if (isR8)\r\n {\r\n data[target] = values[0];\r\n data[target + 3] = 255;\r\n }\r\n else\r\n {\r\n data[target] = values[0];\r\n data[target + 1] = values[1];\r\n data[target + 2] = values[2];\r\n data[target + 3] = isX8 ? 255 : values[3];\r\n }\r\n }\r\n return {\r\n width,\r\n height,\r\n data,\r\n sourceFormat: \"texture-pipeline\",\r\n colorSpace: first?.colorSpace || \"unknown\",\r\n alphaMode: isX8 || isR8 ? \"opaque\" : \"unknown\",\r\n metadata: { carbonPixelFormat: format }\r\n };\r\n}\r\n\r\nfunction ReadPackChannel(source, descriptor, pixel)\r\n{\r\n if (!source)\r\n {\r\n return AssertByte(descriptor?.fill ?? 0, \"fill\");\r\n }\r\n const channel = AssertByte(descriptor?.channel ?? 0, \"channel\");\r\n if (channel > 3)\r\n {\r\n throw new RangeError(\"Tr2TexturePackChannel.channel must be between 0 and 3.\");\r\n }\r\n // Carbon's exposed chooser encodes RED=2 and BLUE=0 for BGRA host\r\n // bitmaps. Translate those values to this package's canonical RGBA input.\r\n const rgbaChannel = channel === 0 ? 2 : channel === 2 ? 0 : channel;\r\n return source.data[pixel * 4 + rgbaChannel];\r\n}\r\n\r\nfunction AssertByte(value, name)\r\n{\r\n if (!Number.isInteger(value) || value < 0 || value > 255)\r\n {\r\n throw new RangeError(`Tr2TexturePackChannel.${name} must be an integer from 0 to 255.`);\r\n }\r\n return value;\r\n}\r\n\r\nfunction RequireInput(inputs, path)\r\n{\r\n const value = inputs.get(String(path || \"\"));\r\n if (!value)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_INPUT_MISSING\",\r\n `Texture pipeline input is unavailable: ${String(path || \"\")}.`\r\n );\r\n }\r\n return value;\r\n}\r\n\r\nfunction RequireBitmap(bitmap)\r\n{\r\n if (!bitmap)\r\n {\r\n throw PipelineError(\r\n \"CJS_TEXTURE_PIPELINE_BITMAP_INVALID\",\r\n \"Texture pipeline step requires a valid input bitmap.\"\r\n );\r\n }\r\n return bitmap;\r\n}\r\n\r\nfunction AddDependency(dependencies, value)\r\n{\r\n const path = String(value || \"\");\r\n if (path)\r\n {\r\n dependencies.add(path);\r\n }\r\n}\r\n\r\nfunction StepName(step)\r\n{\r\n return step?.constructor?.name || step?.className || \"\";\r\n}\r\n\r\nfunction PipelineError(code, message)\r\n{\r\n const error = new Error(message);\r\n error.code = code;\r\n return error;\r\n}\r\n"],"names":["STEP_LOAD","STEP_LIMIT_SIZE","STEP_COMPRESS","STEP_PACK","PACK_FORMATS","Set","CarbonPixelFormat","PIXEL_FORMAT_R8_UNORM","PIXEL_FORMAT_B8G8R8A8_UNORM","PIXEL_FORMAT_B8G8R8X8_UNORM","GetTexturePipelineDependencies","steps","dependencies","step","AssertSteps","name","StepName","AddDependency","path","r","g","b","a","sort","ExecuteTexturePipeline","params","options","list","length","PipelineError","limits","maxWidth","AssertLimit","maxHeight","settings","NormalizeOptions","inputs","Map","set","ResolveInput","bitmap","CloneBitmap","RequireInput","LimitBitmap","RequireBitmap","CombineLimits","PackBitmap","ToPayload","Array","isArray","TypeError","value","Number","isSafeInteger","undefined","load","resMan","GetObject","get","resourceOptions","requirement","emit","payload","GetPayload","validateRgbaPayload","pixelFormat","PayloadPixelFormat","RGBA8_UNORM","FromPayload","data","Uint8Array","width","height","y","sourceOffset","strideBytes","targetOffset","subarray","sourceFormat","colorSpace","alphaMode","metadata","payloadType","origin","TightestLimit","first","second","Math","min","result","Downsample2x2","max","floor","x","counts","samples","oy","ox","sourceX","sourceY","source","channel","target","round","format","PIXEL_FORMAT_UNKNOWN","has","String","descriptors","sources","map","find","Boolean","isR8","isX8","pixel","values","index","ReadPackChannel","carbonPixelFormat","descriptor","AssertByte","fill","RangeError","rgbaChannel","isInteger","add","constructor","className","code","message","error","Error"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AAKA,MAAMA,SAAS,GAAG,4BAA4B;AAC9C,MAAMC,eAAe,GAAG,iCAAiC;AACzD,MAAMC,aAAa,GAAG,gCAAgC;AACtD,MAAMC,SAAS,GAAG,4BAA4B;AAC9C,MAAMC,YAAY,GAAG,IAAIC,GAAG,CAAC,CAC3BC,WAAiB,CAACC,qBAAqB,EACvCD,WAAiB,CAACE,2BAA2B,EAC7CF,WAAiB,CAACG,2BAA2B,CAC9C,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,8BAA8BA,CAACC,KAAK,EACpD;AACE,EAAA,MAAMC,YAAY,GAAG,IAAIP,GAAG,EAAE;AAC9B,EAAA,KAAK,MAAMQ,IAAI,IAAIC,WAAW,CAACH,KAAK,CAAC,EACrC;AACE,IAAA,MAAMI,IAAI,GAAGC,QAAQ,CAACH,I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AACxD,KAAK,IAAI,EAAE,CAAC;AAChC,EAAA,IAAIjC,IAAI,EACR;AACEN,IAAAA,YAAY,CAACkH,GAAG,CAAC5G,IAAI,CAAC;AACxB,EAAA;AACF;AAEA,SAASF,QAAQA,CAACH,IAAI,EACtB;EACE,OAAOA,IAAI,EAAEkH,WAAW,EAAEhH,IAAI,IAAIF,IAAI,EAAEmH,SAAS,IAAI,EAAE;AACzD;AAEA,SAASnG,aAAaA,CAACoG,IAAI,EAAEC,OAAO,EACpC;AACE,EAAA,MAAMC,KAAK,GAAG,IAAIC,KAAK,CAACF,OAAO,CAAC;EAChCC,KAAK,CAACF,IAAI,GAAGA,IAAI;AACjB,EAAA,OAAOE,KAAK;AACd;;;;"}
@@ -8,10 +8,13 @@ and EVE-related data remain copyright their original holders.
8
8
  Wwise and the Wwise soundbank format are property of Audiokinetic Inc.
9
9
 
10
10
  This reader is original CarbonEngineJS code authored directly in
11
- runtime-resource; no legacy package was copied. The soundbank chunk layout was
12
- implemented from publicly documented community knowledge of the format
13
- (ww2ogg, vgmstream, wwiser documentation); no code was copied from those
14
- projects and no Audiokinetic SDK material was used.
11
+ runtime-resource; no legacy package was copied. The soundbank chunk layout,
12
+ HIRC object field layouts, and the event-graph resolution exposed as
13
+ `eventMediaFromBanks` were implemented from publicly documented community
14
+ knowledge of the format (ww2ogg, vgmstream, wwiser documentation) and
15
+ independently verified by hexdump against EVE Online soundbanks (bank
16
+ generator version 150); no code was copied from those projects and no
17
+ Audiokinetic SDK material was used.
15
18
  Audiokinetic, CarbonEngine, and Fenris Creations (CCP Games) are mentioned for
16
19
  interoperability, provenance, and future migration context only. This package
17
20
  is not affiliated with or endorsed by Audiokinetic Inc. or CCP Games.
package/package.json CHANGED
@@ -1,51 +1,51 @@
1
- {
2
- "name": "@carbonenginejs/runtime-resource",
3
- "version": "0.1.0",
4
- "description": "CarbonEngineJS resource lifecycle, cache, source, and object loading contracts.",
5
- "type": "module",
6
- "exports": {
7
- ".": "./dist/index.js",
8
- "./generated/resources": "./dist/generated/resources/index.js",
9
- "./formats": "./dist/formats/index.js",
10
- "./formats/black": "./dist/formats/black/index.js",
11
- "./formats/black/schema": "./dist/formats/black/core/blackSchema.js",
12
- "./formats/black/enums": "./dist/formats/black/core/blackEnums.js",
13
- "./formats/black/version": "./dist/formats/black/core/blackVersion.js",
14
- "./formats/bnk": "./dist/formats/bnk/index.js",
15
- "./formats/cmf": "./dist/formats/cmf/index.js",
16
- "./formats/dds": "./dist/formats/dds/index.js",
17
- "./formats/fbx": "./dist/formats/fbx/index.js",
18
- "./formats/flac": "./dist/formats/flac/index.js",
19
- "./formats/gif": "./dist/formats/gif/index.js",
20
- "./formats/gltf": "./dist/formats/gltf/index.js",
21
- "./formats/jpeg": "./dist/formats/jpeg/index.js",
22
- "./formats/mp3": "./dist/formats/mp3/index.js",
23
- "./formats/mp4": "./dist/formats/mp4/index.js",
24
- "./formats/obj": "./dist/formats/obj/index.js",
25
- "./formats/ogg": "./dist/formats/ogg/index.js",
26
- "./formats/png": "./dist/formats/png/index.js",
27
- "./formats/red": "./dist/formats/red/index.js",
28
- "./formats/red/schema": "./dist/formats/red/core/blackDefinitions.js",
29
- "./formats/stl": "./dist/formats/stl/index.js",
30
- "./formats/tga": "./dist/formats/tga/index.js",
31
- "./formats/wav": "./dist/formats/wav/index.js",
32
- "./formats/webm": "./dist/formats/webm/index.js",
33
- "./formats/webp": "./dist/formats/webp/index.js",
34
- "./formats/wem": "./dist/formats/wem/index.js",
35
- "./formats/yaml": "./dist/formats/yaml/index.js"
36
- },
37
- "sideEffects": false,
38
- "engines": {
39
- "node": ">=18"
40
- },
41
- "dependencies": {
42
- "@carbonenginejs/core-math": "^0.1.3",
43
- "@carbonenginejs/core-types": "^0.5.0",
44
- "meshoptimizer": "^1.2.0",
45
- "yaml": "^2.4.0"
46
- },
47
- "license": "MIT",
48
- "publishConfig": {
49
- "access": "public"
50
- }
51
- }
1
+ {
2
+ "name": "@carbonenginejs/runtime-resource",
3
+ "version": "0.7.0",
4
+ "description": "CarbonEngineJS resource lifecycle, cache, source, and object loading contracts.",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": "./dist/index.js",
8
+ "./formats": "./dist/formats/index.js",
9
+ "./formats/black": "./dist/formats/black/index.js",
10
+ "./formats/black/schema": "./dist/formats/black/core/blackSchema.js",
11
+ "./formats/black/enums": "./dist/formats/black/core/blackEnums.js",
12
+ "./formats/black/version": "./dist/formats/black/core/blackVersion.js",
13
+ "./formats/bnk": "./dist/formats/bnk/index.js",
14
+ "./formats/cmf": "./dist/formats/cmf/index.js",
15
+ "./formats/dds": "./dist/formats/dds/index.js",
16
+ "./formats/fbx": "./dist/formats/fbx/index.js",
17
+ "./formats/flac": "./dist/formats/flac/index.js",
18
+ "./formats/gif": "./dist/formats/gif/index.js",
19
+ "./formats/gltf": "./dist/formats/gltf/index.js",
20
+ "./formats/jpeg": "./dist/formats/jpeg/index.js",
21
+ "./formats/mp3": "./dist/formats/mp3/index.js",
22
+ "./formats/mp4": "./dist/formats/mp4/index.js",
23
+ "./formats/obj": "./dist/formats/obj/index.js",
24
+ "./formats/ogg": "./dist/formats/ogg/index.js",
25
+ "./formats/png": "./dist/formats/png/index.js",
26
+ "./formats/red": "./dist/formats/red/index.js",
27
+ "./formats/red/schema": "./dist/formats/red/core/blackDefinitions.js",
28
+ "./formats/stl": "./dist/formats/stl/index.js",
29
+ "./formats/tga": "./dist/formats/tga/index.js",
30
+ "./formats/wav": "./dist/formats/wav/index.js",
31
+ "./formats/webm": "./dist/formats/webm/index.js",
32
+ "./formats/webp": "./dist/formats/webp/index.js",
33
+ "./formats/wem": "./dist/formats/wem/index.js",
34
+ "./formats/yaml": "./dist/formats/yaml/index.js"
35
+ },
36
+ "sideEffects": false,
37
+ "engines": {
38
+ "node": ">=18"
39
+ },
40
+ "dependencies": {
41
+ "@carbonenginejs/core-math": "^0.1.3",
42
+ "@carbonenginejs/core-types": "^0.12.0",
43
+ "@carbonenginejs/runtime-const": "^0.1.0",
44
+ "meshoptimizer": "^1.2.0",
45
+ "yaml": "^2.4.0"
46
+ },
47
+ "license": "MIT",
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }