@carbonenginejs/runtime 0.1.0-alpha.4 → 0.1.0-alpha.5

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 (384) hide show
  1. package/dist/global/blue/BlueClasses.js +200 -0
  2. package/dist/global/blue/BlueClasses.js.map +1 -0
  3. package/dist/global/blue/IBlueClasses.js +79 -0
  4. package/dist/global/blue/IBlueClasses.js.map +1 -0
  5. package/dist/global/blue/IBlueDynamicResourceConstructor.js +16 -0
  6. package/dist/global/blue/IBlueDynamicResourceConstructor.js.map +1 -1
  7. package/dist/global/blue/blue.js +8 -2
  8. package/dist/global/blue/blue.js.map +1 -1
  9. package/dist/global/blue/index.js +2 -0
  10. package/dist/global/blue/index.js.map +1 -1
  11. package/dist/global/consts/index.js +0 -1
  12. package/dist/global/consts/index.js.map +1 -1
  13. package/dist/global/consts/renderContext/formats.js +26 -25
  14. package/dist/global/consts/renderContext/formats.js.map +1 -1
  15. package/dist/{trinityal/Tr2BitmapDimensions.js → global/imageio/BitmapDimensions.js} +19 -15
  16. package/dist/global/imageio/BitmapDimensions.js.map +1 -0
  17. package/dist/global/imageio/Cutout.js +28 -0
  18. package/dist/global/imageio/Cutout.js.map +1 -0
  19. package/dist/global/imageio/HostBitmap.js +1106 -0
  20. package/dist/global/imageio/HostBitmap.js.map +1 -0
  21. package/dist/global/imageio/ImageIOResult.js +99 -0
  22. package/dist/global/imageio/ImageIOResult.js.map +1 -0
  23. package/dist/global/imageio/ImageUtility.js +205 -0
  24. package/dist/global/imageio/ImageUtility.js.map +1 -0
  25. package/dist/global/imageio/LoadParameters.js +86 -0
  26. package/dist/global/imageio/LoadParameters.js.map +1 -0
  27. package/dist/global/imageio/Metadata.js +22 -0
  28. package/dist/global/imageio/Metadata.js.map +1 -0
  29. package/dist/global/imageio/index.js +8 -0
  30. package/dist/global/{consts/webgpu → imageio}/index.js.map +1 -1
  31. package/dist/global/index.js +2 -1
  32. package/dist/global/index.js.map +1 -1
  33. package/dist/global/math/color.js +1 -1
  34. package/dist/global/math/color.js.map +1 -1
  35. package/dist/global/schema/CjsSchema.js +8 -0
  36. package/dist/global/schema/CjsSchema.js.map +1 -1
  37. package/dist/index.js +12 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/resource/CjsResMan.js +47 -7
  40. package/dist/resource/CjsResMan.js.map +1 -1
  41. package/dist/resource/Tr2LightProfileRes.js +37 -0
  42. package/dist/resource/Tr2LightProfileRes.js.map +1 -1
  43. package/dist/resource/format/CjsByteWriter.js +46 -46
  44. package/dist/resource/format/CjsByteWriter.js.map +1 -1
  45. package/dist/resource/format/CjsFormat.js +7 -8
  46. package/dist/resource/format/CjsFormat.js.map +1 -1
  47. package/dist/resource/format/CjsFormatStore.js +8 -8
  48. package/dist/resource/format/CjsFormatStore.js.map +1 -1
  49. package/dist/resource/format/CjsGeometryFormat.js +114 -0
  50. package/dist/resource/format/CjsGeometryFormat.js.map +1 -0
  51. package/dist/resource/format/CjsImageFormat.js +282 -0
  52. package/dist/resource/format/CjsImageFormat.js.map +1 -0
  53. package/dist/resource/format/CjsResourceProbe.js +12 -48
  54. package/dist/resource/format/CjsResourceProbe.js.map +1 -1
  55. package/dist/resource/format/CjsStringTable.js +37 -37
  56. package/dist/resource/format/CjsStringTable.js.map +1 -1
  57. package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js +10 -10
  58. package/dist/resource/format/carbonEffect/CjsCarbonEffectReader.js.map +1 -1
  59. package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js +37 -37
  60. package/dist/resource/format/carbonEffect/CjsCarbonEffectWriter.js.map +1 -1
  61. package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js +35 -7
  62. package/dist/resource/format/carbonEffect/carbonEffectBackendBlock.js.map +1 -1
  63. package/dist/resource/format/index.js +3 -1
  64. package/dist/resource/format/index.js.map +1 -1
  65. package/dist/resource/formats/black/CjsBlackFormat.js +130 -137
  66. package/dist/resource/formats/black/CjsBlackFormat.js.map +1 -1
  67. package/dist/resource/formats/bnk/CjsBnkFormat.js +12 -19
  68. package/dist/resource/formats/bnk/CjsBnkFormat.js.map +1 -1
  69. package/dist/resource/formats/bnk/core/helpers.js +1 -3
  70. package/dist/resource/formats/bnk/core/helpers.js.map +1 -1
  71. package/dist/resource/formats/cmf/CjsCmfFormat.js +19 -82
  72. package/dist/resource/formats/cmf/CjsCmfFormat.js.map +1 -1
  73. package/dist/resource/formats/cmf/core/constants.js +1 -2
  74. package/dist/resource/formats/cmf/core/constants.js.map +1 -1
  75. package/dist/resource/formats/{stl/core/targets.js → cmf/core/flatShared.js} +9 -8
  76. package/dist/resource/formats/cmf/core/flatShared.js.map +1 -0
  77. package/dist/resource/formats/cmf/core/helpers.js +13 -13
  78. package/dist/resource/formats/cmf/core/helpers.js.map +1 -1
  79. package/dist/resource/formats/cmf/core/writer.js +24 -24
  80. package/dist/resource/formats/cmf/core/writer.js.map +1 -1
  81. package/dist/resource/formats/dds/CjsDdsFormat.js +134 -17
  82. package/dist/resource/formats/dds/CjsDdsFormat.js.map +1 -1
  83. package/dist/resource/formats/dds/core/helpers.js +125 -40
  84. package/dist/resource/formats/dds/core/helpers.js.map +1 -1
  85. package/dist/resource/formats/dxbc/CjsDxbcFormat.js +14 -16
  86. package/dist/resource/formats/dxbc/CjsDxbcFormat.js.map +1 -1
  87. package/dist/resource/formats/dxbc/core/{container.js → DxbcContainer.js} +2 -2
  88. package/dist/resource/formats/dxbc/core/DxbcContainer.js.map +1 -0
  89. package/dist/resource/formats/dxbc/core/{errors.js → DxbcReadError.js} +1 -1
  90. package/dist/resource/formats/dxbc/core/DxbcReadError.js.map +1 -0
  91. package/dist/resource/formats/dxbc/core/DxbcReader.js +1 -1
  92. package/dist/resource/formats/dxbc/core/DxbcReader.js.map +1 -1
  93. package/dist/resource/formats/dxbc/core/{program.js → DxbcShaderProgram.js} +2 -2
  94. package/dist/resource/formats/dxbc/core/DxbcShaderProgram.js.map +1 -0
  95. package/dist/resource/formats/dxbc/core/{signature.js → DxbcSignatureChunk.js} +2 -2
  96. package/dist/resource/formats/dxbc/core/DxbcSignatureChunk.js.map +1 -0
  97. package/dist/resource/formats/dxbc/core/decoder.js +2 -2
  98. package/dist/resource/formats/dxbc/core/decoder.js.map +1 -1
  99. package/dist/resource/formats/dxbc/core/helpers.js +3 -3
  100. package/dist/resource/formats/dxbc/core/helpers.js.map +1 -1
  101. package/dist/resource/formats/fbx/CjsFbxFormat.js +18 -20
  102. package/dist/resource/formats/fbx/CjsFbxFormat.js.map +1 -1
  103. package/dist/resource/formats/flac/CjsFlacFormat.js +7 -13
  104. package/dist/resource/formats/flac/CjsFlacFormat.js.map +1 -1
  105. package/dist/resource/formats/fsd/32/CjsFsd32Format.js +29 -29
  106. package/dist/resource/formats/fsd/32/CjsFsd32Format.js.map +1 -1
  107. package/dist/resource/formats/fsd/64/CjsFsd64Format.js +3 -3
  108. package/dist/resource/formats/fsd/64/CjsFsd64Format.js.map +1 -1
  109. package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js +23 -23
  110. package/dist/resource/formats/fsd/64/core/CjsFsd64Binary.js.map +1 -1
  111. package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js +8 -8
  112. package/dist/resource/formats/fsd/64/core/CjsFsd64Reader.js.map +1 -1
  113. package/dist/resource/formats/fsd/CjsFsdFormat.js +23 -23
  114. package/dist/resource/formats/fsd/CjsFsdFormat.js.map +1 -1
  115. package/dist/resource/formats/gif/CjsGifFormat.js +24 -15
  116. package/dist/resource/formats/gif/CjsGifFormat.js.map +1 -1
  117. package/dist/resource/formats/gltf/CjsGltfFormat.js +33 -98
  118. package/dist/resource/formats/gltf/CjsGltfFormat.js.map +1 -1
  119. package/dist/resource/formats/gltf/core/helpers.js +3 -12
  120. package/dist/resource/formats/gltf/core/helpers.js.map +1 -1
  121. package/dist/resource/formats/gr2/CjsGr2Format.js +27 -91
  122. package/dist/resource/formats/gr2/CjsGr2Format.js.map +1 -1
  123. package/dist/resource/formats/hlsl/CjsHlslFormat.js +22 -25
  124. package/dist/resource/formats/hlsl/CjsHlslFormat.js.map +1 -1
  125. package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js +1 -1
  126. package/dist/resource/formats/hlsl/core/carbonDescriptionToRuntime.js.map +1 -1
  127. package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js +3 -3
  128. package/dist/resource/formats/hlsl/core/tr2/shader/HlslEffectStageInput.js.map +1 -1
  129. package/dist/resource/formats/ies/CjsIESFormat.js +29 -29
  130. package/dist/resource/formats/ies/CjsIESFormat.js.map +1 -1
  131. package/dist/resource/formats/jpeg/CjsJpegFormat.js +24 -15
  132. package/dist/resource/formats/jpeg/CjsJpegFormat.js.map +1 -1
  133. package/dist/resource/formats/jpeg/core/helpers.js +3 -5
  134. package/dist/resource/formats/jpeg/core/helpers.js.map +1 -1
  135. package/dist/resource/formats/jpeg/core/jpeg.js +58 -58
  136. package/dist/resource/formats/jpeg/core/jpeg.js.map +1 -1
  137. package/dist/resource/formats/jsonl/CjsJsonlFormat.js +3 -3
  138. package/dist/resource/formats/jsonl/CjsJsonlFormat.js.map +1 -1
  139. package/dist/resource/formats/mp3/CjsMp3Format.js +7 -14
  140. package/dist/resource/formats/mp3/CjsMp3Format.js.map +1 -1
  141. package/dist/resource/formats/mp3/core/helpers.js +3 -5
  142. package/dist/resource/formats/mp3/core/helpers.js.map +1 -1
  143. package/dist/resource/formats/mp4/CjsMp4Format.js +7 -13
  144. package/dist/resource/formats/mp4/CjsMp4Format.js.map +1 -1
  145. package/dist/resource/formats/mp4/core/helpers.js +3 -5
  146. package/dist/resource/formats/mp4/core/helpers.js.map +1 -1
  147. package/dist/resource/formats/obj/CjsObjFormat.js +92 -157
  148. package/dist/resource/formats/obj/CjsObjFormat.js.map +1 -1
  149. package/dist/resource/formats/obj/core/helpers.js +5 -113
  150. package/dist/resource/formats/obj/core/helpers.js.map +1 -1
  151. package/dist/resource/formats/ogg/CjsOggFormat.js +7 -14
  152. package/dist/resource/formats/ogg/CjsOggFormat.js.map +1 -1
  153. package/dist/resource/formats/pickle/CjsPickleFormat.js +7 -12
  154. package/dist/resource/formats/pickle/CjsPickleFormat.js.map +1 -1
  155. package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js +7 -7
  156. package/dist/resource/formats/pickle/core/CjsPickleProtocol0Reader.js.map +1 -1
  157. package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js +7 -7
  158. package/dist/resource/formats/pickle/core/CjsPickleProtocol4Reader.js.map +1 -1
  159. package/dist/resource/formats/png/CjsPngFormat.js +40 -15
  160. package/dist/resource/formats/png/CjsPngFormat.js.map +1 -1
  161. package/dist/resource/formats/png/core/helpers.js +4 -6
  162. package/dist/resource/formats/png/core/helpers.js.map +1 -1
  163. package/dist/resource/formats/red/CjsRedFormat.js +22 -28
  164. package/dist/resource/formats/red/CjsRedFormat.js.map +1 -1
  165. package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js +3 -7
  166. package/dist/resource/formats/schemabound/CjsSchemaBoundFormat.js.map +1 -1
  167. package/dist/resource/formats/schemabound/core/schemaBoundValues.js +5 -0
  168. package/dist/resource/formats/schemabound/core/schemaBoundValues.js.map +1 -1
  169. package/dist/resource/formats/sqlite/CjsSqliteFormat.js +4 -9
  170. package/dist/resource/formats/sqlite/CjsSqliteFormat.js.map +1 -1
  171. package/dist/resource/formats/static/CjsStaticFormat.js +4 -4
  172. package/dist/resource/formats/static/CjsStaticFormat.js.map +1 -1
  173. package/dist/resource/formats/stl/CjsStlFormat.js +39 -104
  174. package/dist/resource/formats/stl/CjsStlFormat.js.map +1 -1
  175. package/dist/resource/formats/stl/core/helpers.js +5 -19
  176. package/dist/resource/formats/stl/core/helpers.js.map +1 -1
  177. package/dist/resource/formats/tga/CjsTgaFormat.js +26 -15
  178. package/dist/resource/formats/tga/CjsTgaFormat.js.map +1 -1
  179. package/dist/resource/formats/tga/core/helpers.js +3 -5
  180. package/dist/resource/formats/tga/core/helpers.js.map +1 -1
  181. package/dist/resource/formats/vta/CjsVtaFormat.js +8 -15
  182. package/dist/resource/formats/vta/CjsVtaFormat.js.map +1 -1
  183. package/dist/resource/formats/wav/CjsWavFormat.js +7 -14
  184. package/dist/resource/formats/wav/CjsWavFormat.js.map +1 -1
  185. package/dist/resource/formats/wav/core/helpers.js +3 -5
  186. package/dist/resource/formats/wav/core/helpers.js.map +1 -1
  187. package/dist/resource/formats/webgl/CjsWebglFormat.js +103 -105
  188. package/dist/resource/formats/webgl/CjsWebglFormat.js.map +1 -1
  189. package/dist/resource/formats/webgl/core/{errors.js → WebglReadError.js} +1 -1
  190. package/dist/resource/formats/webgl/core/WebglReadError.js.map +1 -0
  191. package/dist/resource/formats/webgl/core/effectPackage.js +1 -1
  192. package/dist/resource/formats/webgl/core/effectPackage.js.map +1 -1
  193. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js +3 -3
  194. package/dist/resource/formats/webgl/core/glsl/DxbcGlslEmitter.js.map +1 -1
  195. package/dist/resource/formats/webgl/core/glsl/{DxbcGlslHelpers.js → DxbcGlslHelperRegistry.js} +2 -2
  196. package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelperRegistry.js.map +1 -0
  197. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js +1 -1
  198. package/dist/resource/formats/webgl/core/glsl/DxbcGlslOperandFormatter.js.map +1 -1
  199. package/dist/resource/formats/webgl/core/glslBackendBlock.js +1 -1
  200. package/dist/resource/formats/webgl/core/glslBackendBlock.js.map +1 -1
  201. package/dist/resource/formats/webgl/core/helpers.js.map +1 -1
  202. package/dist/resource/formats/webgpu/CjsWebgpuFormat.js +28 -29
  203. package/dist/resource/formats/webgpu/CjsWebgpuFormat.js.map +1 -1
  204. package/dist/resource/formats/webgpu/core/{errors.js → WebgpuReadError.js} +1 -1
  205. package/dist/resource/formats/webgpu/core/WebgpuReadError.js.map +1 -0
  206. package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js +1 -1
  207. package/dist/resource/formats/webgpu/core/carbonWebgpu/validateContainer.js.map +1 -1
  208. package/dist/resource/formats/webgpu/core/helpers.js +1 -1
  209. package/dist/resource/formats/webgpu/core/helpers.js.map +1 -1
  210. package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js +1 -1
  211. package/dist/resource/formats/webgpu/core/ir/lowerDxbcToIr.js.map +1 -1
  212. package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js +18 -6
  213. package/dist/resource/formats/webgpu/core/wgsl/buildWgslSet.js.map +1 -1
  214. package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js +39 -13
  215. package/dist/resource/formats/webgpu/core/wgsl/lowerBindingLayout.js.map +1 -1
  216. package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js +16 -14
  217. package/dist/resource/formats/webgpu/core/wgsl/lowerCreateHistogramsComputeProgram.js.map +1 -1
  218. package/dist/resource/formats/webm/CjsWebmFormat.js +8 -13
  219. package/dist/resource/formats/webm/CjsWebmFormat.js.map +1 -1
  220. package/dist/resource/formats/webm/core/helpers.js +3 -5
  221. package/dist/resource/formats/webm/core/helpers.js.map +1 -1
  222. package/dist/resource/formats/webp/CjsWebpFormat.js +8 -12
  223. package/dist/resource/formats/webp/CjsWebpFormat.js.map +1 -1
  224. package/dist/resource/formats/wem/CjsWemFormat.js +9 -17
  225. package/dist/resource/formats/wem/CjsWemFormat.js.map +1 -1
  226. package/dist/resource/formats/wem/core/bitStream.js +35 -35
  227. package/dist/resource/formats/wem/core/bitStream.js.map +1 -1
  228. package/dist/resource/formats/wem/core/helpers.js +1 -3
  229. package/dist/resource/formats/wem/core/helpers.js.map +1 -1
  230. package/dist/resource/formats/yaml/CjsYamlFormat.js +28 -37
  231. package/dist/resource/formats/yaml/CjsYamlFormat.js.map +1 -1
  232. package/dist/resource/imageio/ImageIO.js +142 -0
  233. package/dist/resource/imageio/ImageIO.js.map +1 -0
  234. package/dist/resource/imageio/index.js +17 -0
  235. package/dist/resource/imageio/index.js.map +1 -0
  236. package/dist/resource/index.js +7 -0
  237. package/dist/resource/index.js.map +1 -1
  238. package/dist/resource/shader/reflection/Tr2EffectResource.js +24 -2
  239. package/dist/resource/shader/reflection/Tr2EffectResource.js.map +1 -1
  240. package/dist/resource/shader/reflection/Tr2Pass.js +76 -5
  241. package/dist/resource/shader/reflection/Tr2Pass.js.map +1 -1
  242. package/dist/resource/texture/CjsTextureArrayConstructor.js +97 -0
  243. package/dist/resource/texture/CjsTextureArrayConstructor.js.map +1 -0
  244. package/dist/resource/texture/CjsTexturePackConstructor.js +160 -0
  245. package/dist/resource/texture/CjsTexturePackConstructor.js.map +1 -0
  246. package/dist/resource/texture/CjsTexturePipelineStepArray.js +72 -0
  247. package/dist/resource/texture/CjsTexturePipelineStepArray.js.map +1 -0
  248. package/dist/resource/texture/CjsTexturePipelineStepConvert.js +73 -0
  249. package/dist/resource/texture/CjsTexturePipelineStepConvert.js.map +1 -0
  250. package/dist/resource/texture/CjsTexturePipelineStepPack.js +71 -0
  251. package/dist/resource/texture/CjsTexturePipelineStepPack.js.map +1 -0
  252. package/dist/resource/texture/CjsTexturePipelineStepResize.js +123 -0
  253. package/dist/resource/texture/CjsTexturePipelineStepResize.js.map +1 -0
  254. package/dist/resource/texture/SolidColorTextureConstructor.js +11 -1
  255. package/dist/resource/texture/SolidColorTextureConstructor.js.map +1 -1
  256. package/dist/resource/texture/Tr2ImageRes.js +100 -68
  257. package/dist/resource/texture/Tr2ImageRes.js.map +1 -1
  258. package/dist/resource/texture/Tr2TexturePipeline.js +45 -25
  259. package/dist/resource/texture/Tr2TexturePipeline.js.map +1 -1
  260. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js +34 -1
  261. package/dist/resource/texture/Tr2TexturePipelineStepCompress.js.map +1 -1
  262. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js +30 -3
  263. package/dist/resource/texture/Tr2TexturePipelineStepGenerateMips.js.map +1 -1
  264. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js +81 -1
  265. package/dist/resource/texture/Tr2TexturePipelineStepLimitSize.js.map +1 -1
  266. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js +36 -1
  267. package/dist/resource/texture/Tr2TexturePipelineStepLoad.js.map +1 -1
  268. package/dist/resource/texture/Tr2TexturePipelineStepPack.js +146 -24
  269. package/dist/resource/texture/Tr2TexturePipelineStepPack.js.map +1 -1
  270. package/dist/resource/texture/TriTextureRes.js +151 -29
  271. package/dist/resource/texture/TriTextureRes.js.map +1 -1
  272. package/dist/resource/texture/index.js +7 -0
  273. package/dist/resource/texture/index.js.map +1 -1
  274. package/dist/resource/texture/registerTextureResources.js +83 -0
  275. package/dist/resource/texture/registerTextureResources.js.map +1 -0
  276. package/dist/resource/texture/solidColorTexture.js +10 -19
  277. package/dist/resource/texture/solidColorTexture.js.map +1 -1
  278. package/dist/sof/EveSOF.js +39 -7
  279. package/dist/sof/EveSOF.js.map +1 -1
  280. package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js +2 -2
  281. package/dist/trinity/core/Tr2GpuResourcePool/Tr2GpuResourcePool.js.map +1 -1
  282. package/dist/trinity/core/Tr2ImageIOHelpers.js +80 -17
  283. package/dist/trinity/core/Tr2ImageIOHelpers.js.map +1 -1
  284. package/dist/trinity/core/Tr2RenderUtils.js +1 -1
  285. package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js +49 -62
  286. package/dist/trinity/core/Tr2TextureArray/Tr2TextureArray.js.map +1 -1
  287. package/dist/trinity/core/Tr2TextureReference.js +114 -0
  288. package/dist/trinity/core/Tr2TextureReference.js.map +1 -0
  289. package/dist/trinity/core/device/Tr2DepthStencil.js +2 -2
  290. package/dist/trinity/core/device/Tr2DepthStencil.js.map +1 -1
  291. package/dist/trinity/core/device/Tr2RingBuffer/Tr2RingBuffer.js +1 -1
  292. package/dist/trinity/core/index.js +1 -0
  293. package/dist/trinity/core/index.js.map +1 -1
  294. package/dist/trinity/core/lighting/Tr2LightManager.js +5 -4
  295. package/dist/trinity/core/lighting/Tr2LightManager.js.map +1 -1
  296. package/dist/trinity/core/procedural/GradientTextureConstructor.js +5 -4
  297. package/dist/trinity/core/procedural/GradientTextureConstructor.js.map +1 -1
  298. package/dist/trinity/core/procedural/gradientTexture.js +10 -13
  299. package/dist/trinity/core/procedural/gradientTexture.js.map +1 -1
  300. package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js +1 -1
  301. package/dist/trinity/core/volumetrics/Tr2VolumetricsRenderer.js.map +1 -1
  302. package/dist/trinity/eve/EveImpactOverlay.js +102 -50
  303. package/dist/trinity/eve/EveImpactOverlay.js.map +1 -1
  304. package/dist/trinity/eve/EveModularObjectModifier.js +9 -18
  305. package/dist/trinity/eve/EveModularObjectModifier.js.map +1 -1
  306. package/dist/trinity/eve/attachment/turrets/EveTurretSet.js +175 -157
  307. package/dist/trinity/eve/attachment/turrets/EveTurretSet.js.map +1 -1
  308. package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js +100 -83
  309. package/dist/trinity/eve/attachment/turrets/EveTurretTarget.js.map +1 -1
  310. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js +26 -20
  311. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMesh.js.map +1 -1
  312. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js +368 -179
  313. package/dist/trinity/eve/child/EveChildInstancedMeshes/EveChildInstancedMeshes.js.map +1 -1
  314. package/dist/trinity/eve/child/EveChildMesh.js +242 -234
  315. package/dist/trinity/eve/child/EveChildMesh.js.map +1 -1
  316. package/dist/trinity/eve/child/EveChildTurret.js +57 -16
  317. package/dist/trinity/eve/child/EveChildTurret.js.map +1 -1
  318. package/dist/trinity/eve/child/EveSpaceObjectChild.js +28 -1
  319. package/dist/trinity/eve/child/EveSpaceObjectChild.js.map +1 -1
  320. package/dist/trinity/eve/index.js +2 -2
  321. package/dist/trinity/eve/overlays/EveDamageOverlay.js +5 -1
  322. package/dist/trinity/eve/overlays/EveDamageOverlay.js.map +1 -1
  323. package/dist/trinity/eve/scene/EveSpaceScene.js +234 -233
  324. package/dist/trinity/eve/scene/EveSpaceScene.js.map +1 -1
  325. package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js +2 -0
  326. package/dist/trinity/eve/scene/EveSpaceSceneRenderDriver.js.map +1 -1
  327. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js +492 -437
  328. package/dist/trinity/eve/spaceObject/EveSpaceObject2.js.map +1 -1
  329. package/dist/trinity/generated/index.js +0 -1
  330. package/dist/trinity/generated/index.js.map +1 -1
  331. package/dist/trinity/generated/trinityCore/index.js +0 -1
  332. package/dist/trinity/generated/trinityCore/index.js.map +1 -1
  333. package/dist/trinity/index.js +3 -3
  334. package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js +10 -1
  335. package/dist/trinity/particle/emitter/Tr2GpuSharedEmitter.js.map +1 -1
  336. package/dist/trinity/shader/Tr2DataTextureManager.js +152 -66
  337. package/dist/trinity/shader/Tr2DataTextureManager.js.map +1 -1
  338. package/dist/trinity/shader/Tr2Material.js +1 -1
  339. package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js +5 -5
  340. package/dist/trinityal/Tr2HalHelperStructures/Tr2TextureSubresource.js.map +1 -1
  341. package/dist/trinityal/index.js +1 -1
  342. package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js +2 -2
  343. package/dist/trinityal/stub/Tr2RenderContextALStub/Tr2RenderContextALStub.js.map +1 -1
  344. package/dist/trinityal/stub/Tr2SwapChainALStub.js +45 -45
  345. package/dist/trinityal/stub/Tr2SwapChainALStub.js.map +1 -1
  346. package/dist/trinityal/stub/Tr2TextureALStub.js +170 -170
  347. package/dist/trinityal/stub/Tr2TextureALStub.js.map +1 -1
  348. package/dist/trinityal/webgpu/CjsWebgpuDevice.js +234 -164
  349. package/dist/trinityal/webgpu/CjsWebgpuDevice.js.map +1 -1
  350. package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js +7 -0
  351. package/dist/trinityal/webgpu/CjsWebgpuRenderContextAL.js.map +1 -1
  352. package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js +78 -14
  353. package/dist/trinityal/webgpu/CjsWebgpuTextureAL.js.map +1 -1
  354. package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js +94 -0
  355. package/dist/trinityal/webgpu/core/CjsWebgpuUtils.js.map +1 -0
  356. package/dist/trinityal/webgpu/internal.js +1 -0
  357. package/dist/trinityal/webgpu/internal.js.map +1 -1
  358. package/docs/global/reference/classes/README.md +90 -0
  359. package/docs/resource/concepts/format-capabilities.md +3 -3
  360. package/docs/resource/formats/README.md +1 -1
  361. package/docs/resource/reference/classes/core.md +31 -1
  362. package/docs/resource/reference/classes/formats.md +7 -7
  363. package/docs/resource/reference/classes/resources.md +76 -16
  364. package/docs/trinity/reference/classes/generated.md +0 -10
  365. package/docs/trinity/reference/classes/trinity-core.md +1692 -1682
  366. package/docs/trinityal/reference/classes/README.md +0 -10
  367. package/docs/trinityal/webgpu/reference/classes/README.md +276 -266
  368. package/package.json +4 -3
  369. package/dist/global/consts/webgpu/index.js +0 -2
  370. package/dist/global/consts/webgpu/textureFormats.js +0 -180
  371. package/dist/global/consts/webgpu/textureFormats.js.map +0 -1
  372. package/dist/resource/formats/dxbc/core/container.js.map +0 -1
  373. package/dist/resource/formats/dxbc/core/errors.js.map +0 -1
  374. package/dist/resource/formats/dxbc/core/program.js.map +0 -1
  375. package/dist/resource/formats/dxbc/core/signature.js.map +0 -1
  376. package/dist/resource/formats/stl/core/targets.js.map +0 -1
  377. package/dist/resource/formats/webgl/core/errors.js.map +0 -1
  378. package/dist/resource/formats/webgl/core/glsl/DxbcGlslHelpers.js.map +0 -1
  379. package/dist/resource/formats/webgpu/core/errors.js.map +0 -1
  380. package/dist/resource/texture/texturePipelineBehavior.js +0 -332
  381. package/dist/resource/texture/texturePipelineBehavior.js.map +0 -1
  382. package/dist/trinity/generated/trinityCore/Tr2TextureReference.js +0 -40
  383. package/dist/trinity/generated/trinityCore/Tr2TextureReference.js.map +0 -1
  384. package/dist/trinityal/Tr2BitmapDimensions.js.map +0 -1
