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
- import{Component as k}from"../../core/Component.js";import{applyMixins as U}from"../../core/EntityRepository.js";import{BufferUse as A}from"../../definitions/BufferUse.js";import{ComponentType as B}from"../../definitions/ComponentType.js";import{CompositionType as W}from"../../definitions/CompositionType.js";import{ProcessStage as L}from"../../definitions/ProcessStage.js";import{ShaderType as P}from"../../definitions/ShaderType.js";import{_getGizmoClass as V}from"../../gizmos/GizmoRegistry.js";import{AABB as T}from"../../math/AABB.js";import{Matrix44 as v}from"../../math/Matrix44.js";import{MutableMatrix33 as Q}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as g}from"../../math/MutableMatrix44.js";import{MutableQuaternion as R}from"../../math/MutableQuaternion.js";import{MutableScalar as S}from"../../math/MutableScalar.js";import{MutableVector3 as b}from"../../math/MutableVector3.js";import{Quaternion as y}from"../../math/Quaternion.js";import{Vector3 as G}from"../../math/Vector3.js";import{Is as o}from"../../misc/Is.js";import{CameraComponent as z}from"../Camera/CameraComponent.js";import{TransformComponent as D}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as w}from"../WellKnownComponentTIDs.js";import{flattenHierarchy as E}from"./SceneGraphOps.js";var i=class i extends k{constructor(t,e,s,n,r){super(t,e,s,n,r);this.Ds=[];this.lr=[];this.hr=!1;this.Ls=0;this._worldMatrix=g.dummy();this._worldMatrixRest=g.identity();this._normalMatrix=Q.dummy();this._worldRotation=R.identity();this.js=!1;this.cr=0;this.ur=!1;this.pr=!1;this.$s=!1;this.yr=new T;this.Ir=new T;this.Ks=!0;this.qs=!0;this.Hs=0;this.Cr=-1;this.Rr=-1;this._isVisible=S.dummy();this._isBillboard=S.dummy();this.Fs=!1;this.dr="world";this.io=0;this.toMakeWorldMatrixTheSameAsLocalMatrix=!1;this.isRootJoint=!1;this.jointIndex=-1;this._isCulled=!1;this.tr=-1;i.Gr.push(new WeakRef(this)),this.submitToAllocation(t.config.scenegraphComponentCountPerBufferView,r)}set isVisible(t){this._isVisible.setValue(t?1:0),i.fi(this.i)}get isVisible(){return this._isVisible.getValue()===1}static getUpdateCount(t){var e;return(e=this.pi.get(t))!=null?e:0}static fi(t){var s;let e=(s=this.pi.get(t))!=null?s:0;this.pi.set(t,e+1)}setVisibilityRecursively(t){this.isVisible=t;for(let e of this.Ds)e.setVisibilityRecursively(t)}set isBillboard(t){this._isBillboard.setValue(t?1:0)}get isBillboard(){return this._isBillboard.getValue()===1}setIsBillboardRecursively(t){this._isBillboard.setValue(t?1:0);for(let e of this.Ds)e.isBillboard=t}set isAABBGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Es)&&(this.Es=new(V("aabb"))(this.entity.engine,this.entity),this.Es._setup()),this.Es.isVisible=!0):o.exist(this.Es)&&(this.Es.isVisible=!1)}get isAABBGizmoVisible(){return o.exist(this.Es)?this.Es.isVisible:!1}set isLocatorGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Qs)&&(this.Qs=new(V("locator"))(this.entity.engine,this.entity),this.Qs._setup()),this.Qs.isVisible=!0):o.exist(this.Qs)&&(this.Qs.isVisible=!1)}get isLocatorGizmoVisible(){return o.exist(this.Qs)?this.Qs.isVisible:!1}set isTranslationGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Gs)&&(this.Gs=new(V("translation"))(this.entity.engine,this.entity),this.Gs._setup()),this.Gs.isVisible=!0,this.Mr(),this.Gs.isSetup&&this.Gs._update()):o.exist(this.Gs)&&(this.Gs.isVisible=!1,this.br())}get isTranslationGizmoVisible(){return o.exist(this.Gs)?this.Gs.isVisible:!1}set isRotationGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Is)&&(this.Is=new(V("rotation"))(this.entity.engine,this.entity),this.Is._setup(),this.Is.setSpace(this.dr)),this.Is.isVisible=!0,this.Mr(),this.Is.isSetup&&this.Is._update()):o.exist(this.Is)&&(this.Is.isVisible=!1,this.br())}get isRotationGizmoVisible(){return o.exist(this.Is)?this.Is.isVisible:!1}set isScaleGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Ws)&&(this.Ws=new(V("scale"))(this.entity.engine,this.entity),this.Ws._setup()),this.Ws.isVisible=!0,this.Mr(),this.Ws.isSetup&&this.Ws._update()):o.exist(this.Ws)&&(this.Ws.isVisible=!1,this.br())}get isScaleGizmoVisible(){return o.exist(this.Ws)?this.Ws.isVisible:!1}set isJointGizmoVisible(t){t&&this.isJoint()?(this.Fs=!0,o.not.defined(this.Us)&&(this.Us=new(V("joint"))(this.entity.engine,this.entity),this.Us._setup()),this.Us.isVisible=!0):o.exist(this.Us)&&(this.Us.isVisible=!1)}get isJointGizmoVisible(){return o.exist(this.Us)?this.Us.isVisible:!1}static getTopLevelComponents(){return i.Gr.map(t=>t.deref()).filter(t=>t!==void 0?t.isTopLevel:!1)}isJoint(){return this.jointIndex>=0}static get hierarchyVersion(){return i.Vr}static sr(){i.Vr++,i.Hs++}static get componentTID(){return w.SceneGraphComponentTID}get componentTID(){return w.SceneGraphComponentTID}setWorldMatrixRestDirty(){this.matrixRestInner,this.setWorldMatrixRestDirtyRecursively()}setWorldMatrixRestDirtyRecursively(){this.ur=!1;for(let t of this.children)t.setWorldMatrixRestDirtyRecursively()}get worldMatrixVersion(){return this.cr}setWorldMatrixDirty(){var t;this.setWorldMatrixDirtyRecursively(),this.hr||(t=this.parent)==null||t.setWorldAABBDirtyParentRecursively()}setWorldMatrixDirtyWithoutAABBDirty(){this.setWorldMatrixDirtyRecursively()}setWorldMatrixDirtyRecursively(){if(!(!this.js&&!this.pr&&!this.$s&&this.Ks&&this.qs)){this.cr++,this.js=!1,this.pr=!1,this.$s=!1,this.Ks=!0,this.qs=!0;for(let t of this.children)t.setWorldMatrixDirtyRecursively()}}setWorldAABBDirtyParentRecursively(){let t=i.Hs,e=this;for(;e!=null;){if(e.Ks=!0,e.qs=!0,e.Hs===t)return;e.Hs=t,e=e.Yi}}addChild(t,e=!1){let s;e&&(t.logicForce(),s=t.matrix),o.exist(t.Yi)&&t.Yi.removeChild(t),t.Yi=this,this.Ds.push(t),i.sr(),this.ar(t.Ls),e&&o.exist(s)&&(t.matrix=s),t.setWorldMatrixDirtyRecursively(),this.setWorldAABBDirtyParentRecursively()}removeChild(t){let e=this.Ds.indexOf(t);e>=0&&(this.ar(-t.Ls),this.Ds.splice(e,1));let s=this.lr.indexOf(t);s>=0&&this.lr.splice(s,1),t.Yi=void 0,t.hr=!1,i.sr(),t.setWorldMatrixDirtyRecursively(),e>=0&&this.setWorldAABBDirtyParentRecursively()}_addGizmoChild(t){t.Yi=this,t.hr=!0,this.lr.push(t),i.sr()}get isTopLevel(){return this.Yi==null}get children(){return this.Ds}get parent(){return this.Yi}get matrixInner(){return this.js||this.Br(),this._worldMatrix}get matrix(){return this.matrixInner.clone()}setMatrixWithoutPhysics(t){if(o.not.exist(this.Yi))this.entity.getTransform().localMatrixWithoutPhysics=t;else{let e=this.Yi,s=v.invertTo(e.matrixInner,i.Lr);this.entity.getTransform().localMatrixWithoutPhysics=v.multiplyTo(s,t,i.mr).clone()}}setMatrixToPhysics(t){this.Wr(t,!0,!0,!0),this.fr(!0,!0,!0)}Wr(t,e,s,n){let r=this.entity.tryToGetPhysics();if(r!==void 0&&r.strategy!==void 0){let a=r.strategy;if(s){let l=this.getQuaternionRecursivelyTo(i.Jr);a.setRotation!=null?a.setRotation(l):a.setEulerAngle!=null&&a.setEulerAngle(l.toEulerAnglesTo(i.Ar))}e&&a.setPosition!=null&&a.setPosition(t.getTranslateTo(i.Zr)),n&&a.setScale!=null&&a.setScale(this._getPhysicsWorldScale(t))}}fr(t,e,s){let n=this.entity.tryToGetPhysics()===void 0?0:1;if(this.Ls!==n){this.matrixInner,this.setWorldMatrixDirty();for(let r of this.Ds)!r.toMakeWorldMatrixTheSameAsLocalMatrix&&r.Ls>0&&r.Pr(t,e,s)}}Pr(t,e,s){if(this.Ls!==0){this.Wr(this.matrixInner,t,e,s);for(let n of this.Ds)!n.toMakeWorldMatrixTheSameAsLocalMatrix&&n.Ls>0&&n.Pr(t,e,s)}}_onPhysicsComponentAdded(){this.ar(1)}_onPhysicsComponentRemoved(){this.ar(-1)}get _hasPhysicsComponentInSubtree(){return this.Ls>0}ar(t){this.Ls+=t;let e=this.Yi;e!=null&&e.Ds.includes(this)&&e.ar(t)}set matrix(t){this.setMatrixWithoutPhysics(t),this.setMatrixToPhysics(t)}get matrixRestInner(){return this.ur||this.wr(),this._worldMatrixRest}get matrixRest(){return this.matrixRestInner.clone()}get normalMatrixInner(){return this.pr||(v.invertTo(this.matrixInner,i.invertedMatrix44),this._normalMatrix.copyComponents(i.invertedMatrix44.transpose()),this.pr=!0),this._normalMatrix}get entityWorldWithSkeletalMatrix(){return this.entityWorldMatrixWithSkeletalInner.clone()}get entityWorldMatrixWithSkeletalInner(){let t=this.entity.tryToGetSkeletal();return o.exist(t)&&t.isWorldMatrixUpdated?t.worldMatrixInner:this.entity.getSceneGraph().matrixInner}get normalMatrix(){return this.normalMatrixInner.clone()}isWorldMatrixUpToDateRecursively(){return this.js?this.Yi?this.Yi.isWorldMatrixUpToDateRecursively():!0:!1}Br(){if(this.js)return this._worldMatrix;let t=this.entity.getTransform();if(this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix)t.getLocalMatrixInnerTo(this._worldMatrix);else{let e=this.Yi.Br();t.getLocalMatrixInnerTo(i.mr),g.multiplyTo(e,i.mr,this._worldMatrix)}return this.js=!0,this._worldMatrix}wr(){if(this.ur)return this._worldMatrixRest;let t=this.entity.getTransform();if(this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix)t.getLocalMatrixInnerTo(this._worldMatrixRest);else{let e=this.Yi.wr();t.getLocalMatrixInnerTo(i.mr),g.multiplyTo(e,i.mr,this._worldMatrixRest)}return this.ur=!0,this._worldMatrixRest}getQuaternionRecursively(){return y.fromCopyQuaternion(this.getQuaternionRecursivelyTo(i.jr))}getQuaternionRecursivelyTo(t){let e=this.entity.getTransform().localRotationInner;return this.Yi==null?t.copyComponents(e):(this.Yi.getQuaternionRecursivelyTo(i.Sr),y.multiplyTo(i.Sr,e,t))}get worldPosition(){let t=i.Er;return this.matrixInner.multiplyVector3To(t,i.returnVector3),i.returnVector3}getWorldPositionOf(t){return this.matrixInner.multiplyVector3(t)}getWorldPositionOfTo(t,e){return this.matrixInner.multiplyVector3To(t,e)}getLocalPositionOf(t){return v.invert(this.matrixInner).multiplyVector3(t)}getLocalPositionOfTo(t,e){return v.invertTo(this.matrixInner,i.gr).multiplyVector3To(t,e)}getWorldAABB(){let t=new T,e=this.entity.tryToGetMesh();o.exist(e)&&o.exist(e.mesh)?(t.mergeAABB(e.mesh.AABB),T.multiplyMatrixTo(this.entity.getSceneGraph().matrixInner,t,i.Js)):i.Js.initialize();let s=this.entity.tryToGetRaymarching();if(o.exist(s)){let n=s.calcWorldAABB();n!=null&&i.Js.mergeAABB(n)}return i.Js}calcWorldMergedAABB(){let t=this.getWorldAABB().clone();for(let e of this.children){let s=e.calcWorldMergedAABB();t.mergeAABB(s)}return this.Ir=t,t}get worldMergedAABB(){return this.Ks&&(this.calcWorldMergedAABB(),this.Ks=!1,i.Hs++),this.Ir}getWorldAABBWithSkeletal(){let t=new T,e=this.entity.tryToGetMesh();o.exist(e)&&o.exist(e.mesh)?(t.mergeAABB(e.mesh.AABB),T.multiplyMatrixTo(this.entity.getSceneGraph().entityWorldMatrixWithSkeletalInner,t,i.Js)):i.Js.initialize();let s=this.entity.tryToGetRaymarching();if(o.exist(s)){let n=s.calcWorldAABB();n!=null&&i.Js.mergeAABB(n)}return i.Js}calcWorldMergedAABBWithSkeletal(){let t=this.getWorldAABBWithSkeletal().clone();for(let e of this.children){let s=e.calcWorldMergedAABBWithSkeletal();t.mergeAABB(s)}return this.yr=t,t}get worldMergedAABBWithSkeletal(){return this.qs&&(this.calcWorldMergedAABBWithSkeletal(),this.qs=!1,i.Hs++),this.yr}castRay(t,e,s=0,n=[]){let r=E(this,!1),a=[];for(let p of r){let h=p.entity.tryToGetMesh();h&&a.push(h)}let l=Number.MAX_VALUE,d,c,f,x=0,M=0;for(let p of a){if(!p.entity.getSceneGraph().isVisible||!p.isPickable||n.indexOf(p)!==-1)continue;let h=p.castRay(t,e,s);o.defined(h.data)&&h.data.t<l&&(l=h.data.t,d=h.data.position,c=p,f=void 0,x=h.data.u,M=h.data.v)}for(let p of r){let h=p.entity.tryToGetRaymarching();if(h==null||!h.isPickable||!p.isVisible)continue;let u=h.castRay(t,e);u!=null&&u.t<l&&(l=u.t,d=u.position,c=void 0,f=h,x=0,M=0)}return(o.exist(c)||o.exist(f))&&o.exist(d)?{result:!0,data:{t:l,u:x,v:M,position:d,selectedMeshComponent:c,selectedRaymarchingComponent:f}}:{result:!1}}castRayFromScreen(t,e,s,n,r=0,a=[]){let l=E(this,!1),d=[];for(let u of l){let m=u.entity.tryToGetMesh();m&&d.push(m)}let c=Number.MAX_VALUE,f,x,M,p=0,h=0;for(let u of d){if(!u.entity.getSceneGraph().isVisible||!u.isPickable||a.indexOf(u)!==-1)continue;let m=u.castRayFromScreenInWorld(t,e,s,n,r);o.defined(m.data)&&m.data.t<c&&(c=m.data.t,f=m.data.position,x=u,M=void 0,p=m.data.u,h=m.data.v)}for(let u of l){let m=u.entity.tryToGetRaymarching();if(m==null||!m.isPickable||!u.isVisible)continue;let C=m.castRayFromScreen(t,e,s,n);C.result&&C.data!=null&&C.data.t<c&&(c=C.data.t,f=C.data.position,x=void 0,M=m,p=0,h=0)}return(o.exist(x)||o.exist(M))&&o.exist(f)?{result:!0,data:{t:c,u:p,v:h,position:f,selectedMeshComponent:x,selectedRaymarchingComponent:M}}:{result:!1}}$load(){this.moveStageTo(L.Logic)}$logic(){this.Cr===this.cr&&this.js&&!this.Fs&&this.Rr===this.i.componentRepository._componentCreationCount||this.tr!==D.getUpdateCount(this.i)&&(this.logicForce(),this.tr=D.getUpdateCount(this.i))}logicForce(){this.matrixInner,this.entity.tryToGetMesh()!=null&&this.normalMatrixInner,this.$r(),this.Cr=this.cr,this.Rr=this.i.componentRepository._componentCreationCount}$r(){this.Fs&&(o.exist(this.Es)&&this.Es.isSetup&&this.Es.isVisible&&this.Es._update(),o.exist(this.Qs)&&this.Qs.isSetup&&this.Qs.isVisible&&this.Qs._update(),this.zr(),o.exist(this.Us)&&this.Us.isSetup&&this.Us.isVisible&&this.Us._update())}zr(){o.exist(this.Gs)&&this.Gs.isSetup&&this.Gs.isVisible&&this.Gs._update(),o.exist(this.Is)&&this.Is.isSetup&&this.Is.isVisible&&this.Is._update(),o.exist(this.Ws)&&this.Ws.isSetup&&this.Ws.isVisible&&this.Ws._update()}Kr(){return o.exist(this.Gs)&&this.Gs.isSetup&&this.Gs.isVisible||o.exist(this.Is)&&this.Is.isSetup&&this.Is.isVisible||o.exist(this.Ws)&&this.Ws.isSetup&&this.Ws.isVisible}Mr(){let t=this.i.objectUID,e=i._s.get(t);e==null&&(e=new Set,i._s.set(t,e)),e.add(this)}br(){var t;this.Kr()||(t=i._s.get(this.i.objectUID))==null||t.delete(this)}static _updateTransformGizmosByCameraChange(t){let e=z.getCurrent(t),s=z.getCurrentCameraUpdateCount(t),n=t.objectUID,r=i.xr.get(n);if(r!=null&&r.componentSID===e&&r.updateCount===s)return;i.xr.set(n,{componentSID:e,updateCount:s});let a=i._s.get(n);if(a!=null)for(let l of a)l.zr()}setPositionWithoutPhysics(t){o.not.exist(this.Yi)?this.entity.getTransform().localPositionWithoutPhysics=t:(g.invertTo(this.Yi.entity.getSceneGraph().matrixInner,i.gr),this.entity.getTransform().localPositionWithoutPhysics=i.gr.multiplyVector3(t))}set position(t){this.setPositionWithoutPhysics(t),this.setPositionToPhysics(t)}setPositionToPhysics(t){var s,n;let e=this.entity.tryToGetPhysics();e!==void 0&&e.strategy!==void 0&&((n=(s=e.strategy).setPosition)==null||n.call(s,t)),this.fr(!0,!1,!1)}get position(){return this.matrixInner.getTranslate()}getPositionTo(t){return this.matrixInner.getTranslateTo(t)}get positionRest(){return this.matrixRestInner.getTranslate()}getPositionRestTo(t){return this.matrixRestInner.getTranslateTo(t)}set eulerAngles(t){if(o.not.exist(this.Yi))this.entity.getTransform().localEulerAnglesWithoutPhysics=t;else{let e=y.fromMatrix(this.Yi.entity.getSceneGraph().matrixInner),s=y.invert(e),n=y.fromMatrix(v.rotate(t)),r=y.multiply(n,s);this.entity.getTransform().localEulerAnglesWithoutPhysics=r.toEulerAngles()}this.setEulerAnglesToPhysics(t)}setEulerAnglesToPhysics(t){let e=this.entity.tryToGetPhysics();if(e!==void 0&&e.strategy!==void 0){let s=e.strategy;s.setEulerAngle!=null?s.setEulerAngle(t):s.setRotation!=null&&s.setRotation(y.fromMatrix(v.rotate(t)))}this.Dr()}get eulerAngles(){return this.matrixInner.toEulerAngles()}setRotationWithoutPhysics(t){if(o.not.exist(this.Yi))this.entity.getTransform().localRotationWithoutPhysics=t;else{let e=this.Yi.entity.getSceneGraph().rotation,s=y.invert(e);this.entity.getTransform().localRotationWithoutPhysics=y.multiply(t,s)}}set rotation(t){this.setRotationWithoutPhysics(t),this.setRotationToPhysics(t)}setRotationToPhysics(t){let e=this.entity.tryToGetPhysics();if(e!==void 0&&e.strategy!==void 0){let s=e.strategy;s.setRotation!=null?s.setRotation(t):s.setEulerAngle!=null&&s.setEulerAngle(t.toEulerAnglesTo(i.Ar))}this.Dr()}Dr(){var e;let t=(e=this.entity.tryToGetPhysics())==null?void 0:e.strategy;(t==null?void 0:t.setScale)!=null&&(this.matrixInner,this.setWorldMatrixDirty(),t.setScale(this._getPhysicsWorldScale(this.matrixInner))),this.fr(!0,!0,!0)}Tr(){let t=this.entity.getTransform().localRotationInner;return this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix?(this.$s||(this._worldRotation.copyComponents(t),this.$s=!0),this._worldRotation):(this.$s||(y.multiplyTo(this.Yi.Tr(),t,this._worldRotation),this.$s=!0),this._worldRotation)}get rotation(){return this.rotationInner.clone()}get rotationInner(){return this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix?this.entity.getTransform().localRotationInner:this.Tr()}getRotationTo(t){let e=this.Tr();return t.setComponents(e._v[0],e._v[1],e._v[2],e._v[3]),t}get rotationRest(){let t=this.parent;return t!=null?y.multiply(t.rotationRest,this.entity.getTransform().localRotationRestInner):this.entity.getTransform().localRotationRestInner}getRotationRest(t){let e=this.parent;return e!=null&&!t(this)?y.multiply(e.getRotationRest(t),this.entity.getTransform().localRotationRestInner):y.identity()}set scale(t){if(o.not.exist(this.Yi))this.entity.getTransform().localScaleWithoutPhysics=t;else{let e=this.Yi.entity.getSceneGraph().matrix;e._v[12]=0,e._v[13]=0,e._v[14]=0;let s=g.invert(e);this.entity.getTransform().localScaleWithoutPhysics=s.multiplyVector3(t)}this.setScaleToPhysics(t)}setScaleToPhysics(t){var s,n;let e=this.entity.tryToGetPhysics();e!==void 0&&e.strategy!==void 0&&((n=(s=e.strategy).setScale)==null||n.call(s,t)),this.fr(!0,!0,!0)}get scale(){return this.matrixInner.getScale()}_getPhysicsWorldScale(t=this.matrixInner){let e=this.getQuaternionRecursivelyTo(i.Fr),s=e.transformVector3To(i.Qr,i.Or),n=e.transformVector3To(i.kr,i.Nr),r=e.transformVector3To(i.Ur,i.Xr),a=t.getScaleTo(i.Hr),l=t.m00*s.x+t.m10*s.y+t.m20*s.z,d=t.m01*n.x+t.m11*n.y+t.m21*n.z,c=t.m02*r.x+t.m12*r.y+t.m22*r.z;return i.Yr.setComponents(l<0?-a.x:a.x,d<0?-a.y:a.y,c<0?-a.z:a.z)}qr(t){let e=t.entity.engine.entityRepository._shallowCopyEntityInner(t.entity);return e.getSceneGraph().Yi=this,i.sr(),e}_shallowCopyFrom(t){let e=t;this.Yi=e.Yi,this.Ds=[],i.sr(),this.Ls=0;for(let s=0;s<e.Ds.length;s++){let n=this.qr(e.Ds[s]).getSceneGraph();this.Ds.push(n),this.ar(n.Ls)}this.lr=e.lr.concat(),this.hr=e.hr,this._worldMatrix.copyComponents(e._worldMatrix),this._worldMatrixRest.copyComponents(e._worldMatrixRest),this._normalMatrix.copyComponents(e._normalMatrix),this.js=!1,this.ur=!1,this.pr=!1,this.$s=!1,this.cr++,this.yr=e.yr.clone(),this.Ks=!0,this.qs=!0,this._isVisible.copyComponents(e._isVisible),this._isBillboard.copyComponents(e._isBillboard),this.dr=e.dr,this.io=e.io,this.toMakeWorldMatrixTheSameAsLocalMatrix=e.toMakeWorldMatrixTheSameAsLocalMatrix,this.isRootJoint=e.isRootJoint,this.jointIndex=e.jointIndex}get entity(){return this.i.entityRepository.getEntity(this.gn)}setTransformGizmoSpace(t){var e,s,n;this.dr=t,(e=this.Gs)==null||e.setSpace(t),(s=this.Is)==null||s.setSpace(t),(n=this.Ws)==null||n.setSpace(t)}_destroy(){var t,e,s,n,r,a,l,d;super._destroy(),i.sr(),(t=i._s.get(this.i.objectUID))==null||t.delete(this),(e=this.Es)==null||e._destroy(),(s=this.Qs)==null||s._destroy(),(n=this.Gs)==null||n._destroy(),(r=this.Is)==null||r._destroy(),(a=this.Ws)==null||a._destroy(),(l=this.Us)==null||l._destroy(),(d=this.parent)==null||d.removeChild(this),this.children.forEach(c=>{var f;return(f=c.parent)==null?void 0:f.removeChild(c)})}addThisComponentToEntity(t,e){class s extends t.constructor{getSceneGraph(){return this.vr===void 0&&(this.vr=this.getComponentByComponentTID(w.SceneGraphComponentTID)),this.vr}get parent(){return this.getSceneGraph().parent}get matrix(){return this.getSceneGraph().matrix}get matrixInner(){return this.getSceneGraph().matrixInner}get position(){return this.getSceneGraph().position}set position(r){let a=this.getSceneGraph();a.position=r}get positionRest(){return this.getSceneGraph().positionRest}get scale(){return this.getSceneGraph().scale}set scale(r){let a=this.getSceneGraph();a.scale=r}get eulerAngles(){return this.getSceneGraph().eulerAngles}set eulerAngles(r){let a=this.getSceneGraph();a.eulerAngles=r}get rotation(){return this.getSceneGraph().rotation}set rotation(r){let a=this.getSceneGraph();a.rotation=r}get rotationRest(){return this.getSceneGraph().rotationRest}addChild(r,a=!1){this.getSceneGraph().addChild(r,a)}get children(){return this.getSceneGraph().children}removeChild(r){this.getSceneGraph().removeChild(r)}}return U(t,s),t}static _cleanupForEngine(t){i.pi.delete(t),i._s.delete(t.objectUID),i.xr.delete(t.objectUID)}};i.Vr=0,i.Hs=1,i.Er=G.zero(),i.Qr=G.fromCopy3(1,0,0),i.kr=G.fromCopy3(0,1,0),i.Ur=G.fromCopy3(0,0,1),i.returnVector3=b.zero(),i.Gr=[],i.invertedMatrix44=g.fromCopyArray16ColumnMajor([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i.gr=g.identity(),i.mr=g.identity(),i.Lr=g.identity(),i.Sr=R.identity(),i.jr=R.identity(),i.Fr=R.identity(),i.Jr=R.identity(),i.Or=b.zero(),i.Nr=b.zero(),i.Xr=b.zero(),i.Hr=b.one(),i.Yr=b.one(),i.Ar=b.zero(),i.Zr=b.zero(),i.pi=new Map,i.Js=new T,i._s=new Map,i.xr=new Map;var I=i;I.registerMember({bufferUse:A.GPUInstanceData,memberName:"worldMatrix",dataClassType:g,shaderType:P.VertexAndPixelShader,compositionType:W.Mat4,componentType:B.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});I.registerMember({bufferUse:A.GPUInstanceData,memberName:"normalMatrix",dataClassType:Q,shaderType:P.VertexAndPixelShader,compositionType:W.Mat3,componentType:B.Float,initValues:[1,0,0,0,1,0,0,0,1]});I.registerMember({bufferUse:A.GPUInstanceData,memberName:"isVisible",dataClassType:S,shaderType:P.VertexShader,compositionType:W.Scalar,componentType:B.Float,initValues:[1],convertToBool:!0});I.registerMember({bufferUse:A.GPUInstanceData,memberName:"isBillboard",dataClassType:S,shaderType:P.VertexShader,compositionType:W.Scalar,componentType:B.Float,initValues:[0],convertToBool:!0});export{I as SceneGraphComponent};
1
+ import{Component as U}from"../../core/Component.js";import{applyMixins as k}from"../../core/EntityRepository.js";import{BufferUse as G}from"../../definitions/BufferUse.js";import{ComponentType as S}from"../../definitions/ComponentType.js";import{CompositionType as A}from"../../definitions/CompositionType.js";import{ProcessStage as L}from"../../definitions/ProcessStage.js";import{ShaderType as B}from"../../definitions/ShaderType.js";import{_getGizmoClass as I}from"../../gizmos/GizmoRegistry.js";import{AABB as v}from"../../math/AABB.js";import{Matrix44 as T}from"../../math/Matrix44.js";import{MutableMatrix33 as Q}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as d}from"../../math/MutableMatrix44.js";import{MutableQuaternion as R}from"../../math/MutableQuaternion.js";import{MutableScalar as P}from"../../math/MutableScalar.js";import{MutableVector3 as b}from"../../math/MutableVector3.js";import{Quaternion as y}from"../../math/Quaternion.js";import{Vector3 as W}from"../../math/Vector3.js";import{Is as o}from"../../misc/Is.js";import{CameraComponent as z}from"../Camera/CameraComponent.js";import{TransformComponent as D}from"../Transform/TransformComponent.js";import{WellKnownComponentTIDs as w}from"../WellKnownComponentTIDs.js";import{flattenHierarchy as E}from"./SceneGraphOps.js";var i=class i extends U{constructor(t,e,s,n,r){super(t,e,s,n,r);this.Ds=[];this.ur=[];this.mr=!1;this.Ls=0;this._worldMatrix=d.dummy();this._worldMatrixRest=d.identity();this._normalMatrix=Q.dummy();this._previousWorldMatrix=d.dummy();this._worldRotation=R.identity();this.js=!1;this.yr=0;this.dr=!1;this.fr=!1;this._s=!1;this.xr=new v;this.Sr=new v;this.$s=!0;this.Ks=!0;this.Hs=0;this.Ar=-1;this.Br=-1;this._isVisible=P.dummy();this._isBillboard=P.dummy();this.Fs=!1;this.Mr="world";this.io=0;this.toMakeWorldMatrixTheSameAsLocalMatrix=!1;this.isRootJoint=!1;this.jointIndex=-1;this._isCulled=!1;this.nr=-1;i.Wr.push(new WeakRef(this)),this.submitToAllocation(t.config.scenegraphComponentCountPerBufferView,r)}set isVisible(t){this._isVisible.setValue(t?1:0),i.fi(this.i)}get isVisible(){return this._isVisible.getValue()===1}static getUpdateCount(t){var e;return(e=this.pi.get(t))!=null?e:0}static fi(t){var s;let e=(s=this.pi.get(t))!=null?s:0;this.pi.set(t,e+1)}setVisibilityRecursively(t){this.isVisible=t;for(let e of this.Ds)e.setVisibilityRecursively(t)}set isBillboard(t){this._isBillboard.setValue(t?1:0)}get isBillboard(){return this._isBillboard.getValue()===1}setIsBillboardRecursively(t){this._isBillboard.setValue(t?1:0);for(let e of this.Ds)e.isBillboard=t}set isAABBGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Es)&&(this.Es=new(I("aabb"))(this.entity.engine,this.entity),this.Es._setup()),this.Es.isVisible=!0):o.exist(this.Es)&&(this.Es.isVisible=!1)}get isAABBGizmoVisible(){return o.exist(this.Es)?this.Es.isVisible:!1}set isLocatorGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Qs)&&(this.Qs=new(I("locator"))(this.entity.engine,this.entity),this.Qs._setup()),this.Qs.isVisible=!0):o.exist(this.Qs)&&(this.Qs.isVisible=!1)}get isLocatorGizmoVisible(){return o.exist(this.Qs)?this.Qs.isVisible:!1}set isTranslationGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Gs)&&(this.Gs=new(I("translation"))(this.entity.engine,this.entity),this.Gs._setup()),this.Gs.isVisible=!0,this.Vr(),this.Gs.isSetup&&this.Gs._update()):o.exist(this.Gs)&&(this.Gs.isVisible=!1,this.Ir())}get isTranslationGizmoVisible(){return o.exist(this.Gs)?this.Gs.isVisible:!1}set isRotationGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Is)&&(this.Is=new(I("rotation"))(this.entity.engine,this.entity),this.Is._setup(),this.Is.setSpace(this.Mr)),this.Is.isVisible=!0,this.Vr(),this.Is.isSetup&&this.Is._update()):o.exist(this.Is)&&(this.Is.isVisible=!1,this.Ir())}get isRotationGizmoVisible(){return o.exist(this.Is)?this.Is.isVisible:!1}set isScaleGizmoVisible(t){t?(this.Fs=!0,o.not.defined(this.Ws)&&(this.Ws=new(I("scale"))(this.entity.engine,this.entity),this.Ws._setup()),this.Ws.isVisible=!0,this.Vr(),this.Ws.isSetup&&this.Ws._update()):o.exist(this.Ws)&&(this.Ws.isVisible=!1,this.Ir())}get isScaleGizmoVisible(){return o.exist(this.Ws)?this.Ws.isVisible:!1}set isJointGizmoVisible(t){t&&this.isJoint()?(this.Fs=!0,o.not.defined(this.Us)&&(this.Us=new(I("joint"))(this.entity.engine,this.entity),this.Us._setup()),this.Us.isVisible=!0):o.exist(this.Us)&&(this.Us.isVisible=!1)}get isJointGizmoVisible(){return o.exist(this.Us)?this.Us.isVisible:!1}static getTopLevelComponents(){return i.Wr.map(t=>t.deref()).filter(t=>t!==void 0?t.isTopLevel:!1)}isJoint(){return this.jointIndex>=0}static get hierarchyVersion(){return i.Gr}static lr(){i.Gr++,i.Hs++}static get componentTID(){return w.SceneGraphComponentTID}get componentTID(){return w.SceneGraphComponentTID}setWorldMatrixRestDirty(){this.matrixRestInner,this.setWorldMatrixRestDirtyRecursively()}setWorldMatrixRestDirtyRecursively(){this.dr=!1;for(let t of this.children)t.setWorldMatrixRestDirtyRecursively()}get worldMatrixVersion(){return this.yr}get _previousWorldMatrixInner(){return this._previousWorldMatrix}get _lastComputedWorldMatrixInner(){return this._worldMatrix}setWorldMatrixDirty(){var t;this.setWorldMatrixDirtyRecursively(),this.mr||(t=this.parent)==null||t.setWorldAABBDirtyParentRecursively()}setWorldMatrixDirtyWithoutAABBDirty(){this.setWorldMatrixDirtyRecursively()}setWorldMatrixDirtyRecursively(){if(!(!this.js&&!this.fr&&!this._s&&this.$s&&this.Ks)){this.yr++,this.js=!1,this.fr=!1,this._s=!1,this.$s=!0,this.Ks=!0;for(let t of this.children)t.setWorldMatrixDirtyRecursively()}}setWorldAABBDirtyParentRecursively(){let t=i.Hs,e=this;for(;e!=null;){if(e.$s=!0,e.Ks=!0,e.Hs===t)return;e.Hs=t,e=e.Yi}}addChild(t,e=!1){let s;e&&(t.logicForce(),s=t.matrix),o.exist(t.Yi)&&t.Yi.removeChild(t),t.Yi=this,this.Ds.push(t),i.lr(),this.cr(t.Ls),e&&o.exist(s)&&(t.matrix=s),t.setWorldMatrixDirtyRecursively(),this.setWorldAABBDirtyParentRecursively()}removeChild(t){let e=this.Ds.indexOf(t);e>=0&&(this.cr(-t.Ls),this.Ds.splice(e,1));let s=this.ur.indexOf(t);s>=0&&this.ur.splice(s,1),t.Yi=void 0,t.mr=!1,i.lr(),t.setWorldMatrixDirtyRecursively(),e>=0&&this.setWorldAABBDirtyParentRecursively()}_addGizmoChild(t){t.Yi=this,t.mr=!0,this.ur.push(t),i.lr()}get isTopLevel(){return this.Yi==null}get children(){return this.Ds}get parent(){return this.Yi}get matrixInner(){return this.js||this.zr(),this._worldMatrix}get matrix(){return this.matrixInner.clone()}setMatrixWithoutPhysics(t){if(o.not.exist(this.Yi))this.entity.getTransform().localMatrixWithoutPhysics=t;else{let e=this.Yi,s=T.invertTo(e.matrixInner,i.Or);this.entity.getTransform().localMatrixWithoutPhysics=T.multiplyTo(s,t,i.gr).clone()}}setMatrixToPhysics(t){this.Dr(t,!0,!0,!0),this.br(!0,!0,!0)}Dr(t,e,s,n){let r=this.entity.tryToGetPhysics();if(r!==void 0&&r.strategy!==void 0){let a=r.strategy;if(s){let l=this.getQuaternionRecursivelyTo(i.Hr);a.setRotation!=null?a.setRotation(l):a.setEulerAngle!=null&&a.setEulerAngle(l.toEulerAnglesTo(i.wr))}e&&a.setPosition!=null&&a.setPosition(t.getTranslateTo(i.qr)),n&&a.setScale!=null&&a.setScale(this._getPhysicsWorldScale(t))}}br(t,e,s){let n=this.entity.tryToGetPhysics()===void 0?0:1;if(this.Ls!==n){this.matrixInner,this.setWorldMatrixDirty();for(let r of this.Ds)!r.toMakeWorldMatrixTheSameAsLocalMatrix&&r.Ls>0&&r.Er(t,e,s)}}Er(t,e,s){if(this.Ls!==0){this.Dr(this.matrixInner,t,e,s);for(let n of this.Ds)!n.toMakeWorldMatrixTheSameAsLocalMatrix&&n.Ls>0&&n.Er(t,e,s)}}_onPhysicsComponentAdded(){this.cr(1)}_onPhysicsComponentRemoved(){this.cr(-1)}get _hasPhysicsComponentInSubtree(){return this.Ls>0}cr(t){this.Ls+=t;let e=this.Yi;e!=null&&e.Ds.includes(this)&&e.cr(t)}set matrix(t){this.setMatrixWithoutPhysics(t),this.setMatrixToPhysics(t)}get matrixRestInner(){return this.dr||this.Qr(),this._worldMatrixRest}get matrixRest(){return this.matrixRestInner.clone()}get normalMatrixInner(){return this.fr||(T.invertTo(this.matrixInner,i.invertedMatrix44),this._normalMatrix.copyComponents(i.invertedMatrix44.transpose()),this.fr=!0),this._normalMatrix}get entityWorldWithSkeletalMatrix(){return this.entityWorldMatrixWithSkeletalInner.clone()}get entityWorldMatrixWithSkeletalInner(){let t=this.entity.tryToGetSkeletal();return o.exist(t)&&t.isWorldMatrixUpdated?t.worldMatrixInner:this.entity.getSceneGraph().matrixInner}get normalMatrix(){return this.normalMatrixInner.clone()}isWorldMatrixUpToDateRecursively(){return this.js?this.Yi?this.Yi.isWorldMatrixUpToDateRecursively():!0:!1}zr(){if(this.js)return this._worldMatrix;let t=this.entity.getTransform();if(this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix)t.getLocalMatrixInnerTo(this._worldMatrix);else{let e=this.Yi.zr();t.getLocalMatrixInnerTo(i.gr),d.multiplyTo(e,i.gr,this._worldMatrix)}return this.js=!0,this._worldMatrix}Qr(){if(this.dr)return this._worldMatrixRest;let t=this.entity.getTransform();if(this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix)t.getLocalMatrixInnerTo(this._worldMatrixRest);else{let e=this.Yi.Qr();t.getLocalMatrixInnerTo(i.gr),d.multiplyTo(e,i.gr,this._worldMatrixRest)}return this.dr=!0,this._worldMatrixRest}getQuaternionRecursively(){return y.fromCopyQuaternion(this.getQuaternionRecursivelyTo(i.Nr))}getQuaternionRecursivelyTo(t){let e=this.entity.getTransform().localRotationInner;return this.Yi==null?t.copyComponents(e):(this.Yi.getQuaternionRecursivelyTo(i.Pr),y.multiplyTo(i.Pr,e,t))}get worldPosition(){let t=i.Lr;return this.matrixInner.multiplyVector3To(t,i.returnVector3),i.returnVector3}getWorldPositionOf(t){return this.matrixInner.multiplyVector3(t)}getWorldPositionOfTo(t,e){return this.matrixInner.multiplyVector3To(t,e)}getLocalPositionOf(t){return T.invert(this.matrixInner).multiplyVector3(t)}getLocalPositionOfTo(t,e){return T.invertTo(this.matrixInner,i.vr).multiplyVector3To(t,e)}getWorldAABB(){let t=new v,e=this.entity.tryToGetMesh();o.exist(e)&&o.exist(e.mesh)?(t.mergeAABB(e.mesh.AABB),v.multiplyMatrixTo(this.entity.getSceneGraph().matrixInner,t,i.Js)):i.Js.initialize();let s=this.entity.tryToGetRaymarching();if(o.exist(s)){let n=s.calcWorldAABB();n!=null&&i.Js.mergeAABB(n)}return i.Js}calcWorldMergedAABB(){let t=this.getWorldAABB().clone();for(let e of this.children){let s=e.calcWorldMergedAABB();t.mergeAABB(s)}return this.Sr=t,t}get worldMergedAABB(){return this.$s&&(this.calcWorldMergedAABB(),this.$s=!1,i.Hs++),this.Sr}getWorldAABBWithSkeletal(){let t=new v,e=this.entity.tryToGetMesh();o.exist(e)&&o.exist(e.mesh)?(t.mergeAABB(e.mesh.AABB),v.multiplyMatrixTo(this.entity.getSceneGraph().entityWorldMatrixWithSkeletalInner,t,i.Js)):i.Js.initialize();let s=this.entity.tryToGetRaymarching();if(o.exist(s)){let n=s.calcWorldAABB();n!=null&&i.Js.mergeAABB(n)}return i.Js}calcWorldMergedAABBWithSkeletal(){let t=this.getWorldAABBWithSkeletal().clone();for(let e of this.children){let s=e.calcWorldMergedAABBWithSkeletal();t.mergeAABB(s)}return this.xr=t,t}get worldMergedAABBWithSkeletal(){return this.Ks&&(this.calcWorldMergedAABBWithSkeletal(),this.Ks=!1,i.Hs++),this.xr}castRay(t,e,s=0,n=[]){let r=E(this,!1),a=[];for(let p of r){let h=p.entity.tryToGetMesh();h&&a.push(h)}let l=Number.MAX_VALUE,f,c,g,x=0,M=0;for(let p of a){if(!p.entity.getSceneGraph().isVisible||!p.isPickable||n.indexOf(p)!==-1)continue;let h=p.castRay(t,e,s);o.defined(h.data)&&h.data.t<l&&(l=h.data.t,f=h.data.position,c=p,g=void 0,x=h.data.u,M=h.data.v)}for(let p of r){let h=p.entity.tryToGetRaymarching();if(h==null||!h.isPickable||!p.isVisible)continue;let u=h.castRay(t,e);u!=null&&u.t<l&&(l=u.t,f=u.position,c=void 0,g=h,x=0,M=0)}return(o.exist(c)||o.exist(g))&&o.exist(f)?{result:!0,data:{t:l,u:x,v:M,position:f,selectedMeshComponent:c,selectedRaymarchingComponent:g}}:{result:!1}}castRayFromScreen(t,e,s,n,r=0,a=[]){let l=E(this,!1),f=[];for(let u of l){let m=u.entity.tryToGetMesh();m&&f.push(m)}let c=Number.MAX_VALUE,g,x,M,p=0,h=0;for(let u of f){if(!u.entity.getSceneGraph().isVisible||!u.isPickable||a.indexOf(u)!==-1)continue;let m=u.castRayFromScreenInWorld(t,e,s,n,r);o.defined(m.data)&&m.data.t<c&&(c=m.data.t,g=m.data.position,x=u,M=void 0,p=m.data.u,h=m.data.v)}for(let u of l){let m=u.entity.tryToGetRaymarching();if(m==null||!m.isPickable||!u.isVisible)continue;let C=m.castRayFromScreen(t,e,s,n);C.result&&C.data!=null&&C.data.t<c&&(c=C.data.t,g=C.data.position,x=void 0,M=m,p=0,h=0)}return(o.exist(x)||o.exist(M))&&o.exist(g)?{result:!0,data:{t:c,u:p,v:h,position:g,selectedMeshComponent:x,selectedRaymarchingComponent:M}}:{result:!1}}$load(){this.moveStageTo(L.Logic)}$logic(){this.Ar===this.yr&&this.js&&!this.Fs&&this.Br===this.i.componentRepository._componentCreationCount||this.nr!==D.getUpdateCount(this.i)&&(this.logicForce(),this.nr=D.getUpdateCount(this.i))}logicForce(){this.matrixInner,this.entity.tryToGetMesh()!=null&&this.normalMatrixInner,this.so(),this.Ar=this.yr,this.Br=this.i.componentRepository._componentCreationCount}so(){this.Fs&&(o.exist(this.Es)&&this.Es.isSetup&&this.Es.isVisible&&this.Es._update(),o.exist(this.Qs)&&this.Qs.isSetup&&this.Qs.isVisible&&this.Qs._update(),this.Ur(),o.exist(this.Us)&&this.Us.isSetup&&this.Us.isVisible&&this.Us._update())}Ur(){o.exist(this.Gs)&&this.Gs.isSetup&&this.Gs.isVisible&&this.Gs._update(),o.exist(this.Is)&&this.Is.isSetup&&this.Is.isVisible&&this.Is._update(),o.exist(this.Ws)&&this.Ws.isSetup&&this.Ws.isVisible&&this.Ws._update()}ao(){return o.exist(this.Gs)&&this.Gs.isSetup&&this.Gs.isVisible||o.exist(this.Is)&&this.Is.isSetup&&this.Is.isVisible||o.exist(this.Ws)&&this.Ws.isSetup&&this.Ws.isVisible}Vr(){let t=this.i.objectUID,e=i.qs.get(t);e==null&&(e=new Set,i.qs.set(t,e)),e.add(this)}Ir(){var t;this.ao()||(t=i.qs.get(this.i.objectUID))==null||t.delete(this)}static _updateTransformGizmosByCameraChange(t){let e=z.getCurrent(t),s=z.getCurrentCameraUpdateCount(t),n=t.objectUID,r=i.Tr.get(n);if(r!=null&&r.componentSID===e&&r.updateCount===s)return;i.Tr.set(n,{componentSID:e,updateCount:s});let a=i.qs.get(n);if(a!=null)for(let l of a)l.Ur()}setPositionWithoutPhysics(t){o.not.exist(this.Yi)?this.entity.getTransform().localPositionWithoutPhysics=t:(d.invertTo(this.Yi.entity.getSceneGraph().matrixInner,i.vr),this.entity.getTransform().localPositionWithoutPhysics=i.vr.multiplyVector3(t))}set position(t){this.setPositionWithoutPhysics(t),this.setPositionToPhysics(t)}setPositionToPhysics(t){var s,n;let e=this.entity.tryToGetPhysics();e!==void 0&&e.strategy!==void 0&&((n=(s=e.strategy).setPosition)==null||n.call(s,t)),this.br(!0,!1,!1)}get position(){return this.matrixInner.getTranslate()}getPositionTo(t){return this.matrixInner.getTranslateTo(t)}get positionRest(){return this.matrixRestInner.getTranslate()}getPositionRestTo(t){return this.matrixRestInner.getTranslateTo(t)}set eulerAngles(t){if(o.not.exist(this.Yi))this.entity.getTransform().localEulerAnglesWithoutPhysics=t;else{let e=y.fromMatrix(this.Yi.entity.getSceneGraph().matrixInner),s=y.invert(e),n=y.fromMatrix(T.rotate(t)),r=y.multiply(n,s);this.entity.getTransform().localEulerAnglesWithoutPhysics=r.toEulerAngles()}this.setEulerAnglesToPhysics(t)}setEulerAnglesToPhysics(t){let e=this.entity.tryToGetPhysics();if(e!==void 0&&e.strategy!==void 0){let s=e.strategy;s.setEulerAngle!=null?s.setEulerAngle(t):s.setRotation!=null&&s.setRotation(y.fromMatrix(T.rotate(t)))}this.kr()}get eulerAngles(){return this.matrixInner.toEulerAngles()}setRotationWithoutPhysics(t){if(o.not.exist(this.Yi))this.entity.getTransform().localRotationWithoutPhysics=t;else{let e=this.Yi.entity.getSceneGraph().rotation,s=y.invert(e);this.entity.getTransform().localRotationWithoutPhysics=y.multiply(t,s)}}set rotation(t){this.setRotationWithoutPhysics(t),this.setRotationToPhysics(t)}setRotationToPhysics(t){let e=this.entity.tryToGetPhysics();if(e!==void 0&&e.strategy!==void 0){let s=e.strategy;s.setRotation!=null?s.setRotation(t):s.setEulerAngle!=null&&s.setEulerAngle(t.toEulerAnglesTo(i.wr))}this.kr()}kr(){var e;let t=(e=this.entity.tryToGetPhysics())==null?void 0:e.strategy;(t==null?void 0:t.setScale)!=null&&(this.matrixInner,this.setWorldMatrixDirty(),t.setScale(this._getPhysicsWorldScale(this.matrixInner))),this.br(!0,!0,!0)}Cr(){let t=this.entity.getTransform().localRotationInner;return this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix?(this._s||(this._worldRotation.copyComponents(t),this._s=!0),this._worldRotation):(this._s||(y.multiplyTo(this.Yi.Cr(),t,this._worldRotation),this._s=!0),this._worldRotation)}get rotation(){return this.rotationInner.clone()}get rotationInner(){return this.Yi==null||this.toMakeWorldMatrixTheSameAsLocalMatrix?this.entity.getTransform().localRotationInner:this.Cr()}getRotationTo(t){let e=this.Cr();return t.setComponents(e._v[0],e._v[1],e._v[2],e._v[3]),t}get rotationRest(){let t=this.parent;return t!=null?y.multiply(t.rotationRest,this.entity.getTransform().localRotationRestInner):this.entity.getTransform().localRotationRestInner}getRotationRest(t){let e=this.parent;return e!=null&&!t(this)?y.multiply(e.getRotationRest(t),this.entity.getTransform().localRotationRestInner):y.identity()}set scale(t){if(o.not.exist(this.Yi))this.entity.getTransform().localScaleWithoutPhysics=t;else{let e=this.Yi.entity.getSceneGraph().matrix;e._v[12]=0,e._v[13]=0,e._v[14]=0;let s=d.invert(e);this.entity.getTransform().localScaleWithoutPhysics=s.multiplyVector3(t)}this.setScaleToPhysics(t)}setScaleToPhysics(t){var s,n;let e=this.entity.tryToGetPhysics();e!==void 0&&e.strategy!==void 0&&((n=(s=e.strategy).setScale)==null||n.call(s,t)),this.br(!0,!0,!0)}get scale(){return this.matrixInner.getScale()}_getPhysicsWorldScale(t=this.matrixInner){let e=this.getQuaternionRecursivelyTo(i.Xr),s=e.transformVector3To(i.jr,i.Yr),n=e.transformVector3To(i.Fr,i.Zr),r=e.transformVector3To(i.Jr,i._r),a=t.getScaleTo(i.$r),l=t.m00*s.x+t.m10*s.y+t.m20*s.z,f=t.m01*n.x+t.m11*n.y+t.m21*n.z,c=t.m02*r.x+t.m12*r.y+t.m22*r.z;return i.Kr.setComponents(l<0?-a.x:a.x,f<0?-a.y:a.y,c<0?-a.z:a.z)}lo(t){let e=t.entity.engine.entityRepository._shallowCopyEntityInner(t.entity);return e.getSceneGraph().Yi=this,i.lr(),e}_shallowCopyFrom(t){let e=t;this.Yi=e.Yi,this.Ds=[],i.lr(),this.Ls=0;for(let s=0;s<e.Ds.length;s++){let n=this.lo(e.Ds[s]).getSceneGraph();this.Ds.push(n),this.cr(n.Ls)}this.ur=e.ur.concat(),this.mr=e.mr,this._worldMatrix.copyComponents(e._worldMatrix),this._previousWorldMatrix.copyComponents(e._previousWorldMatrix),this._worldMatrixRest.copyComponents(e._worldMatrixRest),this._normalMatrix.copyComponents(e._normalMatrix),this.js=!1,this.dr=!1,this.fr=!1,this._s=!1,this.yr++,this.xr=e.xr.clone(),this.$s=!0,this.Ks=!0,this._isVisible.copyComponents(e._isVisible),this._isBillboard.copyComponents(e._isBillboard),this.Mr=e.Mr,this.io=e.io,this.toMakeWorldMatrixTheSameAsLocalMatrix=e.toMakeWorldMatrixTheSameAsLocalMatrix,this.isRootJoint=e.isRootJoint,this.jointIndex=e.jointIndex}get entity(){return this.i.entityRepository.getEntity(this.gn)}setTransformGizmoSpace(t){var e,s,n;this.Mr=t,(e=this.Gs)==null||e.setSpace(t),(s=this.Is)==null||s.setSpace(t),(n=this.Ws)==null||n.setSpace(t)}_destroy(){var t,e,s,n,r,a,l,f;super._destroy(),i.lr(),(t=i.qs.get(this.i.objectUID))==null||t.delete(this),(e=this.Es)==null||e._destroy(),(s=this.Qs)==null||s._destroy(),(n=this.Gs)==null||n._destroy(),(r=this.Is)==null||r._destroy(),(a=this.Ws)==null||a._destroy(),(l=this.Us)==null||l._destroy(),(f=this.parent)==null||f.removeChild(this),this.children.forEach(c=>{var g;return(g=c.parent)==null?void 0:g.removeChild(c)})}addThisComponentToEntity(t,e){class s extends t.constructor{getSceneGraph(){return this.Rr===void 0&&(this.Rr=this.getComponentByComponentTID(w.SceneGraphComponentTID)),this.Rr}get parent(){return this.getSceneGraph().parent}get matrix(){return this.getSceneGraph().matrix}get matrixInner(){return this.getSceneGraph().matrixInner}get position(){return this.getSceneGraph().position}set position(r){let a=this.getSceneGraph();a.position=r}get positionRest(){return this.getSceneGraph().positionRest}get scale(){return this.getSceneGraph().scale}set scale(r){let a=this.getSceneGraph();a.scale=r}get eulerAngles(){return this.getSceneGraph().eulerAngles}set eulerAngles(r){let a=this.getSceneGraph();a.eulerAngles=r}get rotation(){return this.getSceneGraph().rotation}set rotation(r){let a=this.getSceneGraph();a.rotation=r}get rotationRest(){return this.getSceneGraph().rotationRest}addChild(r,a=!1){this.getSceneGraph().addChild(r,a)}get children(){return this.getSceneGraph().children}removeChild(r){this.getSceneGraph().removeChild(r)}}return k(t,s),t}static _cleanupForEngine(t){i.pi.delete(t),i.qs.delete(t.objectUID),i.Tr.delete(t.objectUID)}};i.Gr=0,i.Hs=1,i.Lr=W.zero(),i.jr=W.fromCopy3(1,0,0),i.Fr=W.fromCopy3(0,1,0),i.Jr=W.fromCopy3(0,0,1),i.returnVector3=b.zero(),i.Wr=[],i.invertedMatrix44=d.fromCopyArray16ColumnMajor([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),i.vr=d.identity(),i.gr=d.identity(),i.Or=d.identity(),i.Pr=R.identity(),i.Nr=R.identity(),i.Xr=R.identity(),i.Hr=R.identity(),i.Yr=b.zero(),i.Zr=b.zero(),i._r=b.zero(),i.$r=b.one(),i.Kr=b.one(),i.wr=b.zero(),i.qr=b.zero(),i.pi=new Map,i.Js=new v,i.qs=new Map,i.Tr=new Map;var V=i;V.registerMember({bufferUse:G.GPUInstanceData,memberName:"worldMatrix",dataClassType:d,shaderType:B.VertexAndPixelShader,compositionType:A.Mat4,componentType:S.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});V.registerMember({bufferUse:G.GPUInstanceData,memberName:"normalMatrix",dataClassType:Q,shaderType:B.VertexAndPixelShader,compositionType:A.Mat3,componentType:S.Float,initValues:[1,0,0,0,1,0,0,0,1]});V.registerMember({bufferUse:G.GPUInstanceData,memberName:"isVisible",dataClassType:P,shaderType:B.VertexShader,compositionType:A.Scalar,componentType:S.Float,initValues:[1],convertToBool:!0});V.registerMember({bufferUse:G.GPUInstanceData,memberName:"isBillboard",dataClassType:P,shaderType:B.VertexShader,compositionType:A.Scalar,componentType:S.Float,initValues:[0],convertToBool:!0});V.registerMember({bufferUse:G.GPUInstanceData,memberName:"previousWorldMatrix",dataClassType:d,shaderType:B.VertexShader,compositionType:A.Mat4,componentType:S.Float,initValues:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});export{V as SceneGraphComponent};
@@ -1 +1 @@
1
- import{Component as b}from"../../core/Component.js";import{applyMixins as F}from"../../core/EntityRepository.js";import{ProcessStage as R}from"../../definitions/ProcessStage.js";import{normalizeShapeDescriptor as V}from"../../geometry/Shape.js";import{_getGizmoClass as Y}from"../../gizmos/GizmoRegistry.js";import{Quaternion as _,Vector3 as m}from"../../math/index.js";import{WellKnownComponentTIDs as d}from"../WellKnownComponentTIDs.js";var D=class extends b{constructor(e,t,o,i,n){super(e,t,o,i,n);this.po=new Map;this.ao=0;this.moveStageTo(R.Logic)}static get componentTID(){return d.ShapeComponentTID}get componentTID(){return d.ShapeComponentTID}addShape(e,t={}){var n;let o=this.mo(e,t),i=this.ao++;return this.po.set(i,o),(n=this.so)==null||n.rebuild(),i}updateShape(e,t,o={}){var i;return this.po.has(e)?(this.po.set(e,this.mo(t,o)),(i=this.so)==null||i.rebuild(),!0):!1}mo(e,t){var y,S,f,z,C,g,I,w,B,E,v,x,A,T;let o=V(e),i=(S=(y=t.position)==null?void 0:y.x)!=null?S:0,n=(z=(f=t.position)==null?void 0:f.y)!=null?z:0,h=(g=(C=t.position)==null?void 0:C.z)!=null?g:0;if(![i,n,h].every(Number.isFinite))throw new Error("Shape local position components must be finite.");let s=m.fromCopy3(i,n,h);if(![s.x,s.y,s.z].every(Number.isFinite))throw new Error("Shape local position components must be representable as finite numbers.");let u=(w=(I=t.rotation)==null?void 0:I.x)!=null?w:0,r=(E=(B=t.rotation)==null?void 0:B.y)!=null?E:0,p=(x=(v=t.rotation)==null?void 0:v.z)!=null?x:0,a=(T=(A=t.rotation)==null?void 0:A.w)!=null?T:1;if(![u,r,p,a].every(Number.isFinite))throw new Error("Shape local rotation components must be finite.");let c=Math.hypot(u,r,p,a);if(!Number.isFinite(c)||c===0)throw new Error("Shape local rotation must be a non-zero quaternion.");let l=1/c;return Object.freeze({shape:o,localPosition:s,localRotation:_.fromCopy4(u*l,r*l,p*l,a*l)})}addBoxFromAabb(e,t={}){var n;if(e.isVanilla())throw new Error("Cannot create a box from an uninitialized AABB.");let o=(n=t.origin)!=null?n:m.zero();if([e.sizeX,e.sizeY,e.sizeZ,o.x,o.y,o.z].some(h=>!Number.isFinite(h))||e.sizeX<=0||e.sizeY<=0||e.sizeZ<=0)throw new Error("Box AABB and origin must contain finite values and positive dimensions.");return this.addShape({type:"box",size:m.fromCopy3(e.sizeX,e.sizeY,e.sizeZ)},{position:m.subtract(e.centerPoint,o)})}addCapsuleFromAabb(e,t={}){var r,p,a;if(e.isVanilla())throw new Error("Cannot create a capsule from an uninitialized AABB.");let o=(r=t.origin)!=null?r:m.zero(),i=(p=t.radiusScale)!=null?p:1,n=(a=t.maxRadiusToHeightRatio)!=null?a:.2;if([e.sizeX,e.sizeY,e.sizeZ,o.x,o.y,o.z,i,n].some(c=>!Number.isFinite(c))||e.sizeX<=0||e.sizeY<=0||e.sizeZ<=0)throw new Error("Capsule AABB and origin must contain finite values and positive dimensions.");if(i<=0||n<=0||n>=.5)throw new Error("Capsule radiusScale must be positive and maxRadiusToHeightRatio must be between 0 and 0.5.");let s=Math.min(Math.max(e.sizeX,e.sizeZ)/2*i,e.sizeY*n),u=e.sizeY-s*2;return this.addShape({type:"capsule",height:u,radiusBottom:s,radiusTop:s},{position:m.subtract(e.centerPoint,o)})}getShape(e=0){return this.po.get(e)}removeShape(e){var t;return!Number.isInteger(e)||e<0||!this.po.delete(e)?!1:((t=this.so)==null||t.rebuild(),!0)}clearShapes(){var e;this.po.clear(),(e=this.so)==null||e.rebuild()}get shapeCount(){return this.po.size}_getShapeEntries(){return this.po.entries()}$logic(){var e;(e=this.so)!=null&&e.isVisible&&this.so._update()}set isShapeGizmoVisible(e){e&&this.so==null&&(this.so=new(Y("shape"))(this.i,this),this.so._setup()),this.so!=null&&(this.so.isVisible=e)}get isShapeGizmoVisible(){var e,t;return(t=(e=this.so)==null?void 0:e.isVisible)!=null?t:!1}get shapeGizmo(){return this.so}_shallowCopyFrom(e){let t=e;this.po=new Map(t.po),this.ao=t.ao}_destroy(){var e;(e=this.so)==null||e._destroy(),this.so=void 0,this.clearShapes(),this.ao=0,super._destroy()}addThisComponentToEntity(e,t){class o extends e.constructor{getShape(){return this.getComponentByComponentTID(d.ShapeComponentTID)}}return F(e,o),e}};export{D as ShapeComponent};
1
+ import{Component as b}from"../../core/Component.js";import{applyMixins as F}from"../../core/EntityRepository.js";import{ProcessStage as R}from"../../definitions/ProcessStage.js";import{normalizeShapeDescriptor as V}from"../../geometry/Shape.js";import{_getGizmoClass as Y}from"../../gizmos/GizmoRegistry.js";import{Quaternion as _,Vector3 as m}from"../../math/index.js";import{WellKnownComponentTIDs as d}from"../WellKnownComponentTIDs.js";var D=class extends b{constructor(e,t,o,i,n){super(e,t,o,i,n);this.mo=new Map;this.ho=0;this.moveStageTo(R.Logic)}static get componentTID(){return d.ShapeComponentTID}get componentTID(){return d.ShapeComponentTID}addShape(e,t={}){var n;let o=this.uo(e,t),i=this.ho++;return this.mo.set(i,o),(n=this.po)==null||n.rebuild(),i}updateShape(e,t,o={}){var i;return this.mo.has(e)?(this.mo.set(e,this.uo(t,o)),(i=this.po)==null||i.rebuild(),!0):!1}uo(e,t){var y,S,f,z,C,g,I,w,B,E,v,x,A,T;let o=V(e),i=(S=(y=t.position)==null?void 0:y.x)!=null?S:0,n=(z=(f=t.position)==null?void 0:f.y)!=null?z:0,h=(g=(C=t.position)==null?void 0:C.z)!=null?g:0;if(![i,n,h].every(Number.isFinite))throw new Error("Shape local position components must be finite.");let s=m.fromCopy3(i,n,h);if(![s.x,s.y,s.z].every(Number.isFinite))throw new Error("Shape local position components must be representable as finite numbers.");let u=(w=(I=t.rotation)==null?void 0:I.x)!=null?w:0,r=(E=(B=t.rotation)==null?void 0:B.y)!=null?E:0,p=(x=(v=t.rotation)==null?void 0:v.z)!=null?x:0,a=(T=(A=t.rotation)==null?void 0:A.w)!=null?T:1;if(![u,r,p,a].every(Number.isFinite))throw new Error("Shape local rotation components must be finite.");let c=Math.hypot(u,r,p,a);if(!Number.isFinite(c)||c===0)throw new Error("Shape local rotation must be a non-zero quaternion.");let l=1/c;return Object.freeze({shape:o,localPosition:s,localRotation:_.fromCopy4(u*l,r*l,p*l,a*l)})}addBoxFromAabb(e,t={}){var n;if(e.isVanilla())throw new Error("Cannot create a box from an uninitialized AABB.");let o=(n=t.origin)!=null?n:m.zero();if([e.sizeX,e.sizeY,e.sizeZ,o.x,o.y,o.z].some(h=>!Number.isFinite(h))||e.sizeX<=0||e.sizeY<=0||e.sizeZ<=0)throw new Error("Box AABB and origin must contain finite values and positive dimensions.");return this.addShape({type:"box",size:m.fromCopy3(e.sizeX,e.sizeY,e.sizeZ)},{position:m.subtract(e.centerPoint,o)})}addCapsuleFromAabb(e,t={}){var r,p,a;if(e.isVanilla())throw new Error("Cannot create a capsule from an uninitialized AABB.");let o=(r=t.origin)!=null?r:m.zero(),i=(p=t.radiusScale)!=null?p:1,n=(a=t.maxRadiusToHeightRatio)!=null?a:.2;if([e.sizeX,e.sizeY,e.sizeZ,o.x,o.y,o.z,i,n].some(c=>!Number.isFinite(c))||e.sizeX<=0||e.sizeY<=0||e.sizeZ<=0)throw new Error("Capsule AABB and origin must contain finite values and positive dimensions.");if(i<=0||n<=0||n>=.5)throw new Error("Capsule radiusScale must be positive and maxRadiusToHeightRatio must be between 0 and 0.5.");let s=Math.min(Math.max(e.sizeX,e.sizeZ)/2*i,e.sizeY*n),u=e.sizeY-s*2;return this.addShape({type:"capsule",height:u,radiusBottom:s,radiusTop:s},{position:m.subtract(e.centerPoint,o)})}getShape(e=0){return this.mo.get(e)}removeShape(e){var t;return!Number.isInteger(e)||e<0||!this.mo.delete(e)?!1:((t=this.po)==null||t.rebuild(),!0)}clearShapes(){var e;this.mo.clear(),(e=this.po)==null||e.rebuild()}get shapeCount(){return this.mo.size}_getShapeEntries(){return this.mo.entries()}$logic(){var e;(e=this.po)!=null&&e.isVisible&&this.po._update()}set isShapeGizmoVisible(e){e&&this.po==null&&(this.po=new(Y("shape"))(this.i,this),this.po._setup()),this.po!=null&&(this.po.isVisible=e)}get isShapeGizmoVisible(){var e,t;return(t=(e=this.po)==null?void 0:e.isVisible)!=null?t:!1}get shapeGizmo(){return this.po}_shallowCopyFrom(e){let t=e;this.mo=new Map(t.mo),this.ho=t.ho}_destroy(){var e;(e=this.po)==null||e._destroy(),this.po=void 0,this.clearShapes(),this.ho=0,super._destroy()}addThisComponentToEntity(e,t){class o extends e.constructor{getShape(){return this.getComponentByComponentTID(d.ShapeComponentTID)}}return F(e,o),e}};export{D as ShapeComponent};
@@ -1 +1 @@
1
- var e=class{constructor(t){this._r=t}getEntity(){return this._r}retargetQuaternion(t){return this._r.getTransform().localRotationInner}retargetTranslate(t){return this._r.getTransform().localPositionInner}retargetScale(t){return this._r.getTransform().localScaleInner}};export{e as AbsoluteAnimation};
1
+ var e=class{constructor(t){this.Ea=t}getEntity(){return this.Ea}retargetQuaternion(t){return this.Ea.getTransform().localRotationInner}retargetTranslate(t){return this.Ea.getTransform().localPositionInner}retargetScale(t){return this.Ea.getTransform().localScaleInner}};export{e as AbsoluteAnimation};
@@ -1 +1 @@
1
- import{Quaternion as n,Vector3 as m}from"../../../math/index.js";import{Is as c}from"../../../misc/Is.js";import{getTranslationScale as g}from"./AnimationRetarget.js";var y=class{constructor(e){this._r=e}getEntity(){return this._r}getSrcPGRestQ(e){let t,r=e.getSceneGraph().parent;return c.exist(r)?t=r.getRotationRest(s=>c.exist(s.entity.tryToGetVrm())):t=n.identity(),t}getDstPGRestQ(e){let t,r=e.getSceneGraph().parent;return c.exist(r)?t=r.getRotationRest(s=>c.exist(s.entity.tryToGetVrm())):t=n.identity(),t}retargetQuaternion(e){let t=this._r,r=t.getTransform().localRotationInner,s=t.getTransform().localRotationRestInner,i=this.getSrcPGRestQ(t),a=n.multiply(i,n.multiply(r,n.multiply(n.invert(s),n.invert(i)))),l=e.getTransform().localRotationRestInner,o=this.getDstPGRestQ(e);return n.multiply(n.invert(o),n.multiply(a,n.multiply(o,l)))}retargetTranslate(e){let t=this._r,r=t.getTransform().localPositionInner,s=t.getTransform().localPositionRestInner,i=this.getSrcPGRestQ(t),a=m.subtract(r,s),l=i.transformVector3(a),o=e.getTransform().localPositionRestInner,p=this.getDstPGRestQ(e),I=g(t,e,s,o),R=m.multiply(l,I);return m.add(p.transformVector3Inverse(R),o)}retargetScale(e){return this._r.getTransform().localScaleInner}};export{y as GlobalRetarget};
1
+ import{Quaternion as n,Vector3 as m}from"../../../math/index.js";import{Is as c}from"../../../misc/Is.js";import{getTranslationScale as g}from"./AnimationRetarget.js";var y=class{constructor(e){this.Ea=e}getEntity(){return this.Ea}getSrcPGRestQ(e){let t,r=e.getSceneGraph().parent;return c.exist(r)?t=r.getRotationRest(s=>c.exist(s.entity.tryToGetVrm())):t=n.identity(),t}getDstPGRestQ(e){let t,r=e.getSceneGraph().parent;return c.exist(r)?t=r.getRotationRest(s=>c.exist(s.entity.tryToGetVrm())):t=n.identity(),t}retargetQuaternion(e){let t=this.Ea,r=t.getTransform().localRotationInner,s=t.getTransform().localRotationRestInner,i=this.getSrcPGRestQ(t),a=n.multiply(i,n.multiply(r,n.multiply(n.invert(s),n.invert(i)))),l=e.getTransform().localRotationRestInner,o=this.getDstPGRestQ(e);return n.multiply(n.invert(o),n.multiply(a,n.multiply(o,l)))}retargetTranslate(e){let t=this.Ea,r=t.getTransform().localPositionInner,s=t.getTransform().localPositionRestInner,i=this.getSrcPGRestQ(t),a=m.subtract(r,s),l=i.transformVector3(a),o=e.getTransform().localPositionRestInner,p=this.getDstPGRestQ(e),I=g(t,e,s,o),R=m.multiply(l,I);return m.add(p.transformVector3Inverse(R),o)}retargetScale(e){return this.Ea.getTransform().localScaleInner}};export{y as GlobalRetarget};
@@ -1 +1 @@
1
- import{Quaternion as e,Vector3 as a}from"../../../math/index.js";import{Is as l}from"../../../misc/Is.js";import{getTranslationScale as Q}from"./AnimationRetarget.js";var o=class o{constructor(n){this._r=n}getEntity(){return this._r}getSrcPGRestQ(n){let t,r=n.getSceneGraph().parent;return l.exist(r)?t=r.getRotationRest(s=>l.exist(s.entity.tryToGetVrm())):t=e.identity(),t}getDstPGRestQ(n){let t,r=n.getSceneGraph().parent;return l.exist(r)?t=r.getRotationRest(s=>l.exist(s.entity.tryToGetVrm())):t=e.identity(),t}retargetQuaternion(n){let t=this._r,r=t.getTransform().localRotationInner,s=t.getTransform().localRotationRestInner,c=this.getSrcPGRestQ(t),m=e.multiply(c,e.multiply(r,e.multiply(e.invert(s),e.invert(c)))),p=n.getTransform().localRotationRestInner,i=this.getDstPGRestQ(n),y=e.multiply(e.invert(i),e.multiply(m,e.multiply(i,p)));return e.multiply(e.multiply(o.co,y),e.invert(o.co))}retargetTranslate(n){let t=this._r,r=t.getTransform().localPositionInner,s=t.getTransform().localPositionRestInner,c=this.getSrcPGRestQ(t),m=a.subtract(r,s),p=c.transformVector3(m),i=n.getTransform().localPositionRestInner,y=this.getDstPGRestQ(n),I=Q(t,n,s,i),g=a.multiply(p,I),u=a.add(y.transformVector3Inverse(g),i);return o.co.transformVector3(u)}retargetScale(n){return this._r.getTransform().localScaleInner}};o.co=e.fromAxisAngle(a.fromCopy3(0,1,0),Math.PI);var R=o;export{R as GlobalRetargetReverse};
1
+ import{Quaternion as e,Vector3 as a}from"../../../math/index.js";import{Is as l}from"../../../misc/Is.js";import{getTranslationScale as Q}from"./AnimationRetarget.js";var o=class o{constructor(n){this.Ea=n}getEntity(){return this.Ea}getSrcPGRestQ(n){let t,r=n.getSceneGraph().parent;return l.exist(r)?t=r.getRotationRest(s=>l.exist(s.entity.tryToGetVrm())):t=e.identity(),t}getDstPGRestQ(n){let t,r=n.getSceneGraph().parent;return l.exist(r)?t=r.getRotationRest(s=>l.exist(s.entity.tryToGetVrm())):t=e.identity(),t}retargetQuaternion(n){let t=this.Ea,r=t.getTransform().localRotationInner,s=t.getTransform().localRotationRestInner,c=this.getSrcPGRestQ(t),m=e.multiply(c,e.multiply(r,e.multiply(e.invert(s),e.invert(c)))),p=n.getTransform().localRotationRestInner,i=this.getDstPGRestQ(n),y=e.multiply(e.invert(i),e.multiply(m,e.multiply(i,p)));return e.multiply(e.multiply(o.co,y),e.invert(o.co))}retargetTranslate(n){let t=this.Ea,r=t.getTransform().localPositionInner,s=t.getTransform().localPositionRestInner,c=this.getSrcPGRestQ(t),m=a.subtract(r,s),p=c.transformVector3(m),i=n.getTransform().localPositionRestInner,y=this.getDstPGRestQ(n),I=Q(t,n,s,i),g=a.multiply(p,I),u=a.add(y.transformVector3Inverse(g),i);return o.co.transformVector3(u)}retargetScale(n){return this.Ea.getTransform().localScaleInner}};o.co=e.fromAxisAngle(a.fromCopy3(0,1,0),Math.PI);var R=o;export{R as GlobalRetargetReverse};
@@ -47,6 +47,22 @@ export declare class SkeletalComponent extends Component {
47
47
  * w = bone data type index (used by shaders to select the decoding path).
48
48
  */
49
49
  private _boneDataInfo;
50
+ /**
51
+ * The bone data of the previous frame, for the motion vectors of temporal anti-aliasing (same layout as
52
+ * `_boneData`). It holds a single vec4 until `_enablePreviousBoneData` is called, so that applications without
53
+ * temporal anti-aliasing do not pay for it.
54
+ */
55
+ private _previousBoneData;
56
+ /**
57
+ * The location of `_previousBoneData` in the GPU data (written by the memory allocation of Component).
58
+ */
59
+ private _previousBoneDataLocation;
60
+ /**
61
+ * The bone data info of the previous frame. w is -1 while `_previousBoneData` has not received the bone data
62
+ * of a frame yet (the shaders then use the current bone data).
63
+ */
64
+ private _previousBoneDataInfo;
65
+ private __isPreviousBoneDataEnabled;
50
66
  private __boneDataUint32?;
51
67
  private __boneDataType;
52
68
  /** Whether __boneDataType was chosen automatically (an automatic Vec4x1 may be switched to Vec4x2) */
@@ -98,6 +114,14 @@ export declare class SkeletalComponent extends Component {
98
114
  * Clears any existing data to prevent contamination from previous models.
99
115
  */
100
116
  private __resetBoneDataBuffers;
117
+ /**
118
+ * Releases the view of the previous bone data so that it is re-allocated with the current length.
119
+ */
120
+ private __resetPreviousBoneData;
121
+ /**
122
+ * Marks the previous bone data as not received yet (the shaders use the current bone data instead).
123
+ */
124
+ private __invalidatePreviousBoneData;
101
125
  /**
102
126
  * Gets the static component type identifier for SkeletalComponent.
103
127
  *
@@ -204,6 +228,30 @@ export declare class SkeletalComponent extends Component {
204
228
  * @returns The bone data info vector
205
229
  */
206
230
  get boneDataInfo(): MutableVector4;
231
+ /**
232
+ * Allocates the bone data of the previous frame (used by the motion vectors of temporal anti-aliasing).
233
+ * Until the first `_updatePreviousBoneData`, the shaders use the current bone data.
234
+ *
235
+ * @internal
236
+ */
237
+ _enablePreviousBoneData(): void;
238
+ /**
239
+ * Copies the bone data into the previous bone data if they differ.
240
+ *
241
+ * @remarks
242
+ * Called once per frame before the logic stage, when the bone data still holds the previous frame. A skeleton
243
+ * that stopped is copied once more in the frame after it stopped and then not any more.
244
+ *
245
+ * @returns Whether the previous bone data was written (the GPU instance data has to be uploaded)
246
+ * @internal
247
+ */
248
+ _updatePreviousBoneData(): boolean;
249
+ /**
250
+ * The bone data of the previous frame (allocated by `_enablePreviousBoneData`).
251
+ *
252
+ * @internal
253
+ */
254
+ get _previousBoneDataArray(): Float32Array;
207
255
  /**
208
256
  * Gets a copy of the world matrix.
209
257
  *
@@ -1 +1 @@
1
- import{Component as N}from"../../core/Component.js";import{applyMixins as W}from"../../core/EntityRepository.js";import{BoneDataType as b}from"../../definitions/BoneDataType.js";import{BufferUse as w}from"../../definitions/BufferUse.js";import{ComponentType as B}from"../../definitions/ComponentType.js";import{CompositionType as G}from"../../definitions/CompositionType.js";import{ProcessStage as z}from"../../definitions/ProcessStage.js";import{ShaderType as F}from"../../definitions/ShaderType.js";import{MathUtil as S}from"../../math/MathUtil.js";import{Matrix44 as O}from"../../math/Matrix44.js";import{MutableMatrix44 as D}from"../../math/MutableMatrix44.js";import{MutableQuaternion as $}from"../../math/MutableQuaternion.js";import{MutableVector4 as A}from"../../math/MutableVector4.js";import{VectorN as E}from"../../math/VectorN.js";import{DataUtil as H,Is as L}from"../../misc/index.js";import{AnimationStateRepository as x}from"../Animation/AnimationStateRepository.js";import{SceneGraphComponent as j}from"../SceneGraph/SceneGraphComponent.js";import{WellKnownComponentTIDs as J}from"../WellKnownComponentTIDs.js";var P=2147483648,i=class i extends N{constructor(t,e,n,s,a){super(t,e,n,s,a);this._jointIndices=[];this._a=[];this.isSkinning=!0;this._boneData=E.dummy();this._boneDataLocation=A.dummy();this._boneDataInfo=A.dummy();this.Wa=b.Vec4x2;this.$a=!1;this.Ya=!1;this.Qa=0;this.qa=new Float32Array(0);this.Ua=D.identity();this.Ja=!0;this._isCulled=!1;this.Ka=-1;this.ho=-1;this.lo=!1;this.go=-1;this.Do=-1;if(this.moveStageTo(z.Logic),a){this.xo(),this.Ua=D.identity(),this.Ja=!0,this._a=[],this.La=void 0,this.topOfJointsHierarchy=void 0,this._bindShapeMatrix=void 0,this.isSkinning=!0,this.Wa=b.Vec4x2,this.$a=!1,this.Ya=!1,this.Ma=void 0,this.Qa=0,this.Ga=void 0,this.Ea=void 0,this.Fa=void 0,this.Ka=-1,this.ho=-1;return}i.Vo++}xo(){this._boneData.isDummy()||this._boneData._v.fill(0),this._boneData=E.dummy(),this.Xa=void 0}static get componentTID(){return J.SkeletalComponentTID}get componentTID(){return J.SkeletalComponentTID}setInverseBindMatricesAccessor(t){this.wa=t,this.Fa=i.To(t),this.Ha()}setJoints(t){this.ja(),this._a=t,this.Ga=i.Io(t),this.xo();let e=this.boneDataType;this.Qa=i.ko(e,t.length);let n=this.$o;this.submitToAllocation(this.i.config.skeletalComponentCountPerBufferView,n),this.Xa=new Uint32Array(this._boneData._v.buffer,this._boneData._v.byteOffset,this._boneData._v.length),this.Ma=e,this.uo(1,1,1,e),this.Ha()}get boneDataType(){var t;return(t=this.i.config.boneDataType)!=null?t:this.Wa}setBoneDataType(t,e=!1){this.Wa=t,this.$a=e,this._o()}_o(){let t=this.boneDataType;this.Ma===void 0||this.Ma===t||this.setJoints(this._a)}static ko(t,e){return Math.max(e,1)*b.getVec4CountPerJoint(t)}_getArrayLengthForAllocation(t){if(t==="boneData"&&this.Qa>0)return this.Qa}uo(t,e,n,s){if(this._boneDataInfo.isDummy())return;let a=this._boneDataInfo._v;a[0]=t,a[1]=e,a[2]=n,a[3]=s.index}updateJointsLightweight(t){this.ja(),this._a=t,this.Ga=i.Io(t),this.Ha()}getJoints(){return this._a.concat()}get rootJointWorldMatrixInner(){var t;return(t=this.topOfJointsHierarchy)==null?void 0:t.matrixInner}get jointMatrices(){return this.La}get boneDataArray(){return this._boneData._v}get boneDataInfo(){return this._boneDataInfo}get worldMatrix(){return this.Ua.clone()}get worldMatrixInner(){return D.multiplyTo(this.entity.matrixInner,this.Ua,i.Lr)}get isWorldMatrixUpdated(){return!this.Ja}set isJointGizmosVisible(t){for(let e=0;e<this._a.length;e++)this._a[e].isJointGizmoVisible=t}get isJointGizmosVisible(){for(let t=0;t<this._a.length;t++)if(this._a[t].isJointGizmoVisible)return!0;return!1}$logic(){if(!this.isSkinning)return;let t=x.getProcessFrameToken(this.i);if(x.handleFrameTransitionIfNeeded(this.i,t),this._boneData.isDummy())return;if(this._isCulled){this.ja(),this.Co(),this.Ea!==void 0&&x.addCulledSkeletonJoints(this.i,this.Ea,this._a);return}this._o(),this.Co();let e=this.Ea,n=x.getOrCreateCacheLeaders(this.i),s=x.getOrCreateLeaderJointIndexToEntityUID(this.i),a=x.getOrCreateCurrentFrameCachedEntityUIDs(this.i);if(e){let o=i.Za.get(e);if((o==null?void 0:o.processFrameToken)===t){if(!(n.get(e)===this.entityUID))for(let f of this._a){let c=s.get(f.jointIndex);c!==void 0&&c!==f.entityUID&&a.add(f.entityUID)}this.Uo(o),this.ja();return}n.set(e,this.entityUID);for(let u of this._a)s.set(u.jointIndex,u.entityUID)}if(this.wo(e)){e&&i.Za.set(e,this.Mo(t));return}let h=this.Ma,m=this._boneData._v,y=this.Xa,p=this.Bo(h),V=D.invertTo(this.entity.matrixInner,i.Eo),l=!1;for(let o=0;o<this._a.length;o++){let u=this._a[o],f=u.matrixInner,c=D.multiplyTo(V,D.multiplyTypedArrayTo(f,this.wa.getTypedArray(),i.gr,o),i.mr);this._bindShapeMatrix&&c.multiply(this._bindShapeMatrix);let d=c;if(o===0&&u.entity.tryToGetAnimation()!=null&&this.Ua.copyComponents(d),o===1&&this._a[0].entity.tryToGetAnimation()==null&&this.Ua.copyComponents(d),this.Ja=!1,h===b.Mat43x1){this.Go(d,o);continue}let r=d._v,g=Math.hypot(r[0],r[1],r[2]),_=Math.hypot(r[4],r[5],r[6]),T=Math.hypot(r[8],r[9],r[10]),U=i.Fo(r)<0;if(h===b.Vec4x2){let C=U?-g:g,v=i.So(d,C,_,T),M=S.encodeLogQuat(v.x,v.y,v.z,v.w),I=o*8;m[I+0]=r[12],m[I+1]=r[13],m[I+2]=r[14],y[I+3]=M[0],m[I+4]=C,m[I+5]=_,m[I+6]=T,y[I+7]=M[1]}else{!l&&!S.isUniformScale(g,_,T)&&(l=!0);let C=U?-1:1,v=i.So(d,C*g,C*_,C*T),M=S.encodeLogQuat(v.x,v.y,v.z,v.w);p[o*4+0]=r[12],p[o*4+1]=r[13],p[o*4+2]=r[14],p[o*4+3]=Math.max(g,_,T),y[o*4+0]=M[0],y[o*4+1]=U?(M[1]|P)>>>0:M[1]}}if(l&&this.Jo()){this.$logic();return}if(h===b.Vec4x1){let o=1,u=1,f=1;for(let c=0;c<this._a.length;c++){let d=Math.abs(p[c*4+0]);d>o&&(o=d);let r=Math.abs(p[c*4+1]);r>u&&(u=r);let g=Math.abs(p[c*4+2]);g>f&&(f=g)}for(let c=0;c<this._a.length;c++){let d=p[c*4+0]/o,r=p[c*4+1]/u,g=p[c*4+2]/f,_=S.encodeVec4x1Scale(p[c*4+3]),T=S.packSnormVec4ToUVec2(d,r,g,_);y[c*4+2]=T[0],y[c*4+3]=T[1]}this.uo(o,u,f,h)}else this.uo(1,1,1,h);e&&i.Za.set(e,this.Mo(t)),this.Lo(e)}static Fo(t){return t[0]*(t[5]*t[10]-t[6]*t[9])+t[1]*(t[6]*t[8]-t[4]*t[10])+t[2]*(t[4]*t[9]-t[5]*t[8])}static So(t,e,n,s){let a=t._v,h=1/e,m=1/n,y=1/s;a[0]*=h,a[1]*=h,a[2]*=h,a[4]*=m,a[5]*=m,a[6]*=m,a[8]*=y,a[9]*=y,a[10]*=y;let p=i.Ao;return p.tryFromMatrix(t)||p.setComponents(0,0,0,1),p}Jo(){let t=this.jo();if(this.i.config.boneDataType==null&&t.every(e=>e.$a)){for(let e of t)e.setBoneDataType(b.Vec4x2,!0);return this.i.logger.info(`SkeletalComponent (entity ${this.entityUID}): switched the bone data type from Vec4x1 to Vec4x2 because a non-uniform scale was found (${t.length} component(s) sharing the skinning cache).`),this.Ma===b.Vec4x2}return this.Ya||(this.Ya=!0,this.i.logger.warn(`SkeletalComponent (entity ${this.entityUID}): the Vec4x1 bone data type supports only uniform scale, but a non-uniform scale was found. The largest scale is used. Use Vec4x2 or Mat43x1 for this skeleton.`)),!1}jo(){var n;let t=this.Ea;return t==null?[this]:((n=this.i.componentRepository.getComponentsWithType(i))!=null?n:[]).filter(s=>s===this||s.Ea===t)}Bo(t){if(t!==b.Vec4x1)return this.qa;let e=this._a.length*4;return this.qa.length<e&&(this.qa=new Float32Array(e)),this.qa}Go(t,e){this._boneData._v[e*12+0]=t._v[0],this._boneData._v[e*12+1]=t._v[1],this._boneData._v[e*12+2]=t._v[2],this._boneData._v[e*12+3]=t._v[4],this._boneData._v[e*12+4]=t._v[5],this._boneData._v[e*12+5]=t._v[6],this._boneData._v[e*12+6]=t._v[8],this._boneData._v[e*12+7]=t._v[9],this._boneData._v[e*12+8]=t._v[10],this._boneData._v[e*12+9]=t._v[12],this._boneData._v[e*12+10]=t._v[13],this._boneData._v[e*12+11]=t._v[14]}getInverseBindMatricesAccessor(){return this.wa}_shallowCopyFrom(t){let e=t;this._jointIndices=e._jointIndices.concat(),this.Wa=e.Wa,this.$a=e.$a,e._a.length>0?(this.setJoints(e._a.concat()),this.No(e)):(this._a=[],this.ja()),this.wa=e.wa,L.exist(e._bindShapeMatrix)&&(this._bindShapeMatrix=e._bindShapeMatrix.clone()),this.topOfJointsHierarchy=e.topOfJointsHierarchy,this.isSkinning=e.isSkinning,this.Ua.copyComponents(e.Ua),this.Ja=e.Ja,this.Fa=e.Fa,this.Ga=e.Ga,this.Ha()}get entity(){return this.i.entityRepository.getEntity(this.gn)}_destroy(){this.ja(),super._destroy()}static isEntityCached(t,e){return x.isEntityCached(t,e)}addThisComponentToEntity(t,e){class n extends t.constructor{getSkeletal(){return this.getComponentByComponentTID(J.SkeletalComponentTID)}}return W(t,n),t}_getInverseBindMatrices(t){let e=this._a.indexOf(t),n=this.wa.getTypedArray();return new O(n.slice(e*16,e*16+16))}No(t){let e=(n,s)=>{n.isDummy()||s.isDummy()||n.copyComponents(s)};L.exist(t.La)?this.La=t.La.concat():this.La=void 0,this.Ma===t.Ma&&this._boneData._v.length===t._boneData._v.length&&(e(this._boneData,t._boneData),!this._boneDataInfo.isDummy()&&!t._boneDataInfo.isDummy()&&this._boneDataInfo.copyComponents(t._boneDataInfo))}static _registerBoneDataMember(){i.registerMember({bufferUse:w.GPUInstanceData,memberName:"boneDataLocation",dataClassType:A,shaderType:F.VertexShader,compositionType:G.Vec4,componentType:B.Float,initValues:[0,0,0,0]}),i.registerMember({bufferUse:w.GPUInstanceData,memberName:"boneData",dataClassType:E,shaderType:F.VertexShader,compositionType:G.Vec4Array,componentType:B.Float,initValues:new E(new Float32Array(0)),isVariableLength:!0})}static _registerBoneDataInfoMember(){i.registerMember({bufferUse:w.GPUInstanceData,memberName:"boneDataInfo",dataClassType:A,shaderType:F.VertexShader,compositionType:G.Vec4,componentType:B.Float,initValues:[1,1,1,b.Vec4x2.index]})}static Io(t){return t.map(e=>e.jointIndex>=0?e.jointIndex:-1).join(",")}static Wo(t){let e=2166136261;for(let n=0;n<t.length;n++)e^=t[n],e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24),e>>>=0;return e>>>0}static To(t){let e=this.fo.get(t);if(e!==void 0)return e;let n=t.getTypedArray(),s=new Uint8Array(n.buffer,n.byteOffset,n.byteLength),h=this.Wo(s).toString(16);return this.fo.set(t,h),h}static Ho(t){if(!t)return"no_bind_shape";let e=this.yo.get(t);if(e!==void 0)return e;let n=Array.from(t._v).join(",");return this.yo.set(t,n),n}zo(){if(this.entity.parent!=null)return this.Oo(this.entity.parent.entity)}Oo(t){let e=[],n=s=>{let a=s.tryToGetAnimation();if(a!=null){let h=a.getAnimationChannelsOfTrack();if(h.size>0){let m=new Set,y=a.getActiveAnimationTrack(),p=Array.from(h.keys()).some(l=>l.startsWith("vrmExpression/")),V=!1;for(let[l,o]of h)if(!l.startsWith("vrmExpression/")&&o.animatedValue.getAllTrackNames().includes(y)){V=!0;break}if(V){let l=a.currentTrackFeatureHash();l!=null&&m.add(l)}if(m.size===0&&!p)for(let[l,o]of h){if(l.startsWith("vrmExpression/"))continue;let u=o.animatedValue.getFirstActiveAnimationSamplerTrackName(),f=a.getAnimationTrackFeatureHash(u);f!=null&&m.add(f)}for(let l of m)e.push(l)}}for(let h of s.children)n(h.entity)};if(n(t),e.length!==0)return e.length===1?e[0]:H.toCRC32(e.join("|"))}Co(){this.Ka===x.getAnimationBindingVersion()&&this.ho===j.hierarchyVersion||this.Ha()}Ha(){var n,s;if(this.Ka=x.getAnimationBindingVersion(),this.ho=j.hierarchyVersion,!this.wa){this.Ea=void 0;return}this.Fa||(this.Fa=i.To(this.wa));let t=this.zo(),e=((n=this.Ma)!=null?n:this.boneDataType).index;if(t!=null)this.Ea=`anim|${t.toString()}|${this.Fa}|${(s=this.Ga)!=null?s:""}|${e}`;else{if(!this.Ga){this.Ea=void 0;return}this.Ea=`${this.Ga}|${this.Fa}|no_animation|${e}`}}ja(){this.lo=!1}wo(t){if(!this.lo||this.bo!==t||this.vo!==this._bindShapeMatrix)return!1;let e=this.entity.getSceneGraph();if(e==null||e.worldMatrixVersion!==this.Do)return!1;let n=0;for(let s=0;s<this._a.length;s++)n+=this._a[s].worldMatrixVersion;return n===this.go}Lo(t){var n,s;let e=0;for(let a=0;a<this._a.length;a++)e+=this._a[a].worldMatrixVersion;this.bo=t,this.go=e,this.Do=(s=(n=this.entity.getSceneGraph())==null?void 0:n.worldMatrixVersion)!=null?s:-1,this.vo=this._bindShapeMatrix,this.lo=!0}Mo(t){let e=this._boneDataInfo._v;return{processFrameToken:t,boneData:this._boneData.isDummy()?void 0:this._boneData._v,boneDataInfo:[e[0],e[1],e[2],e[3]],jointMatrix:this.Ua._v,isWorldMatrixVanilla:this.Ja}}Uo(t){if(this.Ja=t.isWorldMatrixVanilla,this.Ua._v.set(t.jointMatrix),t.boneData==null)return;let e=this._a.length*b.getVec4CountPerJoint(this.Ma)*4;this._boneData._v.set(t.boneData.subarray(0,Math.min(e,this._boneData._v.length))),this._boneDataInfo.isDummy()||this._boneDataInfo._v.set(t.boneDataInfo)}};i.Za=new Map,i.fo=new WeakMap,i.yo=new WeakMap,i.Vo=0,i.gr=D.identity(),i.Ao=$.fromCopy4(0,0,0,1),i.Eo=D.identity(),i.mr=D.identity(),i.Lr=D.identity();var k=i;k._registerBoneDataMember();k._registerBoneDataInfoMember();export{k as SkeletalComponent};
1
+ import{Component as j}from"../../core/Component.js";import{applyMixins as P}from"../../core/EntityRepository.js";import{BoneDataType as b}from"../../definitions/BoneDataType.js";import{BufferUse as A}from"../../definitions/BufferUse.js";import{ComponentType as E}from"../../definitions/ComponentType.js";import{CompositionType as B}from"../../definitions/CompositionType.js";import{ProcessStage as W}from"../../definitions/ProcessStage.js";import{ShaderType as k}from"../../definitions/ShaderType.js";import{MathUtil as U}from"../../math/MathUtil.js";import{Matrix44 as O}from"../../math/Matrix44.js";import{MutableMatrix44 as v}from"../../math/MutableMatrix44.js";import{MutableQuaternion as z}from"../../math/MutableQuaternion.js";import{MutableVector4 as I}from"../../math/MutableVector4.js";import{VectorN as C}from"../../math/VectorN.js";import{DataUtil as $,Is as L}from"../../misc/index.js";import{AnimationStateRepository as _}from"../Animation/AnimationStateRepository.js";import{SceneGraphComponent as N}from"../SceneGraph/SceneGraphComponent.js";import{WellKnownComponentTIDs as J}from"../WellKnownComponentTIDs.js";var H=2147483648,s=class s extends j{constructor(t,e,i,n,a){super(t,e,i,n,a);this._jointIndices=[];this._a=[];this.isSkinning=!0;this._boneData=C.dummy();this._boneDataLocation=I.dummy();this._boneDataInfo=I.dummy();this._previousBoneData=C.dummy();this._previousBoneDataLocation=I.dummy();this._previousBoneDataInfo=I.dummy();this.Ha=!1;this.Qa=b.Vec4x2;this.qa=!1;this.Ka=!1;this.Wa=0;this.Ya=new Float32Array(0);this.wa=v.identity();this.La=!0;this._isCulled=!1;this.yo=-1;this.bo=-1;this.Do=!1;this.xo=-1;this.Io=-1;if(this.moveStageTo(W.Logic),a){this.Mo(),this.wa=v.identity(),this.La=!0,this._a=[],this.ja=void 0,this.topOfJointsHierarchy=void 0,this._bindShapeMatrix=void 0,this.isSkinning=!0,this.Qa=b.Vec4x2,this.qa=!1,this.Ha=!1,this.Ka=!1,this.Ma=void 0,this.Wa=0,this.Fa=void 0,this.Ua=void 0,this.Ja=void 0,this.yo=-1,this.bo=-1;return}s.Go++}Mo(){this._boneData.isDummy()||this._boneData._v.fill(0),this._boneData=C.dummy(),this.Za=void 0,this.So()}So(){this._previousBoneData.isDummy()||this._previousBoneData._v.fill(0),this._previousBoneData=C.dummy(),this.Vo()}Vo(){this._previousBoneDataInfo.isDummy()||(this._previousBoneDataInfo._v[3]=-1)}static get componentTID(){return J.SkeletalComponentTID}get componentTID(){return J.SkeletalComponentTID}setInverseBindMatricesAccessor(t){this.Ga=t,this.Ja=s.Ao(t),this.Xa()}setJoints(t){this.$a(),this._a=t,this.Fa=s.Eo(t),this.Mo();let e=this.boneDataType;this.Wa=s.Lo(e,t.length);let i=this.No;this.submitToAllocation(this.i.config.skeletalComponentCountPerBufferView,i),this.Za=new Uint32Array(this._boneData._v.buffer,this._boneData._v.byteOffset,this._boneData._v.length),this.Ma=e,this.vo(1,1,1,e),this.Xa()}get boneDataType(){var t;return(t=this.i.config.boneDataType)!=null?t:this.Qa}setBoneDataType(t,e=!1){this.Qa=t,this.qa=e,this.Bo()}Bo(){let t=this.boneDataType;this.Ma===void 0||this.Ma===t||this.setJoints(this._a)}static Lo(t,e){return Math.max(e,1)*b.getVec4CountPerJoint(t)}_getArrayLengthForAllocation(t){if(t==="boneData"&&this.Wa>0)return this.Wa;if(t==="previousBoneData")return this.Ha&&this.Wa>0?this.Wa:1}vo(t,e,i,n){if(this._boneDataInfo.isDummy())return;let a=this._boneDataInfo._v;a[0]=t,a[1]=e,a[2]=i,a[3]=n.index}updateJointsLightweight(t){this.$a(),this._a=t,this.Fa=s.Eo(t),this.Xa()}getJoints(){return this._a.concat()}get rootJointWorldMatrixInner(){var t;return(t=this.topOfJointsHierarchy)==null?void 0:t.matrixInner}get jointMatrices(){return this.ja}get boneDataArray(){return this._boneData._v}get boneDataInfo(){return this._boneDataInfo}_enablePreviousBoneData(){this.Ha||(this.Ha=!0,!this._boneData.isDummy()&&(this.So(),this.submitToAllocation(this.i.config.skeletalComponentCountPerBufferView,this.No),this.Vo()))}_updatePreviousBoneData(){if(!this.Ha||this._boneData.isDummy()||this._previousBoneData.isDummy())return!1;let t=this._boneData._v,e=this._previousBoneData._v;if(e.length!==t.length)return!1;let i=this._boneDataInfo._v,n=this._previousBoneDataInfo._v,a=n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3];if(a){let r=new Uint32Array(t.buffer,t.byteOffset,t.length),c=new Uint32Array(e.buffer,e.byteOffset,e.length);for(let u=0;u<r.length;u++)if(r[u]!==c[u]){a=!1;break}}return a?!1:(e.set(t),n.set(i),!0)}get _previousBoneDataArray(){return this._previousBoneData._v}get worldMatrix(){return this.wa.clone()}get worldMatrixInner(){return v.multiplyTo(this.entity.matrixInner,this.wa,s.Or)}get isWorldMatrixUpdated(){return!this.La}set isJointGizmosVisible(t){for(let e=0;e<this._a.length;e++)this._a[e].isJointGizmoVisible=t}get isJointGizmosVisible(){for(let t=0;t<this._a.length;t++)if(this._a[t].isJointGizmoVisible)return!0;return!1}$logic(){if(!this.isSkinning)return;let t=_.getProcessFrameToken(this.i);if(_.handleFrameTransitionIfNeeded(this.i,t),this._boneData.isDummy())return;if(this._isCulled){this.$a(),this.ko(),this.Ua!==void 0&&_.addCulledSkeletonJoints(this.i,this.Ua,this._a);return}this.Bo(),this.ko();let e=this.Ua,i=_.getOrCreateCacheLeaders(this.i),n=_.getOrCreateLeaderJointIndexToEntityUID(this.i),a=_.getOrCreateCurrentFrameCachedEntityUIDs(this.i);if(e){let o=s.fo.get(e);if((o==null?void 0:o.processFrameToken)===t){if(!(i.get(e)===this.entityUID))for(let y of this._a){let p=n.get(y.jointIndex);p!==void 0&&p!==y.entityUID&&a.add(y.entityUID)}this.jo(o),this.$a();return}i.set(e,this.entityUID);for(let l of this._a)n.set(l.jointIndex,l.entityUID)}if(this.Po(e)){e&&s.fo.set(e,this.Uo(t));return}let r=this.Ma,c=this._boneData._v,u=this.Za,m=this.Wo(r),w=v.invertTo(this.entity.matrixInner,s.Jo),f=!1;for(let o=0;o<this._a.length;o++){let l=this._a[o],y=l.matrixInner,p=v.multiplyTo(w,v.multiplyTypedArrayTo(y,this.Ga.getTypedArray(),s.vr,o),s.gr);this._bindShapeMatrix&&p.multiply(this._bindShapeMatrix);let d=p;if(o===0&&l.entity.tryToGetAnimation()!=null&&this.wa.copyComponents(d),o===1&&this._a[0].entity.tryToGetAnimation()==null&&this.wa.copyComponents(d),this.La=!1,r===b.Mat43x1){this.Oo(d,o);continue}let h=d._v,D=Math.hypot(h[0],h[1],h[2]),M=Math.hypot(h[4],h[5],h[6]),T=Math.hypot(h[8],h[9],h[10]),F=s.zo(h)<0;if(r===b.Vec4x2){let S=F?-D:D,g=s.wo(d,S,M,T),V=U.encodeLogQuat(g.x,g.y,g.z,g.w),x=o*8;c[x+0]=h[12],c[x+1]=h[13],c[x+2]=h[14],u[x+3]=V[0],c[x+4]=S,c[x+5]=M,c[x+6]=T,u[x+7]=V[1]}else{!f&&!U.isUniformScale(D,M,T)&&(f=!0);let S=F?-1:1,g=s.wo(d,S*D,S*M,S*T),V=U.encodeLogQuat(g.x,g.y,g.z,g.w);m[o*4+0]=h[12],m[o*4+1]=h[13],m[o*4+2]=h[14],m[o*4+3]=Math.max(D,M,T),u[o*4+0]=V[0],u[o*4+1]=F?(V[1]|H)>>>0:V[1]}}if(f&&this.$o()){this.$logic();return}if(r===b.Vec4x1){let o=1,l=1,y=1;for(let p=0;p<this._a.length;p++){let d=Math.abs(m[p*4+0]);d>o&&(o=d);let h=Math.abs(m[p*4+1]);h>l&&(l=h);let D=Math.abs(m[p*4+2]);D>y&&(y=D)}for(let p=0;p<this._a.length;p++){let d=m[p*4+0]/o,h=m[p*4+1]/l,D=m[p*4+2]/y,M=U.encodeVec4x1Scale(m[p*4+3]),T=U.packSnormVec4ToUVec2(d,h,D,M);u[p*4+2]=T[0],u[p*4+3]=T[1]}this.vo(o,l,y,r)}else this.vo(1,1,1,r);e&&s.fo.set(e,this.Uo(t)),this.Ho(e)}static zo(t){return t[0]*(t[5]*t[10]-t[6]*t[9])+t[1]*(t[6]*t[8]-t[4]*t[10])+t[2]*(t[4]*t[9]-t[5]*t[8])}static wo(t,e,i,n){let a=t._v,r=1/e,c=1/i,u=1/n;a[0]*=r,a[1]*=r,a[2]*=r,a[4]*=c,a[5]*=c,a[6]*=c,a[8]*=u,a[9]*=u,a[10]*=u;let m=s.Fo;return m.tryFromMatrix(t)||m.setComponents(0,0,0,1),m}$o(){let t=this.Qo();if(this.i.config.boneDataType==null&&t.every(e=>e.qa)){for(let e of t)e.setBoneDataType(b.Vec4x2,!0);return this.i.logger.info(`SkeletalComponent (entity ${this.entityUID}): switched the bone data type from Vec4x1 to Vec4x2 because a non-uniform scale was found (${t.length} component(s) sharing the skinning cache).`),this.Ma===b.Vec4x2}return this.Ka||(this.Ka=!0,this.i.logger.warn(`SkeletalComponent (entity ${this.entityUID}): the Vec4x1 bone data type supports only uniform scale, but a non-uniform scale was found. The largest scale is used. Use Vec4x2 or Mat43x1 for this skeleton.`)),!1}Qo(){var i;let t=this.Ua;return t==null?[this]:((i=this.i.componentRepository.getComponentsWithType(s))!=null?i:[]).filter(n=>n===this||n.Ua===t)}Wo(t){if(t!==b.Vec4x1)return this.Ya;let e=this._a.length*4;return this.Ya.length<e&&(this.Ya=new Float32Array(e)),this.Ya}Oo(t,e){this._boneData._v[e*12+0]=t._v[0],this._boneData._v[e*12+1]=t._v[1],this._boneData._v[e*12+2]=t._v[2],this._boneData._v[e*12+3]=t._v[4],this._boneData._v[e*12+4]=t._v[5],this._boneData._v[e*12+5]=t._v[6],this._boneData._v[e*12+6]=t._v[8],this._boneData._v[e*12+7]=t._v[9],this._boneData._v[e*12+8]=t._v[10],this._boneData._v[e*12+9]=t._v[12],this._boneData._v[e*12+10]=t._v[13],this._boneData._v[e*12+11]=t._v[14]}getInverseBindMatricesAccessor(){return this.Ga}_shallowCopyFrom(t){let e=t;this._jointIndices=e._jointIndices.concat(),this.Qa=e.Qa,this.qa=e.qa,e._a.length>0?(this.setJoints(e._a.concat()),this.Ro(e)):(this._a=[],this.$a()),this.Ga=e.Ga,L.exist(e._bindShapeMatrix)&&(this._bindShapeMatrix=e._bindShapeMatrix.clone()),this.topOfJointsHierarchy=e.topOfJointsHierarchy,this.isSkinning=e.isSkinning,this.wa.copyComponents(e.wa),this.La=e.La,this.Ja=e.Ja,this.Fa=e.Fa,this.Xa()}get entity(){return this.i.entityRepository.getEntity(this.gn)}_destroy(){this.$a(),super._destroy()}static isEntityCached(t,e){return _.isEntityCached(t,e)}addThisComponentToEntity(t,e){class i extends t.constructor{getSkeletal(){return this.getComponentByComponentTID(J.SkeletalComponentTID)}}return P(t,i),t}_getInverseBindMatrices(t){let e=this._a.indexOf(t),i=this.Ga.getTypedArray();return new O(i.slice(e*16,e*16+16))}Ro(t){let e=(i,n)=>{i.isDummy()||n.isDummy()||i.copyComponents(n)};L.exist(t.ja)?this.ja=t.ja.concat():this.ja=void 0,this.Ma===t.Ma&&this._boneData._v.length===t._boneData._v.length&&(e(this._boneData,t._boneData),!this._boneDataInfo.isDummy()&&!t._boneDataInfo.isDummy()&&this._boneDataInfo.copyComponents(t._boneDataInfo))}static _registerBoneDataMember(){s.registerMember({bufferUse:A.GPUInstanceData,memberName:"boneDataLocation",dataClassType:I,shaderType:k.VertexShader,compositionType:B.Vec4,componentType:E.Float,initValues:[0,0,0,0]}),s.registerMember({bufferUse:A.GPUInstanceData,memberName:"boneData",dataClassType:C,shaderType:k.VertexShader,compositionType:B.Vec4Array,componentType:E.Float,initValues:new C(new Float32Array(0)),isVariableLength:!0}),s.registerMember({bufferUse:A.GPUInstanceData,memberName:"previousBoneDataLocation",dataClassType:I,shaderType:k.VertexShader,compositionType:B.Vec4,componentType:E.Float,initValues:[0,0,0,0]}),s.registerMember({bufferUse:A.GPUInstanceData,memberName:"previousBoneData",dataClassType:C,shaderType:k.VertexShader,compositionType:B.Vec4Array,componentType:E.Float,initValues:new C(new Float32Array(0)),isVariableLength:!0})}static _registerBoneDataInfoMember(){s.registerMember({bufferUse:A.GPUInstanceData,memberName:"boneDataInfo",dataClassType:I,shaderType:k.VertexShader,compositionType:B.Vec4,componentType:E.Float,initValues:[1,1,1,b.Vec4x2.index]}),s.registerMember({bufferUse:A.GPUInstanceData,memberName:"previousBoneDataInfo",dataClassType:I,shaderType:k.VertexShader,compositionType:B.Vec4,componentType:E.Float,initValues:[1,1,1,-1]})}static Eo(t){return t.map(e=>e.jointIndex>=0?e.jointIndex:-1).join(",")}static qo(t){let e=2166136261;for(let i=0;i<t.length;i++)e^=t[i],e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24),e>>>=0;return e>>>0}static Ao(t){let e=this.go.get(t);if(e!==void 0)return e;let i=t.getTypedArray(),n=new Uint8Array(i.buffer,i.byteOffset,i.byteLength),r=this.qo(n).toString(16);return this.go.set(t,r),r}static Zo(t){if(!t)return"no_bind_shape";let e=this._o.get(t);if(e!==void 0)return e;let i=Array.from(t._v).join(",");return this._o.set(t,i),i}Xo(){if(this.entity.parent!=null)return this.Yo(this.entity.parent.entity)}Yo(t){let e=[],i=n=>{let a=n.tryToGetAnimation();if(a!=null){let r=a.getAnimationChannelsOfTrack();if(r.size>0){let c=new Set,u=a.getActiveAnimationTrack(),m=Array.from(r.keys()).some(f=>f.startsWith("vrmExpression/")),w=!1;for(let[f,o]of r)if(!f.startsWith("vrmExpression/")&&o.animatedValue.getAllTrackNames().includes(u)){w=!0;break}if(w){let f=a.currentTrackFeatureHash();f!=null&&c.add(f)}if(c.size===0&&!m)for(let[f,o]of r){if(f.startsWith("vrmExpression/"))continue;let l=o.animatedValue.getFirstActiveAnimationSamplerTrackName(),y=a.getAnimationTrackFeatureHash(l);y!=null&&c.add(y)}for(let f of c)e.push(f)}}for(let r of n.children)i(r.entity)};if(i(t),e.length!==0)return e.length===1?e[0]:$.toCRC32(e.join("|"))}ko(){this.yo===_.getAnimationBindingVersion()&&this.bo===N.hierarchyVersion||this.Xa()}Xa(){var i,n;if(this.yo=_.getAnimationBindingVersion(),this.bo=N.hierarchyVersion,!this.Ga){this.Ua=void 0;return}this.Ja||(this.Ja=s.Ao(this.Ga));let t=this.Xo(),e=((i=this.Ma)!=null?i:this.boneDataType).index;if(t!=null)this.Ua=`anim|${t.toString()}|${this.Ja}|${(n=this.Fa)!=null?n:""}|${e}`;else{if(!this.Fa){this.Ua=void 0;return}this.Ua=`${this.Fa}|${this.Ja}|no_animation|${e}`}}$a(){this.Do=!1}Po(t){if(!this.Do||this.To!==t||this.Co!==this._bindShapeMatrix)return!1;let e=this.entity.getSceneGraph();if(e==null||e.worldMatrixVersion!==this.Io)return!1;let i=0;for(let n=0;n<this._a.length;n++)i+=this._a[n].worldMatrixVersion;return i===this.xo}Ho(t){var i,n;let e=0;for(let a=0;a<this._a.length;a++)e+=this._a[a].worldMatrixVersion;this.To=t,this.xo=e,this.Io=(n=(i=this.entity.getSceneGraph())==null?void 0:i.worldMatrixVersion)!=null?n:-1,this.Co=this._bindShapeMatrix,this.Do=!0}Uo(t){let e=this._boneDataInfo._v;return{processFrameToken:t,boneData:this._boneData.isDummy()?void 0:this._boneData._v,boneDataInfo:[e[0],e[1],e[2],e[3]],jointMatrix:this.wa._v,isWorldMatrixVanilla:this.La}}jo(t){if(this.La=t.isWorldMatrixVanilla,this.wa._v.set(t.jointMatrix),t.boneData==null)return;let e=this._a.length*b.getVec4CountPerJoint(this.Ma)*4;this._boneData._v.set(t.boneData.subarray(0,Math.min(e,this._boneData._v.length))),this._boneDataInfo.isDummy()||this._boneDataInfo._v.set(t.boneDataInfo)}};s.fo=new Map,s.go=new WeakMap,s._o=new WeakMap,s.Go=0,s.vr=v.identity(),s.Fo=z.fromCopy4(0,0,0,1),s.Jo=v.identity(),s.gr=v.identity(),s.Or=v.identity();var G=s;G._registerBoneDataMember();G._registerBoneDataInfoMember();export{G as SkeletalComponent};
@@ -1 +1 @@
1
- import{Component as T}from"../../core/Component.js";import{applyMixins as R}from"../../core/EntityRepository.js";import{ProcessStage as d}from"../../definitions/ProcessStage.js";import{Matrix44 as p}from"../../math/index.js";import{MutableQuaternion as h}from"../../math/MutableQuaternion.js";import{Quaternion as I}from"../../math/Quaternion.js";import{Transform3D as g}from"../../math/Transform3D.js";import{Is as a}from"../../misc/index.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var o=class o extends T{constructor(){super(...arguments);this.Ro=new g;this.Qo=0}static get renderedPropertyCount(){return null}static get componentTID(){return m.TransformComponentTID}get componentTID(){return m.TransformComponentTID}get restOrPose(){return this.Po!==void 0?this.Po:this.Ro}static getUpdateCount(t){var e;return(e=this.pi.get(t))!=null?e:0}static fi(t){var s;let e=(s=this.pi.get(t))!=null?s:0;this.pi.set(t,e+1)}_backupTransformAsRest(){this.Po===void 0&&(this.Po=this.Ro.clone(),this.entity.tryToGetSceneGraph().setWorldMatrixRestDirty())}_restoreTransformFromRest(){this.Po!==void 0&&this.Ro.setTransform(this.Po.positionInner,this.Po.scaleInner,h.fromCopyQuaternion(this.Po.rotationInner))}get localTransform(){return this.Ro}set localTransform(t){this.Ro.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}get localTransformRest(){return this.restOrPose}set localTransformRest(t){a.undefined(this.Po)&&(this.Po=new g),this.Po.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}set localPosition(t){this.Ro.position=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setPositionToPhysics(s.matrixInner.multiplyVector3(t)):e.setPositionToPhysics(t)}o.fi(this.i)}set localPositionWithoutPhysics(t){this.Ro.position=t,o.fi(this.i)}setLocalPositionAsArray3(t){this.Ro.setPositionAsArray3(t),o.fi(this.i)}get localPosition(){return this.Ro.position}get localPositionInner(){return this.Ro.positionInner}set localPositionRest(t){a.undefined(this.Po)&&(this.Po=this.Ro.clone()),this.Po.position=t,o.fi(this.i)}get localPositionRest(){return this.restOrPose.position}get localPositionRestInner(){return this.restOrPose.positionInner}set localEulerAngles(t){this.Ro.eulerAngles=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=Math.sin(t._v[0]*.5),i=Math.cos(t._v[0]*.5),n=Math.sin(t._v[1]*.5),r=Math.cos(t._v[1]*.5),l=Math.sin(t._v[2]*.5),c=Math.cos(t._v[2]*.5),u=h.fromCopy4(s*r*c-i*n*l,i*n*c+s*r*l,i*r*l-s*n*c,i*r*c+s*n*l),f=e.parent;f!==void 0?e.setRotationToPhysics(I.multiply(f.rotation,u)):e.setRotationToPhysics(u)}o.fi(this.i)}set localEulerAnglesWithoutPhysics(t){this.Ro.eulerAngles=t,o.fi(this.i)}get localEulerAngles(){return this.Ro.eulerAngles}get localEulerAnglesInner(){return this.Ro.eulerAnglesInner}set localEulerAnglesRest(t){a.undefined(this.Po)&&(this.Po=this.Ro.clone()),this.Po.eulerAngles=t,o.fi(this.i)}get localEulerAnglesRest(){return this.restOrPose.eulerAngles}get localEulerAnglesRestInner(){return this.restOrPose.eulerAnglesInner}set localScale(t){this.Ro.scale=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent,i=s===void 0?this.Ro.matrixInner:p.multiply(s.matrixInner,this.Ro.matrixInner);e.setScaleToPhysics(e._getPhysicsWorldScale(i))}o.fi(this.i)}set localScaleWithoutPhysics(t){this.Ro.scale=t,o.fi(this.i)}setLocalScaleAsArray3(t){this.Ro.setScaleAsArray3(t),o.fi(this.i)}get localScale(){return this.Ro.scale}get localScaleInner(){return this.Ro.scaleInner}set localScaleRest(t){a.undefined(this.Po)&&(this.Po=this.Ro.clone()),this.Po.scale=t,o.fi(this.i)}get localScaleRest(){return this.restOrPose.scale}get localScaleRestInner(){return this.restOrPose.scaleInner}set localRotation(t){this.Ro.rotation=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setRotationToPhysics(I.multiply(s.rotationInner,t)):e.setRotationToPhysics(t)}o.fi(this.i)}set localRotationWithoutPhysics(t){this.Ro.rotation=t,o.fi(this.i)}setLocalRotationAsArray4(t){this.Ro.setRotationAsArray4(t),o.fi(this.i)}get localRotation(){return this.Ro.rotation}get localRotationInner(){return this.Ro.rotationInner}set localRotationRest(t){a.undefined(this.Po)&&(this.Po=this.Ro.clone()),this.Po.rotation=t,o.fi(this.i)}get localRotationRest(){return this.restOrPose.rotation}get localRotationRestInner(){return this.restOrPose.rotationInner}set localMatrix(t){this.Ro.matrix=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setMatrixToPhysics(p.multiply(s.matrix,t)):e.setMatrixToPhysics(t)}o.fi(this.i)}set localMatrixWithoutPhysics(t){this.Ro.matrix=t,o.fi(this.i)}get localMatrix(){return this.Ro.matrix}get localMatrixInner(){return this.Ro.matrixInner}getLocalMatrixInnerTo(t){this.Ro.getMatrixInnerTo(t)}set localMatrixRest(t){a.undefined(this.Po)&&(this.Po=this.Ro.clone()),this.Po.matrix=t,o.fi(this.i)}get localMatrixRest(){return this.restOrPose.matrix}get localMatrixRestInner(){return this.restOrPose.matrixInner}$load(){this.moveStageTo(d.Logic)}$logic(){this.Qo!==this.Ro.updateCount&&(this.entity.tryToGetSceneGraph().setWorldMatrixDirty(),this.Qo=this.Ro.updateCount)}_shallowCopyFrom(t){let e=t;this.Ro=e.Ro.clone(),e.Po!=null&&(this.Po=e.Po.clone()),this.Qo=e.Qo,o.fi(this.i)}get entity(){return this.i.entityRepository.getEntity(this.gn)}_destroy(){super._destroy()}addThisComponentToEntity(t,e){class s extends t.constructor{getTransform(){return this.Ko===void 0&&(this.Ko=this.getComponentByComponentTID(m.TransformComponentTID)),this.Ko}set localPosition(n){let r=this.getTransform();r.localPosition=n}get localPosition(){return this.localPositionInner.clone()}get localPositionInner(){return this.getTransform().localPositionInner}set localPositionRest(n){let r=this.getTransform();r.localPositionRest=n}get localPositionRest(){return this.getTransform().localPositionRest}get localPositionRestInner(){return this.getTransform().localPositionRestInner}set localScale(n){let r=this.getTransform();r.localScale=n}get localScale(){return this.localScaleInner.clone()}get localScaleInner(){return this.getTransform().localScaleInner}set localScaleRest(n){let r=this.getTransform();r.localScaleRest=n}get localScaleRest(){return this.getTransform().localScaleRest}get localScaleRestInner(){return this.getTransform().localScaleRestInner}set localEulerAngles(n){let r=this.getTransform();r.localEulerAngles=n}get localEulerAngles(){return this.localEulerAnglesInner.clone()}get localEulerAnglesInner(){return this.getTransform().localEulerAnglesInner}set localEulerAnglesRest(n){let r=this.getTransform();r.localEulerAnglesRest=n}get localEulerAnglesRest(){return this.localEulerAnglesRestInner.clone()}get localEulerAnglesRestInner(){return this.getTransform().localEulerAnglesRestInner}set localRotation(n){let r=this.getTransform();r.localRotation=n}get localRotation(){return this.localRotationInner.clone()}get localRotationInner(){return this.getTransform().localRotationInner}set localRotationRest(n){let r=this.getTransform();r.localRotationRest=n}get localRotationRest(){return this.localQuaternionRestInner.clone()}get localRotationRestInner(){return this.getTransform().localRotationRestInner}set localMatrix(n){let r=this.getTransform();r.localMatrix=n}get localMatrix(){return this.localMatrixInner.clone()}get localMatrixInner(){return this.getTransform().localMatrixInner}set localMatrixRest(n){let r=this.getTransform();r.localMatrixRest=n}get localMatrixRest(){return this.localMatrixRestInner.clone()}get localMatrixRestInner(){return this.getTransform().localMatrixRestInner}}return R(t,s),t}static _cleanupForEngine(t){o.pi.delete(t)}};o.pi=new Map;var y=o;export{y as TransformComponent};
1
+ import{Component as T}from"../../core/Component.js";import{applyMixins as R}from"../../core/EntityRepository.js";import{ProcessStage as d}from"../../definitions/ProcessStage.js";import{Matrix44 as p}from"../../math/index.js";import{MutableQuaternion as h}from"../../math/MutableQuaternion.js";import{Quaternion as I}from"../../math/Quaternion.js";import{Transform3D as g}from"../../math/Transform3D.js";import{Is as a}from"../../misc/index.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var o=class o extends T{constructor(){super(...arguments);this.Ko=new g;this.el=0}static get renderedPropertyCount(){return null}static get componentTID(){return m.TransformComponentTID}get componentTID(){return m.TransformComponentTID}get restOrPose(){return this.tl!==void 0?this.tl:this.Ko}static getUpdateCount(t){var e;return(e=this.pi.get(t))!=null?e:0}static fi(t){var s;let e=(s=this.pi.get(t))!=null?s:0;this.pi.set(t,e+1)}_backupTransformAsRest(){this.tl===void 0&&(this.tl=this.Ko.clone(),this.entity.tryToGetSceneGraph().setWorldMatrixRestDirty())}_restoreTransformFromRest(){this.tl!==void 0&&this.Ko.setTransform(this.tl.positionInner,this.tl.scaleInner,h.fromCopyQuaternion(this.tl.rotationInner))}get localTransform(){return this.Ko}set localTransform(t){this.Ko.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}get localTransformRest(){return this.restOrPose}set localTransformRest(t){a.undefined(this.tl)&&(this.tl=new g),this.tl.setTransform(t.positionInner,t.scaleInner,h.fromCopyQuaternion(t.rotationInner)),o.fi(this.i)}set localPosition(t){this.Ko.position=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setPositionToPhysics(s.matrixInner.multiplyVector3(t)):e.setPositionToPhysics(t)}o.fi(this.i)}set localPositionWithoutPhysics(t){this.Ko.position=t,o.fi(this.i)}setLocalPositionAsArray3(t){this.Ko.setPositionAsArray3(t),o.fi(this.i)}get localPosition(){return this.Ko.position}get localPositionInner(){return this.Ko.positionInner}set localPositionRest(t){a.undefined(this.tl)&&(this.tl=this.Ko.clone()),this.tl.position=t,o.fi(this.i)}get localPositionRest(){return this.restOrPose.position}get localPositionRestInner(){return this.restOrPose.positionInner}set localEulerAngles(t){this.Ko.eulerAngles=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=Math.sin(t._v[0]*.5),i=Math.cos(t._v[0]*.5),n=Math.sin(t._v[1]*.5),r=Math.cos(t._v[1]*.5),l=Math.sin(t._v[2]*.5),c=Math.cos(t._v[2]*.5),u=h.fromCopy4(s*r*c-i*n*l,i*n*c+s*r*l,i*r*l-s*n*c,i*r*c+s*n*l),f=e.parent;f!==void 0?e.setRotationToPhysics(I.multiply(f.rotation,u)):e.setRotationToPhysics(u)}o.fi(this.i)}set localEulerAnglesWithoutPhysics(t){this.Ko.eulerAngles=t,o.fi(this.i)}get localEulerAngles(){return this.Ko.eulerAngles}get localEulerAnglesInner(){return this.Ko.eulerAnglesInner}set localEulerAnglesRest(t){a.undefined(this.tl)&&(this.tl=this.Ko.clone()),this.tl.eulerAngles=t,o.fi(this.i)}get localEulerAnglesRest(){return this.restOrPose.eulerAngles}get localEulerAnglesRestInner(){return this.restOrPose.eulerAnglesInner}set localScale(t){this.Ko.scale=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent,i=s===void 0?this.Ko.matrixInner:p.multiply(s.matrixInner,this.Ko.matrixInner);e.setScaleToPhysics(e._getPhysicsWorldScale(i))}o.fi(this.i)}set localScaleWithoutPhysics(t){this.Ko.scale=t,o.fi(this.i)}setLocalScaleAsArray3(t){this.Ko.setScaleAsArray3(t),o.fi(this.i)}get localScale(){return this.Ko.scale}get localScaleInner(){return this.Ko.scaleInner}set localScaleRest(t){a.undefined(this.tl)&&(this.tl=this.Ko.clone()),this.tl.scale=t,o.fi(this.i)}get localScaleRest(){return this.restOrPose.scale}get localScaleRestInner(){return this.restOrPose.scaleInner}set localRotation(t){this.Ko.rotation=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setRotationToPhysics(I.multiply(s.rotationInner,t)):e.setRotationToPhysics(t)}o.fi(this.i)}set localRotationWithoutPhysics(t){this.Ko.rotation=t,o.fi(this.i)}setLocalRotationAsArray4(t){this.Ko.setRotationAsArray4(t),o.fi(this.i)}get localRotation(){return this.Ko.rotation}get localRotationInner(){return this.Ko.rotationInner}set localRotationRest(t){a.undefined(this.tl)&&(this.tl=this.Ko.clone()),this.tl.rotation=t,o.fi(this.i)}get localRotationRest(){return this.restOrPose.rotation}get localRotationRestInner(){return this.restOrPose.rotationInner}set localMatrix(t){this.Ko.matrix=t;let e=this.entity.tryToGetSceneGraph();if(e!=null&&e._hasPhysicsComponentInSubtree){let s=e.parent;s!==void 0?e.setMatrixToPhysics(p.multiply(s.matrix,t)):e.setMatrixToPhysics(t)}o.fi(this.i)}set localMatrixWithoutPhysics(t){this.Ko.matrix=t,o.fi(this.i)}get localMatrix(){return this.Ko.matrix}get localMatrixInner(){return this.Ko.matrixInner}getLocalMatrixInnerTo(t){this.Ko.getMatrixInnerTo(t)}set localMatrixRest(t){a.undefined(this.tl)&&(this.tl=this.Ko.clone()),this.tl.matrix=t,o.fi(this.i)}get localMatrixRest(){return this.restOrPose.matrix}get localMatrixRestInner(){return this.restOrPose.matrixInner}$load(){this.moveStageTo(d.Logic)}$logic(){this.el!==this.Ko.updateCount&&(this.entity.tryToGetSceneGraph().setWorldMatrixDirty(),this.el=this.Ko.updateCount)}_shallowCopyFrom(t){let e=t;this.Ko=e.Ko.clone(),e.tl!=null&&(this.tl=e.tl.clone()),this.el=e.el,o.fi(this.i)}get entity(){return this.i.entityRepository.getEntity(this.gn)}_destroy(){super._destroy()}addThisComponentToEntity(t,e){class s extends t.constructor{getTransform(){return this.nl===void 0&&(this.nl=this.getComponentByComponentTID(m.TransformComponentTID)),this.nl}set localPosition(n){let r=this.getTransform();r.localPosition=n}get localPosition(){return this.localPositionInner.clone()}get localPositionInner(){return this.getTransform().localPositionInner}set localPositionRest(n){let r=this.getTransform();r.localPositionRest=n}get localPositionRest(){return this.getTransform().localPositionRest}get localPositionRestInner(){return this.getTransform().localPositionRestInner}set localScale(n){let r=this.getTransform();r.localScale=n}get localScale(){return this.localScaleInner.clone()}get localScaleInner(){return this.getTransform().localScaleInner}set localScaleRest(n){let r=this.getTransform();r.localScaleRest=n}get localScaleRest(){return this.getTransform().localScaleRest}get localScaleRestInner(){return this.getTransform().localScaleRestInner}set localEulerAngles(n){let r=this.getTransform();r.localEulerAngles=n}get localEulerAngles(){return this.localEulerAnglesInner.clone()}get localEulerAnglesInner(){return this.getTransform().localEulerAnglesInner}set localEulerAnglesRest(n){let r=this.getTransform();r.localEulerAnglesRest=n}get localEulerAnglesRest(){return this.localEulerAnglesRestInner.clone()}get localEulerAnglesRestInner(){return this.getTransform().localEulerAnglesRestInner}set localRotation(n){let r=this.getTransform();r.localRotation=n}get localRotation(){return this.localRotationInner.clone()}get localRotationInner(){return this.getTransform().localRotationInner}set localRotationRest(n){let r=this.getTransform();r.localRotationRest=n}get localRotationRest(){return this.localQuaternionRestInner.clone()}get localRotationRestInner(){return this.getTransform().localRotationRestInner}set localMatrix(n){let r=this.getTransform();r.localMatrix=n}get localMatrix(){return this.localMatrixInner.clone()}get localMatrixInner(){return this.getTransform().localMatrixInner}set localMatrixRest(n){let r=this.getTransform();r.localMatrixRest=n}get localMatrixRest(){return this.localMatrixRestInner.clone()}get localMatrixRestInner(){return this.getTransform().localMatrixRestInner}}return R(t,s),t}static _cleanupForEngine(t){o.pi.delete(t)}};o.pi=new Map;var y=o;export{y as TransformComponent};
@@ -1 +1 @@
1
- import{Component as y}from"../../core/Component.js";import{applyMixins as v}from"../../core/EntityRepository.js";import{ProcessStage as b}from"../../definitions/ProcessStage.js";import{EventPubSub as h}from"../../system/EventPubSub.js";import{WellKnownComponentTIDs as c}from"../WellKnownComponentTIDs.js";var g=class g extends y{constructor(e,t,i,n,r){super(e,t,i,n,r);this.mn=new h;this.tp=new Set;this.qo=new Map;this.moveStageTo(b.Logic),g.Yo.add(this)}static get componentTID(){return c.TriggerComponentTID}get componentTID(){return c.TriggerComponentTID}subscribe(e,t){return this.mn.subscribe(e,t)}unsubscribe(e,t){this.mn.unsubscribe(e,t)}get activeOverlapCount(){return this.qo.size}_registerSensorBinding(e,t){let i=g.Zo(e,t),n=g.Xo.get(this.i);n==null&&(n=new Map,g.Xo.set(this.i,n));let r=n.get(i);if(r!=null&&r!==this)throw new Error(`Physics sensor binding ${i} is already owned by another TriggerComponent.`);n.set(i,this),this.tp.add(i)}static _unregisterSensorBinding(e,t,i){let n=this.Zo(t,i),r=this.Xo.get(e);if(r==null)return;let s=r.get(n);s!=null&&(this._deactivateSensorBinding(e,t,i),r.delete(n),r.size===0&&this.Xo.delete(e),s.tp.delete(n))}static _processOverlap(e,t,i,n,r,s,p){let o=this.Xo.get(e),l=o==null?void 0:o.get(this.Zo(t,i));if(l==null||n===l.entity||r!=null&&n.engine===e&&(o==null?void 0:o.get(this.Zo(n.entityUID,r)))===l)return;let u=p==null?`binding:${r!=null?r:"external"}`:`collider:${p}`,d=`${t}:${i}:${u}`,a=l.qo.get(n);if(s){a==null&&(a={otherEntity:n,pairs:new Map,rebuildingPairs:new Map,enteredThisStep:!0},l.qo.set(n,a));let m=a.pairs.size===0&&a.rebuildingPairs.size===0;a.pairs.set(d,{sensorEntityUid:t,sensorBindingId:i,otherBindingId:r,otherColliderHandle:p}),a.rebuildingPairs.clear(),m&&l.ep("enter",a.otherEntity,i,r)}else a!=null&&(a.pairs.delete(d),a.pairs.size===0&&a.rebuildingPairs.size===0&&(l.qo.delete(n),l.ep("exit",a.otherEntity,i,r)))}static _beginPhysicsStep(e){if(e==null){this.rp++;return}this.np.set(e,this.ip(e)+1)}static _finalizeRebuiltOverlaps(e){let t=this.ip(e);for(let i of this.Yo)if(!(e!=null&&i.entity.engine!==e))for(let[n,r]of[...i.qo]){let s=[...r.rebuildingPairs.entries()].filter(([,p])=>p.suspendedAtStep<t);for(let[p]of s)r.rebuildingPairs.delete(p);if(s.length>0&&r.pairs.size===0&&r.rebuildingPairs.size===0){i.qo.delete(n);let p=s[0][1];i.ep("exit",r.otherEntity,p.sensorBindingId,p.otherBindingId)}}}static _publishStayEvents(e){for(let t of this.Yo)if(!(e!=null&&t.entity.engine!==e))for(let i of t.qo.values()){if(i.enteredThisStep){i.enteredThisStep=!1;continue}let n=i.pairs.values().next().value;n!=null&&t.ep("stay",i.otherEntity,n.sensorBindingId,n.otherBindingId)}}static _suspendSensorBinding(e,t,i){var r;let n=(r=this.Xo.get(e))==null?void 0:r.get(this.Zo(t,i));if(n!=null)for(let s of n.qo.values()){let p=[...s.pairs.entries()].filter(([,o])=>o.sensorEntityUid===t&&o.sensorBindingId===i);for(let[o,l]of p)s.pairs.delete(o),s.rebuildingPairs.set(o,{...l,suspendedAtStep:this.ip(e)})}}static _suspendOtherBinding(e,t,i){for(let n of this.Yo){let r=n.qo.get(e);if(r==null)continue;let s=[...r.pairs.entries()].filter(([,p])=>this.sp(p,t,i));for(let[p,o]of s)r.pairs.delete(p),r.rebuildingPairs.set(p,{...o,suspendedAtStep:this.ip(e.engine)})}}static _deactivateSensorBinding(e,t,i){var r,s;let n=(r=this.Xo.get(e))==null?void 0:r.get(this.Zo(t,i));if(n!=null)for(let[p,o]of[...n.qo]){let l=([,a])=>a.sensorEntityUid===t&&a.sensorBindingId===i,u=[...o.pairs.entries()].filter(l),d=[...o.rebuildingPairs.entries()].filter(l);for(let[a]of u)o.pairs.delete(a);for(let[a]of d)o.rebuildingPairs.delete(a);if(u.length+d.length>0&&o.pairs.size===0&&o.rebuildingPairs.size===0){n.qo.delete(p);let a=((s=u[0])!=null?s:d[0])[1];n.ep("exit",o.otherEntity,a.sensorBindingId,a.otherBindingId)}}}static _deactivateOtherBinding(e,t,i){var n;for(let r of this.Yo){let s=r.qo.get(e);if(s==null)continue;let p=([,u])=>this.sp(u,t,i),o=[...s.pairs.entries()].filter(p),l=[...s.rebuildingPairs.entries()].filter(p);for(let[u]of o)s.pairs.delete(u);for(let[u]of l)s.rebuildingPairs.delete(u);if(o.length+l.length>0&&s.pairs.size===0&&s.rebuildingPairs.size===0){r.qo.delete(e);let u=((n=o[0])!=null?n:l[0])[1];r.ep("exit",s.otherEntity,u.sensorBindingId,u.otherBindingId)}}}ep(e,t,i,n){this.mn.publishSync(e,{type:e,triggerComponent:this,triggerEntity:this.entity,otherEntity:t,sensorBindingId:i,otherBindingId:n})}static Zo(e,t){return`${e}:${t}`}static ip(e){var t;return e==null?this.rp:(t=this.np.get(e))!=null?t:0}static sp(e,t,i){return t!=null?e.otherBindingId===t:i==null?e.otherBindingId==null:e.otherColliderHandle===i}_destroy(){let e=g.Xo.get(this.i);for(let t of this.tp)e==null||e.delete(t);(e==null?void 0:e.size)===0&&g.Xo.delete(this.i),this.tp.clear(),this.qo.clear(),g.Yo.delete(this),super._destroy()}addThisComponentToEntity(e,t){class i extends e.constructor{getTrigger(){return this.getComponentByComponentTID(c.TriggerComponentTID)}}return v(e,i),e}};g.Xo=new WeakMap,g.Yo=new Set,g.np=new WeakMap,g.rp=0;var f=g;export{f as TriggerComponent};
1
+ import{Component as y}from"../../core/Component.js";import{applyMixins as v}from"../../core/EntityRepository.js";import{ProcessStage as b}from"../../definitions/ProcessStage.js";import{EventPubSub as h}from"../../system/EventPubSub.js";import{WellKnownComponentTIDs as c}from"../WellKnownComponentTIDs.js";var g=class g extends y{constructor(e,t,i,n,r){super(e,t,i,n,r);this.mn=new h;this.sp=new Set;this.ep=new Map;this.moveStageTo(b.Logic),g.ip.add(this)}static get componentTID(){return c.TriggerComponentTID}get componentTID(){return c.TriggerComponentTID}subscribe(e,t){return this.mn.subscribe(e,t)}unsubscribe(e,t){this.mn.unsubscribe(e,t)}get activeOverlapCount(){return this.ep.size}_registerSensorBinding(e,t){let i=g.np(e,t),n=g.tp.get(this.i);n==null&&(n=new Map,g.tp.set(this.i,n));let r=n.get(i);if(r!=null&&r!==this)throw new Error(`Physics sensor binding ${i} is already owned by another TriggerComponent.`);n.set(i,this),this.sp.add(i)}static _unregisterSensorBinding(e,t,i){let n=this.np(t,i),r=this.tp.get(e);if(r==null)return;let s=r.get(n);s!=null&&(this._deactivateSensorBinding(e,t,i),r.delete(n),r.size===0&&this.tp.delete(e),s.sp.delete(n))}static _processOverlap(e,t,i,n,r,s,p){let o=this.tp.get(e),l=o==null?void 0:o.get(this.np(t,i));if(l==null||n===l.entity||r!=null&&n.engine===e&&(o==null?void 0:o.get(this.np(n.entityUID,r)))===l)return;let u=p==null?`binding:${r!=null?r:"external"}`:`collider:${p}`,d=`${t}:${i}:${u}`,a=l.ep.get(n);if(s){a==null&&(a={otherEntity:n,pairs:new Map,rebuildingPairs:new Map,enteredThisStep:!0},l.ep.set(n,a));let m=a.pairs.size===0&&a.rebuildingPairs.size===0;a.pairs.set(d,{sensorEntityUid:t,sensorBindingId:i,otherBindingId:r,otherColliderHandle:p}),a.rebuildingPairs.clear(),m&&l.rp("enter",a.otherEntity,i,r)}else a!=null&&(a.pairs.delete(d),a.pairs.size===0&&a.rebuildingPairs.size===0&&(l.ep.delete(n),l.rp("exit",a.otherEntity,i,r)))}static _beginPhysicsStep(e){if(e==null){this.pp++;return}this.ap.set(e,this.op(e)+1)}static _finalizeRebuiltOverlaps(e){let t=this.op(e);for(let i of this.ip)if(!(e!=null&&i.entity.engine!==e))for(let[n,r]of[...i.ep]){let s=[...r.rebuildingPairs.entries()].filter(([,p])=>p.suspendedAtStep<t);for(let[p]of s)r.rebuildingPairs.delete(p);if(s.length>0&&r.pairs.size===0&&r.rebuildingPairs.size===0){i.ep.delete(n);let p=s[0][1];i.rp("exit",r.otherEntity,p.sensorBindingId,p.otherBindingId)}}}static _publishStayEvents(e){for(let t of this.ip)if(!(e!=null&&t.entity.engine!==e))for(let i of t.ep.values()){if(i.enteredThisStep){i.enteredThisStep=!1;continue}let n=i.pairs.values().next().value;n!=null&&t.rp("stay",i.otherEntity,n.sensorBindingId,n.otherBindingId)}}static _suspendSensorBinding(e,t,i){var r;let n=(r=this.tp.get(e))==null?void 0:r.get(this.np(t,i));if(n!=null)for(let s of n.ep.values()){let p=[...s.pairs.entries()].filter(([,o])=>o.sensorEntityUid===t&&o.sensorBindingId===i);for(let[o,l]of p)s.pairs.delete(o),s.rebuildingPairs.set(o,{...l,suspendedAtStep:this.op(e)})}}static _suspendOtherBinding(e,t,i){for(let n of this.ip){let r=n.ep.get(e);if(r==null)continue;let s=[...r.pairs.entries()].filter(([,p])=>this.lp(p,t,i));for(let[p,o]of s)r.pairs.delete(p),r.rebuildingPairs.set(p,{...o,suspendedAtStep:this.op(e.engine)})}}static _deactivateSensorBinding(e,t,i){var r,s;let n=(r=this.tp.get(e))==null?void 0:r.get(this.np(t,i));if(n!=null)for(let[p,o]of[...n.ep]){let l=([,a])=>a.sensorEntityUid===t&&a.sensorBindingId===i,u=[...o.pairs.entries()].filter(l),d=[...o.rebuildingPairs.entries()].filter(l);for(let[a]of u)o.pairs.delete(a);for(let[a]of d)o.rebuildingPairs.delete(a);if(u.length+d.length>0&&o.pairs.size===0&&o.rebuildingPairs.size===0){n.ep.delete(p);let a=((s=u[0])!=null?s:d[0])[1];n.rp("exit",o.otherEntity,a.sensorBindingId,a.otherBindingId)}}}static _deactivateOtherBinding(e,t,i){var n;for(let r of this.ip){let s=r.ep.get(e);if(s==null)continue;let p=([,u])=>this.lp(u,t,i),o=[...s.pairs.entries()].filter(p),l=[...s.rebuildingPairs.entries()].filter(p);for(let[u]of o)s.pairs.delete(u);for(let[u]of l)s.rebuildingPairs.delete(u);if(o.length+l.length>0&&s.pairs.size===0&&s.rebuildingPairs.size===0){r.ep.delete(e);let u=((n=o[0])!=null?n:l[0])[1];r.rp("exit",s.otherEntity,u.sensorBindingId,u.otherBindingId)}}}rp(e,t,i,n){this.mn.publishSync(e,{type:e,triggerComponent:this,triggerEntity:this.entity,otherEntity:t,sensorBindingId:i,otherBindingId:n})}static np(e,t){return`${e}:${t}`}static op(e){var t;return e==null?this.pp:(t=this.ap.get(e))!=null?t:0}static lp(e,t,i){return t!=null?e.otherBindingId===t:i==null?e.otherBindingId==null:e.otherColliderHandle===i}_destroy(){let e=g.tp.get(this.i);for(let t of this.sp)e==null||e.delete(t);(e==null?void 0:e.size)===0&&g.tp.delete(this.i),this.sp.clear(),this.ep.clear(),g.ip.delete(this),super._destroy()}addThisComponentToEntity(e,t){class i extends e.constructor{getTrigger(){return this.getComponentByComponentTID(c.TriggerComponentTID)}}return v(e,i),e}};g.tp=new WeakMap,g.ip=new Set,g.ap=new WeakMap,g.pp=0;var f=g;export{f as TriggerComponent};
@@ -1 +1 @@
1
- import{Component as u}from"../../core/Component.js";import{applyMixins as l}from"../../core/EntityRepository.js";import{ProcessStage as x}from"../../definitions/ProcessStage.js";import{Is as d}from"../../misc/index.js";import{BlendShapeComponent as a}from"../BlendShape/BlendShapeComponent.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var y=class extends u{constructor(e,t,o,n,s){super(e,t,o,n,s);this.pp=new Map;this.Be=new Map;this.ap=new Map;this.hp=new Map;this.yp=new Set;this.op=!0;this.mp=-1;this._version="";this.moveStageTo(x.Logic)}static get componentTID(){return m.VrmComponentTID}get componentTID(){return m.VrmComponentTID}setVrmExpressions(e){for(let t of e)this.pp.set(t.name,t),this.Be.set(t.name,0);this.cp(),this.op=!0}cp(){this.ap.clear(),this.hp.clear();for(let[e,t]of this.pp){let o=[];for(let n of t.binds){let s=`${n.entityIdx}:${n.blendShapeIdx}`,i=this.ap.get(s);i===void 0&&(i={entityIdx:n.entityIdx,blendShapeIdx:n.blendShapeIdx,contributions:[]},this.ap.set(s,i)),i.contributions.push({expressionName:e,weight:n.weight}),o.push(s)}this.hp.set(e,o)}}setExpressionWeight(e,t){let o=this.yp;if(o.clear(),this.op||this.mp!==a.updateCount)for(let s of this.ap.keys())o.add(s);this.up(e,t,o),o.size>0&&this.lp(o),this.mp=a.updateCount,this.op&&(this.op=!1),o.clear()}setExpressionWeights(e){let t=this.yp;if(t.clear(),this.op||this.mp!==a.updateCount)for(let n of this.ap.keys())t.add(n);for(let[n,s]of e)this.up(n,s,t);t.size>0&&this.lp(t),this.mp=a.updateCount,this.op&&(this.op=!1),t.clear()}up(e,t,o){let n=this.pp.get(e);if(d.not.exist(n))return!1;let s=Math.min(1,Math.max(0,t)),i=n.isBinary?s>.5?1:0:s;if(this.Be.get(e)===i)return!1;this.Be.set(e,i);let p=this.hp.get(e);if(p!==void 0)for(let r=0;r<p.length;r++)o.add(p[r]);return!0}lp(e){var t;for(let o of e){let n=this.ap.get(o);if(n===void 0)continue;let s=0;for(let r=0;r<n.contributions.length;r++){let h=n.contributions[r],c=(t=this.Be.get(h.expressionName))!=null?t:0;s+=c*h.weight}let p=this.i.entityRepository.getEntity(n.entityIdx).tryToGetBlendShape();d.exist(p)&&p.setWeightByIndex(n.blendShapeIdx,s)}}getExpressionWeight(e){return this.Be.get(e)}getExpressionNames(){return Array.from(this.pp.keys())}_shallowCopyFrom(e){let t=e;this.pp=new Map(t.pp),this.Be=new Map(t.Be),this._version=t._version,this.cp(),this.op=!0}_destroy(){super._destroy()}addThisComponentToEntity(e,t){class o extends e.constructor{getVrm(){return this.dp===void 0&&(this.dp=this.getComponentByComponentTID(m.VrmComponentTID)),this.dp}}return l(e,o),e}};export{y as VrmComponent};
1
+ import{Component as u}from"../../core/Component.js";import{applyMixins as l}from"../../core/EntityRepository.js";import{ProcessStage as x}from"../../definitions/ProcessStage.js";import{Is as d}from"../../misc/index.js";import{BlendShapeComponent as a}from"../BlendShape/BlendShapeComponent.js";import{WellKnownComponentTIDs as m}from"../WellKnownComponentTIDs.js";var y=class extends u{constructor(e,t,o,n,s){super(e,t,o,n,s);this.hp=new Map;this.We=new Map;this.dp=new Map;this.cp=new Map;this.xp=new Set;this.mp=!0;this.yp=-1;this._version="";this.moveStageTo(x.Logic)}static get componentTID(){return m.VrmComponentTID}get componentTID(){return m.VrmComponentTID}setVrmExpressions(e){for(let t of e)this.hp.set(t.name,t),this.We.set(t.name,0);this.fp(),this.mp=!0}fp(){this.dp.clear(),this.cp.clear();for(let[e,t]of this.hp){let o=[];for(let n of t.binds){let s=`${n.entityIdx}:${n.blendShapeIdx}`,i=this.dp.get(s);i===void 0&&(i={entityIdx:n.entityIdx,blendShapeIdx:n.blendShapeIdx,contributions:[]},this.dp.set(s,i)),i.contributions.push({expressionName:e,weight:n.weight}),o.push(s)}this.cp.set(e,o)}}setExpressionWeight(e,t){let o=this.xp;if(o.clear(),this.mp||this.yp!==a.updateCount)for(let s of this.dp.keys())o.add(s);this.gp(e,t,o),o.size>0&&this.Cp(o),this.yp=a.updateCount,this.mp&&(this.mp=!1),o.clear()}setExpressionWeights(e){let t=this.xp;if(t.clear(),this.mp||this.yp!==a.updateCount)for(let n of this.dp.keys())t.add(n);for(let[n,s]of e)this.gp(n,s,t);t.size>0&&this.Cp(t),this.yp=a.updateCount,this.mp&&(this.mp=!1),t.clear()}gp(e,t,o){let n=this.hp.get(e);if(d.not.exist(n))return!1;let s=Math.min(1,Math.max(0,t)),i=n.isBinary?s>.5?1:0:s;if(this.We.get(e)===i)return!1;this.We.set(e,i);let p=this.cp.get(e);if(p!==void 0)for(let r=0;r<p.length;r++)o.add(p[r]);return!0}Cp(e){var t;for(let o of e){let n=this.dp.get(o);if(n===void 0)continue;let s=0;for(let r=0;r<n.contributions.length;r++){let h=n.contributions[r],c=(t=this.We.get(h.expressionName))!=null?t:0;s+=c*h.weight}let p=this.i.entityRepository.getEntity(n.entityIdx).tryToGetBlendShape();d.exist(p)&&p.setWeightByIndex(n.blendShapeIdx,s)}}getExpressionWeight(e){return this.We.get(e)}getExpressionNames(){return Array.from(this.hp.keys())}_shallowCopyFrom(e){let t=e;this.hp=new Map(t.hp),this.We=new Map(t.We),this._version=t._version,this.fp(),this.mp=!0}_destroy(){super._destroy()}addThisComponentToEntity(e,t){class o extends e.constructor{getVrm(){return this.up===void 0&&(this.up=this.getComponentByComponentTID(m.VrmComponentTID)),this.up}}return l(e,o),e}};export{y as VrmComponent};
@@ -1 +1 @@
1
- import{Quaternion as t}from"../math/index.js";import{Vector3 as e}from"../math/Vector3.js";import{Is as v}from"../misc/Is.js";var a=class{constructor(i,o,r,s){this._r=i,this.gp=o,this.fp=r,this.vp=s,this.vp.getTransform()._backupTransformAsRest()}getAxisVector(i){switch(i){case"PositiveX":return e.fromCopy3(1,0,0);case"NegativeX":return e.fromCopy3(-1,0,0);case"PositiveY":return e.fromCopy3(0,1,0);case"NegativeY":return e.fromCopy3(0,-1,0);case"PositiveZ":return e.fromCopy3(0,0,1);case"NegativeZ":return e.fromCopy3(0,0,-1);default:throw new Error("Invalid roll axis")}}update(){let i=this.getAxisVector(this.gp),o=v.exist(this.vp.getSceneGraph().parent)?this.vp.getSceneGraph().parent.rotation:t.identity(),r=this.vp.localRotationRestInner,s=t.multiply(o,r).transformVector3(i),n=e.normalize(e.subtract(this._r.position,this.vp.position)),p=t.fromToRotation(s,n),c=t.lerp(r,t.multiply(t.multiply(t.multiply(t.invert(o),p),o),r),this.fp);this.vp.localRotation=c}};export{a as VrmAimConstraint};
1
+ import{Quaternion as t}from"../math/index.js";import{Vector3 as e}from"../math/Vector3.js";import{Is as v}from"../misc/Is.js";var a=class{constructor(i,o,r,s){this.Ea=i,this.Pp=o,this.Np=r,this.vp=s,this.vp.getTransform()._backupTransformAsRest()}getAxisVector(i){switch(i){case"PositiveX":return e.fromCopy3(1,0,0);case"NegativeX":return e.fromCopy3(-1,0,0);case"PositiveY":return e.fromCopy3(0,1,0);case"NegativeY":return e.fromCopy3(0,-1,0);case"PositiveZ":return e.fromCopy3(0,0,1);case"NegativeZ":return e.fromCopy3(0,0,-1);default:throw new Error("Invalid roll axis")}}update(){let i=this.getAxisVector(this.Pp),o=v.exist(this.vp.getSceneGraph().parent)?this.vp.getSceneGraph().parent.rotation:t.identity(),r=this.vp.localRotationRestInner,s=t.multiply(o,r).transformVector3(i),n=e.normalize(e.subtract(this.Ea.position,this.vp.position)),p=t.fromToRotation(s,n),c=t.lerp(r,t.multiply(t.multiply(t.multiply(t.invert(o),p),o),r),this.Np);this.vp.localRotation=c}};export{a as VrmAimConstraint};
@@ -1 +1 @@
1
- import{Quaternion as t}from"../math/Quaternion.js";import{Vector3 as i}from"../math/Vector3.js";var a=class{constructor(o,n,r,e){this._r=o,this.tl=n,this.fp=r,this.vp=e,this.vp.getTransform()._backupTransformAsRest()}getAxisVector(o){switch(o){case"X":return i.fromCopy3(1,0,0);case"Y":return i.fromCopy3(0,1,0);case"Z":return i.fromCopy3(0,0,1);default:throw new Error("Invalid roll axis")}}update(){let o=t.multiply(t.invert(this._r.localRotationRestInner),this._r.localRotationInner),n=t.multiply(t.multiply(this._r.localRotationRestInner,o),t.invert(this._r.localRotationRestInner)),r=t.multiply(t.multiply(t.invert(this.vp.localRotationRestInner),n),this.vp.localRotationRestInner),e=this.getAxisVector(this.tl),s=r.transformVector3(e),l=t.fromToRotation(e,s),c=t.lerp(this.vp.localRotationRestInner,t.multiply(t.multiply(this.vp.localRotationRestInner,t.invert(l)),r),this.fp);this.vp.localRotation=c}};export{a as VrmRollConstraint};
1
+ import{Quaternion as t}from"../math/Quaternion.js";import{Vector3 as i}from"../math/Vector3.js";var a=class{constructor(o,n,r,e){this.Ea=o,this.ol=n,this.Np=r,this.vp=e,this.vp.getTransform()._backupTransformAsRest()}getAxisVector(o){switch(o){case"X":return i.fromCopy3(1,0,0);case"Y":return i.fromCopy3(0,1,0);case"Z":return i.fromCopy3(0,0,1);default:throw new Error("Invalid roll axis")}}update(){let o=t.multiply(t.invert(this.Ea.localRotationRestInner),this.Ea.localRotationInner),n=t.multiply(t.multiply(this.Ea.localRotationRestInner,o),t.invert(this.Ea.localRotationRestInner)),r=t.multiply(t.multiply(t.invert(this.vp.localRotationRestInner),n),this.vp.localRotationRestInner),e=this.getAxisVector(this.ol),s=r.transformVector3(e),l=t.fromToRotation(e,s),c=t.lerp(this.vp.localRotationRestInner,t.multiply(t.multiply(this.vp.localRotationRestInner,t.invert(l)),r),this.Np);this.vp.localRotation=c}};export{a as VrmRollConstraint};
@@ -1 +1 @@
1
- import{Quaternion as t}from"../math/index.js";var r=class{constructor(e,n,i){this._r=e,this.fp=n,this.vp=i,this.vp.getTransform()._backupTransformAsRest()}update(){let e=t.multiply(t.invert(this._r.localRotationRestInner),this._r.localRotationInner),n=t.lerp(this.vp.localRotationRestInner,t.multiply(this.vp.localRotationRestInner,e),this.fp);this.vp.localRotation=n}};export{r as VrmRotationConstraint};
1
+ import{Quaternion as t}from"../math/index.js";var r=class{constructor(e,n,i){this.Ea=e,this.Np=n,this.vp=i,this.vp.getTransform()._backupTransformAsRest()}update(){let e=t.multiply(t.invert(this.Ea.localRotationRestInner),this.Ea.localRotationInner),n=t.lerp(this.vp.localRotationRestInner,t.multiply(this.vp.localRotationRestInner,e),this.Np);this.vp.localRotation=n}};export{r as VrmRotationConstraint};
@@ -1 +1 @@
1
- import{ComponentType as V}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{ProcessStage as E}from"../definitions/ProcessStage.js";import{VectorN as I}from"../math/VectorN.js";import{RnException as O}from"../misc/index.js";import{Err as A,Ok as L}from"../misc/Result.js";import{RnObject as S}from"./RnObject.js";var a=class a extends S{constructor(e,o,t,r,n){super();this._isAlive=!0;this.$o=!1;this.nf=E.Load;this.i=e,this.gn=o,this._component_sid=t,this.of=e.memoryManager,this.Na=r,n&&(this.$o=!0)}moveStageTo(e){this.nf=e}static get componentTID(){return 0}get componentTID(){return 0}get componentSID(){return this._component_sid}get entityUID(){return this.gn}get currentProcessStage(){return this.nf}static doesTheProcessStageMethodExist(e,o){return e.prototype[o.methodName]!=null}isExistProcessStageMethod(e){return this[e.methodName]!=null}static process(e,o,t){if(!a.doesTheProcessStageMethodExist(o,t))return;let r=t.methodName,n=e.componentRepository._getComponents(o);if(n!=null)for(let i of n)i!=null&&t===i.nf&&i[r]()}static updateComponentsForRenderStage(e,o,t){let r=e.sort_$render;return r(t)}registerDependency(e,o){}rf(e,o,t,r,n,i){let m=this[`_${e}`];if(m!=null&&!m.isDummy())return;let y=Math.floor(n/i),l=n%i,s=this._componentMemoryRegistry,f=this.constructor,u=s.getAccessor(f,e,y)._takeExistedOne(l);if(this[`_${e}`]=new o(u,!1,!0),!(t instanceof I))for(let p=0;p<this[`_${e}`]._v.length;++p)this[`_${e}`]._v[p]=t[p];return null}sf(e,o){var g,h,d,C;let t=e.memberName,r=this[`_${t}`];if(r!=null&&!r.isDummy())return;let n=this.constructor,i=this._componentMemoryRegistry,m=Math.max((d=(h=this._getArrayLengthForAllocation(t))!=null?h:(g=a.tf.get(n))==null?void 0:g.get(t))!=null?d:1,1),y=e.compositionType.getNumberOfComponents()*m,l=y*e.componentType.getSizeInBytes(),s=i.getVariableLengthChunk(n,t,o);(s==null||s.byteCapacity<l)&&(s!=null&&i.releaseVariableLengthChunk(n,t,s),s=(C=i.takeFreeVariableLengthChunk(n,t,l))!=null?C:a.af(this.i,e.bufferUse,l),i.setVariableLengthChunk(n,t,o,s));let f=s.bufferView,c=new Float32Array(f.buffer.getArrayBuffer(),f.byteOffsetInRawArrayBufferOfBuffer,y);c.fill(0);let u=e.dataClassType;this[`_${t}`]=new u(c,!1,!0);let p=this[`_${a._getVariableLengthLocationMemberName(t)}`],b=a._variableLengthLocationRadix;p._v[0]=Math.floor(s.location/b),p._v[1]=s.location%b,p._v[2]=m,p._v[3]=0}static af(e,o,t){let r,n=0;do r=e.memoryManager.createOrGetBuffer(o,n).takeBufferView({byteLengthToNeed:t,byteStride:0}),r.isErr()&&n++;while(r.isErr());let i=r.get(),m=e.memoryManager.getByteOffsetOfExistingBuffers(o,i.buffer.indexOfTheBufferUsage)+i.byteOffsetInBuffer;return{bufferView:i,byteCapacity:t,location:m/4/4}}static _getVariableLengthLocationMemberName(e){return`${e}Location`}get _componentMemoryRegistry(){return this.i.componentMemoryRegistry}static ff(e,o,t,r,n,i,m,y,l){let s=e.componentMemoryRegistry,f=h(),c=s.getAccessor(r,t,m);if(c!=null&&c.elementCount===y&&c.byteStride===f&&c.compositionType===n&&c.componentType===i)return new L(c);let p,b=0;do p=e.memoryManager.createOrGetBuffer(o,b).takeBufferView({byteLengthToNeed:f*y,byteStride:0}),p.isErr()&&b++;while(p.isErr());let g=p.get().takeAccessor({compositionType:n,componentType:i,count:y,byteStride:f,arrayLength:l});if(g.isErr())return new A({message:`Failed to take accessor: ${g.getRnError().message}`,error:void 0});return s.setAccessor(r,t,m,g.get()),g;function h(){let d=n.getNumberOfComponents(),C=i.getSizeInBytes(),B=d*C;return M.isArray(n)&&(B*=l),B}}static registerMember({bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,arrayLength:y,componentSID:l,convertToBool:s,isVariableLength:f}){a.ef.has(this)||a.ef.set(this,new Map);let c=a.ef.get(this);if(f===!0){if(n!==M.Vec4Array&&n!==M.Mat4Array&&n!==M.Mat4x3Array)throw new Error(`Variable-length member ${o} must be Vec4Array, Mat4Array or Mat4x3Array.`);if(i!==V.Float)throw new Error(`Variable-length member ${o} must have the Float component type.`);let u=c.get(a._getVariableLengthLocationMemberName(o));if(u==null||u.compositionType!==M.Vec4)throw new Error(`Register a Vec4 member named ${a._getVariableLengthLocationMemberName(o)} before the variable-length member ${o}.`)}if(c.set(o,{bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,convertToBool:s,isVariableLength:f}),y!=null&&l!=null){a.tf.has(this)||a.tf.set(this,new Map);let u=a.tf.get(this),p=u.get(o);(p==null||y>p)&&u.set(o,y)}}submitToAllocation(e,o){let t=this.constructor,r=this._componentMemoryRegistry;r.setComponentCountPerBufferView(t,e);let n=a.ef.get(t),i=this.i,m=Math.floor(this._component_sid/e);(this._component_sid%e===0||y(m))&&l(m),n.forEach(s=>{s.isVariableLength!==!0&&this.rf(s.memberName,s.dataClassType,s.initValues,o,this._component_sid,e)}),n.forEach(s=>{s.isVariableLength===!0&&this.sf(s,this._component_sid)});function y(s){for(let f of n.values())if(f.isVariableLength!==!0&&r.getAccessor(t,f.memberName,s)==null)return!0;return!1}function l(s){n.forEach(f=>{var h;if(f.isVariableLength===!0)return;let c=(h=a.tf.get(t))==null?void 0:h.get(f.memberName),u=a.ff(i,f.bufferUse,f.memberName,t,f.compositionType,f.componentType,s,e,c!=null?c:1);if(u.isErr())throw new O(u.getRnError());let p=u.get(),g=i.memoryManager.getByteOffsetOfExistingBuffers(f.bufferUse,p.bufferView.buffer.indexOfTheBufferUsage)+p.byteOffsetInBuffer;r.setByteOffset(t,f.memberName,s,g)})}}_getArrayLengthForAllocation(e){}get entity(){return this.Na.getEntity(this.gn)}static getLocationOffsetOfMemberOfComponent(e,o,t){let r=[],i=e.componentMemoryRegistry.getByteOffsetsForMember(o,t);if(i==null)return[0];for(let[m,y]of i)r[m]=y/4/4;for(let m=0;m<r.length;m++)r[m]===void 0&&(r[m]=0);return r}addThisComponentToEntity(e,o){throw"Invalid Calling"}static getCompositionTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.compositionType}static getComponentTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.componentType}static getMemberInfo(e){return new Map(a.ef)}static getComponentCountPerBufferView(e){return e.componentMemoryRegistry.getAllComponentCountPerBufferView()}static getArrayLengthOfMember(e){return new Map(a.tf)}_destroy(){this._isAlive=!1}_shallowCopyFrom(e){}static getStateVersion(e){return e.componentMemoryRegistry.getStateVersion()}};a.ef=new Map,a.tf=new Map,a._processStages=[E.Load,E.Logic,E.Render],a._variableLengthLocationRadix=65536;var T=a;export{T as Component};
1
+ import{ComponentType as V}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{ProcessStage as E}from"../definitions/ProcessStage.js";import{VectorN as I}from"../math/VectorN.js";import{RnException as O}from"../misc/index.js";import{Err as A,Ok as L}from"../misc/Result.js";import{RnObject as S}from"./RnObject.js";var a=class a extends S{constructor(e,o,t,r,n){super();this._isAlive=!0;this.No=!1;this.nf=E.Load;this.i=e,this.gn=o,this._component_sid=t,this.of=e.memoryManager,this.Na=r,n&&(this.No=!0)}moveStageTo(e){this.nf=e}static get componentTID(){return 0}get componentTID(){return 0}get componentSID(){return this._component_sid}get entityUID(){return this.gn}get currentProcessStage(){return this.nf}static doesTheProcessStageMethodExist(e,o){return e.prototype[o.methodName]!=null}isExistProcessStageMethod(e){return this[e.methodName]!=null}static process(e,o,t){if(!a.doesTheProcessStageMethodExist(o,t))return;let r=t.methodName,n=e.componentRepository._getComponents(o);if(n!=null)for(let i of n)i!=null&&t===i.nf&&i[r]()}static updateComponentsForRenderStage(e,o,t){let r=e.sort_$render;return r(t)}registerDependency(e,o){}rf(e,o,t,r,n,i){let m=this[`_${e}`];if(m!=null&&!m.isDummy())return;let y=Math.floor(n/i),l=n%i,s=this._componentMemoryRegistry,f=this.constructor,u=s.getAccessor(f,e,y)._takeExistedOne(l);if(this[`_${e}`]=new o(u,!1,!0),!(t instanceof I))for(let p=0;p<this[`_${e}`]._v.length;++p)this[`_${e}`]._v[p]=t[p];return null}sf(e,o){var g,h,d,C;let t=e.memberName,r=this[`_${t}`];if(r!=null&&!r.isDummy())return;let n=this.constructor,i=this._componentMemoryRegistry,m=Math.max((d=(h=this._getArrayLengthForAllocation(t))!=null?h:(g=a.tf.get(n))==null?void 0:g.get(t))!=null?d:1,1),y=e.compositionType.getNumberOfComponents()*m,l=y*e.componentType.getSizeInBytes(),s=i.getVariableLengthChunk(n,t,o);(s==null||s.byteCapacity<l)&&(s!=null&&i.releaseVariableLengthChunk(n,t,s),s=(C=i.takeFreeVariableLengthChunk(n,t,l))!=null?C:a.af(this.i,e.bufferUse,l),i.setVariableLengthChunk(n,t,o,s));let f=s.bufferView,c=new Float32Array(f.buffer.getArrayBuffer(),f.byteOffsetInRawArrayBufferOfBuffer,y);c.fill(0);let u=e.dataClassType;this[`_${t}`]=new u(c,!1,!0);let p=this[`_${a._getVariableLengthLocationMemberName(t)}`],b=a._variableLengthLocationRadix;p._v[0]=Math.floor(s.location/b),p._v[1]=s.location%b,p._v[2]=m,p._v[3]=0}static af(e,o,t){let r,n=0;do r=e.memoryManager.createOrGetBuffer(o,n).takeBufferView({byteLengthToNeed:t,byteStride:0}),r.isErr()&&n++;while(r.isErr());let i=r.get(),m=e.memoryManager.getByteOffsetOfExistingBuffers(o,i.buffer.indexOfTheBufferUsage)+i.byteOffsetInBuffer;return{bufferView:i,byteCapacity:t,location:m/4/4}}static _getVariableLengthLocationMemberName(e){return`${e}Location`}get _componentMemoryRegistry(){return this.i.componentMemoryRegistry}static ff(e,o,t,r,n,i,m,y,l){let s=e.componentMemoryRegistry,f=h(),c=s.getAccessor(r,t,m);if(c!=null&&c.elementCount===y&&c.byteStride===f&&c.compositionType===n&&c.componentType===i)return new L(c);let p,b=0;do p=e.memoryManager.createOrGetBuffer(o,b).takeBufferView({byteLengthToNeed:f*y,byteStride:0}),p.isErr()&&b++;while(p.isErr());let g=p.get().takeAccessor({compositionType:n,componentType:i,count:y,byteStride:f,arrayLength:l});if(g.isErr())return new A({message:`Failed to take accessor: ${g.getRnError().message}`,error:void 0});return s.setAccessor(r,t,m,g.get()),g;function h(){let d=n.getNumberOfComponents(),C=i.getSizeInBytes(),B=d*C;return M.isArray(n)&&(B*=l),B}}static registerMember({bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,arrayLength:y,componentSID:l,convertToBool:s,isVariableLength:f}){a.ef.has(this)||a.ef.set(this,new Map);let c=a.ef.get(this);if(f===!0){if(n!==M.Vec4Array&&n!==M.Mat4Array&&n!==M.Mat4x3Array)throw new Error(`Variable-length member ${o} must be Vec4Array, Mat4Array or Mat4x3Array.`);if(i!==V.Float)throw new Error(`Variable-length member ${o} must have the Float component type.`);let u=c.get(a._getVariableLengthLocationMemberName(o));if(u==null||u.compositionType!==M.Vec4)throw new Error(`Register a Vec4 member named ${a._getVariableLengthLocationMemberName(o)} before the variable-length member ${o}.`)}if(c.set(o,{bufferUse:e,memberName:o,dataClassType:t,shaderType:r,compositionType:n,componentType:i,initValues:m,convertToBool:s,isVariableLength:f}),y!=null&&l!=null){a.tf.has(this)||a.tf.set(this,new Map);let u=a.tf.get(this),p=u.get(o);(p==null||y>p)&&u.set(o,y)}}submitToAllocation(e,o){let t=this.constructor,r=this._componentMemoryRegistry;r.setComponentCountPerBufferView(t,e);let n=a.ef.get(t),i=this.i,m=Math.floor(this._component_sid/e);(this._component_sid%e===0||y(m))&&l(m),n.forEach(s=>{s.isVariableLength!==!0&&this.rf(s.memberName,s.dataClassType,s.initValues,o,this._component_sid,e)}),n.forEach(s=>{s.isVariableLength===!0&&this.sf(s,this._component_sid)});function y(s){for(let f of n.values())if(f.isVariableLength!==!0&&r.getAccessor(t,f.memberName,s)==null)return!0;return!1}function l(s){n.forEach(f=>{var h;if(f.isVariableLength===!0)return;let c=(h=a.tf.get(t))==null?void 0:h.get(f.memberName),u=a.ff(i,f.bufferUse,f.memberName,t,f.compositionType,f.componentType,s,e,c!=null?c:1);if(u.isErr())throw new O(u.getRnError());let p=u.get(),g=i.memoryManager.getByteOffsetOfExistingBuffers(f.bufferUse,p.bufferView.buffer.indexOfTheBufferUsage)+p.byteOffsetInBuffer;r.setByteOffset(t,f.memberName,s,g)})}}_getArrayLengthForAllocation(e){}get entity(){return this.Na.getEntity(this.gn)}static getLocationOffsetOfMemberOfComponent(e,o,t){let r=[],i=e.componentMemoryRegistry.getByteOffsetsForMember(o,t);if(i==null)return[0];for(let[m,y]of i)r[m]=y/4/4;for(let m=0;m<r.length;m++)r[m]===void 0&&(r[m]=0);return r}addThisComponentToEntity(e,o){throw"Invalid Calling"}static getCompositionTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.compositionType}static getComponentTypeOfMember(e,o,t){let n=a.ef.get(t).get(o);if(n!=null)return n.componentType}static getMemberInfo(e){return new Map(a.ef)}static getComponentCountPerBufferView(e){return e.componentMemoryRegistry.getAllComponentCountPerBufferView()}static getArrayLengthOfMember(e){return new Map(a.tf)}_destroy(){this._isAlive=!1}_shallowCopyFrom(e){}static getStateVersion(e){return e.componentMemoryRegistry.getStateVersion()}};a.ef=new Map,a.tf=new Map,a._processStages=[E.Load,E.Logic,E.Render],a._variableLengthLocationRadix=65536;var T=a;export{T as Component};
@@ -1 +1 @@
1
- import{WellKnownComponentTIDs as l}from"../components/WellKnownComponentTIDs.js";var p=class p{constructor(n){this.Dp=new Map;this.Yo=new Map;this.Ip=[];this.Tp=[];this.bp=0;this.i=n}get _componentCreationCount(){return this.bp}static registerComponentClass(n){this.Cp.set(n.componentTID,n)}static _ensureComponentClassRegistered(n){this.Cp.has(n.componentTID)||this.Cp.set(n.componentTID,n)}static deregisterComponentClass(n){this.Cp.delete(n)}static getComponentClass(n){return this.Cp.get(n)}createComponent(n,t,e){let o=p.Cp.get(n);if(o!==void 0){let i=this.Dp.get(n);i===void 0&&(this.Dp.set(n,0),i=p.invalidComponentSID);let s=this.Yo.get(n),m=-1;if(s!==void 0){for(let r=0;r<s.length;r++)if(s[r]===void 0){m=r;break}}let u=-1,c=!1;m===-1?(this.Dp.set(n,++i),u=i):(u=m,c=!0),this.bp++;let C=new o(this.i,t,u,e,c);this.Yo.has(n)||(this.Yo.set(n,[]),this.Ap());let f=this.Yo.get(n);return f[C.componentSID]=C,C}throw new Error("The Component Class object is invalid.")}deleteComponent(n){let t=n.componentTID,e=n.componentSID,o=this.Yo.get(t);o!=null&&delete o[e]}getComponent(n,t){return this.getComponentFromComponentTID(n.componentTID,t)}getComponentFromComponentTID(n,t){let e=this.Yo.get(n);if(e!=null)return e[t]!=null?e[t]:void 0}hasAnyComponent(n){let t=this.Yo.get(n);if(t==null)return!1;for(let e=0;e<t.length;e++)if(t[e]!=null)return!0;return!1}getComponentCount(n){let t=this.Yo.get(n);if(t==null)return 0;let e=0;for(let o=0;o<t.length;o++)t[o]!=null&&e++;return e}_getComponents(n){return this.Yo.get(n.componentTID)}_getComponentsIncludingDead(n){return this.Yo.get(n.componentTID)}getComponentsWithType(n){return this.getComponentsWithTID(n.componentTID)}getComponentsWithTID(n){let t=this.Yo.get(n);return t==null?[]:t.filter(e=>e!=null)}getComponentsWithTypeWithoutFiltering(n){let t=this.Yo.get(n.componentTID);if(t==null)return[];let e=[];for(let o=0;o<t.length;o++)e.push(t[o]);return e}Ap(){let n=Array.from(this.Yo.keys());n.sort((e,o)=>e-o),this.Ip=n;let t=[];t.push(l.MeshRendererComponentTID),this.Yo.has(l.EffekseerComponentTID)&&t.push(l.EffekseerComponentTID),this.Tp=t}getComponentTIDs(){return this.Ip}getRenderingComponentTIDs(){return this.Tp}};p.Cp=new Map,p.invalidComponentSID=-1;var a=p;export{a as ComponentRepository};
1
+ import{WellKnownComponentTIDs as l}from"../components/WellKnownComponentTIDs.js";var p=class p{constructor(n){this.Ip=new Map;this.ip=new Map;this.Tp=[];this.bp=[];this.Ap=0;this.i=n}get _componentCreationCount(){return this.Ap}static registerComponentClass(n){this.Dp.set(n.componentTID,n)}static _ensureComponentClassRegistered(n){this.Dp.has(n.componentTID)||this.Dp.set(n.componentTID,n)}static deregisterComponentClass(n){this.Dp.delete(n)}static getComponentClass(n){return this.Dp.get(n)}createComponent(n,t,e){let o=p.Dp.get(n);if(o!==void 0){let i=this.Ip.get(n);i===void 0&&(this.Ip.set(n,0),i=p.invalidComponentSID);let s=this.ip.get(n),m=-1;if(s!==void 0){for(let r=0;r<s.length;r++)if(s[r]===void 0){m=r;break}}let u=-1,c=!1;m===-1?(this.Ip.set(n,++i),u=i):(u=m,c=!0),this.Ap++;let C=new o(this.i,t,u,e,c);this.ip.has(n)||(this.ip.set(n,[]),this.Ep());let f=this.ip.get(n);return f[C.componentSID]=C,C}throw new Error("The Component Class object is invalid.")}deleteComponent(n){let t=n.componentTID,e=n.componentSID,o=this.ip.get(t);o!=null&&delete o[e]}getComponent(n,t){return this.getComponentFromComponentTID(n.componentTID,t)}getComponentFromComponentTID(n,t){let e=this.ip.get(n);if(e!=null)return e[t]!=null?e[t]:void 0}hasAnyComponent(n){let t=this.ip.get(n);if(t==null)return!1;for(let e=0;e<t.length;e++)if(t[e]!=null)return!0;return!1}getComponentCount(n){let t=this.ip.get(n);if(t==null)return 0;let e=0;for(let o=0;o<t.length;o++)t[o]!=null&&e++;return e}_getComponents(n){return this.ip.get(n.componentTID)}_getComponentsIncludingDead(n){return this.ip.get(n.componentTID)}getComponentsWithType(n){return this.getComponentsWithTID(n.componentTID)}getComponentsWithTID(n){let t=this.ip.get(n);return t==null?[]:t.filter(e=>e!=null)}getComponentsWithTypeWithoutFiltering(n){let t=this.ip.get(n.componentTID);if(t==null)return[];let e=[];for(let o=0;o<t.length;o++)e.push(t[o]);return e}Ep(){let n=Array.from(this.ip.keys());n.sort((e,o)=>e-o),this.Tp=n;let t=[];t.push(l.MeshRendererComponentTID),this.ip.has(l.EffekseerComponentTID)&&t.push(l.EffekseerComponentTID),this.bp=t}getComponentTIDs(){return this.Tp}getRenderingComponentTIDs(){return this.bp}};p.Dp=new Map,p.invalidComponentSID=-1;var a=p;export{a as ComponentRepository};
@@ -1 +1 @@
1
- import{WellKnownComponentTIDs as n}from"../components/WellKnownComponentTIDs.js";import{Is as C}from"../misc/Is.js";import{RnObject as i}from"./RnObject.js";var o=class o extends i{constructor(e,t,p,m){super();this._myLatestCopyEntityUID=o.invalidEntityUID;this.i=e,this.nm=t,this._isAlive=p,this.Yo=C.exist(m)?m:new Map}get engine(){return this.i}get entityUID(){return this.nm}_setComponent(e,t){this.Yo.set(e.componentTID,t)}hasComponent(e){return this.Yo.has(e.componentTID)}getComponent(e){return this.Yo.get(e.componentTID)}getComponentByComponentTID(e){return this.Yo.get(e)}_removeComponent(e){this.Yo.delete(e)}tryToGetAnimation(){return this.getComponentByComponentTID(n.AnimationComponentTID)}tryToGetAnimationState(){return this.getComponentByComponentTID(n.AnimationStateComponentTID)}tryToGetBlendShape(){return this.getComponentByComponentTID(n.BlendShapeComponentTID)}tryToGetCamera(){return this.getComponentByComponentTID(n.CameraComponentTID)}tryToGetCameraController(){return this.getComponentByComponentTID(n.CameraControllerComponentTID)}tryToGetLight(){return this.getComponentByComponentTID(n.LightComponentTID)}tryToGetMesh(){return this.getComponentByComponentTID(n.MeshComponentTID)}tryToGetMeshRenderer(){return this.getComponentByComponentTID(n.MeshRendererComponentTID)}tryToGetPhysics(){return this.getComponentByComponentTID(n.PhysicsComponentTID)}tryToGetCharacterController(){return this.getComponentByComponentTID(n.CharacterControllerComponentTID)}tryToGetShape(){return this.getComponentByComponentTID(n.ShapeComponentTID)}tryToGetTrigger(){return this.getComponentByComponentTID(n.TriggerComponentTID)}tryToGetSceneGraph(){return this.getComponentByComponentTID(n.SceneGraphComponentTID)}tryToGetSkeletal(){return this.getComponentByComponentTID(n.SkeletalComponentTID)}tryToGetTransform(){return this.getComponentByComponentTID(n.TransformComponentTID)}tryToGetVrm(){return this.getComponentByComponentTID(n.VrmComponentTID)}tryToGetConstraint(){return this.getComponentByComponentTID(n.ConstraintComponentTID)}tryToGetEffekseer(){return this.getComponentByComponentTID(n.EffekseerComponentTID)}tryToGetRaymarching(){return this.getComponentByComponentTID(n.RaymarchingComponentTID)}_destroy(){this.Yo.forEach(e=>{e._destroy()}),this.unregister(),this._isAlive=!1}};o.invalidEntityUID=-1;var r=o;export{r as Entity};
1
+ import{WellKnownComponentTIDs as n}from"../components/WellKnownComponentTIDs.js";import{Is as C}from"../misc/Is.js";import{RnObject as i}from"./RnObject.js";var o=class o extends i{constructor(e,t,p,m){super();this._myLatestCopyEntityUID=o.invalidEntityUID;this.i=e,this.nm=t,this._isAlive=p,this.ip=C.exist(m)?m:new Map}get engine(){return this.i}get entityUID(){return this.nm}_setComponent(e,t){this.ip.set(e.componentTID,t)}hasComponent(e){return this.ip.has(e.componentTID)}getComponent(e){return this.ip.get(e.componentTID)}getComponentByComponentTID(e){return this.ip.get(e)}_removeComponent(e){this.ip.delete(e)}tryToGetAnimation(){return this.getComponentByComponentTID(n.AnimationComponentTID)}tryToGetAnimationState(){return this.getComponentByComponentTID(n.AnimationStateComponentTID)}tryToGetBlendShape(){return this.getComponentByComponentTID(n.BlendShapeComponentTID)}tryToGetCamera(){return this.getComponentByComponentTID(n.CameraComponentTID)}tryToGetCameraController(){return this.getComponentByComponentTID(n.CameraControllerComponentTID)}tryToGetLight(){return this.getComponentByComponentTID(n.LightComponentTID)}tryToGetMesh(){return this.getComponentByComponentTID(n.MeshComponentTID)}tryToGetMeshRenderer(){return this.getComponentByComponentTID(n.MeshRendererComponentTID)}tryToGetPhysics(){return this.getComponentByComponentTID(n.PhysicsComponentTID)}tryToGetCharacterController(){return this.getComponentByComponentTID(n.CharacterControllerComponentTID)}tryToGetShape(){return this.getComponentByComponentTID(n.ShapeComponentTID)}tryToGetTrigger(){return this.getComponentByComponentTID(n.TriggerComponentTID)}tryToGetSceneGraph(){return this.getComponentByComponentTID(n.SceneGraphComponentTID)}tryToGetSkeletal(){return this.getComponentByComponentTID(n.SkeletalComponentTID)}tryToGetTransform(){return this.getComponentByComponentTID(n.TransformComponentTID)}tryToGetVrm(){return this.getComponentByComponentTID(n.VrmComponentTID)}tryToGetConstraint(){return this.getComponentByComponentTID(n.ConstraintComponentTID)}tryToGetEffekseer(){return this.getComponentByComponentTID(n.EffekseerComponentTID)}tryToGetRaymarching(){return this.getComponentByComponentTID(n.RaymarchingComponentTID)}_destroy(){this.ip.forEach(e=>{e._destroy()}),this.unregister(),this._isAlive=!1}};o.invalidEntityUID=-1;var r=o;export{r as Entity};
@@ -1 +1 @@
1
- import{WellKnownComponentTIDs as m}from"../components/WellKnownComponentTIDs.js";import{Logger as f}from"../misc/index.js";import{Is as p}from"../misc/Is.js";import{valueWithCompensation as g}from"../misc/MiscUtil.js";import{ComponentRepository as u}from"./ComponentRepository.js";import{Entity as E}from"./Entity.js";var a=class a{constructor(t){this._p=E.invalidEntityUID;this.Ep=[];this._components=[];this.i=t}createEntity(){let t=-1;for(let o=0;o<this.Ep.length;o++)this.Ep[o]==null&&(t=o);let n=-1;t===-1?n=++this._p:n=t;let e=new E(this.i,n,!0);return this.Ep[n]=e,a.rt++,e}deleteEntity(t){var n;if(!p.not.exist(this._components[t])){for(let[e,o]of this._components[t]){if(e===m.SceneGraphComponentTID){let i=o.children.concat();for(let r of i)this.deleteEntity(r.entity.entityUID)}this.i.componentRepository.deleteComponent(o)}(n=this.Ep[t])==null||n._destroy(),delete this.Ep[t],delete this._components[t],a.rt++}}deleteEntityRecursively(t){let n=this.getEntity(t),e=[],o=n.tryToGetSceneGraph();o!=null&&(e.push(o.entity),s(o));function s(i){let r=i.children;for(let c=0;c<r.length;c++){let y=r[c];e.push(y.entity),s(y)}}for(let i of e)this.deleteEntity(i.entityUID)}shallowCopyEntity(t){let n=this._shallowCopyEntityInner(t);return this.Gp(t),this.Sp(n),n}Gp(t){let n=this.getEntity(t._myLatestCopyEntityUID);if(p.not.exist(n))return;let e=n.getComponentByComponentTID(m.SkeletalComponentTID),o=t.getComponentByComponentTID(m.SkeletalComponentTID);if(p.exist(e)&&p.exist(o)){let i=o.getJoints();if(i.length>0){let r=[];for(let y of i){let h=this.getEntity(y.entity._myLatestCopyEntityUID),l=h==null?void 0:h.tryToGetSceneGraph();p.exist(l)&&r.push(l)}r.length===i.length&&e.updateJointsLightweight(r);let c=o.topOfJointsHierarchy;if(p.exist(c)){let y=this.getEntity(c.entity._myLatestCopyEntityUID),h=y==null?void 0:y.tryToGetSceneGraph();p.exist(h)&&(e.topOfJointsHierarchy=h)}}}let s=t.tryToGetSceneGraph();p.exist(s)&&s.children.forEach(i=>{this.Gp(i.entity)})}_shallowCopyEntityInner(t){let n=this.createEntity();n._tags=Object.assign({},t._tags),t._myLatestCopyEntityUID=n.entityUID;for(let e=1;e<=m.maxWellKnownTidNumber;e++){let o=t.getComponentByComponentTID(e);if(p.exist(o)){this.addComponentToEntity(o.constructor,n);let s=n.getComponentByComponentTID(e);p.exist(s)&&s._shallowCopyFrom(o)}}return n}Sp(t){let n=t._tags;if(p.exist(n)){let o=Object.keys(n);for(let s of o){if(s==="rnEntities"){let r=t.getTagValue("rnEntities").map(c=>this.getEntity(c._myLatestCopyEntityUID));t.tryToSetTag({tag:"rnEntities",value:r})}if(s==="rnEntitiesByNames"){let i=t.getTagValue("rnEntitiesByNames");for(let r of Object.keys(i)){let c=i.get(r);i.set(r,this.getEntity(c._myLatestCopyEntityUID))}t.tryToSetTag({tag:"rnEntitiesByNames",value:i})}}}let e=t.tryToGetSceneGraph();p.exist(e)&&e.children.forEach(o=>{this.Sp(o.entity)})}tryToAddComponentToEntityByTID(t,n){let e=u.getComponentClass(t);return p.not.exist(e)?(f.default.warn(`The component class of ComponentTID ${t} is not registered yet. Use addComponentToEntity() with the component class, or register it with ComponentRepository.registerComponentClass().`),n):this.addComponentToEntity(e,n)}addComponentToEntity(t,n){if(n.hasComponent(t))return f.default.info("This entity already has the Component."),n;u._ensureComponentClassRegistered(t);let e=this.i.componentRepository.createComponent(t.componentTID,n.entityUID,this);g({value:this._components[n.entityUID],compensation:()=>(this._components[n.entityUID]=new Map,this._components[n.entityUID])}).set(t.componentTID,e);let s=e.addThisComponentToEntity(n,t);if(n._setComponent(t,e),t.componentTID===m.PhysicsComponentTID||t.componentTID===m.SceneGraphComponentTID){let i=n.tryToGetSceneGraph();i!==void 0&&n.tryToGetPhysics()!==void 0&&i._onPhysicsComponentAdded()}return a.rt++,n}removeComponentFromEntity(t,n){var s;let e=this._components[n.entityUID];e==null&&(e=new Map,this._components[n.entityUID]=e);let o=e.get(t.componentTID);return p.exist(o)&&(o._destroy(),t.componentTID===m.PhysicsComponentTID&&((s=n.tryToGetSceneGraph())==null||s._onPhysicsComponentRemoved()),e.delete(t.componentTID),n._removeComponent(t.componentTID)),a.rt++,n}getEntity(t){return this.Ep[t]}getComponentOfEntity(t,n){let e=this._components[t],o=null;return e!=null?(o=e.get(n.componentTID),o!=null?o:null):o}searchByTags(t){let n=[];for(let e of this.Ep)e!=null&&e.matchTags(t)&&n.push(e);return n}getEntityByUniqueName(t){for(let n of this.Ep)if(n!=null&&n.uniqueName===t)return n}_getEntities(){return this.Ep.filter(t=>t!=null&&t._isAlive)}getEntitiesNumber(){return this.Ep.filter(n=>n!=null&&n._isAlive).length}static get updateCount(){return this.rt}get engine(){return this.i}};a.rt=0;var C=a;function b(I,t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{Object.defineProperty(I,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}export{C as EntityRepository,b as applyMixins};
1
+ import{WellKnownComponentTIDs as m}from"../components/WellKnownComponentTIDs.js";import{Logger as f}from"../misc/index.js";import{Is as p}from"../misc/Is.js";import{valueWithCompensation as g}from"../misc/MiscUtil.js";import{ComponentRepository as u}from"./ComponentRepository.js";import{Entity as E}from"./Entity.js";var a=class a{constructor(t){this.Up=E.invalidEntityUID;this.Gp=[];this._components=[];this.i=t}createEntity(){let t=-1;for(let o=0;o<this.Gp.length;o++)this.Gp[o]==null&&(t=o);let n=-1;t===-1?n=++this.Up:n=t;let e=new E(this.i,n,!0);return this.Gp[n]=e,a.rt++,e}deleteEntity(t){var n;if(!p.not.exist(this._components[t])){for(let[e,o]of this._components[t]){if(e===m.SceneGraphComponentTID){let i=o.children.concat();for(let r of i)this.deleteEntity(r.entity.entityUID)}this.i.componentRepository.deleteComponent(o)}(n=this.Gp[t])==null||n._destroy(),delete this.Gp[t],delete this._components[t],a.rt++}}deleteEntityRecursively(t){let n=this.getEntity(t),e=[],o=n.tryToGetSceneGraph();o!=null&&(e.push(o.entity),s(o));function s(i){let r=i.children;for(let c=0;c<r.length;c++){let y=r[c];e.push(y.entity),s(y)}}for(let i of e)this.deleteEntity(i.entityUID)}shallowCopyEntity(t){let n=this._shallowCopyEntityInner(t);return this.Sp(t),this._p(n),n}Sp(t){let n=this.getEntity(t._myLatestCopyEntityUID);if(p.not.exist(n))return;let e=n.getComponentByComponentTID(m.SkeletalComponentTID),o=t.getComponentByComponentTID(m.SkeletalComponentTID);if(p.exist(e)&&p.exist(o)){let i=o.getJoints();if(i.length>0){let r=[];for(let y of i){let h=this.getEntity(y.entity._myLatestCopyEntityUID),l=h==null?void 0:h.tryToGetSceneGraph();p.exist(l)&&r.push(l)}r.length===i.length&&e.updateJointsLightweight(r);let c=o.topOfJointsHierarchy;if(p.exist(c)){let y=this.getEntity(c.entity._myLatestCopyEntityUID),h=y==null?void 0:y.tryToGetSceneGraph();p.exist(h)&&(e.topOfJointsHierarchy=h)}}}let s=t.tryToGetSceneGraph();p.exist(s)&&s.children.forEach(i=>{this.Sp(i.entity)})}_shallowCopyEntityInner(t){let n=this.createEntity();n._tags=Object.assign({},t._tags),t._myLatestCopyEntityUID=n.entityUID;for(let e=1;e<=m.maxWellKnownTidNumber;e++){let o=t.getComponentByComponentTID(e);if(p.exist(o)){this.addComponentToEntity(o.constructor,n);let s=n.getComponentByComponentTID(e);p.exist(s)&&s._shallowCopyFrom(o)}}return n}_p(t){let n=t._tags;if(p.exist(n)){let o=Object.keys(n);for(let s of o){if(s==="rnEntities"){let r=t.getTagValue("rnEntities").map(c=>this.getEntity(c._myLatestCopyEntityUID));t.tryToSetTag({tag:"rnEntities",value:r})}if(s==="rnEntitiesByNames"){let i=t.getTagValue("rnEntitiesByNames");for(let r of Object.keys(i)){let c=i.get(r);i.set(r,this.getEntity(c._myLatestCopyEntityUID))}t.tryToSetTag({tag:"rnEntitiesByNames",value:i})}}}let e=t.tryToGetSceneGraph();p.exist(e)&&e.children.forEach(o=>{this._p(o.entity)})}tryToAddComponentToEntityByTID(t,n){let e=u.getComponentClass(t);return p.not.exist(e)?(f.default.warn(`The component class of ComponentTID ${t} is not registered yet. Use addComponentToEntity() with the component class, or register it with ComponentRepository.registerComponentClass().`),n):this.addComponentToEntity(e,n)}addComponentToEntity(t,n){if(n.hasComponent(t))return f.default.info("This entity already has the Component."),n;u._ensureComponentClassRegistered(t);let e=this.i.componentRepository.createComponent(t.componentTID,n.entityUID,this);g({value:this._components[n.entityUID],compensation:()=>(this._components[n.entityUID]=new Map,this._components[n.entityUID])}).set(t.componentTID,e);let s=e.addThisComponentToEntity(n,t);if(n._setComponent(t,e),t.componentTID===m.PhysicsComponentTID||t.componentTID===m.SceneGraphComponentTID){let i=n.tryToGetSceneGraph();i!==void 0&&n.tryToGetPhysics()!==void 0&&i._onPhysicsComponentAdded()}return a.rt++,n}removeComponentFromEntity(t,n){var s;let e=this._components[n.entityUID];e==null&&(e=new Map,this._components[n.entityUID]=e);let o=e.get(t.componentTID);return p.exist(o)&&(o._destroy(),t.componentTID===m.PhysicsComponentTID&&((s=n.tryToGetSceneGraph())==null||s._onPhysicsComponentRemoved()),e.delete(t.componentTID),n._removeComponent(t.componentTID)),a.rt++,n}getEntity(t){return this.Gp[t]}getComponentOfEntity(t,n){let e=this._components[t],o=null;return e!=null?(o=e.get(n.componentTID),o!=null?o:null):o}searchByTags(t){let n=[];for(let e of this.Gp)e!=null&&e.matchTags(t)&&n.push(e);return n}getEntityByUniqueName(t){for(let n of this.Gp)if(n!=null&&n.uniqueName===t)return n}_getEntities(){return this.Gp.filter(t=>t!=null&&t._isAlive)}getEntitiesNumber(){return this.Gp.filter(n=>n!=null&&n._isAlive).length}static get updateCount(){return this.rt}get engine(){return this.i}};a.rt=0;var C=a;function b(I,t){Object.getOwnPropertyNames(t.prototype).forEach(n=>{Object.defineProperty(I,n,Object.getOwnPropertyDescriptor(t.prototype,n)||Object.create(null))})}export{C as EntityRepository,b as applyMixins};
@@ -1 +1 @@
1
- var c=class{constructor(t,r){this.Yo=[];this.jc=[];this.Wc=t,this.jc=[],this.Yo=[];for(let[n,s]of r){let a=n.split(",");for(let e=0;e<a.length;e++){let i=a[e];i===t.X&&(this.jc[0]=e,this.Yo[0]=s),i===t.Y&&(this.jc[1]=e,this.Yo[1]=s),i===t.Z&&(this.jc[2]=e,this.Yo[2]=s),i===t.W&&(this.jc[3]=e,this.Yo[3]=s)}}}get semantic(){return this.Wc}getScalarAsArray(t,r){return[this.Yo[0].getScalarAt(t,this.jc[0],r)]}getVec2AsArray(t,r){return[this.Yo[0].getScalarAt(t,this.jc[0],r),this.Yo[1].getScalarAt(t,this.jc[1],r)]}getVec3AsArray(t,r){return[this.Yo[0].getScalarAt(t,this.jc[0],r),this.Yo[1].getScalarAt(t,this.jc[1],r),this.Yo[2].getScalarAt(t,this.jc[2],r)]}getVec4AsArray(t,r){return[this.Yo[0].getScalarAt(t,this.jc[0],r),this.Yo[1].getScalarAt(t,this.jc[1],r),this.Yo[2].getScalarAt(t,this.jc[2],r),this.Yo[3].getScalarAt(t,this.jc[3],r)]}};export{c as ComplexVertexAttribute};
1
+ var c=class{constructor(t,r){this.ip=[];this.jc=[];this.Wc=t,this.jc=[],this.ip=[];for(let[n,s]of r){let a=n.split(",");for(let e=0;e<a.length;e++){let i=a[e];i===t.X&&(this.jc[0]=e,this.ip[0]=s),i===t.Y&&(this.jc[1]=e,this.ip[1]=s),i===t.Z&&(this.jc[2]=e,this.ip[2]=s),i===t.W&&(this.jc[3]=e,this.ip[3]=s)}}}get semantic(){return this.Wc}getScalarAsArray(t,r){return[this.ip[0].getScalarAt(t,this.jc[0],r)]}getVec2AsArray(t,r){return[this.ip[0].getScalarAt(t,this.jc[0],r),this.ip[1].getScalarAt(t,this.jc[1],r)]}getVec3AsArray(t,r){return[this.ip[0].getScalarAt(t,this.jc[0],r),this.ip[1].getScalarAt(t,this.jc[1],r),this.ip[2].getScalarAt(t,this.jc[2],r)]}getVec4AsArray(t,r){return[this.ip[0].getScalarAt(t,this.jc[0],r),this.ip[1].getScalarAt(t,this.jc[1],r),this.ip[2].getScalarAt(t,this.jc[2],r),this.ip[3].getScalarAt(t,this.jc[3],r)]}};export{c as ComplexVertexAttribute};
@@ -1 +1 @@
1
- import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{ProcessStage as z}from"../definitions/ProcessStage.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as O}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as H,isBlendWithZWrite as k,isOpaque as F,isTranslucent as E}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.Zc=[];this.Bu=[];this.Mu=[];this.Uu=[];this.Tu=[];this.ju=[];this.Pu=new G;this.Xc=[];this.vu=new Set;this.qc=v.InvalidCGAPIResourceUid;this.Ou=!1;this.xu=!1;this.Hu=!1;this.Nu=!1;this.ku=-1;this.Fu=-1;this.Eu=!1;this.du=0;this.gu=-1;this.Jc=-1;this.Ru=0;this.Lu=-1;this.Wu=0;this.Zu=0;this.Yc=[];this.tangentCalculationMode=1;this.Xu=!1;this.Qc=0;this.i=t,this.Gu=++c.qu}static get _primitivePositionUpdateVersion(){return c.Yu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.Zc.findIndex(e=>e.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Yc}_belongToMeshComponent(t){this.Yc.push(t.entity),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){let r=t.entity;this.Yc=this.Yc.filter(e=>e!==r),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),F(t)?this.Bu.push(t):E(t)?this.Mu.push(t):k(t)?this.Uu.push(t):H(t)&&this.Tu.push(t),this.cl(this.Bu.concat(this.Mu).concat(this.Uu).concat(this.Tu))}cl(t){this.Zc=t}isExistOpaque(){return this.Bu.length>0}isExistTranslucent(){return this.Mu.length>0}isExistBlendWithZWrite(){return this.Uu.length>0}isExistBlendWithoutZWrite(){return this.Tu.length>0}getPrimitiveAt(t){return this.Zc[t]}getPrimitiveNumber(){return this.Zc.length}hu(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Yc.length,r=this.i.webglResourceRepository.instanceSidTable,e=this.Jc;(e<0||this.Ru!==t)&&(e>=0&&r.free(e,this.Ru),e=r.allocate(t),this.Jc=e,this.Ru=t,r.writeIdentityRemap(e,t));let i=4294967295;for(let s=0;s<t;s++){let n=this.Yc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(e+s,a,o!=null?o.componentSID:i,u!=null?u.componentSID:i)}return e}get _instanceSidBase(){return this.Jc}get _remapPrepassId(){return this.Lu}set _remapPrepassId(t){this.Lu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.qc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.qc);let r=4294967295,e=this.Yc.length,i=new Uint32Array(e*4),s=new Int32Array(e),n=!1,a=!1;for(let o=0;o<e;o++){s[o]=this.Yc[o].entityUID,i[4*o+0]=this.Yc[o].getSceneGraph().componentSID;let u=this.Yc[o].tryToGetSkeletal();u!=null?i[4*o+1]=u.componentSID:i[4*o+1]=r;let f=this.Yc[o].tryToGetBlendShape();f!=null?i[4*o+2]=f.componentSID:i[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.Ou=e>0,this.xu=n,this.Hu=a,this.hu()?(this.qc=v.InvalidCGAPIResourceUid,this.Iu=i,this.Vu=s,this.Du=void 0,this.wu=void 0,this.du=e,this.yu=void 0,this.gu=-1,this._ensureInstanceSidBase(),!0):(this.qc=t.createVertexBufferFromTypedArray(i),this.Iu=i,this.Vu=s,this.Du=i.slice(),this.wu=new Uint32Array(i.length),this.du=e,this.yu=void 0,this.gu=-1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.hu())return this._packVisibleInstancesToInstanceRemap(t,r);let e=this.Iu,i=this.Vu,s=this.Du,n=this.wu;if(e===void 0||i===void 0||s===void 0||n===void 0||this.qc===v.InvalidCGAPIResourceUid)return this.Yc.length;if(t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let a=i.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=i[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=e[h+0],n[m+1]=e[h+1],n[m+2]=e[h+2],n[m+3]=e[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.qc,l),s.set(l)}return this.du=o,o}_packVisibleInstancesToInstanceRemap(t,r){let e=this.Vu;if(e===void 0)return this.Yc.length;if(this.Jc<0&&this._ensureInstanceSidBase(),t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let i=this.i.webglResourceRepository.instanceSidTable,s=this.Jc,n=e.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=e[o];if(u<t.length&&t[u]===r)continue}i.setRemap(s+a,o),a++}return this.du=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.qc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.qc),this.qc=v.InvalidCGAPIResourceUid,this.Iu=void 0,this.Vu=void 0,this.Du=void 0,this.wu=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let i=0;i<this.Zc.length;i++){let s=this.Zc[i],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[i]=n.vertexHandles.vaoHandle,this.vu.add(i);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[i])||this.Xc[i]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[i]=t.createVertexArray(),a.vaoHandle=this.Xc[i]),t.setVertexDataToPipeline(a,s,this.qc)}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=this.Zc.length;i<this.Xc.length;i++){let s=this.Xc[i];s&&!r.hasVaoHandle(s)&&(e.has(s)||(e.add(s),t.deleteVertexArray(s))),this.Xc[i]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.vu.clear();return}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=0;i<this.Xc.length;i++){let s=this.Xc[i];s&&!e.has(s)&&!r.hasVaoHandle(s)&&(e.add(s),t.deleteVertexArray(s)),this.Xc[i]=v.InvalidCGAPIResourceUid}this.vu.clear()}_clearMultiDrawVaoUids(){for(let t of this.vu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.vu.clear()}castRay(t,r,e=0){var o;let i,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.Zc){let f=u.castRay(t,r,!0,!0,e,this.Xu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,i=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(i)?{result:!0,data:{t:s,u:n,v:a,position:i}}:{result:!1}}get primitives(){return this.Zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.qc}get _variationEntityInfo(){return this.Iu}get _isGpuCullable(){return this.Ou?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.xu)return!0;if(!this.Hu)return!1;for(let t=0;t<this.Zc.length;t++)if(this.Zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.ku===this.Zc.length&&this.Fu===this.Qc&&this.Eu===this.xu?this.Nu:(this.ku=this.Zc.length,this.Fu=this.Qc,this.Eu=this.xu,this.Nu=this.ul(),this.Nu)}ul(){if(this.Zc.length===0)return!1;let t=(r,e)=>r.some(i=>i.split(".")[0]===e);for(let r of this.Zc){let e=r.attributeSemantics;if(!t(e,"POSITION")||this.xu&&(!t(e,"JOINTS_0")||!t(e,"WEIGHTS_0")))return!1;for(let i of r.targets){let s=!1;for(let n of i.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Qc++,c.Yu++;for(let t of this.Yc)t.getMeshRenderer().moveStageTo(z.Load)}get primitivePositionUpdateCount(){return this.Qc}get AABB(){if(this.Qc!==this.Wu&&(this.Pu.initialize(),this.Wu=this.Qc),this.Pu.isVanilla())for(let t of this.Zc)this.Pu.mergeAABB(t.AABB);return this.Pu}pl(){for(let t=0;t<this.Zc.length;t++){let r=this.ju[t],e=this.Zc[t];e.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,e.getAttribute(n))})}}_calcTangents(){if(this.ll())for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let e=t.attributeSemantics.indexOf(g.Texcoord0.XY),i=t.attributeSemantics.indexOf(g.Normal.XYZ);if(e!==-1&&i!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[e],o=t.attributeAccessors[i],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),S=n.getVec3(d+2,{indicesAccessor:u}),M=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),T=a.getVec2(d+2,{indicesAccessor:u}),N=o.getVec3(d,{indicesAccessor:u});this.hl(d,I,A,S,M,U,T,N,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}hl(t,r,e,i,s,n,a,o,u,f){let l=this.zu(r,e,i,s,n,a,o,c.nl),h=this.zu(e,i,r,n,a,s,o,c.ol),m=this.zu(i,r,e,a,s,n,o,c.al);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}zu(t,r,e,i,s,n,a,o){let u=[c.Tt.setComponents(t.x,i.x,i.y),c.bt.setComponents(t.y,i.x,i.y),c.ve.setComponents(t.z,i.x,i.y)],f=[c.Ju.setComponents(r.x,s.x,s.y),c._u.setComponents(r.y,s.x,s.y),c.Ku.setComponents(r.z,s.x,s.y)],l=[c.Qu.setComponents(e.x,n.x,n.y),c.$u.setComponents(e.y,n.x,n.y),c.el.setComponents(e.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.il),d=b.subtractTo(l[p],f[p],c.rl),I=b.crossTo(y,d,c.sl),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),O.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}ll(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.Zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Xu=!0;let e=t.attributeSemantics.indexOf(g.Position.XYZ),i=t.attributeAccessors[e],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=i.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:i.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=i.getVec3(h,{indicesAccessor:s}),p=i.getVec3(h+1,{indicesAccessor:s}),y=i.getVec3(h+2,{indicesAccessor:s});this.fl(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}fl(t,r,e,i,s,n){let a=e.x-r.x,o=e.y-r.y,u=e.z-r.z,f=i.x-r.x,l=i.y-r.y,h=i.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(e){return e.every(i=>i===e[0])}let r=this.primitives.map(e=>e.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Zu!==this.Qc?(this.Zu=this.Qc,!1):!0:!1}_invalidateMultiDrawStructure(){this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.hu()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let e=this.getPrimitiveAt(r);x.exist(e.vertexHandles)?e.update3DAPIVertexData():e.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.Zc)t.delete3DAPIVertexData();this.Jc>=0&&this.Yc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.Jc,this.Ru),this.Jc=-1,this.Ru=0)}};c.invalidateMeshUID=-1,c.qu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c.Ju=b.zero(),c._u=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.el=b.zero(),c.il=b.zero(),c.rl=b.zero(),c.sl=b.zero(),c.nl=b.zero(),c.ol=b.zero(),c.al=b.zero(),c.Yu=0;var B=c;export{B as Mesh};
1
+ import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{ProcessStage as z}from"../definitions/ProcessStage.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as O}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as H,isBlendWithZWrite as k,isOpaque as F,isTranslucent as E}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.Zc=[];this.Bu=[];this.Mu=[];this.Uu=[];this.Tu=[];this.ju=[];this.Pu=new G;this.Xc=[];this.vu=new Set;this.qc=v.InvalidCGAPIResourceUid;this.Ou=!1;this.xu=!1;this.Hu=!1;this.Nu=!1;this.ku=-1;this.Fu=-1;this.Eu=!1;this.du=0;this.gu=-1;this.Jc=-1;this.Ru=0;this.Lu=-1;this.Wu=0;this.Zu=0;this.Yc=[];this.tangentCalculationMode=1;this.Xu=!1;this.Qc=0;this.i=t,this.Gu=++c.qu}static get _primitivePositionUpdateVersion(){return c.Yu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.Zc.findIndex(e=>e.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Yc}_belongToMeshComponent(t){this.Yc.push(t.entity),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){let r=t.entity;this.Yc=this.Yc.filter(e=>e!==r),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),F(t)?this.Bu.push(t):E(t)?this.Mu.push(t):k(t)?this.Uu.push(t):H(t)&&this.Tu.push(t),this.hl(this.Bu.concat(this.Mu).concat(this.Uu).concat(this.Tu))}hl(t){this.Zc=t}isExistOpaque(){return this.Bu.length>0}isExistTranslucent(){return this.Mu.length>0}isExistBlendWithZWrite(){return this.Uu.length>0}isExistBlendWithoutZWrite(){return this.Tu.length>0}getPrimitiveAt(t){return this.Zc[t]}getPrimitiveNumber(){return this.Zc.length}hu(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Yc.length,r=this.i.webglResourceRepository.instanceSidTable,e=this.Jc;(e<0||this.Ru!==t)&&(e>=0&&r.free(e,this.Ru),e=r.allocate(t),this.Jc=e,this.Ru=t,r.writeIdentityRemap(e,t));let i=4294967295;for(let s=0;s<t;s++){let n=this.Yc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(e+s,a,o!=null?o.componentSID:i,u!=null?u.componentSID:i)}return e}get _instanceSidBase(){return this.Jc}get _remapPrepassId(){return this.Lu}set _remapPrepassId(t){this.Lu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.qc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.qc);let r=4294967295,e=this.Yc.length,i=new Uint32Array(e*4),s=new Int32Array(e),n=!1,a=!1;for(let o=0;o<e;o++){s[o]=this.Yc[o].entityUID,i[4*o+0]=this.Yc[o].getSceneGraph().componentSID;let u=this.Yc[o].tryToGetSkeletal();u!=null?i[4*o+1]=u.componentSID:i[4*o+1]=r;let f=this.Yc[o].tryToGetBlendShape();f!=null?i[4*o+2]=f.componentSID:i[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.Ou=e>0,this.xu=n,this.Hu=a,this.hu()?(this.qc=v.InvalidCGAPIResourceUid,this.Iu=i,this.Vu=s,this.Du=void 0,this.wu=void 0,this.du=e,this.yu=void 0,this.gu=-1,this._ensureInstanceSidBase(),!0):(this.qc=t.createVertexBufferFromTypedArray(i),this.Iu=i,this.Vu=s,this.Du=i.slice(),this.wu=new Uint32Array(i.length),this.du=e,this.yu=void 0,this.gu=-1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.hu())return this._packVisibleInstancesToInstanceRemap(t,r);let e=this.Iu,i=this.Vu,s=this.Du,n=this.wu;if(e===void 0||i===void 0||s===void 0||n===void 0||this.qc===v.InvalidCGAPIResourceUid)return this.Yc.length;if(t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let a=i.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=i[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=e[h+0],n[m+1]=e[h+1],n[m+2]=e[h+2],n[m+3]=e[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.qc,l),s.set(l)}return this.du=o,o}_packVisibleInstancesToInstanceRemap(t,r){let e=this.Vu;if(e===void 0)return this.Yc.length;if(this.Jc<0&&this._ensureInstanceSidBase(),t===this.yu&&r===this.gu)return this.du;this.yu=t,this.gu=r;let i=this.i.webglResourceRepository.instanceSidTable,s=this.Jc,n=e.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=e[o];if(u<t.length&&t[u]===r)continue}i.setRemap(s+a,o),a++}return this.du=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.qc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.qc),this.qc=v.InvalidCGAPIResourceUid,this.Iu=void 0,this.Vu=void 0,this.Du=void 0,this.wu=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let i=0;i<this.Zc.length;i++){let s=this.Zc[i],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[i]=n.vertexHandles.vaoHandle,this.vu.add(i);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[i])||this.Xc[i]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[i]=t.createVertexArray(),a.vaoHandle=this.Xc[i]),t.setVertexDataToPipeline(a,s,this.qc)}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=this.Zc.length;i<this.Xc.length;i++){let s=this.Xc[i];s&&!r.hasVaoHandle(s)&&(e.has(s)||(e.add(s),t.deleteVertexArray(s))),this.Xc[i]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.vu.clear();return}let r=t.getMultiDrawRepository(this.i),e=new Set;for(let i=0;i<this.Xc.length;i++){let s=this.Xc[i];s&&!e.has(s)&&!r.hasVaoHandle(s)&&(e.add(s),t.deleteVertexArray(s)),this.Xc[i]=v.InvalidCGAPIResourceUid}this.vu.clear()}_clearMultiDrawVaoUids(){for(let t of this.vu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.vu.clear()}castRay(t,r,e=0){var o;let i,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.Zc){let f=u.castRay(t,r,!0,!0,e,this.Xu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,i=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(i)?{result:!0,data:{t:s,u:n,v:a,position:i}}:{result:!1}}get primitives(){return this.Zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.qc}get _variationEntityInfo(){return this.Iu}get _isGpuCullable(){return this.Ou?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.xu)return!0;if(!this.Hu)return!1;for(let t=0;t<this.Zc.length;t++)if(this.Zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.ku===this.Zc.length&&this.Fu===this.Qc&&this.Eu===this.xu?this.Nu:(this.ku=this.Zc.length,this.Fu=this.Qc,this.Eu=this.xu,this.Nu=this.fl(),this.Nu)}fl(){if(this.Zc.length===0)return!1;let t=(r,e)=>r.some(i=>i.split(".")[0]===e);for(let r of this.Zc){let e=r.attributeSemantics;if(!t(e,"POSITION")||this.xu&&(!t(e,"JOINTS_0")||!t(e,"WEIGHTS_0")))return!1;for(let i of r.targets){let s=!1;for(let n of i.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Qc++,c.Yu++;for(let t of this.Yc)t.getMeshRenderer().moveStageTo(z.Load)}get primitivePositionUpdateCount(){return this.Qc}get AABB(){if(this.Qc!==this.Wu&&(this.Pu.initialize(),this.Wu=this.Qc),this.Pu.isVanilla())for(let t of this.Zc)this.Pu.mergeAABB(t.AABB);return this.Pu}bl(){for(let t=0;t<this.Zc.length;t++){let r=this.ju[t],e=this.Zc[t];e.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,e.getAttribute(n))})}}_calcTangents(){if(this.pl())for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let e=t.attributeSemantics.indexOf(g.Texcoord0.XY),i=t.attributeSemantics.indexOf(g.Normal.XYZ);if(e!==-1&&i!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[e],o=t.attributeAccessors[i],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),S=n.getVec3(d+2,{indicesAccessor:u}),M=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),T=a.getVec2(d+2,{indicesAccessor:u}),N=o.getVec3(d,{indicesAccessor:u});this.dl(d,I,A,S,M,U,T,N,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}dl(t,r,e,i,s,n,a,o,u,f){let l=this.zu(r,e,i,s,n,a,o,c.cl),h=this.zu(e,i,r,n,a,s,o,c.ul),m=this.zu(i,r,e,a,s,n,o,c.ll);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}zu(t,r,e,i,s,n,a,o){let u=[c.Tt.setComponents(t.x,i.x,i.y),c.bt.setComponents(t.y,i.x,i.y),c.ve.setComponents(t.z,i.x,i.y)],f=[c.Ju.setComponents(r.x,s.x,s.y),c._u.setComponents(r.y,s.x,s.y),c.Ku.setComponents(r.z,s.x,s.y)],l=[c.Qu.setComponents(e.x,n.x,n.y),c.$u.setComponents(e.y,n.x,n.y),c.il.setComponents(e.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.rl),d=b.subtractTo(l[p],f[p],c.sl),I=b.crossTo(y,d,c.al),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),O.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}pl(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.Zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let e=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[e].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.Zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Xu=!0;let e=t.attributeSemantics.indexOf(g.Position.XYZ),i=t.attributeAccessors[e],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=i.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:i.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=i.getVec3(h,{indicesAccessor:s}),p=i.getVec3(h+1,{indicesAccessor:s}),y=i.getVec3(h+2,{indicesAccessor:s});this.ml(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}ml(t,r,e,i,s,n){let a=e.x-r.x,o=e.y-r.y,u=e.z-r.z,f=i.x-r.x,l=i.y-r.y,h=i.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(e){return e.every(i=>i===e[0])}let r=this.primitives.map(e=>e.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Zu!==this.Qc?(this.Zu=this.Qc,!1):!0:!1}_invalidateMultiDrawStructure(){this.hu()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.hu()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let e=this.getPrimitiveAt(r);x.exist(e.vertexHandles)?e.update3DAPIVertexData():e.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.Zc)t.delete3DAPIVertexData();this.Jc>=0&&this.Yc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.Jc,this.Ru),this.Jc=-1,this.Ru=0)}};c.invalidateMeshUID=-1,c.qu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c.Ju=b.zero(),c._u=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.il=b.zero(),c.rl=b.zero(),c.sl=b.zero(),c.al=b.zero(),c.cl=b.zero(),c.ul=b.zero(),c.ll=b.zero(),c.Yu=0;var B=c;export{B as Mesh};