rhodonite 0.27.1 → 0.28.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 (855) hide show
  1. package/README.md +10 -10
  2. package/VERSION-FILE +1 -1
  3. package/dist/esm/effekseer/EffekseerComponent.js +3 -3
  4. package/dist/esm/foundation/components/Camera/CameraComponent.js +1 -1
  5. package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +5 -5
  6. package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
  7. package/dist/esm/foundation/core/GlobalDataRepository.d.ts +3 -3
  8. package/dist/esm/foundation/core/GlobalDataRepository.js +1 -1
  9. package/dist/esm/foundation/definitions/RenderBackend.d.ts +21 -0
  10. package/dist/esm/foundation/definitions/RenderBackend.js +1 -0
  11. package/dist/esm/foundation/definitions/index.d.ts +1 -1
  12. package/dist/esm/foundation/definitions/index.js +1 -1
  13. package/dist/esm/foundation/geometry/Mesh.d.ts +18 -68
  14. package/dist/esm/foundation/geometry/Mesh.js +1 -1
  15. package/dist/esm/foundation/geometry/Primitive.d.ts +1 -1
  16. package/dist/esm/foundation/geometry/Primitive.js +1 -1
  17. package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
  18. package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
  19. package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
  20. package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
  21. package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
  22. package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
  23. package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
  24. package/dist/esm/foundation/helpers/Shadow/ShadowCasterFilter.d.ts +8 -0
  25. package/dist/esm/foundation/helpers/Shadow/ShadowCasterFilter.js +1 -0
  26. package/dist/esm/foundation/helpers/Shadow/ShadowDirectionalAutoFit.d.ts +28 -0
  27. package/dist/esm/foundation/helpers/Shadow/ShadowDirectionalAutoFit.js +1 -0
  28. package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
  29. package/dist/esm/foundation/helpers/Shadow/ShadowSpotLightZNear.d.ts +8 -0
  30. package/dist/esm/foundation/helpers/Shadow/ShadowSpotLightZNear.js +1 -0
  31. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.d.ts +1 -29
  32. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
  33. package/dist/esm/foundation/helpers/materials/nodeBasedMaterialCommon.js +1 -1
  34. package/dist/esm/foundation/materials/contents/ColorGradingUsingLUTsMaterialContent.d.ts +0 -20
  35. package/dist/esm/foundation/materials/contents/ColorGradingUsingLUTsMaterialContent.js +1 -1
  36. package/dist/esm/foundation/materials/contents/CustomMaterialContent.d.ts +3 -1
  37. package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
  38. package/dist/esm/foundation/materials/contents/DetectHighLuminanceMaterialContent.d.ts +0 -16
  39. package/dist/esm/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +1 -1
  40. package/dist/esm/foundation/materials/contents/EntityUIDOutputMaterialContent.d.ts +0 -17
  41. package/dist/esm/foundation/materials/contents/EntityUIDOutputMaterialContent.js +1 -1
  42. package/dist/esm/foundation/materials/contents/FurnaceTestMaterialContent.d.ts +0 -21
  43. package/dist/esm/foundation/materials/contents/FurnaceTestMaterialContent.js +1 -1
  44. package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +4 -4
  45. package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +3 -3
  46. package/dist/esm/foundation/materials/contents/MatCapMaterialContent.d.ts +0 -16
  47. package/dist/esm/foundation/materials/contents/MatCapMaterialContent.js +1 -1
  48. package/dist/esm/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +1 -1
  49. package/dist/esm/foundation/materials/contents/SynthesizeHdrMaterialContent.d.ts +0 -23
  50. package/dist/esm/foundation/materials/contents/SynthesizeHdrMaterialContent.js +1 -1
  51. package/dist/esm/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +1 -1
  52. package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +6 -61
  53. package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
  54. package/dist/esm/foundation/materials/core/AbstractShaderNode.d.ts +1 -1
  55. package/dist/esm/foundation/materials/core/AbstractShaderNode.js +2 -2
  56. package/dist/esm/foundation/materials/core/Material.d.ts +7 -114
  57. package/dist/esm/foundation/materials/core/Material.js +1 -1
  58. package/dist/esm/foundation/materials/core/MaterialRepository.js +1 -1
  59. package/dist/esm/foundation/materials/core/ShaderGraphResolver.js +6 -6
  60. package/dist/esm/foundation/materials/core/ShaderNodeFactories.d.ts +23 -0
  61. package/dist/esm/foundation/materials/core/ShaderNodeFactories.js +1 -0
  62. package/dist/esm/foundation/materials/core/ShaderProgramDefinitions.d.ts +41 -0
  63. package/dist/esm/foundation/materials/core/ShaderProgramDefinitions.js +23 -0
  64. package/dist/esm/foundation/materials/nodes/AbsShaderNode.js +1 -1
  65. package/dist/esm/foundation/materials/nodes/AcosShaderNode.js +1 -1
  66. package/dist/esm/foundation/materials/nodes/AddShaderNode.js +1 -1
  67. package/dist/esm/foundation/materials/nodes/Atan2ShaderNode.js +1 -1
  68. package/dist/esm/foundation/materials/nodes/BranchShaderNode.js +1 -1
  69. package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.d.ts +1 -1
  70. package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
  71. package/dist/esm/foundation/materials/nodes/ClampShaderNode.d.ts +1 -1
  72. package/dist/esm/foundation/materials/nodes/ClampShaderNode.js +1 -1
  73. package/dist/esm/foundation/materials/nodes/CosShaderNode.d.ts +1 -1
  74. package/dist/esm/foundation/materials/nodes/CosShaderNode.js +1 -1
  75. package/dist/esm/foundation/materials/nodes/DotProductShaderNode.d.ts +2 -2
  76. package/dist/esm/foundation/materials/nodes/DotProductShaderNode.js +1 -1
  77. package/dist/esm/foundation/materials/nodes/EqualShaderNode.d.ts +1 -1
  78. package/dist/esm/foundation/materials/nodes/EqualShaderNode.js +1 -1
  79. package/dist/esm/foundation/materials/nodes/GreaterOrEqualShaderNode.d.ts +1 -1
  80. package/dist/esm/foundation/materials/nodes/GreaterOrEqualShaderNode.js +1 -1
  81. package/dist/esm/foundation/materials/nodes/GreaterThanShaderNode.d.ts +1 -1
  82. package/dist/esm/foundation/materials/nodes/GreaterThanShaderNode.js +1 -1
  83. package/dist/esm/foundation/materials/nodes/LengthShaderNode.d.ts +1 -1
  84. package/dist/esm/foundation/materials/nodes/LengthShaderNode.js +1 -1
  85. package/dist/esm/foundation/materials/nodes/LessOrEqualShaderNode.d.ts +1 -1
  86. package/dist/esm/foundation/materials/nodes/LessOrEqualShaderNode.js +1 -1
  87. package/dist/esm/foundation/materials/nodes/LessThanShaderNode.d.ts +1 -1
  88. package/dist/esm/foundation/materials/nodes/LessThanShaderNode.js +1 -1
  89. package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
  90. package/dist/esm/foundation/materials/nodes/MinShaderNode.js +1 -1
  91. package/dist/esm/foundation/materials/nodes/MultiplyShaderNode.d.ts +1 -1
  92. package/dist/esm/foundation/materials/nodes/MultiplyShaderNode.js +1 -1
  93. package/dist/esm/foundation/materials/nodes/NormalizeShaderNode.d.ts +1 -1
  94. package/dist/esm/foundation/materials/nodes/NormalizeShaderNode.js +1 -1
  95. package/dist/esm/foundation/materials/nodes/NotEqualShaderNode.d.ts +1 -1
  96. package/dist/esm/foundation/materials/nodes/NotEqualShaderNode.js +1 -1
  97. package/dist/esm/foundation/materials/nodes/PremultipliedAlphaShaderNode.d.ts +1 -1
  98. package/dist/esm/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +1 -1
  99. package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +2 -2
  100. package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +2 -2
  101. package/dist/esm/foundation/materials/nodes/RemapShaderNode.d.ts +1 -1
  102. package/dist/esm/foundation/materials/nodes/RemapShaderNode.js +1 -1
  103. package/dist/esm/foundation/materials/nodes/SinShaderNode.d.ts +1 -1
  104. package/dist/esm/foundation/materials/nodes/SinShaderNode.js +1 -1
  105. package/dist/esm/foundation/materials/nodes/SmoothStepShaderNode.d.ts +1 -1
  106. package/dist/esm/foundation/materials/nodes/SmoothStepShaderNode.js +1 -1
  107. package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.d.ts +1 -1
  108. package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
  109. package/dist/esm/foundation/materials/nodes/StepShaderNode.js +1 -1
  110. package/dist/esm/foundation/materials/nodes/TanShaderNode.d.ts +1 -1
  111. package/dist/esm/foundation/materials/nodes/TanShaderNode.js +1 -1
  112. package/dist/esm/foundation/materials/nodes/TransformShaderNode.d.ts +1 -1
  113. package/dist/esm/foundation/materials/nodes/TransformShaderNode.js +1 -1
  114. package/dist/esm/foundation/math/MathClassUtil.js +1 -1
  115. package/dist/esm/foundation/math/MathUtil.d.ts +11 -0
  116. package/dist/esm/foundation/math/MathUtil.js +1 -1
  117. package/dist/esm/foundation/math/Transform3D.js +1 -1
  118. package/dist/esm/foundation/memory/Accessor.js +1 -1
  119. package/dist/esm/foundation/memory/Buffer.js +3 -3
  120. package/dist/esm/foundation/renderer/CGAPIResourceRepository.d.ts +74 -4
  121. package/dist/esm/foundation/renderer/CGAPIResourceRepository.js +1 -1
  122. package/dist/esm/foundation/renderer/FrameBuffer.js +1 -1
  123. package/dist/esm/foundation/renderer/FrameRenderer.d.ts +42 -0
  124. package/dist/esm/foundation/renderer/FrameRenderer.js +0 -0
  125. package/dist/esm/foundation/renderer/RenderPass.js +1 -1
  126. package/dist/esm/foundation/renderer/ShaderPropertyLayout.d.ts +77 -0
  127. package/dist/esm/foundation/renderer/ShaderPropertyLayout.js +1 -0
  128. package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +9 -3
  129. package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -1
  130. package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.js +1 -1
  131. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +4 -171
  132. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
  133. package/dist/esm/foundation/renderer/pipelines/RaymarchingRenderer.d.ts +263 -0
  134. package/dist/esm/foundation/renderer/pipelines/RaymarchingRenderer.js +1 -0
  135. package/dist/esm/foundation/system/Engine.d.ts +17 -28
  136. package/dist/esm/foundation/system/Engine.js +1 -1
  137. package/dist/esm/foundation/system/EngineState.d.ts +3 -3
  138. package/dist/esm/foundation/system/EngineState.js +1 -1
  139. package/dist/esm/foundation/textures/AbstractReadableRenderTargetTexture.d.ts +39 -0
  140. package/dist/esm/foundation/textures/AbstractReadableRenderTargetTexture.js +1 -0
  141. package/dist/esm/foundation/textures/AbstractRenderTargetTexture.d.ts +60 -0
  142. package/dist/esm/foundation/textures/AbstractRenderTargetTexture.js +1 -0
  143. package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
  144. package/dist/esm/foundation/textures/CubeTexture.js +1 -1
  145. package/dist/esm/foundation/textures/RenderBuffer.js +1 -1
  146. package/dist/esm/foundation/textures/RenderTargetTexture.d.ts +5 -67
  147. package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
  148. package/dist/esm/foundation/textures/RenderTargetTexture2DArray.d.ts +5 -71
  149. package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
  150. package/dist/esm/foundation/textures/RenderTargetTextureCube.d.ts +8 -50
  151. package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
  152. package/dist/esm/foundation/textures/Texture.d.ts +19 -1
  153. package/dist/esm/foundation/textures/Texture.js +1 -1
  154. package/dist/esm/foundation/textures/TextureArray.js +1 -1
  155. package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
  156. package/dist/esm/foundation/textures/VideoTexture.d.ts +11 -0
  157. package/dist/esm/foundation/textures/VideoTexture.js +1 -1
  158. package/dist/esm/foundation/textures/decodeBasisImage.d.ts +14 -0
  159. package/dist/esm/foundation/textures/decodeBasisImage.js +1 -0
  160. package/dist/esm/foundation/textures/index.d.ts +2 -0
  161. package/dist/esm/foundation/textures/index.js +1 -1
  162. package/dist/esm/version.js +1 -1
  163. package/dist/esm/webgl/ComponentDataAccessorGLSL.d.ts +9 -0
  164. package/dist/esm/webgl/ComponentDataAccessorGLSL.js +27 -0
  165. package/dist/esm/webgl/MultiDraw.d.ts +1 -1
  166. package/dist/esm/webgl/MultiDraw.js +1 -1
  167. package/dist/esm/webgl/MultiDrawRepository.js +1 -1
  168. package/dist/esm/webgl/ShaderPropertyAccessorGLSL.d.ts +11 -0
  169. package/dist/esm/webgl/ShaderPropertyAccessorGLSL.js +29 -0
  170. package/dist/esm/webgl/WebGLCompressedTextures.d.ts +48 -0
  171. package/dist/esm/webgl/WebGLCompressedTextures.js +1 -0
  172. package/dist/esm/webgl/WebGLContextWrapper.d.ts +9 -52
  173. package/dist/esm/webgl/WebGLContextWrapper.js +1 -1
  174. package/dist/esm/webgl/WebGLCubeTextureFileLoader.d.ts +38 -0
  175. package/dist/esm/webgl/WebGLCubeTextureFileLoader.js +1 -0
  176. package/dist/esm/webgl/WebGLCubeTextures.d.ts +92 -0
  177. package/dist/esm/webgl/WebGLCubeTextures.js +42 -0
  178. package/dist/esm/webgl/WebGLDataTexture.d.ts +108 -0
  179. package/dist/esm/webgl/WebGLDataTexture.js +1 -0
  180. package/dist/esm/webgl/WebGLDrawState.d.ts +84 -0
  181. package/dist/esm/webgl/WebGLDrawState.js +1 -0
  182. package/dist/esm/webgl/WebGLExternalState.d.ts +43 -0
  183. package/dist/esm/webgl/WebGLExternalState.js +1 -0
  184. package/dist/esm/webgl/WebGLFrameRenderer.d.ts +32 -0
  185. package/dist/esm/webgl/WebGLFrameRenderer.js +1 -0
  186. package/dist/esm/webgl/WebGLFramebuffers.d.ts +142 -0
  187. package/dist/esm/webgl/WebGLFramebuffers.js +1 -0
  188. package/dist/esm/webgl/WebGLGpuTimer.js +1 -1
  189. package/dist/esm/webgl/WebGLMaterialParameters.d.ts +47 -0
  190. package/dist/esm/webgl/WebGLMaterialParameters.js +1 -0
  191. package/dist/esm/webgl/WebGLMeshResources.d.ts +115 -0
  192. package/dist/esm/webgl/WebGLMeshResources.js +1 -0
  193. package/dist/esm/webgl/WebGLMorphUniformBuffers.d.ts +66 -0
  194. package/dist/esm/webgl/WebGLMorphUniformBuffers.js +57 -0
  195. package/dist/esm/webgl/WebGLResourceRepository.d.ts +100 -178
  196. package/dist/esm/webgl/WebGLResourceRepository.js +1 -55
  197. package/dist/esm/webgl/WebGLSamplers.d.ts +78 -0
  198. package/dist/esm/webgl/WebGLSamplers.js +1 -0
  199. package/dist/esm/webgl/WebGLShaderProgramBuilder.d.ts +40 -0
  200. package/dist/esm/webgl/WebGLShaderProgramBuilder.js +15 -0
  201. package/dist/esm/webgl/WebGLShaderPrograms.d.ts +88 -0
  202. package/dist/esm/webgl/WebGLShaderPrograms.js +14 -0
  203. package/dist/esm/webgl/WebGLStereoUtil.d.ts +0 -27
  204. package/dist/esm/webgl/WebGLStereoUtil.js +3 -3
  205. package/dist/esm/webgl/WebGLStrategyDataUploader.d.ts +152 -0
  206. package/dist/esm/webgl/WebGLStrategyDataUploader.js +1 -0
  207. package/dist/esm/webgl/WebGLStrategyMeshBatchRenderer.d.ts +40 -0
  208. package/dist/esm/webgl/WebGLStrategyMeshBatchRenderer.js +1 -0
  209. package/dist/esm/webgl/WebGLStrategyMeshDrawer.d.ts +92 -0
  210. package/dist/esm/webgl/WebGLStrategyMeshDrawer.js +1 -0
  211. package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +7 -360
  212. package/dist/esm/webgl/WebGLStrategyWebGL2.js +1 -146
  213. package/dist/esm/webgl/WebGLTextureUnitState.d.ts +79 -0
  214. package/dist/esm/webgl/WebGLTextureUnitState.js +1 -0
  215. package/dist/esm/webgl/WebGLTextureUploads.d.ts +106 -0
  216. package/dist/esm/webgl/WebGLTextureUploads.js +1 -0
  217. package/dist/esm/webgl/WebGLTextures.d.ts +316 -0
  218. package/dist/esm/webgl/WebGLTextures.js +1 -0
  219. package/dist/esm/webgl/WebGLUniformBuffers.d.ts +35 -0
  220. package/dist/esm/webgl/WebGLUniformBuffers.js +1 -0
  221. package/dist/esm/webgl/WebGLUniforms.d.ts +117 -0
  222. package/dist/esm/webgl/WebGLUniforms.js +1 -0
  223. package/dist/esm/webgl/WebGLVertexBuffers.d.ts +172 -0
  224. package/dist/esm/webgl/WebGLVertexBuffers.js +1 -0
  225. package/dist/esm/webgl/debug/BufferLayoutDecoder.d.ts +4 -4
  226. package/dist/esm/webgl/debug/BufferLayoutDecoder.js +1 -1
  227. package/dist/esm/webgl/debug/ShaderParameterDebugger.js +1 -1
  228. package/dist/esm/webgl/debug/types.d.ts +2 -2
  229. package/dist/esm/webgl/getRenderingStrategy.d.ts +2 -2
  230. package/dist/esm/webgl/getRenderingStrategy.js +1 -1
  231. package/dist/esm/webgl/main.d.ts +4 -17
  232. package/dist/esm/webgl/main.js +1 -1
  233. package/dist/esm/webgl/readColorAttachmentAsRgba8.d.ts +36 -0
  234. package/dist/esm/webgl/readColorAttachmentAsRgba8.js +1 -0
  235. package/dist/esm/webgl/shaders/RaymarchingShaderPart.d.ts +2 -2
  236. package/dist/esm/webgl/shaders/RaymarchingShaderPart.js +9 -9
  237. package/dist/esm/webgl/shaders/RaymarchingShadowShaderPart.js +9 -9
  238. package/dist/esm/webgl/shaders/StandardShaderPart.d.ts +3 -3
  239. package/dist/esm/webgl/shaders/StandardShaderPart.js +16 -16
  240. package/dist/esm/webgl/shaders/glslCommonChunks.d.ts +2 -2
  241. package/dist/esm/webgl/shaders/nodes/BlockBeginShader.js +1 -1
  242. package/dist/esm/webgl/shaders/nodes/BlockEndShader.js +1 -1
  243. package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.d.ts +2 -2
  244. package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +7 -7
  245. package/dist/esm/webgl/shaders/nodes/DiscardShader.d.ts +1 -1
  246. package/dist/esm/webgl/shaders/nodes/DiscardShader.js +3 -3
  247. package/dist/esm/webgl/shaders/nodes/EndShader.d.ts +2 -2
  248. package/dist/esm/webgl/shaders/nodes/EndShader.js +3 -3
  249. package/dist/esm/webgl/shaders/nodes/OutDistance.d.ts +1 -1
  250. package/dist/esm/webgl/shaders/nodes/OutDistance.js +1 -1
  251. package/dist/esm/webgl/shaders/nodes/OutUnion.js +1 -1
  252. package/dist/esm/webgl/shaders/nodes/RaymarchObjectIdUniform.js +3 -3
  253. package/dist/esm/webgl/shaders/nodes/SdApplyTransform.js +1 -1
  254. package/dist/esm/webgl/shaders/nodes/SdApplyWorldMatrix.d.ts +1 -1
  255. package/dist/esm/webgl/shaders/nodes/SdApplyWorldMatrix.js +3 -3
  256. package/dist/esm/webgl/shaders/nodes/Texture2DShader.js +18 -18
  257. package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +14 -14
  258. package/dist/esm/webgl/textureLoader/KTX2TextureLoader.d.ts +1 -1
  259. package/dist/esm/webgl/textureLoader/KTX2TextureLoader.js +1 -1
  260. package/dist/esm/webgpu/AttributeReader.d.ts +18 -0
  261. package/dist/esm/webgpu/AttributeReader.js +1 -0
  262. package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
  263. package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
  264. package/dist/esm/webgpu/RangeAllocator.js +1 -1
  265. package/dist/esm/webgpu/ShaderPropertyAccessorWGSL.d.ts +11 -0
  266. package/dist/esm/webgpu/ShaderPropertyAccessorWGSL.js +24 -0
  267. package/dist/esm/webgpu/WebGpuBindGroups.d.ts +131 -0
  268. package/dist/esm/webgpu/WebGpuBindGroups.js +1 -0
  269. package/dist/esm/webgpu/WebGpuBufferArena.js +1 -1
  270. package/dist/esm/webgpu/WebGpuCompressedTextures.d.ts +38 -0
  271. package/dist/esm/webgpu/WebGpuCompressedTextures.js +1 -0
  272. package/dist/esm/webgpu/WebGpuCubeTextureShaders.d.ts +1 -0
  273. package/dist/esm/webgpu/WebGpuCubeTextureShaders.js +60 -0
  274. package/dist/esm/webgpu/WebGpuCubeTextures.d.ts +72 -0
  275. package/dist/esm/webgpu/WebGpuCubeTextures.js +1 -0
  276. package/dist/esm/webgpu/WebGpuDraw.d.ts +63 -0
  277. package/dist/esm/webgpu/WebGpuDraw.js +1 -0
  278. package/dist/esm/webgpu/WebGpuDrawParameters.d.ts +61 -0
  279. package/dist/esm/webgpu/WebGpuDrawParameters.js +1 -0
  280. package/dist/esm/webgpu/WebGpuExternalRenderPass.d.ts +44 -0
  281. package/dist/esm/webgpu/WebGpuExternalRenderPass.js +1 -0
  282. package/dist/esm/webgpu/WebGpuFrame.d.ts +55 -0
  283. package/dist/esm/webgpu/WebGpuFrame.js +1 -0
  284. package/dist/esm/webgpu/WebGpuFrameRenderer.d.ts +25 -0
  285. package/dist/esm/webgpu/WebGpuFrameRenderer.js +1 -0
  286. package/dist/esm/webgpu/WebGpuGpuCulling.js +1 -236
  287. package/dist/esm/webgpu/WebGpuGpuCullingShaders.d.ts +34 -0
  288. package/dist/esm/webgpu/WebGpuGpuCullingShaders.js +236 -0
  289. package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
  290. package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -153
  291. package/dist/esm/webgpu/WebGpuLightClusterShaders.d.ts +14 -0
  292. package/dist/esm/webgpu/WebGpuLightClusterShaders.js +153 -0
  293. package/dist/esm/webgpu/WebGpuMipmapGenerator.d.ts +54 -0
  294. package/dist/esm/webgpu/WebGpuMipmapGenerator.js +1 -0
  295. package/dist/esm/webgpu/WebGpuMipmapShaders.d.ts +1 -0
  296. package/dist/esm/webgpu/WebGpuMipmapShaders.js +26 -0
  297. package/dist/esm/webgpu/WebGpuRenderBundles.d.ts +117 -0
  298. package/dist/esm/webgpu/WebGpuRenderBundles.js +1 -0
  299. package/dist/esm/webgpu/WebGpuRenderPassEncoders.d.ts +140 -0
  300. package/dist/esm/webgpu/WebGpuRenderPassEncoders.js +1 -0
  301. package/dist/esm/webgpu/WebGpuRenderPipelines.d.ts +75 -0
  302. package/dist/esm/webgpu/WebGpuRenderPipelines.js +3 -0
  303. package/dist/esm/webgpu/WebGpuRenderTargetTextures.d.ts +78 -0
  304. package/dist/esm/webgpu/WebGpuRenderTargetTextures.js +1 -0
  305. package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +52 -322
  306. package/dist/esm/webgpu/WebGpuResourceRepository.js +1 -116
  307. package/dist/esm/webgpu/WebGpuSamplers.d.ts +45 -0
  308. package/dist/esm/webgpu/WebGpuSamplers.js +1 -0
  309. package/dist/esm/webgpu/WebGpuShaderProgramBuilder.d.ts +25 -0
  310. package/dist/esm/webgpu/WebGpuShaderProgramBuilder.js +9 -0
  311. package/dist/esm/webgpu/WebGpuStorageBuffers.d.ts +77 -0
  312. package/dist/esm/webgpu/WebGpuStorageBuffers.js +1 -0
  313. package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +1 -73
  314. package/dist/esm/webgpu/WebGpuStrategyBasic.js +1 -139
  315. package/dist/esm/webgpu/WebGpuStrategyStorage.d.ts +62 -0
  316. package/dist/esm/webgpu/WebGpuStrategyStorage.js +1 -0
  317. package/dist/esm/webgpu/WebGpuTextureReadback.d.ts +111 -0
  318. package/dist/esm/webgpu/WebGpuTextureReadback.js +1 -0
  319. package/dist/esm/webgpu/WebGpuTextureReadbackShaders.d.ts +4 -0
  320. package/dist/esm/webgpu/WebGpuTextureReadbackShaders.js +26 -0
  321. package/dist/esm/webgpu/WebGpuTextureUploads.d.ts +109 -0
  322. package/dist/esm/webgpu/WebGpuTextureUploads.js +1 -0
  323. package/dist/esm/webgpu/WebGpuTextures.d.ts +196 -0
  324. package/dist/esm/webgpu/WebGpuTextures.js +1 -0
  325. package/dist/esm/webgpu/WebGpuVertexBuffers.d.ts +142 -0
  326. package/dist/esm/webgpu/WebGpuVertexBuffers.js +1 -0
  327. package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -124
  328. package/dist/esm/webgpu/WebGpuVertexDeformerShaders.d.ts +7 -0
  329. package/dist/esm/webgpu/WebGpuVertexDeformerShaders.js +124 -0
  330. package/dist/esm/webgpu/WebGpuVertexShaderDefinitions.d.ts +16 -0
  331. package/dist/esm/webgpu/WebGpuVertexShaderDefinitions.js +84 -0
  332. package/dist/esm/webgpu/assertArrayBufferView.d.ts +9 -0
  333. package/dist/esm/webgpu/assertArrayBufferView.js +1 -0
  334. package/dist/esm/webgpu/main.d.ts +2 -16
  335. package/dist/esm/webgpu/main.js +1 -1
  336. package/dist/esm/webgpu/padCompressedRowsForUpload.d.ts +20 -0
  337. package/dist/esm/webgpu/padCompressedRowsForUpload.js +1 -0
  338. package/dist/esm/webgpu/removeRowPadding.d.ts +21 -0
  339. package/dist/esm/webgpu/removeRowPadding.js +1 -0
  340. package/dist/esm/webgpu/shaderity_shaders/common/processGeometry.wgsl.js +1 -1
  341. package/dist/esm/webgpu/wgslCommonChunks.d.ts +2 -2
  342. package/dist/esm/xr/WebARSystem.js +1 -1
  343. package/dist/esm/xr/WebXRSystem.d.ts +0 -4
  344. package/dist/esm/xr/WebXRSystem.js +1 -1
  345. package/dist/esmdev/effekseer/EffekseerComponent.js +3 -3
  346. package/dist/esmdev/foundation/components/Camera/CameraComponent.js +4 -4
  347. package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +5 -5
  348. package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +11 -11
  349. package/dist/esmdev/foundation/core/GlobalDataRepository.d.ts +3 -3
  350. package/dist/esmdev/foundation/core/GlobalDataRepository.js +3 -3
  351. package/dist/esmdev/foundation/definitions/RenderBackend.d.ts +21 -0
  352. package/dist/esmdev/foundation/definitions/RenderBackend.js +60 -0
  353. package/dist/esmdev/foundation/definitions/index.d.ts +1 -1
  354. package/dist/esmdev/foundation/definitions/index.js +2 -2
  355. package/dist/esmdev/foundation/geometry/Mesh.d.ts +18 -68
  356. package/dist/esmdev/foundation/geometry/Mesh.js +159 -383
  357. package/dist/esmdev/foundation/geometry/Primitive.d.ts +1 -1
  358. package/dist/esmdev/foundation/geometry/Primitive.js +123 -123
  359. package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +5 -5
  360. package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
  361. package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
  362. package/dist/esmdev/foundation/gizmos/AABBGizmo.js +12 -12
  363. package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +23 -23
  364. package/dist/esmdev/foundation/gizmos/Gizmo.js +23 -23
  365. package/dist/esmdev/foundation/gizmos/JointGizmo.js +37 -37
  366. package/dist/esmdev/foundation/gizmos/LightGizmo.js +69 -69
  367. package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +22 -22
  368. package/dist/esmdev/foundation/gizmos/RotationGizmo.js +212 -212
  369. package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +130 -130
  370. package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +43 -43
  371. package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +24 -24
  372. package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +129 -129
  373. package/dist/esmdev/foundation/helpers/BloomHelper.js +34 -34
  374. package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
  375. package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
  376. package/dist/esmdev/foundation/helpers/Shadow/ShadowCasterFilter.d.ts +8 -0
  377. package/dist/esmdev/foundation/helpers/Shadow/ShadowCasterFilter.js +17 -0
  378. package/dist/esmdev/foundation/helpers/Shadow/ShadowDirectionalAutoFit.d.ts +28 -0
  379. package/dist/esmdev/foundation/helpers/Shadow/ShadowDirectionalAutoFit.js +126 -0
  380. package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +3 -3
  381. package/dist/esmdev/foundation/helpers/Shadow/ShadowSpotLightZNear.d.ts +8 -0
  382. package/dist/esmdev/foundation/helpers/Shadow/ShadowSpotLightZNear.js +87 -0
  383. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.d.ts +1 -29
  384. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +76 -285
  385. package/dist/esmdev/foundation/helpers/materials/nodeBasedMaterialCommon.js +3 -3
  386. package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
  387. package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +30 -30
  388. package/dist/esmdev/foundation/importer/Gltf2Importer.js +14 -14
  389. package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
  390. package/dist/esmdev/foundation/importer/ModelConverter.js +137 -137
  391. package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
  392. package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
  393. package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
  394. package/dist/esmdev/foundation/materials/contents/ColorGradingUsingLUTsMaterialContent.d.ts +0 -20
  395. package/dist/esmdev/foundation/materials/contents/ColorGradingUsingLUTsMaterialContent.js +1 -33
  396. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.d.ts +3 -1
  397. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +31 -30
  398. package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +2 -2
  399. package/dist/esmdev/foundation/materials/contents/DetectHighLuminanceMaterialContent.d.ts +0 -16
  400. package/dist/esmdev/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +3 -19
  401. package/dist/esmdev/foundation/materials/contents/EntityUIDOutputMaterialContent.d.ts +0 -17
  402. package/dist/esmdev/foundation/materials/contents/EntityUIDOutputMaterialContent.js +1 -17
  403. package/dist/esmdev/foundation/materials/contents/FurnaceTestMaterialContent.d.ts +0 -21
  404. package/dist/esmdev/foundation/materials/contents/FurnaceTestMaterialContent.js +1 -21
  405. package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +142 -143
  406. package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +21 -22
  407. package/dist/esmdev/foundation/materials/contents/MatCapMaterialContent.d.ts +0 -16
  408. package/dist/esmdev/foundation/materials/contents/MatCapMaterialContent.js +1 -17
  409. package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +7 -8
  410. package/dist/esmdev/foundation/materials/contents/SynthesizeHdrMaterialContent.d.ts +0 -23
  411. package/dist/esmdev/foundation/materials/contents/SynthesizeHdrMaterialContent.js +3 -29
  412. package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +7 -8
  413. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +6 -61
  414. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +61 -153
  415. package/dist/esmdev/foundation/materials/core/AbstractShaderNode.d.ts +1 -1
  416. package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +31 -31
  417. package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
  418. package/dist/esmdev/foundation/materials/core/Material.d.ts +7 -114
  419. package/dist/esmdev/foundation/materials/core/Material.js +100 -348
  420. package/dist/esmdev/foundation/materials/core/MaterialRepository.js +55 -55
  421. package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +46 -1399
  422. package/dist/esmdev/foundation/materials/core/ShaderNodeFactories.d.ts +23 -0
  423. package/dist/esmdev/foundation/materials/core/ShaderNodeFactories.js +609 -0
  424. package/dist/esmdev/foundation/materials/core/ShaderProgramDefinitions.d.ts +41 -0
  425. package/dist/esmdev/foundation/materials/core/ShaderProgramDefinitions.js +95 -0
  426. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +14 -14
  427. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +15 -15
  428. package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +16 -16
  429. package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +16 -16
  430. package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +21 -21
  431. package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
  432. package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
  433. package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +18 -18
  434. package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
  435. package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
  436. package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
  437. package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
  438. package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
  439. package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
  440. package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
  441. package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
  442. package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
  443. package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
  444. package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +18 -18
  445. package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
  446. package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.d.ts +1 -1
  447. package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +17 -17
  448. package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.d.ts +1 -1
  449. package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +19 -19
  450. package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
  451. package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
  452. package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
  453. package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
  454. package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
  455. package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
  456. package/dist/esmdev/foundation/materials/nodes/CosShaderNode.d.ts +1 -1
  457. package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +17 -17
  458. package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
  459. package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.d.ts +2 -2
  460. package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +15 -15
  461. package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.d.ts +1 -1
  462. package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +14 -14
  463. package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
  464. package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.d.ts +1 -1
  465. package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +14 -14
  466. package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
  467. package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.d.ts +1 -1
  468. package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +14 -14
  469. package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.d.ts +1 -1
  470. package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +17 -17
  471. package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.d.ts +1 -1
  472. package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +14 -14
  473. package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.d.ts +1 -1
  474. package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +14 -14
  475. package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +23 -23
  476. package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +21 -21
  477. package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.d.ts +1 -1
  478. package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +25 -25
  479. package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
  480. package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.d.ts +1 -1
  481. package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +13 -13
  482. package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.d.ts +1 -1
  483. package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +14 -14
  484. package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
  485. package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
  486. package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
  487. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
  488. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
  489. package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
  490. package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
  491. package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
  492. package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
  493. package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
  494. package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
  495. package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
  496. package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
  497. package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
  498. package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
  499. package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
  500. package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
  501. package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
  502. package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.d.ts +1 -1
  503. package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +8 -8
  504. package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
  505. package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
  506. package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +15 -15
  507. package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +15 -15
  508. package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.d.ts +1 -1
  509. package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +21 -21
  510. package/dist/esmdev/foundation/materials/nodes/SinShaderNode.d.ts +1 -1
  511. package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +17 -17
  512. package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.d.ts +1 -1
  513. package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +19 -19
  514. package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.d.ts +1 -1
  515. package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +22 -22
  516. package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +17 -17
  517. package/dist/esmdev/foundation/materials/nodes/TanShaderNode.d.ts +1 -1
  518. package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +17 -17
  519. package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
  520. package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
  521. package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.d.ts +1 -1
  522. package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +14 -14
  523. package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
  524. package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
  525. package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
  526. package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
  527. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
  528. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
  529. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
  530. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
  531. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
  532. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
  533. package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
  534. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
  535. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
  536. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
  537. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
  538. package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
  539. package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
  540. package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
  541. package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
  542. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
  543. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
  544. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
  545. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
  546. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
  547. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
  548. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
  549. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
  550. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
  551. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
  552. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
  553. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
  554. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
  555. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
  556. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
  557. package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
  558. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
  559. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
  560. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
  561. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
  562. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
  563. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
  564. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
  565. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
  566. package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
  567. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
  568. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
  569. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
  570. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
  571. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
  572. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
  573. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
  574. package/dist/esmdev/foundation/math/AABB.js +132 -132
  575. package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
  576. package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
  577. package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
  578. package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
  579. package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
  580. package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
  581. package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
  582. package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
  583. package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
  584. package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
  585. package/dist/esmdev/foundation/math/MathUtil.d.ts +11 -0
  586. package/dist/esmdev/foundation/math/MathUtil.js +5 -1
  587. package/dist/esmdev/foundation/math/Quaternion.js +14 -14
  588. package/dist/esmdev/foundation/math/Transform3D.js +74 -74
  589. package/dist/esmdev/foundation/math/shapes/MathSphere.js +7 -7
  590. package/dist/esmdev/foundation/memory/Accessor.js +359 -359
  591. package/dist/esmdev/foundation/memory/Buffer.js +34 -34
  592. package/dist/esmdev/foundation/memory/BufferView.js +26 -26
  593. package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
  594. package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
  595. package/dist/esmdev/foundation/misc/Logger.js +14 -14
  596. package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
  597. package/dist/esmdev/foundation/misc/Time.js +27 -27
  598. package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
  599. package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
  600. package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
  601. package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +10 -10
  602. package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +190 -190
  603. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +225 -225
  604. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
  605. package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +36 -36
  606. package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +26 -26
  607. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +6 -6
  608. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +56 -56
  609. package/dist/esmdev/foundation/renderer/CGAPIResourceRepository.d.ts +74 -4
  610. package/dist/esmdev/foundation/renderer/CGAPIResourceRepository.js +4 -4
  611. package/dist/esmdev/foundation/renderer/Expression.js +6 -6
  612. package/dist/esmdev/foundation/renderer/Frame.js +7 -7
  613. package/dist/esmdev/foundation/renderer/FrameBuffer.js +28 -28
  614. package/dist/esmdev/foundation/renderer/FrameRenderer.d.ts +42 -0
  615. package/dist/esmdev/foundation/renderer/FrameRenderer.js +1 -0
  616. package/dist/esmdev/foundation/renderer/RenderPass.js +94 -94
  617. package/dist/esmdev/foundation/renderer/ShaderPropertyLayout.d.ts +77 -0
  618. package/dist/esmdev/foundation/renderer/ShaderPropertyLayout.js +61 -0
  619. package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +6 -6
  620. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +9 -3
  621. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +97 -83
  622. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +162 -162
  623. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
  624. package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +4 -4
  625. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +4 -171
  626. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +335 -1127
  627. package/dist/esmdev/foundation/renderer/pipelines/RaymarchingRenderer.d.ts +263 -0
  628. package/dist/esmdev/foundation/renderer/pipelines/RaymarchingRenderer.js +858 -0
  629. package/dist/esmdev/foundation/system/Engine.d.ts +17 -28
  630. package/dist/esmdev/foundation/system/Engine.js +207 -574
  631. package/dist/esmdev/foundation/system/EngineState.d.ts +3 -3
  632. package/dist/esmdev/foundation/system/EngineState.js +4 -4
  633. package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
  634. package/dist/esmdev/foundation/system/InputManager.js +56 -56
  635. package/dist/esmdev/foundation/system/ModuleManager.js +3 -3
  636. package/dist/esmdev/foundation/textures/AbstractReadableRenderTargetTexture.d.ts +39 -0
  637. package/dist/esmdev/foundation/textures/AbstractReadableRenderTargetTexture.js +88 -0
  638. package/dist/esmdev/foundation/textures/AbstractRenderTargetTexture.d.ts +60 -0
  639. package/dist/esmdev/foundation/textures/AbstractRenderTargetTexture.js +59 -0
  640. package/dist/esmdev/foundation/textures/AbstractTexture.js +49 -49
  641. package/dist/esmdev/foundation/textures/CubeTexture.js +35 -42
  642. package/dist/esmdev/foundation/textures/RenderBuffer.js +16 -17
  643. package/dist/esmdev/foundation/textures/RenderTargetTexture.d.ts +5 -67
  644. package/dist/esmdev/foundation/textures/RenderTargetTexture.js +18 -140
  645. package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.d.ts +5 -71
  646. package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +34 -177
  647. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.d.ts +8 -50
  648. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +31 -88
  649. package/dist/esmdev/foundation/textures/Sampler.js +24 -24
  650. package/dist/esmdev/foundation/textures/Texture.d.ts +19 -1
  651. package/dist/esmdev/foundation/textures/Texture.js +133 -146
  652. package/dist/esmdev/foundation/textures/TextureArray.js +13 -16
  653. package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
  654. package/dist/esmdev/foundation/textures/VideoTexture.d.ts +11 -0
  655. package/dist/esmdev/foundation/textures/VideoTexture.js +47 -46
  656. package/dist/esmdev/foundation/textures/decodeBasisImage.d.ts +14 -0
  657. package/dist/esmdev/foundation/textures/decodeBasisImage.js +14 -0
  658. package/dist/esmdev/foundation/textures/index.d.ts +2 -0
  659. package/dist/esmdev/foundation/textures/index.js +3 -1
  660. package/dist/esmdev/version.js +2 -2
  661. package/dist/esmdev/webgl/ComponentDataAccessorGLSL.d.ts +9 -0
  662. package/dist/esmdev/webgl/ComponentDataAccessorGLSL.js +146 -0
  663. package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
  664. package/dist/esmdev/webgl/MultiDraw.d.ts +1 -1
  665. package/dist/esmdev/webgl/MultiDraw.js +4 -4
  666. package/dist/esmdev/webgl/MultiDrawRepository.js +34 -34
  667. package/dist/esmdev/webgl/ShaderPropertyAccessorGLSL.d.ts +11 -0
  668. package/dist/esmdev/webgl/ShaderPropertyAccessorGLSL.js +142 -0
  669. package/dist/esmdev/webgl/WebGLCompressedTextures.d.ts +48 -0
  670. package/dist/esmdev/webgl/WebGLCompressedTextures.js +105 -0
  671. package/dist/esmdev/webgl/WebGLContextWrapper.d.ts +9 -52
  672. package/dist/esmdev/webgl/WebGLContextWrapper.js +128 -230
  673. package/dist/esmdev/webgl/WebGLCubeTextureFileLoader.d.ts +38 -0
  674. package/dist/esmdev/webgl/WebGLCubeTextureFileLoader.js +178 -0
  675. package/dist/esmdev/webgl/WebGLCubeTextures.d.ts +92 -0
  676. package/dist/esmdev/webgl/WebGLCubeTextures.js +358 -0
  677. package/dist/esmdev/webgl/WebGLDataTexture.d.ts +108 -0
  678. package/dist/esmdev/webgl/WebGLDataTexture.js +337 -0
  679. package/dist/esmdev/webgl/WebGLDrawState.d.ts +84 -0
  680. package/dist/esmdev/webgl/WebGLDrawState.js +164 -0
  681. package/dist/esmdev/webgl/WebGLExternalState.d.ts +43 -0
  682. package/dist/esmdev/webgl/WebGLExternalState.js +70 -0
  683. package/dist/esmdev/webgl/WebGLFrameRenderer.d.ts +32 -0
  684. package/dist/esmdev/webgl/WebGLFrameRenderer.js +155 -0
  685. package/dist/esmdev/webgl/WebGLFramebuffers.d.ts +142 -0
  686. package/dist/esmdev/webgl/WebGLFramebuffers.js +245 -0
  687. package/dist/esmdev/webgl/WebGLGpuTimer.js +30 -30
  688. package/dist/esmdev/webgl/WebGLMaterialParameters.d.ts +47 -0
  689. package/dist/esmdev/webgl/WebGLMaterialParameters.js +81 -0
  690. package/dist/esmdev/webgl/WebGLMeshResources.d.ts +115 -0
  691. package/dist/esmdev/webgl/WebGLMeshResources.js +303 -0
  692. package/dist/esmdev/webgl/WebGLMorphUniformBuffers.d.ts +66 -0
  693. package/dist/esmdev/webgl/WebGLMorphUniformBuffers.js +272 -0
  694. package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +100 -178
  695. package/dist/esmdev/webgl/WebGLResourceRepository.js +345 -2596
  696. package/dist/esmdev/webgl/WebGLSamplers.d.ts +78 -0
  697. package/dist/esmdev/webgl/WebGLSamplers.js +143 -0
  698. package/dist/esmdev/webgl/WebGLShaderProgramBuilder.d.ts +40 -0
  699. package/dist/esmdev/webgl/WebGLShaderProgramBuilder.js +208 -0
  700. package/dist/esmdev/webgl/WebGLShaderPrograms.d.ts +88 -0
  701. package/dist/esmdev/webgl/WebGLShaderPrograms.js +240 -0
  702. package/dist/esmdev/webgl/WebGLStereoUtil.d.ts +0 -27
  703. package/dist/esmdev/webgl/WebGLStereoUtil.js +33 -112
  704. package/dist/esmdev/webgl/WebGLStrategyDataUploader.d.ts +152 -0
  705. package/dist/esmdev/webgl/WebGLStrategyDataUploader.js +370 -0
  706. package/dist/esmdev/webgl/WebGLStrategyMeshBatchRenderer.d.ts +40 -0
  707. package/dist/esmdev/webgl/WebGLStrategyMeshBatchRenderer.js +213 -0
  708. package/dist/esmdev/webgl/WebGLStrategyMeshDrawer.d.ts +92 -0
  709. package/dist/esmdev/webgl/WebGLStrategyMeshDrawer.js +300 -0
  710. package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +7 -360
  711. package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +75 -1863
  712. package/dist/esmdev/webgl/WebGLTextureUnitState.d.ts +79 -0
  713. package/dist/esmdev/webgl/WebGLTextureUnitState.js +149 -0
  714. package/dist/esmdev/webgl/WebGLTextureUploads.d.ts +106 -0
  715. package/dist/esmdev/webgl/WebGLTextureUploads.js +168 -0
  716. package/dist/esmdev/webgl/WebGLTextures.d.ts +316 -0
  717. package/dist/esmdev/webgl/WebGLTextures.js +577 -0
  718. package/dist/esmdev/webgl/WebGLUniformBuffers.d.ts +35 -0
  719. package/dist/esmdev/webgl/WebGLUniformBuffers.js +89 -0
  720. package/dist/esmdev/webgl/WebGLUniforms.d.ts +117 -0
  721. package/dist/esmdev/webgl/WebGLUniforms.js +283 -0
  722. package/dist/esmdev/webgl/WebGLVertexBuffers.d.ts +172 -0
  723. package/dist/esmdev/webgl/WebGLVertexBuffers.js +391 -0
  724. package/dist/esmdev/webgl/debug/BufferLayoutDecoder.d.ts +4 -4
  725. package/dist/esmdev/webgl/debug/BufferLayoutDecoder.js +52 -59
  726. package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +17 -17
  727. package/dist/esmdev/webgl/debug/types.d.ts +2 -2
  728. package/dist/esmdev/webgl/getRenderingStrategy.d.ts +2 -2
  729. package/dist/esmdev/webgl/getRenderingStrategy.js +5 -5
  730. package/dist/esmdev/webgl/main.d.ts +4 -17
  731. package/dist/esmdev/webgl/main.js +5 -3
  732. package/dist/esmdev/webgl/readColorAttachmentAsRgba8.d.ts +36 -0
  733. package/dist/esmdev/webgl/readColorAttachmentAsRgba8.js +47 -0
  734. package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.d.ts +2 -2
  735. package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +15 -15
  736. package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +17 -17
  737. package/dist/esmdev/webgl/shaders/StandardShaderPart.d.ts +3 -3
  738. package/dist/esmdev/webgl/shaders/StandardShaderPart.js +15 -15
  739. package/dist/esmdev/webgl/shaders/glslCommonChunks.d.ts +2 -2
  740. package/dist/esmdev/webgl/shaders/glslCommonChunks.js +1 -1
  741. package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
  742. package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
  743. package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.d.ts +2 -2
  744. package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +27 -27
  745. package/dist/esmdev/webgl/shaders/nodes/DiscardShader.d.ts +1 -1
  746. package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +5 -5
  747. package/dist/esmdev/webgl/shaders/nodes/EndShader.d.ts +2 -2
  748. package/dist/esmdev/webgl/shaders/nodes/EndShader.js +6 -6
  749. package/dist/esmdev/webgl/shaders/nodes/OutDistance.d.ts +1 -1
  750. package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +17 -17
  751. package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +12 -12
  752. package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +11 -11
  753. package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +12 -12
  754. package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.d.ts +1 -1
  755. package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +13 -13
  756. package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +27 -27
  757. package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +27 -27
  758. package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.d.ts +1 -1
  759. package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +33 -27
  760. package/dist/esmdev/webgpu/AttributeReader.d.ts +18 -0
  761. package/dist/esmdev/webgpu/AttributeReader.js +57 -0
  762. package/dist/esmdev/webgpu/GpuCullingRegistry.js +91 -91
  763. package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
  764. package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
  765. package/dist/esmdev/webgpu/ShaderPropertyAccessorWGSL.d.ts +11 -0
  766. package/dist/esmdev/webgpu/ShaderPropertyAccessorWGSL.js +131 -0
  767. package/dist/esmdev/webgpu/WebGpuBindGroups.d.ts +131 -0
  768. package/dist/esmdev/webgpu/WebGpuBindGroups.js +377 -0
  769. package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
  770. package/dist/esmdev/webgpu/WebGpuCompressedTextures.d.ts +38 -0
  771. package/dist/esmdev/webgpu/WebGpuCompressedTextures.js +155 -0
  772. package/dist/esmdev/webgpu/WebGpuCubeTextureShaders.d.ts +1 -0
  773. package/dist/esmdev/webgpu/WebGpuCubeTextureShaders.js +68 -0
  774. package/dist/esmdev/webgpu/WebGpuCubeTextures.d.ts +72 -0
  775. package/dist/esmdev/webgpu/WebGpuCubeTextures.js +340 -0
  776. package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
  777. package/dist/esmdev/webgpu/WebGpuDraw.d.ts +63 -0
  778. package/dist/esmdev/webgpu/WebGpuDraw.js +133 -0
  779. package/dist/esmdev/webgpu/WebGpuDrawParameters.d.ts +61 -0
  780. package/dist/esmdev/webgpu/WebGpuDrawParameters.js +120 -0
  781. package/dist/esmdev/webgpu/WebGpuExternalRenderPass.d.ts +44 -0
  782. package/dist/esmdev/webgpu/WebGpuExternalRenderPass.js +115 -0
  783. package/dist/esmdev/webgpu/WebGpuFrame.d.ts +55 -0
  784. package/dist/esmdev/webgpu/WebGpuFrame.js +89 -0
  785. package/dist/esmdev/webgpu/WebGpuFrameRenderer.d.ts +25 -0
  786. package/dist/esmdev/webgpu/WebGpuFrameRenderer.js +248 -0
  787. package/dist/esmdev/webgpu/WebGpuGpuCulling.js +200 -454
  788. package/dist/esmdev/webgpu/WebGpuGpuCullingShaders.d.ts +34 -0
  789. package/dist/esmdev/webgpu/WebGpuGpuCullingShaders.js +264 -0
  790. package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
  791. package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +39 -194
  792. package/dist/esmdev/webgpu/WebGpuLightClusterShaders.d.ts +14 -0
  793. package/dist/esmdev/webgpu/WebGpuLightClusterShaders.js +161 -0
  794. package/dist/esmdev/webgpu/WebGpuMipmapGenerator.d.ts +54 -0
  795. package/dist/esmdev/webgpu/WebGpuMipmapGenerator.js +187 -0
  796. package/dist/esmdev/webgpu/WebGpuMipmapShaders.d.ts +1 -0
  797. package/dist/esmdev/webgpu/WebGpuMipmapShaders.js +34 -0
  798. package/dist/esmdev/webgpu/WebGpuRenderBundles.d.ts +117 -0
  799. package/dist/esmdev/webgpu/WebGpuRenderBundles.js +299 -0
  800. package/dist/esmdev/webgpu/WebGpuRenderPassEncoders.d.ts +140 -0
  801. package/dist/esmdev/webgpu/WebGpuRenderPassEncoders.js +611 -0
  802. package/dist/esmdev/webgpu/WebGpuRenderPipelines.d.ts +75 -0
  803. package/dist/esmdev/webgpu/WebGpuRenderPipelines.js +249 -0
  804. package/dist/esmdev/webgpu/WebGpuRenderTargetTextures.d.ts +78 -0
  805. package/dist/esmdev/webgpu/WebGpuRenderTargetTextures.js +108 -0
  806. package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +52 -322
  807. package/dist/esmdev/webgpu/WebGpuResourceRepository.js +332 -3127
  808. package/dist/esmdev/webgpu/WebGpuSamplers.d.ts +45 -0
  809. package/dist/esmdev/webgpu/WebGpuSamplers.js +58 -0
  810. package/dist/esmdev/webgpu/WebGpuShaderProgramBuilder.d.ts +25 -0
  811. package/dist/esmdev/webgpu/WebGpuShaderProgramBuilder.js +108 -0
  812. package/dist/esmdev/webgpu/WebGpuStorageBuffers.d.ts +77 -0
  813. package/dist/esmdev/webgpu/WebGpuStorageBuffers.js +191 -0
  814. package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +1 -73
  815. package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +58 -780
  816. package/dist/esmdev/webgpu/WebGpuStrategyStorage.d.ts +62 -0
  817. package/dist/esmdev/webgpu/WebGpuStrategyStorage.js +267 -0
  818. package/dist/esmdev/webgpu/WebGpuTextureReadback.d.ts +111 -0
  819. package/dist/esmdev/webgpu/WebGpuTextureReadback.js +188 -0
  820. package/dist/esmdev/webgpu/WebGpuTextureReadbackShaders.d.ts +4 -0
  821. package/dist/esmdev/webgpu/WebGpuTextureReadbackShaders.js +34 -0
  822. package/dist/esmdev/webgpu/WebGpuTextureUploads.d.ts +109 -0
  823. package/dist/esmdev/webgpu/WebGpuTextureUploads.js +197 -0
  824. package/dist/esmdev/webgpu/WebGpuTextures.d.ts +196 -0
  825. package/dist/esmdev/webgpu/WebGpuTextures.js +344 -0
  826. package/dist/esmdev/webgpu/WebGpuVertexBuffers.d.ts +142 -0
  827. package/dist/esmdev/webgpu/WebGpuVertexBuffers.js +281 -0
  828. package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +106 -284
  829. package/dist/esmdev/webgpu/WebGpuVertexDeformerShaders.d.ts +7 -0
  830. package/dist/esmdev/webgpu/WebGpuVertexDeformerShaders.js +134 -0
  831. package/dist/esmdev/webgpu/WebGpuVertexShaderDefinitions.d.ts +16 -0
  832. package/dist/esmdev/webgpu/WebGpuVertexShaderDefinitions.js +216 -0
  833. package/dist/esmdev/webgpu/assertArrayBufferView.d.ts +9 -0
  834. package/dist/esmdev/webgpu/assertArrayBufferView.js +10 -0
  835. package/dist/esmdev/webgpu/main.d.ts +2 -16
  836. package/dist/esmdev/webgpu/main.js +3 -3
  837. package/dist/esmdev/webgpu/padCompressedRowsForUpload.d.ts +20 -0
  838. package/dist/esmdev/webgpu/padCompressedRowsForUpload.js +20 -0
  839. package/dist/esmdev/webgpu/removeRowPadding.d.ts +21 -0
  840. package/dist/esmdev/webgpu/removeRowPadding.js +23 -0
  841. package/dist/esmdev/webgpu/shaderity_shaders/common/processGeometry.wgsl.js +2 -2
  842. package/dist/esmdev/webgpu/wgslCommonChunks.d.ts +2 -2
  843. package/dist/esmdev/webgpu/wgslCommonChunks.js +1 -1
  844. package/dist/esmdev/xr/WebARSystem.js +65 -65
  845. package/dist/esmdev/xr/WebXRSystem.d.ts +0 -4
  846. package/dist/esmdev/xr/WebXRSystem.js +155 -160
  847. package/package.json +1 -1
  848. package/dist/esm/foundation/definitions/ProcessApproach.d.ts +0 -21
  849. package/dist/esm/foundation/definitions/ProcessApproach.js +0 -1
  850. package/dist/esm/foundation/materials/core/ShaderHandler.d.ts +0 -125
  851. package/dist/esm/foundation/materials/core/ShaderHandler.js +0 -48
  852. package/dist/esmdev/foundation/definitions/ProcessApproach.d.ts +0 -21
  853. package/dist/esmdev/foundation/definitions/ProcessApproach.js +0 -60
  854. package/dist/esmdev/foundation/materials/core/ShaderHandler.d.ts +0 -125
  855. package/dist/esmdev/foundation/materials/core/ShaderHandler.js +0 -416
