rhodonite 0.25.0 → 0.26.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 (469) hide show
  1. package/README.md +93 -19
  2. package/VERSION-FILE +1 -1
  3. package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
  4. package/dist/esm/foundation/components/BlendShape/BlendShapeComponent.js +1 -1
  5. package/dist/esm/foundation/components/Camera/CameraComponent.d.ts +34 -0
  6. package/dist/esm/foundation/components/Camera/CameraComponent.js +1 -1
  7. package/dist/esm/foundation/components/Light/LightComponent.d.ts +3 -1
  8. package/dist/esm/foundation/components/Light/LightComponent.js +1 -1
  9. package/dist/esm/foundation/components/Mesh/MeshComponent.js +1 -1
  10. package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
  11. package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
  12. package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.js +1 -1
  13. package/dist/esm/foundation/components/Shape/ShapeComponent.js +1 -1
  14. package/dist/esm/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +1 -1
  15. package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +1 -1
  16. package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +1 -1
  17. package/dist/esm/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
  18. package/dist/esm/foundation/components/Skeletal/SkeletalComponent.js +1 -1
  19. package/dist/esm/foundation/components/Transform/TransformComponent.js +1 -1
  20. package/dist/esm/foundation/components/Trigger/TriggerComponent.js +1 -1
  21. package/dist/esm/foundation/components/Vrm/VrmComponent.js +1 -1
  22. package/dist/esm/foundation/constraints/VrmAimConstraint.js +1 -1
  23. package/dist/esm/foundation/constraints/VrmRollConstraint.js +1 -1
  24. package/dist/esm/foundation/constraints/VrmRotationConstraint.js +1 -1
  25. package/dist/esm/foundation/core/Component.js +1 -1
  26. package/dist/esm/foundation/core/ComponentRepository.js +1 -1
  27. package/dist/esm/foundation/core/Entity.js +1 -1
  28. package/dist/esm/foundation/core/EntityRepository.js +1 -1
  29. package/dist/esm/foundation/geometry/ComplexVertexAttribute.js +1 -1
  30. package/dist/esm/foundation/geometry/Mesh.js +1 -1
  31. package/dist/esm/foundation/geometry/Primitive.js +1 -1
  32. package/dist/esm/foundation/gizmos/AABBGizmo.js +1 -1
  33. package/dist/esm/foundation/gizmos/CapsuleColliderGizmo.js +1 -1
  34. package/dist/esm/foundation/gizmos/Gizmo.d.ts +13 -0
  35. package/dist/esm/foundation/gizmos/Gizmo.js +1 -1
  36. package/dist/esm/foundation/gizmos/JointGizmo.js +1 -1
  37. package/dist/esm/foundation/gizmos/LightGizmo.d.ts +0 -1
  38. package/dist/esm/foundation/gizmos/LightGizmo.js +1 -1
  39. package/dist/esm/foundation/gizmos/LocatorGizmo.js +1 -1
  40. package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
  41. package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
  42. package/dist/esm/foundation/gizmos/ShapeGizmo.js +1 -1
  43. package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
  44. package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
  45. package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
  46. package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
  47. package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
  48. package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
  49. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
  50. package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
  51. package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.js +1 -0
  52. package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
  53. package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.js +1 -0
  54. package/dist/esm/foundation/importer/AnimationAssigner.js +1 -1
  55. package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
  56. package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
  57. package/dist/esm/foundation/importer/GltfImporter.js +1 -1
  58. package/dist/esm/foundation/importer/ModelConverter.js +1 -1
  59. package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
  60. package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
  61. package/dist/esm/foundation/importer/VrmImporter.js +1 -1
  62. package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
  63. package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +18 -18
  64. package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
  65. package/dist/esm/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
  66. package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
  67. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
  68. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
  69. package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
  70. package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
  71. package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +1 -1
  72. package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +1 -1
  73. package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
  74. package/dist/esm/foundation/math/MathClassUtil.js +1 -1
  75. package/dist/esm/foundation/math/Quaternion.js +1 -1
  76. package/dist/esm/foundation/math/Transform3D.js +1 -1
  77. package/dist/esm/foundation/math/shapes/MathSphere.js +1 -1
  78. package/dist/esm/foundation/memory/Accessor.js +6 -6
  79. package/dist/esm/foundation/memory/BufferView.js +1 -1
  80. package/dist/esm/foundation/misc/cache/Cache.js +1 -1
  81. package/dist/esm/foundation/physics/VRMSpring/CapsuleCollider.js +1 -1
  82. package/dist/esm/foundation/physics/VRMSpring/SphereCollider.js +1 -1
  83. package/dist/esm/foundation/physics/VRMSpring/VRMSpringBone.js +1 -1
  84. package/dist/esm/foundation/renderer/Frame.js +1 -1
  85. package/dist/esm/foundation/renderer/RenderPass.js +1 -1
  86. package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
  87. package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +1 -0
  88. package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
  89. package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -0
  90. package/dist/esm/foundation/renderer/pipelines/DeferredRenderPipeline.js +1 -1
  91. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
  92. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
  93. package/dist/esm/foundation/system/Engine.d.ts +37 -3
  94. package/dist/esm/foundation/system/Engine.js +1 -1
  95. package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
  96. package/dist/esm/foundation/textures/CubeTexture.js +1 -1
  97. package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
  98. package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
  99. package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
  100. package/dist/esm/foundation/textures/Texture.js +1 -1
  101. package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
  102. package/dist/esm/foundation/textures/VideoTexture.js +1 -1
  103. package/dist/esm/version.js +1 -1
  104. package/dist/esm/webgl/MultiDraw.js +1 -1
  105. package/dist/esm/webgl/MultiDrawRepository.js +1 -1
  106. package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
  107. package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +8 -0
  108. package/dist/esm/webgl/WebGLStrategyWebGL2.js +47 -28
  109. package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +0 -3
  110. package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +35 -0
  111. package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +140 -0
  112. package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +175 -0
  113. package/dist/esm/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +18 -0
  114. package/dist/esm/webgl/shaders/StandardShaderPart.js +3 -3
  115. package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
  116. package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +9 -9
  117. package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
  118. package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
  119. package/dist/esm/webgpu/WebGpuGpuCulling.js +1 -1
  120. package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
  121. package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -1
  122. package/dist/esm/webgpu/WebGpuResourceRepository.js +3 -3
  123. package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +8 -0
  124. package/dist/esm/webgpu/WebGpuStrategyBasic.js +78 -59
  125. package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
  126. package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +30 -0
  127. package/dist/esm/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +133 -0
  128. package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +169 -0
  129. package/dist/esm/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +19 -0
  130. package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.d.ts +54 -0
  131. package/dist/esmdev/foundation/components/BlendShape/BlendShapeComponent.js +107 -1
  132. package/dist/esmdev/foundation/components/Camera/CameraComponent.d.ts +34 -0
  133. package/dist/esmdev/foundation/components/Camera/CameraComponent.js +118 -46
  134. package/dist/esmdev/foundation/components/CameraController/CameraControllerComponent.js +8 -8
  135. package/dist/esmdev/foundation/components/CharacterController/CharacterAnimationController.js +74 -74
  136. package/dist/esmdev/foundation/components/CharacterController/CharacterControllerComponent.js +39 -39
  137. package/dist/esmdev/foundation/components/Constraint/ConstraintComponent.js +4 -4
  138. package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +3 -1
  139. package/dist/esmdev/foundation/components/Light/LightComponent.js +126 -121
  140. package/dist/esmdev/foundation/components/Mesh/MeshComponent.js +50 -50
  141. package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +96 -92
  142. package/dist/esmdev/foundation/components/Physics/PhysicsComponent.js +73 -73
  143. package/dist/esmdev/foundation/components/Raymarching/RaymarchingComponent.js +54 -54
  144. package/dist/esmdev/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +251 -251
  145. package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.d.ts +16 -0
  146. package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.js +375 -343
  147. package/dist/esmdev/foundation/components/Shape/ShapeComponent.js +31 -31
  148. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +5 -5
  149. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +5 -5
  150. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +9 -9
  151. package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.d.ts +48 -0
  152. package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.js +337 -205
  153. package/dist/esmdev/foundation/components/Transform/TransformComponent.js +93 -93
  154. package/dist/esmdev/foundation/components/Trigger/TriggerComponent.js +61 -61
  155. package/dist/esmdev/foundation/components/Vrm/VrmComponent.js +44 -44
  156. package/dist/esmdev/foundation/constraints/VrmAimConstraint.js +11 -11
  157. package/dist/esmdev/foundation/constraints/VrmRollConstraint.js +16 -16
  158. package/dist/esmdev/foundation/constraints/VrmRotationConstraint.js +10 -10
  159. package/dist/esmdev/foundation/core/Component.js +32 -32
  160. package/dist/esmdev/foundation/core/ComponentMemoryRegistry.js +42 -42
  161. package/dist/esmdev/foundation/core/ComponentRepository.js +37 -37
  162. package/dist/esmdev/foundation/core/Config.js +9 -9
  163. package/dist/esmdev/foundation/core/Entity.js +9 -9
  164. package/dist/esmdev/foundation/core/EntityRepository.js +19 -19
  165. package/dist/esmdev/foundation/core/GlobalDataRepository.js +17 -17
  166. package/dist/esmdev/foundation/core/MemoryManager.js +25 -25
  167. package/dist/esmdev/foundation/core/RnObject.js +37 -37
  168. package/dist/esmdev/foundation/definitions/Blend.js +3 -3
  169. package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
  170. package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
  171. package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
  172. package/dist/esmdev/foundation/definitions/ShaderSemantics.js +6 -6
  173. package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
  174. package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
  175. package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
  176. package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
  177. package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +112 -112
  178. package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +24 -24
  179. package/dist/esmdev/foundation/geometry/Frustum.js +41 -41
  180. package/dist/esmdev/foundation/geometry/Mesh.js +218 -218
  181. package/dist/esmdev/foundation/geometry/Primitive.js +133 -133
  182. package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
  183. package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
  184. package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
  185. package/dist/esmdev/foundation/gizmos/AABBGizmo.js +17 -20
  186. package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +24 -26
  187. package/dist/esmdev/foundation/gizmos/Gizmo.d.ts +13 -0
  188. package/dist/esmdev/foundation/gizmos/Gizmo.js +43 -21
  189. package/dist/esmdev/foundation/gizmos/JointGizmo.js +38 -40
  190. package/dist/esmdev/foundation/gizmos/LightGizmo.d.ts +0 -1
  191. package/dist/esmdev/foundation/gizmos/LightGizmo.js +26 -30
  192. package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +26 -29
  193. package/dist/esmdev/foundation/gizmos/RotationGizmo.js +217 -219
  194. package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +135 -137
  195. package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +44 -47
  196. package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +25 -27
  197. package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +132 -134
  198. package/dist/esmdev/foundation/helpers/BloomHelper.js +34 -34
  199. package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
  200. package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
  201. package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
  202. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +119 -119
  203. package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.d.ts +25 -0
  204. package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.js +61 -0
  205. package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.d.ts +33 -0
  206. package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.js +127 -0
  207. package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
  208. package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
  209. package/dist/esmdev/foundation/importer/Gltf2Importer.js +14 -14
  210. package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
  211. package/dist/esmdev/foundation/importer/ModelConverter.js +131 -131
  212. package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
  213. package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
  214. package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
  215. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +27 -27
  216. package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +2 -2
  217. package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +138 -138
  218. package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +19 -19
  219. package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +5 -5
  220. package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +5 -5
  221. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.d.ts +11 -0
  222. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +68 -53
  223. package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +26 -26
  224. package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
  225. package/dist/esmdev/foundation/materials/core/Material.js +115 -115
  226. package/dist/esmdev/foundation/materials/core/MaterialRepository.js +65 -65
  227. package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
  228. package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
  229. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +16 -17
  230. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +17 -18
  231. package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
  232. package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
  233. package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
  234. package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
  235. package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
  236. package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
  237. package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
  238. package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
  239. package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
  240. package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
  241. package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
  242. package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
  243. package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
  244. package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
  245. package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
  246. package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
  247. package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
  248. package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
  249. package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
  250. package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
  251. package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
  252. package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
  253. package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
  254. package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
  255. package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
  256. package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
  257. package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
  258. package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
  259. package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
  260. package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
  261. package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
  262. package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
  263. package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
  264. package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
  265. package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
  266. package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
  267. package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
  268. package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
  269. package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
  270. package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
  271. package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
  272. package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
  273. package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
  274. package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
  275. package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
  276. package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
  277. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
  278. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
  279. package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
  280. package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
  281. package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
  282. package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
  283. package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
  284. package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
  285. package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
  286. package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
  287. package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
  288. package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
  289. package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
  290. package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
  291. package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
  292. package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
  293. package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
  294. package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
  295. package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
  296. package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
  297. package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
  298. package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
  299. package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
  300. package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
  301. package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
  302. package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
  303. package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
  304. package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
  305. package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
  306. package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
  307. package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
  308. package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
  309. package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
  310. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
  311. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
  312. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
  313. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
  314. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
  315. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
  316. package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
  317. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
  318. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
  319. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
  320. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
  321. package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
  322. package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
  323. package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
  324. package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
  325. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
  326. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
  327. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
  328. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
  329. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
  330. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
  331. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
  332. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
  333. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
  334. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
  335. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
  336. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
  337. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
  338. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
  339. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
  340. package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
  341. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
  342. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
  343. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
  344. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
  345. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
  346. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
  347. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
  348. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
  349. package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
  350. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
  351. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
  352. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
  353. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
  354. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
  355. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
  356. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
  357. package/dist/esmdev/foundation/math/AABB.js +132 -132
  358. package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
  359. package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
  360. package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
  361. package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
  362. package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
  363. package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
  364. package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
  365. package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
  366. package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
  367. package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
  368. package/dist/esmdev/foundation/math/Quaternion.js +20 -20
  369. package/dist/esmdev/foundation/math/Transform3D.js +83 -83
  370. package/dist/esmdev/foundation/math/shapes/MathSphere.js +9 -9
  371. package/dist/esmdev/foundation/memory/Accessor.js +370 -370
  372. package/dist/esmdev/foundation/memory/Buffer.js +40 -40
  373. package/dist/esmdev/foundation/memory/BufferView.js +33 -33
  374. package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
  375. package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
  376. package/dist/esmdev/foundation/misc/Logger.js +14 -14
  377. package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
  378. package/dist/esmdev/foundation/misc/Time.js +27 -27
  379. package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
  380. package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
  381. package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
  382. package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +13 -13
  383. package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +203 -203
  384. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +241 -241
  385. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
  386. package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +42 -42
  387. package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +27 -27
  388. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +10 -10
  389. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +51 -51
  390. package/dist/esmdev/foundation/renderer/Expression.js +6 -6
  391. package/dist/esmdev/foundation/renderer/Frame.js +12 -12
  392. package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
  393. package/dist/esmdev/foundation/renderer/RenderPass.js +102 -99
  394. package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.d.ts +33 -0
  395. package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +66 -0
  396. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.d.ts +135 -0
  397. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +275 -0
  398. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +153 -153
  399. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
  400. package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +6 -6
  401. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +62 -16
  402. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +535 -428
  403. package/dist/esmdev/foundation/system/Engine.d.ts +37 -3
  404. package/dist/esmdev/foundation/system/Engine.js +266 -224
  405. package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
  406. package/dist/esmdev/foundation/system/InputManager.js +56 -56
  407. package/dist/esmdev/foundation/system/ModuleManager.js +6 -6
  408. package/dist/esmdev/foundation/textures/AbstractTexture.js +50 -50
  409. package/dist/esmdev/foundation/textures/CubeTexture.js +32 -32
  410. package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
  411. package/dist/esmdev/foundation/textures/RenderTargetTexture.js +25 -25
  412. package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +37 -37
  413. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +19 -19
  414. package/dist/esmdev/foundation/textures/Sampler.js +24 -24
  415. package/dist/esmdev/foundation/textures/Texture.js +83 -83
  416. package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
  417. package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
  418. package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
  419. package/dist/esmdev/version.js +2 -2
  420. package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
  421. package/dist/esmdev/webgl/MultiDraw.js +2 -2
  422. package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
  423. package/dist/esmdev/webgl/WebGLContextWrapper.js +164 -164
  424. package/dist/esmdev/webgl/WebGLGpuTimer.js +32 -32
  425. package/dist/esmdev/webgl/WebGLResourceRepository.js +306 -306
  426. package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
  427. package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +8 -0
  428. package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +296 -261
  429. package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
  430. package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +2 -2
  431. package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.js +12 -0
  432. package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +12 -0
  433. package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.js +12 -0
  434. package/dist/esmdev/webgl/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.js +12 -0
  435. package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +4 -4
  436. package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
  437. package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
  438. package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
  439. package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
  440. package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
  441. package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +3 -3
  442. package/dist/esmdev/webgl/shaders/nodes/EndShader.js +3 -3
  443. package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
  444. package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
  445. package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
  446. package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
  447. package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
  448. package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
  449. package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
  450. package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +27 -27
  451. package/dist/esmdev/webgpu/GpuCullingRegistry.js +94 -94
  452. package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
  453. package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
  454. package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
  455. package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
  456. package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
  457. package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
  458. package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +37 -37
  459. package/dist/esmdev/webgpu/WebGpuResourceRepository.js +597 -597
  460. package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +8 -0
  461. package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +170 -133
  462. package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
  463. package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.frag.wgsl.js +12 -0
  464. package/dist/esmdev/webgpu/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.wgsl.js +12 -0
  465. package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.frag.wgsl.js +12 -0
  466. package/dist/esmdev/webgpu/shaderity_shaders/TemporalAAResolveShader/TemporalAAResolveShader.vert.wgsl.js +12 -0
  467. package/dist/esmdev/xr/WebARSystem.js +69 -69
  468. package/dist/esmdev/xr/WebXRSystem.js +153 -153
  469. package/package.json +1 -1
@@ -22,32 +22,33 @@ import { Frame } from '../Frame';
22
22
  * @example
23
23
  * ```typescript
24
24
  * const expressions = [...];
25
- * const matrix = [...];
26
25
  *
27
26
  * // Create and setup the render pipeline
28
- * const forwardRenderPipeline = new Rn.ForwardRenderPipeline();
27
+ * const forwardRenderPipeline = new Rn.ForwardRenderPipeline(engine);
29
28
  * await forwardRenderPipeline.setup(1024, 1024, {isShadow: true, isBloom: true});
30
29
  *
31
30
  * // Configure expressions and IBL
32
31
  * forwardRenderPipeline.setExpressions(expressions);
33
32
  *
34
- * const diffuseCubeTexture = new Rn.CubeTexture();
35
- * diffuseCubeTexture.baseUriToLoad = './../../../assets/ibl/papermill/diffuse/diffuse';
36
- * diffuseCubeTexture.isNamePosNeg = true;
37
- * diffuseCubeTexture.hdriFormat = Rn.HdriFormat.RGBE_PNG;
38
- * diffuseCubeTexture.mipmapLevelNumber = 1;
33
+ * const diffuseCubeTexture = await Rn.CubeTexture.loadFromUrl(engine, {
34
+ * baseUrl: './../../../assets/ibl/papermill/diffuse/diffuse',
35
+ * mipmapLevelNumber: 1,
36
+ * isNamePosNeg: true,
37
+ * hdriFormat: Rn.HdriFormat.RGBE_PNG,
38
+ * });
39
39
  *
40
- * const specularCubeTexture = new Rn.CubeTexture();
41
- * specularCubeTexture.baseUriToLoad = './../../../assets/ibl/papermill/specular/specular';
42
- * specularCubeTexture.isNamePosNeg = true;
43
- * specularCubeTexture.hdriFormat = Rn.HdriFormat.RGBE_PNG;
44
- * specularCubeTexture.mipmapLevelNumber = 10;
40
+ * const specularCubeTexture = await Rn.CubeTexture.loadFromUrl(engine, {
41
+ * baseUrl: './../../../assets/ibl/papermill/specular/specular',
42
+ * mipmapLevelNumber: 10,
43
+ * isNamePosNeg: true,
44
+ * hdriFormat: Rn.HdriFormat.RGBE_PNG,
45
+ * });
45
46
  *
46
47
  * forwardRenderPipeline.setIBLTextures(diffuseCubeTexture, specularCubeTexture);
47
48
  *
48
49
  * // Start the render loop
49
50
  * forwardRenderPipeline.startRenderLoop((frame) => {
50
- * Rn.Engine.process(frame);
51
+ * engine.process(frame);
51
52
  * });
52
53
  * ```
53
54
  */