@@ -7,7 +7,9 @@ import { ShouldReflect, EveComponentType } from '../../EveComponentTypes.js';
7
7
  import { EveSpaceObjectChild as _EveSpaceObjectChild } from '../EveSpaceObjectChild.js';
8
8
  import { RawData } from '../../../core/rawData/RawData.js';
9
9
  import { Tr2RenderReason } from '../../../generated/trinityCore/enums.js';
10
- import { CollectInstancedOverlayAreaBlocks, EmitOverlayBatches } from '../../overlays/overlayBatches.js';
10
+ import { CollectInstancedOverlayAreaBlocks, EmitDamageOverlayBatches, EmitOverlayBatches } from '../../overlays/overlayBatches.js';
11
+ import { EveDamageOverlay as _EveDamageOverlay } from '../../overlays/EveDamageOverlay.js';
12
+ import { EveGetLocatorPose } from '../../locator/EveLocatorSets.js';
11
13
  import { ITr2Renderable } from '../../../core/ITr2Renderable.js';
12
14
  import { EveChildInstancedMeshArea as _EveChildInstancedMes$3 } from './EveChildInstancedMeshArea.js';
13
15
  import { EveChildInstancedMeshInstance as _EveChildInstancedMes$1 } from './EveChildInstancedMeshInstance.js';