package/README.md CHANGED
@@ -76,8 +76,8 @@ $ npm install rhodonite
76
76
 
77
77
  ## Migration to WebGL2 mode
78
78
 
79
- - `ProcessApproach.Uniform` was removed. Use `ProcessApproach.WebGL2`.
80
- - `ProcessApproach.DataTexture` was renamed to `ProcessApproach.WebGL2` (mode name `"WebGL2"`).
79
+ - `RenderBackend.Uniform` was removed. Use `RenderBackend.WebGL2`.
80
+ - `RenderBackend.DataTexture` was renamed to `RenderBackend.WebGL2` (mode name `"WebGL2"`).
81
81
  - `WebGLStrategyDataTexture` was renamed to `WebGLStrategyWebGL2`.
82
82
  - The shader define `RN_IS_DATATEXTURE_MODE` was renamed to `RN_IS_WEBGL2_MODE`.
83
83
  - `Config.maxSkeletalBoneNumberForUniformMode` and the `setUniform` rendering argument were removed.
@@ -93,7 +93,7 @@ $ npm install rhodonite
93
93
  <script>
94
94
  // Init Rhodonite
95
95
  const engine = await Rn.Engine.init({
96
- approach: Rn.ProcessApproach.WebGL2,
96
+ backend: Rn.RenderBackend.WebGL2,
97
97
  canvas: document.getElementById('world'),
98
98
  });