@@ -57,6 +58,8 @@ export declare class ForwardRenderPipeline extends RnObject {
57
58
  private __isShadow;
58
59
  private __isBloom;
59
60
  private __isSimple;
61
+ private __isTemporalAA;
62
+ private __temporalAA?;
60
63
  private __shadowMapSize;
61
64
  private __frame?;
62
65
  private __frameBufferMultiView?;
@@ -132,6 +135,9 @@ export declare class ForwardRenderPipeline extends RnObject {
132
135
  * @param options.isBloom - Whether to enable bloom post-processing effect (default: false)
133
136
  * @param options.shadowMapSize - Size of the shadow map texture in pixels (default: 1024)
134
137
  * @param options.isSimple - Whether to use simplified rendering without post-processing (default: false)
138
+ * @param options.isTemporalAA - Whether to enable temporal anti-aliasing (default: false). It replaces the 4x MSAA
139
+ * of the main render target: the camera projection is jittered by a sub-pixel offset every frame, and the frames
140
+ * are accumulated with motion vectors. Ignored in the simple mode and for WebXR multi-view rendering.
135
141
  *
136
142
  * @returns A Result indicating success or failure of the setup operation
137
143
  *
@@ -155,10 +161,11 @@ export declare class ForwardRenderPipeline extends RnObject {
155
161
  * }
156
162
  * ```
157
163
  */
158
- setup(canvasWidth: number, canvasHeight: number, { isShadow, isBloom, shadowMapSize, isSimple }?: {
164
+ setup(canvasWidth: number, canvasHeight: number, { isShadow, isBloom, shadowMapSize, isSimple, isTemporalAA }?: {
159
165
  isBloom?: boolean | undefined;
160
166
  isShadow?: boolean | undefined;
161
167
  isSimple?: boolean | undefined;
168
+ isTemporalAA?: boolean | undefined;
162
169
  shadowMapSize?: number | undefined;
163
170
  }): Promise<Err<unknown, undefined> | Ok<unknown, unknown>>;
164
171
  /**
@@ -185,6 +192,11 @@ export declare class ForwardRenderPipeline extends RnObject {
185
192
  * @internal
186
193
  */
187
194
  private __getMainFrameBuffer;
195
+ /**
196
+ * Whether temporal anti-aliasing is used: requested in setup, not in the simple mode, and not in WebXR mode
197
+ * (the eye cameras are not jittered, and stereo rendering keeps MSAA).
198
+ */
199
+ private __isTemporalAAActive;
188
200
  /**
189
201
  * Sets the expressions to be rendered by the pipeline.
190
202
  *
@@ -227,7 +239,7 @@ export declare class ForwardRenderPipeline extends RnObject {
227
239
  * ```typescript
228
240
  * const result = pipeline.startRenderLoop((frame) => {
229
241
  * // Update scene
230
- * Rn.Engine.process(frame);
242
+ * engine.process(frame);
231
243
  *
232
244
  * // Custom per-frame logic
233
245
  * updateAnimations();
@@ -235,7 +247,7 @@ export declare class ForwardRenderPipeline extends RnObject {
235
247
  * });
236
248
  *
237
249
  * if (result.isErr()) {
238
- * console.error('Failed to start render loop:', result.getErr());
250
+ * console.error('Failed to start render loop:', result.getRnError());
239
251
  * }
240
252
  * ```
241
253
  */
@@ -254,6 +266,40 @@ export declare class ForwardRenderPipeline extends RnObject {
254
266
  * ```
255
267
  */
256
268
  draw(): void;
269
+ /**
270
+ * Whether temporal anti-aliasing is enabled (requested in setup and supported by the current render targets).
271
+ */
272
+ get isTemporalAA(): boolean;
273
+ /**
274
+ * Discards the accumulated history of temporal anti-aliasing, so that the next frame does not blend with the
275
+ * previous frames. Call it when the view changes discontinuously (e.g. a camera cut).
276
+ */
277
+ resetTemporalAAHistory(): void;
278
+ /**
279
+ * The weight of the current frame in the temporal anti-aliasing blend for pixels that move by a pixel per frame
280
+ * or more (0-1, default 0.1). Larger values react faster to changes and smooth less.
281
+ */
282
+ set temporalAACurrentFrameWeight(weight: number);
283
+ get temporalAACurrentFrameWeight(): number;
284
+ /**
285
+ * The weight of the current frame in the temporal anti-aliasing blend for pixels that do not move (0-1, default
286
+ * 0.04). Smaller values average more frames of the jitter sequence, which steadies the edges of still images;
287
+ * slower pixels interpolate between this weight and {@link ForwardRenderPipeline.temporalAACurrentFrameWeight}.
288
+ */
289
+ set temporalAAStaticFrameWeight(weight: number);
290
+ get temporalAAStaticFrameWeight(): number;
291
+ /**
292
+ * Sets the size of the variance clipping box of the temporal anti-aliasing history in standard deviations
293
+ * (default 1). A large value effectively disables the clipping, which makes wrong motion vectors visible as
294
+ * trails. For debugging.
295
+ *
296
+ * @internal
297
+ */
298
+ _setTemporalAAVarianceClipGamma(gamma: number): void;
299
+ /**
300
+ * Jitters the camera and keeps the previous frame state for temporal anti-aliasing. Runs before Engine.process.
301
+ */
302
+ private __prepareTemporalAAFrame;
257
303
  /**
258
304
  * Requests a refresh of the shadow map expressions on the next frame.
259
305
  * This is useful when materials with shadow support have been changed or added
@@ -1 +1 @@
1
- import{CameraComponent as z}from"../../components/Camera/CameraComponent.js";import{RaymarchingComponent as F}from"../../components/Raymarching/RaymarchingComponent.js";import{RnObject as H}from"../../core/RnObject.js";import{ComponentType as $,CompositionType as G,PixelFormat as W,ToneMappingType as I}from"../../definitions/index.js";import{ShaderSemantics as v}from"../../definitions/ShaderSemantics.js";import{TextureFormat as R}from"../../definitions/TextureFormat.js";import{TextureParameter as w}from"../../definitions/TextureParameter.js";import{Bloom as Z}from"../../helpers/BloomHelper.js";import{collectRrnJson as J,createNodeBasedRaymarchingComponentShadowMaterial as V,createNodeBasedRaymarchingShadowMaterial as O,RAYMARCHING_COMPONENT_WORLD_MATRIX_SEMANTIC as U}from"../../helpers/materials/createNodeBasedRaymarchingMaterials.js";import{createToneMappingMaterial as K}from"../../helpers/materials/createToneMappingMaterial.js";import{RenderableHelper as C}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as X}from"../../helpers/RenderPassHelper.js";import{ShadowSystem as Q}from"../../helpers/Shadow/ShadowSystem.js";import{Scalar as B}from"../../math/Scalar.js";import{Vector2 as ee}from"../../math/Vector2.js";import{Vector3 as S}from"../../math/Vector3.js";import{Vector4 as N}from"../../math/Vector4.js";import{MiscUtil as k}from"../../misc/index.js";import{Is as g}from"../../misc/Is.js";import{Logger as te}from"../../misc/Logger.js";import{Err as L,Ok as Y}from"../../misc/Result.js";import{Sampler as re}from"../../textures/Sampler.js";import{Expression as b}from"../Expression.js";import{Frame as ie}from"../Frame.js";import{RenderPass as P}from"../RenderPass.js";var _=Object.freeze(S.fromCopy3(-1e20,-1e20,-1e20)),D=Object.freeze(S.fromCopy3(1e20,1e20,1e20)),j=class extends H{constructor(e){super();this.sm=0;this.Xx=0;this.jT=!1;this.rT=!1;this.Yx=!1;this.HT=1024;this.pp=[];this.IT=new b;this.dT=[];this.kT=0;this.LT=1;this.YT=1;this.qT=new Map;this.Zx=new Map;this.xT=new Map;this.zT=-1;this.AT=new Map;this.KT=I.GT_ToneMap;this.WT=[];this.QT=[];this.RT=new Map;this.gT=!1;this.fT=new Map;this.MT=new Map;this.i=e,this.$T=new Z(e)}LR(){this.tT!=null&&(this.tT.destroy3DAPIResources(),this.tT=void 0),this.uT!=null&&(this.uT.destroy3DAPIResources(),this.uT=void 0),this.oT!=null&&(this.oT.destroy3DAPIResources(),this.oT=void 0),this.sT!=null&&(this.sT.destroy3DAPIResources(),this.sT=void 0),this.nT!=null&&(this.nT.destroy3DAPIResources(),this.nT=void 0),this.$T.destroy3DAPIResources(),this.iT=void 0,this.vT=void 0,this.CT=void 0,this.FT=void 0,this.PT=void 0,this.pT=void 0,this.yT=void 0,this.hT=void 0,this.RT.clear(),this.gT=!1,this.fT.clear(),this.MT.clear(),this.xT.clear(),this.AT.clear(),this.qT.clear()}async setup(e,t,{isShadow:r=!1,isBloom:i=!1,shadowMapSize:s=1024,isSimple:n=!1}={}){if(this.sm=e,this.Xx=t,this.rT=i,this.jT=r,this.Yx=n,this.HT=s,this.iT!=null)return new L({message:"Already setup",error:void 0});let a=new ie;if(this.iT=a,!this.Yx){let u=new re(this.i,{wrapS:w.Repeat,wrapT:w.Repeat,minFilter:w.LinearMipmapLinear,magFilter:w.Linear});u.create(),this.BT=u,this.YR(e,t),r&&(this.aT=new Q(this.i,s)),this.nT!=null&&!k.isMobile()&&(this.vT=this.qR(this.nT)),this.tT!=null&&(this.UT=this.zR(this.tT),this.CT=this.$R(this.tT));let l=this.XR(),T=l.getColorAttachedRenderTargetTexture(0);if(i){let d=l.getColorAttachedRenderTargetTexture(0),{bloomExpression:p,bloomedRenderTarget:m}=this.$T.createBloomExpression({textureToBloom:d,parameters:{}});this.FT=p,T=m}let f=this.jR(T);this.PT=f}this.OT=this.HR(),this.pp.length>0&&this.setExpressions(this.pp);let[o,h]=this.ZR();return this.pT=o,this.TT=h,this.mT(),new Y}XT(){return this.tT!=null?this.bT:this.nT}XR(){return this.tT!=null?this.uT:this.sT}ST(){return this.tT!=null?this.tT:this.oT}setExpressions(e,t={isTransmission:!0}){let r=e.map(i=>i.clone());if(this.JR(e,{isTransmission:t.isTransmission}),t.isTransmission&&this.KR(r),this.aT!=null){let i=this.pp.flatMap(s=>s.renderPasses.flatMap(n=>n.entities));this.WT=this.aT.getExpressions(i,this.NR(),this.wR())}this.mT()}setGizmoExpression(e){this.IT=e}startRenderLoop(e){return this.iT==null?new L({message:"not initialized.",error:void 0}):(this.JT=e,this.mT(),this.i.startRenderLoop(()=>{let t=this.aT;if(t!=null){let r=this.QT,i=this.NR();t.isLightChanged()&&(this.WT=t.getExpressions(r,i,this.wR()),this.mT()),t.setDepthBiasPV(r,i)}this.QR(),e(this.iT)}),new Y)}draw(){this.JT(this.iT)}setNeedsShadowMapRefresh(){var e;(e=this.aT)==null||e.setNeedsRefresh()}resize(e,t){if(this.iT==null)return new L({message:"not initialized.",error:void 0});let r=this.i._webXRSystemIfEnabled;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&(e=r.getCanvasWidthForVr(),t=r.getCanvasHeightForVr()),e<=0||t<=0){let s=this.sm,n=this.Xx;if(s<=0||n<=0){let[a,o]=this.i.getCanvasSize();s=a,n=o}(s<=0||n<=0)&&(s=1,n=1),te.default.warn(`ForwardRenderPipeline.resize received non-positive dimensions (${e}x${t}). Falling back to ${s}x${n}.`),e=s,t=n}let i=this.getRaymarchingMaterial();return this.i.resizeCanvas(e,t),this.LR(),this.setup(e,t,{isShadow:this.jT,isBloom:this.rT,shadowMapSize:this.HT,isSimple:this.Yx}),i!=null&&this.setRaymarchingMaterial(i),new Y}setIBLTextures(e,t,r){this.NT=e,this.ET=t,g.exist(r)&&(this.cT=r),this.DR(),this.VR(),this.lT(),this.mT()}getInitialExpression(){return this.OT}getToneMappingExpression(){return this.PT}setDiffuseIBLContribution(e){this.LT=e,this.lT();for(let t of this.pp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}for(let t of this.dT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}}setSpecularIBLContribution(e){this.YT=e,this.lT();for(let t of this.pp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}for(let t of this.dT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}}setIBLRotation(e){this.kT=e,this.lT();for(let t of this.pp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.rotationOfCubeMap=e)}}JR(e,t={isTransmission:!0}){for(let r of e)for(let i of r.renderPasses)if(i.setToRenderOpaquePrimitives(!0),i.setToRenderBlendWithZWritePrimitives(!0),i.setToRenderBlendWithoutZWritePrimitives(!0),t.isTransmission?i.setToRenderTranslucentPrimitives(!1):i.setToRenderTranslucentPrimitives(!0),i.toClearDepthBuffer=!1,!this.Yx){let s=this.ST();s!=null&&(i.setFramebuffer(s),this.oT!=null&&(i.setResolveFramebuffer(this.sT),i.setResolveFramebuffer2(this.nT)))}this.pp=e,this.DR()}KR(e){for(let t of e){t.tryToSetUniqueName("modelTransparentForTransmission",!0);for(let r of t.renderPasses)if(r.setToRenderOpaquePrimitives(!1),r.setToRenderTranslucentPrimitives(!0),r.setToRenderBlendWithZWritePrimitives(!1),r.setToRenderBlendWithoutZWritePrimitives(!1),r.toClearDepthBuffer=!1,r.toClearColorBuffer=!1,!this.Yx){r.setFramebuffer(this.ST()),this.sT!=null&&r.setResolveFramebuffer(this.sT);for(let i of r.entities){let s=i.tryToGetMesh();if(g.exist(s)){let n=s.mesh;if(g.exist(n))for(let a=0;a<n.getPrimitiveNumber();a++)n.getPrimitiveAt(a).material.setTextureParameter("backBufferTexture",this.XT().getColorAttachedRenderTargetTexture(0),this.BT)}}}}this.dT=e,this.VR()}refreshBackBufferTextureOnTransparentMaterials(){var r;if(this.Yx)return;let e=(r=this.XT())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.BT;if(!(e==null||t==null))for(let i of this.dT)for(let s of i.renderPasses)for(let n of s.entities){let a=n.tryToGetMesh();if(g.exist(a)){let o=a.mesh;if(g.exist(o))for(let h=0;h<o.getPrimitiveNumber();h++)o.getPrimitiveAt(h).material.setTextureParameter("backBufferTexture",e,t)}}}HR(){let e=new b;e.tryToSetUniqueName("Initial",!0);let t=new P(this.i);if(t.clearColor=N.fromCopyArray4([0,0,0,0]),t.toClearColorBuffer=!0,t.toClearDepthBuffer=!0,t.isOutputForVr=!0,t.tryToSetUniqueName("InitialRenderPass",!0),e.addRenderPasses([t]),!this.Yx){let r=new P(this.i);r.clearColor=N.fromCopyArray4([0,0,0,0]),r.toClearColorBuffer=!0,r.toClearDepthBuffer=!0,r.setFramebuffer(this.ST()),r.tryToSetUniqueName("InitialRenderPassForFrameBuffer",!0),e.addRenderPasses([r])}return e}YR(e,t){let r=this.i._webXRSystemIfEnabled,i=this.i.cgApiResourceRepository;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&i.isSupportMultiViewVRRendering(this.i)){let s=C.createFrameBufferTextureArrayForMultiView(this.i,{width:e/2,height:t,arrayLength:2,level:0,internalFormat:this.rT?R.R11F_G11F_B10F:R.RGBA8,format:this.rT?W.RGB:W.RGBA,type:this.rT?$.Float:$.UnsignedByte});s.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiView",!0);let n=C.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.rT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});n.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlit",!0);let a=C.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.rT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlitBackBuffer",!0),this.tT=s,this.uT=n,this.bT=a,this.oT=void 0,this.sT=void 0,this.nT=void 0}else{console.log(`canvasWidth: ${e}, canvasHeight: ${t}`);let s=C.createFrameBufferMSAA(this.i,{width:e,height:t,colorBufferNum:1,colorFormats:[this.rT?R.R11F_G11F_B10F:R.RGBA8],sampleCountMSAA:4,depthBufferFormat:R.Depth32F});s.tryToSetUniqueName("FramebufferTargetOfToneMappingMsaa",!0);let n=C.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.rT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!0,depthTextureFormat:R.Depth32F});n.tryToSetUniqueName("FramebufferTargetOfToneMappingResolve",!0);let a=C.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.rT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingResolveForReference",!0),this.tT=void 0,this.uT=void 0,this.bT=void 0,this.oT=s,this.sT=n,this.nT=a}}qR(e){let t=new b;t.tryToSetUniqueName("GenerateMipmaps",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("GenerateMipmaps",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(function(){e.getColorAttachedRenderTargetTexture(0).generateMipmaps()}),t}zR(e){let t=new b;t.tryToSetUniqueName("MultiViewBlitBackBuffer",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlitBackBuffer",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.bT!=null&&!k.isMobile()){let i=this.bT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i),i.generateMipmaps()}}),t}$R(e){let t=new b;t.tryToSetUniqueName("MultiViewBlit",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlit",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.uT!=null){let i=this.uT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i)}}),t}jR(e){let t=new b,r=K(this.i);this.ZT=r,this.setToneMappingType(this.KT);let i=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);i.tryToSetUniqueName("renderPassToneMapping",!0),i.toClearColorBuffer=!1,i.toClearDepthBuffer=!1,i.isDepthTest=!1,i.clearColor=N.fromCopyArray4([0,0,0,0]),i.isVrRendering=!1,i.isOutputForVr=!1;let s=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);return s.tryToSetUniqueName("renderPassToneMappingVr",!0),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!1,s.clearColor=N.fromCopyArray4([0,0,0,0]),s.isVrRendering=!1,s.isOutputForVr=!0,t.addRenderPasses([i,s]),t}lM(e){return C.createFrameBuffer(this.i,{width:e,height:e,textureNum:1,textureFormats:[R.RG32F],createDepthBuffer:!0,depthTextureFormat:R.Depth32F})}DR(){for(let e of this.pp)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.NT,this.ET,this.cT)}}VR(){for(let e of this.dT)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.NT,this.ET,this.cT)}}setToneMappingType(e){let t=this.ZT;t!=null&&(this.KT=e,t.removeShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"),t.removeShaderDefine("RN_USE_REINHARD"),t.removeShaderDefine("RN_USE_GT_TONEMAP"),t.removeShaderDefine("RN_USE_ACES_NARKOWICZ"),t.removeShaderDefine("RN_USE_ACES_HILL"),t.removeShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"),e===I.KhronosPbrNeutral?t.addShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"):e===I.Reinhard?t.addShaderDefine("RN_USE_REINHARD"):e===I.GT_ToneMap?t.addShaderDefine("RN_USE_GT_TONEMAP"):e===I.ACES_Narkowicz?t.addShaderDefine("RN_USE_ACES_NARKOWICZ"):e===I.ACES_Hill?t.addShaderDefine("RN_USE_ACES_HILL"):e===I.ACES_Hill_Exposure_Boost&&t.addShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"))}ZR(){let e=new b;e.tryToSetUniqueName("Raymarching",!0);let t=new P(this.i);return t.toClearDepthBuffer=!1,t.isDepthTest=!0,this.OR(t),t.setPreRenderFunction(()=>this.eM(t)),e.addRenderPasses([t]),t.tryToSetUniqueName("Raymarching",!0),[e,t]}OR(e){var r;let t=this.ST();e.setFramebuffer(t),t!=null&&this.oT!=null?(e.setResolveFramebuffer(this.sT),e.setResolveFramebuffer2((r=this.nT)!=null?r:void 0)):(e.setResolveFramebuffer(void 0),e.setResolveFramebuffer2(void 0))}eM(e){this.lT(),this.wT();let t=e.material;if(t==null)return;let r=this.i.componentRepository.getComponentsWithType(F),i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY,u=r.length>0;for(let l of r){let T=l.entity.tryToGetSceneGraph();T!=null&&(t.setParameter(`worldMatrix_${l.componentSID}`,T.matrixInner),t.setParameter(`raymarchObjectId_${l.componentSID}`,B.fromCopyNumber(l.componentSID)));let f=this._T(l);if(f==null){u=!1;continue}i=Math.min(i,f.min.x),s=Math.min(s,f.min.y),n=Math.min(n,f.min.z),a=Math.max(a,f.max.x),o=Math.max(o,f.max.y),h=Math.max(h,f.max.z)}u?(t.setParameter("raymarchAabbMin",S.fromCopy3(i,s,n)),t.setParameter("raymarchAabbMax",S.fromCopy3(a,o,h))):(t.setParameter("raymarchAabbMin",_),t.setParameter("raymarchAabbMax",D))}setRaymarchingComponentMaterial(e,t){var r;this.Zx.set(e.componentSID,t),this.lT(),this.wT(),(r=this.aT)==null||r.applyShadowParametersToMaterials([t]),this.refreshRaymarchingShadowMaterial(),this.iT!=null&&this.mT()}getRaymarchingComponentMaterial(e){return this.Zx.get(e.componentSID)}removeRaymarchingComponentMaterial(e){this.Zx.delete(e.componentSID)&&(this.refreshRaymarchingShadowMaterial(),this.iT!=null&&this.mT())}setRaymarchingMaterial(e){var t,r;(t=this.TT)==null||t.setBufferLessFullScreenRendering(e),this.lT(),this.wT(),(r=this.aT)==null||r.applyShadowParametersToMaterials([e]),this.refreshRaymarchingShadowMaterial(),this.iT!=null&&this.mT()}tM(){let e=[],t=new Set;if(this.zT=-1,this.Zx.size>0)for(let r of this.DT()){let i=r.componentSID,s=this.Zx.get(i);if(s==null)continue;t.add(i);let n=this.xT.get(i);n==null&&(n=new P(this.i),n.toClearDepthBuffer=!1,n.isDepthTest=!0,n.setPreRenderFunction(()=>this.rM(i)),n.tryToSetUniqueName(`Raymarching_${i}`,!0),this.xT.set(i,n)),n.setBufferLessFullScreenRendering(s),this.OR(n),e.length===0&&(this.zT=i),e.push(n)}for(let r of[...this.xT.keys()])t.has(r)||this.xT.delete(r);for(let r of[...this.Zx.keys()])!t.has(r)&&this.i.componentRepository.getComponent(F,r)==null&&this.Zx.delete(r);return e}rM(e){var n,a,o;e===this.zT&&(this.lT(),this.wT());let t=this.Zx.get(e),r=this.i.componentRepository.getComponent(F,e),i=r==null?void 0:r.entity.tryToGetSceneGraph();if(t==null||r==null||i==null)return;t.setParameter(U,i.matrixInner);let s=this._T(r);t.setParameter("raymarchAabbMin",(n=s==null?void 0:s.min)!=null?n:_),t.setParameter("raymarchAabbMax",(a=s==null?void 0:s.max)!=null?a:D),(o=this.xT.get(e))==null||o.setScissorRect(this.iM(s))}_T(e){let t=e.entity.tryToGetSceneGraph();if(t==null)return null;let r=t.matrixInner,i=[r.m00,r.m01,r.m02,r.m03,r.m10,r.m11,r.m12,r.m13,r.m20,r.m21,r.m22,r.m23,r.m30,r.m31,r.m32,r.m33],s=F.getAABBVersion(this.i),n=e.componentSID,a=this.AT.get(n);if(a!=null&&a.aabbVersion===s&&a.matrix.length===i.length&&a.matrix.every((u,l)=>u===i[l]))return a.aabb;let o=e.calcWorldAABB();if(o==null)return this.AT.delete(n),null;let h={min:S.fromCopy3(o.minPoint.x,o.minPoint.y,o.minPoint.z),max:S.fromCopy3(o.maxPoint.x,o.maxPoint.y,o.maxPoint.z)};return this.AT.set(n,{aabbVersion:s,matrix:i,aabb:h}),h}iM(e){if(e==null||this.sm<=0||this.Xx<=0)return;let t=this.i.componentRepository.getComponent(z,z.getCurrent(this.i));if(t==null)return;let r=t.viewProjectionMatrix,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let p=0;p<8;p++){let m=(p&1)===0?e.min.x:e.max.x,c=(p&2)===0?e.min.y:e.max.y,x=(p&4)===0?e.min.z:e.max.z,y=r.multiplyVector(N.fromCopy4(m,c,x,1));if(y.w<=0)return;let E=y.x/y.w,A=y.y/y.w,M=(E*.5+.5)*this.sm,q=(-A*.5+.5)*this.Xx;i=Math.min(i,M),s=Math.min(s,q),n=Math.max(n,M),a=Math.max(a,q)}let o=2,h=Math.max(0,Math.floor(i)-o),u=Math.max(0,Math.floor(s)-o),l=Math.min(this.sm,Math.ceil(n)+o),T=Math.min(this.Xx,Math.ceil(a)+o),f=l-h,d=T-u;if(f<=0||d<=0)return{x:0,y:0,width:1,height:1};if(!(h===0&&u===0&&f===this.sm&&d===this.Xx))return{x:h,y:u,width:f,height:d}}GT(){let e=[];for(let r of this.Zx.values())e.push(r);let t=this.getRaymarchingMaterial();return t!=null&&e.push(t),e}sM(){let e=new b;e.tryToSetUniqueName("Raymarching",!0);let t=this.tM();return t.length>0?e.addRenderPasses(t):this.TT!=null&&this.TT.material!=null&&e.addRenderPasses([this.TT]),e}refreshRaymarchingShadowMaterial(){let e=this.hT,t=new Map(this.fT);if(this.yT=void 0,this.hT=void 0,this.RT.clear(),this.fT.clear(),this.MT.clear(),this.gT=this.Zx.size>0,!(this.aT==null||this.i.config.maxLightNumber<=0)){if(this.gT)for(let r of this.DT()){let i=r.componentSID;if(!r.castShadow||!this.Zx.has(i))continue;let s=V(this.i,r,"regular",t.get(i));s!=null&&this.fT.set(i,s)}else{let r=J(this.i,{castShadowOnly:!0});if(r.nodes.length>0){let i=r;this.yT=i,this.hT=O(this.i,i,"regular",e)}}this.aT.invalidateShadowVolumeFitting(),this.aT.setNeedsRefresh()}}DT(){let e=this.i.componentRepository.getComponentsWithType(F).slice();return e.sort((t,r)=>t.componentSID-r.componentSID),e}getRaymarchingShadowMaterial(){return this.hT}getRaymarchingComponentShadowMaterial(e){return this.fT.get(e.componentSID)}wR(){return{hasCaster:()=>this.gT?this.fT.size>0:this.yT!=null&&this.hT!=null,createPasses:e=>this.nM(e),updatePointLightFarPlane:(e,t)=>this.aM(e,t)}}oM(e,t,r){let i=this.RT.get(e);if(i==null){let n=this.yT;if(n==null)return;let a=O(this.i,n,"paraboloidFront"),o=O(this.i,n,"paraboloidBack");if(a==null||o==null)return;i={front:a,back:o},this.RT.set(e,i)}let s=B.fromCopyNumber(t);return i.front.setParameter("lightIndex",s),i.back.setParameter("lightIndex",s),this.VT(i,r),i}VT(e,t){let r=B.fromCopyNumber(t);e.front.setParameter("shadowFarPlane",r),e.back.setParameter("shadowFarPlane",r)}hM(e,t,r,i){let s=this.MT.get(e);s==null&&(s=new Map,this.MT.set(e,s));let n=s.get(i.componentSID);if(n==null){let o=V(this.i,i,"paraboloidFront"),h=V(this.i,i,"paraboloidBack");if(o==null||h==null)return;n={front:o,back:h},s.set(i.componentSID,n)}let a=B.fromCopyNumber(t);return n.front.setParameter("lightIndex",a),n.back.setParameter("lightIndex",a),this.VT(n,r),n}aM(e,t){let r=this.RT.get(e);r!=null&&this.VT(r,t);let i=this.MT.get(e);if(i!=null)for(let s of i.values())this.VT(s,t)}nM(e){let{lightComponent:t,kind:r,shadowSlot:i,farPlane:s}=e;if(this.gT){let a=[];for(let o of this.DT()){let h=o.componentSID;if(!o.castShadow||!this.Zx.has(h))continue;let u;if(r==="regular")u=this.fT.get(h);else{let l=this.hM(i,t.componentSID,s!=null?s:1e3,o);u=r==="paraboloidFront"?l==null?void 0:l.front:l==null?void 0:l.back}u!=null&&a.push(this.kR(u,e))}return a}let n;if(r==="regular")n=this.hT;else{let a=this.oM(i,t.componentSID,s!=null?s:1e3);n=r==="paraboloidFront"?a==null?void 0:a.front:a==null?void 0:a.back}return n==null?[]:[this.kR(n,e)]}kR(e,{lightEntity:t,framebuffer:r,kind:i}){let s=new P(this.i);return s.isVrRendering=!1,s.setBufferLessFullScreenRendering(e),s.setFramebuffer(r),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!0,s.depthWriteMask=!0,i==="regular"&&(s.cameraComponent=t.getCamera()),s.tryToSetUniqueName(`RaymarchingShadow_${i}`,!0),s}QR(){if(this.gT){this.uM();return}if(this.yT==null)return;let e=[];this.hT!=null&&e.push(this.hT);for(let m of this.RT.values())e.push(m.front,m.back);let t=this.Zx,r=this.getRaymarchingMaterial(),i=t.size>0?t.values().next().value:r,s=(m,c,x)=>{if(i!=null)if(G.isTexture(x.compositionType)){let y=i.getTextureParameter(c);y!=null&&m.setTextureParameter(c,y[1],y[2])}else{let y=i.getParameter(c);y!=null&&m.setParameter(c,y)}},n=this.i.componentRepository.getComponentsWithType(F),a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,h=Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,f=!1;for(let m of n){if(!m.castShadow)continue;f=!0;let c=this._T(m);if(c==null){f=!1;break}a=Math.min(a,c.min.x),o=Math.min(o,c.min.y),h=Math.min(h,c.min.z),u=Math.max(u,c.max.x),l=Math.max(l,c.max.y),T=Math.max(T,c.max.z)}let d=f?S.fromCopy3(a,o,h):_,p=f?S.fromCopy3(u,l,T):D;for(let m of e){m.setParameter("raymarchAabbMin",d),m.setParameter("raymarchAabbMax",p);for(let c of m.fieldsInfoArray){let x=c.semantic;if(x.startsWith("worldMatrix_")||x.startsWith("raymarchObjectId_")||x==="raymarchAabbMin"||x==="raymarchAabbMax"||x==="lightIndex"||x==="shadowFarPlane")continue;let y=/^(.*)_(\d+)$/.exec(x),E=y!=null?t.get(Number(y[2])):void 0;if(E!=null){let A=y[1];if(G.isTexture(c.compositionType)){let M=E.getTextureParameter(A);M!=null&&m.setTextureParameter(x,M[1],M[2])}else{let M=E.getParameter(A);M!=null&&m.setParameter(x,M)}}else s(m,x,c)}for(let c of n){if(!c.castShadow)continue;let x=c.entity.tryToGetSceneGraph();x!=null&&m.setParameter(`worldMatrix_${c.componentSID}`,x.matrixInner),m.setParameter(`raymarchObjectId_${c.componentSID}`,B.fromCopyNumber(c.componentSID))}}}uM(){var e,t;for(let r of this.DT()){let i=r.componentSID;if(!r.castShadow)continue;let s=this.Zx.get(i);if(s==null)continue;let n=[],a=this.fT.get(i);a!=null&&n.push(a);for(let f of this.MT.values()){let d=f.get(i);d!=null&&n.push(d.front,d.back)}if(n.length===0)continue;let o=r.entity.tryToGetSceneGraph(),h=o==null?void 0:o.matrixInner,u=this._T(r),l=(e=u==null?void 0:u.min)!=null?e:_,T=(t=u==null?void 0:u.max)!=null?t:D;for(let f of n){h!=null&&f.setParameter(U,h),f.setParameter("raymarchAabbMin",l),f.setParameter("raymarchAabbMax",T);for(let d of f.fieldsInfoArray){let p=d.semantic;if(!(p===U||p==="raymarchAabbMin"||p==="raymarchAabbMax"||p==="lightIndex"||p==="shadowFarPlane"))if(G.isTexture(d.compositionType)){let m=s.getTextureParameter(p);m!=null&&f.setTextureParameter(p,m[1],m[2])}else{let m=s.getParameter(p);m!=null&&f.setParameter(p,m)}}}}}NR(){return this.GT()}getRaymarchingMaterial(){var e;return(e=this.TT)==null?void 0:e.material}lT(){for(let e of this.GT())this.fM(e)}fM(e){var h,u,l,T,f,d;let t=e.getTextureParameter(v.DiffuseEnvTexture.str),r=e.getTextureParameter(v.SpecularEnvTexture.str);if(t==null||r==null)return;let i=e.getTextureParameter(v.SheenEnvTexture.str),s=this.NT,n=this.ET;if(s==null||n==null)return;let a=`${s.objectUID}:${s.isTextureReady}:${n.objectUID}:${n.isTextureReady}:${(u=(h=this.cT)==null?void 0:h.objectUID)!=null?u:-1}:${(T=(l=this.cT)==null?void 0:l.isTextureReady)!=null?T:!1}:${this.kT}:${this.LT}:${this.YT}`;if(a===this.qT.get(e.objectUID))return;this.qT.set(e.objectUID,a);let o=t[2];if(s.isTextureReady&&e.setTextureParameter(v.DiffuseEnvTexture.str,s,o),n.isTextureReady&&(e.setTextureParameter(v.SpecularEnvTexture.str,n,o),i!=null)){let p=(f=this.cT)!=null&&f.isTextureReady?this.cT:n,m=(d=i[2])!=null?d:o;e.setTextureParameter(v.SheenEnvTexture.str,p,m)}e.setParameter("iblParameter",N.fromCopy4(n.mipmapLevelNumber,this.LT,this.YT,this.kT)),e.setParameter("hdriFormat",ee.fromCopy2(s.hdriFormat.index,n.hdriFormat.index))}mM(){return this.GT().some(e=>e.isShaderDefine("RN_USE_TRANSMISSION"))}wT(){var r;if(this.Yx)return;let e=(r=this.XT())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.BT;if(!(e==null||t==null))for(let i of this.GT())i.setTextureParameter(v.BackBufferTexture.str,e,t)}mT(){let e=this.iT;if(e==null){console.log("Frame is not set.");return}if(e.clearExpressions(),e.addExpression(this.OT),this.pT=this.sM(),!this.Yx)for(let i of this.WT)e.addExpression(i);let t=this.mM();!t&&this.pT!=null&&e.addExpression(this.pT);for(let i of this.pp)this.Yx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);!this.Yx&&this.vT!=null&&!k.isMobile()&&e.addExpression(this.vT),!this.Yx&&this.UT!=null&&e.addExpression(this.UT),t&&this.pT!=null&&e.addExpression(this.pT);for(let i of this.dT)this.Yx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);if(this.IT.renderPasses.length>0){if(!this.Yx){let i=this.ST();if(i!=null)for(let s of this.IT.renderPasses)s.setFramebuffer(i),this.oT!=null&&s.setResolveFramebuffer(this.sT)}e.addExpression(this.IT)}!this.Yx&&this.CT!=null&&e.addExpression(this.CT),!this.Yx&&this.rT&&this.FT!=null&&e.addExpression(this.FT),!this.Yx&&this.PT!=null&&e.addExpression(this.PT);let r=this.pp.flatMap(i=>i.renderPasses.flatMap(s=>s.entities));this.QT=r}};export{j as ForwardRenderPipeline};
1
+ import{CameraComponent as q}from"../../components/Camera/CameraComponent.js";import{RaymarchingComponent as C}from"../../components/Raymarching/RaymarchingComponent.js";import{RnObject as H}from"../../core/RnObject.js";import{ComponentType as z,CompositionType as G,PixelFormat as $,ToneMappingType as v}from"../../definitions/index.js";import{ShaderSemantics as I}from"../../definitions/ShaderSemantics.js";import{TextureFormat as R}from"../../definitions/TextureFormat.js";import{TextureParameter as w}from"../../definitions/TextureParameter.js";import{Bloom as Z}from"../../helpers/BloomHelper.js";import{collectRrnJson as J,createNodeBasedRaymarchingComponentShadowMaterial as V,createNodeBasedRaymarchingShadowMaterial as O,RAYMARCHING_COMPONENT_WORLD_MATRIX_SEMANTIC as U}from"../../helpers/materials/createNodeBasedRaymarchingMaterials.js";import{createToneMappingMaterial as K}from"../../helpers/materials/createToneMappingMaterial.js";import{RenderableHelper as F}from"../../helpers/RenderableHelper.js";import{RenderPassHelper as X}from"../../helpers/RenderPassHelper.js";import{ShadowSystem as Q}from"../../helpers/Shadow/ShadowSystem.js";import{Scalar as A}from"../../math/Scalar.js";import{Vector2 as ee}from"../../math/Vector2.js";import{Vector3 as S}from"../../math/Vector3.js";import{Vector4 as N}from"../../math/Vector4.js";import{MiscUtil as k}from"../../misc/index.js";import{Is as g}from"../../misc/Is.js";import{Logger as te}from"../../misc/Logger.js";import{Err as L,Ok as W}from"../../misc/Result.js";import{Sampler as re}from"../../textures/Sampler.js";import{Expression as M}from"../Expression.js";import{Frame as ie}from"../Frame.js";import{RenderPass as P}from"../RenderPass.js";import{_getTemporalAACamera as se,TemporalAASystem as ne}from"../TemporalAA/TemporalAASystem.js";var _=Object.freeze(S.fromCopy3(-1e20,-1e20,-1e20)),D=Object.freeze(S.fromCopy3(1e20,1e20,1e20)),j=class extends H{constructor(e){super();this.sm=0;this.TT=0;this.jR=!1;this.gT=!1;this.Xx=!1;this.wR=!1;this.HR=1024;this.hp=[];this.WT=new M;this.BT=[];this.OR=0;this.kR=1;this.LR=1;this.YR=new Map;this.Zx=new Map;this.wT=new Map;this.qR=-1;this.HT=new Map;this.KR=v.GT_ToneMap;this.$R=[];this.QR=[];this.GT=new Map;this.VT=!1;this.FT=new Map;this.OT=new Map;this.i=e,this.zR=new Z(e)}Lb(){this.yT!=null&&(this.yT.destroy3DAPIResources(),this.yT=void 0),this.IT!=null&&(this.IT.destroy3DAPIResources(),this.IT=void 0),this.PT!=null&&(this.PT.destroy3DAPIResources(),this.PT=void 0),this.MT!=null&&(this.MT.destroy3DAPIResources(),this.MT=void 0),this.RT!=null&&(this.RT.destroy3DAPIResources(),this.RT=void 0),this.zR.destroy3DAPIResources(),this.Yx!=null&&(this.Yx.destroy3DAPIResources(),this.Yx=void 0),this.bT=void 0,this.YT=void 0,this.qT=void 0,this.zT=void 0,this.kT=void 0,this.AT=void 0,this.DT=void 0,this.vT=void 0,this.GT.clear(),this.VT=!1,this.FT.clear(),this.OT.clear(),this.wT.clear(),this.HT.clear(),this.YR.clear()}async setup(e,t,{isShadow:r=!1,isBloom:i=!1,shadowMapSize:s=1024,isSimple:n=!1,isTemporalAA:a=!1}={}){if(this.sm=e,this.TT=t,this.gT=i,this.jR=r,this.Xx=n,this.wR=a,this.HR=s,this.bT!=null)return new L({message:"Already setup",error:void 0});let o=new ie;if(this.bT=o,!this.Xx){let l=new re(this.i,{wrapS:w.Repeat,wrapT:w.Repeat,minFilter:w.LinearMipmapLinear,magFilter:w.Linear});l.create(),this.jT=l,this.Wb(e,t),r&&(this.ST=new Q(this.i,s)),this.RT!=null&&!k.isMobile()&&(this.YT=this.Yb(this.RT)),this.yT!=null&&(this.VR=this.qb(this.yT),this.qT=this.zb(this.yT));let T=this.$b(),h=T.getColorAttachedRenderTargetTexture(0);if(this.db()&&(this.Yx=new ne(this.i,e,t,T.getColorAttachedRenderTargetTexture(0)),h=this.Yx.outputTexture),i){let c=h,{bloomExpression:m,bloomedRenderTarget:p}=this.zR.createBloomExpression({textureToBloom:c,parameters:{}});this.zT=m,h=p}let d=this.Xb(h);this.kT=d}this.DR=this.jb(),this.hp.length>0&&this.setExpressions(this.hp);let[u,f]=this.Hb();return this.AT=u,this._T=f,this.CT(),new W}XR(){return this.yT!=null?this.UT:this.RT}$b(){return this.yT!=null?this.IT:this.MT}LT(){var e;return this.yT!=null?this.yT:(e=this.PT)!=null?e:this.MT}db(){var e;return!this.wR||this.Xx?!1:!((e=this.i._webXRSystemIfEnabled)!=null&&e.isWebXRMode)}setExpressions(e,t={isTransmission:!0}){let r=e.map(i=>i.clone());if(this.Zb(e,{isTransmission:t.isTransmission}),t.isTransmission&&this.Jb(r),this.ST!=null){let i=this.hp.flatMap(s=>s.renderPasses.flatMap(n=>n.entities));this.$R=this.ST.getExpressions(i,this.Rb(),this.Pb())}this.CT()}setGizmoExpression(e){this.WT=e}startRenderLoop(e){return this.bT==null?new L({message:"not initialized.",error:void 0}):(this.JR=e,this.CT(),this.i.startRenderLoop(()=>{let t=this.ST;if(t!=null){let r=this.QR,i=this.Rb();t.isLightChanged()&&(this.$R=t.getExpressions(r,i,this.Pb()),this.CT()),t.setDepthBiasPV(r,i)}this.Kb(),this.Fb(),e(this.bT)}),new W)}draw(){this.Fb(),this.JR(this.bT)}get isTemporalAA(){return this.Yx!=null}resetTemporalAAHistory(){var e;(e=this.Yx)==null||e.resetHistory()}set temporalAACurrentFrameWeight(e){this.Yx!=null&&(this.Yx.currentFrameWeight=e)}get temporalAACurrentFrameWeight(){var e,t;return(t=(e=this.Yx)==null?void 0:e.currentFrameWeight)!=null?t:.1}set temporalAAStaticFrameWeight(e){this.Yx!=null&&(this.Yx.staticFrameWeight=e)}get temporalAAStaticFrameWeight(){var e,t;return(t=(e=this.Yx)==null?void 0:e.staticFrameWeight)!=null?t:.04}_setTemporalAAVarianceClipGamma(e){this.Yx!=null&&(this.Yx.varianceClipGamma=e)}Fb(){if(this.Yx==null)return;let e=this.hp.flatMap(t=>t.renderPasses);this.Yx.prepareFrame(se(this.i,e))}setNeedsShadowMapRefresh(){var e;(e=this.ST)==null||e.setNeedsRefresh()}resize(e,t){if(this.bT==null)return new L({message:"not initialized.",error:void 0});let r=this.i._webXRSystemIfEnabled;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&(e=r.getCanvasWidthForVr(),t=r.getCanvasHeightForVr()),e<=0||t<=0){let s=this.sm,n=this.TT;if(s<=0||n<=0){let[a,o]=this.i.getCanvasSize();s=a,n=o}(s<=0||n<=0)&&(s=1,n=1),te.default.warn(`ForwardRenderPipeline.resize received non-positive dimensions (${e}x${t}). Falling back to ${s}x${n}.`),e=s,t=n}let i=this.getRaymarchingMaterial();return this.i.resizeCanvas(e,t),this.Lb(),this.setup(e,t,{isShadow:this.jR,isBloom:this.gT,shadowMapSize:this.HR,isSimple:this.Xx,isTemporalAA:this.wR}),i!=null&&this.setRaymarchingMaterial(i),new W}setIBLTextures(e,t,r){this.$T=e,this.XT=t,g.exist(r)&&(this.ET=r),this.wb(),this.Db(),this.NT(),this.CT()}getInitialExpression(){return this.DR}getToneMappingExpression(){return this.kT}setDiffuseIBLContribution(e){this.kR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}for(let t of this.BT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.diffuseCubeMapContribution=e)}}setSpecularIBLContribution(e){this.LR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}for(let t of this.BT)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.specularCubeMapContribution=e)}}setIBLRotation(e){this.OR=e,this.NT();for(let t of this.hp)for(let r of t.renderPasses)for(let i of r.entities){let s=i.tryToGetMeshRenderer();g.exist(s)&&(s.rotationOfCubeMap=e)}}Zb(e,t={isTransmission:!0}){for(let r of e)for(let i of r.renderPasses)if(i.setToRenderOpaquePrimitives(!0),i.setToRenderBlendWithZWritePrimitives(!0),i.setToRenderBlendWithoutZWritePrimitives(!0),t.isTransmission?i.setToRenderTranslucentPrimitives(!1):i.setToRenderTranslucentPrimitives(!0),i.toClearDepthBuffer=!1,!this.Xx){let s=this.LT();s!=null&&(i.setFramebuffer(s),this.PT!=null?(i.setResolveFramebuffer(this.MT),i.setResolveFramebuffer2(this.RT)):this.yT==null&&(i.setResolveFramebuffer(void 0),i.setResolveFramebuffer2(this.RT)))}this.hp=e,this.wb()}Jb(e){for(let t of e){t.tryToSetUniqueName("modelTransparentForTransmission",!0);for(let r of t.renderPasses)if(r.setToRenderOpaquePrimitives(!1),r.setToRenderTranslucentPrimitives(!0),r.setToRenderBlendWithZWritePrimitives(!1),r.setToRenderBlendWithoutZWritePrimitives(!1),r.toClearDepthBuffer=!1,r.toClearColorBuffer=!1,!this.Xx){r.setFramebuffer(this.LT()),this.PT!=null?r.setResolveFramebuffer(this.MT):r.setResolveFramebuffer(void 0);for(let i of r.entities){let s=i.tryToGetMesh();if(g.exist(s)){let n=s.mesh;if(g.exist(n))for(let a=0;a<n.getPrimitiveNumber();a++)n.getPrimitiveAt(a).material.setTextureParameter("backBufferTexture",this.XR().getColorAttachedRenderTargetTexture(0),this.jT)}}}}this.BT=e,this.Db()}refreshBackBufferTextureOnTransparentMaterials(){var r;if(this.Xx)return;let e=(r=this.XR())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.jT;if(!(e==null||t==null))for(let i of this.BT)for(let s of i.renderPasses)for(let n of s.entities){let a=n.tryToGetMesh();if(g.exist(a)){let o=a.mesh;if(g.exist(o))for(let u=0;u<o.getPrimitiveNumber();u++)o.getPrimitiveAt(u).material.setTextureParameter("backBufferTexture",e,t)}}}jb(){let e=new M;e.tryToSetUniqueName("Initial",!0);let t=new P(this.i);if(t.clearColor=N.fromCopyArray4([0,0,0,0]),t.toClearColorBuffer=!0,t.toClearDepthBuffer=!0,t.isOutputForVr=!0,t.tryToSetUniqueName("InitialRenderPass",!0),e.addRenderPasses([t]),!this.Xx){let r=new P(this.i);r.clearColor=N.fromCopyArray4([0,0,0,0]),r.toClearColorBuffer=!0,r.toClearDepthBuffer=!0,r.setFramebuffer(this.LT()),r.tryToSetUniqueName("InitialRenderPassForFrameBuffer",!0),e.addRenderPasses([r])}return e}Wb(e,t){let r=this.i._webXRSystemIfEnabled,i=this.i.cgApiResourceRepository;if(g.exist(r)&&(r!=null&&r.isWebXRMode)&&i.isSupportMultiViewVRRendering(this.i)){let s=F.createFrameBufferTextureArrayForMultiView(this.i,{width:e/2,height:t,arrayLength:2,level:0,internalFormat:this.gT?R.R11F_G11F_B10F:R.RGBA8,format:this.gT?$.RGB:$.RGBA,type:this.gT?z.Float:z.UnsignedByte});s.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiView",!0);let n=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});n.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlit",!0);let a=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingMultiViewBlitBackBuffer",!0),this.yT=s,this.IT=n,this.UT=a,this.PT=void 0,this.MT=void 0,this.RT=void 0}else{console.log(`canvasWidth: ${e}, canvasHeight: ${t}`);let s;this.db()||(s=F.createFrameBufferMSAA(this.i,{width:e,height:t,colorBufferNum:1,colorFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],sampleCountMSAA:4,depthBufferFormat:R.Depth32F}),s.tryToSetUniqueName("FramebufferTargetOfToneMappingMsaa",!0));let n=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!0,depthTextureFormat:R.Depth32F});n.tryToSetUniqueName("FramebufferTargetOfToneMappingResolve",!0);let a=F.createFrameBuffer(this.i,{width:e,height:t,textureNum:1,textureFormats:[this.gT?R.R11F_G11F_B10F:R.RGBA8],createDepthBuffer:!1});a.tryToSetUniqueName("FramebufferTargetOfToneMappingResolveForReference",!0),this.yT=void 0,this.IT=void 0,this.UT=void 0,this.PT=s,this.MT=n,this.RT=a}}Yb(e){let t=new M;t.tryToSetUniqueName("GenerateMipmaps",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("GenerateMipmaps",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(function(){e.getColorAttachedRenderTargetTexture(0).generateMipmaps()}),t}qb(e){let t=new M;t.tryToSetUniqueName("MultiViewBlitBackBuffer",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlitBackBuffer",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.UT!=null&&!k.isMobile()){let i=this.UT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i),i.generateMipmaps()}}),t}zb(e){let t=new M;t.tryToSetUniqueName("MultiViewBlit",!0);let r=new P(this.i);return t.addRenderPasses([r]),r.tryToSetUniqueName("MultiViewBlit",!0),r.toClearDepthBuffer=!1,r.setPostRenderFunction(()=>{if(this.IT!=null){let i=this.IT.colorAttachments[0];e.colorAttachments[0].blitToTexture2dFromTexture2dArrayFake(i)}}),t}Xb(e){let t=new M,r=K(this.i);this.ZR=r,this.setToneMappingType(this.KR);let i=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);i.tryToSetUniqueName("renderPassToneMapping",!0),i.toClearColorBuffer=!1,i.toClearDepthBuffer=!1,i.isDepthTest=!1,i.clearColor=N.fromCopyArray4([0,0,0,0]),i.isVrRendering=!1,i.isOutputForVr=!1;let s=X.createScreenDrawRenderPassWithBaseColorTexture(this.i,r,e);return s.tryToSetUniqueName("renderPassToneMappingVr",!0),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!1,s.clearColor=N.fromCopyArray4([0,0,0,0]),s.isVrRendering=!1,s.isOutputForVr=!0,t.addRenderPasses([i,s]),t}mM(e){return F.createFrameBuffer(this.i,{width:e,height:e,textureNum:1,textureFormats:[R.RG32F],createDepthBuffer:!0,depthTextureFormat:R.Depth32F})}wb(){for(let e of this.hp)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.$T,this.XT,this.ET)}}Db(){for(let e of this.BT)for(let t of e.renderPasses)for(let r of t.entities){let i=r.tryToGetMeshRenderer();g.exist(i)&&i.setIBLCubeMap(this.$T,this.XT,this.ET)}}setToneMappingType(e){let t=this.ZR;t!=null&&(this.KR=e,t.removeShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"),t.removeShaderDefine("RN_USE_REINHARD"),t.removeShaderDefine("RN_USE_GT_TONEMAP"),t.removeShaderDefine("RN_USE_ACES_NARKOWICZ"),t.removeShaderDefine("RN_USE_ACES_HILL"),t.removeShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"),e===v.KhronosPbrNeutral?t.addShaderDefine("RN_USE_KHRONOS_PBR_NEUTRAL"):e===v.Reinhard?t.addShaderDefine("RN_USE_REINHARD"):e===v.GT_ToneMap?t.addShaderDefine("RN_USE_GT_TONEMAP"):e===v.ACES_Narkowicz?t.addShaderDefine("RN_USE_ACES_NARKOWICZ"):e===v.ACES_Hill?t.addShaderDefine("RN_USE_ACES_HILL"):e===v.ACES_Hill_Exposure_Boost&&t.addShaderDefine("RN_USE_ACES_HILL_EXPOSURE_BOOST"))}Hb(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=new P(this.i);return t.toClearDepthBuffer=!1,t.isDepthTest=!0,this.Gb(t),t.setPreRenderFunction(()=>this.Qb(t)),e.addRenderPasses([t]),t.tryToSetUniqueName("Raymarching",!0),[e,t]}Gb(e){var r;let t=this.LT();e.setFramebuffer(t),t!=null&&this.PT!=null?(e.setResolveFramebuffer(this.MT),e.setResolveFramebuffer2((r=this.RT)!=null?r:void 0)):(e.setResolveFramebuffer(void 0),e.setResolveFramebuffer2(t!=null?this.RT:void 0))}Qb(e){this.NT(),this.ZT();let t=e.material;if(t==null)return;let r=this.i.componentRepository.getComponentsWithType(C),i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,u=Number.NEGATIVE_INFINITY,f=r.length>0;for(let l of r){let T=l.entity.tryToGetSceneGraph();T!=null&&(t.setParameter(`worldMatrix_${l.componentSID}`,T.matrixInner),t.setParameter(`raymarchObjectId_${l.componentSID}`,A.fromCopyNumber(l.componentSID)));let h=this.JT(l);if(h==null){f=!1;continue}i=Math.min(i,h.min.x),s=Math.min(s,h.min.y),n=Math.min(n,h.min.z),a=Math.max(a,h.max.x),o=Math.max(o,h.max.y),u=Math.max(u,h.max.z)}f?(t.setParameter("raymarchAabbMin",S.fromCopy3(i,s,n)),t.setParameter("raymarchAabbMax",S.fromCopy3(a,o,u))):(t.setParameter("raymarchAabbMin",_),t.setParameter("raymarchAabbMax",D))}setRaymarchingComponentMaterial(e,t){var r;this.Zx.set(e.componentSID,t),this.NT(),this.ZT(),(r=this.ST)==null||r.applyShadowParametersToMaterials([t]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}getRaymarchingComponentMaterial(e){return this.Zx.get(e.componentSID)}removeRaymarchingComponentMaterial(e){this.Zx.delete(e.componentSID)&&(this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT())}setRaymarchingMaterial(e){var t,r;(t=this._T)==null||t.setBufferLessFullScreenRendering(e),this.NT(),this.ZT(),(r=this.ST)==null||r.applyShadowParametersToMaterials([e]),this.refreshRaymarchingShadowMaterial(),this.bT!=null&&this.CT()}eM(){let e=[],t=new Set;if(this.qR=-1,this.Zx.size>0)for(let r of this.KT()){let i=r.componentSID,s=this.Zx.get(i);if(s==null)continue;t.add(i);let n=this.wT.get(i);n==null&&(n=new P(this.i),n.toClearDepthBuffer=!1,n.isDepthTest=!0,n.setPreRenderFunction(()=>this.tM(i)),n.tryToSetUniqueName(`Raymarching_${i}`,!0),this.wT.set(i,n)),n.setBufferLessFullScreenRendering(s),this.Gb(n),e.length===0&&(this.qR=i),e.push(n)}for(let r of[...this.wT.keys()])t.has(r)||this.wT.delete(r);for(let r of[...this.Zx.keys()])!t.has(r)&&this.i.componentRepository.getComponent(C,r)==null&&this.Zx.delete(r);return e}tM(e){var n,a,o;e===this.qR&&(this.NT(),this.ZT());let t=this.Zx.get(e),r=this.i.componentRepository.getComponent(C,e),i=r==null?void 0:r.entity.tryToGetSceneGraph();if(t==null||r==null||i==null)return;t.setParameter(U,i.matrixInner);let s=this.JT(r);t.setParameter("raymarchAabbMin",(n=s==null?void 0:s.min)!=null?n:_),t.setParameter("raymarchAabbMax",(a=s==null?void 0:s.max)!=null?a:D),(o=this.wT.get(e))==null||o.setScissorRect(this.rM(s))}JT(e){let t=e.entity.tryToGetSceneGraph();if(t==null)return null;let r=t.matrixInner,i=[r.m00,r.m01,r.m02,r.m03,r.m10,r.m11,r.m12,r.m13,r.m20,r.m21,r.m22,r.m23,r.m30,r.m31,r.m32,r.m33],s=C.getAABBVersion(this.i),n=e.componentSID,a=this.HT.get(n);if(a!=null&&a.aabbVersion===s&&a.matrix.length===i.length&&a.matrix.every((f,l)=>f===i[l]))return a.aabb;let o=e.calcWorldAABB();if(o==null)return this.HT.delete(n),null;let u={min:S.fromCopy3(o.minPoint.x,o.minPoint.y,o.minPoint.z),max:S.fromCopy3(o.maxPoint.x,o.maxPoint.y,o.maxPoint.z)};return this.HT.set(n,{aabbVersion:s,matrix:i,aabb:u}),u}rM(e){if(e==null||this.sm<=0||this.TT<=0)return;let t=this.i.componentRepository.getComponent(q,q.getCurrent(this.i));if(t==null)return;let r=t.viewProjectionMatrix,i=Number.POSITIVE_INFINITY,s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let c=0;c<8;c++){let m=(c&1)===0?e.min.x:e.max.x,p=(c&2)===0?e.min.y:e.max.y,x=(c&4)===0?e.min.z:e.max.z,y=r.multiplyVector(N.fromCopy4(m,p,x,1));if(y.w<=0)return;let E=y.x/y.w,B=y.y/y.w,b=(E*.5+.5)*this.sm,Y=(-B*.5+.5)*this.TT;i=Math.min(i,b),s=Math.min(s,Y),n=Math.max(n,b),a=Math.max(a,Y)}let o=2,u=Math.max(0,Math.floor(i)-o),f=Math.max(0,Math.floor(s)-o),l=Math.min(this.sm,Math.ceil(n)+o),T=Math.min(this.TT,Math.ceil(a)+o),h=l-u,d=T-f;if(h<=0||d<=0)return{x:0,y:0,width:1,height:1};if(!(u===0&&f===0&&h===this.sm&&d===this.TT))return{x:u,y:f,width:h,height:d}}QT(){let e=[];for(let r of this.Zx.values())e.push(r);let t=this.getRaymarchingMaterial();return t!=null&&e.push(t),e}iM(){let e=new M;e.tryToSetUniqueName("Raymarching",!0);let t=this.eM();return t.length>0?e.addRenderPasses(t):this._T!=null&&this._T.material!=null&&e.addRenderPasses([this._T]),e}refreshRaymarchingShadowMaterial(){let e=this.vT,t=new Map(this.FT);if(this.DT=void 0,this.vT=void 0,this.GT.clear(),this.FT.clear(),this.OT.clear(),this.VT=this.Zx.size>0,!(this.ST==null||this.i.config.maxLightNumber<=0)){if(this.VT)for(let r of this.KT()){let i=r.componentSID;if(!r.castShadow||!this.Zx.has(i))continue;let s=V(this.i,r,"regular",t.get(i));s!=null&&this.FT.set(i,s)}else{let r=J(this.i,{castShadowOnly:!0});if(r.nodes.length>0){let i=r;this.DT=i,this.vT=O(this.i,i,"regular",e)}}this.ST.invalidateShadowVolumeFitting(),this.ST.setNeedsRefresh()}}KT(){let e=this.i.componentRepository.getComponentsWithType(C).slice();return e.sort((t,r)=>t.componentSID-r.componentSID),e}getRaymarchingShadowMaterial(){return this.vT}getRaymarchingComponentShadowMaterial(e){return this.FT.get(e.componentSID)}Pb(){return{hasCaster:()=>this.VT?this.FT.size>0:this.DT!=null&&this.vT!=null,createPasses:e=>this.sM(e),updatePointLightFarPlane:(e,t)=>this.nM(e,t)}}aM(e,t,r){let i=this.GT.get(e);if(i==null){let n=this.DT;if(n==null)return;let a=O(this.i,n,"paraboloidFront"),o=O(this.i,n,"paraboloidBack");if(a==null||o==null)return;i={front:a,back:o},this.GT.set(e,i)}let s=A.fromCopyNumber(t);return i.front.setParameter("lightIndex",s),i.back.setParameter("lightIndex",s),this.NR(i,r),i}NR(e,t){let r=A.fromCopyNumber(t);e.front.setParameter("shadowFarPlane",r),e.back.setParameter("shadowFarPlane",r)}oM(e,t,r,i){let s=this.OT.get(e);s==null&&(s=new Map,this.OT.set(e,s));let n=s.get(i.componentSID);if(n==null){let o=V(this.i,i,"paraboloidFront"),u=V(this.i,i,"paraboloidBack");if(o==null||u==null)return;n={front:o,back:u},s.set(i.componentSID,n)}let a=A.fromCopyNumber(t);return n.front.setParameter("lightIndex",a),n.back.setParameter("lightIndex",a),this.NR(n,r),n}nM(e,t){let r=this.GT.get(e);r!=null&&this.NR(r,t);let i=this.OT.get(e);if(i!=null)for(let s of i.values())this.NR(s,t)}sM(e){let{lightComponent:t,kind:r,shadowSlot:i,farPlane:s}=e;if(this.VT){let a=[];for(let o of this.KT()){let u=o.componentSID;if(!o.castShadow||!this.Zx.has(u))continue;let f;if(r==="regular")f=this.FT.get(u);else{let l=this.oM(i,t.componentSID,s!=null?s:1e3,o);f=r==="paraboloidFront"?l==null?void 0:l.front:l==null?void 0:l.back}f!=null&&a.push(this.Ub(f,e))}return a}let n;if(r==="regular")n=this.vT;else{let a=this.aM(i,t.componentSID,s!=null?s:1e3);n=r==="paraboloidFront"?a==null?void 0:a.front:a==null?void 0:a.back}return n==null?[]:[this.Ub(n,e)]}Ub(e,{lightEntity:t,framebuffer:r,kind:i}){let s=new P(this.i);return s.isVrRendering=!1,s.setBufferLessFullScreenRendering(e),s.setFramebuffer(r),s.toClearColorBuffer=!1,s.toClearDepthBuffer=!1,s.isDepthTest=!0,s.depthWriteMask=!0,i==="regular"&&(s.cameraComponent=t.getCamera()),s.tryToSetUniqueName(`RaymarchingShadow_${i}`,!0),s}Kb(){if(this.VT){this.hM();return}if(this.DT==null)return;let e=[];this.vT!=null&&e.push(this.vT);for(let m of this.GT.values())e.push(m.front,m.back);let t=this.Zx,r=this.getRaymarchingMaterial(),i=t.size>0?t.values().next().value:r,s=(m,p,x)=>{if(i!=null)if(G.isTexture(x.compositionType)){let y=i.getTextureParameter(p);y!=null&&m.setTextureParameter(p,y[1],y[2])}else{let y=i.getParameter(p);y!=null&&m.setParameter(p,y)}},n=this.i.componentRepository.getComponentsWithType(C),a=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,u=Number.POSITIVE_INFINITY,f=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY,T=Number.NEGATIVE_INFINITY,h=!1;for(let m of n){if(!m.castShadow)continue;h=!0;let p=this.JT(m);if(p==null){h=!1;break}a=Math.min(a,p.min.x),o=Math.min(o,p.min.y),u=Math.min(u,p.min.z),f=Math.max(f,p.max.x),l=Math.max(l,p.max.y),T=Math.max(T,p.max.z)}let d=h?S.fromCopy3(a,o,u):_,c=h?S.fromCopy3(f,l,T):D;for(let m of e){m.setParameter("raymarchAabbMin",d),m.setParameter("raymarchAabbMax",c);for(let p of m.fieldsInfoArray){let x=p.semantic;if(x.startsWith("worldMatrix_")||x.startsWith("raymarchObjectId_")||x==="raymarchAabbMin"||x==="raymarchAabbMax"||x==="lightIndex"||x==="shadowFarPlane")continue;let y=/^(.*)_(\d+)$/.exec(x),E=y!=null?t.get(Number(y[2])):void 0;if(E!=null){let B=y[1];if(G.isTexture(p.compositionType)){let b=E.getTextureParameter(B);b!=null&&m.setTextureParameter(x,b[1],b[2])}else{let b=E.getParameter(B);b!=null&&m.setParameter(x,b)}}else s(m,x,p)}for(let p of n){if(!p.castShadow)continue;let x=p.entity.tryToGetSceneGraph();x!=null&&m.setParameter(`worldMatrix_${p.componentSID}`,x.matrixInner),m.setParameter(`raymarchObjectId_${p.componentSID}`,A.fromCopyNumber(p.componentSID))}}}hM(){var e,t;for(let r of this.KT()){let i=r.componentSID;if(!r.castShadow)continue;let s=this.Zx.get(i);if(s==null)continue;let n=[],a=this.FT.get(i);a!=null&&n.push(a);for(let h of this.OT.values()){let d=h.get(i);d!=null&&n.push(d.front,d.back)}if(n.length===0)continue;let o=r.entity.tryToGetSceneGraph(),u=o==null?void 0:o.matrixInner,f=this.JT(r),l=(e=f==null?void 0:f.min)!=null?e:_,T=(t=f==null?void 0:f.max)!=null?t:D;for(let h of n){u!=null&&h.setParameter(U,u),h.setParameter("raymarchAabbMin",l),h.setParameter("raymarchAabbMax",T);for(let d of h.fieldsInfoArray){let c=d.semantic;if(!(c===U||c==="raymarchAabbMin"||c==="raymarchAabbMax"||c==="lightIndex"||c==="shadowFarPlane"))if(G.isTexture(d.compositionType)){let m=s.getTextureParameter(c);m!=null&&h.setTextureParameter(c,m[1],m[2])}else{let m=s.getParameter(c);m!=null&&h.setParameter(c,m)}}}}}Rb(){return this.QT()}getRaymarchingMaterial(){var e;return(e=this._T)==null?void 0:e.material}NT(){for(let e of this.QT())this.uM(e)}uM(e){var u,f,l,T,h,d;let t=e.getTextureParameter(I.DiffuseEnvTexture.str),r=e.getTextureParameter(I.SpecularEnvTexture.str);if(t==null||r==null)return;let i=e.getTextureParameter(I.SheenEnvTexture.str),s=this.$T,n=this.XT;if(s==null||n==null)return;let a=`${s.objectUID}:${s.isTextureReady}:${n.objectUID}:${n.isTextureReady}:${(f=(u=this.ET)==null?void 0:u.objectUID)!=null?f:-1}:${(T=(l=this.ET)==null?void 0:l.isTextureReady)!=null?T:!1}:${this.OR}:${this.kR}:${this.LR}`;if(a===this.YR.get(e.objectUID))return;this.YR.set(e.objectUID,a);let o=t[2];if(s.isTextureReady&&e.setTextureParameter(I.DiffuseEnvTexture.str,s,o),n.isTextureReady&&(e.setTextureParameter(I.SpecularEnvTexture.str,n,o),i!=null)){let c=(h=this.ET)!=null&&h.isTextureReady?this.ET:n,m=(d=i[2])!=null?d:o;e.setTextureParameter(I.SheenEnvTexture.str,c,m)}e.setParameter("iblParameter",N.fromCopy4(n.mipmapLevelNumber,this.kR,this.LR,this.OR)),e.setParameter("hdriFormat",ee.fromCopy2(s.hdriFormat.index,n.hdriFormat.index))}fM(){return this.QT().some(e=>e.isShaderDefine("RN_USE_TRANSMISSION"))}ZT(){var r;if(this.Xx)return;let e=(r=this.XR())==null?void 0:r.getColorAttachedRenderTargetTexture(0),t=this.jT;if(!(e==null||t==null))for(let i of this.QT())i.setTextureParameter(I.BackBufferTexture.str,e,t)}CT(){let e=this.bT;if(e==null){console.log("Frame is not set.");return}if(e.clearExpressions(),e.addExpression(this.DR),this.AT=this.iM(),!this.Xx)for(let i of this.$R)e.addExpression(i);let t=this.fM();!t&&this.AT!=null&&e.addExpression(this.AT);for(let i of this.hp)this.Xx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);!this.Xx&&this.YT!=null&&!k.isMobile()&&e.addExpression(this.YT),!this.Xx&&this.VR!=null&&e.addExpression(this.VR),t&&this.AT!=null&&e.addExpression(this.AT);for(let i of this.BT)this.Xx?i.renderPasses.forEach(s=>{s.isOutputForVr=!0}):i.renderPasses.forEach(s=>{s.isOutputForVr=!1}),e.addExpression(i);if(this.WT.renderPasses.length>0){if(!this.Xx){let i=this.LT();if(i!=null)for(let s of this.WT.renderPasses)s.setFramebuffer(i),this.PT!=null&&s.setResolveFramebuffer(this.MT)}e.addExpression(this.WT)}let r=this.hp.flatMap(i=>i.renderPasses.flatMap(s=>s.entities));this.QR=r,this.Yx!=null&&(this.Yx.setEntities(r),e.addExpression(this.Yx.expression)),!this.Xx&&this.qT!=null&&e.addExpression(this.qT),!this.Xx&&this.gT&&this.zT!=null&&e.addExpression(this.zT),!this.Xx&&this.kT!=null&&e.addExpression(this.kT)}};export{j as ForwardRenderPipeline};
@@ -49,7 +49,7 @@ interface EngineInitDescription {
49
49
  * ... (create something) ...
50
50
  *
51
51
  * engine.startRenderLoop((time, _myArg1, _myArg2) => {
52
- * Rn.Engine.process([expression]);
52
+ * engine.process([expression]);
53
53
  * }, myArg1, myArg2);
54
54
  * ```
55
55
  */
@@ -92,6 +92,8 @@ export declare class Engine extends RnObject {
92
92
  private __lastTransformComponentsUpdateCount;
93
93
  private __lastPrimitiveCount;
94
94
  private __lastLightComponentsUpdateCount;
95
+ private __gpuInstanceDataVersion;
96
+ private __isPreviousMorphWeightsEnabled;
95
97
  /** Shader program cache map for this engine instance. Maps shader text to program UIDs. */
96
98
  private __shaderProgramCache;
97
99
  private __gpuTimerEnabled;
@@ -149,8 +151,8 @@ export declare class Engine extends RnObject {
149
151
  *
150
152
  * @example
151
153
  * ```
152
- * Rn.Engine.startRenderLoop((time, _myArg1, _myArg2) => {
153
- * Rn.Engine.process([expression]);
154
+ * engine.startRenderLoop((time, _myArg1, _myArg2) => {
155
+ * engine.process([expression]);
154
156
  * }, myArg1, myArg2);
155
157
  * ```
156
158
  *
@@ -347,6 +349,38 @@ export declare class Engine extends RnObject {
347
349
  get dummyTextures(): DummyTextures;
348
350
  get engineState(): EngineState;
349
351
  get config(): Config;
352
+ /**
353
+ * A version that is incremented when the GPU instance data was written outside the component update
354
+ * counts that the rendering strategies compare (e.g. the jitter of temporal anti-aliasing or the previous
355
+ * world matrices it keeps). The strategies re-upload the GPU instance data when it changed.
356
+ *
357
+ * @internal
358
+ */
359
+ get _gpuInstanceDataVersion(): number;
360
+ /**
361
+ * Requests an upload of the GPU instance data in the next prerender stage. Unlike a component update, it does
362
+ * not re-run the logic stage of the components.
363
+ *
364
+ * @internal
365
+ */
366
+ _markGpuInstanceDataDirty(): void;
367
+ /**
368
+ * Whether the morph weights uniform buffer also holds the blend shape weights of the previous frame (for the
369
+ * motion vectors of temporal anti-aliasing). See `BlendShapeComponent._getMorphWeightsVec4Count`.
370
+ *
371
+ * @internal
372
+ */
373
+ get _isPreviousMorphWeightsEnabled(): boolean;
374
+ /**
375
+ * Makes the morph weights uniform buffer hold the blend shape weights of the previous frame as well.
376
+ *
377
+ * @remarks
378
+ * This cannot be turned off again: the shaders compiled afterwards declare the larger buffer, and they must keep
379
+ * working with it.
380
+ *
381
+ * @internal
382
+ */
383
+ _enablePreviousMorphWeights(): void;
350
384
  get logger(): Logger;
351
385
  /**
352
386
  * Gets the shader program cache for this engine instance.
@@ -1 +1 @@
1
- import{VERSION as B}from"../../version.js";import{CameraComponent as G}from"../components/Camera/CameraComponent.js";import{createCameraEntity as V}from"../components/Camera/createCameraEntity.js";import{LightComponent as E}from"../components/Light/LightComponent.js";import{MeshComponent as j}from"../components/Mesh/MeshComponent.js";import{MeshRendererComponent as P}from"../components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as D}from"../components/SceneGraph/SceneGraphComponent.js";import{SkeletalComponent as J}from"../components/Skeletal/SkeletalComponent.js";import{TransformComponent as _}from"../components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as k}from"../components/WellKnownComponentTIDs.js";import{Component as I}from"../core/Component.js";import{ComponentMemoryRegistry as H}from"../core/ComponentMemoryRegistry.js";import{ComponentRepository as y}from"../core/ComponentRepository.js";import{_getComponentRuntimeHooks as F}from"../core/ComponentRuntimeHooks.js";import{Config as X}from"../core/Config.js";import{EntityRepository as K}from"../core/EntityRepository.js";import{GlobalDataRepository as Q}from"../core/GlobalDataRepository.js";import{MemoryManager as Y}from"../core/MemoryManager.js";import{CameraType as Z}from"../definitions/CameraType.js";import{ProcessApproach as h}from"../definitions/ProcessApproach.js";import{ProcessStage as M}from"../definitions/ProcessStage.js";import{Primitive as A}from"../geometry/Primitive.js";import{DummyTextures as ee}from"../materials/core/DummyTextures.js";import{Vector3 as te}from"../math/Vector3.js";import{Vector4 as re}from"../math/Vector4.js";import{Is as L}from"../misc/Is.js";import{Logger as N}from"../misc/Logger.js";import{Time as T}from"../misc/Time.js";import{_getPhysicsBackend as se}from"../physics/PhysicsBackend.js";import{CGAPIResourceRepository as O}from"../renderer/CGAPIResourceRepository.js";import{Expression as ie}from"../renderer/Expression.js";import{Frame as oe}from"../renderer/Frame.js";import{LightClusterSystemStub as ne}from"../renderer/lightCluster/LightClusterSystemStub.js";import{RenderPass as $}from"../renderer/RenderPass.js";import{EngineState as ae}from"./EngineState.js";import{ModuleManager as U}from"./ModuleManager.js";import{WebGLGpuTimer as pe}from"../../webgl/WebGLGpuTimer.js";import{_cleanupWebGLStatesCacheForEngine as ue}from"../../webgl/WebGLStrategyCommonMethod.js";import{RnObject as ce}from"../core/RnObject.js";import{_cleanupGizmosForEngine as fe}from"../gizmos/GizmoRegistry.js";import{_cleanupRenderPassHelperForEngine as de}from"../helpers/RenderPassHelper.js";import{AbstractMaterialContent as he}from"../materials/core/AbstractMaterialContent.js";import{MaterialRepository as me}from"../materials/core/MaterialRepository.js";var m=class m extends ce{constructor(e,t,s,i,r){super();this.Rb=h.None;this.Pb=new ae;this.xb=0;this.Lb=-1;this.Kb=[];this.Db=new ne;this.tC=!1;this.o=!1;this.kb=-1;this.tr=-1;this.Xb=-1;this.er=-1;this.fC=new Map;this.Nb=!1;this.iC=-1;this.Fb=i!=null?i:new X,this.eC=new N,this.eC.logLevel=this.Fb.logLevel,this.iC=m.sC,this.Rb=e,this.Wb=t,this.Qb=new H,this.Ub=new y(this),this.Na=new K(this),this.Yb=new me,this.of=Y.createInstanceIfNotCreated(this,s),r!=null&&this.oC(r),this.jb=Q.init(this),m.sC++}get engineUid(){return this.iC}static getEngine(e){let t=m.rC.get(e);if(!L.not.exist(t))return t}destroy(){this.stopRenderLoop(),this.qb=void 0,this.Kb=[],this.LR()}LR(){var t,s;this.o=!0,this.Yb._makeShaderInvalidateToAllMaterials();let e=this.Na._getEntities();for(let i of e)this.Na.deleteEntity(i.entityUID);if(L.exist(this.Mb)&&(this.Mb.destroy(),this.Mb=void 0),L.exist(this.Gb)){this.Gb.clearCache();try{let i=this.Gb.getWebGpuDeviceWrapper();i&&i.context.unconfigure()}catch{}}L.exist(this.of)&&(this.of.destroy(),this.of=void 0),this.dC(),_._cleanupForEngine(this),D._cleanupForEngine(this),G._cleanupForEngine(this),E._cleanupForEngine(this),P._cleanupForEngine(this),(t=se())==null||t.cleanupForEngine(this),fe(this),he._cleanupForEngine(this),de(this),ue(this),(s=this.wb)==null||s.destroy(),this.wb=void 0,this.Qb.destroy(),this.$b=void 0,this.zb=void 0,this.xb=0,this.kb=-1,this.tr=-1,this.Xb=-1,m.rC.delete(this.objectUID),this.unregister()}startRenderLoop(e,...t){this.qb=e,this.Kb=t,this.Lb!==-1&&this.stopRenderLoop();let s=this.nC();this.Hb=s;let i=s.requestAnimationFrame.bind(s),r=this.db,c=this.Eb,u=t.length>0,n=u?[0,...t]:[],p=u?o=>{n[0]=o,e.apply(e,n)}:o=>{e.call(e,o)},a=((o,l)=>{r!=null&&r.isReadyForWebXR?(r._preRender(o,l),p(o),r._postRender()):c!=null&&c.isReadyForWebAR?(c._preRender(o,l),p(o),c._postRender()):p(o),this.Lb=i(a)});this.Lb=i(a)}nC(){let e=window,t=this.db,s=this.Eb;return t!=null&&t.requestedToEnterWebXR?e=t.xrSession:s!=null&&s.requestedToEnterWebAR&&(e=s.arSession),L.not.exist(e)?window:e}stopRenderLoop(){var t;let e=(t=this.Hb)!=null?t:this.nC();this.Lb!==-1&&e.cancelAnimationFrame(this.Lb),this.Lb=-1,this.Hb=void 0}restartRenderLoop(){this.qb!=null&&this.startRenderLoop(this.qb,...this.Kb)}processAuto(e=re.fromCopy4(0,0,0,1)){if(L.not.exist(this.$b)){let s=new ie,i=new $(this);i.toClearColorBuffer=!0,i.toClearDepthBuffer=!0,i.clearColor=e;let r=new $(this);s.addRenderPasses([i,r]),this.$b=s,this.zb=r}this.zb.clearEntities();let t=this.Na._getEntities();this.zb.addEntities(t),this.process([this.$b])}process(e){let t=this.Nb;t&&this.hC(),T._processBegin(this),this.mC(),!this.tC&&E.getUpdateCount(this)>0&&this._requestLightClusterSystem();let s=e;e instanceof oe&&(s=e.expressions),G.getCurrent(this)===I.InvalidObjectUID&&m.createCamera(this);let i=this.jb.getValue("time",0);i._v[0]=T.timeFromSystemStart,this.processApproach===h.WebGPU?this._processWebGPU(s):this._processWebGL(s),T._processEnd(),t&&this.lC()}get gpuTimerEnabled(){return this.Nb}set gpuTimerEnabled(e){this.Nb=e}get isGpuTimerSupported(){var e,t;return this.Rb===h.WebGPU?this.webGpuResourceRepository._getGpuTimer().isSupported:(t=(e=this.aC())==null?void 0:e.isSupported)!=null?t:!1}get gpuTimeMilliseconds(){var e,t;if(this.Nb)return this.Rb===h.WebGPU?(e=this.Gb)==null?void 0:e._getGpuTimer().lastGpuTimeMilliseconds:(t=this.wb)==null?void 0:t.lastGpuTimeMilliseconds}get gpuPassTimesMilliseconds(){var e;if(!(!this.Nb||this.Rb!==h.WebGPU))return(e=this.Gb)==null?void 0:e._getGpuTimer().lastPassGpuTimesMilliseconds}aC(){var e;if(this.wb==null){let t=(e=this.Jb)==null?void 0:e.currentWebGLContextWrapper;if(t==null)return;this.wb=new pe(t.getRawContextAsWebGL2())}return this.wb}hC(){var e,t;this.Rb===h.WebGPU?(e=this.Gb)==null||e._getGpuTimer().beginFrame():(t=this.aC())==null||t.begin()}lC(){var e,t;this.Rb===h.WebGPU?(e=this.Gb)==null||e._getGpuTimer().endFrame():(t=this.wb)==null||t.end()}gC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,hasAnyEffekseerComponents:c,deferredEffekseerRenderJobs:u}){t.doPreRender();let n;if(c&&t.toRenderEffekseerEffects){n=[];let d=t.entities;for(let f=0;f<d.length;f++){let g=d[f].tryToGetEffekseer();g!=null&&n.push(g)}n.length===0&&(n=void 0)}let p=n!=null,a=p?e.getEffekseerRenderPassOptions(this,t,r):void 0,o=t.toRenderEffekseerEffects&&p,l=o&&t.getResolveFramebuffer()!=null&&u!=null;if(o&&a!=null)for(let d of n)d.prepareWebGPURendering(a);if(l&&u.push({renderPass:t,displayIdx:r,renderPassOptions:a,effekseerComponents:n}),e.clearFrameBuffer(this,t,r),this.bC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:o&&!l}),o&&!l){let d=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,t,r);if(d!=null)for(let f of n)f.$renderWebGPU(d,a,r);e.endRenderPassEncoderForExternalRendering()}return t._copyResolve1ToResolve2WebGpu(),t.doPostRender(),o}RC({webGpuResourceRepository:e,currentRenderPass:t,deferredEffekseerRenderJobs:s,displayIdx:i}){if(s.length===0)return;let r=t.getResolveFramebuffer();if(r!=null)for(let c of s){if(c.displayIdx!==i||c.renderPass.getResolveFramebuffer()!==r)continue;let u=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,c.renderPass,i);if(u!=null)for(let n of c.effekseerComponents)n.$renderWebGPU(u,c.renderPassOptions,i);e.endRenderPassEncoderForExternalRendering(),c.renderPass._copyResolve1ToResolve2WebGpu()}}bC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:c}){var a;let u,n=t._renderedSomethingBefore;if(n&&(c?(u=e.renderWithRenderBundleAndKeepRenderPass(this,t,r),n=u==null):n=!e.renderWithRenderBundle(this,t,r),(a=this.Pb).webgpuRenderBundleMode||(a.webgpuRenderBundleMode=n)),!n)return u;e.createRenderBundleEncoder(this,t,r);let p=P.common_$render({renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,engine:this});if(t._renderedSomethingBefore=p,!p)return u;if(c)return e.finishRenderBundleEncoderAndKeepRenderPass(this,t,r);e.finishRenderBundleEncoder(this,t,r)}_processWebGPU(e){var r,c;let t=this.Ub.getComponentTIDs(),s=this.webGpuResourceRepository,i=this.db;for(let u of I._processStages){if(u===M.Render){this.Db.update(e),P.common_$prerender(this);let n=(r=i==null?void 0:i.isWebXRMode)!=null?r:!1,p=(c=i==null?void 0:i.isMultiView())!=null?c:!1,a=this.Pb.xrPoseWebGPU,o=n&&!p&&a!=null?a.views.length:1,l=this.Ub.hasAnyComponent(k.EffekseerComponentTID),d=o>1,f=d?new Map:void 0,g=d?new Map:void 0;for(let b=0;b<o;b++){let C=l?[]:void 0,x=!1;for(let S of e)for(let R of S.renderPasses){let W=R.renderPassUID,w=f==null?void 0:f.get(W),v;w===void 0?(w=this.xb,R._isChangedSortRenderResult=!1,v=P.sort_$render(this,R),f!=null&&(f.set(W,w),g.set(W,v))):v=g.get(W);let q=this.gC({webGpuResourceRepository:s,renderPass:R,renderPassTickCount:w,primitiveUids:v,displayIdx:b,hasAnyEffekseerComponents:l,deferredEffekseerRenderJobs:C});x||(x=q),C!=null&&C.length>0&&this.RC({webGpuResourceRepository:s,currentRenderPass:R,deferredEffekseerRenderJobs:C,displayIdx:b}),b===o-1&&(f==null||f.delete(W),g==null||g.delete(W),this.xb++)}b<o-1&&x&&s.flush()}s.flush()}else if(!this.Pb.webgpuRenderBundleMode||this.pC()||_.getUpdateCount(this)!==this.tr||G.getCurrentCameraUpdateCount(this)!==this.kb||A.getPrimitiveCount()!==this.Xb||E.getUpdateCount(this)!==this.er){let n=`common_${u.methodName}`;for(let p of t){let a=y.getComponentClass(p),o=a[n];o&&o({processApproach:this.Rb,renderPass:void 0,processStage:u,renderPassTickCount:this.xb,displayIdx:0,engine:this}),a.process(this,a,u)}}u===M.Logic&&D._updateTransformGizmosByCameraChange(this)}this.kb=G.getCurrentCameraUpdateCount(this),this.uC(),this.tr=_.getUpdateCount(this),this.Xb=A.getPrimitiveCount(),this.er=E.getUpdateCount(this)}mC(){var e;for(let t of F())(e=t.beginFrame)==null||e.call(t,this)}pC(){var e;for(let t of F())if(((e=t.isDirty)==null?void 0:e.call(t,this))===!0)return!0;return!1}uC(){var e;for(let t of F())(e=t.markUpdated)==null||e.call(t,this)}dC(){var e;for(let t of F())(e=t.cleanup)==null||e.call(t,this)}_processWebGL(e){let t=this.webglResourceRepository,s=this.Ub.getComponentTIDs(),i=this.Ub.getRenderingComponentTIDs();for(let r of I._processStages){let u=`common_${r.methodName}`;if(r===M.Render){t.getMultiDrawRepository(this).rebuildDirtyGroups(),this.Db.update(e),P.common_$prerender(this);for(let n of e)for(let p of i){let a=y.getComponentClass(p);for(let o of n.renderPasses){typeof spector!="undefined"&&spector.setMarker(`| ${n.uniqueName}: ${o.uniqueName}#`),o.doPreRender(),t.switchDepthTest(o.isDepthTest),this.bindFramebufferWebGL(o),this.setViewportForNormalRendering(o),this.setScissorForNormalRendering(o),p===k.MeshRendererComponentTID&&this.Wb.clearFrameBuffer(this,o),o._isChangedSortRenderResult=!1;let l=P.sort_$render(this,o);if(o._renderedSomethingBefore){let f=a[u];if(f){let g=f({processApproach:this.Rb,renderPass:o,processStage:r,renderPassTickCount:this.xb,primitiveUids:l,displayIdx:0,engine:this});o._renderedSomethingBefore=g}}if(p===k.EffekseerComponentTID&&o.entities.length>0){let f=this.webglResourceRepository,g=f.getCurrentTexture2DBindingsForEffekseer();f.setWebGLStateToDefaultForEffekseer();for(let b of o.entities){let C=b.tryToGetEffekseer();C!=null&&C.$render()}f.restoreTexture2DBindingsForEffekseer(g)}this.xb++,o._copyFramebufferToResolveFramebuffersWebGL(),o.doPostRender()}}}else if(this.pC()||_.getUpdateCount(this)!==this.tr||G.getCurrentCameraUpdateCount(this)!==this.kb||A.getPrimitiveCount()!==this.Xb||E.getUpdateCount(this)!==this.er)for(let n of s){let p=y.getComponentClass(n),a=p[u];a&&a({processApproach:this.Rb,renderPass:void 0,processStage:r,renderPassTickCount:this.xb,displayIdx:0,engine:this}),p.process(this,p,r)}r===M.Logic&&D._updateTransformGizmosByCameraChange(this)}this.kb=G.getCurrentCameraUpdateCount(this),this.uC(),this.tr=_.getUpdateCount(this),this.Xb=A.getPrimitiveCount(),this.er=E.getUpdateCount(this)}static get processTime(){return T.lastTimeTimeIntervalInMilliseconds}static get timeAtProcessBegin(){return T.timeAtProcessBeginMilliseconds}static get timeAtProcessEnd(){return T.timeAtProcessEndMilliseconds}static createCamera(e){let t=V(e,!0);t.getTransform().localPosition=te.fromCopyArray([0,0,1]),t.getCamera().type=Z.Orthographic,t.getCamera().zNear=.1,t.getCamera().zFar=1e4;let s=e.cgApiResourceRepository,[i,r]=s.getCanvasSize();t.getCamera().xMag=i/r,t.getCamera().yMag=1}setViewportForNormalRendering(e){let t=this.db,s=this.Eb;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)&&this.Wb.setViewport(this,e.getViewport())}setScissorForNormalRendering(e){let t=this.db,s=this.Eb,i=this.Wb;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)?i.setScissorRect(e):i.setScissorRect(void 0)}bindFramebufferWebGL(e){let t=this.db,s=this.Eb;if(t!=null&&t.isWebXRMode&&e.isOutputForVr){let r=this.Wb.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,t.framebuffer)}else if(s!=null&&s.isWebARMode){let r=this.Wb.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)}else this.Wb.bindFramebuffer(e.getFramebuffer()),this.Wb.setDrawTargets(e)}yC(){console.log(`%cRhodonite%cWeb3D Library%c %cversion%c${B.version}%c %cbranch%c${B.branch}%c %cmode%c${this.Rb.str}`,"font-weight: bold; padding: 4px 8px; border-radius: 6px 0px 0px 6px; background: linear-gradient(to right, #ff0084 0%,#ff0022 100%);","padding: 4px; border-radius: 0px 6px 6px 0px; background: linear-gradient(to right, #8400ff 0%,#4400ff 100%);","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: firebrick; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: green; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: blue; padding: 4px; border-radius: 0px 6px 6px 0px")}static CC(){y._ensureComponentClassRegistered(_),y._ensureComponentClassRegistered(D),y._ensureComponentClassRegistered(j),y._ensureComponentClassRegistered(P),y._ensureComponentClassRegistered(G),y._ensureComponentClassRegistered(E),y._ensureComponentClassRegistered(J)}static async init(e){var n,p,a,o,l;if(e.approach!==h.None&&e.approach!==h.WebGL2&&e.approach!==h.WebGPU){let d=(p=(n=e.approach)==null?void 0:n.str)!=null?p:String(e.approach);throw new Error(`Unsupported process approach "${d}". The "Uniform" and "DataTexture" modes were removed. Use ProcessApproach.WebGL2 ("WebGL2") or ProcessApproach.WebGPU ("WebGPU").`)}if(e.approach===h.WebGL2&&typeof __RN_WEBGL__!="undefined"&&!__RN_WEBGL__)throw new Error("ProcessApproach.WebGL2 is unavailable: this build was bundled with __RN_WEBGL__ = false.");if(e.approach===h.WebGPU&&typeof __RN_WEBGPU__!="undefined"&&!__RN_WEBGPU__)throw new Error("ProcessApproach.WebGPU is unavailable: this build was bundled with __RN_WEBGPU__ = false.");m.CC();let t=((a=e.xr)!=null?a:m._loadXRByDefault)?await U.getInstance().loadModule("xr"):void 0,s=0,i;if(e.approach===h.WebGPU){let R=function(v){b.features.has(v)&&S.push(v)};var u=R;await U.getInstance().loadModule("webgpu");let d=O.getWebGpuResourceRepository(),g=U.getInstance().getModule("webgpu").WebGpuDeviceWrapper,b=await navigator.gpu.requestAdapter({xrCompatible:!0}),{maxBufferSize:C,maxStorageBufferBindingSize:x}=b.limits,S=[];R("float32-filterable"),R("rg11b10ufloat-renderable"),R("texture-compression-bc"),R("texture-compression-etc2"),R("texture-compression-astc"),R("timestamp-query");let W=await b.requestDevice({requiredFeatures:S,requiredLimits:{maxStorageBufferBindingSize:x,maxBufferSize:C}});s=x;let w=new g(e.canvas,b,W);d.addWebGpuDeviceWrapper(w),d.recreateSystemDepthTexture(),d.createBindGroupLayoutForDrawParameters(),i=d}else e.approach===h.WebGL2?(await U.getInstance().loadModule("webgl"),i=O.getWebGLResourceRepository(),i.generateWebGLContext((o=e.config)!=null?o:new X,e.canvas,!0,e.webglOption),i.switchDepthTest(!0),s=i.currentWebGLContextWrapper.getMaxTextureSize()**2*4*4):s=1024**2*4*4;let r=new m(e.approach,i,s,e.config,t);return r.Pb.currentProcessApproach=e.approach,r.Fb.eventTargetDom=(l=r.Fb.eventTargetDom)!=null?l:e.canvas,e.approach===h.WebGPU&&(r.Gb=i),e.approach===h.WebGL2&&(r.Jb=i),r.Wb=i,e.notToDisplayRnInfoAtInit!==!0&&r.yC(),r.jb.initialize(e.approach),e.canvas!=null&&e.approach===h.WebGL2&&(e.canvas.addEventListener("webglcontextlost",(d=>{d.preventDefault(),r.stopRenderLoop(),r.logger.error("WebGL context lost occurred.")}).bind(this)),e.canvas.addEventListener("webglcontextrestored",()=>{r.logger.error("WebGL context restored."),r.restartRenderLoop()})),r.Mb=await ee.init(r),r.Pb.viewportAspectRatio=e.canvas!=null?e.canvas.width/e.canvas.height:1,r}get processApproach(){return this.Rb}resizeCanvas(e,t){this.cgApiResourceRepository.resizeCanvas(e,t),this.Pb.viewportAspectRatio=e/t}getCanvasSize(){return this.cgApiResourceRepository.getCanvasSize()}getCurrentWebGLContextWrapper(){return this.Wb.currentWebGLContextWrapper}get entityRepository(){return this.Na}get componentRepository(){return this.Ub}get componentMemoryRegistry(){return this.Qb}get webXRSystem(){if(this.db==null)throw new Error(m.cC);return this.db}get webARSystem(){if(this.Eb==null)throw new Error(m.cC);return this.Eb}get isXREnabled(){return this.db!=null}get _webXRSystemIfEnabled(){return this.db}get _webARSystemIfEnabled(){return this.Eb}async enableXR(){if(this.db==null){let e=await U.getInstance().loadModule("xr");this.db==null&&this.oC(e)}return this.db}oC(e){this.db=e.WebXRSystem.init(this),this.Eb=e.WebARSystem.init(this)}get memoryManager(){return this.of}get globalDataRepository(){return this.jb}_requestLightClusterSystem(){this.o||this.Zb!=null||(this.Zb=import("../renderer/lightCluster/LightClusterSystem.js").then(({LightClusterSystem:e})=>{this.o||(this.Db=new e(this),this.tC=!0)}).catch(e=>{N.default.warn(`Failed to load the light cluster system: ${e}`)}))}async _ensureLightClusterSystem(){return this._requestLightClusterSystem(),await this.Zb,this.Db}get lightClusterSystem(){return this.Db}get materialRepository(){return this.Yb}get webglResourceRepository(){return this.Jb}get cgApiResourceRepository(){return this.Wb}get webGpuResourceRepository(){return this.Gb}get dummyTextures(){return this.Mb}get engineState(){return this.Pb}get config(){return this.Fb}get logger(){return this.eC}get shaderProgramCache(){return this.fC}};m._loadXRByDefault=!1,m.rC=new Map,m.sC=0,m.cC="The XR support is not enabled. Initialize the engine with Engine.init({ xr: true }) or call await engine.enableXR() first. The default Rn namespace export enables it automatically.";var z=m;export{z as Engine};
1
+ import{VERSION as B}from"../../version.js";import{CameraComponent as G}from"../components/Camera/CameraComponent.js";import{createCameraEntity as V}from"../components/Camera/createCameraEntity.js";import{LightComponent as E}from"../components/Light/LightComponent.js";import{MeshComponent as j}from"../components/Mesh/MeshComponent.js";import{MeshRendererComponent as P}from"../components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as S}from"../components/SceneGraph/SceneGraphComponent.js";import{SkeletalComponent as J}from"../components/Skeletal/SkeletalComponent.js";import{TransformComponent as _}from"../components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as k}from"../components/WellKnownComponentTIDs.js";import{Component as I}from"../core/Component.js";import{ComponentMemoryRegistry as H}from"../core/ComponentMemoryRegistry.js";import{ComponentRepository as y}from"../core/ComponentRepository.js";import{_getComponentRuntimeHooks as F}from"../core/ComponentRuntimeHooks.js";import{Config as X}from"../core/Config.js";import{EntityRepository as K}from"../core/EntityRepository.js";import{GlobalDataRepository as Q}from"../core/GlobalDataRepository.js";import{MemoryManager as Y}from"../core/MemoryManager.js";import{CameraType as Z}from"../definitions/CameraType.js";import{ProcessApproach as d}from"../definitions/ProcessApproach.js";import{ProcessStage as M}from"../definitions/ProcessStage.js";import{Primitive as A}from"../geometry/Primitive.js";import{DummyTextures as ee}from"../materials/core/DummyTextures.js";import{Vector3 as te}from"../math/Vector3.js";import{Vector4 as re}from"../math/Vector4.js";import{Is as L}from"../misc/Is.js";import{Logger as N}from"../misc/Logger.js";import{Time as T}from"../misc/Time.js";import{_getPhysicsBackend as se}from"../physics/PhysicsBackend.js";import{CGAPIResourceRepository as O}from"../renderer/CGAPIResourceRepository.js";import{Expression as ie}from"../renderer/Expression.js";import{Frame as oe}from"../renderer/Frame.js";import{LightClusterSystemStub as ne}from"../renderer/lightCluster/LightClusterSystemStub.js";import{RenderPass as $}from"../renderer/RenderPass.js";import{EngineState as ae}from"./EngineState.js";import{ModuleManager as U}from"./ModuleManager.js";import{WebGLGpuTimer as pe}from"../../webgl/WebGLGpuTimer.js";import{_cleanupWebGLStatesCacheForEngine as ue}from"../../webgl/WebGLStrategyCommonMethod.js";import{RnObject as ce}from"../core/RnObject.js";import{_cleanupGizmosForEngine as fe}from"../gizmos/GizmoRegistry.js";import{_cleanupRenderPassHelperForEngine as he}from"../helpers/RenderPassHelper.js";import{AbstractMaterialContent as de}from"../materials/core/AbstractMaterialContent.js";import{MaterialRepository as me}from"../materials/core/MaterialRepository.js";var m=class m extends ce{constructor(e,t,s,i,r){super();this.tC=d.None;this.oC=new ae;this.nC=0;this.pC=-1;this.WC=[];this.cC=new ne;this.wC=!1;this.o=!1;this.dC=-1;this.nr=-1;this.mC=-1;this.or=-1;this._C=0;this.LC=!1;this.BC=new Map;this.lC=!1;this.DC=-1;this.fC=i!=null?i:new X,this.xC=new N,this.xC.logLevel=this.fC.logLevel,this.DC=m.UC,this.tC=e,this.rC=t,this.GC=new H,this.uC=new y(this),this.Na=new K(this),this.EC=new me,this.of=Y.createInstanceIfNotCreated(this,s),r!=null&&this.SC(r),this.yC=Q.init(this),m.UC++}get engineUid(){return this.DC}static getEngine(e){let t=m.TC.get(e);if(!L.not.exist(t))return t}destroy(){this.stopRenderLoop(),this.RC=void 0,this.WC=[],this.Lb()}Lb(){var t,s;this.o=!0,this.EC._makeShaderInvalidateToAllMaterials();let e=this.Na._getEntities();for(let i of e)this.Na.deleteEntity(i.entityUID);if(L.exist(this.hC)&&(this.hC.destroy(),this.hC=void 0),L.exist(this.sC)){this.sC.clearCache();try{let i=this.sC.getWebGpuDeviceWrapper();i&&i.context.unconfigure()}catch{}}L.exist(this.of)&&(this.of.destroy(),this.of=void 0),this.XC(),_._cleanupForEngine(this),S._cleanupForEngine(this),G._cleanupForEngine(this),E._cleanupForEngine(this),P._cleanupForEngine(this),(t=se())==null||t.cleanupForEngine(this),fe(this),de._cleanupForEngine(this),he(this),ue(this),(s=this.aC)==null||s.destroy(),this.aC=void 0,this.GC.destroy(),this.gC=void 0,this.bC=void 0,this.nC=0,this.dC=-1,this.nr=-1,this.mC=-1,m.TC.delete(this.objectUID),this.unregister()}startRenderLoop(e,...t){this.RC=e,this.WC=t,this.pC!==-1&&this.stopRenderLoop();let s=this.FC();this.vC=s;let i=s.requestAnimationFrame.bind(s),r=this.eC,c=this.iC,u=t.length>0,n=u?[0,...t]:[],p=u?o=>{n[0]=o,e.apply(e,n)}:o=>{e.call(e,o)},a=((o,l)=>{r!=null&&r.isReadyForWebXR?(r._preRender(o,l),p(o),r._postRender()):c!=null&&c.isReadyForWebAR?(c._preRender(o,l),p(o),c._postRender()):p(o),this.pC=i(a)});this.pC=i(a)}FC(){let e=window,t=this.eC,s=this.iC;return t!=null&&t.requestedToEnterWebXR?e=t.xrSession:s!=null&&s.requestedToEnterWebAR&&(e=s.arSession),L.not.exist(e)?window:e}stopRenderLoop(){var t;let e=(t=this.vC)!=null?t:this.FC();this.pC!==-1&&e.cancelAnimationFrame(this.pC),this.pC=-1,this.vC=void 0}restartRenderLoop(){this.RC!=null&&this.startRenderLoop(this.RC,...this.WC)}processAuto(e=re.fromCopy4(0,0,0,1)){if(L.not.exist(this.gC)){let s=new ie,i=new $(this);i.toClearColorBuffer=!0,i.toClearDepthBuffer=!0,i.clearColor=e;let r=new $(this);s.addRenderPasses([i,r]),this.gC=s,this.bC=r}this.bC.clearEntities();let t=this.Na._getEntities();this.bC.addEntities(t),this.process([this.gC])}process(e){let t=this.lC;t&&this.NC(),T._processBegin(this),this.OC(),!this.wC&&E.getUpdateCount(this)>0&&this._requestLightClusterSystem();let s=e;e instanceof oe&&(s=e.expressions),G.getCurrent(this)===I.InvalidObjectUID&&m.createCamera(this);let i=this.yC.getValue("time",0);i._v[0]=T.timeFromSystemStart,this.processApproach===d.WebGPU?this._processWebGPU(s):this._processWebGL(s),T._processEnd(),t&&this.$C()}get gpuTimerEnabled(){return this.lC}set gpuTimerEnabled(e){this.lC=e}get isGpuTimerSupported(){var e,t;return this.tC===d.WebGPU?this.webGpuResourceRepository._getGpuTimer().isSupported:(t=(e=this.MC())==null?void 0:e.isSupported)!=null?t:!1}get gpuTimeMilliseconds(){var e,t;if(this.lC)return this.tC===d.WebGPU?(e=this.sC)==null?void 0:e._getGpuTimer().lastGpuTimeMilliseconds:(t=this.aC)==null?void 0:t.lastGpuTimeMilliseconds}get gpuPassTimesMilliseconds(){var e;if(!(!this.lC||this.tC!==d.WebGPU))return(e=this.sC)==null?void 0:e._getGpuTimer().lastPassGpuTimesMilliseconds}MC(){var e;if(this.aC==null){let t=(e=this.CC)==null?void 0:e.currentWebGLContextWrapper;if(t==null)return;this.aC=new pe(t.getRawContextAsWebGL2())}return this.aC}NC(){var e,t;this.tC===d.WebGPU?(e=this.sC)==null||e._getGpuTimer().beginFrame():(t=this.MC())==null||t.begin()}$C(){var e,t;this.tC===d.WebGPU?(e=this.sC)==null||e._getGpuTimer().endFrame():(t=this.aC)==null||t.end()}zC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,hasAnyEffekseerComponents:c,deferredEffekseerRenderJobs:u}){t.doPreRender();let n;if(c&&t.toRenderEffekseerEffects){n=[];let h=t.entities;for(let f=0;f<h.length;f++){let g=h[f].tryToGetEffekseer();g!=null&&n.push(g)}n.length===0&&(n=void 0)}let p=n!=null,a=p?e.getEffekseerRenderPassOptions(this,t,r):void 0,o=t.toRenderEffekseerEffects&&p,l=o&&t.getResolveFramebuffer()!=null&&u!=null;if(o&&a!=null)for(let h of n)h.prepareWebGPURendering(a);if(l&&u.push({renderPass:t,displayIdx:r,renderPassOptions:a,effekseerComponents:n}),e.clearFrameBuffer(this,t,r),this.qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:o&&!l}),o&&!l){let h=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,t,r);if(h!=null)for(let f of n)f.$renderWebGPU(h,a,r);e.endRenderPassEncoderForExternalRendering()}return t._copyResolve1ToResolve2WebGpu(),t.doPostRender(),o}VC({webGpuResourceRepository:e,currentRenderPass:t,deferredEffekseerRenderJobs:s,displayIdx:i}){if(s.length===0)return;let r=t.getResolveFramebuffer();if(r!=null)for(let c of s){if(c.displayIdx!==i||c.renderPass.getResolveFramebuffer()!==r)continue;let u=e.getOrCreateRenderPassEncoderForEffekseerExternalRendering(this,c.renderPass,i);if(u!=null)for(let n of c.effekseerComponents)n.$renderWebGPU(u,c.renderPassOptions,i);e.endRenderPassEncoderForExternalRendering(),c.renderPass._copyResolve1ToResolve2WebGpu()}}qC({webGpuResourceRepository:e,renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,shouldKeepRenderPassForEffekseer:c}){var a;let u,n=t._renderedSomethingBefore;if(n&&(c?(u=e.renderWithRenderBundleAndKeepRenderPass(this,t,r),n=u==null):n=!e.renderWithRenderBundle(this,t,r),(a=this.oC).webgpuRenderBundleMode||(a.webgpuRenderBundleMode=n)),!n)return u;e.createRenderBundleEncoder(this,t,r);let p=P.common_$render({renderPass:t,renderPassTickCount:s,primitiveUids:i,displayIdx:r,engine:this});if(t._renderedSomethingBefore=p,!p)return u;if(c)return e.finishRenderBundleEncoderAndKeepRenderPass(this,t,r);e.finishRenderBundleEncoder(this,t,r)}_processWebGPU(e){var r,c;let t=this.uC.getComponentTIDs(),s=this.webGpuResourceRepository,i=this.eC;for(let u of I._processStages){if(u===M.Render){this.cC.update(e),P.common_$prerender(this);let n=(r=i==null?void 0:i.isWebXRMode)!=null?r:!1,p=(c=i==null?void 0:i.isMultiView())!=null?c:!1,a=this.oC.xrPoseWebGPU,o=n&&!p&&a!=null?a.views.length:1,l=this.uC.hasAnyComponent(k.EffekseerComponentTID),h=o>1,f=h?new Map:void 0,g=h?new Map:void 0;for(let b=0;b<o;b++){let C=l?[]:void 0,x=!1;for(let D of e)for(let R of D.renderPasses){let v=R.renderPassUID,w=f==null?void 0:f.get(v),W;w===void 0?(w=this.nC,R._isChangedSortRenderResult=!1,W=P.sort_$render(this,R),f!=null&&(f.set(v,w),g.set(v,W))):W=g.get(v);let q=this.zC({webGpuResourceRepository:s,renderPass:R,renderPassTickCount:w,primitiveUids:W,displayIdx:b,hasAnyEffekseerComponents:l,deferredEffekseerRenderJobs:C});x||(x=q),C!=null&&C.length>0&&this.VC({webGpuResourceRepository:s,currentRenderPass:R,deferredEffekseerRenderJobs:C,displayIdx:b}),b===o-1&&(f==null||f.delete(v),g==null||g.delete(v),this.nC++)}b<o-1&&x&&s.flush()}s.flush()}else if(!this.oC.webgpuRenderBundleMode||this.AC()||_.getUpdateCount(this)!==this.nr||G.getCurrentCameraUpdateCount(this)!==this.dC||A.getPrimitiveCount()!==this.mC||E.getUpdateCount(this)!==this.or){let n=`common_${u.methodName}`;for(let p of t){let a=y.getComponentClass(p),o=a[n];o&&o({processApproach:this.tC,renderPass:void 0,processStage:u,renderPassTickCount:this.nC,displayIdx:0,engine:this}),a.process(this,a,u)}}u===M.Logic&&S._updateTransformGizmosByCameraChange(this)}this.dC=G.getCurrentCameraUpdateCount(this),this.kC(),this.nr=_.getUpdateCount(this),this.mC=A.getPrimitiveCount(),this.or=E.getUpdateCount(this)}OC(){var e;for(let t of F())(e=t.beginFrame)==null||e.call(t,this)}AC(){var e;for(let t of F())if(((e=t.isDirty)==null?void 0:e.call(t,this))===!0)return!0;return!1}kC(){var e;for(let t of F())(e=t.markUpdated)==null||e.call(t,this)}XC(){var e;for(let t of F())(e=t.cleanup)==null||e.call(t,this)}_processWebGL(e){let t=this.webglResourceRepository,s=this.uC.getComponentTIDs(),i=this.uC.getRenderingComponentTIDs();for(let r of I._processStages){let u=`common_${r.methodName}`;if(r===M.Render){t.getMultiDrawRepository(this).rebuildDirtyGroups(),this.cC.update(e),P.common_$prerender(this);for(let n of e)for(let p of i){let a=y.getComponentClass(p);for(let o of n.renderPasses){typeof spector!="undefined"&&spector.setMarker(`| ${n.uniqueName}: ${o.uniqueName}#`),o.doPreRender(),t.switchDepthTest(o.isDepthTest),this.bindFramebufferWebGL(o),this.setViewportForNormalRendering(o),this.setScissorForNormalRendering(o),p===k.MeshRendererComponentTID&&this.rC.clearFrameBuffer(this,o),o._isChangedSortRenderResult=!1;let l=P.sort_$render(this,o);if(o._renderedSomethingBefore){let f=a[u];if(f){let g=f({processApproach:this.tC,renderPass:o,processStage:r,renderPassTickCount:this.nC,primitiveUids:l,displayIdx:0,engine:this});o._renderedSomethingBefore=g}}if(p===k.EffekseerComponentTID&&o.entities.length>0){let f=this.webglResourceRepository,g=f.getCurrentTexture2DBindingsForEffekseer();f.setWebGLStateToDefaultForEffekseer();for(let b of o.entities){let C=b.tryToGetEffekseer();C!=null&&C.$render()}f.restoreTexture2DBindingsForEffekseer(g)}this.nC++,o._copyFramebufferToResolveFramebuffersWebGL(),o.doPostRender()}}}else if(this.AC()||_.getUpdateCount(this)!==this.nr||G.getCurrentCameraUpdateCount(this)!==this.dC||A.getPrimitiveCount()!==this.mC||E.getUpdateCount(this)!==this.or)for(let n of s){let p=y.getComponentClass(n),a=p[u];a&&a({processApproach:this.tC,renderPass:void 0,processStage:r,renderPassTickCount:this.nC,displayIdx:0,engine:this}),p.process(this,p,r)}r===M.Logic&&S._updateTransformGizmosByCameraChange(this)}this.dC=G.getCurrentCameraUpdateCount(this),this.kC(),this.nr=_.getUpdateCount(this),this.mC=A.getPrimitiveCount(),this.or=E.getUpdateCount(this)}static get processTime(){return T.lastTimeTimeIntervalInMilliseconds}static get timeAtProcessBegin(){return T.timeAtProcessBeginMilliseconds}static get timeAtProcessEnd(){return T.timeAtProcessEndMilliseconds}static createCamera(e){let t=V(e,!0);t.getTransform().localPosition=te.fromCopyArray([0,0,1]),t.getCamera().type=Z.Orthographic,t.getCamera().zNear=.1,t.getCamera().zFar=1e4;let s=e.cgApiResourceRepository,[i,r]=s.getCanvasSize();t.getCamera().xMag=i/r,t.getCamera().yMag=1}setViewportForNormalRendering(e){let t=this.eC,s=this.iC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)&&this.rC.setViewport(this,e.getViewport())}setScissorForNormalRendering(e){let t=this.eC,s=this.iC,i=this.rC;(!(t!=null&&t.isWebXRMode)||!e.isVrRendering)&&!(s!=null&&s.isWebARMode)?i.setScissorRect(e):i.setScissorRect(void 0)}bindFramebufferWebGL(e){let t=this.eC,s=this.iC;if(t!=null&&t.isWebXRMode&&e.isOutputForVr){let r=this.rC.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,t.framebuffer)}else if(s!=null&&s.isWebARMode){let r=this.rC.currentWebGLContextWrapper.getRawContext();r.bindFramebuffer(r.FRAMEBUFFER,s.framebuffer)}else this.rC.bindFramebuffer(e.getFramebuffer()),this.rC.setDrawTargets(e)}jC(){console.log(`%cRhodonite%cWeb3D Library%c %cversion%c${B.version}%c %cbranch%c${B.branch}%c %cmode%c${this.tC.str}`,"font-weight: bold; padding: 4px 8px; border-radius: 6px 0px 0px 6px; background: linear-gradient(to right, #ff0084 0%,#ff0022 100%);","padding: 4px; border-radius: 0px 6px 6px 0px; background: linear-gradient(to right, #8400ff 0%,#4400ff 100%);","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: firebrick; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: green; padding: 4px; border-radius: 0px 6px 6px 0px","","background: #666; padding: 4px; border-radius: 6px 0px 0px 6px","background: blue; padding: 4px; border-radius: 0px 6px 6px 0px")}static JC(){y._ensureComponentClassRegistered(_),y._ensureComponentClassRegistered(S),y._ensureComponentClassRegistered(j),y._ensureComponentClassRegistered(P),y._ensureComponentClassRegistered(G),y._ensureComponentClassRegistered(E),y._ensureComponentClassRegistered(J)}static async init(e){var n,p,a,o,l;if(e.approach!==d.None&&e.approach!==d.WebGL2&&e.approach!==d.WebGPU){let h=(p=(n=e.approach)==null?void 0:n.str)!=null?p:String(e.approach);throw new Error(`Unsupported process approach "${h}". The "Uniform" and "DataTexture" modes were removed. Use ProcessApproach.WebGL2 ("WebGL2") or ProcessApproach.WebGPU ("WebGPU").`)}if(e.approach===d.WebGL2&&typeof __RN_WEBGL__!="undefined"&&!__RN_WEBGL__)throw new Error("ProcessApproach.WebGL2 is unavailable: this build was bundled with __RN_WEBGL__ = false.");if(e.approach===d.WebGPU&&typeof __RN_WEBGPU__!="undefined"&&!__RN_WEBGPU__)throw new Error("ProcessApproach.WebGPU is unavailable: this build was bundled with __RN_WEBGPU__ = false.");m.JC();let t=((a=e.xr)!=null?a:m._loadXRByDefault)?await U.getInstance().loadModule("xr"):void 0,s=0,i;if(e.approach===d.WebGPU){let R=function(W){b.features.has(W)&&D.push(W)};var u=R;await U.getInstance().loadModule("webgpu");let h=O.getWebGpuResourceRepository(),g=U.getInstance().getModule("webgpu").WebGpuDeviceWrapper,b=await navigator.gpu.requestAdapter({xrCompatible:!0}),{maxBufferSize:C,maxStorageBufferBindingSize:x}=b.limits,D=[];R("float32-filterable"),R("rg11b10ufloat-renderable"),R("texture-compression-bc"),R("texture-compression-etc2"),R("texture-compression-astc"),R("timestamp-query");let v=await b.requestDevice({requiredFeatures:D,requiredLimits:{maxStorageBufferBindingSize:x,maxBufferSize:C}});s=x;let w=new g(e.canvas,b,v);h.addWebGpuDeviceWrapper(w),h.recreateSystemDepthTexture(),h.createBindGroupLayoutForDrawParameters(),i=h}else e.approach===d.WebGL2?(await U.getInstance().loadModule("webgl"),i=O.getWebGLResourceRepository(),i.generateWebGLContext((o=e.config)!=null?o:new X,e.canvas,!0,e.webglOption),i.switchDepthTest(!0),s=i.currentWebGLContextWrapper.getMaxTextureSize()**2*4*4):s=1024**2*4*4;let r=new m(e.approach,i,s,e.config,t);return r.oC.currentProcessApproach=e.approach,r.fC.eventTargetDom=(l=r.fC.eventTargetDom)!=null?l:e.canvas,e.approach===d.WebGPU&&(r.sC=i),e.approach===d.WebGL2&&(r.CC=i),r.rC=i,e.notToDisplayRnInfoAtInit!==!0&&r.jC(),r.yC.initialize(e.approach),e.canvas!=null&&e.approach===d.WebGL2&&(e.canvas.addEventListener("webglcontextlost",(h=>{h.preventDefault(),r.stopRenderLoop(),r.logger.error("WebGL context lost occurred.")}).bind(this)),e.canvas.addEventListener("webglcontextrestored",()=>{r.logger.error("WebGL context restored."),r.restartRenderLoop()})),r.hC=await ee.init(r),r.oC.viewportAspectRatio=e.canvas!=null?e.canvas.width/e.canvas.height:1,r}get processApproach(){return this.tC}resizeCanvas(e,t){this.cgApiResourceRepository.resizeCanvas(e,t),this.oC.viewportAspectRatio=e/t}getCanvasSize(){return this.cgApiResourceRepository.getCanvasSize()}getCurrentWebGLContextWrapper(){return this.rC.currentWebGLContextWrapper}get entityRepository(){return this.Na}get componentRepository(){return this.uC}get componentMemoryRegistry(){return this.GC}get webXRSystem(){if(this.eC==null)throw new Error(m.IC);return this.eC}get webARSystem(){if(this.iC==null)throw new Error(m.IC);return this.iC}get isXREnabled(){return this.eC!=null}get _webXRSystemIfEnabled(){return this.eC}get _webARSystemIfEnabled(){return this.iC}async enableXR(){if(this.eC==null){let e=await U.getInstance().loadModule("xr");this.eC==null&&this.SC(e)}return this.eC}SC(e){this.eC=e.WebXRSystem.init(this),this.iC=e.WebARSystem.init(this)}get memoryManager(){return this.of}get globalDataRepository(){return this.yC}_requestLightClusterSystem(){this.o||this.PC!=null||(this.PC=import("../renderer/lightCluster/LightClusterSystem.js").then(({LightClusterSystem:e})=>{this.o||(this.cC=new e(this),this.wC=!0)}).catch(e=>{N.default.warn(`Failed to load the light cluster system: ${e}`)}))}async _ensureLightClusterSystem(){return this._requestLightClusterSystem(),await this.PC,this.cC}get lightClusterSystem(){return this.cC}get materialRepository(){return this.EC}get webglResourceRepository(){return this.CC}get cgApiResourceRepository(){return this.rC}get webGpuResourceRepository(){return this.sC}get dummyTextures(){return this.hC}get engineState(){return this.oC}get config(){return this.fC}get _gpuInstanceDataVersion(){return this._C}_markGpuInstanceDataDirty(){this._C++}get _isPreviousMorphWeightsEnabled(){return this.LC}_enablePreviousMorphWeights(){this.LC=!0}get logger(){return this.xC}get shaderProgramCache(){return this.BC}};m._loadXRByDefault=!1,m.TC=new Map,m.UC=0,m.IC="The XR support is not enabled. Initialize the engine with Engine.init({ xr: true }) or call await engine.enableXR() first. The default Rn namespace export enables it automatically.";var z=m;export{z as Engine};
@@ -1 +1 @@
1
- import{RnObject as u}from"../core/RnObject.js";import{ComponentType as c}from"../definitions/ComponentType.js";import{CompositionType as d}from"../definitions/CompositionType.js";import{PixelFormat as l}from"../definitions/PixelFormat.js";import{TextureFormat as g}from"../definitions/TextureFormat.js";import{Is as h}from"../misc/Is.js";import{TextureDataFloat as x}from"./TextureDataFloat.js";var s=class s extends u{constructor(e){super();this.sm=0;this.Xx=0;this.pI=0;this.uI=1;this.cI=g.RGBA8;this.dI=l.RGBA;this.Ye=c.UnsignedByte;this.nI=!1;this.iI=!1;this.aI=!1;this.mI=!1;this.wy="untitled";this._textureResourceUid=-1;this._samplerResourceUid=-1;this._textureViewResourceUid=-1;this._textureViewAsRenderTargetResourceUid=-1;this.oI=++s.sI,this.i=e}get textureUID(){return this.oI}get width(){return this.sm}getWidthAtMipLevel(e){return Math.max(1,Math.floor(this.sm/2**e))}getHeightAtMipLevel(e){return Math.max(1,Math.floor(this.Xx/2**e))}set width(e){this.sm=e}get height(){return this.Xx}set height(e){this.Xx=e}get isTextureReady(){return this.aI}get startedToLoad(){return this.mI}get isDummyTexture(){return this.iI}markAsDummyTexture(e=!0){this.iI=e}get htmlImageElement(){return this.eI}get htmlCanvasElement(){let e=document.createElement("canvas"),t=e==null?void 0:e.getContext("2d");return this.tI=e,h.exist(t)&&h.exist(this.eI)&&(e.width=this.eI.width,e.height=this.eI.height,t.drawImage(this.eI,0,0,this.eI.width,this.eI.height)),this.tI}get uri(){return this.hI}set name(e){this.wy=e}get name(){return this.wy}getImageData(e,t,r,o){return this.rI===void 0&&this.createInternalCanvasContext(),this.rI.getImageData(e,t,r,o)}getPixelAs(e,t,r){let i=this.getImageData(e,t,1,1).data;return r.compositionType===d.Vec4?new r(new Float32Array([i[0],i[1],i[2],i[3]])):new r(new Float32Array([i[0],i[1],i[2]]))}getPixelAsArray(e,t){return this.getImageData(e,t,1,1).data}setPixel(e,t,r){let o=this.getImageData(e,t,1,1),i=o.data,n=r.constructor.compositionType.getNumberOfComponents();for(let m=0;m<n;m++)i[m]=r.at(m);this.rI.putImageData(o,e,t)}setPixelAtChannel(e,t,r,o){let i=this.getImageData(e,t,1,1),a=i.data;a[r]=o,this.rI.putImageData(i,e,t)}get isTransparent(){return this.nI}createInternalCanvasContext(){let e;this.tI!=null?e=this.tI:(e=document.createElement("canvas"),e.width=this.width,e.height=this.height),this.tI=e,this.rI=e.getContext("2d")}getTextureDataFloat(e){let t=this.getImageData(0,0,this.width,this.height),r=new x(this.width,this.height,e),o=t.data;for(let i=0;i<this.height;i++)for(let a=0;a<this.width;a++)for(let n=0;n<e;n++)r.setPixelAtChannel(a,i,n,o[i*this.width*4+a*4+n]/255);return r}async getTexturePixelDataFromGPU(){if(!(!this.aI||this._textureResourceUid<0||this.sm<=0||this.Xx<=0))try{return await this.i.cgApiResourceRepository.getPixelDataFromTextureAsync(this._textureResourceUid,0,0,this.sm,this.Xx)}catch(e){console.warn("Failed to read texture pixel data from GPU:",e);return}}async createCanvasFromGPU(){let e=await this.getTexturePixelDataFromGPU();if(!e||e.length===0)return;let t=document.createElement("canvas");t.width=this.sm,t.height=this.Xx;let r=t.getContext("2d");if(!r)return;let o=new ImageData(new Uint8ClampedArray(e),this.sm,this.Xx);return r.putImageData(o,0,0),t}};s.InvalidTextureUid=-1,s.sI=s.InvalidTextureUid;var p=s;export{p as AbstractTexture};
1
+ import{RnObject as u}from"../core/RnObject.js";import{ComponentType as c}from"../definitions/ComponentType.js";import{CompositionType as d}from"../definitions/CompositionType.js";import{PixelFormat as l}from"../definitions/PixelFormat.js";import{TextureFormat as g}from"../definitions/TextureFormat.js";import{Is as h}from"../misc/Is.js";import{TextureDataFloat as x}from"./TextureDataFloat.js";var s=class s extends u{constructor(e){super();this.sm=0;this.TT=0;this.pI=0;this.uI=1;this.cI=g.RGBA8;this.dI=l.RGBA;this.Qe=c.UnsignedByte;this.nI=!1;this.iI=!1;this.aI=!1;this.mI=!1;this.wy="untitled";this._textureResourceUid=-1;this._samplerResourceUid=-1;this._textureViewResourceUid=-1;this._textureViewAsRenderTargetResourceUid=-1;this.oI=++s.sI,this.i=e}get textureUID(){return this.oI}get width(){return this.sm}getWidthAtMipLevel(e){return Math.max(1,Math.floor(this.sm/2**e))}getHeightAtMipLevel(e){return Math.max(1,Math.floor(this.TT/2**e))}set width(e){this.sm=e}get height(){return this.TT}set height(e){this.TT=e}get isTextureReady(){return this.aI}get startedToLoad(){return this.mI}get isDummyTexture(){return this.iI}markAsDummyTexture(e=!0){this.iI=e}get htmlImageElement(){return this.eI}get htmlCanvasElement(){let e=document.createElement("canvas"),t=e==null?void 0:e.getContext("2d");return this.tI=e,h.exist(t)&&h.exist(this.eI)&&(e.width=this.eI.width,e.height=this.eI.height,t.drawImage(this.eI,0,0,this.eI.width,this.eI.height)),this.tI}get uri(){return this.hI}set name(e){this.wy=e}get name(){return this.wy}getImageData(e,t,r,o){return this.rI===void 0&&this.createInternalCanvasContext(),this.rI.getImageData(e,t,r,o)}getPixelAs(e,t,r){let i=this.getImageData(e,t,1,1).data;return r.compositionType===d.Vec4?new r(new Float32Array([i[0],i[1],i[2],i[3]])):new r(new Float32Array([i[0],i[1],i[2]]))}getPixelAsArray(e,t){return this.getImageData(e,t,1,1).data}setPixel(e,t,r){let o=this.getImageData(e,t,1,1),i=o.data,n=r.constructor.compositionType.getNumberOfComponents();for(let m=0;m<n;m++)i[m]=r.at(m);this.rI.putImageData(o,e,t)}setPixelAtChannel(e,t,r,o){let i=this.getImageData(e,t,1,1),a=i.data;a[r]=o,this.rI.putImageData(i,e,t)}get isTransparent(){return this.nI}createInternalCanvasContext(){let e;this.tI!=null?e=this.tI:(e=document.createElement("canvas"),e.width=this.width,e.height=this.height),this.tI=e,this.rI=e.getContext("2d")}getTextureDataFloat(e){let t=this.getImageData(0,0,this.width,this.height),r=new x(this.width,this.height,e),o=t.data;for(let i=0;i<this.height;i++)for(let a=0;a<this.width;a++)for(let n=0;n<e;n++)r.setPixelAtChannel(a,i,n,o[i*this.width*4+a*4+n]/255);return r}async getTexturePixelDataFromGPU(){if(!(!this.aI||this._textureResourceUid<0||this.sm<=0||this.TT<=0))try{return await this.i.cgApiResourceRepository.getPixelDataFromTextureAsync(this._textureResourceUid,0,0,this.sm,this.TT)}catch(e){console.warn("Failed to read texture pixel data from GPU:",e);return}}async createCanvasFromGPU(){let e=await this.getTexturePixelDataFromGPU();if(!e||e.length===0)return;let t=document.createElement("canvas");t.width=this.sm,t.height=this.TT;let r=t.getContext("2d");if(!r)return;let o=new ImageData(new Uint8ClampedArray(e),this.sm,this.TT);return r.putImageData(o,0,0),t}};s.InvalidTextureUid=-1,s.sI=s.InvalidTextureUid;var p=s;export{p as AbstractTexture};
@@ -1 +1 @@
1
- import{HdriFormat as x}from"../definitions/HdriFormat.js";import{ProcessApproach as m}from"../definitions/ProcessApproach.js";import{TextureParameter as p}from"../definitions/TextureParameter.js";import{Logger as n}from"../misc/Logger.js";import{CGAPIResourceRepository as d}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as A}from"./AbstractTexture.js";var u=class u extends A{constructor(){super(...arguments);this.mipmapLevelNumber=1;this.hdriFormat=x.LDR_SRGB}uA(e,t){this._textureResourceUid=e,u.managedRegistry.register(this,{textureResourceUid:e,engine:this.i,uniqueName:t},this)}async loadTextureImages({baseUrl:e,mipmapLevelNumber:t,isNamePosNeg:r,hdriFormat:i}){this.mI=!0,this.mipmapLevelNumber=t,this.hdriFormat=i;let s=this.i.cgApiResourceRepository,[o,c,l,a]=await s.createCubeTextureFromFiles(this.i,e,t,r,i);this.uA(o,this.uniqueName),this._recommendedTextureSampler=c,this._samplerResourceUid=c._samplerResourceUid,this.sm=l,this.Xx=a,this.i.engineState.currentProcessApproach===m.WebGPU&&(this._textureViewResourceUid=s.createTextureViewCube(this._textureResourceUid)),this.aI=!0}loadTextureImagesFromBasis(e,{magFilter:t=p.Linear,minFilter:r=p.LinearMipmapLinear,wrapS:i=p.Repeat,wrapT:s=p.Repeat}={}){this.mI=!0,typeof BASIS=="undefined"&&n.default.error("Failed to call BASIS() function. Please check to import basis_transcoder.js."),BASIS().then(o=>{let{initializeBasis:c}=o;c();let l=o.BasisFile,a=new l(e);if(!a.startTranscoding()){n.default.error("failed to start transcoding."),a.close(),a.delete();return}let g=this.i.webglResourceRepository,{resourceHandle:y,width:R,height:b}=g.createCubeTextureFromBasis(a,{magFilter:t,minFilter:r,wrapS:i,wrapT:s});this.uA(y,this.uniqueName),this.sm=R,this.Xx=b,this.aI=!0,a.close(),a.delete()})}load1x1Texture(e="rgba(0,0,0,1)"){let t=document.createElement("canvas");t.width=1,t.height=1;let r=t.getContext("2d");if(r==null){n.default.error("Failed to get canvas context.");return}r.fillStyle=e,r.fillRect(0,0,1,1);let i=this.i.cgApiResourceRepository,[s,o]=i.createCubeTexture(this.i,1,[{posX:t,negX:t,posY:t,negY:t,posZ:t,negZ:t}],1,1);this.uA(s,this.uniqueName),this._recommendedTextureSampler=o,this._samplerResourceUid=o._samplerResourceUid,this.sm=1,this.Xx=1,this.i.engineState.currentProcessApproach===m.WebGPU&&(this._textureViewResourceUid=i.createTextureViewCube(this._textureResourceUid)),this.aI=!0}generateTextureFromTypedArrays(e,t,r){let i=this.i.webglResourceRepository,[s,o]=i.createCubeTexture(this.i,e.length,e,t,r);this._recommendedTextureSampler=o,this.uA(s,this.uniqueName),this.sm=t,this.Xx=r,this.aI=!0,this.mI=!0}importWebGLTextureDirectly(e,t=0,r=0){this.sm=t,this.Xx=r;let s=this.i.webglResourceRepository.setWebGLTextureDirectly(e);this.uA(s,this.uniqueName),this.mI=!0,this.aI=!0}static cA(e,t){e.cgApiResourceRepository.deleteTexture(t)}destroy3DAPIResources(){u.cA(this.i,this._textureResourceUid),this._textureResourceUid=d.InvalidCGAPIResourceUid,this._samplerResourceUid=d.InvalidCGAPIResourceUid,this._recommendedTextureSampler&&this._recommendedTextureSampler.destroy(),this.aI=!1,this.mI=!1}[Symbol.dispose](){n.default.debug("[Symbol.dispose] is called"),this.destroy()}async getCubeFacePixelData(e){if(e<0||e>5)throw new Error(`Invalid face index: ${e}. Must be between 0 and 5.`);return await this.i.cgApiResourceRepository.getCubeTexturePixelData(this._textureResourceUid,this.sm,this.Xx,e)}async getAllCubeFacePixelData(){let[e,t,r,i,s,o]=await Promise.all([this.getCubeFacePixelData(0),this.getCubeFacePixelData(1),this.getCubeFacePixelData(2),this.getCubeFacePixelData(3),this.getCubeFacePixelData(4),this.getCubeFacePixelData(5)]);return{posX:e,negX:t,posY:r,negY:i,posZ:s,negZ:o}}destroy(){this.destroy3DAPIResources(),this.unregister(),u.managedRegistry.unregister(this)}static async loadFromUrl(e,{baseUrl:t,mipmapLevelNumber:r,isNamePosNeg:i,hdriFormat:s}){let o=new u(e);return await o.loadTextureImages({baseUrl:t,mipmapLevelNumber:r,isNamePosNeg:i,hdriFormat:s}),o}};u.managedRegistry=new FinalizationRegistry(e=>{n.default.info(`WebGL/WebGPU cube texture "${e.uniqueName}" was automatically released along with GC. But explicit release is recommended.`),u.cA(e.engine,e.textureResourceUid)});var h=u;export{h as CubeTexture};
1
+ import{HdriFormat as x}from"../definitions/HdriFormat.js";import{ProcessApproach as m}from"../definitions/ProcessApproach.js";import{TextureParameter as p}from"../definitions/TextureParameter.js";import{Logger as n}from"../misc/Logger.js";import{CGAPIResourceRepository as d}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as A}from"./AbstractTexture.js";var u=class u extends A{constructor(){super(...arguments);this.mipmapLevelNumber=1;this.hdriFormat=x.LDR_SRGB}uA(e,t){this._textureResourceUid=e,u.managedRegistry.register(this,{textureResourceUid:e,engine:this.i,uniqueName:t},this)}async loadTextureImages({baseUrl:e,mipmapLevelNumber:t,isNamePosNeg:r,hdriFormat:i}){this.mI=!0,this.mipmapLevelNumber=t,this.hdriFormat=i;let s=this.i.cgApiResourceRepository,[o,c,l,a]=await s.createCubeTextureFromFiles(this.i,e,t,r,i);this.uA(o,this.uniqueName),this._recommendedTextureSampler=c,this._samplerResourceUid=c._samplerResourceUid,this.sm=l,this.TT=a,this.i.engineState.currentProcessApproach===m.WebGPU&&(this._textureViewResourceUid=s.createTextureViewCube(this._textureResourceUid)),this.aI=!0}loadTextureImagesFromBasis(e,{magFilter:t=p.Linear,minFilter:r=p.LinearMipmapLinear,wrapS:i=p.Repeat,wrapT:s=p.Repeat}={}){this.mI=!0,typeof BASIS=="undefined"&&n.default.error("Failed to call BASIS() function. Please check to import basis_transcoder.js."),BASIS().then(o=>{let{initializeBasis:c}=o;c();let l=o.BasisFile,a=new l(e);if(!a.startTranscoding()){n.default.error("failed to start transcoding."),a.close(),a.delete();return}let g=this.i.webglResourceRepository,{resourceHandle:y,width:R,height:b}=g.createCubeTextureFromBasis(a,{magFilter:t,minFilter:r,wrapS:i,wrapT:s});this.uA(y,this.uniqueName),this.sm=R,this.TT=b,this.aI=!0,a.close(),a.delete()})}load1x1Texture(e="rgba(0,0,0,1)"){let t=document.createElement("canvas");t.width=1,t.height=1;let r=t.getContext("2d");if(r==null){n.default.error("Failed to get canvas context.");return}r.fillStyle=e,r.fillRect(0,0,1,1);let i=this.i.cgApiResourceRepository,[s,o]=i.createCubeTexture(this.i,1,[{posX:t,negX:t,posY:t,negY:t,posZ:t,negZ:t}],1,1);this.uA(s,this.uniqueName),this._recommendedTextureSampler=o,this._samplerResourceUid=o._samplerResourceUid,this.sm=1,this.TT=1,this.i.engineState.currentProcessApproach===m.WebGPU&&(this._textureViewResourceUid=i.createTextureViewCube(this._textureResourceUid)),this.aI=!0}generateTextureFromTypedArrays(e,t,r){let i=this.i.webglResourceRepository,[s,o]=i.createCubeTexture(this.i,e.length,e,t,r);this._recommendedTextureSampler=o,this.uA(s,this.uniqueName),this.sm=t,this.TT=r,this.aI=!0,this.mI=!0}importWebGLTextureDirectly(e,t=0,r=0){this.sm=t,this.TT=r;let s=this.i.webglResourceRepository.setWebGLTextureDirectly(e);this.uA(s,this.uniqueName),this.mI=!0,this.aI=!0}static cA(e,t){e.cgApiResourceRepository.deleteTexture(t)}destroy3DAPIResources(){u.cA(this.i,this._textureResourceUid),this._textureResourceUid=d.InvalidCGAPIResourceUid,this._samplerResourceUid=d.InvalidCGAPIResourceUid,this._recommendedTextureSampler&&this._recommendedTextureSampler.destroy(),this.aI=!1,this.mI=!1}[Symbol.dispose](){n.default.debug("[Symbol.dispose] is called"),this.destroy()}async getCubeFacePixelData(e){if(e<0||e>5)throw new Error(`Invalid face index: ${e}. Must be between 0 and 5.`);return await this.i.cgApiResourceRepository.getCubeTexturePixelData(this._textureResourceUid,this.sm,this.TT,e)}async getAllCubeFacePixelData(){let[e,t,r,i,s,o]=await Promise.all([this.getCubeFacePixelData(0),this.getCubeFacePixelData(1),this.getCubeFacePixelData(2),this.getCubeFacePixelData(3),this.getCubeFacePixelData(4),this.getCubeFacePixelData(5)]);return{posX:e,negX:t,posY:r,negY:i,posZ:s,negZ:o}}destroy(){this.destroy3DAPIResources(),this.unregister(),u.managedRegistry.unregister(this)}static async loadFromUrl(e,{baseUrl:t,mipmapLevelNumber:r,isNamePosNeg:i,hdriFormat:s}){let o=new u(e);return await o.loadTextureImages({baseUrl:t,mipmapLevelNumber:r,isNamePosNeg:i,hdriFormat:s}),o}};u.managedRegistry=new FinalizationRegistry(e=>{n.default.info(`WebGL/WebGPU cube texture "${e.uniqueName}" was automatically released along with GC. But explicit release is recommended.`),u.cA(e.engine,e.textureResourceUid)});var h=u;export{h as CubeTexture};
@@ -1 +1 @@
1
- import{ProcessApproach as n}from"../definitions/ProcessApproach.js";import{TextureFormat as h}from"../definitions/TextureFormat.js";import{Vector4 as p}from"../math/Vector4.js";import{CGAPIResourceRepository as d}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as m}from"./AbstractTexture.js";var u=class extends m{create({width:e,height:t,mipLevelCount:i,format:r}){this.sm=e,this.Xx=t,this.uI=i!=null?i:Math.floor(Math.log2(Math.max(e,t)))+1;let{format:s,type:o}=h.getPixelFormatAndComponentTypeFromTextureFormat(r);this.cI=r,this.dI=s,this.Ye=o,this.fA()}set _fbo(e){this.RA=e}get fbo(){return this.RA}fA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTexture({width:this.sm,height:this.Xx,mipLevelCount:this.uI,format:this.cI});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===n.WebGPU&&(this._textureViewResourceUid=e.createTextureView2d(this._textureResourceUid),this._textureViewAsRenderTargetResourceUid=e.createTextureViewAsRenderTarget(this._textureResourceUid))}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.Xx=t,this.fA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=d.InvalidCGAPIResourceUid,!0}async getTexturePixelData(){return this.i.cgApiResourceRepository.getTexturePixelData(this._textureResourceUid,this.sm,this.Xx,this.RA.framebufferUID,this.RA.whichColorAttachment(this))}async downloadTexturePixelData(){let e=await this.getTexturePixelData(),t=document.createElement("canvas");t.width=this.sm,t.height=this.Xx;let i=t.getContext("2d");if(!(e.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported when downloading texture pixel data.");let r=new Uint8ClampedArray(e.buffer,e.byteOffset,e.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),s=new ImageData(r,this.sm,this.Xx);i.putImageData(s,this.sm,this.Xx);let o=t.toDataURL("image/png"),a=document.createElement("a"),c=document.createEvent("MouseEvent");a.href=o,a.download="texture.png",c.initEvent("click",!0,!0),a.dispatchEvent(c)}async getPixelValueAt(e,t,i){let r=i;return r||(r=await this.getTexturePixelData()),p.fromCopyArray([r[(t*this.width+e)*4+0],r[(t*this.width+e)*4+1],r[(t*this.width+e)*4+2],r[(t*this.width+e)*4+3]])}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.width,this.height)}createCubeTextureViewAsRenderTarget(e,t){}};export{u as RenderTargetTexture};
1
+ import{ProcessApproach as n}from"../definitions/ProcessApproach.js";import{TextureFormat as h}from"../definitions/TextureFormat.js";import{Vector4 as p}from"../math/Vector4.js";import{CGAPIResourceRepository as d}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as m}from"./AbstractTexture.js";var u=class extends m{create({width:e,height:t,mipLevelCount:i,format:r}){this.sm=e,this.TT=t,this.uI=i!=null?i:Math.floor(Math.log2(Math.max(e,t)))+1;let{format:s,type:o}=h.getPixelFormatAndComponentTypeFromTextureFormat(r);this.cI=r,this.dI=s,this.Qe=o,this.fA()}set _fbo(e){this.RA=e}get fbo(){return this.RA}fA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTexture({width:this.sm,height:this.TT,mipLevelCount:this.uI,format:this.cI});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===n.WebGPU&&(this._textureViewResourceUid=e.createTextureView2d(this._textureResourceUid),this._textureViewAsRenderTargetResourceUid=e.createTextureViewAsRenderTarget(this._textureResourceUid))}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.TT=t,this.fA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=d.InvalidCGAPIResourceUid,!0}async getTexturePixelData(){return this.i.cgApiResourceRepository.getTexturePixelData(this._textureResourceUid,this.sm,this.TT,this.RA.framebufferUID,this.RA.whichColorAttachment(this))}async downloadTexturePixelData(){let e=await this.getTexturePixelData(),t=document.createElement("canvas");t.width=this.sm,t.height=this.TT;let i=t.getContext("2d");if(!(e.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported when downloading texture pixel data.");let r=new Uint8ClampedArray(e.buffer,e.byteOffset,e.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),s=new ImageData(r,this.sm,this.TT);i.putImageData(s,this.sm,this.TT);let o=t.toDataURL("image/png"),a=document.createElement("a"),c=document.createEvent("MouseEvent");a.href=o,a.download="texture.png",c.initEvent("click",!0,!0),a.dispatchEvent(c)}async getPixelValueAt(e,t,i){let r=i;return r||(r=await this.getTexturePixelData()),p.fromCopyArray([r[(t*this.width+e)*4+0],r[(t*this.width+e)*4+1],r[(t*this.width+e)*4+2],r[(t*this.width+e)*4+3]])}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.width,this.height)}createCubeTextureViewAsRenderTarget(e,t){}};export{u as RenderTargetTexture};
@@ -1 +1 @@
1
- import{ComponentType as h}from"../definitions/ComponentType.js";import{PixelFormat as p}from"../definitions/PixelFormat.js";import{ProcessApproach as c}from"../definitions/ProcessApproach.js";import{TextureFormat as d}from"../definitions/TextureFormat.js";import{Vector4 as R}from"../math/Vector4.js";import{CGAPIResourceRepository as m}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as y}from"./AbstractTexture.js";var n=class extends y{constructor(){super(...arguments);this.Vb=0}create({width:e,height:t,level:i=0,internalFormat:r=d.RGB8,format:s=p.RGBA,type:a=h.UnsignedByte,arrayLength:o}){this.sm=e,this.Xx=t,this.pI=i,this.cI=r,this.dI=s,this.Ye=a,this.Vb=o,this.yA()}set _fbo(e){this.RA=e}get fbo(){return this.RA}get arrayLength(){return this.Vb}yA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTextureArray({width:this.sm,height:this.Xx,level:this.pI,internalFormat:this.cI,format:this.dI,type:this.Ye,arrayLength:this.Vb});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=e.createTextureView2dArray(this._textureResourceUid,this.Vb),this._textureViewAsRenderTargetResourceUid=e.createTextureView2dArrayAsRenderTarget(this._textureResourceUid,0,0))}changeRenderTargetLayerWebGPU(e){if(this.i.engineState.currentProcessApproach===c.WebGPU){let t=this.i.cgApiResourceRepository;this._textureViewAsRenderTargetResourceUid=t.createTextureView2dArrayAsRenderTarget(this._textureResourceUid,e,0)}}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.Xx=t,this.yA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=m.InvalidCGAPIResourceUid,!0}async getTexturePixelData(){return this.i.cgApiResourceRepository.getTexturePixelData(this._textureResourceUid,this.sm,this.Xx,this.RA.framebufferUID,this.RA.whichColorAttachment(this))}async downloadTexturePixelData(){let e=await this.getTexturePixelData(),t=document.createElement("canvas");t.width=this.sm,t.height=this.Xx;let i=t.getContext("2d");if(!(e.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported when downloading texture pixel data.");let r=new Uint8ClampedArray(e.buffer,e.byteOffset,e.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),s=new ImageData(r,this.sm,this.Xx);i.putImageData(s,this.sm,this.Xx);let a=t.toDataURL("image/png"),o=document.createElement("a"),u=document.createEvent("MouseEvent");o.href=a,o.download="texture.png",u.initEvent("click",!0,!0),o.dispatchEvent(u)}async getPixelValueAt(e,t,i){let r=i;return r||(r=await this.getTexturePixelData()),R.fromCopyArray([r[(t*this.width+e)*4+0],r[(t*this.width+e)*4+1],r[(t*this.width+e)*4+2],r[(t*this.width+e)*4+3]])}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.width,this.height)}blitToTexture2dFromTexture2dArray(e){if(this.Vb===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArray(this._textureResourceUid,e.RA.cgApiResourceUid,e.width,e.height)}blitToTexture2dFromTexture2dArrayFake(e){if(this.Vb===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArrayFake(this._textureResourceUid,e.RA.cgApiResourceUid,e.width,e.height)}blitToTexture2dFromTexture2dArray2(e){if(this.Vb===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArray2(this._textureResourceUid,e._textureResourceUid,e.width/2,e.height)}createCubeTextureViewAsRenderTarget(e,t){}};export{n as RenderTargetTexture2DArray};
1
+ import{ComponentType as h}from"../definitions/ComponentType.js";import{PixelFormat as p}from"../definitions/PixelFormat.js";import{ProcessApproach as c}from"../definitions/ProcessApproach.js";import{TextureFormat as d}from"../definitions/TextureFormat.js";import{Vector4 as R}from"../math/Vector4.js";import{CGAPIResourceRepository as m}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as y}from"./AbstractTexture.js";var n=class extends y{constructor(){super(...arguments);this.Ib=0}create({width:e,height:t,level:i=0,internalFormat:r=d.RGB8,format:s=p.RGBA,type:a=h.UnsignedByte,arrayLength:o}){this.sm=e,this.TT=t,this.pI=i,this.cI=r,this.dI=s,this.Qe=a,this.Ib=o,this.yA()}set _fbo(e){this.RA=e}get fbo(){return this.RA}get arrayLength(){return this.Ib}yA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTextureArray({width:this.sm,height:this.TT,level:this.pI,internalFormat:this.cI,format:this.dI,type:this.Qe,arrayLength:this.Ib});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=e.createTextureView2dArray(this._textureResourceUid,this.Ib),this._textureViewAsRenderTargetResourceUid=e.createTextureView2dArrayAsRenderTarget(this._textureResourceUid,0,0))}changeRenderTargetLayerWebGPU(e){if(this.i.engineState.currentProcessApproach===c.WebGPU){let t=this.i.cgApiResourceRepository;this._textureViewAsRenderTargetResourceUid=t.createTextureView2dArrayAsRenderTarget(this._textureResourceUid,e,0)}}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.TT=t,this.yA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=m.InvalidCGAPIResourceUid,!0}async getTexturePixelData(){return this.i.cgApiResourceRepository.getTexturePixelData(this._textureResourceUid,this.sm,this.TT,this.RA.framebufferUID,this.RA.whichColorAttachment(this))}async downloadTexturePixelData(){let e=await this.getTexturePixelData(),t=document.createElement("canvas");t.width=this.sm,t.height=this.TT;let i=t.getContext("2d");if(!(e.buffer instanceof ArrayBuffer))throw new Error("SharedArrayBuffer is not supported when downloading texture pixel data.");let r=new Uint8ClampedArray(e.buffer,e.byteOffset,e.byteLength/Uint8ClampedArray.BYTES_PER_ELEMENT),s=new ImageData(r,this.sm,this.TT);i.putImageData(s,this.sm,this.TT);let a=t.toDataURL("image/png"),o=document.createElement("a"),u=document.createEvent("MouseEvent");o.href=a,o.download="texture.png",u.initEvent("click",!0,!0),o.dispatchEvent(u)}async getPixelValueAt(e,t,i){let r=i;return r||(r=await this.getTexturePixelData()),R.fromCopyArray([r[(t*this.width+e)*4+0],r[(t*this.width+e)*4+1],r[(t*this.width+e)*4+2],r[(t*this.width+e)*4+3]])}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.width,this.height)}blitToTexture2dFromTexture2dArray(e){if(this.Ib===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArray(this._textureResourceUid,e.RA.cgApiResourceUid,e.width,e.height)}blitToTexture2dFromTexture2dArrayFake(e){if(this.Ib===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArrayFake(this._textureResourceUid,e.RA.cgApiResourceUid,e.width,e.height)}blitToTexture2dFromTexture2dArray2(e){if(this.Ib===0)return;this.i.webglResourceRepository.blitToTexture2dFromTexture2dArray2(this._textureResourceUid,e._textureResourceUid,e.width/2,e.height)}createCubeTextureViewAsRenderTarget(e,t){}};export{n as RenderTargetTexture2DArray};
@@ -1 +1 @@
1
- import{HdriFormat as c}from"../definitions/HdriFormat.js";import{ProcessApproach as i}from"../definitions/ProcessApproach.js";import{TextureFormat as R}from"../definitions/TextureFormat.js";import{CGAPIResourceRepository as a}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as h}from"./AbstractTexture.js";var o=class extends h{constructor(){super(...arguments);this.hdriFormat=c.HDR_LINEAR;this._textureViewAsRenderTargetResourceUid=-1}create({width:e,height:t,mipLevelCount:r,format:s}){this.sm=e,this.Xx=t,this.uI=r!=null?r:Math.floor(Math.log2(Math.max(e,t)))+1;let{format:u,type:p}=R.getPixelFormatAndComponentTypeFromTextureFormat(s);this.cI=s,this.dI=u,this.Ye=p,this.fA()}fA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTextureCube({width:this.sm,height:this.Xx,mipLevelCount:this.uI,format:this.cI});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===i.WebGPU&&(this._textureViewResourceUid=e.createTextureViewCube(this._textureResourceUid),this._textureViewAsRenderTargetResourceUid=e.createCubeTextureViewAsRenderTarget(this._textureResourceUid,0,0))}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmapsCube(this._textureResourceUid,this.width,this.height)}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.Xx=t,this.fA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=a.InvalidCGAPIResourceUid,!0}createCubeTextureViewAsRenderTarget(e,t){if(this.i.engineState.currentProcessApproach===i.WebGPU){let r=this.i.webGpuResourceRepository;this._textureViewAsRenderTargetResourceUid=r.createCubeTextureViewAsRenderTarget(this._textureResourceUid,e,t)}}set _fbo(e){this.RA=e}get fbo(){return this.RA}get mipmapLevelNumber(){return this.uI}setIsTextureReady(){this.aI=!0}};export{o as RenderTargetTextureCube};
1
+ import{HdriFormat as c}from"../definitions/HdriFormat.js";import{ProcessApproach as i}from"../definitions/ProcessApproach.js";import{TextureFormat as R}from"../definitions/TextureFormat.js";import{CGAPIResourceRepository as a}from"../renderer/CGAPIResourceRepository.js";import{AbstractTexture as h}from"./AbstractTexture.js";var o=class extends h{constructor(){super(...arguments);this.hdriFormat=c.HDR_LINEAR;this._textureViewAsRenderTargetResourceUid=-1}create({width:e,height:t,mipLevelCount:r,format:s}){this.sm=e,this.TT=t,this.uI=r!=null?r:Math.floor(Math.log2(Math.max(e,t)))+1;let{format:u,type:p}=R.getPixelFormatAndComponentTypeFromTextureFormat(s);this.cI=s,this.dI=u,this.Qe=p,this.fA()}fA(){let e=this.i.cgApiResourceRepository,t=e.createRenderTargetTextureCube({width:this.sm,height:this.TT,mipLevelCount:this.uI,format:this.cI});this._textureResourceUid=t,this.i.engineState.currentProcessApproach===i.WebGPU&&(this._textureViewResourceUid=e.createTextureViewCube(this._textureResourceUid),this._textureViewAsRenderTargetResourceUid=e.createCubeTextureViewAsRenderTarget(this._textureResourceUid,0,0))}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmapsCube(this._textureResourceUid,this.width,this.height)}resize(e,t){this.destroy3DAPIResources(),this.sm=e,this.TT=t,this.fA()}destroy3DAPIResources(){return this.i.cgApiResourceRepository.deleteTexture(this._textureResourceUid),this._textureResourceUid=a.InvalidCGAPIResourceUid,!0}createCubeTextureViewAsRenderTarget(e,t){if(this.i.engineState.currentProcessApproach===i.WebGPU){let r=this.i.webGpuResourceRepository;this._textureViewAsRenderTargetResourceUid=r.createCubeTextureViewAsRenderTarget(this._textureResourceUid,e,t)}}set _fbo(e){this.RA=e}get fbo(){return this.RA}get mipmapLevelNumber(){return this.uI}setIsTextureReady(){this.aI=!0}};export{o as RenderTargetTextureCube};
@@ -1 +1 @@
1
- import{ComponentType as m}from"../definitions/ComponentType.js";import{PixelFormat as h}from"../definitions/PixelFormat.js";import{ProcessApproach as c}from"../definitions/ProcessApproach.js";import{TextureFormat as l}from"../definitions/TextureFormat.js";import{DataUtil as x}from"../misc/DataUtil.js";import{Logger as d}from"../misc/Logger.js";import{CGAPIResourceRepository as y}from"../renderer/CGAPIResourceRepository.js";import{ModuleManager as T}from"../system/ModuleManager.js";import{AbstractTexture as A}from"./AbstractTexture.js";var a=class a extends A{constructor(){super(...arguments);this.autoDetectTransparency=!1}uA(e,t){this._textureResourceUid=e,a.managedRegistry.register(this,{textureResourceUid:e,engine:this.i,uniqueName:t},this)}async generateTextureFromBasis(e,t){var r;this.mI=!0,typeof BASIS=="undefined"&&d.default.error("Failed to call BASIS() function. Please check to import basis_transcoder.js."),a.AA?a.gA?this.TA(e,t):(r=a.lA)==null||r.then(()=>{this.TA(e,t)}):(a.AA=!0,a.lA=new Promise(i=>{BASIS().then(s=>{let{initializeBasis:n}=s;n(),a.gA=s.BasisFile,this.TA(e,t),i()})})),await a.lA}TA(e,{_level:t=0,_internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,_generateMipmap:n=!0}={}){this.mI=!0;let o=new a.gA(e);if(!o.startTranscoding()){d.default.error("failed to start transcoding."),o.close(),o.delete();return}let u=this.i.cgApiResourceRepository.createCompressedTextureFromBasis(o,{border:0,format:i,type:s});this.uA(u,this.uniqueName),this.aI=!0,o.close(),o.delete()}async generateTextureFromKTX2(e){this.mI=!0;let{KTX2TextureLoader:t}=await import("../../webgl/textureLoader/KTX2TextureLoader.js"),r=await t.getInstance().transcode(this.i,e);this.sm=r.width,this.Xx=r.height,await this.generateCompressedTextureWithMipmapFromTypedArray(r.mipmapData,r.compressionTextureType)}async generateTextureFromImage(e,{level:t=0,internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,generateMipmap:n=!0}={}){this.mI=!0,this.eI=e;let o=e;this.autoDetectTransparency&&(this.nI=x.detectTransparentPixelExistence(o)),this.sm=o.width,this.Xx=o.height;let p=this.i.cgApiResourceRepository,u;if(o instanceof HTMLImageElement)u=await p.createTextureFromHTMLImageElement(o,{level:t,internalFormat:r,width:this.sm,height:this.Xx,border:0,format:i,type:s,generateMipmap:n});else throw new Error("Unsupported image type.");this.uA(u,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=p.createTextureView2d(this._textureResourceUid)),this.aI=!0,this.hI=e.src}async generateTextureFromUrl(e,{level:t=0,internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,generateMipmap:n=!0}={}){return this.hI=e,this.mI=!0,new Promise((o,p)=>{this.lI=new Image,e.match(/^data:/)||(this.lI.crossOrigin="Anonymous"),this.lI.onload=()=>{this.eI=this.lI;let u=this.lI;this.autoDetectTransparency&&(this.nI=x.detectTransparentPixelExistence(u)),this.sm=u.width,this.Xx=u.height;let R=this.i.cgApiResourceRepository,g=y.InvalidCGAPIResourceUid;(async()=>{if(u instanceof HTMLImageElement)g=await R.createTextureFromHTMLImageElement(u,{level:t,internalFormat:r,width:this.sm,height:this.Xx,border:0,format:i,type:s,generateMipmap:n});else throw new Error("Unsupported image type");this.uA(g,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=R.createTextureView2d(this._textureResourceUid)),this.aI=!0,o()})()},this.lI.src=e})}async generate1x1TextureFrom(e="rgba(255,255,255,1)"){let t=document.createElement("canvas");t.width=1,t.height=1,this.sm=1,this.Xx=1;let r=t.getContext("2d");if(r==null){d.default.error("Failed to get canvas context.");return}r.fillStyle=e,r.fillRect(0,0,1,1);let i=this.i.cgApiResourceRepository,s=await i.createTextureFromImageBitmapData(t,{level:0,internalFormat:l.RGBA8,width:1,height:1,border:0,format:h.RGBA,type:m.UnsignedByte,generateMipmap:!1});this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}async generateSheenLutTextureFromDataUri(){this.aI||(this.xA==null&&(this.xA=this.wA()),await this.xA)}async wA(){let r=await T.getInstance().loadModule("pbr"),i=this.i.cgApiResourceRepository;if(i==null){d.default.error("Failed to get CGAPIResourceRepository.");return}let s=await i.createTextureFromDataUri(r.sheen_E_and_DGTerm,{level:0,internalFormat:l.RGBA8,border:0,format:h.RGBA,type:m.UnsignedByte,generateMipmap:!1});this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}allocate(e){var i;let t=this.i.cgApiResourceRepository;e.mipLevelCount=(i=e.mipLevelCount)!=null?i:Math.floor(Math.log2(Math.max(e.width,e.height)))+1;let r=t.allocateTexture({mipLevelCount:e.mipLevelCount,width:e.width,height:e.height,format:e.format});this.uA(r,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=t.createTextureView2d(this._textureResourceUid)),this.sm=e.width,this.Xx=e.height,this.uI=e.mipLevelCount,this.cI=e.format}async loadImageToMipLevel(e){await this.i.cgApiResourceRepository.loadImageToMipLevelOfTexture2D({mipLevel:e.mipLevel,textureUid:this._textureResourceUid,format:this.cI,type:e.type,xOffset:e.xOffset,yOffset:e.yOffset,width:e.width,height:e.height,rowSizeByPixel:e.rowSizeByPixel,data:e.data}),e.mipLevel===0&&(this.aI=!0)}async generateCompressedTextureFromTypedArray(e,t,r,i){this.sm=t,this.Xx=r;let s={level:0,width:t,height:r,buffer:e},n=this.i.cgApiResourceRepository,o=await n.createCompressedTexture([s],i);this.uA(o,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=n.createTextureView2d(this._textureResourceUid)),this.aI=!0}async generateCompressedTextureWithMipmapFromTypedArray(e,t){let r=e.find(n=>n.level===0);if(r==null)throw new Error("texture data with level 0 is not found");this.sm=r.width,this.Xx=r.height;let i=this.i.cgApiResourceRepository,s=await i.createCompressedTexture(e,t);this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.sm,this.Xx)}importWebGLTextureDirectly(e,t=0,r=0){this.sm=t,this.Xx=r;let s=this.i.webglResourceRepository.setWebGLTextureDirectly(e);this.uA(s,this.uniqueName),this.mI=!0,this.aI=!0}destroy3DAPIResources(){return a.cA(this.i,this._textureResourceUid),this._textureResourceUid=y.InvalidCGAPIResourceUid,this._samplerResourceUid=y.InvalidCGAPIResourceUid,this._recommendedTextureSampler&&this._recommendedTextureSampler.destroy(),this.aI=!1,this.mI=!1,!0}static cA(e,t){e.cgApiResourceRepository.deleteTexture(t)}[Symbol.dispose](){d.default.debug("[Symbol.dispose] is called"),this.destroy()}destroy(){this.destroy3DAPIResources(),this.unregister(),a.managedRegistry.unregister(this)}static async loadFromUrl(e,t,{level:r=0,internalFormat:i=l.RGBA8,format:s=h.RGBA,type:n=m.UnsignedByte,generateMipmap:o=!0}={}){let p=new a(e);return await p.generateTextureFromUrl(t,{level:r,internalFormat:i,format:s,type:n,generateMipmap:o}),p}};a.AA=!1,a.managedRegistry=new FinalizationRegistry(e=>{d.default.info(`WebGL/WebGPU 2D texture "${e.uniqueName}" was automatically released along with GC. But explicit release is recommended.`),a.cA(e.engine,e.textureResourceUid)});var f=a;export{f as Texture};
1
+ import{ComponentType as m}from"../definitions/ComponentType.js";import{PixelFormat as h}from"../definitions/PixelFormat.js";import{ProcessApproach as c}from"../definitions/ProcessApproach.js";import{TextureFormat as l}from"../definitions/TextureFormat.js";import{DataUtil as x}from"../misc/DataUtil.js";import{Logger as d}from"../misc/Logger.js";import{CGAPIResourceRepository as y}from"../renderer/CGAPIResourceRepository.js";import{ModuleManager as T}from"../system/ModuleManager.js";import{AbstractTexture as A}from"./AbstractTexture.js";var a=class a extends A{constructor(){super(...arguments);this.autoDetectTransparency=!1}uA(e,t){this._textureResourceUid=e,a.managedRegistry.register(this,{textureResourceUid:e,engine:this.i,uniqueName:t},this)}async generateTextureFromBasis(e,t){var r;this.mI=!0,typeof BASIS=="undefined"&&d.default.error("Failed to call BASIS() function. Please check to import basis_transcoder.js."),a.AA?a.gA?this.TA(e,t):(r=a.lA)==null||r.then(()=>{this.TA(e,t)}):(a.AA=!0,a.lA=new Promise(i=>{BASIS().then(s=>{let{initializeBasis:n}=s;n(),a.gA=s.BasisFile,this.TA(e,t),i()})})),await a.lA}TA(e,{_level:t=0,_internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,_generateMipmap:n=!0}={}){this.mI=!0;let o=new a.gA(e);if(!o.startTranscoding()){d.default.error("failed to start transcoding."),o.close(),o.delete();return}let u=this.i.cgApiResourceRepository.createCompressedTextureFromBasis(o,{border:0,format:i,type:s});this.uA(u,this.uniqueName),this.aI=!0,o.close(),o.delete()}async generateTextureFromKTX2(e){this.mI=!0;let{KTX2TextureLoader:t}=await import("../../webgl/textureLoader/KTX2TextureLoader.js"),r=await t.getInstance().transcode(this.i,e);this.sm=r.width,this.TT=r.height,await this.generateCompressedTextureWithMipmapFromTypedArray(r.mipmapData,r.compressionTextureType)}async generateTextureFromImage(e,{level:t=0,internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,generateMipmap:n=!0}={}){this.mI=!0,this.eI=e;let o=e;this.autoDetectTransparency&&(this.nI=x.detectTransparentPixelExistence(o)),this.sm=o.width,this.TT=o.height;let p=this.i.cgApiResourceRepository,u;if(o instanceof HTMLImageElement)u=await p.createTextureFromHTMLImageElement(o,{level:t,internalFormat:r,width:this.sm,height:this.TT,border:0,format:i,type:s,generateMipmap:n});else throw new Error("Unsupported image type.");this.uA(u,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=p.createTextureView2d(this._textureResourceUid)),this.aI=!0,this.hI=e.src}async generateTextureFromUrl(e,{level:t=0,internalFormat:r=l.RGBA8,format:i=h.RGBA,type:s=m.UnsignedByte,generateMipmap:n=!0}={}){return this.hI=e,this.mI=!0,new Promise((o,p)=>{this.lI=new Image,e.match(/^data:/)||(this.lI.crossOrigin="Anonymous"),this.lI.onload=()=>{this.eI=this.lI;let u=this.lI;this.autoDetectTransparency&&(this.nI=x.detectTransparentPixelExistence(u)),this.sm=u.width,this.TT=u.height;let R=this.i.cgApiResourceRepository,g=y.InvalidCGAPIResourceUid;(async()=>{if(u instanceof HTMLImageElement)g=await R.createTextureFromHTMLImageElement(u,{level:t,internalFormat:r,width:this.sm,height:this.TT,border:0,format:i,type:s,generateMipmap:n});else throw new Error("Unsupported image type");this.uA(g,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=R.createTextureView2d(this._textureResourceUid)),this.aI=!0,o()})()},this.lI.src=e})}async generate1x1TextureFrom(e="rgba(255,255,255,1)"){let t=document.createElement("canvas");t.width=1,t.height=1,this.sm=1,this.TT=1;let r=t.getContext("2d");if(r==null){d.default.error("Failed to get canvas context.");return}r.fillStyle=e,r.fillRect(0,0,1,1);let i=this.i.cgApiResourceRepository,s=await i.createTextureFromImageBitmapData(t,{level:0,internalFormat:l.RGBA8,width:1,height:1,border:0,format:h.RGBA,type:m.UnsignedByte,generateMipmap:!1});this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}async generateSheenLutTextureFromDataUri(){this.aI||(this.xA==null&&(this.xA=this.wA()),await this.xA)}async wA(){let r=await T.getInstance().loadModule("pbr"),i=this.i.cgApiResourceRepository;if(i==null){d.default.error("Failed to get CGAPIResourceRepository.");return}let s=await i.createTextureFromDataUri(r.sheen_E_and_DGTerm,{level:0,internalFormat:l.RGBA8,border:0,format:h.RGBA,type:m.UnsignedByte,generateMipmap:!1});this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}allocate(e){var i;let t=this.i.cgApiResourceRepository;e.mipLevelCount=(i=e.mipLevelCount)!=null?i:Math.floor(Math.log2(Math.max(e.width,e.height)))+1;let r=t.allocateTexture({mipLevelCount:e.mipLevelCount,width:e.width,height:e.height,format:e.format});this.uA(r,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=t.createTextureView2d(this._textureResourceUid)),this.sm=e.width,this.TT=e.height,this.uI=e.mipLevelCount,this.cI=e.format}async loadImageToMipLevel(e){await this.i.cgApiResourceRepository.loadImageToMipLevelOfTexture2D({mipLevel:e.mipLevel,textureUid:this._textureResourceUid,format:this.cI,type:e.type,xOffset:e.xOffset,yOffset:e.yOffset,width:e.width,height:e.height,rowSizeByPixel:e.rowSizeByPixel,data:e.data}),e.mipLevel===0&&(this.aI=!0)}async generateCompressedTextureFromTypedArray(e,t,r,i){this.sm=t,this.TT=r;let s={level:0,width:t,height:r,buffer:e},n=this.i.cgApiResourceRepository,o=await n.createCompressedTexture([s],i);this.uA(o,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=n.createTextureView2d(this._textureResourceUid)),this.aI=!0}async generateCompressedTextureWithMipmapFromTypedArray(e,t){let r=e.find(n=>n.level===0);if(r==null)throw new Error("texture data with level 0 is not found");this.sm=r.width,this.TT=r.height;let i=this.i.cgApiResourceRepository,s=await i.createCompressedTexture(e,t);this.uA(s,this.uniqueName),this.i.engineState.currentProcessApproach===c.WebGPU&&(this._textureViewResourceUid=i.createTextureView2d(this._textureResourceUid)),this.aI=!0}generateMipmaps(){this.i.cgApiResourceRepository.generateMipmaps2d(this._textureResourceUid,this.sm,this.TT)}importWebGLTextureDirectly(e,t=0,r=0){this.sm=t,this.TT=r;let s=this.i.webglResourceRepository.setWebGLTextureDirectly(e);this.uA(s,this.uniqueName),this.mI=!0,this.aI=!0}destroy3DAPIResources(){return a.cA(this.i,this._textureResourceUid),this._textureResourceUid=y.InvalidCGAPIResourceUid,this._samplerResourceUid=y.InvalidCGAPIResourceUid,this._recommendedTextureSampler&&this._recommendedTextureSampler.destroy(),this.aI=!1,this.mI=!1,!0}static cA(e,t){e.cgApiResourceRepository.deleteTexture(t)}[Symbol.dispose](){d.default.debug("[Symbol.dispose] is called"),this.destroy()}destroy(){this.destroy3DAPIResources(),this.unregister(),a.managedRegistry.unregister(this)}static async loadFromUrl(e,t,{level:r=0,internalFormat:i=l.RGBA8,format:s=h.RGBA,type:n=m.UnsignedByte,generateMipmap:o=!0}={}){let p=new a(e);return await p.generateTextureFromUrl(t,{level:r,internalFormat:i,format:s,type:n,generateMipmap:o}),p}};a.AA=!1,a.managedRegistry=new FinalizationRegistry(e=>{d.default.info(`WebGL/WebGPU 2D texture "${e.uniqueName}" was automatically released along with GC. But explicit release is recommended.`),a.cA(e.engine,e.textureResourceUid)});var f=a;export{f as Texture};
@@ -1 +1 @@
1
- var m=class l{constructor(t,e,r){this.IA=r,this.sm=t,this.Xx=e,this.CA=new Float32Array(t*e*r)}resize(t,e,r){this.sm=t,this.Xx=e,this.IA=r,this.CA=new Float32Array(l.transfer(this.CA.buffer,t*e*r*4))}setPixelAtChannel(t,e,r,i){this.CA[e*this.sm*this.IA+t*this.IA+r]=i}get width(){return this.sm}get height(){return this.Xx}get data(){return this.CA}getPixel(t,e,r){return this.CA[e*this.sm*this.IA+t*this.IA+r]}getPixelAs(t,e,r,i){if(r===3)return new i(new Float32Array([this.CA[e*this.sm*this.IA+t*this.IA+0],this.CA[e*this.sm*this.IA+t*this.IA+1],this.CA[e*this.sm*this.IA+t*this.IA+2]]));if(r===4)return new i(new Float32Array([this.CA[e*this.sm*this.IA+t*this.IA+0],this.CA[e*this.sm*this.IA+t*this.IA+1],this.CA[e*this.sm*this.IA+t*this.IA+2],this.CA[e*this.sm*this.IA+t*this.IA+3]]))}getPixelAsArray(t,e){let r=[];for(let i=0;i<this.IA;i++)r.push(this.CA[e*this.sm*this.IA+t*this.IA+i]);return r}initialize(t,e,r){this.sm=t,this.Xx=e,this.IA=r,this.CA=new Float32Array(t*e*r)}static transfer(t,e){t=Object(t);let r=new ArrayBuffer(e);if(!(t instanceof ArrayBuffer)||!(r instanceof ArrayBuffer))throw new TypeError("Source and destination must be ArrayBuffer instances");if(r.byteLength>=t.byteLength){let n=0,a=t.byteLength;[8,4,2,1].forEach(h=>{if(a>=h){let o=i(h,t,r,n,a);n=o.nextOffset,a=o.leftBytes}})}return r;function i(n,a,y,h,o){let s=Uint8Array;switch(n){case 8:s=Float64Array;break;case 4:s=Float32Array;break;case 2:s=Uint16Array;break;case 1:s=Uint8Array;break;default:s=Uint8Array;break}let f=new s(a,h,Math.trunc(o/n)),u=new s(y,h,Math.trunc(o/n));for(let b=0;b<u.length;b++)u[b]=f[b];return{nextOffset:f.byteOffset+f.byteLength,leftBytes:a.byteLength-(f.byteOffset+f.byteLength)}}}};export{m as TextureDataFloat};
1
+ var m=class l{constructor(t,e,r){this.IA=r,this.sm=t,this.TT=e,this.CA=new Float32Array(t*e*r)}resize(t,e,r){this.sm=t,this.TT=e,this.IA=r,this.CA=new Float32Array(l.transfer(this.CA.buffer,t*e*r*4))}setPixelAtChannel(t,e,r,i){this.CA[e*this.sm*this.IA+t*this.IA+r]=i}get width(){return this.sm}get height(){return this.TT}get data(){return this.CA}getPixel(t,e,r){return this.CA[e*this.sm*this.IA+t*this.IA+r]}getPixelAs(t,e,r,i){if(r===3)return new i(new Float32Array([this.CA[e*this.sm*this.IA+t*this.IA+0],this.CA[e*this.sm*this.IA+t*this.IA+1],this.CA[e*this.sm*this.IA+t*this.IA+2]]));if(r===4)return new i(new Float32Array([this.CA[e*this.sm*this.IA+t*this.IA+0],this.CA[e*this.sm*this.IA+t*this.IA+1],this.CA[e*this.sm*this.IA+t*this.IA+2],this.CA[e*this.sm*this.IA+t*this.IA+3]]))}getPixelAsArray(t,e){let r=[];for(let i=0;i<this.IA;i++)r.push(this.CA[e*this.sm*this.IA+t*this.IA+i]);return r}initialize(t,e,r){this.sm=t,this.TT=e,this.IA=r,this.CA=new Float32Array(t*e*r)}static transfer(t,e){t=Object(t);let r=new ArrayBuffer(e);if(!(t instanceof ArrayBuffer)||!(r instanceof ArrayBuffer))throw new TypeError("Source and destination must be ArrayBuffer instances");if(r.byteLength>=t.byteLength){let n=0,a=t.byteLength;[8,4,2,1].forEach(h=>{if(a>=h){let o=i(h,t,r,n,a);n=o.nextOffset,a=o.leftBytes}})}return r;function i(n,a,y,h,o){let s=Uint8Array;switch(n){case 8:s=Float64Array;break;case 4:s=Float32Array;break;case 2:s=Uint16Array;break;case 1:s=Uint8Array;break;default:s=Uint8Array;break}let f=new s(a,h,Math.trunc(o/n)),u=new s(y,h,Math.trunc(o/n));for(let b=0;b<u.length;b++)u[b]=f[b];return{nextOffset:f.byteOffset+f.byteLength,leftBytes:a.byteLength-(f.byteOffset+f.byteLength)}}}};export{m as TextureDataFloat};