@@ -15,8 +17,8 @@ import { EveChildInstancedMesh as _EveChildInstancedMes$2 } from './EveChildInst
15
17
 
16
18
  let _initProto, _initClass, _init_name, _init_extra_name, _init_worldTransform, _init_extra_worldTransform, _init_hasUpdated, _init_extra_hasUpdated, _init_meshes, _init_extra_meshes;
17
19
 
18
- /** Carbon EveInstancedMeshManager::InstanceFlags (EveInstancedMeshManager.h:
19
- * 13-26, cpp:998-1048): a uint32 bitfield - bit (1 << batchType) per present
20
+ /** Carbon EveInstancedMeshManager::InstanceFlags (EveInstancedMeshManager.h:
21
+ * 13-26, cpp:998-1048): a uint32 bitfield - bit (1 << batchType) per present
20
22
  * batch type, CASTS_SHADOW = 1 << 30, RENDER_IN_REFLECTION = 1 << 31. */
21
23
  const INSTANCE_FLAG_CASTS_SHADOW = 0x40000000;
22
24
  const INSTANCE_FLAG_RENDER_IN_REFLECTION = 0x80000000;
@@ -28,10 +30,28 @@ const OVERLAY_INV_WORLD_SCRATCH = mat4.create();
28
30
  const OVERLAY_INV_LOCAL_SCRATCH = mat4.create();
29
31
  const OVERLAY_CLIP_SCRATCH = vec3.create();
30
32
 
31
- /**
32
- * Space-object child that hands batches of instanced meshes to the engine's
33
- * instanced mesh manager, owning their registration handles, instance flags and
34
- * world cull bounds.
33
+ /** Stand-in for an instance sphere the async pass has not built yet: Carbon
34
+ * sizes instanceSpheres at AddMesh (cpp:559), JS fills it lazily. */
35
+ const EMPTY_SPHERE = {
36
+ center: vec3.create(),
37
+ radius: 0
38
+ };
39
+
40
+ /**
41
+ * Returns the locator list of a part's own "damage" set, or null (Carbon
42
+ * EveChildInstancedMeshes.cpp:12-22, file-local).
43
+ */
44
+ function FindDamageLocators(sets) {
45
+ for (const entry of sets) {
46
+ if (entry.HasName("damage")) return entry.GetLocators();
47
+ }
48
+ return null;
49
+ }
50
+
51
+ /**
52
+ * Space-object child that hands batches of instanced meshes to the engine's
53
+ * instanced mesh manager, owning their registration handles, instance flags and
54
+ * world cull bounds.
35
55
  */
