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
@@ -1 +1 @@
1
- var w=t=>{throw TypeError(t)};var E=(t,i,e)=>i.has(t)||w("Cannot "+e);var m=(t,i,e)=>(E(t,i,"read from private field"),e?e.call(t):i.get(t)),b=(t,i,e)=>i.has(t)?w("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,e),f=(t,i,e,o)=>(E(t,i,"write to private field"),o?o.call(t,e):i.set(t,e),e);import{ComponentType as x}from"../definitions/ComponentType.js";import{PixelFormat as R}from"../definitions/PixelFormat.js";import{TextureFormat as P}from"../definitions/TextureFormat.js";import{DataUtil as v}from"../misc/DataUtil.js";import{AbstractTexture as L}from"./AbstractTexture.js";var s,T=class extends L{constructor(){super(...arguments);this.autoResize=!0;this.autoDetectTransparency=!1;b(this,s)}Rw(e,o){let u=document.createElement("canvas"),h=v.getNearestPowerOfTwo(e.width),p=v.getNearestPowerOfTwo(e.height),c=p/h,n=0,a=0;h>p?(n=Math.min(h,o),a=n*c):(a=Math.min(p,o),n=a/c),u.width=n,u.height=a;let y=u.getContext("2d");if(y.drawImage(e,0,0,e.width,e.height,0,0,n,a),this.autoDetectTransparency){this.xw=y.getImageData(0,0,n,a);for(let d=0;d<a;d++)for(let l=0;l<n;l++)if(this.xw.data[(l+d*n)*4+3]<1)return this.nI=!0,u;this.nI=!1}return u}async generateTextureFromVideo(e,{_level:o=0,internalFormat:u=P.RGBA8,format:h=R.RGBA,type:p=x.UnsignedByte,generateMipmap:c=!1,mutedAutoPlay:n=!0}={}){this.mI=!0,f(this,s,e),n&&(e.autoplay=!0,e.muted=!0);let a=e;this.sm=a.videoWidth,this.Xx=a.videoHeight;let d=await this.i.webglResourceRepository.createTextureFromImageBitmapData(a,{internalFormat:u,width:this.sm,height:this.Xx,format:h,type:p,generateMipmap:c});this._textureResourceUid=d,this.aI=!0,this.hI=e.src}async generateTextureFromUri(e,{_level:o=0,internalFormat:u=P.RGBA8,format:h=R.RGBA,type:p=x.UnsignedByte,generateMipmap:c=!1,mutedAutoPlay:n=!0,playButtonDomElement:a=void 0}={}){return this.hI=e,this.mI=!0,new Promise((y,d)=>{let l=a,g=async()=>{this.sm=r.videoWidth,this.Xx=r.videoHeight;let F=await this.i.webglResourceRepository.createTextureFromImageBitmapData(r,{internalFormat:u,width:this.sm,height:this.Xx,format:h,type:p,generateMipmap:c});this._textureResourceUid=F,this.aI=!0,y()};l==null||l.addEventListener("click",()=>{g(),r.play()},!0);let r=document.createElement("video");r.crossOrigin="anonymous",r.setAttribute("playsinline","playsinline"),n&&(r.autoplay=!0,r.muted=!0),r.preload="auto",f(this,s,r),r.addEventListener("canplaythrough",()=>{g(),r.play()},!0),r.addEventListener("ended",()=>{r.play()},!0),r.src=e})}updateTexture(){let e=this.i.webglResourceRepository;this.aI&&m(this,s)&&e.updateTexture(this._textureResourceUid,m(this,s),{level:0,offsetX:0,offsetY:0,width:this.sm,height:this.Xx,format:R.RGBA,type:x.UnsignedByte})}getCurrentFramePixelData(){let e,o=this.i.webglResourceRepository;return this.aI&&m(this,s)&&(e=o.getPixelDataFromTexture(this._textureResourceUid,0,0,this.width,this.height)),[e,this.width,this.height]}set playbackRate(e){m(this,s)&&(m(this,s).playbackRate=e)}get playbackRate(){var o;let e=(o=m(this,s))==null?void 0:o.playbackRate;return e!=null?e:1}play(){var e;(e=m(this,s))==null||e.play()}pause(){m(this,s).pause()}};s=new WeakMap,T.AA=!1;export{T as VideoTexture};
1
+ var w=t=>{throw TypeError(t)};var E=(t,i,e)=>i.has(t)||w("Cannot "+e);var m=(t,i,e)=>(E(t,i,"read from private field"),e?e.call(t):i.get(t)),b=(t,i,e)=>i.has(t)?w("Cannot add the same private member more than once"):i instanceof WeakSet?i.add(t):i.set(t,e),f=(t,i,e,o)=>(E(t,i,"write to private field"),o?o.call(t,e):i.set(t,e),e);import{ComponentType as x}from"../definitions/ComponentType.js";import{PixelFormat as R}from"../definitions/PixelFormat.js";import{TextureFormat as P}from"../definitions/TextureFormat.js";import{DataUtil as v}from"../misc/DataUtil.js";import{AbstractTexture as L}from"./AbstractTexture.js";var s,T=class extends L{constructor(){super(...arguments);this.autoResize=!0;this.autoDetectTransparency=!1;b(this,s)}Rw(e,o){let u=document.createElement("canvas"),h=v.getNearestPowerOfTwo(e.width),p=v.getNearestPowerOfTwo(e.height),c=p/h,n=0,a=0;h>p?(n=Math.min(h,o),a=n*c):(a=Math.min(p,o),n=a/c),u.width=n,u.height=a;let y=u.getContext("2d");if(y.drawImage(e,0,0,e.width,e.height,0,0,n,a),this.autoDetectTransparency){this.xw=y.getImageData(0,0,n,a);for(let d=0;d<a;d++)for(let l=0;l<n;l++)if(this.xw.data[(l+d*n)*4+3]<1)return this.nI=!0,u;this.nI=!1}return u}async generateTextureFromVideo(e,{_level:o=0,internalFormat:u=P.RGBA8,format:h=R.RGBA,type:p=x.UnsignedByte,generateMipmap:c=!1,mutedAutoPlay:n=!0}={}){this.mI=!0,f(this,s,e),n&&(e.autoplay=!0,e.muted=!0);let a=e;this.sm=a.videoWidth,this.TT=a.videoHeight;let d=await this.i.webglResourceRepository.createTextureFromImageBitmapData(a,{internalFormat:u,width:this.sm,height:this.TT,format:h,type:p,generateMipmap:c});this._textureResourceUid=d,this.aI=!0,this.hI=e.src}async generateTextureFromUri(e,{_level:o=0,internalFormat:u=P.RGBA8,format:h=R.RGBA,type:p=x.UnsignedByte,generateMipmap:c=!1,mutedAutoPlay:n=!0,playButtonDomElement:a=void 0}={}){return this.hI=e,this.mI=!0,new Promise((y,d)=>{let l=a,g=async()=>{this.sm=r.videoWidth,this.TT=r.videoHeight;let F=await this.i.webglResourceRepository.createTextureFromImageBitmapData(r,{internalFormat:u,width:this.sm,height:this.TT,format:h,type:p,generateMipmap:c});this._textureResourceUid=F,this.aI=!0,y()};l==null||l.addEventListener("click",()=>{g(),r.play()},!0);let r=document.createElement("video");r.crossOrigin="anonymous",r.setAttribute("playsinline","playsinline"),n&&(r.autoplay=!0,r.muted=!0),r.preload="auto",f(this,s,r),r.addEventListener("canplaythrough",()=>{g(),r.play()},!0),r.addEventListener("ended",()=>{r.play()},!0),r.src=e})}updateTexture(){let e=this.i.webglResourceRepository;this.aI&&m(this,s)&&e.updateTexture(this._textureResourceUid,m(this,s),{level:0,offsetX:0,offsetY:0,width:this.sm,height:this.TT,format:R.RGBA,type:x.UnsignedByte})}getCurrentFramePixelData(){let e,o=this.i.webglResourceRepository;return this.aI&&m(this,s)&&(e=o.getPixelDataFromTexture(this._textureResourceUid,0,0,this.width,this.height)),[e,this.width,this.height]}set playbackRate(e){m(this,s)&&(m(this,s).playbackRate=e)}get playbackRate(){var o;let e=(o=m(this,s))==null?void 0:o.playbackRate;return e!=null?e:1}play(){var e;(e=m(this,s))==null||e.play()}pause(){m(this,s).pause()}};s=new WeakMap,T.AA=!1;export{T as VideoTexture};
@@ -1 +1 @@
1
- var r={version:"v0.25.0-1-g9eb631b69-dirty",branch:"main"};var t=r;export{t as VERSION};
1
+ var r={version:"v0.26.0-1-g0df3359c4-dirty",branch:"main"};var t=r;export{t as VERSION};
@@ -1 +1 @@
1
- import{VertexAttribute as z}from"../foundation/definitions/VertexAttribute.js";var g=class g{constructor({key:t,sourceBuffer:r,indexed:u,primitiveMode:e,attributes:o}){this.entries=[];this.totalVertexCount=0;this.totalIndexCount=0;this.version=0;this.uid=++g.cM,this.key=t,this.sourceBuffer=r,this.indexed=u,this.primitiveMode=e,this.attributes=o}};g.cM=0;var S=g,k=new WeakMap,G=0;function H(n){let t=k.get(n);return t==null&&(t=++G,k.set(n,t)),t}var _=(n,t)=>n.attributeAccessors[t].bufferView.buffer;function O(n){if(n.targets.length>0||n.mesh==null)return null;let t=n.attributeAccessors;if(t.length===0)return null;let r=_(n,0),u=n.indicesAccessor,e=n.getVertexCountAsVerticesBased();if(e===0)return null;for(let i of t)if(i.elementCount!==e)return null;let o=n.attributeSemantics,a="";for(let i=0;i<t.length;i++){let s=t[i];a+=`${o[i]}#${s.componentType.index}#${s.compositionType.index}#${s.normalized?1:0}#${s.actualByteStride},`}let l=u!=null;return`${H(r)}#${l?1:0}#${n.primitiveMode.index}#${t.length}#${a}`}function W(n){let t=[],r=n.attributeAccessors,u=n.attributeSemantics;for(let e=0;e<r.length;e++){let o=r[e],a=z.fromString(u[e].split(".")[0]);t.push({semantic:u[e],slot:e,componentType:o.componentType,compositionType:o.compositionType,normalized:o.normalized,byteStride:o.actualByteStride,isIntegerType:a.isIntegerType})}return t}function Y(n){let t=new Map;for(let u of n){let e=O(u);if(e==null)continue;let o=t.get(e);o==null&&(o=[],t.set(e,o)),o.push(u)}let r=[];for(let[u,e]of t){if(e.length<2)continue;let o=e[0],a=o.indicesAccessor!=null,l=W(o),i=_(o,0),s=new S({key:u,sourceBuffer:i,indexed:a,primitiveMode:o.primitiveMode,attributes:l}),c=0,m=0;for(let d of e)c+=d.getVertexCountAsVerticesBased(),a&&(m+=d.indicesAccessor.elementCount);if(c>4294967295)continue;let p=l.map(d=>new Uint8Array(c*d.byteStride)),M=a?new Uint32Array(m):void 0,C=new Uint32Array(c),w=new Uint32Array(c),y=0,h=0;for(let d of e){let B=d.mesh,$=B._ensureInstanceSidBase(),b=d.getVertexCountAsVerticesBased(),P=d.attributeAccessors;for(let f=0;f<P.length;f++){let T=l[f],U=P[f].getUint8Array(),E=y*T.byteStride,K=Math.min(U.length,b*T.byteStride);p[f].set(U.subarray(0,K),E)}C.fill($,y,y+b);let V=d.material.materialSID;w.fill(V,y,y+b);let v=d.indicesAccessor,I=a?v.elementCount:0;if(a&&M!=null)for(let f=0;f<I;f++)M[h+f]=v.getScalar(f,{})+y;let R={primitive:d,primitiveUid:d.primitiveUid,mesh:B,vertexOffset:y,vertexCount:b,indexCount:I,indexByteOffset:h*4,materialSid:V};s.entries.push(R),y+=b,h+=I}s.totalVertexCount=c,s.totalIndexCount=m,s.counts=new Int32Array(s.entries.length),s.offsets=new Int32Array(s.entries.length),s.instanceCounts=new Int32Array(s.entries.length),s.firsts=new Int32Array(s.entries.length),s.vertexCounts=new Int32Array(s.entries.length),s.materialSids=w,r.push({group:s,attributeBytes:p,mergedIndices:M,instanceBases:C,materialSids:w})}return r}function j(n){var u,e;let t=n.mesh,r=t==null?void 0:t.meshEntitiesInner[0];return(e=(u=r==null?void 0:r.getMeshRenderer())==null?void 0:u.getFingerPrintId())!=null?e:0}function L(n,t,r){let u=n._multiDrawGroup;if(u==null)return null;let e=t===n.material,o=e?t._getMultiDrawStateKey():`${t.materialUID}|${t._getMultiDrawStateKey()}`;return`${u.uid}|${e?1:0}|${o}|${r}|${n.primitiveMode.index}|${n.getRenderIndexBitSize()}|${n.hasIndices()?1:0}`}var A=new WeakMap,x=new Map,F=0,D=0,J=65536;function q(n,t,r){let u=n._multiDrawGroup;if(u==null)return null;let e=t===n.material,o=n.primitiveMode.index,a=n.getRenderIndexBitSize(),l=n.hasIndices(),i=A.get(n);if(i!=null&&i.generation===D&&i.groupUid===u.uid&&i.materialUid===t.materialUID&&i.materialStateVersion===t.stateVersion&&i.meshRendererFingerPrintId===r&&i.mode===o&&i.indexBitSize===a&&i.indexed===l&&i.isPerVertexMaterial===e)return i.keyId;let s=L(n,t,r);if(s==null)return A.delete(n),null;let c=x.get(s);return c==null&&(x.size>=J&&(x.clear(),D++),c=++F,x.set(s,c)),A.set(n,{groupUid:u.uid,materialUid:t.materialUID,materialStateVersion:t.stateVersion,meshRendererFingerPrintId:r,mode:o,indexBitSize:a,indexed:l,isPerVertexMaterial:e,keyId:c,generation:D}),c}function N(n,t,r,u){let e=[];if(r>0&&n>t||r<0&&n<t)return e;let o=n;for(;;){let a=u(o),l=1,i=o+r;for(;(r>0?i<=t:i>=t)&&u(i)===a;)l++,i+=r;if(e.push({startIndex:o,count:l,step:r,key:a}),r>0&&i>t||r<0&&i<t)break;o=i}return e}function Q(n,t,r,u,e){var s,c;if(e.count=0,r>0&&n>t||r<0&&n<t)return e;let o=Math.abs(t-n)+1;if(e.starts.length<o){let m=Math.max(e.starts.length*2,64);for(;m<o;)m*=2;e.starts=new Int32Array(m),e.counts=new Int32Array(m),e.keys=new Int32Array(m)}let a=n,l=(s=u(n))!=null?s:-1,i=1;for(let m=n+r;r>0?m<=t:m>=t;m+=r){let p=(c=u(m))!=null?c:-1;if(p===l){i++;continue}e.starts[e.count]=a,e.counts[e.count]=i,e.keys[e.count]=l,e.count++,a=m,l=p,i=1}return e.starts[e.count]=a,e.counts[e.count]=i,e.keys[e.count]=l,e.count++,e}export{S as MultiDrawGroup,Y as buildMultiDrawGroups,H as getBufferId,W as getMultiDrawAttributes,q as getMultiDrawStateKeyId,j as getPrimitiveMeshRendererFingerPrintId,O as makeMultiDrawGroupKey,L as makeMultiDrawRenderStateKey,N as planMultiDrawRuns,Q as planMultiDrawRunsInto};
1
+ import{VertexAttribute as z}from"../foundation/definitions/VertexAttribute.js";var g=class g{constructor({key:t,sourceBuffer:r,indexed:u,primitiveMode:e,attributes:o}){this.entries=[];this.totalVertexCount=0;this.totalIndexCount=0;this.version=0;this.uid=++g.lM,this.key=t,this.sourceBuffer=r,this.indexed=u,this.primitiveMode=e,this.attributes=o}};g.lM=0;var S=g,k=new WeakMap,G=0;function H(n){let t=k.get(n);return t==null&&(t=++G,k.set(n,t)),t}var _=(n,t)=>n.attributeAccessors[t].bufferView.buffer;function O(n){if(n.targets.length>0||n.mesh==null)return null;let t=n.attributeAccessors;if(t.length===0)return null;let r=_(n,0),u=n.indicesAccessor,e=n.getVertexCountAsVerticesBased();if(e===0)return null;for(let i of t)if(i.elementCount!==e)return null;let o=n.attributeSemantics,a="";for(let i=0;i<t.length;i++){let s=t[i];a+=`${o[i]}#${s.componentType.index}#${s.compositionType.index}#${s.normalized?1:0}#${s.actualByteStride},`}let l=u!=null;return`${H(r)}#${l?1:0}#${n.primitiveMode.index}#${t.length}#${a}`}function W(n){let t=[],r=n.attributeAccessors,u=n.attributeSemantics;for(let e=0;e<r.length;e++){let o=r[e],a=z.fromString(u[e].split(".")[0]);t.push({semantic:u[e],slot:e,componentType:o.componentType,compositionType:o.compositionType,normalized:o.normalized,byteStride:o.actualByteStride,isIntegerType:a.isIntegerType})}return t}function Y(n){let t=new Map;for(let u of n){let e=O(u);if(e==null)continue;let o=t.get(e);o==null&&(o=[],t.set(e,o)),o.push(u)}let r=[];for(let[u,e]of t){if(e.length<2)continue;let o=e[0],a=o.indicesAccessor!=null,l=W(o),i=_(o,0),s=new S({key:u,sourceBuffer:i,indexed:a,primitiveMode:o.primitiveMode,attributes:l}),c=0,m=0;for(let d of e)c+=d.getVertexCountAsVerticesBased(),a&&(m+=d.indicesAccessor.elementCount);if(c>4294967295)continue;let p=l.map(d=>new Uint8Array(c*d.byteStride)),M=a?new Uint32Array(m):void 0,C=new Uint32Array(c),w=new Uint32Array(c),y=0,h=0;for(let d of e){let B=d.mesh,$=B._ensureInstanceSidBase(),b=d.getVertexCountAsVerticesBased(),P=d.attributeAccessors;for(let f=0;f<P.length;f++){let T=l[f],U=P[f].getUint8Array(),E=y*T.byteStride,K=Math.min(U.length,b*T.byteStride);p[f].set(U.subarray(0,K),E)}C.fill($,y,y+b);let V=d.material.materialSID;w.fill(V,y,y+b);let v=d.indicesAccessor,I=a?v.elementCount:0;if(a&&M!=null)for(let f=0;f<I;f++)M[h+f]=v.getScalar(f,{})+y;let R={primitive:d,primitiveUid:d.primitiveUid,mesh:B,vertexOffset:y,vertexCount:b,indexCount:I,indexByteOffset:h*4,materialSid:V};s.entries.push(R),y+=b,h+=I}s.totalVertexCount=c,s.totalIndexCount=m,s.counts=new Int32Array(s.entries.length),s.offsets=new Int32Array(s.entries.length),s.instanceCounts=new Int32Array(s.entries.length),s.firsts=new Int32Array(s.entries.length),s.vertexCounts=new Int32Array(s.entries.length),s.materialSids=w,r.push({group:s,attributeBytes:p,mergedIndices:M,instanceBases:C,materialSids:w})}return r}function j(n){var u,e;let t=n.mesh,r=t==null?void 0:t.meshEntitiesInner[0];return(e=(u=r==null?void 0:r.getMeshRenderer())==null?void 0:u.getFingerPrintId())!=null?e:0}function L(n,t,r){let u=n._multiDrawGroup;if(u==null)return null;let e=t===n.material,o=e?t._getMultiDrawStateKey():`${t.materialUID}|${t._getMultiDrawStateKey()}`;return`${u.uid}|${e?1:0}|${o}|${r}|${n.primitiveMode.index}|${n.getRenderIndexBitSize()}|${n.hasIndices()?1:0}`}var A=new WeakMap,x=new Map,F=0,D=0,J=65536;function q(n,t,r){let u=n._multiDrawGroup;if(u==null)return null;let e=t===n.material,o=n.primitiveMode.index,a=n.getRenderIndexBitSize(),l=n.hasIndices(),i=A.get(n);if(i!=null&&i.generation===D&&i.groupUid===u.uid&&i.materialUid===t.materialUID&&i.materialStateVersion===t.stateVersion&&i.meshRendererFingerPrintId===r&&i.mode===o&&i.indexBitSize===a&&i.indexed===l&&i.isPerVertexMaterial===e)return i.keyId;let s=L(n,t,r);if(s==null)return A.delete(n),null;let c=x.get(s);return c==null&&(x.size>=J&&(x.clear(),D++),c=++F,x.set(s,c)),A.set(n,{groupUid:u.uid,materialUid:t.materialUID,materialStateVersion:t.stateVersion,meshRendererFingerPrintId:r,mode:o,indexBitSize:a,indexed:l,isPerVertexMaterial:e,keyId:c,generation:D}),c}function N(n,t,r,u){let e=[];if(r>0&&n>t||r<0&&n<t)return e;let o=n;for(;;){let a=u(o),l=1,i=o+r;for(;(r>0?i<=t:i>=t)&&u(i)===a;)l++,i+=r;if(e.push({startIndex:o,count:l,step:r,key:a}),r>0&&i>t||r<0&&i<t)break;o=i}return e}function Q(n,t,r,u,e){var s,c;if(e.count=0,r>0&&n>t||r<0&&n<t)return e;let o=Math.abs(t-n)+1;if(e.starts.length<o){let m=Math.max(e.starts.length*2,64);for(;m<o;)m*=2;e.starts=new Int32Array(m),e.counts=new Int32Array(m),e.keys=new Int32Array(m)}let a=n,l=(s=u(n))!=null?s:-1,i=1;for(let m=n+r;r>0?m<=t:m>=t;m+=r){let p=(c=u(m))!=null?c:-1;if(p===l){i++;continue}e.starts[e.count]=a,e.counts[e.count]=i,e.keys[e.count]=l,e.count++,a=m,l=p,i=1}return e.starts[e.count]=a,e.counts[e.count]=i,e.keys[e.count]=l,e.count++,e}export{S as MultiDrawGroup,Y as buildMultiDrawGroups,H as getBufferId,W as getMultiDrawAttributes,q as getMultiDrawStateKeyId,j as getPrimitiveMeshRendererFingerPrintId,O as makeMultiDrawGroupKey,L as makeMultiDrawRenderStateKey,N as planMultiDrawRuns,Q as planMultiDrawRunsInto};
@@ -1 +1 @@
1
- import{ProcessApproach as h}from"../foundation/definitions/ProcessApproach.js";import{VertexAttribute as p}from"../foundation/definitions/VertexAttribute.js";import{Primitive as m}from"../foundation/geometry/Primitive.js";import{buildMultiDrawGroups as v}from"./MultiDraw.js";var f=class{constructor(t){this.eV=new Map;this.tV=!0;this.vb=0;this.rV=new Set;this.iV=!0;this.i=t}get version(){return this.vb}hasVaoHandle(t){var e;for(let i of this.eV.values())if(((e=i.vertexHandles)==null?void 0:e.vaoHandle)===t)return!0;return!1}get groups(){return this.eV}markDirty(){this.iV=!0,this.tV=!0}markDirtyForMesh(t){this.rV.add(t),this.tV=!0}rebuildDirtyGroups(){if(!this.tV)return;this.tV=!1;let t=this.iV;this.iV=!1;let e=this.i,i=e.webglResourceRepository,d=e.config.isMultiDrawEnabled&&h.isWebGL2Approach(e.engineState.currentProcessApproach)&&i.isInstanceSidTextureCapable;if(this.aV(),!d){this.rV.clear(),this.vb++;return}let n=[],o=new Set;m.forEachPrimitive(r=>{if(r._engine!==e)return;n.push(r);let a=r.mesh;a!=null&&o.add(a)});let c=v(n),l=new Set;for(let r of c){let a=r.group;this.sV(r);for(let s=0;s<a.entries.length;s++){let u=a.entries[s];u.primitive.delete3DAPIVertexData(),u.primitive._setMultiDrawGroup(a,s),l.add(u.primitive)}this.eV.set(a.key,a)}for(let r of o)r.updateVariationVBO();for(let r of n)if(!l.has(r))if(r.vertexHandles==null)r.create3DAPIVertexData();else{let a=r.mesh;(t||a!=null&&this.rV.has(a))&&r.update3DAPIVertexData()}for(let r of o)r.updateVAO();this.rV.clear(),this.vb++}invalidateAll(){this.aV(),this.tV=!0}aV(){let t=this.i.webglResourceRepository;for(let e of this.eV.values()){for(let i of e.entries)i.mesh._clearMultiDrawVaoUids(),i.primitive._multiDrawGroup===e&&i.primitive._clearMultiDrawGroup();e.genericMaterialSidVaoHandle!=null&&(t.deleteVertexArray(e.genericMaterialSidVaoHandle),e.genericMaterialSidVaoHandle=void 0),e.vertexHandles!=null&&(t.deleteVertexDataResources(e.vertexHandles),e.vertexHandles=void 0),e.instanceBaseVboHandle!=null&&(t.deleteVertexBuffer(e.instanceBaseVboHandle),e.instanceBaseVboHandle=void 0),e.materialSidVboHandle!=null&&(t.deleteVertexBuffer(e.materialSidVboHandle),e.materialSidVboHandle=void 0)}this.eV.clear()}sV(t){let e=this.i.webglResourceRepository,i=t.group,d=t.attributeBytes.map(s=>e.createVertexBufferFromTypedArray(s)),n=t.mergedIndices!=null?e.createIndexBufferFromTypedArray(t.mergedIndices):void 0,o=e.createVertexBufferFromTypedArray(t.instanceBases),c=e.createVertexBufferFromTypedArray(t.materialSids),l=e.createVertexArray(),r=e.createVertexArray(),a=[];for(let s=0;s<p.AttributeTypeNumber;s++)a[s]=!1;for(let s of i.attributes){let u=p.toAttributeSlotFromJoinedString(s.semantic);a[u]=!0}i.vertexHandles={vaoHandle:l,iboHandle:n,vboHandles:d,attributesFlags:a,setComplete:!1},i.instanceBaseVboHandle=o,i.materialSidVboHandle=c,i.genericMaterialSidVaoHandle=r,i.version++,e.setMultiDrawVertexDataToPipeline(i,l,!0),e.setMultiDrawVertexDataToPipeline(i,r,!1)}};export{f as MultiDrawRepository};
1
+ import{ProcessApproach as h}from"../foundation/definitions/ProcessApproach.js";import{VertexAttribute as p}from"../foundation/definitions/VertexAttribute.js";import{Primitive as m}from"../foundation/geometry/Primitive.js";import{buildMultiDrawGroups as v}from"./MultiDraw.js";var f=class{constructor(t){this.eV=new Map;this.tV=!0;this.Mb=0;this.rV=new Set;this.iV=!0;this.i=t}get version(){return this.Mb}hasVaoHandle(t){var e;for(let i of this.eV.values())if(((e=i.vertexHandles)==null?void 0:e.vaoHandle)===t)return!0;return!1}get groups(){return this.eV}markDirty(){this.iV=!0,this.tV=!0}markDirtyForMesh(t){this.rV.add(t),this.tV=!0}rebuildDirtyGroups(){if(!this.tV)return;this.tV=!1;let t=this.iV;this.iV=!1;let e=this.i,i=e.webglResourceRepository,d=e.config.isMultiDrawEnabled&&h.isWebGL2Approach(e.engineState.currentProcessApproach)&&i.isInstanceSidTextureCapable;if(this.aV(),!d){this.rV.clear(),this.Mb++;return}let n=[],o=new Set;m.forEachPrimitive(r=>{if(r._engine!==e)return;n.push(r);let a=r.mesh;a!=null&&o.add(a)});let c=v(n),l=new Set;for(let r of c){let a=r.group;this.sV(r);for(let s=0;s<a.entries.length;s++){let u=a.entries[s];u.primitive.delete3DAPIVertexData(),u.primitive._setMultiDrawGroup(a,s),l.add(u.primitive)}this.eV.set(a.key,a)}for(let r of o)r.updateVariationVBO();for(let r of n)if(!l.has(r))if(r.vertexHandles==null)r.create3DAPIVertexData();else{let a=r.mesh;(t||a!=null&&this.rV.has(a))&&r.update3DAPIVertexData()}for(let r of o)r.updateVAO();this.rV.clear(),this.Mb++}invalidateAll(){this.aV(),this.tV=!0}aV(){let t=this.i.webglResourceRepository;for(let e of this.eV.values()){for(let i of e.entries)i.mesh._clearMultiDrawVaoUids(),i.primitive._multiDrawGroup===e&&i.primitive._clearMultiDrawGroup();e.genericMaterialSidVaoHandle!=null&&(t.deleteVertexArray(e.genericMaterialSidVaoHandle),e.genericMaterialSidVaoHandle=void 0),e.vertexHandles!=null&&(t.deleteVertexDataResources(e.vertexHandles),e.vertexHandles=void 0),e.instanceBaseVboHandle!=null&&(t.deleteVertexBuffer(e.instanceBaseVboHandle),e.instanceBaseVboHandle=void 0),e.materialSidVboHandle!=null&&(t.deleteVertexBuffer(e.materialSidVboHandle),e.materialSidVboHandle=void 0)}this.eV.clear()}sV(t){let e=this.i.webglResourceRepository,i=t.group,d=t.attributeBytes.map(s=>e.createVertexBufferFromTypedArray(s)),n=t.mergedIndices!=null?e.createIndexBufferFromTypedArray(t.mergedIndices):void 0,o=e.createVertexBufferFromTypedArray(t.instanceBases),c=e.createVertexBufferFromTypedArray(t.materialSids),l=e.createVertexArray(),r=e.createVertexArray(),a=[];for(let s=0;s<p.AttributeTypeNumber;s++)a[s]=!1;for(let s of i.attributes){let u=p.toAttributeSlotFromJoinedString(s.semantic);a[u]=!0}i.vertexHandles={vaoHandle:l,iboHandle:n,vboHandles:d,attributesFlags:a,setComplete:!1},i.instanceBaseVboHandle=o,i.materialSidVboHandle=c,i.genericMaterialSidVaoHandle=r,i.version++,e.setMultiDrawVertexDataToPipeline(i,l,!0),e.setMultiDrawVertexDataToPipeline(i,r,!1)}};export{f as MultiDrawRepository};
@@ -1,3 +1,3 @@
1
1
  import{Logger as _}from"../foundation/misc/Logger.js";var R=["#version 300 es","uniform vec2 u_offset;","uniform vec2 u_scale;","out mediump vec3 v_texcoord;","void main() {"," const float eye_offset_x[12] = float[12] ("," 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,"," 1.0, 1.0, 1.0, 1.0, 1.0, 1.0"," );"," const vec3 quad_positions[12] = vec3[12]"," ("," vec3(0.0, 0.0, 0.0),"," vec3(1.0, 0.0, 0.0),"," vec3(0.0, 1.0, 0.0),"," vec3(0.0, 1.0, 0.0),"," vec3(1.0, 0.0, 0.0),"," vec3(1.0, 1.0, 0.0),"," vec3(0.0, 0.0, 1.0),"," vec3(1.0, 0.0, 1.0),"," vec3(0.0, 1.0, 1.0),"," vec3(0.0, 1.0, 1.0),"," vec3(1.0, 0.0, 1.0),"," vec3(1.0, 1.0, 1.0)"," );"," const vec2 pos_scale = vec2(0.5, 1.0);"," vec2 eye_offset = vec2(eye_offset_x[gl_VertexID], 0.0);"," gl_Position = vec4(((quad_positions[gl_VertexID].xy * u_scale + u_offset) * pos_scale * 2.0) - 1.0 + eye_offset, 0.0, 1.0);"," v_texcoord = vec3(quad_positions[gl_VertexID].xy * u_scale + u_offset, quad_positions[gl_VertexID].z);","}"].join(`
2
2
  `),b=["#version 300 es","uniform mediump sampler2DArray u_source_texture;","in mediump vec3 v_texcoord;","out mediump vec4 output_color;","void main()","{"," output_color = texture(u_source_texture, v_texcoord);","}"].join(`
3
- `),f=class m{constructor(i){this.bE=i,this.u_=i.createProgram(),this.__(R,i.VERTEX_SHADER),this.__(b,i.FRAGMENT_SHADER),this.bE.linkProgram(this.u_),this.R_({v_texcoord:0}),this.b_()}static getInstance(i){return this.rc||(this.rc=new m(i)),this.rc}__(i,o){let t=this.bE,s;switch(o){case t.VERTEX_SHADER:this.E_=t.createShader(o),s=this.E_;break;case t.FRAGMENT_SHADER:this.f_=t.createShader(o),s=this.f_;break;default:_.default.error(`Invalid Shader Type: ${o}`);return}t.attachShader(this.u_,s),t.shaderSource(s,i),t.compileShader(s)}R_(i){let o=this.bE;if(i){this.m_={};for(let t in i)o.bindAttribLocation(this.u_,i[t],t),this.m_[t]=i[t]}}b_(){let i=this.bE;if(this.T_==null){this.T_={};let o=i.getProgramParameter(this.u_,i.ACTIVE_UNIFORMS),t="";for(let s=0;s<o;s++)t=i.getActiveUniform(this.u_,s).name.replace("[0]",""),this.T_[t]=i.getUniformLocation(this.u_,t)}}blit(i,o,t,s,e,n,c){let r=this.bE,T=this.u_;r.activeTexture(r.TEXTURE15),r.bindTexture(r.TEXTURE_2D_ARRAY,i),r.useProgram(T);let u=r.getParameter(r.DEPTH_TEST),a=r.getParameter(r.DEPTH_WRITEMASK);r.disable(r.SCISSOR_TEST),u&&r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.colorMask(!0,!0,!0,!0),a&&r.depthMask(!1);let E=r.getParameter(r.VIEWPORT);r.viewport(0,0,n,c),r.uniform2f(this.T_.u_scale,s,e),r.uniform2f(this.T_.u_offset,o,t),r.uniform1i(this.T_.u_source_texture,15),r.drawArrays(r.TRIANGLES,0,12),r.JA=!0,r.viewport(E[0],E[1],E[2],E[3]),u&&r.enable(r.DEPTH_TEST),r.depthMask(a),r.flush()}blitFake(i,o,t,s,e,n,c){let r=this.bE,T=this.u_;r.activeTexture(r.TEXTURE15),r.bindTexture(r.TEXTURE_2D_ARRAY,i),r.useProgram(T);let u=r.getParameter(r.VIEWPORT);r.viewport(0,0,n,c),r.uniform2f(this.T_.u_scale,s,e),r.uniform2f(this.T_.u_offset,o,t),r.uniform1i(this.T_.u_source_texture,15),r.drawArrays(r.TRIANGLES,0,12),r.JA=!0,r.viewport(u[0],u[1],u[2],u[3])}blit2(i,o,t,s){let e=this.bE,n=e.createFramebuffer(),c=e.createFramebuffer();function r(T,u){let a=e.createTexture();e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,s,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,n),e.framebufferTextureLayer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,i,0,T),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),e.blitFramebuffer(0,0,t,s,0,0,t,s,e.COLOR_BUFFER_BIT,e.NEAREST),e.framebufferTexture2D(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),e.blitFramebuffer(0,0,t,s,u,0,u+t,s,e.COLOR_BUFFER_BIT,e.NEAREST)}r(0,0),r(1,t),e.bindFramebuffer(e.FRAMEBUFFER,null)}};export{f as WebGLStereoUtil};
3
+ `),f=class m{constructor(i){this.bE=i,this.u_=i.createProgram(),this.R_(R,i.VERTEX_SHADER),this.R_(b,i.FRAGMENT_SHADER),this.bE.linkProgram(this.u_),this.b_({v_texcoord:0}),this.v_()}static getInstance(i){return this.rc||(this.rc=new m(i)),this.rc}R_(i,o){let t=this.bE,s;switch(o){case t.VERTEX_SHADER:this.E_=t.createShader(o),s=this.E_;break;case t.FRAGMENT_SHADER:this.f_=t.createShader(o),s=this.f_;break;default:_.default.error(`Invalid Shader Type: ${o}`);return}t.attachShader(this.u_,s),t.shaderSource(s,i),t.compileShader(s)}b_(i){let o=this.bE;if(i){this.__={};for(let t in i)o.bindAttribLocation(this.u_,i[t],t),this.__[t]=i[t]}}v_(){let i=this.bE;if(this.T_==null){this.T_={};let o=i.getProgramParameter(this.u_,i.ACTIVE_UNIFORMS),t="";for(let s=0;s<o;s++)t=i.getActiveUniform(this.u_,s).name.replace("[0]",""),this.T_[t]=i.getUniformLocation(this.u_,t)}}blit(i,o,t,s,e,n,c){let r=this.bE,T=this.u_;r.activeTexture(r.TEXTURE15),r.bindTexture(r.TEXTURE_2D_ARRAY,i),r.useProgram(T);let u=r.getParameter(r.DEPTH_TEST),a=r.getParameter(r.DEPTH_WRITEMASK);r.disable(r.SCISSOR_TEST),u&&r.disable(r.DEPTH_TEST),r.disable(r.STENCIL_TEST),r.colorMask(!0,!0,!0,!0),a&&r.depthMask(!1);let E=r.getParameter(r.VIEWPORT);r.viewport(0,0,n,c),r.uniform2f(this.T_.u_scale,s,e),r.uniform2f(this.T_.u_offset,o,t),r.uniform1i(this.T_.u_source_texture,15),r.drawArrays(r.TRIANGLES,0,12),r.JA=!0,r.viewport(E[0],E[1],E[2],E[3]),u&&r.enable(r.DEPTH_TEST),r.depthMask(a),r.flush()}blitFake(i,o,t,s,e,n,c){let r=this.bE,T=this.u_;r.activeTexture(r.TEXTURE15),r.bindTexture(r.TEXTURE_2D_ARRAY,i),r.useProgram(T);let u=r.getParameter(r.VIEWPORT);r.viewport(0,0,n,c),r.uniform2f(this.T_.u_scale,s,e),r.uniform2f(this.T_.u_offset,o,t),r.uniform1i(this.T_.u_source_texture,15),r.drawArrays(r.TRIANGLES,0,12),r.JA=!0,r.viewport(u[0],u[1],u[2],u[3])}blit2(i,o,t,s){let e=this.bE,n=e.createFramebuffer(),c=e.createFramebuffer();function r(T,u){let a=e.createTexture();e.bindTexture(e.TEXTURE_2D,a),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,s,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,n),e.framebufferTextureLayer(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,i,0,T),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),e.blitFramebuffer(0,0,t,s,0,0,t,s,e.COLOR_BUFFER_BIT,e.NEAREST),e.framebufferTexture2D(e.READ_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,a,0),e.framebufferTexture2D(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),e.blitFramebuffer(0,0,t,s,u,0,u+t,s,e.COLOR_BUFFER_BIT,e.NEAREST)}r(0,0),r(1,t),e.bindFramebuffer(e.FRAMEBUFFER,null)}};export{f as WebGLStereoUtil};
@@ -53,11 +53,13 @@ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy
53
53
  private static __isDebugOperationToDataTextureBufferDone;
54
54
  private __uniformMorphOffsetsTypedArray?;
55
55
  private __uniformMorphWeightsTypedArray?;
56
+ private __isPreviousMorphWeightsSettled;
56
57
  private __lastBlendShapeComponentsUpdateCountForWeights;
57
58
  private __lastMorphMaxIndex;
58
59
  private __lastMaterialsUpdateCount;
59
60
  private __lastLightClusterDataVersion;
60
61
  private __lastLightComponentsUpdateCount;
62
+ private __lastGpuInstanceDataVersion;
61
63
  private __lastTotalSizeOfGPUShaderDataStorageExceptMorphData;
62
64
  private __lastTransformComponentsUpdateCount;
63
65
  private __lastSceneGraphComponentsUpdateCount;
@@ -273,6 +275,12 @@ export declare class WebGLStrategyWebGL2 implements CGAPIStrategy, WebGLStrategy
273
275
  * Copies weight values from blend shape components to GPU-accessible uniform buffers.
274
276
  */
275
277
  private __updateMorphWeightsUniformBuffer;
278
+ private __uploadMorphWeights;
279
+ /**
280
+ * Makes the weights of the previous frame in the morph weights uniform buffer equal to the current weights once
281
+ * the weights stopped changing (temporal anti-aliasing only).
282
+ */
283
+ private __settlePreviousMorphWeights;
276
284
  /**
277
285
  * Determines whether Uniform Buffer Objects (UBO) should be used for data storage.
278
286
  * UBOs are only used when both WebGL 2.0 is available and UBO usage is enabled in configuration.
@@ -1,41 +1,59 @@
1
- import{AnimationComponent as re}from"../foundation/components/Animation/AnimationComponent.js";import{BlendShapeComponent as O}from"../foundation/components/BlendShape/BlendShapeComponent.js";import{CameraComponent as k}from"../foundation/components/Camera/CameraComponent.js";import{_getCameraControllerUpdateCount as q}from"../foundation/components/CameraController/CameraControllerUpdateCount.js";import{LightComponent as z}from"../foundation/components/Light/LightComponent.js";import{MeshComponent as ne}from"../foundation/components/Mesh/MeshComponent.js";import{MeshRendererComponent as H}from"../foundation/components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as J}from"../foundation/components/SceneGraph/SceneGraphComponent.js";import{TransformComponent as Q}from"../foundation/components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as N}from"../foundation/components/WellKnownComponentTIDs.js";import{Component as P}from"../foundation/core/Component.js";import{BufferUse as $}from"../foundation/definitions/BufferUse.js";import{ComponentType as T}from"../foundation/definitions/ComponentType.js";import{CompositionType as g}from"../foundation/definitions/CompositionType.js";import{PixelFormat as j}from"../foundation/definitions/PixelFormat.js";import{ShaderType as X}from"../foundation/definitions/ShaderType.js";import{TextureFormat as ae}from"../foundation/definitions/TextureFormat.js";import{VertexAttribute as E}from"../foundation/definitions/VertexAttribute.js";import{Primitive as U}from"../foundation/geometry/Primitive.js";import{Logger as ee}from"../foundation/misc/Logger.js";import{MiscUtil as oe}from"../foundation/misc/MiscUtil.js";import{CGAPIResourceRepository as v}from"../foundation/renderer/CGAPIResourceRepository.js";import{subtractByteRanges as se}from"../foundation/renderer/lightCluster/LightClusterLayout.js";import{isSkipDrawing as te}from"../foundation/renderer/RenderingCommonMethods.js";import{getMultiDrawStateKeyId as ce,getPrimitiveMeshRendererFingerPrintId as le,planMultiDrawRunsInto as fe}from"./MultiDraw.js";import V,{setupShaderProgram as Y}from"./WebGLStrategyCommonMethod.js";var B=class B{constructor(t){this.__dataTextureUid=v.InvalidCGAPIResourceUid;this.bI=v.InvalidCGAPIResourceUid;this.gI=v.InvalidCGAPIResourceUid;this.yI=v.InvalidCGAPIResourceUid;this.II=v.InvalidCGAPIResourceUid;this.$I=-1;this.IC=-1;this.vI=1;this.SC={starts:new Int32Array(0),counts:new Int32Array(0),keys:new Int32Array(0),count:0};this.SI=0;this.BI=0;this.UI=0;this.RI=0;this.CI=0;this.GI=0;this._totalSizeOfGPUShaderDataStorageExceptMorphData=0;this.FI=-1;this.zI=-1;this.HI=-1;this.jI=-1;this.er=-1;this.XI=-1;this.tr=-1;this.YI=-1;this.kb=-1;this.rr=-1;this.ZI=-1;this.PI=-1;this.KI=-1;this.qI=-1;this.i=t,this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0)}static dumpDataTextureBuffer(){this.DI=!1}static JI(t,e){let i="";return P.getMemberInfo(t).forEach((r,c)=>{r.forEach((s,p)=>{var d;if(s.shaderType!==e&&s.shaderType!==X.VertexAndPixelShader)return;let l=(d=P.getComponentCountPerBufferView(t).get(c))!=null?d:1;g.isArray(s.compositionType)?a(s,c,p,l):o(s,c,p,l)})}),i;function a(r,c,s,p){var I,y;let l="",d="";switch(r.compositionType){case g.Vec4Array:l="vec4",d="fetchVec4";break;case g.Mat4Array:l="mat4",d="fetchMat4";break;case g.Mat4x3Array:l="mat4x3",d="fetchMat4x3";break;default:throw new Error(`Unsupported composition type: ${r.compositionType.str}`)}let m=r.compositionType.getVec4SizeOfProperty();if(r.isVariableLength===!0){let A=P._variableLengthLocationRadix;i+=`
1
+ import{AnimationComponent as re}from"../foundation/components/Animation/AnimationComponent.js";import{BlendShapeComponent as G}from"../foundation/components/BlendShape/BlendShapeComponent.js";import{CameraComponent as k}from"../foundation/components/Camera/CameraComponent.js";import{_getCameraControllerUpdateCount as q}from"../foundation/components/CameraController/CameraControllerUpdateCount.js";import{LightComponent as z}from"../foundation/components/Light/LightComponent.js";import{MeshComponent as ne}from"../foundation/components/Mesh/MeshComponent.js";import{MeshRendererComponent as H}from"../foundation/components/MeshRenderer/MeshRendererComponent.js";import{SceneGraphComponent as J}from"../foundation/components/SceneGraph/SceneGraphComponent.js";import{TransformComponent as Q}from"../foundation/components/Transform/TransformComponent.js";import{WellKnownComponentTIDs as N}from"../foundation/components/WellKnownComponentTIDs.js";import{Component as O}from"../foundation/core/Component.js";import{BufferUse as $}from"../foundation/definitions/BufferUse.js";import{ComponentType as T}from"../foundation/definitions/ComponentType.js";import{CompositionType as g}from"../foundation/definitions/CompositionType.js";import{PixelFormat as j}from"../foundation/definitions/PixelFormat.js";import{ShaderType as X}from"../foundation/definitions/ShaderType.js";import{TextureFormat as ae}from"../foundation/definitions/TextureFormat.js";import{VertexAttribute as E}from"../foundation/definitions/VertexAttribute.js";import{Primitive as U}from"../foundation/geometry/Primitive.js";import{Logger as ee}from"../foundation/misc/Logger.js";import{MiscUtil as oe}from"../foundation/misc/MiscUtil.js";import{CGAPIResourceRepository as v}from"../foundation/renderer/CGAPIResourceRepository.js";import{subtractByteRanges as se}from"../foundation/renderer/lightCluster/LightClusterLayout.js";import{isSkipDrawing as te}from"../foundation/renderer/RenderingCommonMethods.js";import{getMultiDrawStateKeyId as ce,getPrimitiveMeshRendererFingerPrintId as le,planMultiDrawRunsInto as fe}from"./MultiDraw.js";import V,{setupShaderProgram as Y}from"./WebGLStrategyCommonMethod.js";var B=class B{constructor(t){this.__dataTextureUid=v.InvalidCGAPIResourceUid;this.bI=v.InvalidCGAPIResourceUid;this.gI=v.InvalidCGAPIResourceUid;this.yI=v.InvalidCGAPIResourceUid;this.SI=v.InvalidCGAPIResourceUid;this.EI=-1;this.S_=-1;this.vI=1;this.M_={starts:new Int32Array(0),counts:new Int32Array(0),keys:new Int32Array(0),count:0};this.RI=0;this.UI=0;this.DI=0;this._I=0;this.MI=0;this.PI=0;this._totalSizeOfGPUShaderDataStorageExceptMorphData=0;this.OI=!0;this.zI=-1;this.HI=-1;this.jI=-1;this.XI=-1;this.or=-1;this.YI=-1;this.ZI=-1;this.nr=-1;this.KI=-1;this.dC=-1;this.sr=-1;this.qI=-1;this.VI=-1;this.JI=-1;this.QI=-1;this.i=t,this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0)}static dumpDataTextureBuffer(){this.GI=!1}static LS(t,e){let i="";return O.getMemberInfo(t).forEach((n,c)=>{n.forEach((s,p)=>{var d;if(s.shaderType!==e&&s.shaderType!==X.VertexAndPixelShader)return;let l=(d=O.getComponentCountPerBufferView(t).get(c))!=null?d:1;g.isArray(s.compositionType)?a(s,c,p,l):o(s,c,p,l)})}),i;function a(n,c,s,p){var I,y;let l="",d="";switch(n.compositionType){case g.Vec4Array:l="vec4",d="fetchVec4";break;case g.Mat4Array:l="mat4",d="fetchMat4";break;case g.Mat4x3Array:l="mat4x3",d="fetchMat4x3";break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let m=n.compositionType.getVec4SizeOfProperty();if(n.isVariableLength===!0){let A=O._variableLengthLocationRadix;i+=`
2
2
  ${l} get_${s}(uint instanceId, uint idxOfArray) {
3
- vec4 location = get_${P._getVariableLengthLocationMemberName(s)}(instanceId);
3
+ vec4 location = get_${O._getVariableLengthLocationMemberName(s)}(instanceId);
4
4
  int index = int(location.x) * ${A} + int(location.y) + ${m} * int(idxOfArray);
5
5
  ${l} value = ${d}(index);
6
6
  return value;
7
7
  }
8
- `;return}let f=P.getLocationOffsetOfMemberOfComponent(t,c,s),b=`int arrayLength = ${(y=((I=P.getArrayLengthOfMember(t).get(c))!=null?I:new Map).get(s))!=null?y:0};`,u=`rnIndices_${s}`,R=`int index = ${u}[instanceIdOfBufferViews] + int(instanceIdInBufferView) * ${m} * arrayLength + ${m} * int(idxOfArray);`,C="";r.convertToBool&&(C="return (value > 0.5) ? true : false;"),i+=`
8
+ `;return}let f=O.getLocationOffsetOfMemberOfComponent(t,c,s),b=`int arrayLength = ${(y=((I=O.getArrayLengthOfMember(t).get(c))!=null?I:new Map).get(s))!=null?y:0};`,u=`rnIndices_${s}`,R=`int index = ${u}[instanceIdOfBufferViews] + int(instanceIdInBufferView) * ${m} * arrayLength + ${m} * int(idxOfArray);`,_="";n.convertToBool&&(_="return (value > 0.5) ? true : false;"),i+=`
9
9
  const int ${u}[${f.length}] = int[${f.length}](${f.join(", ")});
10
- ${r.convertToBool?"bool":l} get_${s}(uint instanceId, uint idxOfArray) {
10
+ ${n.convertToBool?"bool":l} get_${s}(uint instanceId, uint idxOfArray) {
11
11
  uint instanceIdOfBufferViews = instanceId / ${p}u;
12
12
  uint instanceIdInBufferView = instanceId % ${p}u;
13
13
  ${b}
14
14
  ${R}
15
15
  ${l} value = ${d}(index);
16
- ${r.convertToBool?C:"return value;"}
16
+ ${n.convertToBool?_:"return value;"}
17
17
  }
18
- `}function o(r,c,s,p){let l="",d="";switch(r.compositionType){case g.Mat4:l="mat4",d="fetchMat4";break;case g.Mat3:l="mat3",d="fetchMat3No16BytesAligned";break;case g.Vec4:l="vec4",d="fetchVec4";break;case g.Vec3:l="vec3",d="fetchVec3No16BytesAligned";break;case g.Scalar:l="float",d="fetchScalarNo16BytesAligned";break;default:throw new Error(`Unsupported composition type: ${r.compositionType.str}`)}let m=P.getLocationOffsetOfMemberOfComponent(t,c,s),f=`rnIndices_${s}`,h="";switch(r.compositionType){case g.Mat4:h=`int index = ${f}[instanceIdOfBufferViews] + 4 * int(instanceIdInBufferView);`;break;case g.Mat3:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 9 * int(instanceIdInBufferView);`;break;case g.Vec4:h=`int index = ${f}[instanceIdOfBufferViews] + 1 * int(instanceIdInBufferView);`;break;case g.Vec3:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 3 * int(instanceIdInBufferView);`;break;case g.Scalar:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 1 * int(instanceIdInBufferView);`;break;default:throw new Error(`Unsupported composition type: ${r.compositionType.str}`)}let x="";r.convertToBool&&(x="return (value > 0.5) ? true : false;"),i+=`
18
+ `}function o(n,c,s,p){let l="",d="";switch(n.compositionType){case g.Mat4:l="mat4",d="fetchMat4";break;case g.Mat3:l="mat3",d="fetchMat3No16BytesAligned";break;case g.Vec4:l="vec4",d="fetchVec4";break;case g.Vec3:l="vec3",d="fetchVec3No16BytesAligned";break;case g.Scalar:l="float",d="fetchScalarNo16BytesAligned";break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let m=O.getLocationOffsetOfMemberOfComponent(t,c,s),f=`rnIndices_${s}`,h="";switch(n.compositionType){case g.Mat4:h=`int index = ${f}[instanceIdOfBufferViews] + 4 * int(instanceIdInBufferView);`;break;case g.Mat3:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 9 * int(instanceIdInBufferView);`;break;case g.Vec4:h=`int index = ${f}[instanceIdOfBufferViews] + 1 * int(instanceIdInBufferView);`;break;case g.Vec3:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 3 * int(instanceIdInBufferView);`;break;case g.Scalar:h=`int index = ${f}[instanceIdOfBufferViews] * 4 + 1 * int(instanceIdInBufferView);`;break;default:throw new Error(`Unsupported composition type: ${n.compositionType.str}`)}let x="";n.convertToBool&&(x="return (value > 0.5) ? true : false;"),i+=`
19
19
  const int ${f}[${m.length}] = int[${m.length}](${m.join(", ")});
20
- ${r.convertToBool?"bool":l} get_${s}(uint instanceId) {
20
+ ${n.convertToBool?"bool":l} get_${s}(uint instanceId) {
21
21
  uint instanceIdOfBufferViews = instanceId / ${p}u;
22
22
  uint instanceIdInBufferView = instanceId % ${p}u;
23
23
  ${h}
24
24
  ${l} value = ${d}(index);
25
- ${r.convertToBool?x:"return value;"}
25
+ ${n.convertToBool?x:"return value;"}
26
26
  }
27
- `}}static MC(t){let e=U.getMorphUniformDataTargetNumbers(),i=`
27
+ `}}static C_(t){let e=U.getMorphUniformDataTargetNumbers(),i=`
28
28
  const int rnMorphUniformDataTargetNumbers[${e.length}] = int[${e.length}](${e.join(", ")});
29
- `,n=U.getMorphUniformDataOffsets(),a=`
30
- const int rnMorphUniformDataOffsets[${n.length}] = int[${n.length}](${n.join(", ")});
31
- `,o=O.getOffsetsInUniform(t),r=`
29
+ `,r=U.getMorphUniformDataOffsets(),a=`
30
+ const int rnMorphUniformDataOffsets[${r.length}] = int[${r.length}](${r.join(", ")});
31
+ `,o=G.getOffsetsInUniform(t),n=`
32
32
  const int rnBlendShapeUniformDataOffsets[${o.length}] = int[${o.length}](${o.join(", ")});
33
- `;return`
33
+ `,c=t._isPreviousMorphWeightsEnabled?`
34
+ vec3 get_previousMorphedPosition(uint vertexId, vec3 basePosition, uint blendShapeComponentSID) {
35
+ int currentPrimitiveIdx = u_currentPrimitiveIdx;
36
+ int offsetInUniform = rnMorphUniformDataOffsets[currentPrimitiveIdx];
37
+ int offsetInUniform2 = rnBlendShapeUniformDataOffsets[blendShapeComponentSID] + ${G._getPreviousMorphWeightsOffset(t)};
38
+ vec3 position = basePosition;
39
+ int scalar_idx = 3 * int(vertexId);
40
+ for (int i=0; i<rnMorphUniformDataTargetNumbers[currentPrimitiveIdx]; i++) {
41
+ int idx = offsetInUniform + i;
42
+ ivec4 offsets = uniformMorphOffsets.data[ idx / 4];
43
+ int offsetPosition = offsets[idx % 4];
44
+ int basePosIn4bytes = offsetPosition * 4 + scalar_idx;
45
+ vec3 addPos = fetchVec3No16BytesAligned(basePosIn4bytes);
46
+ int idx2 = offsetInUniform2 + i;
47
+ vec4 morphWeights = uniformMorphWeights.data[ idx2 / 4];
48
+ position += addPos * morphWeights[idx2 % 4];
49
+ }
50
+ return position;
51
+ }`:"";return`
34
52
  #ifdef RN_IS_VERTEX_SHADER
35
53
  #ifdef RN_IS_MORPHING
36
54
  ${i}
37
55
  ${a}
38
- ${r}
56
+ ${n}
39
57
  vec3 get_position(uint vertexId, vec3 basePosition, uint blendShapeComponentSID) {
40
58
  int currentPrimitiveIdx = u_currentPrimitiveIdx;
41
59
  int offsetInUniform = rnMorphUniformDataOffsets[currentPrimitiveIdx];
@@ -59,17 +77,18 @@ import{AnimationComponent as re}from"../foundation/components/Animation/Animatio
59
77
 
60
78
  return position;
61
79
  }
80
+ ${c}
62
81
  #endif
63
82
  #endif
64
- `}setupShaderForMaterial(t,e){let i=this.i.webglResourceRepository,n=i.currentWebGLContextWrapper,[a,o]=t._createProgramWebGL(this.i,B.JI(this.i,X.VertexShader),B.JI(this.i,X.PixelShader),B._C,B.AC,B.MC(this.i),e);return o&&(t._setupBasicUniformsLocations(e),t._setUniformLocationsOfMaterialNodes(e),t._setupAdditionalUniformLocations(V.getPointSpriteShaderSemanticsInfoArray(),e),this.i.globalDataRepository._setUniformLocationsForWebGL2ModeOnly(t.getShaderProgramUid(e)),i.setUniformBlockBindingForMorphOffsetsAndWeights(a,this.gI,this.yI)),a}_reSetupShaderForMaterialBySpector(t,e,i,n){let[a,o]=t._createProgramByUpdatedSources(i,e,n);return a===v.InvalidCGAPIResourceUid||(o&&(t._setupBasicUniformsLocations(e),t._setUniformLocationsOfMaterialNodes(e),t._setupAdditionalUniformLocations(V.getPointSpriteShaderSemanticsInfoArray(),e)),this.i.globalDataRepository._setUniformLocationsForWebGL2ModeOnly(t.getShaderProgramUid(e))),a}static _C(t,e){var x,b;let i=e.compositionType.getGlslStr(e.componentType),n,a=g.isTexture(e.compositionType),o=e.semantic.replace(".","_"),r="",c=e.compositionType.getGlslStr(e.componentType),s="";e.arrayLength&&(s=`[${e.arrayLength}]`),(e.needUniformInDataTextureMode||a)&&(r=` uniform ${c} u_${o}${s};
65
- `);let p=e.compositionType.getVec4SizeOfProperty(),l=e.compositionType.getNumberOfComponents(),d=B.getOffsetOfPropertyOfGlobalDataRepository(t,e.semantic);d===-1&&ee.default.error("Could not get the location offset of the property.");let m=p;if(n=`int vec4_idx = ${d} + ${m} * instanceId;
66
- `,g.isArray(e.compositionType)){m=p*((x=e.arrayLength)!=null?x:1);let R=Math.ceil(l/4)*4*((b=e.arrayLength)!=null?b:1);n=`int vec4_idx = ${d} + ${m} * instanceId + ${p} * int(idxOfArray);
67
- `,n+=`int scalar_idx = ${d*4} + ${R} * instanceId + ${l} * int(idxOfArray);
83
+ `}setupShaderForMaterial(t,e){let i=this.i.webglResourceRepository,r=i.currentWebGLContextWrapper,[a,o]=t._createProgramWebGL(this.i,B.LS(this.i,X.VertexShader),B.LS(this.i,X.PixelShader),B.A_,B.B_,B.C_(this.i),e);return o&&(t._setupBasicUniformsLocations(e),t._setUniformLocationsOfMaterialNodes(e),t._setupAdditionalUniformLocations(V.getPointSpriteShaderSemanticsInfoArray(),e),this.i.globalDataRepository._setUniformLocationsForWebGL2ModeOnly(t.getShaderProgramUid(e)),i.setUniformBlockBindingForMorphOffsetsAndWeights(a,this.gI,this.yI)),a}_reSetupShaderForMaterialBySpector(t,e,i,r){let[a,o]=t._createProgramByUpdatedSources(i,e,r);return a===v.InvalidCGAPIResourceUid||(o&&(t._setupBasicUniformsLocations(e),t._setUniformLocationsOfMaterialNodes(e),t._setupAdditionalUniformLocations(V.getPointSpriteShaderSemanticsInfoArray(),e)),this.i.globalDataRepository._setUniformLocationsForWebGL2ModeOnly(t.getShaderProgramUid(e))),a}static A_(t,e){var x,b;let i=e.compositionType.getGlslStr(e.componentType),r,a=g.isTexture(e.compositionType),o=e.semantic.replace(".","_"),n="",c=e.compositionType.getGlslStr(e.componentType),s="";e.arrayLength&&(s=`[${e.arrayLength}]`),(e.needUniformInDataTextureMode||a)&&(n=` uniform ${c} u_${o}${s};
84
+ `);let p=e.compositionType.getVec4SizeOfProperty(),l=e.compositionType.getNumberOfComponents(),d=B.getOffsetOfPropertyOfGlobalDataRepository(t,e.semantic);d===-1&&ee.default.error("Could not get the location offset of the property.");let m=p;if(r=`int vec4_idx = ${d} + ${m} * instanceId;
85
+ `,g.isArray(e.compositionType)){m=p*((x=e.arrayLength)!=null?x:1);let R=Math.ceil(l/4)*4*((b=e.arrayLength)!=null?b:1);r=`int vec4_idx = ${d} + ${m} * instanceId + ${p} * int(idxOfArray);
86
+ `,r+=`int scalar_idx = ${d*4} + ${R} * instanceId + ${l} * int(idxOfArray);
68
87
  `}let f="";e.componentType===T.Int&&e.compositionType!==g.Scalar&&(f="i");let h="";if(!a&&!e.needUniformInDataTextureMode){h+=`
69
88
  ${i} get_${o}(highp uint _instanceId, const uint idxOfArray) {
70
89
  int instanceId = int(_instanceId);
71
- ${n}
72
- `;let u=`${r}
90
+ ${r}
91
+ `;let u=`${n}
73
92
  ${h}`;switch(e.compositionType){case g.Vec4:case g.Vec4Array:u+=` highp vec4 val = fetchElement(vec4_idx);
74
93
  `;break;case g.Vec3:u+=` vec4 col0 = fetchElement(vec4_idx);
75
94
  `,u+=` highp ${f}vec3 val = ${f}vec3(col0.xyz);`;break;case g.Vec3Array:u+=` vec3 val = fetchVec3No16BytesAligned(scalar_idx);
@@ -87,17 +106,17 @@ ${h}`;switch(e.compositionType){case g.Vec4:case g.Vec4Array:u+=` highp v
87
106
  `;break;default:u+=""}return u+=`
88
107
  return val;
89
108
  }
90
- `,u}if(!a&&e.needUniformInDataTextureMode){let u="";return e.arrayLength&&(u="[idxOfArray]"),`${r}
109
+ `,u}if(!a&&e.needUniformInDataTextureMode){let u="";return e.arrayLength&&(u="[idxOfArray]"),`${n}
91
110
  ${i} get_${o}(highp uint _instanceId, const uint idxOfArray) {
92
111
  return u_${o}${u};
93
112
  }
94
- `}return r}static AC(t,e,i){var C,I;let n=i.compositionType.getGlslStr(i.componentType),a,o=g.isTexture(i.compositionType),r=i.semantic.replace(".","_"),c="",s=i.compositionType.getGlslStr(i.componentType),p="";i.arrayLength&&(p=`[${i.arrayLength}]`),(i.needUniformInDataTextureMode||o)&&(c=` uniform ${s} u_${r}${p};
95
- `);let l=i.compositionType.getVec4SizeOfProperty(),d=i.compositionType.getNumberOfComponents(),m=B.getOffsetOfPropertyOfMaterial(t,i.semantic,e),f=t.materialRepository._getMaterialCountPerBufferView(e),h=`rnOffsets_${r}`,x=`const int ${h}[${m.length}] = int[${m.length}](${m.join(", ")});`,b=l;if(a=`int vec4_idx = ${h}[instanceIdOfBufferViews] + ${b} * int(instanceIdInBufferView);
96
- `,g.isArray(i.compositionType)){b=l*((C=i.arrayLength)!=null?C:1);let A=Math.ceil(d/4)*4*((I=i.arrayLength)!=null?I:1);a=`int vec4_idx = ${h}[instanceIdOfBufferViews] + ${b} * int(instanceIdInBufferView) + ${l} * int(idxOfArray);
113
+ `}return n}static B_(t,e,i){var _,I;let r=i.compositionType.getGlslStr(i.componentType),a,o=g.isTexture(i.compositionType),n=i.semantic.replace(".","_"),c="",s=i.compositionType.getGlslStr(i.componentType),p="";i.arrayLength&&(p=`[${i.arrayLength}]`),(i.needUniformInDataTextureMode||o)&&(c=` uniform ${s} u_${n}${p};
114
+ `);let l=i.compositionType.getVec4SizeOfProperty(),d=i.compositionType.getNumberOfComponents(),m=B.getOffsetOfPropertyOfMaterial(t,i.semantic,e),f=t.materialRepository._getMaterialCountPerBufferView(e),h=`rnOffsets_${n}`,x=`const int ${h}[${m.length}] = int[${m.length}](${m.join(", ")});`,b=l;if(a=`int vec4_idx = ${h}[instanceIdOfBufferViews] + ${b} * int(instanceIdInBufferView);
115
+ `,g.isArray(i.compositionType)){b=l*((_=i.arrayLength)!=null?_:1);let A=Math.ceil(d/4)*4*((I=i.arrayLength)!=null?I:1);a=`int vec4_idx = ${h}[instanceIdOfBufferViews] + ${b} * int(instanceIdInBufferView) + ${l} * int(idxOfArray);
97
116
  `,a+=`int scalar_idx = ${h}[instanceIdOfBufferViews] * 4 + ${A} * int(instanceIdInBufferView) + ${d} * int(idxOfArray);
98
117
  `}let u="";i.componentType===T.Int&&i.compositionType!==g.Scalar&&(u="i");let R="";if(!o&&!i.needUniformInDataTextureMode){R+=`
99
118
  ${x}
100
- ${n} get_${r}(highp uint _instanceId, const uint idxOfArray) {
119
+ ${r} get_${n}(highp uint _instanceId, const uint idxOfArray) {
101
120
  uint instanceId = _instanceId;
102
121
  uint instanceIdOfBufferViews = instanceId / ${f}u;
103
122
  uint instanceIdInBufferView = instanceId % ${f}u;
@@ -121,7 +140,7 @@ ${R}`;switch(i.compositionType){case g.Vec4:case g.Vec4Array:y+=` highp v
121
140
  return val;
122
141
  }
123
142
  `,y}if(!o&&i.needUniformInDataTextureMode){let y="";return i.arrayLength&&(y="[idxOfArray]"),`${c}
124
- ${n} get_${r}(highp uint _instanceId, const uint idxOfArray) {
125
- return u_${r}${y};
143
+ ${r} get_${n}(highp uint _instanceId, const uint idxOfArray) {
144
+ return u_${n}${y};
126
145
  }
127
- `}return c}static getOffsetOfPropertyOfMaterial(t,e,i){return t.materialRepository.getLocationOffsetOfMemberOfMaterial(t,i,e)}static getOffsetOfPropertyOfGlobalDataRepository(t,e){return t.globalDataRepository.getLocationOffsetOfProperty(e)}$load(t){let e=t.mesh;return e==null?(ne.alertNoMeshSet(t),!1):(this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0),e.isSetUpDone()||(this.deleteDataTexture(),e._updateVBOAndVAO()),!0)}QI(){let t=U.getMorphUniformDataOffsets();for(let i=0;i<U.getPrimitiveCountHasMorph();i++){let n=U.getPrimitiveHasMorph(i);if(n!=null)for(let a=0;a<n.targets.length;a++){let r=n.targets[a].get(E.Position.XYZ),c=this.i.memoryManager.getByteOffsetOfExistingBuffers($.GPUVertexData,r.bufferView.buffer.indexOfTheBufferUsage);this.wI[t[i]+a]=(this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData+c+r.byteOffsetInBuffer)/4/4}else break}let e=t[t.length-1];this.i.webglResourceRepository.updateUniformBuffer(this.gI,this.wI,0,e)}common_$load(){this.TC()}TC(){let t=!1,e=U.getMorphUniformDataOffsets(),i=Math.max(Math.ceil(e[e.length-1]/4)*4*4,4);if(i!==this.PI){if(this.gI!==v.InvalidCGAPIResourceUid&&(this.i.webglResourceRepository.deleteUniformBuffer(this.gI),this.gI=v.InvalidCGAPIResourceUid),this.PI=i,this.gI===v.InvalidCGAPIResourceUid){let o=new Uint32Array(i);this.wI=o,this.gI=this.i.webglResourceRepository.createUniformBufferWithBufferView(o),this.QI()}this.PI=i,t=!0}let n=O.getOffsetsInUniform(this.i),a=Math.max(Math.ceil(n[n.length-1]/4)*4*4,4);if(a!==this.KI){if(this.yI!==v.InvalidCGAPIResourceUid&&(this.i.webglResourceRepository.deleteUniformBuffer(this.yI),this.yI=v.InvalidCGAPIResourceUid),this.yI===v.InvalidCGAPIResourceUid){let o=new Float32Array(a);this.OI=o,this.yI=this.i.webglResourceRepository.createUniformBufferWithBufferView(o),this._S()}this.KI=a,t=!0}t&&this.BC()}BC(){this.gI!==v.InvalidCGAPIResourceUid&&this.yI!==v.InvalidCGAPIResourceUid&&this.i.webglResourceRepository.setUniformBlockBindingForMorphOffsetsAndWeightsWithoutShaderProgram(this.gI,this.yI)}UC(){let t=U.getPrimitiveCountHasMorph();(t!==this.zI||this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData!==this.XI)&&(this.QI(),this.XI=this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData,this.zI=t)}GC(){this.__createAndUpdateDataTextureInner()}__createAndUpdateDataTextureInner(){let t=this.i.memoryManager,i=t.getSizesOfTheBuffers($.GPUInstanceData).reduce((c,s)=>c+s,0),n=t.getBuffers($.GPUInstanceData),a=n.length;a!==this.ZI&&(this.ZI=a,this.deleteDataTexture());let o=this.i.webglResourceRepository.currentWebGLContextWrapper;if(o==null)return;let r=o.getMaxTextureSize();if(this.__dataTextureUid!==v.InvalidCGAPIResourceUid){let c=i/4/4,s=Math.ceil(c/r),p=r*s*4*4,l=this.i.lightClusterSystem,d=l._getExcludedByteRanges(),m=0;for(let f=0;f<n.length;f++){let h=n[f],x=f===n.length-1?h.takenSizeInByte:h.byteLength;x>p&&ee.default.warn("The buffer size exceeds the size of the data texture.");let b=new Float32Array(h.getArrayBuffer());for(let[u,R]of se(m,m+Math.min(x,p),d))this.LS(b,m,u,R,r);B.DI||(oe.downloadTypedArray("Rhodonite_dataTextureBuffer.bin",b),B.DI=!0),m+=h.byteLength}for(let[f,h]of l._takeDirtyByteRanges()){let x=0;for(let b of n){let u=x+b.byteLength;if(f>=x&&h<=u){let R=new Float32Array(b.getArrayBuffer());this.LS(R,x,f,h,r);break}x=u}}}else{let c=t.getBuffers($.GPUVertexData),s=c.map(S=>S.getArrayBuffer()),p=r*4*4,l=n.map(S=>Math.ceil(S.byteLength/p)*p),d=l.reduce((S,M)=>S+M,0),m=c.reduce((S,M)=>S+M.byteLength,0),f=Math.max(Math.ceil((d+m)/p),1),h=this.i.config.isMultiDrawEnabled&&this.i.webglResourceRepository.isInstanceSidTextureCapable,x=this.i.webglResourceRepository.instanceSidTable,b=h?Math.max(x.usedEnd,1):0,u=h?Math.max(Math.ceil(b/r),1):0,R=h?Math.max(Math.ceil(Math.ceil(b/4)/r),1):0,C=f+u+R;this.SI=r,this.BI=f,this.UI=f+u,this.RI=this.BI*r,this.CI=this.UI*r,this.GI=b,h&&x.markAllDirty();let I=p*C,y=new Uint8Array(I),A=0;n.forEach((S,M)=>{y.set(new Uint8Array(S.getArrayBuffer(),0,S.takenSizeInByte),A),A+=l[M]}),c.forEach((S,M)=>{y.set(new Uint8Array(s[M],0,S.byteLength),A),A+=S.byteLength});let L=new Float32Array(y.buffer);this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData=d,this.__dataTextureUid=this.i.webglResourceRepository.createTextureFromTypedArray(L,{internalFormat:ae.RGBA32F,width:r,height:C,format:j.RGBA,type:T.Float,generateMipmap:!1}),this.i.lightClusterSystem._takeDirtyByteRanges()}}LS(t,e,i,n,a){let o=this.i.webglResourceRepository,r=Math.floor(i/16),c=Math.ceil(n/16),s=e/16,p=(l,d,m,f,h)=>{let x=(h-s)*4;o.updateTexture(this.__dataTextureUid,t.subarray(x,x+m*f*4),{level:0,offsetX:l,offsetY:d,width:m,height:f,format:j.RGBA,type:T.Float})};for(;r<c;){let l=r%a,d=Math.floor(r/a);if(l!==0||c-r<a){let m=Math.min(a-l,c-r);p(l,d,m,1,r),r+=m}else{let m=Math.floor((c-r)/a);p(0,d,a,m,r),r+=m*a}}}deleteDataTexture(){this.__dataTextureUid!=null&&(this.i.webglResourceRepository.deleteTexture(this.__dataTextureUid),this.__dataTextureUid=v.InvalidCGAPIResourceUid),this.GI=0,this.SI=0,this.II=v.InvalidCGAPIResourceUid}prerender(){if(this.i.config.isMultiDrawEnabled&&this.i.webglResourceRepository.isInstanceSidTextureCapable){let e=this.i.webglResourceRepository.instanceSidTable;this.__dataTextureUid!==v.InvalidCGAPIResourceUid&&e.usedEnd>this.GI&&this.deleteDataTexture()}(re.getIsAnimating(this.i)||Q.getUpdateCount(this.i)!==this.tr||J.getUpdateCount(this.i)!==this.YI||k.getCurrentCameraUpdateCount(this.i)!==this.kb||q(this.i)!==this.rr||this.i.materialRepository.stateVersion!==this.HI||this.i.lightClusterSystem.dataVersion!==this.jI||z.getUpdateCount(this.i)!==this.er||this.__dataTextureUid===v.InvalidCGAPIResourceUid)&&(this.GC(),this.DC(),this.tr=Q.getUpdateCount(this.i),this.YI=J.getUpdateCount(this.i),this.kb=k.getCurrentCameraUpdateCount(this.i),this.rr=q(this.i),this.HI=this.i.materialRepository.stateVersion,this.jI=this.i.lightClusterSystem.dataVersion,this.er=z.getUpdateCount(this.i)),(O.updateCount!==this.FI||O.getCountOfBlendShapeComponents(this.i)!==this.qI)&&(this._S(),this.FI=O.updateCount,this.qI=O.getCountOfBlendShapeComponents(this.i),this.i.materialRepository._makeShaderInvalidateToMorphMaterials()),this.UC(),this.EI=this.i.componentRepository.getComponentsWithType(z)}_S(){let e=this.i.memoryManager.getBuffer($.GPUVertexData);if(e==null||e.takenSizeInByte===0)return;let i=O.getOffsetsInUniform(this.i),n=this.i.componentRepository.getComponentsWithTypeWithoutFiltering(O);for(let a=0;a<n.length;a++){let o=n[a],r=o!=null?o.weights:[];for(let c=0;c<r.length;c++)this.OI[i[a]+c]=r[c]}if(n.length>0){let a=i[i.length-1];this.i.webglResourceRepository.updateUniformBuffer(this.yI,this.OI,0,a)}}wC(){return this.i.webglResourceRepository.currentWebGLContextWrapper.isWebGL2&&this.i.config.isUboEnabled}DC(){if(this.wC()){let t=this.i.webglResourceRepository.currentWebGLContextWrapper,e=t.getAlignedMaxUniformBlockSize(),i=t.getMaxConventionUniformBlocks(),a=this.i.memoryManager.getBuffer($.GPUInstanceData);if(this.bI===v.InvalidCGAPIResourceUid)this.bI=this.i.webglResourceRepository.setupUniformBufferDataArea(new Float32Array(a.getArrayBuffer()));else{let o=new Float32Array(a.getArrayBuffer());this.i.webglResourceRepository.updateUniformBuffer(this.bI,o,0,e*i/4)}}}attachGPUData(t){}attachGPUDataInner(t,e){}attachVertexData(t,e,i,n){}attachVertexDataInner(t,e,i,n,a){let o=this.i.webglResourceRepository.getWebGLResource(t.getVaoUids(i));if(o!=null)n.bindVertexArray(o);else{n.bindVertexArray(null);let r=e.vertexHandles;this.i.webglResourceRepository.setVertexDataToPipeline(r,e,t._variationVBOUid);let c=this.i.webglResourceRepository.getWebGLResource(r.iboHandle),s=n.getRawContext();s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,c)}}dettachVertexData(t){let e=t.getRawContext();t.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.bindBuffer(e.ARRAY_BUFFER,null)}static init(t){return new B(t)}zS(t,e,i){if(i){let n=-1,a=this.i._webXRSystemIfEnabled;a!=null&&a.isWebXRMode&&(a.isMultiView()?n=a._getCameraComponentSIDAt(0):n=a._getCameraComponentSIDAt(e)),this.xI._v[N.CameraComponentTID]=n}else{let n=t.cameraComponent;n==null&&(n=this.i.componentRepository.getComponent(k,k.getCurrent(this.i))),n?this.xI._v[N.CameraComponentTID]=n.componentSID:this.xI._v[N.CameraComponentTID]=-1}}HS(t,e,i){this.xI==null&&(this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0)),this.xI._v[0]=e.materialSID}OC(t,e,i){if(!this.i.config.isMultiDrawEnabled)return;let n=this.i.webglResourceRepository,a=n.currentWebGLContextWrapper;if(a==null||a.webgl2ExtMD==null)return;let o=n.instanceSidTable;if(!o.isSupported)return;let r=H._getInstanceCullingState(e),c=r!=null&&r.culledEntityCount>0;if(this.vI=c?0:1,!c){this.XS(o);return}let s=r.culledEntityStamp,p=r.cullTick,l=r.cullingId;for(let d=0;d<t.length;d++){let m=t[d];if(m===-1)continue;let f=i!=null?i[d]:U.getPrimitive(m);if(f==null)continue;let h=f.mesh;h==null||h._remapPrepassId===l||(h._remapPrepassId=l,h._packVisibleInstancesToVariationVBO(s,p))}this.XS(o)}XS(t){if(this.__dataTextureUid===v.InvalidCGAPIResourceUid||this.SI<=0)return;let e=t.usedEnd;if(e<=0){t.clearSidDirty(),t.clearRemapDirty();return}t.sidDirty&&(this.YS(this.BI,e,(i,n,a)=>t.writeSidTexels(i,n,a)),t.clearSidDirty()),t.remapDirty&&this.vI===0&&(this.YS(this.UI,Math.ceil(e/4),(i,n,a)=>t.writeRemapTexels(i,n,a)),t.clearRemapDirty())}YS(t,e,i){let n=this.SI,a=e,o=0,r=t;for(;a>0;){let c=Math.min(a,n),s=new Float32Array(c*4);i(s,o,c),this.i.webglResourceRepository.updateTexture(this.__dataTextureUid,s,{level:0,offsetX:0,offsetY:r,width:c,height:1,format:j.RGBA,type:T.Float}),a-=c,o+=c,r++}}common_$render(t,e,i,n){typeof spector!="undefined"&&spector.setMarker("| | WebGL2:common_$render#");let a=this.i.webglResourceRepository.currentWebGLContextWrapper,o=a.getRawContextAsWebGL2(),r=V.isVrMainPass(this.i,e),c=V.getDisplayCount(r,this.i._webXRSystemIfEnabled),s=e._lastPrimitiveUids===t?e._lastPrimitives:null;if(e.isBufferLessRenderingMode())return this.PC(o,e,r),o.depthMask(!0),!0;this.OC(t,e,s);let p=!1;return e._toRenderOpaquePrimitives&&(e.depthWriteMask||o.depthMask(!1),p=this.MI(t,s,e._lastOpaqueIndex,0,-1,a,e,r,c)||p),e._toRenderTranslucentPrimitives&&(p=this.MI(t,s,e._lastOpaqueIndex+1,e._lastTranslucentIndex,1,a,e,r,c)||p),e._toRenderBlendWithZWritePrimitives&&(p=this.MI(t,s,e._lastTranslucentIndex+1,e._lastBlendWithZWriteIndex,1,a,e,r,c)||p),e._toRenderBlendWithoutZWritePrimitives&&(o.depthMask(!1),p=this.MI(t,s,e._lastBlendWithZWriteIndex+1,e._lastBlendWithoutZWriteIndex,1,a,e,r,c)||p),o.depthMask(!0),this.dettachVertexData(a),this.IC=i,p}PC(t,e,i){let n=e.material,a=e._dummyPrimitiveForBufferLessRendering;Y(n,a,this);let o=n.getShaderProgramUid(a),r=this.i.webglResourceRepository.getWebGLResource(o);if(t.useProgram(r),this.II=o,this.bindDataTexture(t,r),this.HS(t,n,r),this.zS(e,0,i),this.ZS(t,r),this.KS(t,r),r.vrState!=null&&i){let s=this.i.globalDataRepository.getValue("vrState",0);s._v[0]=i?1:0,s._v[1]=0,r._gl.uniform2iv(r.vrState,s._v)}V.setWebGLParameters(this.i,n,t),n._setParametersToGpuWebGLWithOutInternalSetting({shaderProgram:r,firstTime:!0}),e.depthWriteMask?t.depthMask(!0):t.depthMask(!1),this.i.webglResourceRepository.setViewport(this.i,e.getViewport());let c=this.i.webglResourceRepository.currentWebGLContextWrapper;c!=null&&this.VI(c)&&(t.bindVertexArray(null),t.vertexAttribI4ui(E.MaterialSid.getAttributeSlot(),n.materialSID,0,0,0),t.vertexAttribI4ui(E.Instance.getAttributeSlot(),0,0,0,0),this.qS(t,r),this.JS(t,r)),t.drawArrays(e._primitiveModeForBufferLessRendering.index,0,e._drawVertexNumberForBufferLessRendering)}VI(t){return this.i.config.isMultiDrawEnabled&&t.webgl2ExtMD!=null&&this.i.webglResourceRepository.instanceSidTable.isSupported}VC(t,e,i){let n=E.MaterialSid.getAttributeSlot(),a=t._multiDrawGroup,o=i.getRawContextAsWebGL2();if(a==null||a.vertexHandles==null){o.vertexAttribI4ui(n,e.materialSID,0,0,0);return}let r=e===t.material,c=r?a.vertexHandles.vaoHandle:a.genericMaterialSidVaoHandle;if(c!=null){let s=this.i.webglResourceRepository.getWebGLResource(c);s!=null&&i.bindVertexArray(s)}r||o.vertexAttribI4ui(n,e.materialSID,0,0,0)}MI(t,e,i,n,a,o,r,c,s){let p=!c&&s===1&&this.i.config.isMultiDrawEnabled&&o.webgl2ExtMD!=null&&this.i.webglResourceRepository.isInstanceSidTextureCapable,l=!1;if(!p){for(let f=i;a>0?f<=n:f>=n;f+=a)l=this._I(t[f],o,r,c,s,void 0,e==null?void 0:e[f])||l;return l}let m=fe(i,n,a,f=>{let h=t[f];if(h===-1)return null;let x=e!=null?e[f]:U.getPrimitive(h);if(x==null||x._multiDrawGroup==null)return null;let b=r.getAppropriateMaterial(x);return b._materialContent.isMultiDrawCompatible?ce(x,b,le(x)):null},this.SC);for(let f=0;f<m.count;f++){let h=m.starts[f],x=m.counts[f];if(m.keys[f]===-1||x<2)for(let b=0;b<x;b++){let u=h+b*a;l=this._I(t[u],o,r,c,s,void 0,e==null?void 0:e[u])||l}else l=this.LC(t,e,h,x,a,o,r,s)||l}return l}LC(t,e,i,n,a,o,r,c){var S;let s=e!=null?e[i]:U.getPrimitive(t[i]);if(s==null||s._multiDrawGroup==null)return!1;let p=s.mesh,l={primitive:s,mesh:p,indexed:s.hasIndices(),mode:s.primitiveMode.index,indexBitSize:s.getRenderIndexBitSize(),count:0,offset:0,instanceCount:0};if(!this._I(t[i],o,r,!1,c,l,s)){let M=!1;for(let G=1;G<n;G++){let _=i+G*a;M=this._I(t[_],o,r,!1,c,void 0,e==null?void 0:e[_])||M}return M}let m=s._multiDrawGroup,f=m.counts,h=m.offsets,x=m.instanceCounts,b=m.firsts,u=m.vertexCounts,R=l.indexed,C=o.getRawContextAsWebGL2(),I=0;f[I]=l.count,h[I]=l.offset,b[I]=l.offset,u[I]=l.count,x[I]=l.instanceCount,I++;let y=H._getInstanceCullingState(r),A=y==null?void 0:y.culledEntityStamp,L=(S=y==null?void 0:y.cullTick)!=null?S:0;for(let M=1;M<n;M++){let G=i+M*a,_=e!=null?e[G]:U.getPrimitive(t[G]);if(_==null||_._multiDrawGroup!==m)continue;let W=r.getAppropriateMaterial(_);if(W.getShaderProgramUid(_)===-1&&Y(W,_,this),te(W,_))continue;let D=_.mesh._packVisibleInstancesToVariationVBO(A,L);if(D===0)continue;let w=_._multiDrawEntry;w!=null&&(f[I]=w.indexCount,h[I]=w.indexByteOffset,b[I]=w.vertexOffset,u[I]=w.vertexCount,x[I]=D,I++)}return I>=2?R?o.multiDrawElementsInstanced(l.mode,f,0,C.UNSIGNED_INT,h,0,x,0,I):o.multiDrawArraysInstanced(l.mode,b,0,u,0,x,0,I):I===1&&(R?C.drawElementsInstanced(l.mode,f[0],C.UNSIGNED_INT,h[0],x[0]):C.drawArraysInstanced(l.mode,b[0],u[0],x[0])),!0}_I(t,e,i,n,a,o,r){var I,y,A,L;let c=e.getRawContextAsWebGL2(),s=r!=null?r:U.getPrimitive(t);if(s==null)return!1;let p=s.mesh,l=p.meshEntitiesInner[0],d=i.getAppropriateMaterial(s);Y(d,s,this);let m=l.getMeshRenderer(),f=H._getInstanceCullingState(i),h=p._packVisibleInstancesToVariationVBO(f==null?void 0:f.culledEntityStamp,(I=f==null?void 0:f.cullTick)!=null?I:0);if(h===0)return!1;let x=p.getPrimitiveIndexInMesh(s);this.attachVertexDataInner(p,s,x,e,p._variationVBOUid),this.VI(e)&&this.VC(s,d,e);let b=!1,u=!1,R=d.getShaderProgramUid(s);if(R!==this.II||c.JA){if(te(d,s))return this.dettachVertexData(e),!1;let S=this.i.webglResourceRepository.getWebGLResource(R);c.useProgram(S),c.JA=!1,this.bindDataTexture(c,S),this.fI=S,b=!0,u=!0}((y=this.WI)==null?void 0:y.deref())!==d&&(u=!0,this.WI=new WeakRef(d)),this.$I!==d.stateVersion&&(u=!0,this.$I=d.stateVersion),this.VI(e)&&this.fI!=null&&(this.qS(c,this.fI),this.JS(c,this.fI));let C={glw:e,entity:l,worldMatrix:l.getSceneGraph().matrixInner,normalMatrix:l.getSceneGraph().normalMatrixInner,isBillboard:l.getSceneGraph().isBillboard,isVisible:l.getSceneGraph().isVisible,lightComponents:this.EI,renderPass:i,primitive:s,diffuseCube:m.diffuseCubeMap,specularCube:m.specularCubeMap,sheenCube:m.sheenCubeMap,isVr:n,displayIdx:-1};b&&d._setParametersToGpuWebGLPerShaderProgram({engine:this.i,material:d,shaderProgram:this.fI,firstTime:b,args:C}),u&&(this.HS(c,d,this.fI),V.setWebGLParameters(this.i,d,c),d._setParametersToGpuWebGL({engine:this.i,material:d,shaderProgram:this.fI,firstTime:u,args:C})),d._setParametersToGpuWebGLPerPrimitive({material:d,shaderProgram:this.fI,firstTime:u,args:C});for(let S=0;S<a;S++){if(n&&V.setVRViewport(this.i,i,S),this.zS(i,S,n),this.ZS(c,this.fI),this.KS(c,this.fI),this.fI.vrState!=null&&n&&a>1){let F=this.i.globalDataRepository.getValue("vrState",0);F._v[0]=n?1:0,F._v[1]=S,this.fI._gl.uniform2iv(this.fI.vrState,F._v)}this.i.config.isMultiDrawEnabled&&e.webgl2ExtMD!=null&&this.i.webglResourceRepository.instanceSidTable.isSupported&&s._multiDrawGroup==null&&c.vertexAttribI4ui(E.Instance.getAttributeSlot(),Math.max(0,p._instanceSidBase),0,0,0);let G=s.indicesAccessor,_=G!=null,W=s.getRenderIndexBitSize(),Z=W==="uint32"?c.UNSIGNED_INT:c.UNSIGNED_SHORT,D=s._multiDrawEntry,w=(A=D==null?void 0:D.indexByteOffset)!=null?A:0,K=(L=D==null?void 0:D.vertexOffset)!=null?L:0;o!=null?(o.primitive=s,o.mesh=p,o.indexed=_,o.mode=s.primitiveMode.index,o.indexBitSize=W,o.count=_?G.elementCount:s.getVertexCountAsVerticesBased(),o.offset=_?w:K,o.instanceCount=h):_?c.drawElementsInstanced(s.primitiveMode.index,G.elementCount,Z,w,h):c.drawArraysInstanced(s.primitiveMode.index,K,s.getVertexCountAsVerticesBased(),h)}return this.II=R,!0}KS(t,e){let i=e,n=i.lightClusterView;if(n==null)return;let a=this.xI._v[N.CameraComponentTID],o=this.i.lightClusterSystem,r=o.dataVersion;i._lightClusterViewCameraSid===a&&i._lightClusterViewVersion===r||(t.uniform4fv(n,o._getViewUniformData(a)),i._lightClusterViewCameraSid=a,i._lightClusterViewVersion=r)}ZS(t,e){let i=this.xI._v,n=this.NI;if(this.kI===e&&n!=null&&n.length===i.length){let a=!0;for(let o=0;o<i.length;o++)if(n[o]!==i[o]){a=!1;break}if(a)return}t.uniform1fv(e.currentComponentSIDs,i),(n==null||n.length!==i.length)&&(n=new Float32Array(i.length),this.NI=n),n.set(i),this.kI=e}bindDataTexture(t,e){t.uniform1i(e.dataTexture,0),this.i.webglResourceRepository.bindTexture2D(0,this.__dataTextureUid);let i=this.i.webglResourceRepository.createOrGetTextureSamplerRepeatNearest();this.i.webglResourceRepository.bindTextureSampler(0,i),this.bindInstanceSidTextures(t,e)}bindInstanceSidTextures(t,e){let i=this.i.webglResourceRepository,n=i.currentWebGLContextWrapper;if(n==null||n.webgl2ExtMD==null||!this.i.config.isMultiDrawEnabled||!i.instanceSidTable.isSupported)return;let o=e;o.WC===void 0&&(o.AI=t.getUniformLocation(e,"u_instanceSidDataTextureIndex"),o.LI=t.getUniformLocation(e,"u_instanceRemapDataTextureIndex"),o.TI=t.getUniformLocation(e,"u_instanceRemapIdentity"),o.WC=null),o.AI!=null&&(t.uniform1i(o.AI,this.RI),o.QS=this.RI),o.LI!=null&&(t.uniform1i(o.LI,this.CI),o.xC=this.CI),o.TI!=null&&(t.uniform1i(o.TI,this.vI),o.vC=this.vI)}JS(t,e){let i=e;if(i.AI==null)return;let n=this.RI;i.QS!==n&&(t.uniform1i(i.AI,n),i.QS=n);let a=this.CI;i.xC!==a&&(t.uniform1i(i.LI,a),i.xC=a)}qS(t,e){let i=e;if(i.TI==null)return;let n=this.vI;i.vC!==n&&(t.uniform1i(i.TI,n),i.vC=n)}destroy(){let t=this.i.webglResourceRepository;this.__dataTextureUid!==v.InvalidCGAPIResourceUid&&(t.deleteTexture(this.__dataTextureUid),this.__dataTextureUid=v.InvalidCGAPIResourceUid),this.bI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.bI),this.bI=v.InvalidCGAPIResourceUid),this.gI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.gI),this.gI=v.InvalidCGAPIResourceUid),this.yI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.yI),this.yI=v.InvalidCGAPIResourceUid)}};B.DI=!0;var ie=B;export{ie as WebGLStrategyWebGL2};
146
+ `}return c}static getOffsetOfPropertyOfMaterial(t,e,i){return t.materialRepository.getLocationOffsetOfMemberOfMaterial(t,i,e)}static getOffsetOfPropertyOfGlobalDataRepository(t,e){return t.globalDataRepository.getLocationOffsetOfProperty(e)}$load(t){let e=t.mesh;return e==null?(ne.alertNoMeshSet(t),!1):(this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0),e.isSetUpDone()||(this.deleteDataTexture(),e._updateVBOAndVAO()),!0)}zS(){let t=U.getMorphUniformDataOffsets();for(let i=0;i<U.getPrimitiveCountHasMorph();i++){let r=U.getPrimitiveHasMorph(i);if(r!=null)for(let a=0;a<r.targets.length;a++){let n=r.targets[a].get(E.Position.XYZ),c=this.i.memoryManager.getByteOffsetOfExistingBuffers($.GPUVertexData,n.bufferView.buffer.indexOfTheBufferUsage);this.wI[t[i]+a]=(this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData+c+n.byteOffsetInBuffer)/4/4}else break}let e=t[t.length-1];this.i.webglResourceRepository.updateUniformBuffer(this.gI,this.wI,0,e)}common_$load(){this.U_()}U_(){let t=!1,e=U.getMorphUniformDataOffsets(),i=Math.max(Math.ceil(e[e.length-1]/4)*4*4,4);if(i!==this.VI){if(this.gI!==v.InvalidCGAPIResourceUid&&(this.i.webglResourceRepository.deleteUniformBuffer(this.gI),this.gI=v.InvalidCGAPIResourceUid),this.VI=i,this.gI===v.InvalidCGAPIResourceUid){let a=new Uint32Array(i);this.wI=a,this.gI=this.i.webglResourceRepository.createUniformBufferWithBufferView(a),this.zS()}this.VI=i,t=!0}let r=G._getMorphWeightsUniformBufferFloatCount(this.i);if(r!==this.JI){if(this.yI!==v.InvalidCGAPIResourceUid&&(this.i.webglResourceRepository.deleteUniformBuffer(this.yI),this.yI=v.InvalidCGAPIResourceUid),this.yI===v.InvalidCGAPIResourceUid){let a=new Float32Array(r);this.II=a,this.yI=this.i.webglResourceRepository.createUniformBufferWithBufferView(a),this.HS(!0)}this.JI=r,t=!0}t&&this.D_()}D_(){this.gI!==v.InvalidCGAPIResourceUid&&this.yI!==v.InvalidCGAPIResourceUid&&this.i.webglResourceRepository.setUniformBlockBindingForMorphOffsetsAndWeightsWithoutShaderProgram(this.gI,this.yI)}P_(){let t=U.getPrimitiveCountHasMorph();(t!==this.HI||this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData!==this.ZI)&&(this.zS(),this.ZI=this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData,this.HI=t)}G_(){this.__createAndUpdateDataTextureInner()}__createAndUpdateDataTextureInner(){let t=this.i.memoryManager,i=t.getSizesOfTheBuffers($.GPUInstanceData).reduce((c,s)=>c+s,0),r=t.getBuffers($.GPUInstanceData),a=r.length;a!==this.qI&&(this.qI=a,this.deleteDataTexture());let o=this.i.webglResourceRepository.currentWebGLContextWrapper;if(o==null)return;let n=o.getMaxTextureSize();if(this.__dataTextureUid!==v.InvalidCGAPIResourceUid){let c=i/4/4,s=Math.ceil(c/n),p=n*s*4*4,l=this.i.lightClusterSystem,d=l._getExcludedByteRanges(),m=0;for(let f=0;f<r.length;f++){let h=r[f],x=f===r.length-1?h.takenSizeInByte:h.byteLength;x>p&&ee.default.warn("The buffer size exceeds the size of the data texture.");let b=new Float32Array(h.getArrayBuffer());for(let[u,R]of se(m,m+Math.min(x,p),d))this.XS(b,m,u,R,n);B.GI||(oe.downloadTypedArray("Rhodonite_dataTextureBuffer.bin",b),B.GI=!0),m+=h.byteLength}for(let[f,h]of l._takeDirtyByteRanges()){let x=0;for(let b of r){let u=x+b.byteLength;if(f>=x&&h<=u){let R=new Float32Array(b.getArrayBuffer());this.XS(R,x,f,h,n);break}x=u}}}else{let c=t.getBuffers($.GPUVertexData),s=c.map(S=>S.getArrayBuffer()),p=n*4*4,l=r.map(S=>Math.ceil(S.byteLength/p)*p),d=l.reduce((S,M)=>S+M,0),m=c.reduce((S,M)=>S+M.byteLength,0),f=Math.max(Math.ceil((d+m)/p),1),h=this.i.config.isMultiDrawEnabled&&this.i.webglResourceRepository.isInstanceSidTextureCapable,x=this.i.webglResourceRepository.instanceSidTable,b=h?Math.max(x.usedEnd,1):0,u=h?Math.max(Math.ceil(b/n),1):0,R=h?Math.max(Math.ceil(Math.ceil(b/4)/n),1):0,_=f+u+R;this.RI=n,this.UI=f,this.DI=f+u,this._I=this.UI*n,this.MI=this.DI*n,this.PI=b,h&&x.markAllDirty();let I=p*_,y=new Uint8Array(I),A=0;r.forEach((S,M)=>{y.set(new Uint8Array(S.getArrayBuffer(),0,S.takenSizeInByte),A),A+=l[M]}),c.forEach((S,M)=>{y.set(new Uint8Array(s[M],0,S.byteLength),A),A+=S.byteLength});let W=new Float32Array(y.buffer);this.i.engineState.totalSizeOfGPUShaderDataStorageExceptMorphData=d,this.__dataTextureUid=this.i.webglResourceRepository.createTextureFromTypedArray(W,{internalFormat:ae.RGBA32F,width:n,height:_,format:j.RGBA,type:T.Float,generateMipmap:!1}),this.i.lightClusterSystem._takeDirtyByteRanges()}}XS(t,e,i,r,a){let o=this.i.webglResourceRepository,n=Math.floor(i/16),c=Math.ceil(r/16),s=e/16,p=(l,d,m,f,h)=>{let x=(h-s)*4;o.updateTexture(this.__dataTextureUid,t.subarray(x,x+m*f*4),{level:0,offsetX:l,offsetY:d,width:m,height:f,format:j.RGBA,type:T.Float})};for(;n<c;){let l=n%a,d=Math.floor(n/a);if(l!==0||c-n<a){let m=Math.min(a-l,c-n);p(l,d,m,1,n),n+=m}else{let m=Math.floor((c-n)/a);p(0,d,a,m,n),n+=m*a}}}deleteDataTexture(){this.__dataTextureUid!=null&&(this.i.webglResourceRepository.deleteTexture(this.__dataTextureUid),this.__dataTextureUid=v.InvalidCGAPIResourceUid),this.PI=0,this.RI=0,this.SI=v.InvalidCGAPIResourceUid}prerender(){if(this.i.config.isMultiDrawEnabled&&this.i.webglResourceRepository.isInstanceSidTextureCapable){let e=this.i.webglResourceRepository.instanceSidTable;this.__dataTextureUid!==v.InvalidCGAPIResourceUid&&e.usedEnd>this.PI&&this.deleteDataTexture()}(re.getIsAnimating(this.i)||Q.getUpdateCount(this.i)!==this.nr||J.getUpdateCount(this.i)!==this.KI||k.getCurrentCameraUpdateCount(this.i)!==this.dC||q(this.i)!==this.sr||this.i.materialRepository.stateVersion!==this.jI||this.i.lightClusterSystem.dataVersion!==this.XI||z.getUpdateCount(this.i)!==this.or||this.i._gpuInstanceDataVersion!==this.YI||this.__dataTextureUid===v.InvalidCGAPIResourceUid)&&(this.G_(),this.w_(),this.nr=Q.getUpdateCount(this.i),this.KI=J.getUpdateCount(this.i),this.dC=k.getCurrentCameraUpdateCount(this.i),this.sr=q(this.i),this.jI=this.i.materialRepository.stateVersion,this.XI=this.i.lightClusterSystem.dataVersion,this.or=z.getUpdateCount(this.i),this.YI=this.i._gpuInstanceDataVersion),G.updateCount!==this.zI||G.getCountOfBlendShapeComponents(this.i)!==this.QI?(this.HS(),this.zI=G.updateCount,this.QI=G.getCountOfBlendShapeComponents(this.i),this.i.materialRepository._makeShaderInvalidateToMorphMaterials()):this.O_(),this.P_(),this.kI=this.i.componentRepository.getComponentsWithType(z)}HS(t=!1){let i=this.i.memoryManager.getBuffer($.GPUVertexData);if(i==null||i.takenSizeInByte===0)return;let r=G._writeMorphWeightsUniformArray(this.i,this.II,t);this.OI=!1,r>0&&this.YS(r)}YS(t){this.i.webglResourceRepository.updateUniformBuffer(this.yI,this.II,0,t)}O_(){if(this.OI||this.II==null)return;this.OI=!0;let t=G._settlePreviousMorphWeights(this.i,this.II);t>0&&this.YS(t)}V_(){return this.i.webglResourceRepository.currentWebGLContextWrapper.isWebGL2&&this.i.config.isUboEnabled}w_(){if(this.V_()){let t=this.i.webglResourceRepository.currentWebGLContextWrapper,e=t.getAlignedMaxUniformBlockSize(),i=t.getMaxConventionUniformBlocks(),a=this.i.memoryManager.getBuffer($.GPUInstanceData);if(this.bI===v.InvalidCGAPIResourceUid)this.bI=this.i.webglResourceRepository.setupUniformBufferDataArea(new Float32Array(a.getArrayBuffer()));else{let o=new Float32Array(a.getArrayBuffer());this.i.webglResourceRepository.updateUniformBuffer(this.bI,o,0,e*i/4)}}}attachGPUData(t){}attachGPUDataInner(t,e){}attachVertexData(t,e,i,r){}attachVertexDataInner(t,e,i,r,a){let o=this.i.webglResourceRepository.getWebGLResource(t.getVaoUids(i));if(o!=null)r.bindVertexArray(o);else{r.bindVertexArray(null);let n=e.vertexHandles;this.i.webglResourceRepository.setVertexDataToPipeline(n,e,t._variationVBOUid);let c=this.i.webglResourceRepository.getWebGLResource(n.iboHandle),s=r.getRawContext();s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,c)}}dettachVertexData(t){let e=t.getRawContext();t.bindVertexArray(null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.bindBuffer(e.ARRAY_BUFFER,null)}static init(t){return new B(t)}ZS(t,e,i){if(i){let r=-1,a=this.i._webXRSystemIfEnabled;a!=null&&a.isWebXRMode&&(a.isMultiView()?r=a._getCameraComponentSIDAt(0):r=a._getCameraComponentSIDAt(e)),this.xI._v[N.CameraComponentTID]=r}else{let r=t.cameraComponent;r==null&&(r=this.i.componentRepository.getComponent(k,k.getCurrent(this.i))),r?this.xI._v[N.CameraComponentTID]=r.componentSID:this.xI._v[N.CameraComponentTID]=-1}}KS(t,e,i){this.xI==null&&(this.xI=this.i.globalDataRepository.getValue("currentComponentSIDs",0)),this.xI._v[0]=e.materialSID}W_(t,e,i){if(!this.i.config.isMultiDrawEnabled)return;let r=this.i.webglResourceRepository,a=r.currentWebGLContextWrapper;if(a==null||a.webgl2ExtMD==null)return;let o=r.instanceSidTable;if(!o.isSupported)return;let n=H._getInstanceCullingState(e),c=n!=null&&n.culledEntityCount>0;if(this.vI=c?0:1,!c){this.qS(o);return}let s=n.culledEntityStamp,p=n.cullTick,l=n.cullingId;for(let d=0;d<t.length;d++){let m=t[d];if(m===-1)continue;let f=i!=null?i[d]:U.getPrimitive(m);if(f==null)continue;let h=f.mesh;h==null||h._remapPrepassId===l||(h._remapPrepassId=l,h._packVisibleInstancesToVariationVBO(s,p))}this.qS(o)}qS(t){if(this.__dataTextureUid===v.InvalidCGAPIResourceUid||this.RI<=0)return;let e=t.usedEnd;if(e<=0){t.clearSidDirty(),t.clearRemapDirty();return}t.sidDirty&&(this.JS(this.UI,e,(i,r,a)=>t.writeSidTexels(i,r,a)),t.clearSidDirty()),t.remapDirty&&this.vI===0&&(this.JS(this.DI,Math.ceil(e/4),(i,r,a)=>t.writeRemapTexels(i,r,a)),t.clearRemapDirty())}JS(t,e,i){let r=this.RI,a=e,o=0,n=t;for(;a>0;){let c=Math.min(a,r),s=new Float32Array(c*4);i(s,o,c),this.i.webglResourceRepository.updateTexture(this.__dataTextureUid,s,{level:0,offsetX:0,offsetY:n,width:c,height:1,format:j.RGBA,type:T.Float}),a-=c,o+=c,n++}}common_$render(t,e,i,r){typeof spector!="undefined"&&spector.setMarker("| | WebGL2:common_$render#");let a=this.i.webglResourceRepository.currentWebGLContextWrapper,o=a.getRawContextAsWebGL2(),n=V.isVrMainPass(this.i,e),c=V.getDisplayCount(n,this.i._webXRSystemIfEnabled),s=e._lastPrimitiveUids===t?e._lastPrimitives:null;if(e.isBufferLessRenderingMode())return this.L_(o,e,n),o.depthMask(!0),!0;this.W_(t,e,s);let p=!1;return e._toRenderOpaquePrimitives&&(e.depthWriteMask||o.depthMask(!1),p=this.CI(t,s,e._lastOpaqueIndex,0,-1,a,e,n,c)||p),e._toRenderTranslucentPrimitives&&(p=this.CI(t,s,e._lastOpaqueIndex+1,e._lastTranslucentIndex,1,a,e,n,c)||p),e._toRenderBlendWithZWritePrimitives&&(p=this.CI(t,s,e._lastTranslucentIndex+1,e._lastBlendWithZWriteIndex,1,a,e,n,c)||p),e._toRenderBlendWithoutZWritePrimitives&&(o.depthMask(!1),p=this.CI(t,s,e._lastBlendWithZWriteIndex+1,e._lastBlendWithoutZWriteIndex,1,a,e,n,c)||p),o.depthMask(!0),this.dettachVertexData(a),this.S_=i,p}L_(t,e,i){let r=e.material,a=e._dummyPrimitiveForBufferLessRendering;Y(r,a,this);let o=r.getShaderProgramUid(a),n=this.i.webglResourceRepository.getWebGLResource(o);if(t.useProgram(n),this.SI=o,this.bindDataTexture(t,n),this.KS(t,r,n),this.ZS(e,0,i),this.QS(t,n),this.l_(t,n),n.vrState!=null&&i){let s=this.i.globalDataRepository.getValue("vrState",0);s._v[0]=i?1:0,s._v[1]=0,n._gl.uniform2iv(n.vrState,s._v)}V.setWebGLParameters(this.i,r,t),r._setParametersToGpuWebGLWithOutInternalSetting({shaderProgram:n,firstTime:!0}),e.depthWriteMask?t.depthMask(!0):t.depthMask(!1),this.i.webglResourceRepository.setViewport(this.i,e.getViewport());let c=this.i.webglResourceRepository.currentWebGLContextWrapper;c!=null&&this.WI(c)&&(t.bindVertexArray(null),t.vertexAttribI4ui(E.MaterialSid.getAttributeSlot(),r.materialSID,0,0,0),t.vertexAttribI4ui(E.Instance.getAttributeSlot(),0,0,0,0),this.d_(t,n),this.g_(t,n)),t.drawArrays(e._primitiveModeForBufferLessRendering.index,0,e._drawVertexNumberForBufferLessRendering)}WI(t){return this.i.config.isMultiDrawEnabled&&t.webgl2ExtMD!=null&&this.i.webglResourceRepository.instanceSidTable.isSupported}$_(t,e,i){let r=E.MaterialSid.getAttributeSlot(),a=t._multiDrawGroup,o=i.getRawContextAsWebGL2();if(a==null||a.vertexHandles==null){o.vertexAttribI4ui(r,e.materialSID,0,0,0);return}let n=e===t.material,c=n?a.vertexHandles.vaoHandle:a.genericMaterialSidVaoHandle;if(c!=null){let s=this.i.webglResourceRepository.getWebGLResource(c);s!=null&&i.bindVertexArray(s)}n||o.vertexAttribI4ui(r,e.materialSID,0,0,0)}CI(t,e,i,r,a,o,n,c,s){let p=!c&&s===1&&this.i.config.isMultiDrawEnabled&&o.webgl2ExtMD!=null&&this.i.webglResourceRepository.isInstanceSidTextureCapable,l=!1;if(!p){for(let f=i;a>0?f<=r:f>=r;f+=a)l=this.AI(t[f],o,n,c,s,void 0,e==null?void 0:e[f])||l;return l}let m=fe(i,r,a,f=>{let h=t[f];if(h===-1)return null;let x=e!=null?e[f]:U.getPrimitive(h);if(x==null||x._multiDrawGroup==null)return null;let b=n.getAppropriateMaterial(x);return b._materialContent.isMultiDrawCompatible?ce(x,b,le(x)):null},this.M_);for(let f=0;f<m.count;f++){let h=m.starts[f],x=m.counts[f];if(m.keys[f]===-1||x<2)for(let b=0;b<x;b++){let u=h+b*a;l=this.AI(t[u],o,n,c,s,void 0,e==null?void 0:e[u])||l}else l=this.k_(t,e,h,x,a,o,n,s)||l}return l}k_(t,e,i,r,a,o,n,c){var S;let s=e!=null?e[i]:U.getPrimitive(t[i]);if(s==null||s._multiDrawGroup==null)return!1;let p=s.mesh,l={primitive:s,mesh:p,indexed:s.hasIndices(),mode:s.primitiveMode.index,indexBitSize:s.getRenderIndexBitSize(),count:0,offset:0,instanceCount:0};if(!this.AI(t[i],o,n,!1,c,l,s)){let M=!1;for(let D=1;D<r;D++){let C=i+D*a;M=this.AI(t[C],o,n,!1,c,void 0,e==null?void 0:e[C])||M}return M}let m=s._multiDrawGroup,f=m.counts,h=m.offsets,x=m.instanceCounts,b=m.firsts,u=m.vertexCounts,R=l.indexed,_=o.getRawContextAsWebGL2(),I=0;f[I]=l.count,h[I]=l.offset,b[I]=l.offset,u[I]=l.count,x[I]=l.instanceCount,I++;let y=H._getInstanceCullingState(n),A=y==null?void 0:y.culledEntityStamp,W=(S=y==null?void 0:y.cullTick)!=null?S:0;for(let M=1;M<r;M++){let D=i+M*a,C=e!=null?e[D]:U.getPrimitive(t[D]);if(C==null||C._multiDrawGroup!==m)continue;let L=n.getAppropriateMaterial(C);if(L.getShaderProgramUid(C)===-1&&Y(L,C,this),te(L,C))continue;let P=C.mesh._packVisibleInstancesToVariationVBO(A,W);if(P===0)continue;let w=C._multiDrawEntry;w!=null&&(f[I]=w.indexCount,h[I]=w.indexByteOffset,b[I]=w.vertexOffset,u[I]=w.vertexCount,x[I]=P,I++)}return I>=2?R?o.multiDrawElementsInstanced(l.mode,f,0,_.UNSIGNED_INT,h,0,x,0,I):o.multiDrawArraysInstanced(l.mode,b,0,u,0,x,0,I):I===1&&(R?_.drawElementsInstanced(l.mode,f[0],_.UNSIGNED_INT,h[0],x[0]):_.drawArraysInstanced(l.mode,b[0],u[0],x[0])),!0}AI(t,e,i,r,a,o,n){var I,y,A,W;let c=e.getRawContextAsWebGL2(),s=n!=null?n:U.getPrimitive(t);if(s==null)return!1;let p=s.mesh,l=p.meshEntitiesInner[0],d=i.getAppropriateMaterial(s);Y(d,s,this);let m=l.getMeshRenderer(),f=H._getInstanceCullingState(i),h=p._packVisibleInstancesToVariationVBO(f==null?void 0:f.culledEntityStamp,(I=f==null?void 0:f.cullTick)!=null?I:0);if(h===0)return!1;let x=p.getPrimitiveIndexInMesh(s);this.attachVertexDataInner(p,s,x,e,p._variationVBOUid),this.WI(e)&&this.$_(s,d,e);let b=!1,u=!1,R=d.getShaderProgramUid(s);if(R!==this.SI||c.JA){if(te(d,s))return this.dettachVertexData(e),!1;let S=this.i.webglResourceRepository.getWebGLResource(R);c.useProgram(S),c.JA=!1,this.bindDataTexture(c,S),this.fI=S,b=!0,u=!0}((y=this.$I)==null?void 0:y.deref())!==d&&(u=!0,this.$I=new WeakRef(d)),this.EI!==d.stateVersion&&(u=!0,this.EI=d.stateVersion),this.WI(e)&&this.fI!=null&&(this.d_(c,this.fI),this.g_(c,this.fI));let _={glw:e,entity:l,worldMatrix:l.getSceneGraph().matrixInner,normalMatrix:l.getSceneGraph().normalMatrixInner,isBillboard:l.getSceneGraph().isBillboard,isVisible:l.getSceneGraph().isVisible,lightComponents:this.kI,renderPass:i,primitive:s,diffuseCube:m.diffuseCubeMap,specularCube:m.specularCubeMap,sheenCube:m.sheenCubeMap,isVr:r,displayIdx:-1};b&&d._setParametersToGpuWebGLPerShaderProgram({engine:this.i,material:d,shaderProgram:this.fI,firstTime:b,args:_}),u&&(this.KS(c,d,this.fI),V.setWebGLParameters(this.i,d,c),d._setParametersToGpuWebGL({engine:this.i,material:d,shaderProgram:this.fI,firstTime:u,args:_})),d._setParametersToGpuWebGLPerPrimitive({material:d,shaderProgram:this.fI,firstTime:u,args:_});for(let S=0;S<a;S++){if(r&&V.setVRViewport(this.i,i,S),this.ZS(i,S,r),this.QS(c,this.fI),this.l_(c,this.fI),this.fI.vrState!=null&&r&&a>1){let F=this.i.globalDataRepository.getValue("vrState",0);F._v[0]=r?1:0,F._v[1]=S,this.fI._gl.uniform2iv(this.fI.vrState,F._v)}this.i.config.isMultiDrawEnabled&&e.webgl2ExtMD!=null&&this.i.webglResourceRepository.instanceSidTable.isSupported&&s._multiDrawGroup==null&&c.vertexAttribI4ui(E.Instance.getAttributeSlot(),Math.max(0,p._instanceSidBase),0,0,0);let D=s.indicesAccessor,C=D!=null,L=s.getRenderIndexBitSize(),Z=L==="uint32"?c.UNSIGNED_INT:c.UNSIGNED_SHORT,P=s._multiDrawEntry,w=(A=P==null?void 0:P.indexByteOffset)!=null?A:0,K=(W=P==null?void 0:P.vertexOffset)!=null?W:0;o!=null?(o.primitive=s,o.mesh=p,o.indexed=C,o.mode=s.primitiveMode.index,o.indexBitSize=L,o.count=C?D.elementCount:s.getVertexCountAsVerticesBased(),o.offset=C?w:K,o.instanceCount=h):C?c.drawElementsInstanced(s.primitiveMode.index,D.elementCount,Z,w,h):c.drawArraysInstanced(s.primitiveMode.index,K,s.getVertexCountAsVerticesBased(),h)}return this.SI=R,!0}l_(t,e){let i=e,r=i.lightClusterView;if(r==null)return;let a=this.xI._v[N.CameraComponentTID],o=this.i.lightClusterSystem,n=o.dataVersion;i._lightClusterViewCameraSid===a&&i._lightClusterViewVersion===n||(t.uniform4fv(r,o._getViewUniformData(a)),i._lightClusterViewCameraSid=a,i._lightClusterViewVersion=n)}QS(t,e){let i=this.xI._v,r=this.FI;if(this.NI===e&&r!=null&&r.length===i.length){let a=!0;for(let o=0;o<i.length;o++)if(r[o]!==i[o]){a=!1;break}if(a)return}t.uniform1fv(e.currentComponentSIDs,i),(r==null||r.length!==i.length)&&(r=new Float32Array(i.length),this.FI=r),r.set(i),this.NI=e}bindDataTexture(t,e){t.uniform1i(e.dataTexture,0),this.i.webglResourceRepository.bindTexture2D(0,this.__dataTextureUid);let i=this.i.webglResourceRepository.createOrGetTextureSamplerRepeatNearest();this.i.webglResourceRepository.bindTextureSampler(0,i),this.bindInstanceSidTextures(t,e)}bindInstanceSidTextures(t,e){let i=this.i.webglResourceRepository,r=i.currentWebGLContextWrapper;if(r==null||r.webgl2ExtMD==null||!this.i.config.isMultiDrawEnabled||!i.instanceSidTable.isSupported)return;let o=e;o.N_===void 0&&(o.TI=t.getUniformLocation(e,"u_instanceSidDataTextureIndex"),o.LI=t.getUniformLocation(e,"u_instanceRemapDataTextureIndex"),o.BI=t.getUniformLocation(e,"u_instanceRemapIdentity"),o.N_=null),o.TI!=null&&(t.uniform1i(o.TI,this._I),o.y_=this._I),o.LI!=null&&(t.uniform1i(o.LI,this.MI),o.x_=this.MI),o.BI!=null&&(t.uniform1i(o.BI,this.vI),o.I_=this.vI)}g_(t,e){let i=e;if(i.TI==null)return;let r=this._I;i.y_!==r&&(t.uniform1i(i.TI,r),i.y_=r);let a=this.MI;i.x_!==a&&(t.uniform1i(i.LI,a),i.x_=a)}d_(t,e){let i=e;if(i.BI==null)return;let r=this.vI;i.I_!==r&&(t.uniform1i(i.BI,r),i.I_=r)}destroy(){let t=this.i.webglResourceRepository;this.__dataTextureUid!==v.InvalidCGAPIResourceUid&&(t.deleteTexture(this.__dataTextureUid),this.__dataTextureUid=v.InvalidCGAPIResourceUid),this.bI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.bI),this.bI=v.InvalidCGAPIResourceUid),this.gI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.gI),this.gI=v.InvalidCGAPIResourceUid),this.yI!==v.InvalidCGAPIResourceUid&&(t.deleteUniformBuffer(this.yI),this.yI=v.InvalidCGAPIResourceUid)}};B.GI=!0;var ie=B;export{ie as WebGLStrategyWebGL2};
@@ -13,9 +13,6 @@ var t=`
13
13
  uniform float u_pointSize; // initialValue=30
14
14
  uniform vec3 u_pointDistanceAttenuation; // initialValue=(0,0.1,0.01)
15
15
 
16
- // BiasMatrix * LightProjectionMatrix * LightViewMatrix, See: http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-16-shadow-mapping/#basic-shader
17
- uniform mat4 u_depthBiasPV; // initialValue=(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)
18
-
19
16
  #ifdef RN_IS_MORPHING
20
17
  uniform int u_currentPrimitiveIdx; // initialValue=0, isInternalSetting=true, soloDatum=false, needUniformInDataTextureMode=true
21
18
  #endif
@@ -0,0 +1,35 @@
1
+ var i=`
2
+
3
+ /* shaderity: @{glslPrecision} */
4
+
5
+ /* shaderity: @{definitions} */
6
+
7
+ /* shaderity: @{prerequisites} */
8
+
9
+ /* shaderity: @{vertexIn} */
10
+
11
+ in vec4 v_currentPosition_inClip;
12
+ in vec4 v_previousPosition_inClip;
13
+
14
+ /* shaderity: @{renderTargetBegin} */
15
+
16
+ /* shaderity: @{getters} */
17
+
18
+
19
+ void main (){
20
+
21
+ /* shaderity: @{mainPrerequisites} */
22
+
23
+ // The motion from the previous frame in texture coordinates. In WebGL, the texture coordinates of a
24
+ // render target have the same orientation as NDC (both y up), so the NDC motion is halved.
25
+ vec2 velocity = vec2(2.0, 2.0); // moves the history lookup off screen, i.e. rejects the history
26
+ if (v_previousPosition_inClip.w > 0.0) {
27
+ vec2 currentNdc = v_currentPosition_inClip.xy / v_currentPosition_inClip.w;
28
+ vec2 previousNdc = v_previousPosition_inClip.xy / v_previousPosition_inClip.w;
29
+ velocity = (currentNdc - previousNdc) * 0.5;
30
+ }
31
+
32
+ // z: the depth, used to pick the motion vector of the closest surface around a pixel.
33
+ rt0 = vec4(velocity, gl_FragCoord.z, 1.0);
34
+ }
35
+ `,t="fragment",r=!0,o={code:i,shaderStage:t,isFragmentShader:r};export{i as code,o as default,r as isFragmentShader,t as shaderStage};
@@ -0,0 +1,140 @@
1
+ var t=`
2
+ /* shaderity: @{enableVertexExtensions} */
3
+ /* shaderity: @{glslPrecision} */
4
+
5
+ /* shaderity: @{definitions} */
6
+
7
+ /* shaderity: @{vertexInOut} */
8
+
9
+ uniform float u_pointSize; // initialValue=30, soloDatum=true
10
+ uniform vec3 u_pointDistanceAttenuation; // initialValue=(0.0, 0.1, 0.01), soloDatum=true
11
+
12
+ // Clip space positions of this frame (without the jitter) and of the previous frame.
13
+ out vec4 v_currentPosition_inClip;
14
+ out vec4 v_previousPosition_inClip;
15
+
16
+ #ifdef RN_IS_MORPHING
17
+ uniform int u_currentPrimitiveIdx; // initialValue=0, isInternalSetting=true, soloDatum=false, needUniformInDataTextureMode=true
18
+ #endif
19
+
20
+
21
+ /* shaderity: @{prerequisites} */
22
+
23
+ /* shaderity: @{getters} */
24
+
25
+ /* shaderity: @{matricesGetters} */
26
+
27
+ /* shaderity: @{processGeometry} */
28
+
29
+ #ifdef RN_IS_SKINNING
30
+ // The matrix of one joint decoded from the bone data of the previous frame (see getBoneMatrix in processGeometry)
31
+ mat4 getPreviousBoneMatrix(uint skeletalComponentSID, uint jointIdx, int boneDataType, vec4 boneDataInfo) {
32
+ if (boneDataType == RN_BONE_DATA_TYPE_MAT43X1) {
33
+ vec4 a = get_previousBoneData(skeletalComponentSID, jointIdx * 3u);
34
+ vec4 b = get_previousBoneData(skeletalComponentSID, jointIdx * 3u + 1u);
35
+ vec4 c = get_previousBoneData(skeletalComponentSID, jointIdx * 3u + 2u);
36
+ return mat4(
37
+ a.x, a.y, a.z, 0.0,
38
+ a.w, b.x, b.y, 0.0,
39
+ b.z, b.w, c.x, 0.0,
40
+ c.y, c.z, c.w, 1.0
41
+ );
42
+ } else if (boneDataType == RN_BONE_DATA_TYPE_VEC4X2) {
43
+ vec4 tq = get_previousBoneData(skeletalComponentSID, jointIdx * 2u);
44
+ vec4 sq = get_previousBoneData(skeletalComponentSID, jointIdx * 2u + 1u);
45
+ vec4 quat = decodeLogQuat(uvec2(floatBitsToUint(tq.w), floatBitsToUint(sq.w)));
46
+ return createMatrixFromQuaternionTranslationScale(quat, tq.xyz, sq.xyz);
47
+ } else {
48
+ uvec4 chunk = floatBitsToUint(get_previousBoneData(skeletalComponentSID, jointIdx));
49
+ vec4 ts = unpackVec4FromUvec2(chunk.zw);
50
+ vec3 translation = ts.xyz * boneDataInfo.xyz;
51
+ float scale = decodeVec4x1Scale(ts.w, chunk.y);
52
+ return createMatrixFromQuaternionTranslationScale(decodeLogQuat(chunk.xy), translation, vec3(scale));
53
+ }
54
+ }
55
+
56
+ // The skinning matrix of the previous frame. The previous bone data info has w = -1 until the skeleton has
57
+ // previous bone data; the current skinning matrix is used then.
58
+ mat4 getPreviousSkinMatrix(uint skeletalComponentSID, uvec4 joint, vec4 weight) {
59
+ vec4 boneDataInfo = get_previousBoneDataInfo(skeletalComponentSID);
60
+ if (boneDataInfo.w < 0.0) {
61
+ return getSkinMatrix(skeletalComponentSID, joint, weight);
62
+ }
63
+ int boneDataType = int(boneDataInfo.w + 0.5);
64
+ mat4 skinMat = weight.x * getPreviousBoneMatrix(skeletalComponentSID, joint.x, boneDataType, boneDataInfo);
65
+ skinMat += weight.y * getPreviousBoneMatrix(skeletalComponentSID, joint.y, boneDataType, boneDataInfo);
66
+ skinMat += weight.z * getPreviousBoneMatrix(skeletalComponentSID, joint.z, boneDataType, boneDataInfo);
67
+ skinMat += weight.w * getPreviousBoneMatrix(skeletalComponentSID, joint.w, boneDataType, boneDataInfo);
68
+ return skinMat;
69
+ }
70
+ #endif
71
+
72
+ void main()
73
+ {
74
+
75
+ /* shaderity: @{mainPrerequisites} */
76
+
77
+ mat4 worldMatrix = get_worldMatrix(uint(a_instanceIds.x));
78
+ mat4 previousWorldMatrix = get_previousWorldMatrix(uint(a_instanceIds.x));
79
+ mat4 viewMatrix = get_viewMatrix(cameraSID);
80
+ mat4 projectionMatrix = get_projectionMatrix(cameraSID);
81
+ mat3 normalMatrix = get_normalMatrix(uint(a_instanceIds.x));
82
+ bool isBillboard = get_isBillboard(uint(a_instanceIds.x));
83
+
84
+ v_color = a_color;
85
+
86
+ bool isSkinning = false;
87
+
88
+ isSkinning = processGeometry(
89
+ worldMatrix,
90
+ normalMatrix,
91
+ viewMatrix,
92
+ a_position,
93
+ a_normal,
94
+ uvec4(a_joint),
95
+ a_weight,
96
+ isBillboard,
97
+ normalMatrix,
98
+ v_position_inWorld,
99
+ v_normal_inWorld
100
+ );
101
+
102
+ // The same (jittered) position as the color pass, so that the motion vectors cover the same pixels.
103
+ vec4 position_inClip = projectionMatrix * viewMatrix * v_position_inWorld;
104
+ gl_Position = position_inClip;
105
+
106
+ // The jitter moves the NDC position by currentJitter, i.e. the clip position by currentJitter * w.
107
+ vec2 currentJitter = get_currentJitter(materialSID, 0u);
108
+ v_currentPosition_inClip = position_inClip - vec4(currentJitter * position_inClip.w, 0.0, 0.0);
109
+
110
+ // The previous world position: the vertex deformed by the blend shape weights and the bone data of the previous
111
+ // frame, transformed by the world matrix of the previous frame.
112
+ vec4 previousPosition_inWorld;
113
+ if (isBillboard) {
114
+ // A billboard faces the camera of each frame: only the motion of its world matrix is considered.
115
+ previousPosition_inWorld = previousWorldMatrix * (inverse(worldMatrix) * v_position_inWorld);
116
+ } else {
117
+ vec3 previousPosition_inLocal = a_position.xyz;
118
+ #ifdef RN_IS_MORPHING
119
+ int blendShapeComponentSID = int(a_instanceIds.z);
120
+ if (blendShapeComponentSID != -1) {
121
+ previousPosition_inLocal = get_previousMorphedPosition(uint(a_baryCentricCoord.w), a_position.xyz, uint(blendShapeComponentSID));
122
+ }
123
+ #endif
124
+ mat4 previousLocalToWorld = previousWorldMatrix;
125
+ #ifdef RN_IS_SKINNING
126
+ if (skeletalComponentSID != INVALID_ID) {
127
+ previousLocalToWorld = previousWorldMatrix * getPreviousSkinMatrix(skeletalComponentSID, uvec4(a_joint), a_weight);
128
+ }
129
+ #endif
130
+ previousPosition_inWorld = previousLocalToWorld * vec4(previousPosition_inLocal, 1.0);
131
+ }
132
+ v_previousPosition_inClip = get_previousViewProjectionMatrix(materialSID, 0u) * previousPosition_inWorld;
133
+
134
+ bool visibility = get_isVisible(uint(a_instanceIds.x));
135
+ if (!visibility)
136
+ {
137
+ gl_Position = vec4(0.0);
138
+ }
139
+ }
140
+ `,i="vertex",o=!1,a={code:t,shaderStage:i,isFragmentShader:o};export{t as code,a as default,o as isFragmentShader,i as shaderStage};