99
99
 
@@ -127,7 +127,7 @@ import Rn from 'rhodonite';
127
127
 
128
128
  // Init Rhodonite
129
129
  const engine = await Rn.Engine.init({
130
- approach: Rn.ProcessApproach.WebGL2,
130
+ backend: Rn.RenderBackend.WebGL2,
131
131
  canvas: document.getElementById('world') as HTMLCanvasElement,
132
132
  });
133
133
 
@@ -162,7 +162,7 @@ import Rn from 'rhodonite/dist/esm/index.js';
162
162
 
163
163
  // Init Rhodonite
164
164
  const engine = await Rn.Engine.init({
165
- approach: Rn.ProcessApproach.WebGL2,
165
+ backend: Rn.RenderBackend.WebGL2,
166
166
  canvas: document.getElementById('world') as HTMLCanvasElement,
167
167
  });
168
168
 
@@ -218,10 +218,10 @@ Rollup, Rolldown, webpack, esbuild, ...), import what you use by name and the bu
218
218
  out of your bundle:
219
219
 
220
220
  ```typescript
221
- import { Engine, MeshHelper, ProcessApproach, Vector3 } from 'rhodonite';
221
+ import { Engine, MeshHelper, RenderBackend, Vector3 } from 'rhodonite';
222
222
 
223
223
  const engine = await Engine.init({
224
- approach: ProcessApproach.WebGL2,
224
+ backend: RenderBackend.WebGL2,
225
225
  canvas: document.getElementById('world') as HTMLCanvasElement,
226
226
  });
227
227
  const planeEntity = MeshHelper.createPlane(engine);
@@ -252,19 +252,19 @@ export default {
252
252
  ```
253
253
 
254
254
  `esbuild` takes the same `define` option, and webpack takes `new webpack.DefinePlugin({ __RN_WEBGPU__: 'false' })`.
255
- `Engine.init` throws when the requested process approach was excluded this way.
255
+ `Engine.init` throws when the requested render backend was excluded this way.
256
256
 
257
257
  With named imports, two optional features are enabled explicitly (the default `Rn` export enables both
258
258
  automatically):
259
259
 
260
260
  ```typescript
261
- import { Engine, ProcessApproach, registerGizmos } from 'rhodonite';
261
+ import { Engine, RenderBackend, registerGizmos } from 'rhodonite';
262
262
 
263
263
  // Gizmos (isTranslationGizmoVisible, isLightGizmoVisible, isShapeGizmoVisible, ...)
264
264
  registerGizmos();
265
265
 
266
266
  // WebXR / WebAR: load the XR support at init, or later with `await engine.enableXR()`
267
- const engine = await Engine.init({ approach: ProcessApproach.WebGL2, canvas, xr: true });
267
+ const engine = await Engine.init({ backend: RenderBackend.WebGL2, canvas, xr: true });
268
268
  ```
269
269
 
270
270
  Without them, showing a gizmo or reading `engine.webXRSystem` throws an error that says what to call.
package/VERSION-FILE CHANGED
@@ -1,2 +1,2 @@
1
- v0.27.1-1-g9b62bac36-dirty
1
+ v0.28.0-1-g6a4577d43-dirty
2
2
  main