36
56
  let _EveChildInstancedMes;
37
57
  new class extends _identity {
@@ -43,7 +63,7 @@ new class extends _identity {
43
63
  } = _applyDecs2311(this, [type.define({
44
64
  className: "EveChildInstancedMeshes",
45
65
  family: "eve/child"
46
- }), carbon.inherit(ITr2Renderable)], [[[edit, edit.persist, type, type.string], 16, "name"], [[edit, edit.read, type, type.mat4], 16, "worldTransform"], [[edit, edit.read, type, type.boolean], 16, "hasUpdated"], [[edit, edit.persist, void 0, type.list("EveChildInstancedMesh")], 16, "meshes"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetName"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetName"], [[carbon, carbon.method, impl, impl.adapted], 18, "UpdateVisibility"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetRenderables"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetBoundingSphere"], [[carbon, carbon.method, impl, impl.implemented], 18, "UpdateSyncronous"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Trinity owns the CPU per-object field copy; the raytracing mesh build (cpp:283-327) is not ported yet. Mesh bounds come from a GetMeshData duck ({minBounds, maxBounds}) and meshes without one are skipped fail-closed.")], 18, "UpdateAsyncronous"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetLocalToWorldTransform"], [[carbon, carbon.method, impl, impl.implemented], 18, "Setup"], [[carbon, carbon.method, impl, impl.implemented], 18, "ChangeLOD"], [[carbon, carbon.method, impl, impl.adapted], 18, "SetOrigin"], [[carbon, carbon.method, impl, impl.implemented], 18, "IsAlwaysOn"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after manager removal is explicit in JavaScript; the option write, hash refresh and registration lifecycle otherwise follow Carbon.")], 18, "SetShaderOption"], [[carbon, carbon.method, impl, impl.adapted], 18, "AddMesh"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("JavaScript explicitly nulls manager handles after removal; Carbon invalidates them by reference.")], 18, "RemoveInstancesByPartTag"], [[carbon, carbon.method, impl, impl.implemented], 18, "CollectOwnedGeometry"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetInstanceTransformByPartTag"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetInstancesTransforms"], [[carbon, carbon.method, impl, impl.adapted], 18, "Clear"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetSofSourceLocator"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshInfo"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAreaInfo"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshDisplay"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after removal is explicit (Carbon's DataHandle is invalidated by the manager by reference).")], 18, "SetMeshDisplay"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshInheritOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetMeshInheritOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "AddMeshOverlayEffect"], [[carbon, carbon.method, impl, impl.implemented], 18, "RemoveMeshOverlayEffect"], [[carbon, carbon.method, impl, impl.implemented], 18, "ClearMeshOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshOverlayEffectCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "SetGeometryResource"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshData"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetRevision"], [[carbon, carbon.method, impl, impl.implemented], 18, "HasTransparentBatches"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetSortValue"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetPerObjectData"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "RegisterComponents"], [[carbon, carbon.method, impl, impl.implemented], 18, "UnRegisterComponents"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after removal is explicit (Carbon's DataHandle is invalidated by the manager by reference).")], 18, "UnregisterFromMeshManager"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("The manager is duck-typed and returns opaque handles (out-params become returns) - Carbon EveInstancedMeshManager is not ported (quarantined in src/trinity/dropped); Carbon's combinedVertexDeclaration gate (cpp:499, a D3D declaration handle rebuilt in RebuildCachedData cpp:435-457) reduces to geometry presence + IsGood, and the declaration argument is passed as 0 for the engine to rebuild; GetRawRoot() becomes the object itself as picking owner.")], 18, "AddMeshesToManager"], [[carbon, carbon.method, impl, impl.implemented], 18, "IsCastingShadow"], [[carbon, carbon.method, impl, impl.noop], 18, "GetShadowBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetShadowPerObjectData"]], 0, void 0, _EveSpaceObjectChild));
66
+ }), carbon.inherit(ITr2Renderable)], [[[edit, edit.persist, type, type.string], 16, "name"], [[edit, edit.read, type, type.mat4], 16, "worldTransform"], [[edit, edit.read, type, type.boolean], 16, "hasUpdated"], [[edit, edit.persist, void 0, type.list("EveChildInstancedMesh")], 16, "meshes"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetName"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetName"], [[carbon, carbon.method, impl, impl.adapted], 18, "UpdateVisibility"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetRenderables"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetBoundingSphere"], [[carbon, carbon.method, impl, impl.implemented], 18, "UpdateSyncronous"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Trinity owns the CPU per-object field copy; the raytracing mesh build (cpp:283-327) is not ported yet. Mesh bounds come from a GetMeshData duck ({minBounds, maxBounds}) and meshes without one are skipped fail-closed.")], 18, "UpdateAsyncronous"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetLocalToWorldTransform"], [[carbon, carbon.method, impl, impl.implemented], 18, "Setup"], [[carbon, carbon.method, impl, impl.implemented], 18, "ChangeLOD"], [[carbon, carbon.method, impl, impl.adapted], 18, "SetOrigin"], [[carbon, carbon.method, impl, impl.implemented], 18, "IsAlwaysOn"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after manager removal is explicit in JavaScript; the option write, hash refresh and registration lifecycle otherwise follow Carbon.")], 18, "SetShaderOption"], [[carbon, carbon.method, impl, impl.adapted], 18, "AddMesh"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("JavaScript explicitly nulls manager handles after removal; Carbon invalidates them by reference.")], 18, "RemoveInstancesByPartTag"], [[carbon, carbon.method, impl, impl.implemented], 18, "CollectOwnedGeometry"], [[carbon, carbon.method, impl, impl.implemented], 18, "CollectOwnedLocatorSets"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetPartDamageOverlay"], [[carbon, carbon.method, impl, impl.implemented], 18, "CreatePartDamageOverlay"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetPartArmorDamageShaderEffect"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetPartDamageLocatorAnimatedLocal"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetInstanceTransformByPartTag"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetInstancesTransforms"], [[carbon, carbon.method, impl, impl.adapted], 18, "Clear"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetSofSourceLocator"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshInfo"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetAreaInfo"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshDisplay"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after removal is explicit (Carbon's DataHandle is invalidated by the manager by reference).")], 18, "SetMeshDisplay"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshInheritOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "SetMeshInheritOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "AddMeshOverlayEffect"], [[carbon, carbon.method, impl, impl.implemented], 18, "RemoveMeshOverlayEffect"], [[carbon, carbon.method, impl, impl.implemented], 18, "ClearMeshOverlayEffects"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetMeshOverlayEffectCount"], [[carbon, carbon.method, impl, impl.adapted], 18, "SetGeometryResource"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetMeshData"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetRevision"], [[carbon, carbon.method, impl, impl.implemented], 18, "HasTransparentBatches"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetSortValue"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetPerObjectData"], [[carbon, carbon.method, impl, impl.adapted], 18, "GetBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "RegisterComponents"], [[carbon, carbon.method, impl, impl.implemented], 18, "UnRegisterComponents"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("Handle invalidation after removal is explicit (Carbon's DataHandle is invalidated by the manager by reference).")], 18, "UnregisterFromMeshManager"], [[carbon, carbon.method, impl, impl.adapted, void 0, impl.reason("The manager is duck-typed and returns opaque handles (out-params become returns) - Carbon EveInstancedMeshManager is not ported (quarantined in src/trinity/dropped); Carbon's combinedVertexDeclaration gate (cpp:499, a D3D declaration handle rebuilt in RebuildCachedData cpp:435-457) reduces to geometry presence + IsGood, and the declaration argument is passed as 0 for the engine to rebuild; GetRawRoot() becomes the object itself as picking owner.")], 18, "AddMeshesToManager"], [[carbon, carbon.method, impl, impl.implemented], 18, "IsCastingShadow"], [[carbon, carbon.method, impl, impl.noop], 18, "GetShadowBatches"], [[carbon, carbon.method, impl, impl.implemented], 18, "GetShadowPerObjectData"]], 0, void 0, _EveSpaceObjectChild));
47
67
  }
48
68
  name = (_initProto(this), _init_name(this, ""));
49
69
  worldTransform = (_init_extra_name(this), _init_worldTransform(this, mat4.create()));
@@ -54,9 +74,9 @@ new class extends _identity {
54
74
  /** Carbon m_perObjectDataHandle (h:143) - manager registration handle. */
55
75
  #perObjectDataHandle = null;
56
76
 
57
- /**
58
- * Carbon m_perObjectData (EveSpacePerObjectData): the PERSISTENT per-instance
59
- * record the mesh manager uploads into its structured buffer.
77
+ /**
78
+ * Carbon m_perObjectData (EveSpacePerObjectData): the PERSISTENT per-instance
79
+ * record the mesh manager uploads into its structured buffer.
60
80
  */
61
81
  #perObjectData = RawData.create("EveSpacePerObjectData");
62
82
 
@@ -70,16 +90,20 @@ new class extends _identity {
70
90
  #lastCameraFrustum = null;
71
91
  #lastInvLodFactor = 1;
72
92
 
93
+ /** Carbon m_partDamageOverlays (h:215): one damage overlay per part tag,
94
+ * created on first damage through CreatePartDamageOverlay. */
95
+ _partDamageOverlays = new Map();
96
+
73
97
  /** EVE_SPACEOBJECT_CUSTOWMASK_MAX (EveSpaceObject2.h:49). */
74
98
 
75
- /** Carbon m_allRegistered (h:147) - the AddMeshesToManager retry latch:
76
- * set optimistically each pass, cleared by ANY not-ready mesh/area so the
99
+ /** Carbon m_allRegistered (h:147) - the AddMeshesToManager retry latch:
100
+ * set optimistically each pass, cleared by ANY not-ready mesh/area so the
77
101
  * per-frame CollectMeshes retries until geometry streams in. */
78
102
  #allRegistered = false;
79
103
 
80
- /**
81
- * The authored name, persisted with the child and used to identify it in the
82
- * parent graph.
104
+ /**
105
+ * The authored name, persisted with the child and used to identify it in the
106
+ * parent graph.
83
107
  */
84
108
  GetName() {
85
109
  return this.name;
@@ -90,43 +114,43 @@ new class extends _identity {
90
114
  this.name = String(name ?? "");
91
115
  }
92
116
 
93
- /**
94
- * Carbon EveChildInstancedMeshes::UpdateVisibility (cpp:183-186) only caches
95
- * the frame's camera frustum for later use; the JS port has no consumer for
96
- * that cache, so the frame hook does nothing.
117
+ /**
118
+ * Carbon EveChildInstancedMeshes::UpdateVisibility (cpp:183-186) only caches
119
+ * the frame's camera frustum for later use; the JS port has no consumer for
120
+ * that cache, so the frame hook does nothing.
97
121
  */
98
122
  UpdateVisibility(updateContext) {
99
123
  this.#lastCameraFrustum = updateContext.GetFrustum();
100
124
  this.#lastInvLodFactor = updateContext.GetInvLodFactor();
101
125
  }
102
126
 
103
- /**
104
- * Carbon EveChildInstancedMeshes::GetRenderables (cpp:188-190) collects
105
- * nothing: the instanced mesh manager emits the draws, so the accumulator
106
- * comes back unchanged.
127
+ /**
128
+ * Carbon EveChildInstancedMeshes::GetRenderables (cpp:200-207): the base
129
+ * hull draws through the instanced mesh manager, so this child is a
130
+ * renderable only for overlay draws - inherited, own, or part damage.
107
131
  */
108
132
  GetRenderables(renderables = []) {
109
- if (this.hasUpdated && (this.#parentOverlayEffects?.length && this.#AnyMeshInheritsOverlayEffects() || this.#HasAnyOwnOverlayEffects())) {
133
+ if (this.hasUpdated && (this.#parentOverlayEffects?.length && this.#AnyMeshInheritsOverlayEffects() || this.#HasAnyOwnOverlayEffects() || this._partDamageOverlays.size !== 0)) {
110
134
  renderables.push(this);
111
135
  }
112
136
  return renderables;
113
137
  }
114
138
 
115
- /**
116
- * Carbon EveChildInstancedMeshes::GetBoundingSphere (cpp:192-195) always
117
- * returns false - the child publishes no bounds of its own, because each mesh
118
- * registers its own sphere group with the manager.
139
+ /**
140
+ * Carbon EveChildInstancedMeshes::GetBoundingSphere (cpp:192-195) always
141
+ * returns false - the child publishes no bounds of its own, because each mesh
142
+ * registers its own sphere group with the manager.
119
143
  */
120
144
  GetBoundingSphere() {
121
145
  return false;
122
146
  }
123
147
 
124
- /**
125
- * Carbon EveChildInstancedMeshes::UpdateAsyncronous (cpp:204-238): the
126
- * per-instance record is this child's own transforms plus the hull values it
127
- * inherits, flattened into ONE struct - EveSpacePerObjectData carries both
128
- * the VS and PS halves because the manager uploads it as a single instance.
129
- * @param {Object} parent - the space-object parent, when there is one
148
+ /**
149
+ * Carbon EveChildInstancedMeshes::UpdateAsyncronous (cpp:204-238): the
150
+ * per-instance record is this child's own transforms plus the hull values it
151
+ * inherits, flattened into ONE struct - EveSpacePerObjectData carries both
152
+ * the VS and PS halves because the manager uploads it as a single instance.
153
+ * @param {Object} parent - the space-object parent, when there is one
130
154
  */
131
155
  #UpdatePerObjectData(parent) {
132
156
  const record = this.#perObjectData;
@@ -184,10 +208,10 @@ new class extends _identity {
184
208
  };
185
209
  }
186
210
 
187
- /**
188
- * Stamps the child's world transform from the parent's localToWorldTransform
189
- * (Carbon cpp:197-200); every per-instance cull sphere the async pass builds
190
- * is derived from it.
211
+ /**
212
+ * Stamps the child's world transform from the parent's localToWorldTransform
213
+ * (Carbon cpp:197-200); every per-instance cull sphere the async pass builds
214
+ * is derived from it.
191
215
  */
192
216
  UpdateSyncronous(updateContext, params) {
193
217
  if (params?.localToWorldTransform?.length === 16) {
@@ -197,22 +221,25 @@ new class extends _identity {
197
221
  for (const mesh of this.meshes) {
198
222
  for (const overlay of mesh.ownOverlayEffects) overlay.Update(time, time);
199
223
  }
224
+
225
+ // Carbon cpp:228-231: every part's damage overlay publishes its block.
226
+ for (const overlay of this._partDamageOverlays.values()) overlay.UpdateSyncronous(updateContext);
200
227
  }
201
228
 
202
- /** Carbon EveChildInstancedMeshes::UpdateAsyncronous (cpp:202-328), the CPU
203
- * half: per-mesh RENDER_IN_REFLECTION refresh (cpp:251), the mesh-local
204
- * bounds sphere radius = |center| + radius (cpp:254-255), per-instance
205
- * world cull spheres - position from the instance translation (Carbon reads
206
- * the packed rows' w = _41.._43, i.e. the transform translation) moved
207
- * through the child world transform, radius scaled by the instance's max
208
- * basis length times the child worldScale (cpp:259-269; NOTE Carbon's two
209
- * scale extractions deliberately differ - worldScale uses the world
210
- * transform's basis ROWS while the instance scale uses the packed rows'
211
- * xyz = the transpose's rows; equal under rotation + uniform scale,
212
- * ported exactly) - the world bounding sphere over all instance spheres
213
- * (cpp:257-270), a live SetSphereGroupBounds refresh on registered handles
229
+ /** Carbon EveChildInstancedMeshes::UpdateAsyncronous (cpp:234-413), the CPU
230
+ * half: per-mesh RENDER_IN_REFLECTION refresh (cpp:251), the mesh-local
231
+ * bounds sphere radius = |center| + radius (cpp:254-255), per-instance
232
+ * world cull spheres - position from the instance translation (Carbon reads
233
+ * the packed rows' w = _41.._43, i.e. the transform translation) moved
234
+ * through the child world transform, radius scaled by the instance's max
235
+ * basis length times the child worldScale (cpp:259-269; NOTE Carbon's two
236
+ * scale extractions deliberately differ - worldScale uses the world
237
+ * transform's basis ROWS while the instance scale uses the packed rows'
238
+ * xyz = the transpose's rows; equal under rotation + uniform scale,
239
+ * ported exactly) - the world bounding sphere over all instance spheres
240
+ * (cpp:257-270), a live SetSphereGroupBounds refresh on registered handles
214
241
  * (cpp:272-278), and the hasUpdated stamp (cpp:281). */
215
- UpdateAsyncronous(_updateContext, params) {
242
+ UpdateAsyncronous(updateContext, params) {
216
243
  const previousWorldTransform = mat4.create();
217
244
  mat4.transpose(previousWorldTransform, this.#perObjectData.GetTransposed("worldTransform"));
218
245
  const parentRecords = this.#UpdatePerObjectData(params?.spaceObjectParent ?? null);
@@ -288,16 +315,49 @@ new class extends _identity {
288
315
  }
289
316
  const parent = params?.spaceObjectParent ?? null;
290
317
  this.#parentOverlayEffects = Array.isArray(parent?.overlayEffects) && parent.overlayEffects.length ? parent.overlayEffects : null;
291
- if (this.#parentOverlayEffects && this.#AnyMeshInheritsOverlayEffects() || this.#HasAnyOwnOverlayEffects()) {
292
- this.#UpdateOverlayInstanceData(parentRecords.vs, parentRecords.ps, previousWorldTransform);
318
+
319
+ // Carbon cpp:333-359: each part's overlay is aged against its own
320
+ // instance - local mesh sphere, world instance sphere, and the part's own
321
+ // bind-pose damage locators. A part whose mesh is not loaded gets Carbon's
322
+ // default owner info, which resolves no locators.
323
+ for (const [partTag, overlay] of this._partDamageOverlays) {
324
+ const info = {
325
+ boundingSphere: [0, 0, 0, -1],
326
+ estimatedPixelDiameter: 0,
327
+ isInFrustum: false
328
+ };
329
+ const found = this._FindMeshByPartTag(partTag);
330
+ const geometry = found?.mesh.GetGeometryResource();
331
+ if (found && geometry && geometry.IsGood() !== false) {
332
+ const meshData = geometry.GetMeshData(found.mesh.meshIndex);
333
+ if (meshData?.minBounds && meshData?.maxBounds) {
334
+ const minBounds = meshData.minBounds;
335
+ const maxBounds = meshData.maxBounds;
336
+ info.boundingSphere = [(minBounds[0] + maxBounds[0]) * 0.5, (minBounds[1] + maxBounds[1]) * 0.5, (minBounds[2] + maxBounds[2]) * 0.5, Math.hypot(maxBounds[0] - minBounds[0], maxBounds[1] - minBounds[1], maxBounds[2] - minBounds[2]) * 0.5];
337
+ }
338
+ const worldSphere = found.mesh.instanceSpheres[found.instanceIndex] ?? EMPTY_SPHERE;
339
+ const frustum = updateContext.GetFrustum();
340
+ info.estimatedPixelDiameter = Math.max(frustum.GetPixelSizeAccrossEst(worldSphere.center, worldSphere.radius) * updateContext.GetInvLodFactor(), 0);
341
+ info.isInFrustum = frustum.IsSphereVisible(worldSphere.center, worldSphere.radius);
342
+ const damageLocators = FindDamageLocators(found.mesh.ownedLocatorSets);
343
+ info.getDamageLocatorPositionOS = (index, out) => {
344
+ if (!damageLocators || index < 0 || index >= damageLocators.length) return false;
345
+ vec3.copy(out, damageLocators[index].position);
346
+ return true;
347
+ };
348
+ }
349
+ overlay.UpdateAsyncronous(updateContext, info, 0, false);
350
+ }
351
+ if (this.#parentOverlayEffects && this.#AnyMeshInheritsOverlayEffects() || this.#HasAnyOwnOverlayEffects() || this._partDamageOverlays.size !== 0) {
352
+ this.#UpdateOverlayInstanceData(updateContext, parentRecords.vs, parentRecords.ps, previousWorldTransform);
293
353
  }
294
354
  this.hasUpdated = true;
295
355
  }
296
356
 
297
357
  /** Builds one persistent VS/PS record pair per authored instance. */
298
- #UpdateOverlayInstanceData(parentVs, parentPs, previousWorldTransform) {
358
+ #UpdateOverlayInstanceData(updateContext, parentVs, parentPs, previousWorldTransform) {
299
359
  for (const mesh of this.meshes) {
300
- if (!mesh.instances.length || !mesh.display || !this.#MeshHasActiveOverlayEffects(mesh)) continue;
360
+ if (!mesh.instances.length || !mesh.display || !this._MeshNeedsOverlayPods(mesh)) continue;
301
361
  if (!mesh.overlayPods || mesh.overlayPods.length !== mesh.instances.length) {
302
362
  mesh.overlayPods = Array.from({
303
363
  length: mesh.instances.length
@@ -337,6 +397,15 @@ new class extends _identity {
337
397
  pod.ps.Set("clipSphereFactor", [0]);
338
398
  pod.ps.Set("clipSphereFactor2", [0]);
339
399
  }
400
+
401
+ // Carbon cpp:1238-1242: a damaged part flickers and reads its own
402
+ // rows of the damage data texture.
403
+ const damageOverlay = this._FindPartDamageOverlay(mesh.partTags[index]);
404
+ if (damageOverlay) {
405
+ const shipData = pod.ps.Get("shipData");
406
+ pod.ps.Set("shipData", [shipData[0], shipData[1] * damageOverlay.GetActivationStrength(updateContext), shipData[2], shipData[3]]);
407
+ pod.ps.Set("impactDataOffset", [damageOverlay.GetDataTextureOffset()]);
408
+ }
340
409
  }
341
410
  }
342
411
  }
@@ -356,10 +425,43 @@ new class extends _identity {
356
425
  return mesh.ownOverlayEffects.length !== 0 || this.#parentOverlayEffects !== null && mesh.inheritOverlayEffects;
357
426
  }
358
427
 
359
- /**
360
- * Returns the child's world transform as stamped by the last sync update.
361
- * @param {Float32Array} [out] - caller-owned; when given, receives a copy and is returned instead of the live matrix
362
- * @returns {Float32Array} out when supplied, otherwise the live internal matrix
428
+ /**
429
+ * Finds the mesh holding an instance of a part, and that instance's index
430
+ * (Carbon FindMeshByPartTag, cpp:1115-1132; the size_t* out-param becomes
431
+ * the returned record).
432
+ * @returns {{mesh: EveChildInstancedMesh, instanceIndex: Number}|null}
433
+ */
434
+ _FindMeshByPartTag(partTag) {
435
+ for (const mesh of this.meshes) {
436
+ const instanceIndex = mesh.partTags.indexOf(partTag);
437
+ if (instanceIndex !== -1) return {
438
+ mesh,
439
+ instanceIndex
440
+ };
441
+ }
442
+ return null;
443
+ }
444
+
445
+ /** Returns a part's damage overlay, or null (Carbon FindPartDamageOverlay, cpp:1134-1142). */
446
+ _FindPartDamageOverlay(partTag) {
447
+ return this._partDamageOverlays.get(partTag) ?? null;
448
+ }
449
+
450
+ /** Reports whether any instance of a mesh belongs to a damaged part (Carbon cpp:1144-1158). */
451
+ _MeshHasDamageOverlays(mesh) {
452
+ if (this._partDamageOverlays.size === 0) return false;
453
+ return mesh.partTags.some(tag => this._partDamageOverlays.has(tag));
454
+ }
455
+
456
+ /** Reports whether a mesh needs per-instance overlay pods (Carbon cpp:1160-1163). */
457
+ _MeshNeedsOverlayPods(mesh) {
458
+ return this.#MeshHasActiveOverlayEffects(mesh) || this._MeshHasDamageOverlays(mesh);
459
+ }
460
+
461
+ /**
462
+ * Returns the child's world transform as stamped by the last sync update.
463
+ * @param {Float32Array} [out] - caller-owned; when given, receives a copy and is returned instead of the live matrix
464
+ * @returns {Float32Array} out when supplied, otherwise the live internal matrix
363
465
  */
364
466
  GetLocalToWorldTransform(out = null) {
365
467
  if (out) {
@@ -368,37 +470,37 @@ new class extends _identity {
368
470
  return this.worldTransform;
369
471
  }
370
472
 
371
- /**
372
- * Carbon EveChildInstancedMeshes::Setup (cpp:335-337) is an intentional no-op:
373
- * placement comes from the authored per-instance transforms, not from an SRT
374
- * setup.
473
+ /**
474
+ * Carbon EveChildInstancedMeshes::Setup (cpp:335-337) is an intentional no-op:
475
+ * placement comes from the authored per-instance transforms, not from an SRT
476
+ * setup.
375
477
  */
376
478
  Setup() {}
377
479
 
378
- /**
379
- * Carbon EveChildInstancedMeshes::ChangeLOD (cpp:339-341) is an intentional
380
- * no-op; the child keeps no LOD state.
480
+ /**
481
+ * Carbon EveChildInstancedMeshes::ChangeLOD (cpp:339-341) is an intentional
482
+ * no-op; the child keeps no LOD state.
381
483
  */
382
484
  ChangeLOD() {}
383
485
 
384
- /**
385
- * Accepts and discards the placement origin; this child has no Carbon origin
386
- * field and stores none.
486
+ /**
487
+ * Accepts and discards the placement origin; this child has no Carbon origin
488
+ * field and stores none.
387
489
  */
388
490
  SetOrigin() {}
389
491
 
390
- /**
391
- * Returns false, so owners treat this child as subject to normal activation
392
- * gating.
492
+ /**
493
+ * Returns false, so owners treat this child as subject to normal activation
494
+ * gating.
393
495
  */
394
496
  IsAlwaysOn() {
395
497
  return false;
396
498
  }
397
499
 
398
- /** Carbon EveChildInstancedMeshes::SetShaderOption (cpp:343-359): flips the
399
- * option and refreshes the effect hash on every area, then removes any
400
- * registered mesh-group handle and clears the latch - so the groups
401
- * re-register with the NEW effectHash on the next AddMeshesToManager pass.
500
+ /** Carbon EveChildInstancedMeshes::SetShaderOption (cpp:343-359): flips the
501
+ * option and refreshes the effect hash on every area, then removes any
502
+ * registered mesh-group handle and clears the latch - so the groups
503
+ * re-register with the NEW effectHash on the next AddMeshesToManager pass.
402
504
  * Sphere/per-object handles deliberately stay registered. */
403
505
  SetShaderOption(name, value) {
404
506
  for (const mesh of this.meshes) {
@@ -415,14 +517,16 @@ new class extends _identity {
415
517
  this.#revision++;
416
518
  }
417
519
 
418
- /**
419
- * Appends one instanced mesh: normalizes the area ducks, copies the instance transforms, stamps CASTS_SHADOW plus one flag bit per area batch type (Carbon cpp:418-425), and clears the registration latch so the next AddMeshesToManager pass picks it up.
420
- * @param {Iterable} areas - area ducks ({effect, batchType, areaIndex, areaCount})
421
- * @param {Iterable<Float32Array>} instanceTransforms - 16-value matrices; copied, not retained
422
- * @param {Number} partTag - modular owner shared by every appended instance
423
- * @returns {Boolean} false when no areas or no instances were supplied (nothing is added)
520
+ /**
521
+ * Appends one instanced mesh: normalizes the area ducks, copies the instance transforms, stamps CASTS_SHADOW plus one flag bit per area batch type (Carbon cpp:574-581), and clears the registration latch so the next AddMeshesToManager pass picks it up.
522
+ * @param {Iterable} areas - area ducks ({effect, batchType, areaIndex, areaCount})
523
+ * @param {Iterable<Float32Array>} instanceTransforms - 16-value matrices; copied, not retained
524
+ * @param {Number} partTag - modular owner shared by every appended instance
525
+ * @param {Iterable} ownedLocatorSets - the part's hull-local EveLocatorSets, merged by the owner per instance
526
+ * @param {Object|null} armorDamageShader - the part's armour damage Tr2Effect
527
+ * @returns {Boolean} false when no areas or no instances were supplied (nothing is added)
424
528
  */
425
- AddMesh(geometryPath, castsShadow, reflectionMode, meshIndex, areas, instanceTransforms, sofHullName = "", sofLocatorSetName = "", partTag = 0) {
529
+ AddMesh(geometryPath, castsShadow, reflectionMode, meshIndex, areas, instanceTransforms, sofHullName = "", sofLocatorSetName = "", partTag = 0, ownedLocatorSets = [], armorDamageShader = null) {
426
530
  const sourceAreas = Array.from(areas ?? []);
427
531
  const sourceTransforms = Array.from(instanceTransforms ?? []);
428
532
  if (!sourceAreas.length || !sourceTransforms.length) {
@@ -448,9 +552,15 @@ new class extends _identity {
448
552
  mesh.partTags = instances.map(() => Number(partTag) >>> 0);
449
553
  mesh.sofHullName = String(sofHullName ?? "");
450
554
  mesh.sofLocatorSetName = String(sofLocatorSetName ?? "");
451
- // Carbon (cpp:418-425): the CASTS_SHADOW flag and one bit per area batch
555
+ mesh.ownedLocatorSets = Array.from(ownedLocatorSets ?? []);
556
+ mesh.armorDamageShader = armorDamageShader ?? null;
557
+ // Carbon cpp:586-589: the owner merges this part's sets per instance.
558
+ if (mesh.ownedLocatorSets.length && this.GetOwner()) {
559
+ this.GetOwner().InvalidateMergedLocators("structure");
560
+ }
561
+ // Carbon (cpp:574-581): the CASTS_SHADOW flag and one bit per area batch
452
562
  // type are stamped at add time; RENDER_IN_REFLECTION is refreshed each
453
- // async pass. cpp:428 clears the registration latch.
563
+ // async pass. cpp:590 clears the registration latch.
454
564
  if (mesh.castsShadow) {
455
565
  mesh.flags = (mesh.flags | INSTANCE_FLAG_CASTS_SHADOW) >>> 0;
456
566
  }
@@ -463,13 +573,14 @@ new class extends _identity {
463
573
  return true;
464
574
  }
465
575
 
466
- /**
467
- * Removes every instance owned by a modular part, dropping empty meshes and
468
- * invalidating manager registrations.
576
+ /**
577
+ * Removes every instance owned by a modular part, dropping empty meshes and
578
+ * invalidating manager registrations.
469
579
  */
470
580
  RemoveInstancesByPartTag(partTag) {
471
581
  const tag = Number(partTag) >>> 0;
472
582
  let changed = false;
583
+ let removedOwnedLocators = false;
473
584
  for (let meshIndex = this.meshes.length - 1; meshIndex >= 0; meshIndex--) {
474
585
  const mesh = this.meshes[meshIndex];
475
586
  const keptInstances = [];
@@ -484,6 +595,7 @@ new class extends _identity {
484
595
  keptTags.push(instanceTag);
485
596
  }
486
597
  if (keptInstances.length === mesh.instances.length) continue;
598
+ removedOwnedLocators ||= mesh.ownedLocatorSets.length !== 0;
487
599
  if (mesh.sphereHandle !== null) {
488
600
  this.#meshManager.RemoveBoundingSphereGroup(mesh.sphereHandle);
489
601
  mesh.sphereHandle = null;
@@ -509,16 +621,22 @@ new class extends _identity {
509
621
  this.#allRegistered = false;
510
622
  this.#revision++;
511
623
  }
624
+ // Carbon cpp:659-663: the part's damage overlay goes with it, and the
625
+ // owner re-merges without the part's locators.
626
+ this._partDamageOverlays.delete(tag);
627
+ if (removedOwnedLocators && this.GetOwner()) {
628
+ this.GetOwner().InvalidateMergedLocators("structure");
629
+ }
512
630
  return changed;
513
631
  }
514
632
 
515
- /**
516
- * Contributes every instance of every mesh to the owner's merged raycast set
517
- * (Carbon EveChildInstancedMeshes.cpp:1279-1324): the type-matching areas
518
- * are appended ONCE per mesh and shared by all of that mesh's instance
519
- * records via areaStart/areaCount; meshes with no matching areas contribute
520
- * nothing. Carbon row-vector instanceTransform * parentTransform maps to
521
- * gl-matrix multiply(out, parentTransform, instanceTransform).
633
+ /**
634
+ * Contributes every instance of every mesh to the owner's merged raycast set
635
+ * (Carbon EveChildInstancedMeshes.cpp:1279-1324): the type-matching areas
636
+ * are appended ONCE per mesh and shared by all of that mesh's instance
637
+ * records via areaStart/areaCount; meshes with no matching areas contribute
638
+ * nothing. Carbon row-vector instanceTransform * parentTransform maps to
639
+ * gl-matrix multiply(out, parentTransform, instanceTransform).
522
640
  */
523
641
  CollectOwnedGeometry(type, parentTransform, out, areaPool) {
524
642
  for (const mesh of this.meshes) {
@@ -549,30 +667,91 @@ new class extends _identity {
549
667
  }
550
668
  }
551
669
 
552
- /**
553
- * Overwrites the transform of every instance owned by a modular part with an
554
- * ABSOLUTE new transform (Carbon EveChildInstancedMeshes.cpp:591-605,
555
- * PLAT-11963). Carbon writes only the instance transform: no dirty flag, no
556
- * handle teardown - the per-frame async pass refreshes the cull spheres from
557
- * the live transforms, and the per-part filter lives HERE, not at the call
558
- * site (the shared child carries many parts' instances).
670
+ /**
671
+ * Contributes each part's owned locator sets once per instance, tagged with
672
+ * that instance's part (Carbon EveChildInstancedMeshes.cpp:1473-1495).
673
+ * Carbon row-vector instanceTransform * parentTransform maps to gl-matrix
674
+ * multiply(out, parentTransform, instanceTransform).
675
+ */
676
+ CollectOwnedLocatorSets(parentTransform, out) {
677
+ for (const mesh of this.meshes) {
678
+ for (const sets of mesh.ownedLocatorSets) {
679
+ if (!sets || !sets.GetLocators().length) continue;
680
+ for (let index = 0; index < mesh.instances.length; index++) {
681
+ const childToObject = mat4.create();
682
+ mat4.multiply(childToObject, parentTransform, mesh.instances[index].transform);
683
+ out.push({
684
+ childToObject,
685
+ owner: this,
686
+ partTag: mesh.partTags[index],
687
+ sets
688
+ });
689
+ }
690
+ }
691
+ }
692
+ }
693
+
694
+ /** Returns a part's damage overlay, or null while it has none (Carbon cpp:1497-1500). */
695
+ GetPartDamageOverlay(partTag) {
696
+ return this._FindPartDamageOverlay(partTag);
697
+ }
698
+
699
+ /** Creates a part's damage overlay when it does not yet exist (Carbon cpp:1502-1509). */
700
+ CreatePartDamageOverlay(partTag) {
701
+ if (!this._partDamageOverlays.has(partTag)) {
702
+ this._partDamageOverlays.set(partTag, new _EveDamageOverlay());
703
+ }
704
+ }
705
+
706
+ /** Returns the armour damage shader of the mesh carrying a part (Carbon cpp:1511-1518). */
707
+ GetPartArmorDamageShaderEffect(partTag) {
708
+ return this._FindMeshByPartTag(partTag)?.mesh.armorDamageShader ?? null;
709
+ }
710
+
711
+ /**
712
+ * Writes the part-local pose of one of a part's damage locators. Shared
713
+ * instances carry no skeleton, so the pose is the authored one (Carbon
714
+ * cpp:1520-1534 passes a null animation updater).
715
+ */
716
+ GetPartDamageLocatorAnimatedLocal(partTag, index, position, direction) {
717
+ const found = this._FindMeshByPartTag(partTag);
718
+ if (!found) return false;
719
+ const locators = FindDamageLocators(found.mesh.ownedLocatorSets);
720
+ if (!locators || index < 0 || index >= locators.length) return false;
721
+ EveGetLocatorPose(position, direction, null, locators[index]);
722
+ return true;
723
+ }
724
+
725
+ /**
726
+ * Overwrites the transform of every instance owned by a modular part with an
727
+ * ABSOLUTE new transform (Carbon EveChildInstancedMeshes.cpp:665-685,
728
+ * PLAT-11963). No handle teardown - the per-frame async pass refreshes the
729
+ * cull spheres from the live transforms - but a part that owns locators
730
+ * invalidates the owner's merged set. The per-part filter lives HERE, not at
731
+ * the call site (the shared child carries many parts' instances).
559
732
  */
560
733
  SetInstanceTransformByPartTag(partTag, translation, rotation, scale) {
561
734
  const tag = Number(partTag) >>> 0;
562
735
  const transform = mat4.fromRotationTranslationScale(mat4.create(), rotation, translation, scale);
736
+ let movedOwnedLocators = false;
563
737
  for (const mesh of this.meshes) {
564
738
  for (let index = 0; index < mesh.instances.length; index++) {
565
739
  if (Number(mesh.partTags[index] ?? 0) >>> 0 === tag) {
566
740
  mat4.copy(mesh.instances[index].transform, transform);
741
+ movedOwnedLocators ||= mesh.ownedLocatorSets.length !== 0;
567
742
  }
568
743
  }
569
744
  }
745
+ // Carbon cpp:681-684: moved part-owned locators are re-merged.
746
+ if (movedOwnedLocators && this.GetOwner()) {
747
+ this.GetOwner().InvalidateMergedLocators("partMoved");
748
+ }
570
749
  }
571
750
 
572
- /**
573
- * Returns one [translation, rotation, scale] decomposition per instance of a
574
- * mesh (Carbon EveChildInstancedMeshes.cpp:781-806, script-exposed tooling);
575
- * throws RangeError where Carbon raises IndexError.
751
+ /**
752
+ * Returns one [translation, rotation, scale] decomposition per instance of a
753
+ * mesh (Carbon EveChildInstancedMeshes.cpp:781-806, script-exposed tooling);
754
+ * throws RangeError where Carbon raises IndexError.
576
755
  */
577
756
  GetInstancesTransforms(meshId) {
578
757
  const index = Number(meshId) >>> 0;
@@ -595,10 +774,10 @@ new class extends _identity {
595
774
  });
596
775
  }
597
776
 
598
- /**
599
- * Drops every mesh and clears the hasUpdated stamp so nothing re-registers
600
- * until another update pass runs; registration handles are NOT released here,
601
- * so call UnregisterFromMeshManager first when a manager still holds them.
777
+ /**
778
+ * Drops every mesh and clears the hasUpdated stamp so nothing re-registers
779
+ * until another update pass runs; registration handles are NOT released here,
780
+ * so call UnregisterFromMeshManager first when a manager still holds them.
602
781
  */
603
782
  Clear() {
604
783
  this.meshes.length = 0;
@@ -606,10 +785,10 @@ new class extends _identity {
606
785
  this.#revision++;
607
786
  }
608
787
 
609
- /**
610
- * Decodes a picking area id back to the SOF locator it came from.
611
- * @param {Number} areaId - mesh ordinal in the high 16 bits, locator index in the low 16 (the pairing AddMeshesToManager registers)
612
- * @returns {Array|null} [sofHullName, sofLocatorSetName, locatorIndex], or null when the mesh is unknown or carries no SOF hull name
788
+ /**
789
+ * Decodes a picking area id back to the SOF locator it came from.
790
+ * @param {Number} areaId - mesh ordinal in the high 16 bits, locator index in the low 16 (the pairing AddMeshesToManager registers)
791
+ * @returns {Array|null} [sofHullName, sofLocatorSetName, locatorIndex], or null when the mesh is unknown or carries no SOF hull name
613
792
  */
614
793
  GetSofSourceLocator(areaId) {
615
794
  const value = Number(areaId) >>> 0;
@@ -625,21 +804,21 @@ new class extends _identity {
625
804
  return this.meshes.length;
626
805
  }
627
806
 
628
- /**
629
- * Reports one mesh's authoring state as a positional tuple (Carbon's multiple out-params).
630
- * @param {Number} meshId - mesh index; RangeError when out of range
631
- * @returns {Array} [geometryPath, geometryResource, meshIndex, castsShadow, reflectionMode, areaCount, instanceCount]
807
+ /**
808
+ * Reports one mesh's authoring state as a positional tuple (Carbon's multiple out-params).
809
+ * @param {Number} meshId - mesh index; RangeError when out of range
810
+ * @returns {Array} [geometryPath, geometryResource, meshIndex, castsShadow, reflectionMode, areaCount, instanceCount]
632
811
  */
633
812
  GetMeshInfo(meshId) {
634
813
  const mesh = _EveChildInstancedMes.#GetMesh(this.meshes, meshId);
635
814
  return [mesh.geometryPath, mesh.GetGeometryResource(), mesh.meshIndex, mesh.castsShadow, mesh.reflectionMode, mesh.areas.length, mesh.instances.length];
636
815
  }
637
816
 
638
- /**
639
- * Reports one area of one mesh as a positional tuple (Carbon's multiple out-params).
640
- * @param {Number} meshId - mesh index; RangeError when out of range
641
- * @param {Number} areaId - area index within that mesh; RangeError when out of range
642
- * @returns {Array} [effect, batchType, areaIndex, areaCount] - the effect is the live reference
817
+ /**
818
+ * Reports one area of one mesh as a positional tuple (Carbon's multiple out-params).
819
+ * @param {Number} meshId - mesh index; RangeError when out of range
820
+ * @param {Number} areaId - area index within that mesh; RangeError when out of range
821
+ * @returns {Array} [effect, batchType, areaIndex, areaCount] - the effect is the live reference
643
822
  */
644
823
  GetAreaInfo(meshId, areaId) {
645
824
  const mesh = _EveChildInstancedMes.#GetMesh(this.meshes, meshId);
@@ -651,17 +830,17 @@ new class extends _identity {
651
830
  return [area.effect, area.batchType, area.areaIndex, area.areaCount];
652
831
  }
653
832
 
654
- /**
655
- * Whether the given mesh is currently displayed; throws RangeError for an
656
- * unknown mesh index.
833
+ /**
834
+ * Whether the given mesh is currently displayed; throws RangeError for an
835
+ * unknown mesh index.
657
836
  */
658
837
  GetMeshDisplay(meshId) {
659
838
  return _EveChildInstancedMes.#GetMesh(this.meshes, meshId).display;
660
839
  }
661
840
 
662
- /** Carbon EveChildInstancedMeshes::SetMeshDisplay (cpp:663-691): a toggle
663
- * clears the latch; turning a mesh OFF eagerly removes its sphere and
664
- * mesh-group handles - which is why AddMeshesToManager's display-off skip
841
+ /** Carbon EveChildInstancedMeshes::SetMeshDisplay (cpp:663-691): a toggle
842
+ * clears the latch; turning a mesh OFF eagerly removes its sphere and
843
+ * mesh-group handles - which is why AddMeshesToManager's display-off skip
665
844
  * does NOT clear the latch (the handles are already gone). */
666
845
  SetMeshDisplay(meshId, display) {
667
846
  const mesh = _EveChildInstancedMes.#GetMesh(this.meshes, meshId);
@@ -727,9 +906,9 @@ new class extends _identity {
727
906
  return _EveChildInstancedMes.#GetMesh(this.meshes, meshId).ownOverlayEffects.length;
728
907
  }
729
908
 
730
- /**
731
- * Assigns one mesh's geometry resource, bumping the revision only when it
732
- * actually changes; registration waits for the next AddMeshesToManager pass.
909
+ /**
910
+ * Assigns one mesh's geometry resource, bumping the revision only when it
911
+ * actually changes; registration waits for the next AddMeshesToManager pass.
733
912
  */
734
913
  SetGeometryResource(meshId, geometry) {
735
914
  const mesh = _EveChildInstancedMes.#GetMesh(this.meshes, meshId);
@@ -739,20 +918,20 @@ new class extends _identity {
739
918
  }
740
919
  }
741
920
 
742
- /**
743
- * Returns a detached snapshot of one mesh - instance transforms cloned, areas
744
- * shallow-copied, geometry resource shared by reference - so callers can read
745
- * it without touching live registration state.
921
+ /**
922
+ * Returns a detached snapshot of one mesh - instance transforms cloned, areas
923
+ * shallow-copied, geometry resource shared by reference - so callers can read
924
+ * it without touching live registration state.
746
925
  */
747
926
  GetMeshData(meshId) {
748
927
  const mesh = _EveChildInstancedMes.#GetMesh(this.meshes, meshId);
749
928
  return _EveChildInstancedMes.#CloneMesh(mesh);
750
929
  }
751
930
 
752
- /**
753
- * Monotonic counter bumped by every structural change (AddMesh, Clear,
754
- * SetMeshDisplay, SetGeometryResource, SetShaderOption), for consumers caching
755
- * derived data.
931
+ /**
932
+ * Monotonic counter bumped by every structural change (AddMesh, Clear,
933
+ * SetMeshDisplay, SetGeometryResource, SetShaderOption), for consumers caching
934
+ * derived data.
756
935
  */
757
936
  GetRevision() {
758
937
  return this.#revision;
@@ -779,11 +958,11 @@ new class extends _identity {
779
958
 
780
959
  /** Exposes stable per-instance CPU record pairs for this frame's overlay batches. */
781
960
  GetPerObjectData(_accumulator = null) {
782
- if ((!this.#parentOverlayEffects || !this.#AnyMeshInheritsOverlayEffects()) && !this.#HasAnyOwnOverlayEffects()) return null;
961
+ if ((!this.#parentOverlayEffects || !this.#AnyMeshInheritsOverlayEffects()) && !this.#HasAnyOwnOverlayEffects() && this._partDamageOverlays.size === 0) return null;
783
962
  let first = null;
784
963
  for (const mesh of this.meshes) {
785
964
  if (!mesh.overlayPods) continue;
786
- if (!mesh.display || !this.#MeshHasActiveOverlayEffects(mesh)) {
965
+ if (!mesh.display || !this._MeshNeedsOverlayPods(mesh)) {
787
966
  for (const pod of mesh.overlayPods) pod.framePod = null;
788
967
  continue;
789
968
  }
@@ -804,7 +983,8 @@ new class extends _identity {
804
983
  let committed = false;
805
984
  for (const mesh of this.meshes) {
806
985
  const inherited = this.#parentOverlayEffects && mesh.inheritOverlayEffects ? this.#parentOverlayEffects : null;
807
- if (!inherited?.length && !mesh.ownOverlayEffects.length || !mesh.display || !mesh.overlayPods) continue;
986
+ const hasDamageOverlays = this._MeshHasDamageOverlays(mesh);
987
+ if (!inherited?.length && !mesh.ownOverlayEffects.length && !hasDamageOverlays || !mesh.display || !mesh.overlayPods) continue;
808
988
  if (reason === Tr2RenderReason.TR2RENDERREASON_REFLECTION && !ShouldReflect(mesh.reflectionMode)) continue;
809
989
  const geometry = mesh.GetGeometryResource();
810
990
  if (!geometry || geometry.IsGood() === false) continue;
@@ -820,6 +1000,15 @@ new class extends _identity {
820
1000
  if (this.#lastCameraFrustum && this.#lastCameraFrustum.IsSphereVisible(sphere.center, sphere.radius) === false) continue;
821
1001
  const screenSize = this.#lastCameraFrustum ? this.#lastCameraFrustum.GetPixelSizeAccrossEst(sphere.center, sphere.radius) * this.#lastInvLodFactor : Infinity;
822
1002
  const lod = geometry.GetMeshLod(mesh.meshIndex, screenSize);
1003
+
1004
+ // Carbon cpp:1404-1413: the part's damage pass comes first, under
1005
+ // its own and the inherited overlays.
1006
+ if (hasDamageOverlays) {
1007
+ const damageShader = this._FindPartDamageOverlay(mesh.partTags[index])?.GetArmorDamageShader(batchType);
1008
+ if (damageShader) {
1009
+ committed = EmitDamageOverlayBatches(batches, pod.framePod, damageShader, mesh.overlayAreaBlocks, geometry, mesh.meshIndex, lod) || committed;
1010
+ }
1011
+ }
823
1012
  if (mesh.ownOverlayEffects.length) {
824
1013
  committed = EmitOverlayBatches(batches, pod.framePod, batchType, mesh.ownOverlayEffects, mesh.overlayAreaBlocks, geometry, mesh.meshIndex, lod) || committed;
825
1014
  }
@@ -831,8 +1020,8 @@ new class extends _identity {
831
1020
  return committed;
832
1021
  }
833
1022
 
834
- /** Carbon EveChildInstancedMeshes::RegisterComponents (cpp:36-43):
835
- * unconditional InstancedMeshProvider + ShadowCaster leaf
1023
+ /** Carbon EveChildInstancedMeshes::RegisterComponents (cpp:36-43):
1024
+ * unconditional InstancedMeshProvider + ShadowCaster leaf
836
1025
  * self-registration. */
837
1026
  RegisterComponents() {
838
1027
  const registry = this.GetComponentRegistry();
@@ -842,15 +1031,15 @@ new class extends _identity {
842
1031
  }
843
1032
  }
844
1033
 
845
- /** Carbon EveChildInstancedMeshes::UnRegisterComponents (cpp:45-48) only
846
- * calls UnregisterFromMeshManager; own components were already removed by
1034
+ /** Carbon EveChildInstancedMeshes::UnRegisterComponents (cpp:45-48) only
1035
+ * calls UnregisterFromMeshManager; own components were already removed by
847
1036
  * EveEntity::UnRegister (EveEntity.cpp:90). */
848
1037
  UnRegisterComponents() {
849
1038
  this.UnregisterFromMeshManager();
850
1039
  }
851
1040
 
852
- /** Carbon EveChildInstancedMeshes::UnregisterFromMeshManager (cpp:50-71):
853
- * every registered mesh-group / sphere-group / per-object handle is removed
1041
+ /** Carbon EveChildInstancedMeshes::UnregisterFromMeshManager (cpp:50-71):
1042
+ * every registered mesh-group / sphere-group / per-object handle is removed
854
1043
  * through the manager that issued the opaque handles, then the latch clears. */
855
1044
  UnregisterFromMeshManager() {
856
1045
  for (const mesh of this.meshes) {
@@ -877,19 +1066,19 @@ new class extends _identity {
877
1066
  this.#allRegistered = false;
878
1067
  }
879
1068
 
880
- /** Carbon EveChildInstancedMeshes::AddMeshesToManager (cpp:472-553), the
881
- * InstancedMeshProvider entry the engine's CollectMeshes drives
882
- * (EveInstancedMeshManager.cpp:45-56; scene EveSpaceScene.cpp:1516).
883
- * Contract quirks preserved: nothing registers before the first update
884
- * pass (cpp:474); switching managers tears EVERYTHING down BEFORE the
885
- * latch early-out (cpp:478-481); the latch is set optimistically and
886
- * cleared by ANY not-ready mesh/area so the per-frame caller retries until
887
- * geometry streams in - EXCEPT display-off meshes, which skip WITHOUT
888
- * clearing it (their handles were already removed by SetMeshDisplay);
889
- * handles are add-once (partial re-registration after SetShaderOption /
890
- * display toggles); an area-level effect failure clears the latch while
891
- * the mesh's sphere group STAYS registered (Carbon's asymmetry);
892
- * pickingOwnerIndex is the mesh ordinal (pairs with GetSofSourceLocator's
1069
+ /** Carbon EveChildInstancedMeshes::AddMeshesToManager (cpp:472-553), the
1070
+ * InstancedMeshProvider entry the engine's CollectMeshes drives
1071
+ * (EveInstancedMeshManager.cpp:45-56; scene EveSpaceScene.cpp:1516).
1072
+ * Contract quirks preserved: nothing registers before the first update
1073
+ * pass (cpp:474); switching managers tears EVERYTHING down BEFORE the
1074
+ * latch early-out (cpp:478-481); the latch is set optimistically and
1075
+ * cleared by ANY not-ready mesh/area so the per-frame caller retries until
1076
+ * geometry streams in - EXCEPT display-off meshes, which skip WITHOUT
1077
+ * clearing it (their handles were already removed by SetMeshDisplay);
1078
+ * handles are add-once (partial re-registration after SetShaderOption /
1079
+ * display toggles); an area-level effect failure clears the latch while
1080
+ * the mesh's sphere group STAYS registered (Carbon's asymmetry);
1081
+ * pickingOwnerIndex is the mesh ordinal (pairs with GetSofSourceLocator's
893
1082
  * meshIndex<<16 decode). */
894
1083
  AddMeshesToManager(manager) {
895
1084
  if (!this.hasUpdated) {
@@ -943,41 +1132,41 @@ new class extends _identity {
943
1132
  }
944
1133
  }
945
1134
 
946
- /** Carbon EveChildInstancedMeshes::IsCastingShadow (cpp:73-76) always
947
- * returns false (instanced shadows cull per instance group); presence
1135
+ /** Carbon EveChildInstancedMeshes::IsCastingShadow (cpp:73-76) always
1136
+ * returns false (instanced shadows cull per instance group); presence
948
1137
  * satisfies the "ShadowCaster" duck contract. */
949
1138
  IsCastingShadow(..._args) {
950
1139
  return false;
951
1140
  }
952
1141
 
953
- /** Carbon EveChildInstancedMeshes::GetShadowBatches (cpp:78-80) is an
1142
+ /** Carbon EveChildInstancedMeshes::GetShadowBatches (cpp:78-80) is an
954
1143
  * intentional no-op (the instanced mesh manager emits the batches). */
955
1144
  GetShadowBatches(..._args) {}
956
1145
 
957
- /** Carbon EveChildInstancedMeshes::GetShadowPerObjectData (cpp:82-85)
1146
+ /** Carbon EveChildInstancedMeshes::GetShadowPerObjectData (cpp:82-85)
958
1147
  * returns null (per-object data flows through the mesh manager). */
959
1148
  GetShadowPerObjectData(..._args) {
960
1149
  return null;
961
1150
  }
962
1151
 
963
- /**
964
- * Resolves a mesh index against the list, throwing RangeError rather than
965
- * returning undefined so every public accessor fails loudly.
1152
+ /**
1153
+ * Resolves a mesh index against the list, throwing RangeError rather than
1154
+ * returning undefined so every public accessor fails loudly.
966
1155
  */
967
1156
 
968
- /**
969
- * Builds an area record from a plain duck, defaulting areaCount to 1 and
970
- * caching the effect hash the manager registers the mesh group under.
1157
+ /**
1158
+ * Builds an area record from a plain duck, defaulting areaCount to 1 and
1159
+ * caching the effect hash the manager registers the mesh group under.
971
1160
  */
972
1161
 
973
- /**
974
- * Deep-copies a mesh into a plain object for GetMeshData: instance transforms
975
- * cloned, areas spread-copied, the geometry resource shared by reference.
1162
+ /**
1163
+ * Deep-copies a mesh into a plain object for GetMeshData: instance transforms
1164
+ * cloned, areas spread-copied, the geometry resource shared by reference.
976
1165
  */
977
1166
 
978
- /**
979
- * Reads an owned effect's stable registration hash; null areas retain the
980
- * Carbon zero hash until their effect arrives.
1167
+ /**
1168
+ * Reads an owned effect's stable registration hash; null areas retain the
1169
+ * Carbon zero hash until their effect arrives.
981
1170
  */
982
1171
  }];
983
1172
  #inverseScratch = mat4.create();