@@ -1,4 +1,4 @@
1
- import{CameraComponent as m}from"../foundation/components/Camera/CameraComponent.js";import{WellKnownComponentTIDs as P}from"../foundation/components/WellKnownComponentTIDs.js";import{Component as w}from"../foundation/core/Component.js";import{applyMixins as E}from"../foundation/core/EntityRepository.js";import{ProcessApproach as C}from"../foundation/definitions/ProcessApproach.js";import{ProcessStage as c}from"../foundation/definitions/ProcessStage.js";import{MutableMatrix44 as y}from"../foundation/math/MutableMatrix44.js";import{Is as r}from"../foundation/misc/Is.js";import{Logger as f}from"../foundation/misc/Logger.js";var s=class s extends w{constructor(){super(...arguments);this.type="efk";this.playJustAfterLoaded=!1;this.isLoop=!1;this.isPause=!1;this.randomSeed=-1;this.isImageLoadWithCredential=!1;this.isSoundEnabled=!1;this.autoResumeSoundByUserGesture=!0;this.c=1;this.l=!1;this.o=!1;this.w=!1;this.m=-1;this.b=-1}static get componentTID(){return P.EffekseerComponentTID}static G(){return globalThis.effekseer}static U(e){if(e==null)return-1;let t=s.C.get(e);return t==null&&(t=++s.T,s.C.set(e,t)),t}static M(e){var t,i,n,o;return e==="webgpu"?{wasmPath:(t=s.wasmModuleUriWebGPU)!=null?t:s.wasmModuleUri,scriptPath:(i=s.nativeScriptUriWebGPU)!=null?i:s.nativeScriptUri}:{wasmPath:(n=s.wasmModuleUriWebGL)!=null?n:s.wasmModuleUri,scriptPath:(o=s.nativeScriptUriWebGL)!=null?o:s.nativeScriptUri}}static async k(e,t,i){let{wasmPath:n,scriptPath:o}=s.M(t),u=`${t}
1
+ import{CameraComponent as m}from"../foundation/components/Camera/CameraComponent.js";import{WellKnownComponentTIDs as P}from"../foundation/components/WellKnownComponentTIDs.js";import{Component as w}from"../foundation/core/Component.js";import{applyMixins as E}from"../foundation/core/EntityRepository.js";import{ProcessStage as c}from"../foundation/definitions/ProcessStage.js";import{RenderBackend as C}from"../foundation/definitions/RenderBackend.js";import{MutableMatrix44 as y}from"../foundation/math/MutableMatrix44.js";import{Is as r}from"../foundation/misc/Is.js";import{Logger as f}from"../foundation/misc/Logger.js";var s=class s extends w{constructor(){super(...arguments);this.type="efk";this.playJustAfterLoaded=!1;this.isLoop=!1;this.isPause=!1;this.randomSeed=-1;this.isImageLoadWithCredential=!1;this.isSoundEnabled=!1;this.autoResumeSoundByUserGesture=!0;this.c=1;this.l=!1;this.a=!1;this.w=!1;this.m=-1;this.b=-1}static get componentTID(){return P.EffekseerComponentTID}static G(){return globalThis.effekseer}static U(e){if(e==null)return-1;let t=s.C.get(e);return t==null&&(t=++s.T,s.C.set(e,t)),t}static M(e){var t,i,n,a;return e==="webgpu"?{wasmPath:(t=s.wasmModuleUriWebGPU)!=null?t:s.wasmModuleUri,scriptPath:(i=s.nativeScriptUriWebGPU)!=null?i:s.nativeScriptUri}:{wasmPath:(n=s.wasmModuleUriWebGL)!=null?n:s.wasmModuleUri,scriptPath:(a=s.nativeScriptUriWebGL)!=null?a:s.nativeScriptUri}}static async k(e,t,i){let{wasmPath:n,scriptPath:a}=s.M(t),u=`${t}
2
2
  ${n!=null?n:""}
3
- ${o!=null?o:""}
4
- ${s.U(i)}`;(s.d==null||s.E!==u)&&(s.E=u,s.d=e.initRuntime(t==="webgpu"?{backend:t,device:i,wasmPath:n,scriptPath:o}:{backend:t,wasmPath:n,scriptPath:o}).catch(h=>{throw s.d=void 0,h})),await s.d}static R(e){return e instanceof Error?e.message:String(e)}cancelLoop(){clearInterval(this.p)}isPlay(){return r.exist(this.t)&&this.t.exists?!this.isPause:!1}play(){var e;return r.not.exist(this.e)?(f.default.warn("No Effekseer context yet"),!1):r.not.exist(this.s)?(f.default.warn("No Effekseer effect yet"),!1):(this.stop(),this.isPause=!1,this.t=(e=this.e.play(this.s,0,0,0))!=null?e:void 0,r.exist(this.t)&&this.randomSeed>0&&this.t.setRandomSeed(this.randomSeed),r.exist(this.t))}continue(){this.isPause=!1}pause(){r.exist(this.t)&&(this.isPause=!0,clearInterval(this.p))}stop(){r.exist(this.t)&&(this.t.stop(),this.isPause=!0,clearInterval(this.p))}set playSpeed(e){this.t&&this.t.setSpeed(e),this.c=e}get playSpeed(){return this.c}setSoundVolume(e){var t,i;(i=(t=this.e)==null?void 0:t.setSoundVolume)==null||i.call(t,e)}async resumeSound(){var e;return this.isSoundEnabled=!0,this.f(),r.not.exist((e=this.e)==null?void 0:e.resumeSound)?!1:(await this.e.resumeSound(),!0)}pauseSound(){var e,t;this.isSoundEnabled=!1,this.f(),(t=(e=this.e)==null?void 0:e.pauseSound)==null||t.call(e)}L(){var t;if(!this.autoResumeSoundByUserGesture||this.isSoundEnabled||r.not.exist((t=this.e)==null?void 0:t.resumeSound)||r.exist(this.r))return;let e;if(this.a()==="webgpu")e=this.i.webGpuResourceRepository.getWebGpuDeviceWrapper().canvas;else{let i=this.i.webglResourceRepository.currentWebGLContextWrapper;e=i==null?void 0:i.canvas}e!=null||(e=typeof window!="undefined"?window:void 0),!r.not.exist(e)&&(this.n=e,this.r=()=>{this.W()},e.addEventListener("pointerdown",this.r,{once:!0}),e.addEventListener("keydown",this.r,{once:!0}),e.addEventListener("touchstart",this.r,{once:!0,passive:!0}))}f(){r.not.exist(this.n)||r.not.exist(this.r)||(this.n.removeEventListener("pointerdown",this.r),this.n.removeEventListener("keydown",this.r),this.n.removeEventListener("touchstart",this.r),this.n=void 0,this.r=void 0)}async W(){if(this.f(),this.o)return;let e=this.playJustAfterLoaded&&!this.isLoop;!await this.resumeSound()||this.o||e&&(this.stop(),this.play())}setTime(e){if(!this.play()||r.not.exist(this.e))return!1;let t=0,i=.0166;for(t=i;t<=e;)if(this.e.update(t/i),t+=i,e<t){let n=e-t,o=i-n;this.e.update(o/i);break}return this.pause(),!0}set translate(e){this.t&&this.t.setLocation(e.x,e.y,e.z),this.entity.tryToGetTransform().localPosition=e}get translate(){return this.entity.tryToGetTransform().localPosition}set rotate(e){this.t&&this.t.setRotation(e.x,e.y,e.z),this.entity.tryToGetTransform().localEulerAngles=e}get rotate(){return this.entity.tryToGetTransform().localEulerAngles}set scale(e){this.t&&this.t.setScale(e.x,e.y,e.z),this.entity.tryToGetTransform().localScale=e}get scale(){return this.entity.tryToGetTransform().localScale}a(){return C.isWebGpuApproach(this.i.processApproach)?"webgpu":"webgl"}A(){if(this.a()==="webgpu")return this.i.webGpuResourceRepository.getWebGpuDeviceWrapper().gpuDevice}prepareWebGPURendering(e){var o;if(this.a()!=="webgpu"||r.not.exist((o=this.e)==null?void 0:o.configureSurface))return;let t=this.i.webGpuResourceRepository.getWebGpuDeviceWrapper(),i=t.canvas.width,n=t.canvas.height;this.m===i&&this.b===n&&this.v===(e==null?void 0:e.colorFormat)&&this.g===(e==null?void 0:e.depthFormat)||(this.e.configureSurface({width:i,height:n,colorFormat:e==null?void 0:e.colorFormat,depthFormat:e==null?void 0:e.depthFormat,enablePremultipliedAlpha:!0}),this.m=i,this.b=n,this.v=e==null?void 0:e.colorFormat,this.g=e==null?void 0:e.depthFormat)}async I(e){var n,o,u,h,l;if(r.not.exist(this.uri)&&r.not.exist(this.arrayBuffer))return!1;let t=this.a();if(e.setImageCrossOrigin(this.isImageLoadWithCredential?"use-credentials":""),t==="webgpu"){let d=this.i.webGpuResourceRepository,a=d.getWebGpuDeviceWrapper(),{colorFormat:p,depthFormat:x}=d.getEffekseerRenderPassOptions(this.i),b=a.context,g={canvas:{width:a.canvas.width,height:a.canvas.height},configure:R=>{},unconfigure:(n=b.unconfigure)==null?void 0:n.bind(b),getCurrentTexture:()=>b.getCurrentTexture()};this.e=await e.createContext({backend:t,canvasContext:g,device:a.gpuDevice,colorFormat:p,depthFormat:x,width:a.canvas.width,height:a.canvas.height,enablePremultipliedAlpha:!0})}else{let a=this.i.webglResourceRepository.currentWebGLContextWrapper;if(r.not.exist(a))return f.default.error("WebGL context is not ready for Effekseer"),!1;let p=a.getRawContext();this.e=await e.createContext({backend:t,graphicsContext:p,enablePremultipliedAlpha:!0})}(u=(o=this.e).setRestorationOfStatesFlag)==null||u.call(o,!0),this.isSoundEnabled||((l=(h=this.e).pauseSound)==null||l.call(h),this.L());let i=r.exist(this.uri)?this.uri:this.arrayBuffer;try{if(this.type==="efkpkg"){if(r.not.exist(s.Unzip))return f.default.error("Please Set an Unzip object to EffekseerComponent.Unzip"),this.h(e),!1;this.s=await this.e.loadEffectPackage(i,s.Unzip,1)}else this.s=await this.e.loadEffect(i,1)}catch(d){return f.default.error(`Failed to load Effekseer effect: ${s.R(d)}`),this.h(e),!1}return this.o?(this.h(e),!1):(this.l=!0,this.playJustAfterLoaded&&this.play(),!0)}$load(){if(!(this.l||this.u!=null||this.o)&&r.not.exist(this.e)&&r.not.exist(this.s)){let e=s.G();if(r.not.exist(e)){this.w||(f.default.error("Effekseer module is not found. Import effekseer.js in HTML and assign it to globalThis.effekseer."),this.w=!0);return}this.u=(async()=>(await s.k(e,this.a(),this.A()),this.I(e)))(),this.u.then(t=>{t&&this.moveStageTo(c.Logic)}).catch(t=>{f.default.error(`Failed to initialize Effekseer: ${s.R(t)}`)}).finally(()=>{this.u=void 0})}}$logic(){if(this.isPause||r.exist(this.e)&&r.false(this.isPause)&&this.e.update(),this.t!=null){let e=s.P.copyComponents(this.entity.tryToGetSceneGraph().matrixInner);this.t.setMatrix(e._v),this.t.setSpeed(this.c)}if(this.isPause){this.moveStageTo(c.Render);return}this.isLoop&&(this.isPlay()||this.play()),this.moveStageTo(c.Render)}_destroy(){super._destroy(),this.o=!0;let e=s.G();this.h(e)}h(e){var t,i;this.f(),r.exist(this.t)&&(this.t.stop(),this.t=void 0),r.exist(this.e)&&(r.exist(this.s)&&this.e.releaseEffect(this.s),r.exist(e)?e.releaseContext(this.e):(i=(t=this.e).release)==null||i.call(t),this.e=void 0),this.s=void 0,this.l=!1,this.m=-1,this.b=-1,this.v=void 0,this.g=void 0}F(){let e=this.i.componentRepository.getComponent(m,m.getCurrent(this.i)),t=s.P,i=s.S;e?(t.copyComponents(e.viewMatrix),i.copyComponents(e.projectionMatrix)):(t.identity(),i.identity()),r.exist(this.e)&&(this.e.setProjectionMatrix(i._v),this.e.setCameraMatrix(t._v),this.e.draw())}D(e,t,i=0){var h,l,d;let n=this.i.componentRepository.getComponent(m,m.getCurrent(this.i)),o=s.P,u=s.S;if((h=this.i._webXRSystemIfEnabled)!=null&&h.isWebXRMode){let a=this.i._webXRSystemIfEnabled._getProjectMatrixAt(i),p=this.i._webXRSystemIfEnabled._getViewMatrixAt(i);r.exist(a)&&r.exist(p)?(o.copyComponents(p),u.copyComponents(a)):(o.identity(),u.identity())}else n?(o.copyComponents(n.viewMatrix),u.copyComponents(n.projectionMatrix)):(o.identity(),u.identity());if(r.exist(this.e)&&r.exist(this.e.drawToRenderPass)){this.e.setProjectionMatrix(u._v),this.e.setCameraMatrix(o._v),this.e.drawToRenderPass(e,t);let a=(d=(l=this.e).getLastWebGPUError)==null?void 0:d.call(l);a&&f.default.error(a)}}B(){let e=this.i._webXRSystemIfEnabled;if(e!=null)for(let t=0;t<2;t++){let i=e._getProjectMatrixAt(t),n=e._getViewMatrixAt(t);r.exist(i)&&r.exist(n)&&r.exist(this.e)&&(this.i.webglResourceRepository.setViewport(this.i,e._getViewportAt(t)),this.e.setProjectionMatrix(i._v),this.e.setCameraMatrix(n._v),this.e.draw())}}$render(){var e;if(r.not.exist(this.s)){this.moveStageTo(c.Load);return}(e=this.i._webXRSystemIfEnabled)!=null&&e.isWebXRMode?this.B():this.F(),this.moveStageTo(c.Logic)}$renderWebGPU(e,t,i=0){if(r.not.exist(this.s)){this.moveStageTo(c.Load);return}this.D(e,t,i),this.moveStageTo(c.Logic)}static sort_$render(e,t){return r.false(t.toRenderEffekseerEffects)?[]:e.componentRepository.getComponentsWithType(s).map(n=>n.componentSID)}addThisComponentToEntity(e,t){class i extends e.constructor{getEffekseer(){return this.getComponentByComponentTID(s.componentTID)}}return E(e,i),e}};s.ANIMATION_EVENT_PLAY=0,s.ANIMATION_EVENT_PAUSE=1,s.ANIMATION_EVENT_END=2,s.C=new WeakMap,s.T=0,s.P=y.identity(),s.S=y.identity();var v=s;export{v as EffekseerComponent};
3
+ ${a!=null?a:""}
4
+ ${s.U(i)}`;(s.d==null||s.E!==u)&&(s.E=u,s.d=e.initRuntime(t==="webgpu"?{backend:t,device:i,wasmPath:n,scriptPath:a}:{backend:t,wasmPath:n,scriptPath:a}).catch(h=>{throw s.d=void 0,h})),await s.d}static R(e){return e instanceof Error?e.message:String(e)}cancelLoop(){clearInterval(this.p)}isPlay(){return r.exist(this.t)&&this.t.exists?!this.isPause:!1}play(){var e;return r.not.exist(this.e)?(f.default.warn("No Effekseer context yet"),!1):r.not.exist(this.s)?(f.default.warn("No Effekseer effect yet"),!1):(this.stop(),this.isPause=!1,this.t=(e=this.e.play(this.s,0,0,0))!=null?e:void 0,r.exist(this.t)&&this.randomSeed>0&&this.t.setRandomSeed(this.randomSeed),r.exist(this.t))}continue(){this.isPause=!1}pause(){r.exist(this.t)&&(this.isPause=!0,clearInterval(this.p))}stop(){r.exist(this.t)&&(this.t.stop(),this.isPause=!0,clearInterval(this.p))}set playSpeed(e){this.t&&this.t.setSpeed(e),this.c=e}get playSpeed(){return this.c}setSoundVolume(e){var t,i;(i=(t=this.e)==null?void 0:t.setSoundVolume)==null||i.call(t,e)}async resumeSound(){var e;return this.isSoundEnabled=!0,this.f(),r.not.exist((e=this.e)==null?void 0:e.resumeSound)?!1:(await this.e.resumeSound(),!0)}pauseSound(){var e,t;this.isSoundEnabled=!1,this.f(),(t=(e=this.e)==null?void 0:e.pauseSound)==null||t.call(e)}L(){var t;if(!this.autoResumeSoundByUserGesture||this.isSoundEnabled||r.not.exist((t=this.e)==null?void 0:t.resumeSound)||r.exist(this.r))return;let e;if(this.o()==="webgpu")e=this.i.webGpuResourceRepository.getWebGpuDeviceWrapper().canvas;else{let i=this.i.webglResourceRepository.currentWebGLContextWrapper;e=i==null?void 0:i.canvas}e!=null||(e=typeof window!="undefined"?window:void 0),!r.not.exist(e)&&(this.n=e,this.r=()=>{this.W()},e.addEventListener("pointerdown",this.r,{once:!0}),e.addEventListener("keydown",this.r,{once:!0}),e.addEventListener("touchstart",this.r,{once:!0,passive:!0}))}f(){r.not.exist(this.n)||r.not.exist(this.r)||(this.n.removeEventListener("pointerdown",this.r),this.n.removeEventListener("keydown",this.r),this.n.removeEventListener("touchstart",this.r),this.n=void 0,this.r=void 0)}async W(){if(this.f(),this.a)return;let e=this.playJustAfterLoaded&&!this.isLoop;!await this.resumeSound()||this.a||e&&(this.stop(),this.play())}setTime(e){if(!this.play()||r.not.exist(this.e))return!1;let t=0,i=.0166;for(t=i;t<=e;)if(this.e.update(t/i),t+=i,e<t){let n=e-t,a=i-n;this.e.update(a/i);break}return this.pause(),!0}set translate(e){this.t&&this.t.setLocation(e.x,e.y,e.z),this.entity.tryToGetTransform().localPosition=e}get translate(){return this.entity.tryToGetTransform().localPosition}set rotate(e){this.t&&this.t.setRotation(e.x,e.y,e.z),this.entity.tryToGetTransform().localEulerAngles=e}get rotate(){return this.entity.tryToGetTransform().localEulerAngles}set scale(e){this.t&&this.t.setScale(e.x,e.y,e.z),this.entity.tryToGetTransform().localScale=e}get scale(){return this.entity.tryToGetTransform().localScale}o(){return C.isWebGpuBackend(this.i.renderBackend)?"webgpu":"webgl"}I(){if(this.o()==="webgpu")return this.i.webGpuResourceRepository.getWebGpuDeviceWrapper().gpuDevice}prepareWebGPURendering(e){var a;if(this.o()!=="webgpu"||r.not.exist((a=this.e)==null?void 0:a.configureSurface))return;let t=this.i.webGpuResourceRepository.getWebGpuDeviceWrapper(),i=t.canvas.width,n=t.canvas.height;this.m===i&&this.b===n&&this.v===(e==null?void 0:e.colorFormat)&&this.g===(e==null?void 0:e.depthFormat)||(this.e.configureSurface({width:i,height:n,colorFormat:e==null?void 0:e.colorFormat,depthFormat:e==null?void 0:e.depthFormat,enablePremultipliedAlpha:!0}),this.m=i,this.b=n,this.v=e==null?void 0:e.colorFormat,this.g=e==null?void 0:e.depthFormat)}async A(e){var n,a,u,h,l;if(r.not.exist(this.uri)&&r.not.exist(this.arrayBuffer))return!1;let t=this.o();if(e.setImageCrossOrigin(this.isImageLoadWithCredential?"use-credentials":""),t==="webgpu"){let d=this.i.webGpuResourceRepository,o=d.getWebGpuDeviceWrapper(),{colorFormat:p,depthFormat:x}=d.getEffekseerRenderPassOptions(this.i),b=o.context,g={canvas:{width:o.canvas.width,height:o.canvas.height},configure:R=>{},unconfigure:(n=b.unconfigure)==null?void 0:n.bind(b),getCurrentTexture:()=>b.getCurrentTexture()};this.e=await e.createContext({backend:t,canvasContext:g,device:o.gpuDevice,colorFormat:p,depthFormat:x,width:o.canvas.width,height:o.canvas.height,enablePremultipliedAlpha:!0})}else{let o=this.i.webglResourceRepository.currentWebGLContextWrapper;if(r.not.exist(o))return f.default.error("WebGL context is not ready for Effekseer"),!1;let p=o.getRawContext();this.e=await e.createContext({backend:t,graphicsContext:p,enablePremultipliedAlpha:!0})}(u=(a=this.e).setRestorationOfStatesFlag)==null||u.call(a,!0),this.isSoundEnabled||((l=(h=this.e).pauseSound)==null||l.call(h),this.L());let i=r.exist(this.uri)?this.uri:this.arrayBuffer;try{if(this.type==="efkpkg"){if(r.not.exist(s.Unzip))return f.default.error("Please Set an Unzip object to EffekseerComponent.Unzip"),this.h(e),!1;this.s=await this.e.loadEffectPackage(i,s.Unzip,1)}else this.s=await this.e.loadEffect(i,1)}catch(d){return f.default.error(`Failed to load Effekseer effect: ${s.R(d)}`),this.h(e),!1}return this.a?(this.h(e),!1):(this.l=!0,this.playJustAfterLoaded&&this.play(),!0)}$load(){if(!(this.l||this.u!=null||this.a)&&r.not.exist(this.e)&&r.not.exist(this.s)){let e=s.G();if(r.not.exist(e)){this.w||(f.default.error("Effekseer module is not found. Import effekseer.js in HTML and assign it to globalThis.effekseer."),this.w=!0);return}this.u=(async()=>(await s.k(e,this.o(),this.I()),this.A(e)))(),this.u.then(t=>{t&&this.moveStageTo(c.Logic)}).catch(t=>{f.default.error(`Failed to initialize Effekseer: ${s.R(t)}`)}).finally(()=>{this.u=void 0})}}$logic(){if(this.isPause||r.exist(this.e)&&r.false(this.isPause)&&this.e.update(),this.t!=null){let e=s.P.copyComponents(this.entity.tryToGetSceneGraph().matrixInner);this.t.setMatrix(e._v),this.t.setSpeed(this.c)}if(this.isPause){this.moveStageTo(c.Render);return}this.isLoop&&(this.isPlay()||this.play()),this.moveStageTo(c.Render)}_destroy(){super._destroy(),this.a=!0;let e=s.G();this.h(e)}h(e){var t,i;this.f(),r.exist(this.t)&&(this.t.stop(),this.t=void 0),r.exist(this.e)&&(r.exist(this.s)&&this.e.releaseEffect(this.s),r.exist(e)?e.releaseContext(this.e):(i=(t=this.e).release)==null||i.call(t),this.e=void 0),this.s=void 0,this.l=!1,this.m=-1,this.b=-1,this.v=void 0,this.g=void 0}F(){let e=this.i.componentRepository.getComponent(m,m.getCurrent(this.i)),t=s.P,i=s.S;e?(t.copyComponents(e.viewMatrix),i.copyComponents(e.projectionMatrix)):(t.identity(),i.identity()),r.exist(this.e)&&(this.e.setProjectionMatrix(i._v),this.e.setCameraMatrix(t._v),this.e.draw())}D(e,t,i=0){var h,l,d;let n=this.i.componentRepository.getComponent(m,m.getCurrent(this.i)),a=s.P,u=s.S;if((h=this.i._webXRSystemIfEnabled)!=null&&h.isWebXRMode){let o=this.i._webXRSystemIfEnabled._getProjectMatrixAt(i),p=this.i._webXRSystemIfEnabled._getViewMatrixAt(i);r.exist(o)&&r.exist(p)?(a.copyComponents(p),u.copyComponents(o)):(a.identity(),u.identity())}else n?(a.copyComponents(n.viewMatrix),u.copyComponents(n.projectionMatrix)):(a.identity(),u.identity());if(r.exist(this.e)&&r.exist(this.e.drawToRenderPass)){this.e.setProjectionMatrix(u._v),this.e.setCameraMatrix(a._v),this.e.drawToRenderPass(e,t);let o=(d=(l=this.e).getLastWebGPUError)==null?void 0:d.call(l);o&&f.default.error(o)}}B(){let e=this.i._webXRSystemIfEnabled;if(e!=null)for(let t=0;t<2;t++){let i=e._getProjectMatrixAt(t),n=e._getViewMatrixAt(t);r.exist(i)&&r.exist(n)&&r.exist(this.e)&&(this.i.webglResourceRepository.setViewport(this.i,e._getViewportAt(t)),this.e.setProjectionMatrix(i._v),this.e.setCameraMatrix(n._v),this.e.draw())}}$render(){var e;if(r.not.exist(this.s)){this.moveStageTo(c.Load);return}(e=this.i._webXRSystemIfEnabled)!=null&&e.isWebXRMode?this.B():this.F(),this.moveStageTo(c.Logic)}$renderWebGPU(e,t,i=0){if(r.not.exist(this.s)){this.moveStageTo(c.Load);return}this.D(e,t,i),this.moveStageTo(c.Logic)}static sort_$render(e,t){return r.false(t.toRenderEffekseerEffects)?[]:e.componentRepository.getComponentsWithType(s).map(n=>n.componentSID)}addThisComponentToEntity(e,t){class i extends e.constructor{getEffekseer(){return this.getComponentByComponentTID(s.componentTID)}}return E(e,i),e}};s.ANIMATION_EVENT_PLAY=0,s.ANIMATION_EVENT_PAUSE=1,s.ANIMATION_EVENT_END=2,s.C=new WeakMap,s.T=0,s.P=y.identity(),s.S=y.identity();var v=s;export{v as EffekseerComponent};
@@ -1 +1 @@
1
- import{Component as w}from"../../core/Component.js";import{applyMixins as V}from"../../core/EntityRepository.js";import{BufferUse as _}from"../../definitions/BufferUse.js";import{CameraType as m}from"../../definitions/CameraType.js";import{ComponentType as g}from"../../definitions/ComponentType.js";import{CompositionType as I}from"../../definitions/CompositionType.js";import{LightType as C}from"../../definitions/LightType.js";import{ProcessApproach as d}from"../../definitions/ProcessApproach.js";import{ProcessStage as z}from"../../definitions/ProcessStage.js";import{ShaderType as x}from"../../definitions/ShaderType.js";import{Frustum as P}from"../../geometry/Frustum.js";import{MathUtil as l}from"../../math/MathUtil.js";import{Matrix44 as v}from"../../math/Matrix44.js";import{MutableMatrix44 as h}from"../../math/MutableMatrix44.js";import{MutableVector2 as D}from"../../math/MutableVector2.js";import{MutableVector3 as s}from"../../math/MutableVector3.js";import{MutableVector4 as c}from"../../math/MutableVector4.js";import{Vector3 as y}from"../../math/Vector3.js";import{Vector4 as E}from"../../math/Vector4.js";import{Is as b}from"../../misc/Is.js";import{_getCameraControllerUpdateCount as j}from"../CameraController/CameraControllerUpdateCount.js";import{TransformComponent as T}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as f}from"../WellKnownComponentTIDs.js";var n=class n extends w{constructor(t,r,e,i,o){super(t,r,e,i,o);this._eyeInner=s.zero();this._direction=s.fromCopy3(0,0,-1);this._directionInner=s.fromCopy3(0,0,-1);this._up=s.fromCopy3(0,1,0);this._upInner=s.fromCopy3(0,1,0);this._filmWidth=36;this._filmHeight=24;this._focalLength=20;this.primitiveMode=!1;this._corner=c.fromCopy4(-1,1,1,-1);this._cornerInner=c.fromCopy4(-1,1,1,-1);this._parameters=c.fromCopy4(.1,1e4,90,1);this._parametersInner=c.fromCopy4(.1,1e4,90,1);this.Qe=m.Perspective;this._projectionMatrix=h.dummy();this.He=h.identity();this.Xe=!1;this.Ne=D.zero();this._viewMatrix=h.dummy();this._viewPosition=s.dummy();this._lightClusterViewInfo=c.dummy();this._xrLeft=!1;this._xrRight=!1;this.isSyncToLight=!1;this.rr=new P;this.rt=0;this.ir=-1;this.nr=-1;this.or=-1;this.sr=-1;this.setFovyAndChangeFocalLength(90),n.getCurrent(t)===-1&&n.setCurrent(t,e),this.submitToAllocation(t.config.cameraComponentCountPerBufferView,o)}static getCurrent(t){var r;return(r=this.Ye.get(t.engineUid))!=null?r:-1}static setCurrent(t,r){this.Ye.set(t.engineUid,r)}get updateCount(){return this.rt}static getCurrentCameraUpdateCount(t){var e;let r=t.componentRepository.getComponent(n,n.getCurrent(t));return(e=r==null?void 0:r.updateCount)!=null?e:0}set type(t){this.Qe=t,t===m.Orthographic?(this._parameters.z=1,this._parameters.w=1,this._parametersInner.z=1,this._parametersInner.w=1):(this.setFovyAndChangeFocalLength(90),this._parameters.w=1,this._parametersInner.z=90,this._parametersInner.w=1),this.rt++}get type(){return this.Qe}get eye(){return n._eye}set eye(t){throw Error("In Rhodonite, eye is always (0,0,0). Use TransformComponent for Camera positioning.")}get eyeInner(){return this._eyeInner}set eyeInner(t){this._eyeInner.copyComponents(t),this.rt++}set upInner(t){this._upInner.copyComponents(t),this.rt++}set up(t){this._up.copyComponents(t),this.rt++}get up(){return this._up.clone()}get upInner(){return this._upInner}set direction(t){let r=this._direction,e=t,i=this._up,p=s.crossTo(e,i,n.tr).length()===0,a;if(p){let M=s.crossTo(r,i,n.Ze);a=s.crossTo(M,e,n.$e)}else{let M=s.multiplyTo(e,e.dot(i),n.Ze);a=s.subtractTo(i,M,n.$e)}this._up.copyComponents(a).normalize(),this._direction.copyComponents(e),this.rt++}set directionInner(t){this._directionInner.copyComponents(t),this.rt++}get direction(){return this._direction.clone()}get directionInner(){return this._directionInner}set corner(t){this._corner.copyComponents(t),this.rt++}get corner(){return this._corner.clone()}set left(t){this._corner.x=t,this.rt++}set leftInner(t){this._cornerInner.x=t,this.rt++}get left(){return this._corner.x}set right(t){this._corner.y=t,this.rt++}set rightInner(t){this._cornerInner.y=t,this.rt++}get right(){return this._corner.y}set top(t){this._corner.z=t,this.rt++}set topInner(t){this._cornerInner.z=t,this.rt++}get top(){return this._corner.z}set bottom(t){this._corner.w=t,this.rt++}set bottomInner(t){this._cornerInner.w=t,this.rt++}get bottom(){return this._corner.w}set cornerInner(t){this._cornerInner.copyComponents(t),this.rt++}get cornerInner(){return this._cornerInner}set parametersInner(t){this._parametersInner.copyComponents(t),this.rt++}get parametersInner(){return this._parametersInner}get parameters(){return this._parameters.clone()}set zNear(t){this._parameters.x=t,this.rt++}set zNearInner(t){this._parametersInner.x=t,this.rt++}get zNearInner(){return this._parametersInner.x}get zNear(){return this._parameters.x}set focalLength(t){this._focalLength=t,this._parameters.z=2*l.radianToDegree(Math.atan(this._filmHeight/(t*2))),this.rt++}get focalLength(){return this._focalLength}set focalLengthInner(t){this._parametersInner.z=2*l.radianToDegree(Math.atan(this._filmHeight/(t*2))),this.rt++}get focalLengthInner(){return this._parametersInner.z}set zFar(t){this._parameters.y=t,this.rt++}set zFarInner(t){this._parametersInner.y=t,this.rt++}get zFarInner(){return this._parametersInner.y}get zFar(){return this._parameters.y}setFovyAndChangeFilmSize(t){this._parameters.z=t,this._filmHeight=2*this.focalLength*Math.tan(l.degreeToRadian(t)/2),this._filmWidth=this._filmHeight*this.aspect,this.rt++}setFovyAndChangeFocalLength(t){this._parameters.z=t,this._focalLength=this._filmHeight/2/Math.tan(l.degreeToRadian(t)/2),this.rt++}get fovy(){return this._parameters.z}set fovyInner(t){this._parametersInner.z=t,this.rt++}set aspect(t){this._parameters.w=t,this._filmWidth=this._filmHeight*t,this.rt++}set aspectInner(t){this._parametersInner.w=t,this.rt++}get aspectInner(){return this._parametersInner.w}get aspect(){return this._parameters.w}set xMag(t){this._parameters.z=t,this.rt++}get xMag(){return this._parameters.z}set yMag(t){this._parameters.w=t}get yMag(){return this._parameters.w}static get componentTID(){return f.CameraComponentTID}get componentTID(){return f.CameraComponentTID}calcProjectionMatrix(){let t=this._parametersInner.x,r=this._parametersInner.y;if(this.i.engineState.currentProcessApproach===d.WebGPU)if(this.type===m.Perspective){let e=this._parametersInner.z,i=this._parametersInner.w;i<0&&(i=this.i.engineState.viewportAspectRatio);let o=1/Math.tan(.5*e*Math.PI/180),p=o/i;if(this._projectionMatrix.m00=p,this._projectionMatrix.m01=0,this._projectionMatrix.m02=0,this._projectionMatrix.m03=0,this._projectionMatrix.m10=0,this._projectionMatrix.m11=o,this._projectionMatrix.m12=0,this._projectionMatrix.m13=0,this._projectionMatrix.m20=0,this._projectionMatrix.m21=0,r===Number.POSITIVE_INFINITY)this._projectionMatrix.m22=-1,this._projectionMatrix.m23=-t;else{let a=1/(t-r);this._projectionMatrix.m22=r*a,this._projectionMatrix.m23=r*t*a}this._projectionMatrix.m30=0,this._projectionMatrix.m31=0,this._projectionMatrix.m32=-1,this._projectionMatrix.m33=0}else if(this.type===m.Orthographic){let e=this._parametersInner.z,i=this._parametersInner.w;this._projectionMatrix.setComponents(1/e,0,0,0,0,1/i,0,0,0,0,-1/(r-t),-t/(r-t),0,0,0,1)}else{let e=this._cornerInner.x,i=this._cornerInner.y,o=this._cornerInner.z,p=this._cornerInner.w,a=1/(t-r);this._projectionMatrix.setComponents(2*t/(i-e),0,(i+e)/(i-e),0,0,2*t/(o-p),(o+p)/(o-p),0,0,0,r*a,r*t*a,0,0,-1,0)}else if(this.type===m.Perspective){let e=this._parametersInner.z,i=this._parametersInner.w;i<0&&(i=this.i.engineState.viewportAspectRatio);let o=1/Math.tan(.5*e*Math.PI/180),p=o/i;if(this._projectionMatrix.m00=p,this._projectionMatrix.m01=0,this._projectionMatrix.m02=0,this._projectionMatrix.m03=0,this._projectionMatrix.m10=0,this._projectionMatrix.m11=o,this._projectionMatrix.m12=0,this._projectionMatrix.m13=0,this._projectionMatrix.m20=0,this._projectionMatrix.m21=0,r===Number.POSITIVE_INFINITY)this._projectionMatrix.m22=-1,this._projectionMatrix.m23=-2*t;else{let a=1/(t-r);this._projectionMatrix.m22=(r+t)*a,this._projectionMatrix.m23=2*r*t*a}this._projectionMatrix.m30=0,this._projectionMatrix.m31=0,this._projectionMatrix.m32=-1,this._projectionMatrix.m33=0}else if(this.type===m.Orthographic){let e=this._parametersInner.z,i=this._parametersInner.w;this._projectionMatrix.setComponents(1/e,0,0,0,0,1/i,0,0,0,0,-2/(r-t),-(r+t)/(r-t),0,0,0,1)}else{let e=this._cornerInner.x,i=this._cornerInner.y,o=this._cornerInner.z,p=this._cornerInner.w,a=1/(t-r);this._projectionMatrix.setComponents(2*t/(i-e),0,(i+e)/(i-e),0,0,2*t/(o-p),(o+p)/(o-p),0,0,0,(r+t)*a,2*r*t*a,0,0,-1,0)}return this.He.copyComponents(this._projectionMatrix),this.Xe=!0,this.qe(),this._projectionMatrix}qe(){let t=this.Ne.x,r=this.Ne.y,e=this.He,i=this._projectionMatrix;if(t===0&&r===0){i.copyComponents(e);return}i.copyComponents(e),i.m00=e.m00+t*e.m30,i.m01=e.m01+t*e.m31,i.m02=e.m02+t*e.m32,i.m03=e.m03+t*e.m33,i.m10=e.m10+r*e.m30,i.m11=e.m11+r*e.m31,i.m12=e.m12+r*e.m32,i.m13=e.m13+r*e.m33}get jitterOffset(){return this.Ne}set jitterOffset(t){this.Ne.x===t.x&&this.Ne.y===t.y||(this.Ne.setComponents(t.x,t.y),!(this._xrLeft||this._xrRight||!this.Xe)&&(this.qe(),this.i._markGpuInstanceDataDirty()))}get projectionMatrixWithoutJitter(){return this.He}calcViewMatrix(){let t=this.eyeInner,r=s.subtractTo(this._directionInner,t,n.tr).normalize(),e=s.crossTo(r,this._upInner,n.Ze).normalize(),i=s.crossTo(e,r,n.$e);if(this._viewMatrix.setComponents(e.x,e.y,e.z,-y.dot(e,t),i.x,i.y,i.z,-y.dot(i,t),-r.x,-r.y,-r.z,y.dot(r,t),0,0,0,1),!this.primitiveMode){let o=h.invertTo(this.entity.getSceneGraph().matrixInner,n.Ge);this._viewMatrix.multiply(o)}return this._viewMatrix}get viewMatrix(){return this._viewMatrix}set viewMatrix(t){this._viewMatrix.copyComponents(t),this.rt++}get projectionMatrix(){if(this._xrLeft||this._xrRight){let t=this.i._webXRSystemIfEnabled;if(t!=null&&t.isWebXRMode){if(this._xrLeft)return t.leftProjectionMatrix;if(this._xrRight)return t.rightProjectionMatrix}}return this._projectionMatrix}set projectionMatrix(t){this.He.copyComponents(t),this.Xe=!0,this.qe(),this.rt++}get _projectionMatrixForGpu(){return this._projectionMatrix}get _lightClusterViewInfoForGpu(){return this._lightClusterViewInfo}get viewProjectionMatrix(){return h.multiplyTo(this._projectionMatrix,this._viewMatrix,n.Ge)}get biasViewProjectionMatrix(){return h.multiplyTo(this._projectionMatrix,this._viewMatrix,n.Ge),this.i.engineState.currentProcessApproach===d.WebGPU?h.multiplyTo(n.pr,n.Ge,n.er):h.multiplyTo(n.ar,n.Ge,n.er)}hr(){this._viewPosition.copyComponents(this.worldPosition)}get worldPosition(){return this.entity.getSceneGraph().matrixInner.multiplyVector3To(this.eyeInner,n.returnVector3),n.returnVector3}updateFrustum(){this.rr.update(this.viewMatrix,this.projectionMatrix)}get frustum(){return this.rr}$load(){this.moveStageTo(z.Logic)}$logic(){let t=this.entity.tryToGetLight(),r=t!=null?t.updateCount:-1;if(!(this.ir===this.rt&&this.nr===T.getUpdateCount(this.i)&&this.or===r&&this.sr===j(this.i))){if(this.isSyncToLight&&b.exist(t)){if(this._eyeInner.copyComponents(n._eye),this._directionInner.copyComponents(this._direction),this._upInner.copyComponents(this._up),t.type===C.Spot)this.type=m.Perspective,this.setFovyAndChangeFilmSize(l.radianToDegree(t.outerConeAngle*2)),this._cornerInner.copyComponents(this._corner),this.aspect=1,this.zNear=t.shadowZNearForSpotLight,this.zFar=t.range!==-1?t.range:100,this._parametersInner.copyComponents(this._parameters);else if(t.type===C.Directional){this.type=m.Orthographic;let e=t.shadowAreaSizeForDirectionalLight;this._cornerInner.copyComponents(E.fromCopy4(-e,e,e,-e)),this.aspect=1,this.zNear=t.shadowZNearForDirectionalLight,this.zFar=t.range!==-1?t.range:100,this._parametersInner.x=this.zNear,this._parametersInner.y=this.zFar,this._parametersInner.z=e,this._parametersInner.w=e}}else{let e=this.entity.tryToGetCameraController();b.exist(e)?this._parametersInner.w=this._parameters.w:this.primitiveMode||(this._eyeInner.copyComponents(n._eye),this._directionInner.copyComponents(this._direction),this._upInner.copyComponents(this._up),this._cornerInner.copyComponents(this._corner),this._parametersInner.copyComponents(this._parameters))}if(this.calcViewMatrix(),this._xrLeft||this._xrRight){let e=this.i._webXRSystemIfEnabled;e!=null&&e.isWebXRMode&&(this._xrLeft?this._projectionMatrix.copyComponents(e.leftProjectionMatrix):this._xrRight&&this._projectionMatrix.copyComponents(e.rightProjectionMatrix))}else this.calcProjectionMatrix();this.hr(),this.ir=this.rt,this.nr=T.getUpdateCount(this.i),this.or=r,this.sr=j(this.i)}}get entity(){return this.i.entityRepository.getEntity(this.gn)}addThisComponentToEntity(t,r){class e extends t.constructor{getCamera(){return this.getComponentByComponentTID(f.CameraComponentTID)}}return V(t,e),t}static _cleanupForEngine(t){n.Ye.delete(t.engineUid)}};n._eye=y.zero(),n.Ye=new Map,n.returnVector3=s.zero(),n.tr=s.zero(),n.Ze=s.zero(),n.$e=s.zero(),n.Ge=h.zero(),n.er=h.zero(),n.ar=v.fromCopy16ColumnMajor(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),n.pr=v.fromCopy16ColumnMajor(.5,0,0,0,0,-.5,0,0,0,0,1,0,.5,.5,0,1);var u=n;u.registerMember({bufferUse:_.GPUInstanceData,memberName:"viewMatrix",dataClassType:h,shaderType:x.VertexAndPixelShader,compositionType:I.Mat4,componentType:g.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"projectionMatrix",dataClassType:h,shaderType:x.VertexAndPixelShader,compositionType:I.Mat4,componentType:g.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"viewPosition",dataClassType:s,shaderType:x.VertexAndPixelShader,compositionType:I.Vec3,componentType:g.Float,initValues:[0,0,0]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"lightClusterViewInfo",dataClassType:c,shaderType:x.VertexAndPixelShader,compositionType:I.Vec4,componentType:g.Float,initValues:[-1,0,0,0]});export{u as CameraComponent};
1
+ import{Component as w}from"../../core/Component.js";import{applyMixins as V}from"../../core/EntityRepository.js";import{BufferUse as _}from"../../definitions/BufferUse.js";import{CameraType as m}from"../../definitions/CameraType.js";import{ComponentType as g}from"../../definitions/ComponentType.js";import{CompositionType as I}from"../../definitions/CompositionType.js";import{LightType as C}from"../../definitions/LightType.js";import{ProcessStage as z}from"../../definitions/ProcessStage.js";import{RenderBackend as d}from"../../definitions/RenderBackend.js";import{ShaderType as x}from"../../definitions/ShaderType.js";import{Frustum as D}from"../../geometry/Frustum.js";import{MathUtil as l}from"../../math/MathUtil.js";import{Matrix44 as v}from"../../math/Matrix44.js";import{MutableMatrix44 as h}from"../../math/MutableMatrix44.js";import{MutableVector2 as E}from"../../math/MutableVector2.js";import{MutableVector3 as s}from"../../math/MutableVector3.js";import{MutableVector4 as c}from"../../math/MutableVector4.js";import{Vector3 as y}from"../../math/Vector3.js";import{Vector4 as P}from"../../math/Vector4.js";import{Is as b}from"../../misc/Is.js";import{_getCameraControllerUpdateCount as j}from"../CameraController/CameraControllerUpdateCount.js";import{TransformComponent as T}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as f}from"../WellKnownComponentTIDs.js";var n=class n extends w{constructor(t,r,e,i,o){super(t,r,e,i,o);this._eyeInner=s.zero();this._direction=s.fromCopy3(0,0,-1);this._directionInner=s.fromCopy3(0,0,-1);this._up=s.fromCopy3(0,1,0);this._upInner=s.fromCopy3(0,1,0);this._filmWidth=36;this._filmHeight=24;this._focalLength=20;this.primitiveMode=!1;this._corner=c.fromCopy4(-1,1,1,-1);this._cornerInner=c.fromCopy4(-1,1,1,-1);this._parameters=c.fromCopy4(.1,1e4,90,1);this._parametersInner=c.fromCopy4(.1,1e4,90,1);this.Qe=m.Perspective;this._projectionMatrix=h.dummy();this.He=h.identity();this.Xe=!1;this.Ne=E.zero();this._viewMatrix=h.dummy();this._viewPosition=s.dummy();this._lightClusterViewInfo=c.dummy();this._xrLeft=!1;this._xrRight=!1;this.isSyncToLight=!1;this.rr=new D;this.rt=0;this.ir=-1;this.nr=-1;this.or=-1;this.sr=-1;this.setFovyAndChangeFocalLength(90),n.getCurrent(t)===-1&&n.setCurrent(t,e),this.submitToAllocation(t.config.cameraComponentCountPerBufferView,o)}static getCurrent(t){var r;return(r=this.Ye.get(t.engineUid))!=null?r:-1}static setCurrent(t,r){this.Ye.set(t.engineUid,r)}get updateCount(){return this.rt}static getCurrentCameraUpdateCount(t){var e;let r=t.componentRepository.getComponent(n,n.getCurrent(t));return(e=r==null?void 0:r.updateCount)!=null?e:0}set type(t){this.Qe=t,t===m.Orthographic?(this._parameters.z=1,this._parameters.w=1,this._parametersInner.z=1,this._parametersInner.w=1):(this.setFovyAndChangeFocalLength(90),this._parameters.w=1,this._parametersInner.z=90,this._parametersInner.w=1),this.rt++}get type(){return this.Qe}get eye(){return n._eye}set eye(t){throw Error("In Rhodonite, eye is always (0,0,0). Use TransformComponent for Camera positioning.")}get eyeInner(){return this._eyeInner}set eyeInner(t){this._eyeInner.copyComponents(t),this.rt++}set upInner(t){this._upInner.copyComponents(t),this.rt++}set up(t){this._up.copyComponents(t),this.rt++}get up(){return this._up.clone()}get upInner(){return this._upInner}set direction(t){let r=this._direction,e=t,i=this._up,p=s.crossTo(e,i,n.tr).length()===0,a;if(p){let M=s.crossTo(r,i,n.Ze);a=s.crossTo(M,e,n.$e)}else{let M=s.multiplyTo(e,e.dot(i),n.Ze);a=s.subtractTo(i,M,n.$e)}this._up.copyComponents(a).normalize(),this._direction.copyComponents(e),this.rt++}set directionInner(t){this._directionInner.copyComponents(t),this.rt++}get direction(){return this._direction.clone()}get directionInner(){return this._directionInner}set corner(t){this._corner.copyComponents(t),this.rt++}get corner(){return this._corner.clone()}set left(t){this._corner.x=t,this.rt++}set leftInner(t){this._cornerInner.x=t,this.rt++}get left(){return this._corner.x}set right(t){this._corner.y=t,this.rt++}set rightInner(t){this._cornerInner.y=t,this.rt++}get right(){return this._corner.y}set top(t){this._corner.z=t,this.rt++}set topInner(t){this._cornerInner.z=t,this.rt++}get top(){return this._corner.z}set bottom(t){this._corner.w=t,this.rt++}set bottomInner(t){this._cornerInner.w=t,this.rt++}get bottom(){return this._corner.w}set cornerInner(t){this._cornerInner.copyComponents(t),this.rt++}get cornerInner(){return this._cornerInner}set parametersInner(t){this._parametersInner.copyComponents(t),this.rt++}get parametersInner(){return this._parametersInner}get parameters(){return this._parameters.clone()}set zNear(t){this._parameters.x=t,this.rt++}set zNearInner(t){this._parametersInner.x=t,this.rt++}get zNearInner(){return this._parametersInner.x}get zNear(){return this._parameters.x}set focalLength(t){this._focalLength=t,this._parameters.z=2*l.radianToDegree(Math.atan(this._filmHeight/(t*2))),this.rt++}get focalLength(){return this._focalLength}set focalLengthInner(t){this._parametersInner.z=2*l.radianToDegree(Math.atan(this._filmHeight/(t*2))),this.rt++}get focalLengthInner(){return this._parametersInner.z}set zFar(t){this._parameters.y=t,this.rt++}set zFarInner(t){this._parametersInner.y=t,this.rt++}get zFarInner(){return this._parametersInner.y}get zFar(){return this._parameters.y}setFovyAndChangeFilmSize(t){this._parameters.z=t,this._filmHeight=2*this.focalLength*Math.tan(l.degreeToRadian(t)/2),this._filmWidth=this._filmHeight*this.aspect,this.rt++}setFovyAndChangeFocalLength(t){this._parameters.z=t,this._focalLength=this._filmHeight/2/Math.tan(l.degreeToRadian(t)/2),this.rt++}get fovy(){return this._parameters.z}set fovyInner(t){this._parametersInner.z=t,this.rt++}set aspect(t){this._parameters.w=t,this._filmWidth=this._filmHeight*t,this.rt++}set aspectInner(t){this._parametersInner.w=t,this.rt++}get aspectInner(){return this._parametersInner.w}get aspect(){return this._parameters.w}set xMag(t){this._parameters.z=t,this.rt++}get xMag(){return this._parameters.z}set yMag(t){this._parameters.w=t}get yMag(){return this._parameters.w}static get componentTID(){return f.CameraComponentTID}get componentTID(){return f.CameraComponentTID}calcProjectionMatrix(){let t=this._parametersInner.x,r=this._parametersInner.y;if(this.i.engineState.currentRenderBackend===d.WebGPU)if(this.type===m.Perspective){let e=this._parametersInner.z,i=this._parametersInner.w;i<0&&(i=this.i.engineState.viewportAspectRatio);let o=1/Math.tan(.5*e*Math.PI/180),p=o/i;if(this._projectionMatrix.m00=p,this._projectionMatrix.m01=0,this._projectionMatrix.m02=0,this._projectionMatrix.m03=0,this._projectionMatrix.m10=0,this._projectionMatrix.m11=o,this._projectionMatrix.m12=0,this._projectionMatrix.m13=0,this._projectionMatrix.m20=0,this._projectionMatrix.m21=0,r===Number.POSITIVE_INFINITY)this._projectionMatrix.m22=-1,this._projectionMatrix.m23=-t;else{let a=1/(t-r);this._projectionMatrix.m22=r*a,this._projectionMatrix.m23=r*t*a}this._projectionMatrix.m30=0,this._projectionMatrix.m31=0,this._projectionMatrix.m32=-1,this._projectionMatrix.m33=0}else if(this.type===m.Orthographic){let e=this._parametersInner.z,i=this._parametersInner.w;this._projectionMatrix.setComponents(1/e,0,0,0,0,1/i,0,0,0,0,-1/(r-t),-t/(r-t),0,0,0,1)}else{let e=this._cornerInner.x,i=this._cornerInner.y,o=this._cornerInner.z,p=this._cornerInner.w,a=1/(t-r);this._projectionMatrix.setComponents(2*t/(i-e),0,(i+e)/(i-e),0,0,2*t/(o-p),(o+p)/(o-p),0,0,0,r*a,r*t*a,0,0,-1,0)}else if(this.type===m.Perspective){let e=this._parametersInner.z,i=this._parametersInner.w;i<0&&(i=this.i.engineState.viewportAspectRatio);let o=1/Math.tan(.5*e*Math.PI/180),p=o/i;if(this._projectionMatrix.m00=p,this._projectionMatrix.m01=0,this._projectionMatrix.m02=0,this._projectionMatrix.m03=0,this._projectionMatrix.m10=0,this._projectionMatrix.m11=o,this._projectionMatrix.m12=0,this._projectionMatrix.m13=0,this._projectionMatrix.m20=0,this._projectionMatrix.m21=0,r===Number.POSITIVE_INFINITY)this._projectionMatrix.m22=-1,this._projectionMatrix.m23=-2*t;else{let a=1/(t-r);this._projectionMatrix.m22=(r+t)*a,this._projectionMatrix.m23=2*r*t*a}this._projectionMatrix.m30=0,this._projectionMatrix.m31=0,this._projectionMatrix.m32=-1,this._projectionMatrix.m33=0}else if(this.type===m.Orthographic){let e=this._parametersInner.z,i=this._parametersInner.w;this._projectionMatrix.setComponents(1/e,0,0,0,0,1/i,0,0,0,0,-2/(r-t),-(r+t)/(r-t),0,0,0,1)}else{let e=this._cornerInner.x,i=this._cornerInner.y,o=this._cornerInner.z,p=this._cornerInner.w,a=1/(t-r);this._projectionMatrix.setComponents(2*t/(i-e),0,(i+e)/(i-e),0,0,2*t/(o-p),(o+p)/(o-p),0,0,0,(r+t)*a,2*r*t*a,0,0,-1,0)}return this.He.copyComponents(this._projectionMatrix),this.Xe=!0,this.qe(),this._projectionMatrix}qe(){let t=this.Ne.x,r=this.Ne.y,e=this.He,i=this._projectionMatrix;if(t===0&&r===0){i.copyComponents(e);return}i.copyComponents(e),i.m00=e.m00+t*e.m30,i.m01=e.m01+t*e.m31,i.m02=e.m02+t*e.m32,i.m03=e.m03+t*e.m33,i.m10=e.m10+r*e.m30,i.m11=e.m11+r*e.m31,i.m12=e.m12+r*e.m32,i.m13=e.m13+r*e.m33}get jitterOffset(){return this.Ne}set jitterOffset(t){this.Ne.x===t.x&&this.Ne.y===t.y||(this.Ne.setComponents(t.x,t.y),!(this._xrLeft||this._xrRight||!this.Xe)&&(this.qe(),this.i._markGpuInstanceDataDirty()))}get projectionMatrixWithoutJitter(){return this.He}calcViewMatrix(){let t=this.eyeInner,r=s.subtractTo(this._directionInner,t,n.tr).normalize(),e=s.crossTo(r,this._upInner,n.Ze).normalize(),i=s.crossTo(e,r,n.$e);if(this._viewMatrix.setComponents(e.x,e.y,e.z,-y.dot(e,t),i.x,i.y,i.z,-y.dot(i,t),-r.x,-r.y,-r.z,y.dot(r,t),0,0,0,1),!this.primitiveMode){let o=h.invertTo(this.entity.getSceneGraph().matrixInner,n.Ge);this._viewMatrix.multiply(o)}return this._viewMatrix}get viewMatrix(){return this._viewMatrix}set viewMatrix(t){this._viewMatrix.copyComponents(t),this.rt++}get projectionMatrix(){if(this._xrLeft||this._xrRight){let t=this.i._webXRSystemIfEnabled;if(t!=null&&t.isWebXRMode){if(this._xrLeft)return t.leftProjectionMatrix;if(this._xrRight)return t.rightProjectionMatrix}}return this._projectionMatrix}set projectionMatrix(t){this.He.copyComponents(t),this.Xe=!0,this.qe(),this.rt++}get _projectionMatrixForGpu(){return this._projectionMatrix}get _lightClusterViewInfoForGpu(){return this._lightClusterViewInfo}get viewProjectionMatrix(){return h.multiplyTo(this._projectionMatrix,this._viewMatrix,n.Ge)}get biasViewProjectionMatrix(){return h.multiplyTo(this._projectionMatrix,this._viewMatrix,n.Ge),this.i.engineState.currentRenderBackend===d.WebGPU?h.multiplyTo(n.pr,n.Ge,n.er):h.multiplyTo(n.ar,n.Ge,n.er)}hr(){this._viewPosition.copyComponents(this.worldPosition)}get worldPosition(){return this.entity.getSceneGraph().matrixInner.multiplyVector3To(this.eyeInner,n.returnVector3),n.returnVector3}updateFrustum(){this.rr.update(this.viewMatrix,this.projectionMatrix)}get frustum(){return this.rr}$load(){this.moveStageTo(z.Logic)}$logic(){let t=this.entity.tryToGetLight(),r=t!=null?t.updateCount:-1;if(!(this.ir===this.rt&&this.nr===T.getUpdateCount(this.i)&&this.or===r&&this.sr===j(this.i))){if(this.isSyncToLight&&b.exist(t)){if(this._eyeInner.copyComponents(n._eye),this._directionInner.copyComponents(this._direction),this._upInner.copyComponents(this._up),t.type===C.Spot)this.type=m.Perspective,this.setFovyAndChangeFilmSize(l.radianToDegree(t.outerConeAngle*2)),this._cornerInner.copyComponents(this._corner),this.aspect=1,this.zNear=t.shadowZNearForSpotLight,this.zFar=t.range!==-1?t.range:100,this._parametersInner.copyComponents(this._parameters);else if(t.type===C.Directional){this.type=m.Orthographic;let e=t.shadowAreaSizeForDirectionalLight;this._cornerInner.copyComponents(P.fromCopy4(-e,e,e,-e)),this.aspect=1,this.zNear=t.shadowZNearForDirectionalLight,this.zFar=t.range!==-1?t.range:100,this._parametersInner.x=this.zNear,this._parametersInner.y=this.zFar,this._parametersInner.z=e,this._parametersInner.w=e}}else{let e=this.entity.tryToGetCameraController();b.exist(e)?this._parametersInner.w=this._parameters.w:this.primitiveMode||(this._eyeInner.copyComponents(n._eye),this._directionInner.copyComponents(this._direction),this._upInner.copyComponents(this._up),this._cornerInner.copyComponents(this._corner),this._parametersInner.copyComponents(this._parameters))}if(this.calcViewMatrix(),this._xrLeft||this._xrRight){let e=this.i._webXRSystemIfEnabled;e!=null&&e.isWebXRMode&&(this._xrLeft?this._projectionMatrix.copyComponents(e.leftProjectionMatrix):this._xrRight&&this._projectionMatrix.copyComponents(e.rightProjectionMatrix))}else this.calcProjectionMatrix();this.hr(),this.ir=this.rt,this.nr=T.getUpdateCount(this.i),this.or=r,this.sr=j(this.i)}}get entity(){return this.i.entityRepository.getEntity(this.gn)}addThisComponentToEntity(t,r){class e extends t.constructor{getCamera(){return this.getComponentByComponentTID(f.CameraComponentTID)}}return V(t,e),t}static _cleanupForEngine(t){n.Ye.delete(t.engineUid)}};n._eye=y.zero(),n.Ye=new Map,n.returnVector3=s.zero(),n.tr=s.zero(),n.Ze=s.zero(),n.$e=s.zero(),n.Ge=h.zero(),n.er=h.zero(),n.ar=v.fromCopy16ColumnMajor(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),n.pr=v.fromCopy16ColumnMajor(.5,0,0,0,0,-.5,0,0,0,0,1,0,.5,.5,0,1);var u=n;u.registerMember({bufferUse:_.GPUInstanceData,memberName:"viewMatrix",dataClassType:h,shaderType:x.VertexAndPixelShader,compositionType:I.Mat4,componentType:g.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"projectionMatrix",dataClassType:h,shaderType:x.VertexAndPixelShader,compositionType:I.Mat4,componentType:g.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"viewPosition",dataClassType:s,shaderType:x.VertexAndPixelShader,compositionType:I.Vec3,componentType:g.Float,initValues:[0,0,0]});u.registerMember({bufferUse:_.GPUInstanceData,memberName:"lightClusterViewInfo",dataClassType:c,shaderType:x.VertexAndPixelShader,compositionType:I.Vec4,componentType:g.Float,initValues:[-1,0,0,0]});export{u as CameraComponent};
@@ -2,7 +2,7 @@ import type { CGAPIResourceHandle, ComponentSID, ComponentTID, Count, EntityUID,
2
2
  import { Component } from '../../core/Component';
3
3
  import type { IEntity } from '../../core/Entity';
4
4
  import { type EntityRepository } from '../../core/EntityRepository';
5
- import { type ProcessApproachEnum } from '../../definitions/ProcessApproach';
5
+ import { type RenderBackendEnum } from '../../definitions/RenderBackend';
6
6
  import type { RenderPass } from '../../renderer/RenderPass';
7
7
  import type { Engine } from '../../system/Engine';
8
8
  import type { CubeTexture } from '../../textures/CubeTexture';
@@ -180,12 +180,12 @@ export declare class MeshRendererComponent extends Component {
180
180
  */
181
181
  setIBLCubeMap(diffuseCubeTexture: CubeTexture | RenderTargetTextureCube, specularCubeTexture: CubeTexture | RenderTargetTextureCube, sheenCubeTexture?: CubeTexture | RenderTargetTextureCube): void;
182
182
  /**
183
- * Common loading method that initializes the rendering strategy based on the process approach.
183
+ * Common loading method that initializes the rendering strategy based on the render backend.
184
184
  * This method sets up either WebGPU or WebGL rendering strategies.
185
- * @param processApproach - The graphics API approach to use (WebGPU or WebGL)
185
+ * @param renderBackend - The render backend to use (WebGPU or WebGL)
186
186
  */
187
- static common_$load({ processApproach, engine }: {
188
- processApproach: ProcessApproachEnum;
187
+ static common_$load({ renderBackend, engine }: {
188
+ renderBackend: RenderBackendEnum;
189
189
  engine: Engine;
190
190
  }): void;
191
191
  /**
@@ -1 +1 @@
1
- import{getMultiDrawStateKeyId as A,getPrimitiveMeshRendererFingerPrintId as w}from"../../../webgl/MultiDraw.js";import{Component as G}from"../../core/Component.js";import{applyMixins as B}from"../../core/EntityRepository.js";import{ProcessApproach as M}from"../../definitions/ProcessApproach.js";import{ProcessStage as E}from"../../definitions/ProcessStage.js";import{isBlend as P,isBlendWithoutZWrite as T,isBlendWithZWrite as U,isTranslucent as Z}from"../../geometry/types/GeometryTypes.js";import{ModuleManager as j}from"../../system/ModuleManager.js";import{CameraComponent as v}from"../Camera/CameraComponent.js";import{_getCameraControllerUpdateCount as W}from"../CameraController/CameraControllerUpdateCount.js";import{SceneGraphComponent as D}from"../SceneGraph/SceneGraphComponent.js";import{TransformComponent as x}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as k}from"../WellKnownComponentTIDs.js";var n=class n extends G{constructor(t,e,o,i,a){super(t,e,o,i,a);this.ki=1;this.Ei=1;this.Ui=0;this.rt=0;this.Nn="";this.Wi=0;this.calcFingerPrint()}static get componentTID(){return k.MeshRendererComponentTID}get componentTID(){return k.MeshRendererComponentTID}get diffuseCubeMap(){return this.Zn}get specularCubeMap(){return this.jn}get sheenCubeMap(){return this.$n}get updateCount(){return this.rt}static get updateCount(){return n.rt}static get hasPendingLoad(){return n.Xn.size>0}markNeedsLoad(){this.rt++,n.rt++,n.Xn.add(this),this.moveStageTo(E.Load)}Qn(){n.Xn.delete(this)}get diffuseCubeMapContribution(){return this.ki}set diffuseCubeMapContribution(t){this.ki=t,this.rt++,n.rt++}get specularCubeMapContribution(){return this.Ei}set specularCubeMapContribution(t){this.Ei=t,this.rt++,n.rt++}get rotationOfCubeMap(){return this.Ui}set rotationOfCubeMap(t){this.Ui=t,this.rt++,n.rt++}calcFingerPrint(){this.Nn=`${this.Zn!=null?this.Zn.textureUID:-1} ${this.jn!=null?this.jn.textureUID:-1} ${this.$n!=null?this.$n.textureUID:-1}`,this.Wi=n.Pi(this.Nn)}static Pi(t){let e=n.xi.get(t);return e==null&&(e=++n.Bi,n.xi.set(t,e)),e}getFingerPrint(){return this.Nn}getFingerPrintId(){return this.Wi}setIBLCubeMap(t,e,o){t==null||e==null||(this.Zn=t,this.jn=e,this.$n=o,this.calcFingerPrint(),this.rt++,n.rt++)}static common_$load({processApproach:t,engine:e}){let o=j.getInstance(),i=e.objectUID;if(t===M.WebGPU){let u=o.getModule("webgpu");n.Wn.has(i)||n.Wn.set(i,u.WebGpuStrategyBasic.init(e)),n.Wn.get(i).common_$load()}else{let u=o.getModule("webgl");n.Wn.has(i)||n.Wn.set(i,u.getRenderingStrategy(e,t)),n.Wn.get(i).common_$load()}}$load(){let t=this.entity.tryToGetMesh();if((t==null?void 0:t.mesh)==null){this.Qn();return}let e=n.Wn.get(this.i.objectUID);e==null||!e.$load(t)||(this.rt++,n.rt++,this.Qn(),this.moveStageTo(E.Unknown))}static sort_$render(t,e){var y;let o=t.webglResourceRepository,i=o!=null?o.getMultiDrawRepository(t).version:0,a=n.Zi(e),u=n._isGpuCullingActive(t,e);if(x.getUpdateCount(t)===e._lastTransformComponentsUpdateCount&&W(t)===e._lastCameraControllerComponentsUpdateCount&&D.getUpdateCount(t)===e._lastSceneGraphComponentsUpdateCount&&i===e._lastMultiDrawGroupVersion&&u===a.isGpuCullingActive&&t.config.isComputeSkinningEnabled===a.isComputeSkinningEnabled)return e._lastPrimitiveUids;a.isGpuCullingActive=u,a.isComputeSkinningEnabled=t.config.isComputeSkinningEnabled;let d=e.cameraComponent;if(d==null&&(d=t.componentRepository.getComponent(v,v.getCurrent(t))),d==null&&(d=t.componentRepository.getComponentsWithType(v).find(m=>m==null?void 0:m._isAlive),v.setCurrent(t,d.componentSID)),e.isVrRendering){let r=t._webXRSystemIfEnabled;r!=null&&r.isWebXRMode&&(d=r._getCameraComponentAt(0))}let s=n.ji(d,e._optimizedMeshComponents,a.primitives,a,u);n.Vi(s,a),s.length>1&&s.sort(n.$i);let l=s.length-1,c=s.length-1,C=s.length-1,p=s.length-1;for(let r=0;r<s.length;r++){let m=s[r];if(Z(m)){l=r-1;break}if(U(m)){l=r-1;break}if(T(m)){l=r-1;break}}for(let r=l+1;r<s.length;r++){let m=s[r];if(U(m)){c=r-1;break}if(T(m)){c=r-1;break}}for(let r=c+1;r<s.length;r++){let m=s[r];if(T(m)){C=r-1;break}}if(l>0&&t.config.isMultiDrawEnabled&&M.isWebGL2Approach(t.engineState.currentProcessApproach)){let r=l+1,m=a.keyedPrimitives;if(m.length<r)for(let h=m.length;h<r;h++)m.push({primitive:null,keyId:0,index:0});else m.length=r;for(let h=0;h<r;h++){let b=s[h],I=e.getAppropriateMaterial(b),S=m[h];S.primitive=b,S.index=h,S.keyId=(y=A(b,I,w(b)))!=null?y:-(I.materialUID+1)}m.sort((h,b)=>h.keyId-b.keyId||h.index-b.index);for(let h=0;h<r;h++)s[h]=m[h].primitive}let g=n.Fi(s),f=!1;if(l!==e._lastOpaqueIndex&&(e._lastOpaqueIndex=l,f||(f=!0)),c!==e._lastTranslucentIndex&&(e._lastTranslucentIndex=c,f||(f=!0)),C!==e._lastBlendWithZWriteIndex&&(e._lastBlendWithZWriteIndex=C,f||(f=!0)),p!==e._lastBlendWithoutZWriteIndex&&(e._lastBlendWithoutZWriteIndex=p,f||(f=!0)),g.length!==e._lastPrimitiveUids.length)f||(f=!0);else{let r=e._lastPrimitiveUids;for(let m=0;m<g.length;m++)if(g[m]!==r[m]){f||(f=!0);break}}return e._isChangedSortRenderResult=f,e._lastPrimitiveUids=g,e._lastPrimitives=s,e._lastTransformComponentsUpdateCount=x.getUpdateCount(t),e._lastCameraControllerComponentsUpdateCount=W(t),e._lastSceneGraphComponentsUpdateCount=D.getUpdateCount(t),e._lastMultiDrawGroupVersion=i,f&&(e._renderedSomethingBefore=!0),g}static ji(t,e,o,i,a){var c;o.length=0;let u=i.cullTick+1;u===4294967295&&(i.culledEntityStamp.fill(0),i.handledEntityStamp.fill(0),i.meshCullTick=new WeakMap,i.meshAppendTick=new WeakMap,u=1),i.cullTick=u,i.culledEntityCount=0;let d=i.culledInstancedMeshComponents;d.length=0,i.cullingId=++n.Gi;let s=t!=null&&n._isFrustumCullingEnabled,l;s&&(t.updateFrustum(),l=t.frustum);for(let C=0;C<e.length;C++){let p=e[C];if(!p._isAlive)continue;let g=p.entity;if(g==null)continue;let f=g.getSceneGraph();if(i.handledEntityStamp=n.Ri(i.handledEntityStamp,p.entityUID,u),a&&((c=p.mesh)==null?void 0:c._isGpuCullable)===!0){f._isCulled=!1;let y=p.entity.tryToGetSkeletal();if(y!==void 0){let r=f.isVisible;r&&l!=null&&p.entity.getTagValue("type")!=="background-assets"&&(r=l.culling(p)),y._isCulled=!r}n.Yn(p,t,o),n.Ai(p,i,u);continue}if(!f.isVisible){n.Mi(i,p.entityUID,u),n.wi(p,i);continue}if(l!=null){let r=p.entity.getTagValue("type")==="background-assets"?!0:l.culling(p);f._isCulled=!r;let m=p.entity.tryToGetSkeletal();if(m!==void 0&&(m._isCulled=!r),!r){n.Mi(i,p.entityUID,u),n.wi(p,i);continue}}n.Yn(p,t,o),n.Ai(p,i,u)}return n.Oi(e,l,i,u,a),n.qi(t,o,i,u),o}static Oi(t,e,o,i,a){for(let u=0;u<t.length;u++){let d=t[u];if(!d._isAlive)continue;let s=d.mesh;if(s===void 0||a&&s._isGpuCullable)continue;let l=s.meshEntitiesInner;if(!(l.length<=1||o.meshCullTick.get(s)===i)){o.meshCullTick.set(s,i);for(let c=0;c<l.length;c++){let C=l[c],p=C.entityUID;if(p<o.handledEntityStamp.length&&o.handledEntityStamp[p]===i)continue;let g=C.getSceneGraph().isVisible;g&&e!=null&&C.getTagValue("type")!=="background-assets"&&(g=e.culling(C.getMesh())),g||n.Mi(o,p,i)}}}}static wi(t,e){let o=t.mesh;o!==void 0&&o.meshEntitiesInner.length>1&&e.culledInstancedMeshComponents.push(t)}static Ai(t,e,o){let i=t.mesh;i!==void 0&&e.meshAppendTick.set(i,o)}static qi(t,e,o,i){let a=o.culledInstancedMeshComponents,u=o.culledEntityStamp;for(let d=0;d<a.length;d++){let s=a[d],l=s.mesh;if(l===void 0||o.meshAppendTick.get(l)===i)continue;o.meshAppendTick.set(l,i);let c=l.meshEntitiesInner,C=!1;for(let p=0;p<c.length;p++){let g=c[p].entityUID;if(g>=u.length||u[g]!==i){C=!0;break}}C&&n.Yn(s,t,e)}a.length=0}static Mi(t,e,o){t.culledEntityStamp=n.Ri(t.culledEntityStamp,e,o),t.culledEntityCount++}static Ri(t,e,o){let i=t;return e>=t.length&&(i=new Uint32Array(Math.max(e+1,t.length*2,64)),i.set(t)),i[e]=o,i}static _isGpuCullingActive(t,e){if(!t.config.isGpuCullingEnabled||!n._isFrustumCullingEnabled||!M.isWebGpuApproach(t.engineState.currentProcessApproach)||e.isBufferLessRenderingMode())return!1;let o=t._webXRSystemIfEnabled;return!(e.isVrRendering&&(o!=null&&o.isWebXRMode)&&o.isMultiView())}static _getInstanceCullingState(t){let e=n.Kn.get(t);if(!(e===void 0||e.cullTick===0))return e}static Yn(t,e,o){let i=t.mesh;if(i===void 0)return;let a=i.primitives,u=a.length,d=!1;for(let s=0;s<u;s++){let l=a[s];o.push(l),!d&&P(l)&&(d=!0)}if(d){let s=t.calcViewDepth(e);for(let l=0;l<u;l++)a[l]._viewDepth=s}}static Vi(t,e){let o=t.length;if(o<=1)return;let i=e.stamp,a=e.stampTick+1;a===4294967295&&(i.fill(0),a=1),e.stampTick=a;let u=0;for(let d=0;d<o;d++){let s=t[d],l=s.primitiveUid;if(l<0){t[u++]=s;continue}if(l>=i.length){let c=new Uint32Array(Math.max(l+1,i.length*2,64));c.set(i),e.stamp=c,i=c}i[l]!==a&&(i[l]=a,t[u++]=s)}t.length=u}static $i(t,e){let o=t._sortkey-e._sortkey;return o!==0?o:t._viewDepth-e._viewDepth}static Fi(t){let e=t.length,o=new Array(e+1);for(let i=0;i<e;i++)o[i]=t[i].primitiveUid;return o[e]=-1,o}static Zi(t){let e=n.Kn.get(t);return e===void 0&&(e={primitives:[],stamp:new Uint32Array(64),stampTick:0,culledEntityStamp:new Uint32Array(64),handledEntityStamp:new Uint32Array(64),meshCullTick:new WeakMap,cullTick:0,culledEntityCount:0,cullingId:0,keyedPrimitives:[],isGpuCullingActive:void 0,isComputeSkinningEnabled:void 0,culledInstancedMeshComponents:[],meshAppendTick:new WeakMap},n.Kn.set(t,e)),e}static common_$prerender(t){let e=t.objectUID,o=n.Jn;if(o===void 0||n.On!==e){if(o=n.Wn.get(e),o===void 0){let i=t.engineState.currentProcessApproach;if(this.common_$load({processApproach:i,engine:t}),o=n.Wn.get(e),o===void 0)return}n.On=e,n.Jn=o}o.prerender()}static common_$render({renderPass:t,renderPassTickCount:e,primitiveUids:o,displayIdx:i,engine:a}){return n.Wn.get(a.objectUID).common_$render(o,t,e,i)}$render(){}_shallowCopyFrom(t){let e=t;this.Zn=e.Zn,this.jn=e.jn,this.diffuseCubeMapContribution=e.diffuseCubeMapContribution,this.specularCubeMapContribution=e.specularCubeMapContribution,this.rotationOfCubeMap=e.rotationOfCubeMap}_destroy(){super._destroy(),this.Qn(),this.Zn=void 0,this.jn=void 0}addThisComponentToEntity(t,e){class o extends t.constructor{getMeshRenderer(){return this.getComponentByComponentTID(k.MeshRendererComponentTID)}}return B(t,o),t}static _cleanupForEngine(t){let e=n.Wn.get(t.objectUID);e!=null&&e.destroy(),n.Wn.delete(t.objectUID),n.On===t.objectUID&&(n.On=-1,n.Jn=void 0)}};n.Wn=new Map,n.Ni=new Map,n.rt=0,n._isFrustumCullingEnabled=!0,n.Gi=0,n.xi=new Map,n.Bi=0,n.Xn=new Set,n.Kn=new WeakMap,n.On=-1;var R=n;export{R as MeshRendererComponent};
1
+ import{getMultiDrawStateKeyId as w,getPrimitiveMeshRendererFingerPrintId as G}from"../../../webgl/MultiDraw.js";import{Component as A}from"../../core/Component.js";import{applyMixins as B}from"../../core/EntityRepository.js";import{ProcessStage as E}from"../../definitions/ProcessStage.js";import{RenderBackend as M}from"../../definitions/RenderBackend.js";import{isBlend as Z,isBlendWithoutZWrite as k,isBlendWithZWrite as U,isTranslucent as j}from"../../geometry/types/GeometryTypes.js";import{ModuleManager as P}from"../../system/ModuleManager.js";import{CameraComponent as v}from"../Camera/CameraComponent.js";import{_getCameraControllerUpdateCount as W}from"../CameraController/CameraControllerUpdateCount.js";import{SceneGraphComponent as R}from"../SceneGraph/SceneGraphComponent.js";import{TransformComponent as D}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as T}from"../WellKnownComponentTIDs.js";var n=class n extends A{constructor(t,e,o,i,a){super(t,e,o,i,a);this.ki=1;this.Ei=1;this.Ui=0;this.rt=0;this.Nn="";this.Wi=0;this.calcFingerPrint()}static get componentTID(){return T.MeshRendererComponentTID}get componentTID(){return T.MeshRendererComponentTID}get diffuseCubeMap(){return this.Zn}get specularCubeMap(){return this.jn}get sheenCubeMap(){return this.$n}get updateCount(){return this.rt}static get updateCount(){return n.rt}static get hasPendingLoad(){return n.Xn.size>0}markNeedsLoad(){this.rt++,n.rt++,n.Xn.add(this),this.moveStageTo(E.Load)}Qn(){n.Xn.delete(this)}get diffuseCubeMapContribution(){return this.ki}set diffuseCubeMapContribution(t){this.ki=t,this.rt++,n.rt++}get specularCubeMapContribution(){return this.Ei}set specularCubeMapContribution(t){this.Ei=t,this.rt++,n.rt++}get rotationOfCubeMap(){return this.Ui}set rotationOfCubeMap(t){this.Ui=t,this.rt++,n.rt++}calcFingerPrint(){this.Nn=`${this.Zn!=null?this.Zn.textureUID:-1} ${this.jn!=null?this.jn.textureUID:-1} ${this.$n!=null?this.$n.textureUID:-1}`,this.Wi=n.Zi(this.Nn)}static Zi(t){let e=n.Ri.get(t);return e==null&&(e=++n.Bi,n.Ri.set(t,e)),e}getFingerPrint(){return this.Nn}getFingerPrintId(){return this.Wi}setIBLCubeMap(t,e,o){t==null||e==null||(this.Zn=t,this.jn=e,this.$n=o,this.calcFingerPrint(),this.rt++,n.rt++)}static common_$load({renderBackend:t,engine:e}){let o=P.getInstance(),i=e.objectUID;if(t===M.WebGPU){let u=o.getModule("webgpu");n.Wn.has(i)||n.Wn.set(i,u.WebGpuStrategyBasic.init(e)),n.Wn.get(i).common_$load()}else{let u=o.getModule("webgl");n.Wn.has(i)||n.Wn.set(i,u.getRenderingStrategy(e,t)),n.Wn.get(i).common_$load()}}$load(){let t=this.entity.tryToGetMesh();if((t==null?void 0:t.mesh)==null){this.Qn();return}let e=n.Wn.get(this.i.objectUID);e==null||!e.$load(t)||(this.rt++,n.rt++,this.Qn(),this.moveStageTo(E.Unknown))}static sort_$render(t,e){var y;let o=t.webglResourceRepository,i=o!=null?o.getMultiDrawRepository(t).version:0,a=n.ji(e),u=n._isGpuCullingActive(t,e);if(D.getUpdateCount(t)===e._lastTransformComponentsUpdateCount&&W(t)===e._lastCameraControllerComponentsUpdateCount&&R.getUpdateCount(t)===e._lastSceneGraphComponentsUpdateCount&&i===e._lastMultiDrawGroupVersion&&u===a.isGpuCullingActive&&t.config.isComputeSkinningEnabled===a.isComputeSkinningEnabled)return e._lastPrimitiveUids;a.isGpuCullingActive=u,a.isComputeSkinningEnabled=t.config.isComputeSkinningEnabled;let d=e.cameraComponent;if(d==null&&(d=t.componentRepository.getComponent(v,v.getCurrent(t))),d==null&&(d=t.componentRepository.getComponentsWithType(v).find(m=>m==null?void 0:m._isAlive),v.setCurrent(t,d.componentSID)),e.isVrRendering){let r=t._webXRSystemIfEnabled;r!=null&&r.isWebXRMode&&(d=r._getCameraComponentAt(0))}let s=n.Pi(d,e._optimizedMeshComponents,a.primitives,a,u);n.Vi(s,a),s.length>1&&s.sort(n.$i);let l=s.length-1,c=s.length-1,C=s.length-1,p=s.length-1;for(let r=0;r<s.length;r++){let m=s[r];if(j(m)){l=r-1;break}if(U(m)){l=r-1;break}if(k(m)){l=r-1;break}}for(let r=l+1;r<s.length;r++){let m=s[r];if(U(m)){c=r-1;break}if(k(m)){c=r-1;break}}for(let r=c+1;r<s.length;r++){let m=s[r];if(k(m)){C=r-1;break}}if(l>0&&t.config.isMultiDrawEnabled&&M.isWebGL2Backend(t.engineState.currentRenderBackend)){let r=l+1,m=a.keyedPrimitives;if(m.length<r)for(let h=m.length;h<r;h++)m.push({primitive:null,keyId:0,index:0});else m.length=r;for(let h=0;h<r;h++){let b=s[h],I=e.getAppropriateMaterial(b),S=m[h];S.primitive=b,S.index=h,S.keyId=(y=w(b,I,G(b)))!=null?y:-(I.materialUID+1)}m.sort((h,b)=>h.keyId-b.keyId||h.index-b.index);for(let h=0;h<r;h++)s[h]=m[h].primitive}let g=n.Fi(s),f=!1;if(l!==e._lastOpaqueIndex&&(e._lastOpaqueIndex=l,f||(f=!0)),c!==e._lastTranslucentIndex&&(e._lastTranslucentIndex=c,f||(f=!0)),C!==e._lastBlendWithZWriteIndex&&(e._lastBlendWithZWriteIndex=C,f||(f=!0)),p!==e._lastBlendWithoutZWriteIndex&&(e._lastBlendWithoutZWriteIndex=p,f||(f=!0)),g.length!==e._lastPrimitiveUids.length)f||(f=!0);else{let r=e._lastPrimitiveUids;for(let m=0;m<g.length;m++)if(g[m]!==r[m]){f||(f=!0);break}}return e._isChangedSortRenderResult=f,e._lastPrimitiveUids=g,e._lastPrimitives=s,e._lastTransformComponentsUpdateCount=D.getUpdateCount(t),e._lastCameraControllerComponentsUpdateCount=W(t),e._lastSceneGraphComponentsUpdateCount=R.getUpdateCount(t),e._lastMultiDrawGroupVersion=i,f&&(e._renderedSomethingBefore=!0),g}static Pi(t,e,o,i,a){var c;o.length=0;let u=i.cullTick+1;u===4294967295&&(i.culledEntityStamp.fill(0),i.handledEntityStamp.fill(0),i.meshCullTick=new WeakMap,i.meshAppendTick=new WeakMap,u=1),i.cullTick=u,i.culledEntityCount=0;let d=i.culledInstancedMeshComponents;d.length=0,i.cullingId=++n.Ai;let s=t!=null&&n._isFrustumCullingEnabled,l;s&&(t.updateFrustum(),l=t.frustum);for(let C=0;C<e.length;C++){let p=e[C];if(!p._isAlive)continue;let g=p.entity;if(g==null)continue;let f=g.getSceneGraph();if(i.handledEntityStamp=n.xi(i.handledEntityStamp,p.entityUID,u),a&&((c=p.mesh)==null?void 0:c._isGpuCullable)===!0){f._isCulled=!1;let y=p.entity.tryToGetSkeletal();if(y!==void 0){let r=f.isVisible;r&&l!=null&&p.entity.getTagValue("type")!=="background-assets"&&(r=l.culling(p)),y._isCulled=!r}n.Yn(p,t,o),n.wi(p,i,u);continue}if(!f.isVisible){n.Mi(i,p.entityUID,u),n.Gi(p,i);continue}if(l!=null){let r=p.entity.getTagValue("type")==="background-assets"?!0:l.culling(p);f._isCulled=!r;let m=p.entity.tryToGetSkeletal();if(m!==void 0&&(m._isCulled=!r),!r){n.Mi(i,p.entityUID,u),n.Gi(p,i);continue}}n.Yn(p,t,o),n.wi(p,i,u)}return n.Oi(e,l,i,u,a),n.qi(t,o,i,u),o}static Oi(t,e,o,i,a){for(let u=0;u<t.length;u++){let d=t[u];if(!d._isAlive)continue;let s=d.mesh;if(s===void 0||a&&s._isGpuCullable)continue;let l=s.meshEntitiesInner;if(!(l.length<=1||o.meshCullTick.get(s)===i)){o.meshCullTick.set(s,i);for(let c=0;c<l.length;c++){let C=l[c],p=C.entityUID;if(p<o.handledEntityStamp.length&&o.handledEntityStamp[p]===i)continue;let g=C.getSceneGraph().isVisible;g&&e!=null&&C.getTagValue("type")!=="background-assets"&&(g=e.culling(C.getMesh())),g||n.Mi(o,p,i)}}}}static Gi(t,e){let o=t.mesh;o!==void 0&&o.meshEntitiesInner.length>1&&e.culledInstancedMeshComponents.push(t)}static wi(t,e,o){let i=t.mesh;i!==void 0&&e.meshAppendTick.set(i,o)}static qi(t,e,o,i){let a=o.culledInstancedMeshComponents,u=o.culledEntityStamp;for(let d=0;d<a.length;d++){let s=a[d],l=s.mesh;if(l===void 0||o.meshAppendTick.get(l)===i)continue;o.meshAppendTick.set(l,i);let c=l.meshEntitiesInner,C=!1;for(let p=0;p<c.length;p++){let g=c[p].entityUID;if(g>=u.length||u[g]!==i){C=!0;break}}C&&n.Yn(s,t,e)}a.length=0}static Mi(t,e,o){t.culledEntityStamp=n.xi(t.culledEntityStamp,e,o),t.culledEntityCount++}static xi(t,e,o){let i=t;return e>=t.length&&(i=new Uint32Array(Math.max(e+1,t.length*2,64)),i.set(t)),i[e]=o,i}static _isGpuCullingActive(t,e){if(!t.config.isGpuCullingEnabled||!n._isFrustumCullingEnabled||!M.isWebGpuBackend(t.engineState.currentRenderBackend)||e.isBufferLessRenderingMode())return!1;let o=t._webXRSystemIfEnabled;return!(e.isVrRendering&&(o!=null&&o.isWebXRMode)&&o.isMultiView())}static _getInstanceCullingState(t){let e=n.Kn.get(t);if(!(e===void 0||e.cullTick===0))return e}static Yn(t,e,o){let i=t.mesh;if(i===void 0)return;let a=i.primitives,u=a.length,d=!1;for(let s=0;s<u;s++){let l=a[s];o.push(l),!d&&Z(l)&&(d=!0)}if(d){let s=t.calcViewDepth(e);for(let l=0;l<u;l++)a[l]._viewDepth=s}}static Vi(t,e){let o=t.length;if(o<=1)return;let i=e.stamp,a=e.stampTick+1;a===4294967295&&(i.fill(0),a=1),e.stampTick=a;let u=0;for(let d=0;d<o;d++){let s=t[d],l=s.primitiveUid;if(l<0){t[u++]=s;continue}if(l>=i.length){let c=new Uint32Array(Math.max(l+1,i.length*2,64));c.set(i),e.stamp=c,i=c}i[l]!==a&&(i[l]=a,t[u++]=s)}t.length=u}static $i(t,e){let o=t._sortkey-e._sortkey;return o!==0?o:t._viewDepth-e._viewDepth}static Fi(t){let e=t.length,o=new Array(e+1);for(let i=0;i<e;i++)o[i]=t[i].primitiveUid;return o[e]=-1,o}static ji(t){let e=n.Kn.get(t);return e===void 0&&(e={primitives:[],stamp:new Uint32Array(64),stampTick:0,culledEntityStamp:new Uint32Array(64),handledEntityStamp:new Uint32Array(64),meshCullTick:new WeakMap,cullTick:0,culledEntityCount:0,cullingId:0,keyedPrimitives:[],isGpuCullingActive:void 0,isComputeSkinningEnabled:void 0,culledInstancedMeshComponents:[],meshAppendTick:new WeakMap},n.Kn.set(t,e)),e}static common_$prerender(t){let e=t.objectUID,o=n.Jn;if(o===void 0||n.On!==e){if(o=n.Wn.get(e),o===void 0){let i=t.engineState.currentRenderBackend;if(this.common_$load({renderBackend:i,engine:t}),o=n.Wn.get(e),o===void 0)return}n.On=e,n.Jn=o}o.prerender()}static common_$render({renderPass:t,renderPassTickCount:e,primitiveUids:o,displayIdx:i,engine:a}){return n.Wn.get(a.objectUID).common_$render(o,t,e,i)}$render(){}_shallowCopyFrom(t){let e=t;this.Zn=e.Zn,this.jn=e.jn,this.diffuseCubeMapContribution=e.diffuseCubeMapContribution,this.specularCubeMapContribution=e.specularCubeMapContribution,this.rotationOfCubeMap=e.rotationOfCubeMap}_destroy(){super._destroy(),this.Qn(),this.Zn=void 0,this.jn=void 0}addThisComponentToEntity(t,e){class o extends t.constructor{getMeshRenderer(){return this.getComponentByComponentTID(T.MeshRendererComponentTID)}}return B(t,o),t}static _cleanupForEngine(t){let e=n.Wn.get(t.objectUID);e!=null&&e.destroy(),n.Wn.delete(t.objectUID),n.On===t.objectUID&&(n.On=-1,n.Jn=void 0)}};n.Wn=new Map,n.Ni=new Map,n.rt=0,n._isFrustumCullingEnabled=!0,n.Ai=0,n.Ri=new Map,n.Bi=0,n.Xn=new Set,n.Kn=new WeakMap,n.On=-1;var x=n;export{x as MeshRendererComponent};
@@ -1,4 +1,4 @@
1
- import type { ProcessApproachEnum } from '../../foundation/definitions/ProcessApproach';
1
+ import type { RenderBackendEnum } from '../../foundation/definitions/RenderBackend';
2
2
  import type { CGAPIResourceHandle, Count, Index, IndexOf16Bytes } from '../../types/CommonTypes';
3
3
  import type { getShaderPropertyFuncOfGlobalDataRepository, ShaderSemanticsName } from '../definitions/ShaderSemantics';
4
4
  import { type ShaderSemanticsInfo } from '../definitions/ShaderSemanticsInfo';
@@ -16,12 +16,12 @@ export declare class GlobalDataRepository {
16
16
  /**
17
17
  * Initializes the GlobalDataRepository with all required global properties.
18
18
  * Sets up data structures for camera matrices, lighting, skeletal animation,
19
- * and other rendering parameters based on the specified process approach.
19
+ * and other rendering parameters based on the specified render backend.
20
20
  *
21
21
  * @param approach - The processing approach that determines
22
22
  * how data is organized and accessed in shaders
23
23
  */
24
- initialize(_approach: ProcessApproachEnum): void;
24
+ initialize(_backend: RenderBackendEnum): void;
25
25
  /**
26
26
  * Returns the singleton instance of GlobalDataRepository.
27
27
  * Creates a new instance if it doesn't exist yet.
@@ -1 +1 @@
1
- import{WellKnownComponentTIDs as p}from"../components/WellKnownComponentTIDs.js";import{BufferUse as y}from"../definitions/BufferUse.js";import{ComponentType as i}from"../definitions/ComponentType.js";import{CompositionType as s}from"../definitions/CompositionType.js";import{calcAlignedByteLength as x}from"../definitions/ShaderSemanticsInfo.js";import{ShaderType as o}from"../definitions/ShaderType.js";import{MathClassUtil as h}from"../math/MathClassUtil.js";import{Scalar as f}from"../math/Scalar.js";import{Vector2 as d}from"../math/Vector2.js";import{Vector3 as A}from"../math/Vector3.js";import{VectorN as S}from"../math/VectorN.js";import{getLightClusterGlobalPropertyLength as T}from"../renderer/lightCluster/LightClusterLayout.js";var g=class b{constructor(e){this.em=new Map;this.i=e}initialize(e){let t={semantic:"currentComponentSIDs",compositionType:s.ScalarArray,componentType:i.Float,arrayLength:p.maxWellKnownTidNumber,stage:o.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:new S(new Float32Array(p.maxWellKnownTidNumber))};this.tm(t,1),this.takeOne("currentComponentSIDs");let n={semantic:"skinningMode",compositionType:s.Scalar,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:1,isInternalSetting:!0,initialValue:f.fromCopyNumber(-1)};this.tm(n,1),this.takeOne("skinningMode");let a={semantic:"lightNumber",compositionType:s.Scalar,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(a,1),this.takeOne("lightNumber");let r=T(this.i.config.maxLightListLength),m={semantic:"clusteredLightData",compositionType:s.Vec4Array,componentType:i.Float,arrayLength:r,stage:o.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:new S(new Float32Array(r*4))};this.tm(m,1),this.takeOne("clusteredLightData");let c={semantic:"ambientLightIntensity",compositionType:s.Vec3,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:A.fromCopy3(0,0,0)};this.tm(c,1),this.takeOne("ambientLightIntensity");let u={semantic:"backBufferTextureSize",compositionType:s.Vec2,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(u,1),this.takeOne("backBufferTextureSize");let l={semantic:"vrState",compositionType:s.Vec2,componentType:i.Int,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(l,1),this.takeOne("vrState");let I={semantic:"time",compositionType:s.Scalar,componentType:i.Float,stage:o.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(I,1),this.takeOne("time")}static init(e){return new b(e)}tm(e,t){let n=x(e),a,r=0;do a=this.i.memoryManager.createOrGetBuffer(y.GPUInstanceData,r).takeBufferView({byteLengthToNeed:n*t,byteStride:0}),a.isErr()&&r++;while(a.isErr());let m=e.arrayLength;s.isArray(e.compositionType)&&m==null&&(m=100);let c=a.get().takeAccessor({compositionType:e.compositionType,componentType:i.Float,count:t,byteStride:n,arrayLength:m}).unwrapForce(),u={shaderSemanticsInfo:e,values:[],maxCount:t,accessor:c};this.em.set(e.semantic,u)}takeOne(e){let t=this.em.get(e);if(t){let n=t.shaderSemanticsInfo,a=t.accessor.takeOne(),r=t.values.length,m=h.initWithFloat32Array(n.initialValue,a);return t.values[r]=m,m}}setValue(e,t,n){let a=this.em.get(e);if(a){let r=a.values[t];h._setForce(r,n)}}getValue(e,t){let n=this.em.get(e);if(n)return n.values[t]}getPropertyTable(){let e=[];return this.em.forEach((t,n)=>{e.push({semantic:n,info:t.shaderSemanticsInfo,value:t.values[0],vec4Index:this.getLocationOffsetOfProperty(n),maxCount:t.maxCount})}),e}_setUniformLocationsForWebGL2ModeOnly(e){let t=this.i.webglResourceRepository,n=[];this.em.forEach(a=>{let r=a.shaderSemanticsInfo;r.needUniformInDataTextureMode&&n.push(r)}),t.setupUniformLocations(this.i.config,e,n)}getLocationOffsetOfProperty(e){let t=this.em.get(e);if(t){let n=t.accessor;return(this.i.memoryManager.getByteOffsetOfExistingBuffers(y.GPUInstanceData,n.bufferView.buffer.indexOfTheBufferUsage)+n.byteOffsetInBuffer)/4/4}return-1}_addPropertiesStr(e,t,n){return this.em.forEach(a=>{let r=a.shaderSemanticsInfo;(r.stage===o.VertexShader||r.stage===o.VertexAndPixelShader)&&(e+=n(this.i,r)),(r.stage===o.PixelShader||r.stage===o.VertexAndPixelShader)&&(t+=n(this.i,r))}),[e,t]}};export{g as GlobalDataRepository};
1
+ import{WellKnownComponentTIDs as p}from"../components/WellKnownComponentTIDs.js";import{BufferUse as y}from"../definitions/BufferUse.js";import{ComponentType as o}from"../definitions/ComponentType.js";import{CompositionType as s}from"../definitions/CompositionType.js";import{calcAlignedByteLength as x}from"../definitions/ShaderSemanticsInfo.js";import{ShaderType as i}from"../definitions/ShaderType.js";import{MathClassUtil as h}from"../math/MathClassUtil.js";import{Scalar as f}from"../math/Scalar.js";import{Vector2 as d}from"../math/Vector2.js";import{Vector3 as A}from"../math/Vector3.js";import{VectorN as S}from"../math/VectorN.js";import{getLightClusterGlobalPropertyLength as T}from"../renderer/lightCluster/LightClusterLayout.js";var g=class b{constructor(e){this.em=new Map;this.i=e}initialize(e){let t={semantic:"currentComponentSIDs",compositionType:s.ScalarArray,componentType:o.Float,arrayLength:p.maxWellKnownTidNumber,stage:i.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:new S(new Float32Array(p.maxWellKnownTidNumber))};this.tm(t,1),this.takeOne("currentComponentSIDs");let n={semantic:"skinningMode",compositionType:s.Scalar,componentType:o.Int,stage:i.VertexAndPixelShader,min:0,max:1,isInternalSetting:!0,initialValue:f.fromCopyNumber(-1)};this.tm(n,1),this.takeOne("skinningMode");let a={semantic:"lightNumber",compositionType:s.Scalar,componentType:o.Int,stage:i.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(a,1),this.takeOne("lightNumber");let r=T(this.i.config.maxLightListLength),m={semantic:"clusteredLightData",compositionType:s.Vec4Array,componentType:o.Float,arrayLength:r,stage:i.VertexAndPixelShader,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:new S(new Float32Array(r*4))};this.tm(m,1),this.takeOne("clusteredLightData");let c={semantic:"ambientLightIntensity",compositionType:s.Vec3,componentType:o.Float,stage:i.VertexAndPixelShader,min:0,max:Number.MAX_VALUE,isInternalSetting:!0,initialValue:A.fromCopy3(0,0,0)};this.tm(c,1),this.takeOne("ambientLightIntensity");let u={semantic:"backBufferTextureSize",compositionType:s.Vec2,componentType:o.Float,stage:i.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(u,1),this.takeOne("backBufferTextureSize");let l={semantic:"vrState",compositionType:s.Vec2,componentType:o.Int,stage:i.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,needUniformInDataTextureMode:!0,initialValue:d.fromCopy2(0,0)};this.tm(l,1),this.takeOne("vrState");let I={semantic:"time",compositionType:s.Scalar,componentType:o.Float,stage:i.VertexAndPixelShader,min:0,max:Number.MAX_SAFE_INTEGER,isInternalSetting:!0,initialValue:f.fromCopyNumber(0)};this.tm(I,1),this.takeOne("time")}static init(e){return new b(e)}tm(e,t){let n=x(e),a,r=0;do a=this.i.memoryManager.createOrGetBuffer(y.GPUInstanceData,r).takeBufferView({byteLengthToNeed:n*t,byteStride:0}),a.isErr()&&r++;while(a.isErr());let m=e.arrayLength;s.isArray(e.compositionType)&&m==null&&(m=100);let c=a.get().takeAccessor({compositionType:e.compositionType,componentType:o.Float,count:t,byteStride:n,arrayLength:m}).unwrapForce(),u={shaderSemanticsInfo:e,values:[],maxCount:t,accessor:c};this.em.set(e.semantic,u)}takeOne(e){let t=this.em.get(e);if(t){let n=t.shaderSemanticsInfo,a=t.accessor.takeOne(),r=t.values.length,m=h.initWithFloat32Array(n.initialValue,a);return t.values[r]=m,m}}setValue(e,t,n){let a=this.em.get(e);if(a){let r=a.values[t];h._setForce(r,n)}}getValue(e,t){let n=this.em.get(e);if(n)return n.values[t]}getPropertyTable(){let e=[];return this.em.forEach((t,n)=>{e.push({semantic:n,info:t.shaderSemanticsInfo,value:t.values[0],vec4Index:this.getLocationOffsetOfProperty(n),maxCount:t.maxCount})}),e}_setUniformLocationsForWebGL2ModeOnly(e){let t=this.i.webglResourceRepository,n=[];this.em.forEach(a=>{let r=a.shaderSemanticsInfo;r.needUniformInDataTextureMode&&n.push(r)}),t.setupUniformLocations(this.i.config,e,n)}getLocationOffsetOfProperty(e){let t=this.em.get(e);if(t){let n=t.accessor;return(this.i.memoryManager.getByteOffsetOfExistingBuffers(y.GPUInstanceData,n.bufferView.buffer.indexOfTheBufferUsage)+n.byteOffsetInBuffer)/4/4}return-1}_addPropertiesStr(e,t,n){return this.em.forEach(a=>{let r=a.shaderSemanticsInfo;(r.stage===i.VertexShader||r.stage===i.VertexAndPixelShader)&&(e+=n(this.i,r)),(r.stage===i.PixelShader||r.stage===i.VertexAndPixelShader)&&(t+=n(this.i,r))}),[e,t]}};export{g as GlobalDataRepository};
@@ -0,0 +1,21 @@
1
+ import { EnumClass, type EnumIO } from '../misc/EnumIO';
2
+ export declare class RenderBackendClass extends EnumClass implements EnumIO {
3
+ constructor({ index, str }: {
4
+ index: number;
5
+ str: string;
6
+ });
7
+ get webGLVersion(): 0 | 2;
8
+ }
9
+ export type RenderBackendEnum = RenderBackendClass;
10
+ declare function from(index: number): RenderBackendEnum | undefined;
11
+ declare const isWebGpuBackend: (renderBackend: RenderBackendEnum) => boolean;
12
+ declare const isWebGL2Backend: (renderBackend: RenderBackendEnum) => boolean;
13
+ export declare const RenderBackend: Readonly<{
14
+ isWebGpuBackend: typeof isWebGpuBackend;
15
+ None: RenderBackendClass;
16
+ WebGL2: RenderBackendClass;
17
+ WebGPU: RenderBackendClass;
18
+ from: typeof from;
19
+ isWebGL2Backend: typeof isWebGL2Backend;
20
+ }>;
21
+ export {};
@@ -0,0 +1 @@
1
+ import{_from as c,EnumClass as a}from"../misc/EnumIO.js";var n=class extends a{constructor({index:d,str:u}){super({index:d,str:u})}get webGLVersion(){return this===r?2:0}},s=new n({index:0,str:"NONE"}),r=new n({index:2,str:"WebGL2"}),t=new n({index:3,str:"WebGPU"}),m=[s,r,t];function o(e){return c({typeList:m,index:e})}var i=e=>e===t,E=e=>e===r,k=Object.freeze({isWebGpuBackend:i,None:s,WebGL2:r,WebGPU:t,from:o,isWebGL2Backend:E});export{k as RenderBackend,n as RenderBackendClass};
@@ -15,8 +15,8 @@ export * from './LightType';
15
15
  export * from './PhysicsShapeType';
16
16
  export * from './PixelFormat';
17
17
  export * from './PrimitiveMode';
18
- export * from './ProcessApproach';
19
18
  export * from './ProcessStage';
19
+ export * from './RenderBackend';
20
20
  export * from './RenderBufferTarget';
21
21
  export * from './SdfShapeType';
22
22
  export * from './ShaderNode';
@@ -1 +1 @@
1
- export*from"./AlphaMode.js";export*from"./AnimationAttribute.js";export*from"./AnimationInterpolation.js";export*from"./BasisCompressionType.js";export*from"./BoneDataType.js";export*from"./BufferUse.js";export*from"./CameraControllerType.js";export*from"./CameraType.js";export*from"./ComponentType.js";export*from"./CompositionType.js";export*from"./CompressionTextureType.js";export*from"./FileType.js";export*from"./HdriFormat.js";export*from"./LightType.js";export*from"./PhysicsShapeType.js";export*from"./PixelFormat.js";export*from"./PrimitiveMode.js";export*from"./ProcessApproach.js";export*from"./ProcessStage.js";export*from"./RenderBufferTarget.js";export*from"./SdfShapeType.js";export*from"./ShaderNode.js";export*from"./ShaderSemantics.js";export*from"./ShaderSemanticsInfo.js";export*from"./ShaderType.js";export*from"./ShaderVariableType.js";export*from"./ShadingModel.js";export*from"./ShadowMap.js";export*from"./TextureFormat.js";export*from"./TextureParameter.js";export*from"./ToneMappingType.js";export*from"./VertexAttribute.js";export*from"./Visibility.js";
1
+ export*from"./AlphaMode.js";export*from"./AnimationAttribute.js";export*from"./AnimationInterpolation.js";export*from"./BasisCompressionType.js";export*from"./BoneDataType.js";export*from"./BufferUse.js";export*from"./CameraControllerType.js";export*from"./CameraType.js";export*from"./ComponentType.js";export*from"./CompositionType.js";export*from"./CompressionTextureType.js";export*from"./FileType.js";export*from"./HdriFormat.js";export*from"./LightType.js";export*from"./PhysicsShapeType.js";export*from"./PixelFormat.js";export*from"./PrimitiveMode.js";export*from"./ProcessStage.js";export*from"./RenderBackend.js";export*from"./RenderBufferTarget.js";export*from"./SdfShapeType.js";export*from"./ShaderNode.js";export*from"./ShaderSemantics.js";export*from"./ShaderSemanticsInfo.js";export*from"./ShaderType.js";export*from"./ShaderVariableType.js";export*from"./ShadingModel.js";export*from"./ShadowMap.js";export*from"./TextureFormat.js";export*from"./TextureParameter.js";export*from"./ToneMappingType.js";export*from"./VertexAttribute.js";export*from"./Visibility.js";
@@ -1,4 +1,5 @@
1
1
  import type { CGAPIResourceHandle, Index } from '../../types/CommonTypes';
2
+ import type { WebGLMeshResources } from '../../webgl/WebGLMeshResources';
2
3
  import type { MeshComponent } from '../components/Mesh/MeshComponent';
3
4
  import type { IMeshEntity } from '../helpers/EntityHelper';
4
5
  import { AABB } from '../math/AABB';
@@ -24,9 +25,6 @@ export declare class Mesh implements IMesh {
24
25
  private __blendWithoutZWritePrimitives;
25
26
  private __morphPrimitives;
26
27
  private __localAABB;
27
- private __vaoUids;
28
- /** Indices of __vaoUids that refer to a MultiDrawRepository-owned group VAO. */
29
- private __multiDrawVaoIndices;
30
28
  private __variationVBOUid;
31
29
  /** Instance variation data of all the entities, in the order of `__variationEntityUIDs`. */
32
30
  private __variationEntityInfo?;
@@ -43,20 +41,8 @@ export declare class Mesh implements IMesh {
43
41
  private __computeDeformablePrimitiveCount;
44
42
  private __computeDeformablePositionUpdateCount;
45
43
  private __computeDeformableHasSkeletal;
46
- /** Mirror of the current content of the variation VBO (WebGL). */
47
- private __variationVBOContent?;
48
- /** Scratch buffer to pack the instance variation data of the visible instances. */
49
- private __packedVariationEntityInfo?;
50
- /** Number of the instances packed at the front of the variation VBO. */
51
- private __variationVBOInstanceCount;
52
- /** Culling state the variation VBO content was packed for; used to skip redundant packing. */
53
- private __variationVBOCulledEntityStamp?;
54
- private __variationVBOCullTick;
55
- /** Stable slot range in the engine-wide instance SID table (WebGL multi-draw). */
56
- private __instanceSidBase;
57
- private __instanceSidCount;
58
- /** Id of the last culling pass that visited this mesh in the per-pass instance prepass. */
59
- private __remapPrepassId;
44
+ /** The WebGL2 resources; created on first use when the engine renders with WebGL2 (see `_webglResources`). */
45
+ private __webglResources?;
60
46
  private __latestPrimitivePositionAccessorVersionForAABB;
61
47
  private __latestPrimitivePositionAccessorVersionForSetUpDone;
62
48
  private __belongToEntities;
@@ -185,57 +171,22 @@ export declare class Mesh implements IMesh {
185
171
  */
186
172
  getPrimitiveNumber(): number;
187
173
  /**
188
- * Whether the WebGL instance SID texture path (multi-draw) is active for this mesh.
174
+ * Returns the WebGL2 resources of this mesh, creating them on first use. Undefined unless the engine renders
175
+ * with WebGL2.
189
176
  */
190
- private __isInstanceSidTextureMode;
177
+ private __getWebGLResources;
191
178
  /**
192
- * Ensures that this mesh owns a contiguous range of stable instance slots in the
193
- * engine-wide instance SID table and writes the instance identity records.
194
- * @returns The first stable slot index (instanceBase).
179
+ * The WebGL2 resources of this mesh: the VAOs, the multi-draw instance slots and the packing of the visible
180
+ * instances. Only for the WebGL2 backend.
195
181
  * @internal
196
182
  */
197
- _ensureInstanceSidBase(): number;
198
- /**
199
- * Gets the first stable instance slot of this mesh (WebGL multi-draw).
200
- * @internal
201
- */
202
- get _instanceSidBase(): number;
203
- /**
204
- * Visit stamp of the per-pass instance prepass (WebGL multi-draw).
205
- * @internal
206
- */
207
- get _remapPrepassId(): number;
208
- set _remapPrepassId(id: number);
183
+ get _webglResources(): WebGLMeshResources;
209
184
  /**
210
185
  * Updates the variation VBO (Vertex Buffer Object) for instancing.
211
186
  * @returns True if updated, false if not changed (not dirty)
212
187
  * @internal
213
188
  */
214
189
  updateVariationVBO(): boolean;
215
- /**
216
- * Packs the instance variation data of the instances that were not culled in a render pass
217
- * into the front of the variation VBO, so that an instanced draw call renders only them.
218
- * The VBO is rewritten only when its content changes. WebGL only.
219
- *
220
- * Instances whose entities are not handled by the render pass's culling keep being drawn.
221
- *
222
- * @param culledEntityStamp - Per-EntityUID stamps written by the culling of the render pass
223
- * (undefined: draw all the instances)
224
- * @param cullTick - The stamp value of the latest culling of the render pass
225
- * @returns The number of the instances to draw
226
- * @internal
227
- */
228
- _packVisibleInstancesToVariationVBO(culledEntityStamp: Uint32Array | undefined, cullTick: number): number;
229
- /**
230
- * Packs the visible instances into the engine-wide remap table so that the shader can
231
- * resolve `instanceBase + gl_InstanceID` to a stable SID slot. WebGL multi-draw only.
232
- *
233
- * @param culledEntityStamp - Per-EntityUID stamps written by the render pass culling
234
- * @param cullTick - The stamp value of the latest culling of the render pass
235
- * @returns The number of visible instances
236
- * @internal
237
- */
238
- _packVisibleInstancesToInstanceRemap(culledEntityStamp: Uint32Array | undefined, cullTick: number): number;
239
190
  /**
240
191
  * Deletes the variation VBO (Vertex Buffer Object).
241
192
  * @returns True if updated, false if not changed (not dirty)
@@ -251,12 +202,6 @@ export declare class Mesh implements IMesh {
251
202
  * Group VAOs are owned by the MultiDrawRepository and are skipped.
252
203
  */
253
204
  deleteVAO(): void;
254
- /**
255
- * Clears the VAO entries that point at multi-draw group VAOs. The groups own those
256
- * VAOs and delete them, so the mesh must forget them before the group is released.
257
- * @internal
258
- */
259
- _clearMultiDrawVaoUids(): void;
260
205
  /**
261
206
  * Performs ray casting against this mesh to find intersection points.
262
207
  * @param srcPointInLocal - The ray origin point in local space
@@ -287,6 +232,11 @@ export declare class Mesh implements IMesh {
287
232
  * @internal
288
233
  */
289
234
  get _variationEntityInfo(): Uint32Array | undefined;
235
+ /**
236
+ * EntityUIDs of the instances in `_variationEntityInfo`, in the same order.
237
+ * @internal
238
+ */
239
+ get _variationEntityUIDs(): Int32Array | undefined;
290
240
  /**
291
241
  * Whether the instances of this mesh can be culled on the GPU (WebGPU GPU culling).
292
242
  * The bounding boxes of the deformed instances (skinning, blend shapes) depend on the deformation: they are culled on
@@ -418,16 +368,16 @@ export declare class Mesh implements IMesh {
418
368
  * @returns True if setup is done, false otherwise
419
369
  */
420
370
  isSetUpDone(): boolean;
421
- /**
422
- * Updates VBO (Vertex Buffer Object) and VAO (Vertex Array Object) for all primitives.
423
- * @internal
424
- */
425
371
  /**
426
372
  * Marks this mesh's multi-draw groups (and the legacy setup) for a rebuild.
427
373
  * Called when a primitive's attributes or indices change.
428
374
  * @internal
429
375
  */
430
376
  _invalidateMultiDrawStructure(): void;
377
+ /**
378
+ * Updates VBO (Vertex Buffer Object) and VAO (Vertex Array Object) for all primitives.
379
+ * @internal
380
+ */
431
381
  _updateVBOAndVAO(): void;
432
382
  /**
433
383
  * Deletes all 3D API vertex data for this mesh.
@@ -1 +1 @@
1
- import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as z}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as O,isBlendWithZWrite as H,isOpaque as k,isTranslucent as F}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.zc=[];this.wu=[];this.Bu=[];this.Mu=[];this.Uu=[];this.qu=[];this.Ru=new G;this.Xc=[];this.gu=new Set;this.Yc=v.InvalidCGAPIResourceUid;this.zu=!1;this.Iu=!1;this.Ou=!1;this.Nu=!1;this.Hu=-1;this.ku=-1;this.Fu=!1;this.hu=0;this.yu=-1;this.qc=-1;this.Vu=0;this.Eu=-1;this.Lu=0;this.Wu=0;this.Zc=[];this.xu=!1;this.tangentCalculationMode=1;this.Zu=!1;this.Jc=0;this.i=t,this.Gu=++c.Yu}static get _primitivePositionUpdateVersion(){return c.Xu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.zc.findIndex(i=>i.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Zc}get _variationInstanceCount(){return this.Qc==null?this.Zc.length:this.Qc.length/4}_belongToMeshComponent(t){this.Zc.push(t.entity),this.xu=!0,this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){var i;let r=t.entity;this.Zc=this.Zc.filter(e=>e!==r),this.xu=!0;for(let e of this.Zc)(i=e.tryToGetMeshRenderer())==null||i.markNeedsLoad();this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),k(t)?this.wu.push(t):F(t)?this.Bu.push(t):H(t)?this.Mu.push(t):O(t)&&this.Uu.push(t),this.hl(this.wu.concat(this.Bu).concat(this.Mu).concat(this.Uu))}hl(t){this.zc=t}isExistOpaque(){return this.wu.length>0}isExistTranslucent(){return this.Bu.length>0}isExistBlendWithZWrite(){return this.Mu.length>0}isExistBlendWithoutZWrite(){return this.Uu.length>0}getPrimitiveAt(t){return this.zc[t]}getPrimitiveNumber(){return this.zc.length}$c(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Zc.length,r=this.i.webglResourceRepository.instanceSidTable,i=this.qc;(i<0||this.Vu!==t)&&(i>=0&&r.free(i,this.Vu),i=r.allocate(t),this.qc=i,this.Vu=t,r.writeIdentityRemap(i,t));let e=4294967295;for(let s=0;s<t;s++){let n=this.Zc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(i+s,a,o!=null?o.componentSID:e,u!=null?u.componentSID:e)}return i}get _instanceSidBase(){return this.qc}get _remapPrepassId(){return this.Eu}set _remapPrepassId(t){this.Eu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.Yc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.Yc);let r=4294967295,i=this.Zc.length,e=new Uint32Array(i*4),s=new Int32Array(i),n=!1,a=!1;for(let o=0;o<i;o++){s[o]=this.Zc[o].entityUID,e[4*o+0]=this.Zc[o].getSceneGraph().componentSID;let u=this.Zc[o].tryToGetSkeletal();u!=null?e[4*o+1]=u.componentSID:e[4*o+1]=r;let f=this.Zc[o].tryToGetBlendShape();f!=null?e[4*o+2]=f.componentSID:e[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.zu=i>0,this.Iu=n,this.Ou=a,this.$c()?(this.Yc=v.InvalidCGAPIResourceUid,this.Qc=e,this.vu=s,this.Pu=void 0,this.Du=void 0,this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,this._ensureInstanceSidBase(),!0):(this.Yc=t.createVertexBufferFromTypedArray(e),this.Qc=e,this.vu=s,this.Pu=e.slice(),this.Du=new Uint32Array(e.length),this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.$c())return this._packVisibleInstancesToInstanceRemap(t,r);let i=this.Qc,e=this.vu,s=this.Pu,n=this.Du;if(i===void 0||e===void 0||s===void 0||n===void 0||this.Yc===v.InvalidCGAPIResourceUid)return this.Zc.length;if(t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let a=e.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=e[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=i[h+0],n[m+1]=i[h+1],n[m+2]=i[h+2],n[m+3]=i[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.Yc,l),s.set(l)}return this.hu=o,o}_packVisibleInstancesToInstanceRemap(t,r){let i=this.vu;if(i===void 0)return this.Zc.length;if(this.qc<0&&this._ensureInstanceSidBase(),t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let e=this.i.webglResourceRepository.instanceSidTable,s=this.qc,n=i.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=i[o];if(u<t.length&&t[u]===r)continue}e.setRemap(s+a,o),a++}return this.hu=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.Yc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.Yc),this.Yc=v.InvalidCGAPIResourceUid,this.Qc=void 0,this.vu=void 0,this.Pu=void 0,this.Du=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let e=0;e<this.zc.length;e++){let s=this.zc[e],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[e]=n.vertexHandles.vaoHandle,this.gu.add(e);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[e])||this.Xc[e]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[e]=t.createVertexArray(),a.vaoHandle=this.Xc[e]),t.setVertexDataToPipeline(a,s,this.Yc)}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=this.zc.length;e<this.Xc.length;e++){let s=this.Xc[e];s&&!r.hasVaoHandle(s)&&(i.has(s)||(i.add(s),t.deleteVertexArray(s))),this.Xc[e]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.gu.clear();return}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=0;e<this.Xc.length;e++){let s=this.Xc[e];s&&!i.has(s)&&!r.hasVaoHandle(s)&&(i.add(s),t.deleteVertexArray(s)),this.Xc[e]=v.InvalidCGAPIResourceUid}this.gu.clear()}_clearMultiDrawVaoUids(){for(let t of this.gu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.gu.clear()}castRay(t,r,i=0){var o;let e,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.zc){let f=u.castRay(t,r,!0,!0,i,this.Zu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,e=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(e)?{result:!0,data:{t:s,u:n,v:a,position:e}}:{result:!1}}get primitives(){return this.zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.Yc}get _variationEntityInfo(){return this.Qc}get _isGpuCullable(){return this.zu?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.Iu)return!0;if(!this.Ou)return!1;for(let t=0;t<this.zc.length;t++)if(this.zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.Hu===this.zc.length&&this.ku===this.Jc&&this.Fu===this.Iu?this.Nu:(this.Hu=this.zc.length,this.ku=this.Jc,this.Fu=this.Iu,this.Nu=this.fl(),this.Nu)}fl(){if(this.zc.length===0)return!1;let t=(r,i)=>r.some(e=>e.split(".")[0]===i);for(let r of this.zc){let i=r.attributeSemantics;if(!t(i,"POSITION")||this.Iu&&(!t(i,"JOINTS_0")||!t(i,"WEIGHTS_0")))return!1;for(let e of r.targets){let s=!1;for(let n of e.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Jc++,c.Xu++;for(let t of this.Zc)t.getMeshRenderer().markNeedsLoad()}get primitivePositionUpdateCount(){return this.Jc}get AABB(){if(this.Jc!==this.Lu&&(this.Ru.initialize(),this.Lu=this.Jc),this.Ru.isVanilla())for(let t of this.zc)this.Ru.mergeAABB(t.AABB);return this.Ru}bl(){for(let t=0;t<this.zc.length;t++){let r=this.qu[t],i=this.zc[t];i.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,i.getAttribute(n))})}}_calcTangents(){if(this.pl())for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let i=t.attributeSemantics.indexOf(g.Texcoord0.XY),e=t.attributeSemantics.indexOf(g.Normal.XYZ);if(i!==-1&&e!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[i],o=t.attributeAccessors[e],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),M=n.getVec3(d+2,{indicesAccessor:u}),S=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),N=a.getVec2(d+2,{indicesAccessor:u}),T=o.getVec3(d,{indicesAccessor:u});this.dl(d,I,A,M,S,U,N,T,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}dl(t,r,i,e,s,n,a,o,u,f){let l=this.Tu(r,i,e,s,n,a,o,c.cl),h=this.Tu(i,e,r,n,a,s,o,c.ul),m=this.Tu(e,r,i,a,s,n,o,c.ll);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}Tu(t,r,i,e,s,n,a,o){let u=[c.Tt.setComponents(t.x,e.x,e.y),c.bt.setComponents(t.y,e.x,e.y),c.ve.setComponents(t.z,e.x,e.y)],f=[c._u.setComponents(r.x,s.x,s.y),c.ju.setComponents(r.y,s.x,s.y),c.Ju.setComponents(r.z,s.x,s.y)],l=[c.Ku.setComponents(i.x,n.x,n.y),c.Qu.setComponents(i.y,n.x,n.y),c.$u.setComponents(i.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.il),d=b.subtractTo(l[p],f[p],c.sl),I=b.crossTo(y,d,c.al),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),z.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}pl(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Zu=!0;let i=t.attributeSemantics.indexOf(g.Position.XYZ),e=t.attributeAccessors[i],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=e.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:e.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=e.getVec3(h,{indicesAccessor:s}),p=e.getVec3(h+1,{indicesAccessor:s}),y=e.getVec3(h+2,{indicesAccessor:s});this.ml(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}ml(t,r,i,e,s,n){let a=i.x-r.x,o=i.y-r.y,u=i.z-r.z,f=e.x-r.x,l=e.y-r.y,h=e.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(i){return i.every(e=>e===i[0])}let r=this.primitives.map(i=>i.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){if(this.xu)return!1;let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Wu!==this.Jc?(this.Wu=this.Jc,!1):!0:!1}_invalidateMultiDrawStructure(){this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.$c()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let i=this.getPrimitiveAt(r);x.exist(i.vertexHandles)?i.update3DAPIVertexData():i.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.zc)t.delete3DAPIVertexData();this.qc>=0&&this.Zc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.qc,this.Vu),this.qc=-1,this.Vu=0)}};c.invalidateMeshUID=-1,c.Yu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c._u=b.zero(),c.ju=b.zero(),c.Ju=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.il=b.zero(),c.sl=b.zero(),c.al=b.zero(),c.cl=b.zero(),c.ul=b.zero(),c.ll=b.zero(),c.Xu=0;var B=c;export{B as Mesh};
1
+ import{BufferUse as I}from"../definitions/BufferUse.js";import{ComponentType as C}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as x}from"../definitions/PrimitiveMode.js";import{RenderBackend as B}from"../definitions/RenderBackend.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as z}from"../math/AABB.js";import{MutableVector3 as h}from"../math/MutableVector3.js";import{Vector3 as O}from"../math/Vector3.js";import{Is as M}from"../misc/Is.js";import{Logger as G}from"../misc/Logger.js";import{CGAPIResourceRepository as V}from"../renderer/CGAPIResourceRepository.js";import{ModuleManager as w}from"../system/ModuleManager.js";import{isBlendWithoutZWrite as E,isBlendWithZWrite as k,isOpaque as L,isTranslucent as W}from"./types/GeometryTypes.js";var s=class s{constructor(t){this.zc=[];this.gu=[];this.vu=[];this.Vu=[];this.xu=[];this.Eu=[];this.du=new z;this.Yc=V.InvalidCGAPIResourceUid;this.Bu=!1;this.$c=!1;this.Du=!1;this.Iu=!1;this.Tu=-1;this.Ru=-1;this.Uu=!1;this.Nu=0;this.zu=0;this.Zc=[];this.hu=!1;this.tangentCalculationMode=1;this.Ou=!1;this.qc=0;this.i=t,this.Mu=++s.wu}static get _primitivePositionUpdateVersion(){return s.Gu}getVaoUids(t){var e,i;return(i=(e=this.Xc())==null?void 0:e.getVaoUid(t))!=null?i:V.InvalidCGAPIResourceUid}getVaoUidsByPrimitiveUid(t){let e=this.zc.findIndex(i=>i.primitiveUid===t);return this.getVaoUids(e)}get meshEntitiesInner(){return this.Zc}get _variationInstanceCount(){return this.Jc==null?this.Zc.length:this.Jc.length/4}_belongToMeshComponent(t){var e;this.Zc.push(t.entity),this.hu=!0,(e=this.Xc())==null||e.markMultiDrawDirty()}_removeMeshComponent(t){var i,r;let e=t.entity;this.Zc=this.Zc.filter(o=>o!==e),this.hu=!0;for(let o of this.Zc)(i=o.tryToGetMeshRenderer())==null||i.markNeedsLoad();(r=this.Xc())==null||r.markMultiDrawDirty()}addPrimitive(t){var e;t._belongToMesh(this),(e=this.Xc())==null||e.markMultiDrawDirty(),L(t)?this.gu.push(t):W(t)?this.vu.push(t):k(t)?this.Vu.push(t):E(t)&&this.xu.push(t),this.Qu(this.gu.concat(this.vu).concat(this.Vu).concat(this.xu))}Qu(t){this.zc=t}isExistOpaque(){return this.gu.length>0}isExistTranslucent(){return this.vu.length>0}isExistBlendWithZWrite(){return this.Vu.length>0}isExistBlendWithoutZWrite(){return this.xu.length>0}getPrimitiveAt(t){return this.zc[t]}getPrimitiveNumber(){return this.zc.length}Xc(){if(this.Qc===void 0&&this.i.engineState.currentRenderBackend===B.WebGL2){let t=w.getInstance().getModule("webgl");this.Qc=new t.WebGLMeshResources(this.i,this)}return this.Qc}get _webglResources(){return this.Xc()}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.Yc!==V.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.Yc);let e=4294967295,i=this.Zc.length,r=new Uint32Array(i*4),o=new Int32Array(i),n=!1,c=!1;for(let a=0;a<i;a++){o[a]=this.Zc[a].entityUID,r[4*a+0]=this.Zc[a].getSceneGraph().componentSID;let l=this.Zc[a].tryToGetSkeletal();l!=null?r[4*a+1]=l.componentSID:r[4*a+1]=e;let f=this.Zc[a].tryToGetBlendShape();f!=null?r[4*a+2]=f.componentSID:r[4*a+2]=e,n||(n=l!=null),c||(c=f!=null)}this.Bu=i>0,this.$c=n,this.Du=c;let u=this.Xc();return u!=null&&u.isInstanceSidTextureMode()?(this.Yc=V.InvalidCGAPIResourceUid,this.Jc=r,this.yu=o,u.onVariationDataUpdated(void 0,i),this.hu=!1,u.ensureInstanceSidBase(),!0):(this.Yc=t.createVertexBufferFromTypedArray(r),this.Jc=r,this.yu=o,u==null||u.onVariationDataUpdated(r,i),this.hu=!1,!0)}deleteVariationVBO(){var e;let t=this.i.webglResourceRepository;return this.Yc!==V.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.Yc),this.Yc=V.InvalidCGAPIResourceUid,this.Jc=void 0,this.yu=void 0,(e=this.Qc)==null||e.onVariationVBODeleted(),!0):!1}updateVAO(){var t;(t=this.Xc())==null||t.updateVAO()}deleteVAO(){var t;(t=this.Qc)==null||t.deleteVAO()}castRay(t,e,i=0){var u;let r,o=Number.MAX_VALUE,n=0,c=0;for(let a of this.zc){let l=a.castRay(t,e,!0,!0,i,this.Ou);M.defined(l.data)&&((u=l.data)==null?void 0:u.t)<o&&(o=l.data.t,r=l.data.position,n=l.data.u,c=l.data.v)}return M.defined(r)?{result:!0,data:{t:o,u:n,v:c,position:r}}:{result:!1}}get primitives(){return this.zc}get meshUID(){return this.Mu}get _variationVBOUid(){return this.Yc}get _variationEntityInfo(){return this.Jc}get _variationEntityUIDs(){return this.yu}get _isGpuCullable(){return this.Bu?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.$c)return!0;if(!this.Du)return!1;for(let t=0;t<this.zc.length;t++)if(this.zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.Tu===this.zc.length&&this.Ru===this.qc&&this.Uu===this.$c?this.Iu:(this.Tu=this.zc.length,this.Ru=this.qc,this.Uu=this.$c,this.Iu=this.$u(),this.Iu)}$u(){if(this.zc.length===0)return!1;let t=(e,i)=>e.some(r=>r.split(".")[0]===i);for(let e of this.zc){let i=e.attributeSemantics;if(!t(i,"POSITION")||this.$c&&(!t(i,"JOINTS_0")||!t(i,"WEIGHTS_0")))return!1;for(let r of e.targets){let o=!1;for(let n of r.keys())n.split(".")[0]==="POSITION"&&(o=!0);if(!o)return!1}}return!0}_onPrimitivePositionUpdated(){this.qc++,s.Gu++;for(let t of this.Zc)t.getMeshRenderer().markNeedsLoad()}get primitivePositionUpdateCount(){return this.qc}get AABB(){if(this.qc!==this.Nu&&(this.du.initialize(),this.Nu=this.qc),this.du.isVanilla())for(let t of this.zc)this.du.mergeAABB(t.AABB);return this.du}al(){for(let t=0;t<this.zc.length;t++){let e=this.Eu[t],i=this.zc[t];i.targets[0].forEach((o,n)=>{let c=e.getAttribute(n),u=c.elementCount;for(let a=0;a<u;a++)c.setElementFromSameCompositionAccessor(a,i.getAttribute(n))})}}_calcTangents(){if(this._u())for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let i=t.attributeSemantics.indexOf(g.Texcoord0.XY),r=t.attributeSemantics.indexOf(g.Normal.XYZ);if(i!==-1&&r!==-1){let o=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[o],c=t.attributeAccessors[i],u=t.attributeAccessors[r],a=t.indicesAccessor,l=3;(t.primitiveMode===x.TriangleStrip||t.primitiveMode===x.TriangleFan)&&(l=1);let f=t.getVertexCountAsIndicesBased(),p=n.byteLength*4/3,b=this.i.memoryManager.createBufferOnDemand(I.CPUGeneric,p,4).takeBufferView({byteLengthToNeed:p,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:C.Float,count:n.elementCount}).unwrapForce();for(let m=0;m<f-2;m+=l){let v=n.getVec3(m,{indicesAccessor:a}),A=n.getVec3(m+1,{indicesAccessor:a}),S=n.getVec3(m+2,{indicesAccessor:a}),T=c.getVec2(m,{indicesAccessor:a}),R=c.getVec2(m+1,{indicesAccessor:a}),U=c.getVec2(m+2,{indicesAccessor:a}),N=u.getVec3(m,{indicesAccessor:a});this.il(m,v,A,S,T,R,U,N,b,a)}t.setVertexAttribute(b,g.Tangent.XYZ)}}}il(t,e,i,r,o,n,c,u,a,l){let f=this.Pu(e,i,r,o,n,c,u,s.ju),p=this.Pu(i,r,e,n,c,o,u,s.Ju),y=this.Pu(r,e,i,c,o,n,u,s.Ku);a.setVec4(t,f.x,f.y,f.z,1,{indicesAccessor:l}),a.setVec4(t+1,p.x,p.y,p.z,1,{indicesAccessor:l}),a.setVec4(t+2,y.x,y.y,y.z,1,{indicesAccessor:l})}Pu(t,e,i,r,o,n,c,u){let a=[s.Tt.setComponents(t.x,r.x,r.y),s.bt.setComponents(t.y,r.x,r.y),s.ve.setComponents(t.z,r.x,r.y)],l=[s.ku.setComponents(e.x,o.x,o.y),s.Lu.setComponents(e.y,o.x,o.y),s.Wu.setComponents(e.z,o.x,o.y)],f=[s.Zu.setComponents(i.x,n.x,n.y),s.Fu.setComponents(i.y,n.x,n.y),s.Xu.setComponents(i.z,n.x,n.y)],p=[],y=[];for(let d=0;d<3;d++){let b=h.subtractTo(l[d],a[d],s.Yu),m=h.subtractTo(f[d],l[d],s.Hu),v=h.crossTo(b,m,s.qu),A=Math.abs(v.x)<Number.EPSILON;if(A)return G.default.assert(A,"Polygons or polygons on UV are degenerate!"),O.fromCopyArray([0,0,0]);p[d]=-v.y/v.x,y[d]=-v.z/v.x}return p[0]*p[0]+p[1]*p[1]+p[2]*p[2]<Number.EPSILON?(h.crossTo(c,e,u),u.normalize()):u.setComponents(p[0],p[1],p[2]).normalize()}_u(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.zc){let e=t.getAttribute(g.BaryCentricCoord.XYZ);if(e!=null){let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount;for(let c=0;c<n;c++){let u=e.getVec4(c,{});e.setVec4(c,c%3===0?1:0,c%3===1?1:0,c%3===2?1:0,u.w,{})}}else{let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount,c=n*4*4,l=this.i.memoryManager.createBufferOnDemand(I.CPUGeneric,c,4).takeBufferView({byteLengthToNeed:c,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:C.Float,count:n}).unwrapForce();for(let f=0;f<n;f++)l.setVec4(f,f%3===0?1:0,f%3===1?1:0,f%3===2?1:0,f,{});t.setVertexAttribute(l,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Ou=!0;let i=t.attributeSemantics.indexOf(g.Position.XYZ),r=t.attributeAccessors[i],o=t.indicesAccessor,n=3;(t.primitiveMode===x.TriangleStrip||t.primitiveMode===x.TriangleFan)&&(n=1);let c=t.getVertexCountAsIndicesBased(),u=r.byteLength,f=this.i.memoryManager.createBufferOnDemand(I.CPUGeneric,u,4).takeBufferView({byteLengthToNeed:u,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:C.Float,count:r.elementCount}).unwrapForce();for(let p=0;p<c-2;p+=n){let y=r.getVec3(p,{indicesAccessor:o}),d=r.getVec3(p+1,{indicesAccessor:o}),b=r.getVec3(p+2,{indicesAccessor:o});this.sl(p,y,d,b,f,o)}t.setVertexAttribute(f,g.Normal.XYZ)}}sl(t,e,i,r,o,n){let c=i.x-e.x,u=i.y-e.y,a=i.z-e.z,l=r.x-e.x,f=r.y-e.y,p=r.z-e.z,y=u*p-a*f,d=a*l-c*p,b=c*f-u*l,m=Math.hypot(y,d,b);m<=1e-6&&(m=1e-4),m=1/m,y*=m,d*=m,b*=m,o.setVec3(t,y,d,b,{indicesAccessor:n}),o.setVec3(t+1,y,d,b,{indicesAccessor:n}),o.setVec3(t+2,y,d,b,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let e of this.primitives)e.applyMaterialVariant(t)}getCurrentVariantName(){function t(i){return i.every(r=>r===i[0])}let e=this.primitives.map(i=>i.getCurrentVariantName());return e.length===0?"":t(e)?e[0]:""}getVariantNames(){let t=[];for(let e of this.primitives)Array.prototype.push.apply(t,e.getVariantNames());return t}isSetUpDone(){if(this.hu)return!1;let t=!0;for(let e of this.primitives)if(e.vertexHandles==null){t=!1;break}return t?this.zu!==this.qc?(this.zu=this.qc,!1):!0:!1}_invalidateMultiDrawStructure(){var t;(t=this.Xc())==null||t.markMultiDrawDirty()}_updateVBOAndVAO(){let t=this.Xc();if(t!=null&&t.isInstanceSidTextureMode()){t.markMultiDrawDirty();return}let e=this.getPrimitiveNumber();for(let i=0;i<e;i++){let r=this.getPrimitiveAt(i);M.exist(r.vertexHandles)?r.update3DAPIVertexData():r.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentRenderBackend!==B.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){var t;for(let e of this.zc)e.delete3DAPIVertexData();(t=this.Qc)==null||t.freeUnusedInstanceSidSlots()}};s.invalidateMeshUID=-1,s.wu=s.invalidateMeshUID,s.Tt=h.zero(),s.bt=h.zero(),s.ve=h.zero(),s.ku=h.zero(),s.Lu=h.zero(),s.Wu=h.zero(),s.Zu=h.zero(),s.Fu=h.zero(),s.Xu=h.zero(),s.Yu=h.zero(),s.Hu=h.zero(),s.qu=h.zero(),s.ju=h.zero(),s.Ju=h.zero(),s.Ku=h.zero(),s.Gu=0;var D=s;export{D as Mesh};
@@ -1,6 +1,5 @@
1
1
  import type { Count, Index, Offset, PrimitiveUID, TypedArray } from '../../types/CommonTypes';
2
2
  import type { MultiDrawEntry, MultiDrawGroup } from '../../webgl/MultiDraw';
3
- import type { VertexHandles } from '../../webgl/WebGLResourceRepository';
4
3
  import { RnObject } from '../core/RnObject';
5
4
  import { type ComponentTypeEnum } from '../definitions/ComponentType';
6
5
  import { type CompositionTypeEnum } from '../definitions/CompositionType';
@@ -10,6 +9,7 @@ import type { Material } from '../materials/core/Material';
10
9
  import { AABB } from '../math/AABB';
11
10
  import type { IVector3 } from '../math/IVector';
12
11
  import type { Accessor } from '../memory/Accessor';
12
+ import type { VertexHandles } from '../renderer/CGAPIResourceRepository';
13
13
  import type { Engine } from '../system/Engine';
14
14
  import type { Mesh } from './Mesh';
15
15
  import { type IMesh, type PrimitiveSortKey, type PrimitiveSortKeyLength, type PrimitiveSortKeyOffset, type RaycastResultEx1 } from './types/GeometryTypes';