rhodonite 0.26.0 → 0.27.1

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 (762) hide show
  1. package/VERSION-FILE +1 -1
  2. package/dist/esm/foundation/components/Light/LightComponent.d.ts +14 -0
  3. package/dist/esm/foundation/components/Light/LightComponent.js +1 -1
  4. package/dist/esm/foundation/components/Mesh/MeshComponent.js +1 -1
  5. package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +28 -0
  6. package/dist/esm/foundation/components/MeshRenderer/MeshRendererComponent.js +1 -1
  7. package/dist/esm/foundation/components/Physics/PhysicsComponent.js +1 -1
  8. package/dist/esm/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +1 -1
  9. package/dist/esm/foundation/components/SceneGraph/SceneGraphComponent.js +1 -1
  10. package/dist/esm/foundation/components/Shape/ShapeComponent.js +1 -1
  11. package/dist/esm/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +1 -1
  12. package/dist/esm/foundation/components/Skeletal/SkeletalComponent.js +1 -1
  13. package/dist/esm/foundation/components/Transform/TransformComponent.js +1 -1
  14. package/dist/esm/foundation/constraints/VrmRollConstraint.js +1 -1
  15. package/dist/esm/foundation/core/Component.js +1 -1
  16. package/dist/esm/foundation/core/Config.d.ts +15 -0
  17. package/dist/esm/foundation/core/Config.js +1 -1
  18. package/dist/esm/foundation/core/GlobalDataRepository.js +1 -1
  19. package/dist/esm/foundation/core/MemoryManager.d.ts +19 -0
  20. package/dist/esm/foundation/core/MemoryManager.js +2 -2
  21. package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +1 -0
  22. package/dist/esm/foundation/definitions/ShaderSemantics.js +2 -2
  23. package/dist/esm/foundation/definitions/ShaderSemanticsInfo.d.ts +1 -0
  24. package/dist/esm/foundation/definitions/ShaderSemanticsInfo.js +1 -1
  25. package/dist/esm/foundation/definitions/VertexAttribute.js +1 -1
  26. package/dist/esm/foundation/exporter/Gltf2Exporter.d.ts +6 -0
  27. package/dist/esm/foundation/exporter/Gltf2Exporter.js +1 -1
  28. package/dist/esm/foundation/geometry/Frustum.js +1 -1
  29. package/dist/esm/foundation/geometry/Mesh.d.ts +15 -0
  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/geometry/shapes/Cylinder.js +1 -1
  33. package/dist/esm/foundation/geometry/shapes/Joint.js +1 -1
  34. package/dist/esm/foundation/gizmos/AABBGizmo.js +1 -1
  35. package/dist/esm/foundation/gizmos/CapsuleColliderGizmo.js +1 -1
  36. package/dist/esm/foundation/gizmos/Gizmo.js +1 -1
  37. package/dist/esm/foundation/gizmos/JointGizmo.js +1 -1
  38. package/dist/esm/foundation/gizmos/LightGizmo.d.ts +108 -10
  39. package/dist/esm/foundation/gizmos/LightGizmo.js +1 -1
  40. package/dist/esm/foundation/gizmos/LocatorGizmo.js +1 -1
  41. package/dist/esm/foundation/gizmos/RotationGizmo.js +1 -1
  42. package/dist/esm/foundation/gizmos/ScaleGizmo.js +1 -1
  43. package/dist/esm/foundation/gizmos/ShapeGizmo.js +1 -1
  44. package/dist/esm/foundation/gizmos/SphereColliderGizmo.js +1 -1
  45. package/dist/esm/foundation/gizmos/TranslationGizmo.js +1 -1
  46. package/dist/esm/foundation/helpers/BloomHelper.js +1 -1
  47. package/dist/esm/foundation/helpers/GaussianBlurHelper.js +1 -1
  48. package/dist/esm/foundation/helpers/MaterialHelper.d.ts +2 -0
  49. package/dist/esm/foundation/helpers/MaterialHelper.js +1 -1
  50. package/dist/esm/foundation/helpers/Shadow/PointShadowMap.js +1 -1
  51. package/dist/esm/foundation/helpers/Shadow/ShadowMap.js +1 -1
  52. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
  53. package/dist/esm/foundation/helpers/materials/createClassicUberMaterial.js +1 -1
  54. package/dist/esm/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.d.ts +21 -0
  55. package/dist/esm/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.js +1 -0
  56. package/dist/esm/foundation/helpers/materials/createGaussianBlurForEncodedDepthMaterial.js +1 -1
  57. package/dist/esm/foundation/helpers/materials/createGaussianBlurMaterial.js +1 -1
  58. package/dist/esm/foundation/helpers/materials/createMotionVectorMaterial.js +1 -1
  59. package/dist/esm/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +1 -1
  60. package/dist/esm/foundation/helpers/materials/createPbrUberMaterial.js +1 -1
  61. package/dist/esm/foundation/helpers/materials/createTemporalAAResolveMaterial.js +1 -1
  62. package/dist/esm/foundation/helpers/materials/index.d.ts +1 -0
  63. package/dist/esm/foundation/helpers/materials/index.js +1 -1
  64. package/dist/esm/foundation/helpers/materials/nodeBasedMaterialCommon.js +1 -1
  65. package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
  66. package/dist/esm/foundation/importer/Gltf2Importer.d.ts +2 -1
  67. package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
  68. package/dist/esm/foundation/importer/GltfImporter.js +1 -1
  69. package/dist/esm/foundation/importer/ModelConverter.d.ts +19 -0
  70. package/dist/esm/foundation/importer/ModelConverter.js +1 -1
  71. package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
  72. package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
  73. package/dist/esm/foundation/importer/VrmImporter.js +1 -1
  74. package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
  75. package/dist/esm/foundation/materials/contents/DepthEncodeMaterialContent.js +1 -1
  76. package/dist/esm/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +1 -1
  77. package/dist/esm/foundation/materials/contents/EntityUIDOutputMaterialContent.js +1 -1
  78. package/dist/esm/foundation/materials/contents/FurnaceTestMaterialContent.js +1 -1
  79. package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +18 -18
  80. package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
  81. package/dist/esm/foundation/materials/contents/MatCapMaterialContent.js +1 -1
  82. package/dist/esm/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +1 -1
  83. package/dist/esm/foundation/materials/contents/SynthesizeHdrMaterialContent.js +1 -1
  84. package/dist/esm/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +1 -1
  85. package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
  86. package/dist/esm/foundation/materials/core/AbstractShaderNode.js +2 -2
  87. package/dist/esm/foundation/materials/core/Material.d.ts +7 -2
  88. package/dist/esm/foundation/materials/core/Material.js +1 -1
  89. package/dist/esm/foundation/materials/core/MaterialRepository.js +1 -1
  90. package/dist/esm/foundation/materials/core/ShaderGraphResolver.js +4 -4
  91. package/dist/esm/foundation/materials/core/ShaderHandler.js +3 -3
  92. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
  93. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
  94. package/dist/esm/foundation/materials/nodes/AbsShaderNode.js +1 -1
  95. package/dist/esm/foundation/materials/nodes/AcosShaderNode.js +1 -1
  96. package/dist/esm/foundation/materials/nodes/AddShaderNode.js +1 -1
  97. package/dist/esm/foundation/materials/nodes/AlphaTestShaderNode.js +1 -1
  98. package/dist/esm/foundation/materials/nodes/AndShaderNode.js +1 -1
  99. package/dist/esm/foundation/materials/nodes/Atan2ShaderNode.js +1 -1
  100. package/dist/esm/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
  101. package/dist/esm/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
  102. package/dist/esm/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
  103. package/dist/esm/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
  104. package/dist/esm/foundation/materials/nodes/AttributePositionShaderNode.js +1 -1
  105. package/dist/esm/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
  106. package/dist/esm/foundation/materials/nodes/AttributeTexcoordShaderNode.js +1 -1
  107. package/dist/esm/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
  108. package/dist/esm/foundation/materials/nodes/BlockBeginShaderNode.js +1 -1
  109. package/dist/esm/foundation/materials/nodes/BlockEndShaderNode.js +1 -1
  110. package/dist/esm/foundation/materials/nodes/BranchShaderNode.js +1 -1
  111. package/dist/esm/foundation/materials/nodes/CalcBitangentShaderNode.js +1 -1
  112. package/dist/esm/foundation/materials/nodes/CastToFloatShaderNode.js +1 -1
  113. package/dist/esm/foundation/materials/nodes/ClampShaderNode.js +1 -1
  114. package/dist/esm/foundation/materials/nodes/ClassicShaderNode.js +1 -1
  115. package/dist/esm/foundation/materials/nodes/ConstantVariableShaderNode.js +1 -1
  116. package/dist/esm/foundation/materials/nodes/CosShaderNode.js +1 -1
  117. package/dist/esm/foundation/materials/nodes/DotProductShaderNode.js +1 -1
  118. package/dist/esm/foundation/materials/nodes/EqualShaderNode.js +1 -1
  119. package/dist/esm/foundation/materials/nodes/FlatShaderNode.js +1 -1
  120. package/dist/esm/foundation/materials/nodes/GreaterOrEqualShaderNode.js +1 -1
  121. package/dist/esm/foundation/materials/nodes/GreaterShaderNode.js +1 -1
  122. package/dist/esm/foundation/materials/nodes/GreaterThanShaderNode.js +1 -1
  123. package/dist/esm/foundation/materials/nodes/LengthShaderNode.js +1 -1
  124. package/dist/esm/foundation/materials/nodes/LessOrEqualShaderNode.js +1 -1
  125. package/dist/esm/foundation/materials/nodes/LessThanShaderNode.js +1 -1
  126. package/dist/esm/foundation/materials/nodes/MergeVectorShaderNode.js +1 -1
  127. package/dist/esm/foundation/materials/nodes/MinShaderNode.js +1 -1
  128. package/dist/esm/foundation/materials/nodes/MultiplyShaderNode.js +1 -1
  129. package/dist/esm/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
  130. package/dist/esm/foundation/materials/nodes/NormalizeShaderNode.js +1 -1
  131. package/dist/esm/foundation/materials/nodes/NotEqualShaderNode.js +1 -1
  132. package/dist/esm/foundation/materials/nodes/OrShaderNode.js +1 -1
  133. package/dist/esm/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +1 -1
  134. package/dist/esm/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +1 -1
  135. package/dist/esm/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +1 -1
  136. package/dist/esm/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +1 -1
  137. package/dist/esm/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +1 -1
  138. package/dist/esm/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +1 -1
  139. package/dist/esm/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +1 -1
  140. package/dist/esm/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +1 -1
  141. package/dist/esm/foundation/materials/nodes/PbrNormalPropsShaderNode.js +1 -1
  142. package/dist/esm/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +1 -1
  143. package/dist/esm/foundation/materials/nodes/PbrShaderShaderNode.js +1 -1
  144. package/dist/esm/foundation/materials/nodes/PbrSheenPropsShaderNode.js +1 -1
  145. package/dist/esm/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +1 -1
  146. package/dist/esm/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +1 -1
  147. package/dist/esm/foundation/materials/nodes/PbrVolumePropsShaderNode.js +1 -1
  148. package/dist/esm/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +1 -1
  149. package/dist/esm/foundation/materials/nodes/ProcessGeometryShaderNode.js +1 -1
  150. package/dist/esm/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
  151. package/dist/esm/foundation/materials/nodes/Random_HashPRNGShaderNode.js +1 -1
  152. package/dist/esm/foundation/materials/nodes/Random_SinHashShaderNode.js +1 -1
  153. package/dist/esm/foundation/materials/nodes/RemapShaderNode.js +1 -1
  154. package/dist/esm/foundation/materials/nodes/SinShaderNode.js +1 -1
  155. package/dist/esm/foundation/materials/nodes/SmoothStepShaderNode.js +1 -1
  156. package/dist/esm/foundation/materials/nodes/SplitVectorShaderNode.js +1 -1
  157. package/dist/esm/foundation/materials/nodes/StepShaderNode.js +1 -1
  158. package/dist/esm/foundation/materials/nodes/TanShaderNode.js +1 -1
  159. package/dist/esm/foundation/materials/nodes/Texture2DShaderNode.js +1 -1
  160. package/dist/esm/foundation/materials/nodes/TimeShaderNode.js +1 -1
  161. package/dist/esm/foundation/materials/nodes/TransformShaderNode.js +1 -1
  162. package/dist/esm/foundation/materials/nodes/UniformDataShaderNode.js +1 -1
  163. package/dist/esm/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
  164. package/dist/esm/foundation/materials/nodes/WireframeMaterialNode.js +1 -1
  165. package/dist/esm/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
  166. package/dist/esm/foundation/materials/nodes/raymarching/BendXYShaderNode.js +1 -1
  167. package/dist/esm/foundation/materials/nodes/raymarching/BendXZShaderNode.js +1 -1
  168. package/dist/esm/foundation/materials/nodes/raymarching/BendYXShaderNode.js +1 -1
  169. package/dist/esm/foundation/materials/nodes/raymarching/BendYZShaderNode.js +1 -1
  170. package/dist/esm/foundation/materials/nodes/raymarching/BendZXShaderNode.js +1 -1
  171. package/dist/esm/foundation/materials/nodes/raymarching/BendZYShaderNode.js +1 -1
  172. package/dist/esm/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
  173. package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +1 -1
  174. package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +1 -1
  175. package/dist/esm/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +1 -1
  176. package/dist/esm/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +1 -1
  177. package/dist/esm/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +1 -1
  178. package/dist/esm/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +1 -1
  179. package/dist/esm/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +1 -1
  180. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +1 -1
  181. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +1 -1
  182. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +1 -1
  183. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +1 -1
  184. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +1 -1
  185. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +1 -1
  186. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +1 -1
  187. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +1 -1
  188. package/dist/esm/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +1 -1
  189. package/dist/esm/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +1 -1
  190. package/dist/esm/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +1 -1
  191. package/dist/esm/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +1 -1
  192. package/dist/esm/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +1 -1
  193. package/dist/esm/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +1 -1
  194. package/dist/esm/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +1 -1
  195. package/dist/esm/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +1 -1
  196. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +1 -1
  197. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +1 -1
  198. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +1 -1
  199. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +1 -1
  200. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +1 -1
  201. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +1 -1
  202. package/dist/esm/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +1 -1
  203. package/dist/esm/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +1 -1
  204. package/dist/esm/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +1 -1
  205. package/dist/esm/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +1 -1
  206. package/dist/esm/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +1 -1
  207. package/dist/esm/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +1 -1
  208. package/dist/esm/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +1 -1
  209. package/dist/esm/foundation/materials/nodes/raymarching/TwistXShaderNode.js +1 -1
  210. package/dist/esm/foundation/materials/nodes/raymarching/TwistYShaderNode.js +1 -1
  211. package/dist/esm/foundation/materials/nodes/raymarching/TwistZShaderNode.js +1 -1
  212. package/dist/esm/foundation/math/IdentityMatrix33.js +2 -2
  213. package/dist/esm/foundation/math/IdentityMatrix44.js +2 -2
  214. package/dist/esm/foundation/math/MathClassUtil.js +1 -1
  215. package/dist/esm/foundation/math/Quaternion.js +1 -1
  216. package/dist/esm/foundation/math/Transform3D.js +1 -1
  217. package/dist/esm/foundation/memory/Accessor.js +6 -6
  218. package/dist/esm/foundation/memory/Buffer.js +3 -3
  219. package/dist/esm/foundation/memory/BufferView.js +1 -1
  220. package/dist/esm/foundation/misc/Logger.js +1 -1
  221. package/dist/esm/foundation/misc/PngDecoder.d.ts +18 -0
  222. package/dist/esm/foundation/misc/PngDecoder.js +1 -0
  223. package/dist/esm/foundation/misc/Time.js +1 -1
  224. package/dist/esm/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +1 -1
  225. package/dist/esm/foundation/physics/Rapier/RapierPhysicsStrategy.js +1 -1
  226. package/dist/esm/foundation/physics/VRMSpring/CapsuleCollider.js +1 -1
  227. package/dist/esm/foundation/physics/VRMSpring/SphereCollider.js +1 -1
  228. package/dist/esm/foundation/physics/VRMSpring/VRMSpringBone.js +1 -1
  229. package/dist/esm/foundation/renderer/Frame.js +1 -1
  230. package/dist/esm/foundation/renderer/FrameBuffer.js +1 -1
  231. package/dist/esm/foundation/renderer/RenderPass.d.ts +7 -0
  232. package/dist/esm/foundation/renderer/RenderPass.js +1 -1
  233. package/dist/esm/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +1 -1
  234. package/dist/esm/foundation/renderer/TemporalAA/TemporalAASystem.js +1 -1
  235. package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.d.ts +12 -0
  236. package/dist/esm/foundation/renderer/lightCluster/LightClusterSystem.js +1 -1
  237. package/dist/esm/foundation/renderer/lightCluster/LightClusterSystemStub.js +1 -1
  238. package/dist/esm/foundation/renderer/pipelines/DeferredRenderPipeline.js +1 -1
  239. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +84 -10
  240. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
  241. package/dist/esm/foundation/system/Engine.d.ts +2 -16
  242. package/dist/esm/foundation/system/Engine.js +1 -1
  243. package/dist/esm/foundation/system/EngineState.d.ts +6 -0
  244. package/dist/esm/foundation/system/GpuDriverWorkarounds.d.ts +50 -0
  245. package/dist/esm/foundation/system/GpuDriverWorkarounds.js +1 -0
  246. package/dist/esm/foundation/system/ModuleManager.js +1 -1
  247. package/dist/esm/foundation/system/index.d.ts +1 -0
  248. package/dist/esm/foundation/system/index.js +1 -1
  249. package/dist/esm/foundation/textures/AbstractTexture.js +1 -1
  250. package/dist/esm/foundation/textures/CubeTexture.d.ts +11 -2
  251. package/dist/esm/foundation/textures/CubeTexture.js +1 -1
  252. package/dist/esm/foundation/textures/RenderTargetTexture.js +1 -1
  253. package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
  254. package/dist/esm/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
  255. package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
  256. package/dist/esm/foundation/textures/Texture.js +1 -1
  257. package/dist/esm/foundation/textures/TextureDataFloat.js +1 -1
  258. package/dist/esm/foundation/textures/VideoTexture.js +1 -1
  259. package/dist/esm/types/glTF2.d.ts +9 -0
  260. package/dist/esm/version.js +1 -1
  261. package/dist/esm/webgl/InstanceSidTable.js +1 -1
  262. package/dist/esm/webgl/MultiDraw.js +1 -1
  263. package/dist/esm/webgl/MultiDrawRepository.js +1 -1
  264. package/dist/esm/webgl/WebGLResourceRepository.d.ts +5 -0
  265. package/dist/esm/webgl/WebGLResourceRepository.js +4 -4
  266. package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
  267. package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +19 -14
  268. package/dist/esm/webgl/WebGLStrategyWebGL2.js +67 -67
  269. package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +17 -8
  270. package/dist/esm/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +5 -5
  271. package/dist/esm/webgl/shaderity_shaders/ColorGradingUsingLUTsShader/ColorGradingUsingLUTsShader.vert.js +1 -1
  272. package/dist/esm/webgl/shaderity_shaders/DepthEncodeSingleShader/DepthEncodeSingleShader.vert.js +2 -2
  273. package/dist/esm/webgl/shaderity_shaders/DepthMomentEncodeShader/DepthMomentEncodeShader.vert.js +3 -3
  274. package/dist/esm/webgl/shaderity_shaders/DetectHighLuminanceAndCorrectShader/DetectHighLuminanceAndCorrectShader.vert.js +2 -2
  275. package/dist/esm/webgl/shaderity_shaders/EntityUIDOutputSingleShader/EntityUIDOutputSingleShader.vert.js +2 -2
  276. package/dist/esm/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.js +84 -0
  277. package/dist/esm/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.js +34 -0
  278. package/dist/esm/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +5 -5
  279. package/dist/esm/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
  280. package/dist/esm/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +7 -7
  281. package/dist/esm/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.vert.js +4 -4
  282. package/dist/esm/webgl/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +1 -1
  283. package/dist/esm/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +8 -4
  284. package/dist/esm/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js +1 -1
  285. package/dist/esm/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +43 -39
  286. package/dist/esm/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js +4 -4
  287. package/dist/esm/webgl/shaderity_shaders/MatCapShader/MatCapShader.vert.js +1 -1
  288. package/dist/esm/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +3 -3
  289. package/dist/esm/webgl/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.js +1 -1
  290. package/dist/esm/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.glsl.js +1 -1
  291. package/dist/esm/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.glsl.js +4 -4
  292. package/dist/esm/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +125 -111
  293. package/dist/esm/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.vert.js +6 -6
  294. package/dist/esm/webgl/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.js +5 -5
  295. package/dist/esm/webgl/shaderity_shaders/ShadowMapDecodeClassicSingleShader/ShadowMapDecodeClassicSingleShader.vert.js +2 -2
  296. package/dist/esm/webgl/shaderity_shaders/SummedAreaTableShader/SummedAreaTableShader.frag.js +3 -3
  297. package/dist/esm/webgl/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.js +1 -1
  298. package/dist/esm/webgl/shaderity_shaders/VarianceShadowMapDecodeClassicShader/VarianceShadowMapDecodeClassicShader.vert.js +2 -2
  299. package/dist/esm/webgl/shaderity_shaders/common/iblDefinition.glsl.js +64 -5
  300. package/dist/esm/webgl/shaderity_shaders/common/morphVariables.glsl.js +2 -2
  301. package/dist/esm/webgl/shaderity_shaders/common/opticalDefinition.glsl.js +4 -1
  302. package/dist/esm/webgl/shaderity_shaders/common/prerequisites.glsl.js +3 -3
  303. package/dist/esm/webgl/shaderity_shaders/nodes/ClassicShader.glsl.js +10 -1
  304. package/dist/esm/webgl/shaderity_shaders/nodes/PbrShader.glsl.js +12 -0
  305. package/dist/esm/webgl/shaders/RaymarchingShaderPart.js +23 -11
  306. package/dist/esm/webgl/shaders/nodes/BlockBeginShader.js +1 -1
  307. package/dist/esm/webgl/shaders/nodes/BlockEndShader.js +1 -1
  308. package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
  309. package/dist/esm/webgl/shaders/nodes/DiscardShader.js +1 -1
  310. package/dist/esm/webgl/shaders/nodes/EndShader.js +1 -1
  311. package/dist/esm/webgl/shaders/nodes/RaymarchObjectIdUniform.js +3 -3
  312. package/dist/esm/webgl/shaders/nodes/SdApplyTransform.js +5 -5
  313. package/dist/esm/webgl/shaders/nodes/SdApplyWorldMatrix.js +3 -3
  314. package/dist/esm/webgl/shaders/nodes/Texture2DShader.js +14 -14
  315. package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +13 -13
  316. package/dist/esm/webgl/textureLoader/KTX2TextureLoader.js +1 -1
  317. package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
  318. package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
  319. package/dist/esm/webgpu/RangeAllocator.js +1 -1
  320. package/dist/esm/webgpu/WebGpuBufferArena.js +1 -1
  321. package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
  322. package/dist/esm/webgpu/WebGpuLightClusterBuilder.js +1 -1
  323. package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +6 -0
  324. package/dist/esm/webgpu/WebGpuResourceRepository.js +5 -5
  325. package/dist/esm/webgpu/WebGpuStrategyBasic.d.ts +1 -0
  326. package/dist/esm/webgpu/WebGpuStrategyBasic.js +54 -54
  327. package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
  328. package/dist/esm/webgpu/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +15 -8
  329. package/dist/esm/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.wgsl.js +84 -0
  330. package/dist/esm/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.wgsl.js +19 -0
  331. package/dist/esm/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +6 -6
  332. package/dist/esm/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +3 -3
  333. package/dist/esm/webgpu/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +5 -5
  334. package/dist/esm/webgpu/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +3 -3
  335. package/dist/esm/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +9 -5
  336. package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +44 -40
  337. package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js +2 -2
  338. package/dist/esm/webgpu/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.wgsl.js +1 -1
  339. package/dist/esm/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.wgsl.js +2 -2
  340. package/dist/esm/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.wgsl.js +3 -3
  341. package/dist/esm/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +125 -113
  342. package/dist/esm/webgpu/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.wgsl.js +5 -5
  343. package/dist/esm/webgpu/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.wgsl.js +1 -1
  344. package/dist/esm/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +65 -5
  345. package/dist/esm/webgpu/shaderity_shaders/common/opticalDefinition.wgsl.js +4 -1
  346. package/dist/esm/webgpu/shaderity_shaders/nodes/ClassicShader.wgsl.js +7 -0
  347. package/dist/esm/webgpu/shaderity_shaders/nodes/PbrShader.wgsl.js +13 -2
  348. package/dist/esmdev/foundation/components/Light/LightComponent.d.ts +14 -0
  349. package/dist/esmdev/foundation/components/Light/LightComponent.js +38 -11
  350. package/dist/esmdev/foundation/components/Mesh/MeshComponent.js +47 -44
  351. package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.d.ts +28 -0
  352. package/dist/esmdev/foundation/components/MeshRenderer/MeshRendererComponent.js +142 -92
  353. package/dist/esmdev/foundation/components/Physics/PhysicsComponent.js +65 -65
  354. package/dist/esmdev/foundation/components/Raymarching/RaymarchingComponent.js +54 -54
  355. package/dist/esmdev/foundation/components/Raymarching/RaymarchingSdfEvaluator.js +250 -250
  356. package/dist/esmdev/foundation/components/SceneGraph/SceneGraphComponent.js +335 -335
  357. package/dist/esmdev/foundation/components/Shape/ShapeComponent.js +31 -31
  358. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/AbsoluteAnimation.js +5 -5
  359. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetarget.js +5 -5
  360. package/dist/esmdev/foundation/components/Skeletal/AnimationRetarget/GlobalRetargetReverse.js +9 -9
  361. package/dist/esmdev/foundation/components/Skeletal/SkeletalComponent.js +222 -222
  362. package/dist/esmdev/foundation/components/Transform/TransformComponent.js +66 -66
  363. package/dist/esmdev/foundation/components/Trigger/TriggerComponent.js +61 -61
  364. package/dist/esmdev/foundation/components/Vrm/VrmComponent.js +44 -44
  365. package/dist/esmdev/foundation/constraints/VrmAimConstraint.js +11 -11
  366. package/dist/esmdev/foundation/constraints/VrmRollConstraint.js +16 -16
  367. package/dist/esmdev/foundation/constraints/VrmRotationConstraint.js +10 -10
  368. package/dist/esmdev/foundation/core/Component.js +32 -32
  369. package/dist/esmdev/foundation/core/ComponentMemoryRegistry.js +41 -41
  370. package/dist/esmdev/foundation/core/ComponentRepository.js +37 -37
  371. package/dist/esmdev/foundation/core/Config.d.ts +15 -0
  372. package/dist/esmdev/foundation/core/Config.js +27 -10
  373. package/dist/esmdev/foundation/core/Entity.js +9 -9
  374. package/dist/esmdev/foundation/core/EntityRepository.js +19 -19
  375. package/dist/esmdev/foundation/core/GlobalDataRepository.js +31 -18
  376. package/dist/esmdev/foundation/core/MemoryManager.d.ts +19 -0
  377. package/dist/esmdev/foundation/core/MemoryManager.js +52 -27
  378. package/dist/esmdev/foundation/core/RnObject.js +37 -37
  379. package/dist/esmdev/foundation/definitions/Blend.js +3 -3
  380. package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
  381. package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
  382. package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
  383. package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +1 -0
  384. package/dist/esmdev/foundation/definitions/ShaderSemantics.js +12 -7
  385. package/dist/esmdev/foundation/definitions/ShaderSemanticsInfo.d.ts +1 -0
  386. package/dist/esmdev/foundation/definitions/ShaderSemanticsInfo.js +1 -1
  387. package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
  388. package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
  389. package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
  390. package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
  391. package/dist/esmdev/foundation/exporter/Gltf2Exporter.d.ts +6 -0
  392. package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +140 -110
  393. package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +24 -24
  394. package/dist/esmdev/foundation/geometry/Frustum.js +41 -41
  395. package/dist/esmdev/foundation/geometry/Mesh.d.ts +15 -0
  396. package/dist/esmdev/foundation/geometry/Mesh.js +245 -215
  397. package/dist/esmdev/foundation/geometry/Primitive.js +141 -135
  398. package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
  399. package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
  400. package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
  401. package/dist/esmdev/foundation/gizmos/AABBGizmo.js +16 -16
  402. package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +23 -23
  403. package/dist/esmdev/foundation/gizmos/Gizmo.js +23 -23
  404. package/dist/esmdev/foundation/gizmos/JointGizmo.js +37 -37
  405. package/dist/esmdev/foundation/gizmos/LightGizmo.d.ts +108 -10
  406. package/dist/esmdev/foundation/gizmos/LightGizmo.js +248 -49
  407. package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +25 -25
  408. package/dist/esmdev/foundation/gizmos/RotationGizmo.js +211 -211
  409. package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +130 -130
  410. package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +43 -43
  411. package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +24 -24
  412. package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +129 -129
  413. package/dist/esmdev/foundation/helpers/BloomHelper.js +42 -38
  414. package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
  415. package/dist/esmdev/foundation/helpers/MaterialHelper.d.ts +2 -0
  416. package/dist/esmdev/foundation/helpers/MaterialHelper.js +3 -1
  417. package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +12 -12
  418. package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
  419. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +119 -119
  420. package/dist/esmdev/foundation/helpers/materials/createClassicUberMaterial.js +13 -5
  421. package/dist/esmdev/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.d.ts +21 -0
  422. package/dist/esmdev/foundation/helpers/materials/createEnvConstantScreenSpaceMaterial.js +32 -0
  423. package/dist/esmdev/foundation/helpers/materials/createGaussianBlurForEncodedDepthMaterial.js +12 -4
  424. package/dist/esmdev/foundation/helpers/materials/createGaussianBlurMaterial.js +13 -5
  425. package/dist/esmdev/foundation/helpers/materials/createMotionVectorMaterial.js +7 -3
  426. package/dist/esmdev/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +49 -17
  427. package/dist/esmdev/foundation/helpers/materials/createPbrUberMaterial.js +13 -5
  428. package/dist/esmdev/foundation/helpers/materials/createTemporalAAResolveMaterial.js +22 -8
  429. package/dist/esmdev/foundation/helpers/materials/index.d.ts +1 -0
  430. package/dist/esmdev/foundation/helpers/materials/index.js +3 -1
  431. package/dist/esmdev/foundation/helpers/materials/nodeBasedMaterialCommon.js +32 -10
  432. package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
  433. package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +33 -33
  434. package/dist/esmdev/foundation/importer/Gltf2Importer.d.ts +2 -1
  435. package/dist/esmdev/foundation/importer/Gltf2Importer.js +21 -17
  436. package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
  437. package/dist/esmdev/foundation/importer/ModelConverter.d.ts +19 -0
  438. package/dist/esmdev/foundation/importer/ModelConverter.js +183 -132
  439. package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
  440. package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
  441. package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
  442. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +37 -28
  443. package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +15 -9
  444. package/dist/esmdev/foundation/materials/contents/DetectHighLuminanceMaterialContent.js +3 -2
  445. package/dist/esmdev/foundation/materials/contents/EntityUIDOutputMaterialContent.js +5 -3
  446. package/dist/esmdev/foundation/materials/contents/FurnaceTestMaterialContent.js +16 -8
  447. package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +205 -170
  448. package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +28 -20
  449. package/dist/esmdev/foundation/materials/contents/MatCapMaterialContent.js +7 -4
  450. package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +33 -19
  451. package/dist/esmdev/foundation/materials/contents/SynthesizeHdrMaterialContent.js +3 -1
  452. package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +41 -24
  453. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +51 -51
  454. package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +26 -26
  455. package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
  456. package/dist/esmdev/foundation/materials/core/Material.d.ts +7 -2
  457. package/dist/esmdev/foundation/materials/core/Material.js +132 -118
  458. package/dist/esmdev/foundation/materials/core/MaterialRepository.js +65 -65
  459. package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
  460. package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
  461. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +26 -20
  462. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +29 -23
  463. package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
  464. package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
  465. package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
  466. package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
  467. package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
  468. package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
  469. package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
  470. package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
  471. package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
  472. package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
  473. package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
  474. package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
  475. package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
  476. package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
  477. package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
  478. package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
  479. package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
  480. package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
  481. package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
  482. package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
  483. package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
  484. package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
  485. package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
  486. package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
  487. package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
  488. package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
  489. package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
  490. package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
  491. package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
  492. package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
  493. package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
  494. package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
  495. package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
  496. package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
  497. package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
  498. package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
  499. package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
  500. package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
  501. package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
  502. package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
  503. package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
  504. package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
  505. package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
  506. package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
  507. package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
  508. package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
  509. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
  510. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
  511. package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
  512. package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
  513. package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
  514. package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
  515. package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
  516. package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
  517. package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
  518. package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
  519. package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
  520. package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
  521. package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
  522. package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
  523. package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
  524. package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
  525. package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
  526. package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
  527. package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
  528. package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
  529. package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
  530. package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
  531. package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
  532. package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
  533. package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
  534. package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
  535. package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
  536. package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
  537. package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
  538. package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
  539. package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
  540. package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
  541. package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
  542. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
  543. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
  544. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
  545. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
  546. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
  547. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
  548. package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
  549. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
  550. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
  551. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
  552. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
  553. package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
  554. package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +16 -16
  555. package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
  556. package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +16 -16
  557. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
  558. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
  559. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
  560. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
  561. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
  562. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
  563. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
  564. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
  565. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
  566. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
  567. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
  568. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
  569. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
  570. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
  571. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
  572. package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
  573. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
  574. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
  575. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
  576. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
  577. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
  578. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
  579. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
  580. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
  581. package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
  582. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
  583. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
  584. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
  585. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
  586. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
  587. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
  588. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
  589. package/dist/esmdev/foundation/math/AABB.js +132 -132
  590. package/dist/esmdev/foundation/math/AnimatedQuaternion.js +54 -54
  591. package/dist/esmdev/foundation/math/AnimatedScalar.js +55 -55
  592. package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +20 -20
  593. package/dist/esmdev/foundation/math/AnimatedVector2.js +55 -55
  594. package/dist/esmdev/foundation/math/AnimatedVector3.js +55 -55
  595. package/dist/esmdev/foundation/math/AnimatedVector4.js +55 -55
  596. package/dist/esmdev/foundation/math/AnimatedVectorN.js +55 -55
  597. package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
  598. package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
  599. package/dist/esmdev/foundation/math/MathClassUtil.js +4 -4
  600. package/dist/esmdev/foundation/math/Quaternion.js +20 -20
  601. package/dist/esmdev/foundation/math/Transform3D.js +74 -74
  602. package/dist/esmdev/foundation/math/shapes/MathSphere.js +7 -7
  603. package/dist/esmdev/foundation/memory/Accessor.js +369 -369
  604. package/dist/esmdev/foundation/memory/Buffer.js +40 -40
  605. package/dist/esmdev/foundation/memory/BufferView.js +33 -33
  606. package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
  607. package/dist/esmdev/foundation/misc/EnumIO.js +10 -10
  608. package/dist/esmdev/foundation/misc/Logger.js +14 -14
  609. package/dist/esmdev/foundation/misc/PngDecoder.d.ts +18 -0
  610. package/dist/esmdev/foundation/misc/PngDecoder.js +113 -0
  611. package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
  612. package/dist/esmdev/foundation/misc/Time.js +27 -27
  613. package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
  614. package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
  615. package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
  616. package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +10 -10
  617. package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +193 -193
  618. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +241 -241
  619. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
  620. package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +42 -42
  621. package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +27 -27
  622. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +10 -10
  623. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +56 -56
  624. package/dist/esmdev/foundation/renderer/Expression.js +6 -6
  625. package/dist/esmdev/foundation/renderer/Frame.js +12 -12
  626. package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
  627. package/dist/esmdev/foundation/renderer/RenderPass.d.ts +7 -0
  628. package/dist/esmdev/foundation/renderer/RenderPass.js +109 -101
  629. package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +10 -10
  630. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +78 -78
  631. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.d.ts +12 -0
  632. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +193 -155
  633. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
  634. package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +6 -6
  635. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +84 -10
  636. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +585 -461
  637. package/dist/esmdev/foundation/system/Engine.d.ts +2 -16
  638. package/dist/esmdev/foundation/system/Engine.js +239 -238
  639. package/dist/esmdev/foundation/system/EngineState.d.ts +6 -0
  640. package/dist/esmdev/foundation/system/EngineState.js +1 -1
  641. package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
  642. package/dist/esmdev/foundation/system/GpuDriverWorkarounds.d.ts +50 -0
  643. package/dist/esmdev/foundation/system/GpuDriverWorkarounds.js +93 -0
  644. package/dist/esmdev/foundation/system/InputManager.js +56 -56
  645. package/dist/esmdev/foundation/system/ModuleManager.js +6 -6
  646. package/dist/esmdev/foundation/system/index.d.ts +1 -0
  647. package/dist/esmdev/foundation/system/index.js +2 -1
  648. package/dist/esmdev/foundation/textures/AbstractTexture.js +49 -49
  649. package/dist/esmdev/foundation/textures/CubeTexture.d.ts +11 -2
  650. package/dist/esmdev/foundation/textures/CubeTexture.js +47 -36
  651. package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
  652. package/dist/esmdev/foundation/textures/RenderTargetTexture.js +24 -24
  653. package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +35 -35
  654. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
  655. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +25 -19
  656. package/dist/esmdev/foundation/textures/Sampler.js +24 -24
  657. package/dist/esmdev/foundation/textures/Texture.js +83 -83
  658. package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
  659. package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
  660. package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
  661. package/dist/esmdev/types/glTF2.d.ts +9 -0
  662. package/dist/esmdev/types/glTF2.js +1 -1
  663. package/dist/esmdev/version.js +2 -2
  664. package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
  665. package/dist/esmdev/webgl/MultiDraw.js +2 -2
  666. package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
  667. package/dist/esmdev/webgl/WebGLContextWrapper.js +164 -164
  668. package/dist/esmdev/webgl/WebGLGpuTimer.js +32 -32
  669. package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +5 -0
  670. package/dist/esmdev/webgl/WebGLResourceRepository.js +379 -314
  671. package/dist/esmdev/webgl/WebGLStereoUtil.js +42 -42
  672. package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +19 -14
  673. package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +320 -299
  674. package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
  675. package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +2 -2
  676. package/dist/esmdev/webgl/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.vert.js +2 -2
  677. package/dist/esmdev/webgl/shaderity_shaders/ColorGradingUsingLUTsShader/ColorGradingUsingLUTsShader.vert.js +2 -2
  678. package/dist/esmdev/webgl/shaderity_shaders/DepthEncodeSingleShader/DepthEncodeSingleShader.vert.js +2 -2
  679. package/dist/esmdev/webgl/shaderity_shaders/DepthMomentEncodeShader/DepthMomentEncodeShader.vert.js +2 -2
  680. package/dist/esmdev/webgl/shaderity_shaders/DetectHighLuminanceAndCorrectShader/DetectHighLuminanceAndCorrectShader.vert.js +2 -2
  681. package/dist/esmdev/webgl/shaderity_shaders/EntityUIDOutputSingleShader/EntityUIDOutputSingleShader.vert.js +2 -2
  682. package/dist/esmdev/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.js +12 -0
  683. package/dist/esmdev/webgl/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.js +12 -0
  684. package/dist/esmdev/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +2 -2
  685. package/dist/esmdev/webgl/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
  686. package/dist/esmdev/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +2 -2
  687. package/dist/esmdev/webgl/shaderity_shaders/FlatSingleShader/FlatSingleShader.vert.js +2 -2
  688. package/dist/esmdev/webgl/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +2 -2
  689. package/dist/esmdev/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +2 -2
  690. package/dist/esmdev/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js +2 -2
  691. package/dist/esmdev/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +2 -2
  692. package/dist/esmdev/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js +2 -2
  693. package/dist/esmdev/webgl/shaderity_shaders/MatCapShader/MatCapShader.vert.js +2 -2
  694. package/dist/esmdev/webgl/shaderity_shaders/MotionVectorShader/MotionVectorShader.vert.js +2 -2
  695. package/dist/esmdev/webgl/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.js +2 -2
  696. package/dist/esmdev/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.glsl.js +2 -2
  697. package/dist/esmdev/webgl/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.glsl.js +2 -2
  698. package/dist/esmdev/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
  699. package/dist/esmdev/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.vert.js +2 -2
  700. package/dist/esmdev/webgl/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.js +2 -2
  701. package/dist/esmdev/webgl/shaderity_shaders/ShadowMapDecodeClassicSingleShader/ShadowMapDecodeClassicSingleShader.vert.js +2 -2
  702. package/dist/esmdev/webgl/shaderity_shaders/SummedAreaTableShader/SummedAreaTableShader.frag.js +2 -2
  703. package/dist/esmdev/webgl/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.js +2 -2
  704. package/dist/esmdev/webgl/shaderity_shaders/VarianceShadowMapDecodeClassicShader/VarianceShadowMapDecodeClassicShader.vert.js +2 -2
  705. package/dist/esmdev/webgl/shaderity_shaders/common/iblDefinition.glsl.js +2 -2
  706. package/dist/esmdev/webgl/shaderity_shaders/common/morphVariables.glsl.js +2 -2
  707. package/dist/esmdev/webgl/shaderity_shaders/common/opticalDefinition.glsl.js +5 -2
  708. package/dist/esmdev/webgl/shaderity_shaders/common/prerequisites.glsl.js +2 -2
  709. package/dist/esmdev/webgl/shaderity_shaders/nodes/ClassicShader.glsl.js +2 -2
  710. package/dist/esmdev/webgl/shaderity_shaders/nodes/PbrShader.glsl.js +2 -2
  711. package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +25 -13
  712. package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
  713. package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
  714. package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
  715. package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
  716. package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
  717. package/dist/esmdev/webgl/shaders/nodes/DiscardShader.js +3 -3
  718. package/dist/esmdev/webgl/shaders/nodes/EndShader.js +3 -3
  719. package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
  720. package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
  721. package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
  722. package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
  723. package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
  724. package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
  725. package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
  726. package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +27 -27
  727. package/dist/esmdev/webgpu/GpuCullingRegistry.js +94 -94
  728. package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
  729. package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
  730. package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
  731. package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
  732. package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
  733. package/dist/esmdev/webgpu/WebGpuGpuTimer.js +52 -52
  734. package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +37 -37
  735. package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +6 -0
  736. package/dist/esmdev/webgpu/WebGpuResourceRepository.js +661 -599
  737. package/dist/esmdev/webgpu/WebGpuStrategyBasic.d.ts +1 -0
  738. package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +129 -125
  739. package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
  740. package/dist/esmdev/webgpu/shaderity_shaders/ClassicSingleShader/ClassicSingleShader.frag.js +2 -2
  741. package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.frag.wgsl.js +12 -0
  742. package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantScreenSpaceShader/EnvConstantScreenSpaceShader.vert.wgsl.js +12 -0
  743. package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.frag.js +2 -2
  744. package/dist/esmdev/webgpu/shaderity_shaders/EnvConstantSingleShader/EnvConstantSingleShader.vert.js +2 -2
  745. package/dist/esmdev/webgpu/shaderity_shaders/FlatSingleShader/FlatSingleShader.frag.js +2 -2
  746. package/dist/esmdev/webgpu/shaderity_shaders/GammaCorrectionShader/GammaCorrectionShader.frag.js +2 -2
  747. package/dist/esmdev/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +2 -2
  748. package/dist/esmdev/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +2 -2
  749. package/dist/esmdev/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js +2 -2
  750. package/dist/esmdev/webgpu/shaderity_shaders/PanoramaToCubeShader/PanoramaToCubeShader.frag.wgsl.js +2 -2
  751. package/dist/esmdev/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.frag.wgsl.js +2 -2
  752. package/dist/esmdev/webgpu/shaderity_shaders/ParaboloidDepthMomentEncodeShader/ParaboloidDepthMomentEncodeShader.vert.wgsl.js +2 -2
  753. package/dist/esmdev/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
  754. package/dist/esmdev/webgpu/shaderity_shaders/PrefilterIBLShader/PrefilterIBLShader.frag.wgsl.js +2 -2
  755. package/dist/esmdev/webgpu/shaderity_shaders/ToneMappingShader/ToneMappingShader.frag.wgsl.js +2 -2
  756. package/dist/esmdev/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +2 -2
  757. package/dist/esmdev/webgpu/shaderity_shaders/common/opticalDefinition.wgsl.js +5 -2
  758. package/dist/esmdev/webgpu/shaderity_shaders/nodes/ClassicShader.wgsl.js +2 -2
  759. package/dist/esmdev/webgpu/shaderity_shaders/nodes/PbrShader.wgsl.js +2 -2
  760. package/dist/esmdev/xr/WebARSystem.js +69 -69
  761. package/dist/esmdev/xr/WebXRSystem.js +153 -153
  762. package/package.json +2 -1
@@ -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.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};
1
+ import{BufferUse as C}from"../definitions/BufferUse.js";import{ComponentType as R}from"../definitions/ComponentType.js";import{CompositionType as P}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{ProcessApproach as D}from"../definitions/ProcessApproach.js";import{VertexAttribute as g}from"../definitions/VertexAttribute.js";import{AABB as G}from"../math/AABB.js";import{MutableVector3 as b}from"../math/MutableVector3.js";import{Vector3 as z}from"../math/Vector3.js";import{Is as x}from"../misc/Is.js";import{Logger as w}from"../misc/Logger.js";import{CGAPIResourceRepository as v}from"../renderer/CGAPIResourceRepository.js";import{isBlendWithoutZWrite as O,isBlendWithZWrite as H,isOpaque as k,isTranslucent as F}from"./types/GeometryTypes.js";var c=class c{constructor(t){this.zc=[];this.wu=[];this.Bu=[];this.Mu=[];this.Uu=[];this.qu=[];this.Ru=new G;this.Xc=[];this.gu=new Set;this.Yc=v.InvalidCGAPIResourceUid;this.zu=!1;this.Iu=!1;this.Ou=!1;this.Nu=!1;this.Hu=-1;this.ku=-1;this.Fu=!1;this.hu=0;this.yu=-1;this.qc=-1;this.Vu=0;this.Eu=-1;this.Lu=0;this.Wu=0;this.Zc=[];this.xu=!1;this.tangentCalculationMode=1;this.Zu=!1;this.Jc=0;this.i=t,this.Gu=++c.Yu}static get _primitivePositionUpdateVersion(){return c.Xu}getVaoUids(t){return this.Xc[t]}getVaoUidsByPrimitiveUid(t){let r=this.zc.findIndex(i=>i.primitiveUid===t);return this.Xc[r]}get meshEntitiesInner(){return this.Zc}get _variationInstanceCount(){return this.Qc==null?this.Zc.length:this.Qc.length/4}_belongToMeshComponent(t){this.Zc.push(t.entity),this.xu=!0,this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_removeMeshComponent(t){var i;let r=t.entity;this.Zc=this.Zc.filter(e=>e!==r),this.xu=!0;for(let e of this.Zc)(i=e.tryToGetMeshRenderer())==null||i.markNeedsLoad();this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}addPrimitive(t){t._belongToMesh(this),this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this),k(t)?this.wu.push(t):F(t)?this.Bu.push(t):H(t)?this.Mu.push(t):O(t)&&this.Uu.push(t),this.hl(this.wu.concat(this.Bu).concat(this.Mu).concat(this.Uu))}hl(t){this.zc=t}isExistOpaque(){return this.wu.length>0}isExistTranslucent(){return this.Bu.length>0}isExistBlendWithZWrite(){return this.Mu.length>0}isExistBlendWithoutZWrite(){return this.Uu.length>0}getPrimitiveAt(t){return this.zc[t]}getPrimitiveNumber(){return this.zc.length}$c(){if(!this.i.config.isMultiDrawEnabled||this.i.engineState.currentProcessApproach!==D.WebGL2)return!1;let t=this.i.webglResourceRepository,r=t.currentWebGLContextWrapper;return r!=null&&r.webgl2ExtMD!=null&&t.instanceSidTable.isSupported}_ensureInstanceSidBase(){let t=this.Zc.length,r=this.i.webglResourceRepository.instanceSidTable,i=this.qc;(i<0||this.Vu!==t)&&(i>=0&&r.free(i,this.Vu),i=r.allocate(t),this.qc=i,this.Vu=t,r.writeIdentityRemap(i,t));let e=4294967295;for(let s=0;s<t;s++){let n=this.Zc[s],a=n.getSceneGraph().componentSID,o=n.tryToGetSkeletal(),u=n.tryToGetBlendShape();r.setRecord(i+s,a,o!=null?o.componentSID:e,u!=null?u.componentSID:e)}return i}get _instanceSidBase(){return this.qc}get _remapPrepassId(){return this.Eu}set _remapPrepassId(t){this.Eu=t}updateVariationVBO(){let t=this.i.cgApiResourceRepository;this.Yc!==v.InvalidCGAPIResourceUid&&t.deleteVertexBuffer(this.Yc);let r=4294967295,i=this.Zc.length,e=new Uint32Array(i*4),s=new Int32Array(i),n=!1,a=!1;for(let o=0;o<i;o++){s[o]=this.Zc[o].entityUID,e[4*o+0]=this.Zc[o].getSceneGraph().componentSID;let u=this.Zc[o].tryToGetSkeletal();u!=null?e[4*o+1]=u.componentSID:e[4*o+1]=r;let f=this.Zc[o].tryToGetBlendShape();f!=null?e[4*o+2]=f.componentSID:e[4*o+2]=r,n||(n=u!=null),a||(a=f!=null)}return this.zu=i>0,this.Iu=n,this.Ou=a,this.$c()?(this.Yc=v.InvalidCGAPIResourceUid,this.Qc=e,this.vu=s,this.Pu=void 0,this.Du=void 0,this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,this._ensureInstanceSidBase(),!0):(this.Yc=t.createVertexBufferFromTypedArray(e),this.Qc=e,this.vu=s,this.Pu=e.slice(),this.Du=new Uint32Array(e.length),this.hu=i,this.du=void 0,this.yu=-1,this.xu=!1,!0)}_packVisibleInstancesToVariationVBO(t,r){if(this.$c())return this._packVisibleInstancesToInstanceRemap(t,r);let i=this.Qc,e=this.vu,s=this.Pu,n=this.Du;if(i===void 0||e===void 0||s===void 0||n===void 0||this.Yc===v.InvalidCGAPIResourceUid)return this.Zc.length;if(t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let a=e.length,o=0;for(let l=0;l<a;l++){if(t!==void 0){let p=e[l];if(p<t.length&&t[p]===r)continue}let h=4*l,m=4*o;n[m+0]=i[h+0],n[m+1]=i[h+1],n[m+2]=i[h+2],n[m+3]=i[h+3],o++}let u=4*o,f=!1;for(let l=0;l<u;l++)if(n[l]!==s[l]){f=!0;break}if(f){let l=n.subarray(0,u);this.i.webglResourceRepository.updateVertexBufferWithTypedArray(this.Yc,l),s.set(l)}return this.hu=o,o}_packVisibleInstancesToInstanceRemap(t,r){let i=this.vu;if(i===void 0)return this.Zc.length;if(this.qc<0&&this._ensureInstanceSidBase(),t===this.du&&r===this.yu)return this.hu;this.du=t,this.yu=r;let e=this.i.webglResourceRepository.instanceSidTable,s=this.qc,n=i.length,a=0;for(let o=0;o<n;o++){if(t!==void 0){let u=i[o];if(u<t.length&&t[u]===r)continue}e.setRemap(s+a,o),a++}return this.hu=a,a}deleteVariationVBO(){let t=this.i.webglResourceRepository;return this.Yc!==v.InvalidCGAPIResourceUid?(t.deleteVertexBuffer(this.Yc),this.Yc=v.InvalidCGAPIResourceUid,this.Qc=void 0,this.vu=void 0,this.Pu=void 0,this.Du=void 0,!0):!1}updateVAO(){let t=this.i.webglResourceRepository;if(t==null)return;for(let e=0;e<this.zc.length;e++){let s=this.zc[e],n=s._multiDrawGroup;if((n==null?void 0:n.vertexHandles)!=null){this.Xc[e]=n.vertexHandles.vaoHandle,this.gu.add(e);continue}let a=s.vertexHandles;if(x.undefined(a)){w.default.warn("Need to create 3DAPIVertexData before update VAO");continue}(Number.isNaN(this.Xc[e])||this.Xc[e]===v.InvalidCGAPIResourceUid||a.vaoHandle===v.InvalidCGAPIResourceUid)&&(this.Xc[e]=t.createVertexArray(),a.vaoHandle=this.Xc[e]),t.setVertexDataToPipeline(a,s,this.Yc)}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=this.zc.length;e<this.Xc.length;e++){let s=this.Xc[e];s&&!r.hasVaoHandle(s)&&(i.has(s)||(i.add(s),t.deleteVertexArray(s))),this.Xc[e]=v.InvalidCGAPIResourceUid}}deleteVAO(){let t=this.i.webglResourceRepository;if(t==null){this.Xc.length=0,this.gu.clear();return}let r=t.getMultiDrawRepository(this.i),i=new Set;for(let e=0;e<this.Xc.length;e++){let s=this.Xc[e];s&&!i.has(s)&&!r.hasVaoHandle(s)&&(i.add(s),t.deleteVertexArray(s)),this.Xc[e]=v.InvalidCGAPIResourceUid}this.gu.clear()}_clearMultiDrawVaoUids(){for(let t of this.gu)t<this.Xc.length&&(this.Xc[t]=v.InvalidCGAPIResourceUid);this.gu.clear()}castRay(t,r,i=0){var o;let e,s=Number.MAX_VALUE,n=0,a=0;for(let u of this.zc){let f=u.castRay(t,r,!0,!0,i,this.Zu);x.defined(f.data)&&((o=f.data)==null?void 0:o.t)<s&&(s=f.data.t,e=f.data.position,n=f.data.u,a=f.data.v)}return x.defined(e)?{result:!0,data:{t:s,u:n,v:a,position:e}}:{result:!1}}get primitives(){return this.zc}get meshUID(){return this.Gu}get _variationVBOUid(){return this.Yc}get _variationEntityInfo(){return this.Qc}get _isGpuCullable(){return this.zu?this._needsComputeDeformation?this.i.config.isComputeSkinningEnabled&&this._isComputeDeformable:!0:!1}get _needsComputeDeformation(){if(this.Iu)return!0;if(!this.Ou)return!1;for(let t=0;t<this.zc.length;t++)if(this.zc[t].targets.length>0)return!0;return!1}get _isComputeDeformable(){return this.Hu===this.zc.length&&this.ku===this.Jc&&this.Fu===this.Iu?this.Nu:(this.Hu=this.zc.length,this.ku=this.Jc,this.Fu=this.Iu,this.Nu=this.fl(),this.Nu)}fl(){if(this.zc.length===0)return!1;let t=(r,i)=>r.some(e=>e.split(".")[0]===i);for(let r of this.zc){let i=r.attributeSemantics;if(!t(i,"POSITION")||this.Iu&&(!t(i,"JOINTS_0")||!t(i,"WEIGHTS_0")))return!1;for(let e of r.targets){let s=!1;for(let n of e.keys())n.split(".")[0]==="POSITION"&&(s=!0);if(!s)return!1}}return!0}_onPrimitivePositionUpdated(){this.Jc++,c.Xu++;for(let t of this.Zc)t.getMeshRenderer().markNeedsLoad()}get primitivePositionUpdateCount(){return this.Jc}get AABB(){if(this.Jc!==this.Lu&&(this.Ru.initialize(),this.Lu=this.Jc),this.Ru.isVanilla())for(let t of this.zc)this.Ru.mergeAABB(t.AABB);return this.Ru}bl(){for(let t=0;t<this.zc.length;t++){let r=this.qu[t],i=this.zc[t];i.targets[0].forEach((s,n)=>{let a=r.getAttribute(n),o=a.elementCount;for(let u=0;u<o;u++)a.setElementFromSameCompositionAccessor(u,i.getAttribute(n))})}}_calcTangents(){if(this.pl())for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Tangent.XYZ)!==-1&&this.tangentCalculationMode===2)continue;let i=t.attributeSemantics.indexOf(g.Texcoord0.XY),e=t.attributeSemantics.indexOf(g.Normal.XYZ);if(i!==-1&&e!==-1){let s=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[s],a=t.attributeAccessors[i],o=t.attributeAccessors[e],u=t.indicesAccessor,f=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(f=1);let l=t.getVertexCountAsIndicesBased(),h=n.byteLength*4/3,y=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,h,4).takeBufferView({byteLengthToNeed:h,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n.elementCount}).unwrapForce();for(let d=0;d<l-2;d+=f){let I=n.getVec3(d,{indicesAccessor:u}),A=n.getVec3(d+1,{indicesAccessor:u}),M=n.getVec3(d+2,{indicesAccessor:u}),S=a.getVec2(d,{indicesAccessor:u}),U=a.getVec2(d+1,{indicesAccessor:u}),N=a.getVec2(d+2,{indicesAccessor:u}),T=o.getVec3(d,{indicesAccessor:u});this.dl(d,I,A,M,S,U,N,T,y,u)}t.setVertexAttribute(y,g.Tangent.XYZ)}}}dl(t,r,i,e,s,n,a,o,u,f){let l=this.Tu(r,i,e,s,n,a,o,c.cl),h=this.Tu(i,e,r,n,a,s,o,c.ul),m=this.Tu(e,r,i,a,s,n,o,c.ll);u.setVec4(t,l.x,l.y,l.z,1,{indicesAccessor:f}),u.setVec4(t+1,h.x,h.y,h.z,1,{indicesAccessor:f}),u.setVec4(t+2,m.x,m.y,m.z,1,{indicesAccessor:f})}Tu(t,r,i,e,s,n,a,o){let u=[c.Tt.setComponents(t.x,e.x,e.y),c.bt.setComponents(t.y,e.x,e.y),c.ve.setComponents(t.z,e.x,e.y)],f=[c._u.setComponents(r.x,s.x,s.y),c.ju.setComponents(r.y,s.x,s.y),c.Ju.setComponents(r.z,s.x,s.y)],l=[c.Ku.setComponents(i.x,n.x,n.y),c.Qu.setComponents(i.y,n.x,n.y),c.$u.setComponents(i.z,n.x,n.y)],h=[],m=[];for(let p=0;p<3;p++){let y=b.subtractTo(f[p],u[p],c.il),d=b.subtractTo(l[p],f[p],c.sl),I=b.crossTo(y,d,c.al),A=Math.abs(I.x)<Number.EPSILON;if(A)return w.default.assert(A,"Polygons or polygons on UV are degenerate!"),z.fromCopyArray([0,0,0]);h[p]=-I.y/I.x,m[p]=-I.z/I.x}return h[0]*h[0]+h[1]*h[1]+h[2]*h[2]<Number.EPSILON?(b.crossTo(a,r,o),o.normalize()):o.setComponents(h[0],h[1],h[2]).normalize()}pl(){return!(this.tangentCalculationMode===0||this.tangentCalculationMode===1||this.tangentCalculationMode===3)}_calcBaryCentricCoord(){for(let t of this.zc){let r=t.getAttribute(g.BaryCentricCoord.XYZ);if(r!=null){let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount;for(let a=0;a<n;a++){let o=r.getVec4(a,{});r.setVec4(a,a%3===0?1:0,a%3===1?1:0,a%3===2?1:0,o.w,{})}}else{let i=t.attributeSemantics.indexOf(g.Position.XYZ),n=t.attributeAccessors[i].elementCount,a=n*4*4,f=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,a,4).takeBufferView({byteLengthToNeed:a,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec4,componentType:R.Float,count:n}).unwrapForce();for(let l=0;l<n;l++)f.setVec4(l,l%3===0?1:0,l%3===1?1:0,l%3===2?1:0,l,{});t.setVertexAttribute(f,g.BaryCentricCoord.XYZ)}}}_calcFaceNormalsIfNonNormal(){for(let t of this.zc){if(t.attributeSemantics.indexOf(g.Normal.XYZ)!==-1)return;this.Zu=!0;let i=t.attributeSemantics.indexOf(g.Position.XYZ),e=t.attributeAccessors[i],s=t.indicesAccessor,n=3;(t.primitiveMode===V.TriangleStrip||t.primitiveMode===V.TriangleFan)&&(n=1);let a=t.getVertexCountAsIndicesBased(),o=e.byteLength,l=this.i.memoryManager.createBufferOnDemand(C.CPUGeneric,o,4).takeBufferView({byteLengthToNeed:o,byteStride:0}).unwrapForce().takeAccessor({compositionType:P.Vec3,componentType:R.Float,count:e.elementCount}).unwrapForce();for(let h=0;h<a-2;h+=n){let m=e.getVec3(h,{indicesAccessor:s}),p=e.getVec3(h+1,{indicesAccessor:s}),y=e.getVec3(h+2,{indicesAccessor:s});this.ml(h,m,p,y,l,s)}t.setVertexAttribute(l,g.Normal.XYZ)}}ml(t,r,i,e,s,n){let a=i.x-r.x,o=i.y-r.y,u=i.z-r.z,f=e.x-r.x,l=e.y-r.y,h=e.z-r.z,m=o*h-u*l,p=u*f-a*h,y=a*l-o*f,d=Math.hypot(m,p,y);d<=1e-6&&(d=1e-4),d=1/d,m*=d,p*=d,y*=d,s.setVec3(t,m,p,y,{indicesAccessor:n}),s.setVec3(t+1,m,p,y,{indicesAccessor:n}),s.setVec3(t+2,m,p,y,{indicesAccessor:n})}getPrimitiveIndexInMesh(t){return this.primitives.indexOf(t)}applyMaterialVariant(t){for(let r of this.primitives)r.applyMaterialVariant(t)}getCurrentVariantName(){function t(i){return i.every(e=>e===i[0])}let r=this.primitives.map(i=>i.getCurrentVariantName());return r.length===0?"":t(r)?r[0]:""}getVariantNames(){let t=[];for(let r of this.primitives)Array.prototype.push.apply(t,r.getVariantNames());return t}isSetUpDone(){if(this.xu)return!1;let t=!0;for(let r of this.primitives)if(r.vertexHandles==null){t=!1;break}return t?this.Wu!==this.Jc?(this.Wu=this.Jc,!1):!0:!1}_invalidateMultiDrawStructure(){this.$c()&&this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this)}_updateVBOAndVAO(){if(this.$c()){this.i.webglResourceRepository.getMultiDrawRepository(this.i).markDirtyForMesh(this);return}let t=this.getPrimitiveNumber();for(let r=0;r<t;r++){let i=this.getPrimitiveAt(r);x.exist(i.vertexHandles)?i.update3DAPIVertexData():i.create3DAPIVertexData()}this.updateVariationVBO(),this.i.engineState.currentProcessApproach!==D.WebGPU&&this.updateVAO()}delete3DAPIVertexData(){for(let t of this.zc)t.delete3DAPIVertexData();this.qc>=0&&this.Zc.length===0&&(this.i.webglResourceRepository.instanceSidTable.free(this.qc,this.Vu),this.qc=-1,this.Vu=0)}};c.invalidateMeshUID=-1,c.Yu=c.invalidateMeshUID,c.Tt=b.zero(),c.bt=b.zero(),c.ve=b.zero(),c._u=b.zero(),c.ju=b.zero(),c.Ju=b.zero(),c.Ku=b.zero(),c.Qu=b.zero(),c.$u=b.zero(),c.il=b.zero(),c.sl=b.zero(),c.al=b.zero(),c.cl=b.zero(),c.ul=b.zero(),c.ll=b.zero(),c.Xu=0;var B=c;export{B as Mesh};
@@ -1 +1 @@
1
- import{RnObject as H}from"../core/RnObject.js";import{BufferUse as k}from"../definitions/BufferUse.js";import{ComponentType as I}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{PrimitiveMode as V}from"../definitions/PrimitiveMode.js";import{VertexAttribute as w}from"../definitions/VertexAttribute.js";import{createClassicUberMaterial as z}from"../helpers/materials/createClassicUberMaterial.js";import{AABB as F}from"../math/AABB.js";import{MutableVector3 as x}from"../math/MutableVector3.js";import{Vector3 as T}from"../math/Vector3.js";import{DataUtil as N}from"../misc/DataUtil.js";import{Is as B}from"../misc/Is.js";import{None as R,Some as O}from"../misc/Option.js";import{RnException as L}from"../misc/RnException.js";import{PrimitiveSortKey_BitLength_Material as G,PrimitiveSortKey_BitLength_PrimitiveType as W,PrimitiveSortKey_BitLength_RenderQueue as K,PrimitiveSortKey_BitLength_TranslucencyType as J,PrimitiveSortKey_BitOffset_Material as X,PrimitiveSortKey_BitOffset_PrimitiveType as Y,PrimitiveSortKey_BitOffset_RenderQueue as Z,PrimitiveSortKey_BitOffset_TranslucencyType as Q}from"./types/GeometryTypes.js";var s=class s extends H{constructor(e){super();this.Rp=V.Unknown;this.Op=new Map;this.gl="";this.Mp=new Map;this.wp=new R;this.Lp=-1;this.Hp=new F;this.Jp=[];this.Wp=-1;this._sortkey=0;this._viewDepth=0;this.jp=0;this.$p=0;this.Nn="";this.i=e,s.Kp==null&&(s.Kp=z(this.i,{isSkinning:!0,isLighting:!0})),this.kp=s.Kp,this._prevMaterial=new WeakRef(s.Kp)}calcFingerPrint(){let e="";e+=this.Rp.index,this.wp.has()&&(e+=this.getRenderIndexBitSize()),e+=this.targets.length,e+=s.getPrimitiveIdxHasMorph(this.Lp);for(let[t,i]of this.Mp)e+=t,e+=i.componentType.webgpu+i.compositionType.webgpu,e+=i.actualByteStride;this.Nn=e}_getFingerPrint(){return this.Nn}getRenderIndexBitSize(){return this.wp.has()?this.Bp!=null?"uint32":this.getIndexBitSize():"uint16"}get _engine(){return this.i}get _multiDrawGroup(){return this.Bp}get _multiDrawEntry(){if(!(this.Bp==null||this.Wp<0))return this.Bp.entries[this.Wp]}_setMultiDrawGroup(e,t){this.Bp=e,this.Wp=t,this.Vp=e.vertexHandles,this.calcFingerPrint()}_clearMultiDrawGroup(){this.Bp=void 0,this.Wp=-1,this.Vp=void 0,this.calcFingerPrint()}static getPrimitiveIdxHasMorph(e){return this.Qp.get(e)}static getPrimitiveHasMorph(e){return this.qp.get(e)}getIndexBitSize(){let e=this.wp.unwrapOrUndefined();if(e==null)throw new Error("indexAccessor is null");if(e.componentType===I.UnsignedShort)return"uint16";if(e.componentType===I.UnsignedInt)return"uint32";if(e.componentType===I.UnsignedByte)return"uint16";throw new Error("unknown indexAccessor.componentType")}get _vertexHandles(){return this.Vp}static get variantUpdateCount(){return this.Yp}setMaterialVariant(e,t){this.Op.set(e,t),s.Yp++}applyMaterialVariant(e){let t=this.Op.get(e);t&&(this.material=t,this.gl=e,s.Yp++)}getCurrentVariantName(){for(let[e,t]of this.Op)if(t===this.kp)return e;return""}getVariantNames(){return Array.from(this.Op.keys())}getVariantMaterial(e){return this.Op.get(e)}set material(e){this.kp=e,this.setSortKey(X,G,e.materialUID);let t=0;e.isTranslucentOpaque()?t=1:e.isBlend()&&(e.zWriteWhenBlend?t=2:t=3),this.setSortKey(Q,J,t),e._addBelongPrimitive(this),this.zp()}get material(){return this.kp}setSortKey(e,t,i){let a=i<<e;this._sortkey|=a;let y=(1<<t)-1;this._sortkey&=~(y<<e),this._sortkey|=(i&y)<<e}setRenderQueue(e){let t=(1<<K)-1,i=Math.max(0,Math.min(t,e|0));this.setSortKey(Z,K,i)}_belongToMesh(e){this.eo=e}get mesh(){return this.eo}_backupMaterial(){this._prevMaterial=new WeakRef(this.kp)}_restoreMaterial(){let e=this._prevMaterial.deref();e!=null&&(this.kp=e)}static getPrimitive(e){var t;return(t=this.Zc[e])==null?void 0:t.deref()}static forEachPrimitive(e){var t;for(let i=0;i<this.Zc.length;i++){let a=(t=this.Zc[i])==null?void 0:t.deref();a!=null&&e(a)}}static getPrimitiveCount(){return this.Zp}onAccessorUpdated(e){this.$p=e,this.eo!=null&&this.eo._onPrimitivePositionUpdated()}setData(e,t,i,a){a!=null?this.wp=new O(a):this.wp=new R,this.Mp=e;let y=this.Mp.get(w.Position.XYZ);y._primitive=new WeakRef(this),i!=null?this.material=i:this.material=z(this.i,{isSkinning:!0,isLighting:!0}),this.Rp=t,this.setSortKey(Y,W,t.index),this.Lp=s.Zp++,s.Zc[this.Lp]=new WeakRef(this),this.calcFingerPrint(),this.zp()}copyVertexData({attributes:e,attributeSemantics:t,primitiveMode:i,indices:a,material:y}){let g=0,n=4;e.forEach(r=>{g+=r.byteLength});let p=g;a!=null&&(p+=N.addPaddingBytes(a.byteLength,n));let u=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,p,n),m,f;if(a!=null){m=I.fromTypedArray(a);let r=u.takeBufferView({byteLengthToNeed:a.byteLength,byteStride:0});if(r.isErr())throw new L(r.getRnError());let c=r.get().takeAccessor({compositionType:M.Scalar,componentType:m,count:a.byteLength/m.getSizeInBytes()});if(c.isErr())throw new L(c.getRnError());f=c.get();for(let l=0;l<a.byteLength/f.componentSizeInBytes;l++)f.setScalar(l,a[l],{})}let o=u.takeBufferView({byteLengthToNeed:g,byteStride:0}).unwrapForce(),b=[],S=[];e.forEach((r,c)=>{let l=M.vectorFrom(w.toVectorComponentN(t[c]));S[c]=I.fromTypedArray(e[c]);let A=o.takeAccessor({compositionType:l,componentType:I.fromTypedArray(e[c]),count:r.byteLength/l.getNumberOfComponents()/S[c].getSizeInBytes()}).unwrapForce();A.copyFromTypedArray(r),b.push(A)});let v=new Map;for(let r=0;r<t.length;r++){let c=t[r];v.set(c,b[r])}this.setData(v,i,y,f)}static createPrimitive(e,t){let i=new s(e);return i.copyVertexData(t),i}get indicesAccessor(){return this.wp.unwrapOrUndefined()}getVertexCountAsIndicesBased(){return this.indicesAccessor?this.indicesAccessor.elementCount:this.getVertexCountAsVerticesBased()}getVertexCountAsVerticesBased(){for(let e of this.Mp.values())return e.elementCount;return 0}getTriangleCountAsIndicesBased(){if(this.indicesAccessor)switch(this.Rp){case V.Triangles:return this.indicesAccessor.elementCount/3;case V.TriangleStrip:return this.indicesAccessor.elementCount-2;case V.TriangleFan:return this.indicesAccessor.elementCount-2;default:return 0}return this.getTriangleCountAsVerticesBased()}getTriangleCountAsVerticesBased(){for(let e of this.Mp.values())switch(this.Rp){case V.Triangles:return e.elementCount/3;case V.TriangleStrip:return e.elementCount-2;case V.TriangleFan:return e.elementCount-2;default:return 0}return 0}hasIndices(){return this.wp.has()}get attributeAccessors(){let e=[];return this.Mp.forEach(t=>{e.push(t)}),e}getAttribute(e){return this.Mp.get(e)}get attributeSemantics(){let e=[];return this.Mp.forEach((t,i)=>{e.push(i)}),e}get attributeEntries(){return this.Mp.entries()}get attributeCompositionTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.compositionType)}),e}get attributeComponentTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.componentType)}),e}get primitiveMode(){return this.Rp}get primitiveUid(){return this.Lp}get positionAccessorVersion(){return this.$p}get AABB(){if(this.Hp.isVanilla()||this.positionAccessorVersion!==this.jp){let e=this.Mp.get(w.Position.XYZ),t=e.min;this.Hp.minPoint=s.Tt.setComponents(t[0],t[1],t[2]);let i=e.max;this.Hp.maxPoint=s.Tt.setComponents(i[0],i[1],i[2]),this.jp=e.version}return this.Hp}zp(){let e=this.eo;e!=null&&e._invalidateMultiDrawStructure()}setVertexAttribute(e,t){this.Mp.set(t,e),this.calcFingerPrint(),this.zp()}removeIndices(){this.wp=new R,this.calcFingerPrint(),this.zp()}setIndices(e){this.wp=new O(e),this.calcFingerPrint(),this.zp()}setBlendShapeTargets(e){s.qp.set(s.Xp,this),s.Qp.set(this.Lp,s.Xp++),this.Jp=e,this.calcFingerPrint(),this.zp()}static getMorphUniformDataTargetNumbers(){let e=[];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(i.targets.length)}return e.length===0?[0]:e}static getMorphUniformDataOffsets(){let e=[0];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(e[e.length-1]+i.targets.length)}return e}static getPrimitiveCountHasMorph(){return this.Xp}getBlendShapeTargets(){return this.Jp.concat()}get targets(){return this.Jp}isBlend(){return!(this.material==null||!this.material.isBlend())}isOpaque(){return!this.isBlend()}create3DAPIVertexData(){if(this.Bp!=null||this.Vp!=null)return!1;let e=this.i.cgApiResourceRepository;return this.Vp=e.createVertexBufferAndIndexBuffer(this),!0}update3DAPIVertexData(){if(this.Bp!=null)return!0;let e=this.Vp;return B.not.exist(this.Vp)?!1:(this.i.cgApiResourceRepository.updateVertexBufferAndIndexBuffer(this,e),!0)}delete3DAPIVertexData(){return this.Bp!=null||this.Vp==null?!1:(this.i.cgApiResourceRepository.deleteVertexDataResources(this.Vp),this.Vp=void 0,!0)}get vertexHandles(){return this.Vp}convertToUnindexedGeometry(){let e=this.indicesAccessor;if(e==null)return;let t=e.getTypedArray(),i=0;for(let g=0;g<this.attributeAccessors.length;g++){let p=this.attributeAccessors[g].compositionType,u=0;p.index===M.Vec4.index?u=4:p.index===M.Vec3.index?u=3:p.index===M.Vec2.index?u=2:p.index===M.Scalar.index&&(u=1),i+=t.length*u*4}let y=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,i,4).takeBufferView({byteLengthToNeed:i,byteStride:0}).unwrapForce();for(let[g,n]of this.Mp){let p=n.compositionType,u=y.takeAccessor({compositionType:p,componentType:n.componentType,count:t.length}).unwrapForce();for(let m=0;m<t.length;m++){let f=t[m];if(p.index===M.Vec4.index){let o=n.getVec4(f,{});u.setVec4(m,o.x,o.y,o.z,o.w,{})}else if(p.index===M.Vec3.index){let o=n.getVec3(f,{});u.setVec3(m,o.x,o.y,o.z,{})}else if(p.index===M.Vec2.index){let o=n.getVec2(f,{});u.setVec2(m,o.x,o.y,{})}else if(p.index===M.Scalar.index){let o=n.getScalar(f,{});u.setScalar(m,o,{})}}this.setVertexAttribute(u,g)}this.removeIndices()}castRay(e,t,i,a,y,g){let n=Number.MAX_VALUE,p=3;if(this.Rp===V.TriangleStrip)p=1;else if(this.Rp===V.Points)return{result:!1};let u=0,m=0,f=0,o=0,b=0;if(this.hasIndices()){let v=this.wp.unwrapForce();for(let r=0;r<v.elementCount-2;r++){let c=r*p;if(c+2>v.elementCount-1)break;let l=v.getScalar(c,{}),A=v.getScalar(c+1,{}),h=v.getScalar(c+2,{}),d=this.yl(e,t,r,l,A,h,i,a,y,g);B.false(d)||B.not.exist(d.data)||d.data.t<n&&(n=d.data.t,o=d.data.u,b=d.data.v,u=l,m=A,f=h)}}else{let v=0;for(let r of this.Mp.values()){v=r.elementCount;break}for(let r=0;r+2<v;r+=p){let c=r,l=r+1,A=r+2,h=this.yl(e,t,r,c,l,A,i,a,y,g);if(h.result&&B.defined(h.data)){let d=h.data.t;d<n&&(n=d,o=h.data.u,b=h.data.v,u=c,m=l,f=A)}}}if(n===Number.MAX_VALUE)return{result:!1};let S=T.fromCopy3(t.x*n+e.x,t.y*n+e.y,t.z*n+e.z);return{result:!0,data:{t:n,u:o,v:b,position:S}}}yl(e,t,i,a,y,g,n,p,u,m){if(m){let E=this.Mp.get(w.Normal.XYZ);if(E){let U=E.getVec3(i,{});if(U.dot(t)<u&&!n)return{result:!1};if(U.dot(t)>-u&&!p)return{result:!1}}}let f=this.Mp.get(w.Position.XYZ),o=f.getVec3(a,{}),b=f.getVec3(y,{}),S=f.getVec3(g,{}),v=x.zero(),r=x.zero(),c=x.zero(),l=x.zero(),A=x.zero(),h=0,d=0;x.subtractTo(b,o,v),x.subtractTo(S,o,r),x.crossTo(t,r,c);let P=T.dot(v,c);if(P>1e-4){if(x.subtractTo(e,o,l),h=T.dot(l,c),h<0||h>P)return{result:!1};if(x.crossTo(l,v,A),d=T.dot(t,A),d<0||h+d>P)return{result:!1}}else if(P<-1e-4){if(x.subtractTo(e,o,l),h=T.dot(l,c),h>0||h<P)return{result:!1};if(x.crossTo(l,v,A),d=T.dot(t,A),d>0||h+d<P)return{result:!1}}else return{result:!1};let C=1/P,D=T.dot(r,A);return D*=C,h*=C,d*=C,{result:!0,data:{t:D,u:h,v:d}}}vl(e,t,i,a,y){let g=1-a-y,n=this.Mp.get(w.Position.XYZ),p=n.getVec3(e,{}),u=n.getVec3(t,{}),m=n.getVec3(i,{}),f=T.multiply(p,g),o=T.multiply(u,a),b=T.multiply(m,y);return x.zero().add(f).add(o).add(b)}};s.Zp=0,s.Zc=[],s.Qp=new Map,s.qp=new Map,s.Xp=0,s.Tt=x.zero(),s.Yp=0;var _=s;export{_ as Primitive};
1
+ import{RnObject as H}from"../core/RnObject.js";import{BufferUse as k}from"../definitions/BufferUse.js";import{ComponentType as I}from"../definitions/ComponentType.js";import{CompositionType as M}from"../definitions/CompositionType.js";import{PrimitiveMode as T}from"../definitions/PrimitiveMode.js";import{VertexAttribute as w}from"../definitions/VertexAttribute.js";import{createClassicUberMaterial as z}from"../helpers/materials/createClassicUberMaterial.js";import{AABB as F}from"../math/AABB.js";import{MutableVector3 as x}from"../math/MutableVector3.js";import{Vector3 as V}from"../math/Vector3.js";import{DataUtil as N}from"../misc/DataUtil.js";import{Is as B}from"../misc/Is.js";import{None as D,Some as O}from"../misc/Option.js";import{RnException as L}from"../misc/RnException.js";import{PrimitiveSortKey_BitLength_Material as G,PrimitiveSortKey_BitLength_PrimitiveType as W,PrimitiveSortKey_BitLength_RenderQueue as K,PrimitiveSortKey_BitLength_TranslucencyType as J,PrimitiveSortKey_BitOffset_Material as X,PrimitiveSortKey_BitOffset_PrimitiveType as Y,PrimitiveSortKey_BitOffset_RenderQueue as Z,PrimitiveSortKey_BitOffset_TranslucencyType as Q}from"./types/GeometryTypes.js";var s=class s extends H{constructor(e){super();this.Rp=T.Unknown;this.Op=new Map;this.yl="";this.Mp=new Map;this.wp=new D;this.Lp=-1;this.Hp=new F;this.Jp=[];this.Wp=-1;this._sortkey=0;this._viewDepth=0;this.jp=0;this.$p=0;this.Nn="";this.i=e,s.Kp==null&&(s.Kp=z(this.i,{isSkinning:!0,isLighting:!0})),this.kp=s.Kp,this._prevMaterial=new WeakRef(s.Kp)}calcFingerPrint(){let e="";e+=this.Rp.index,this.wp.has()&&(e+=this.getRenderIndexBitSize()),e+=this.targets.length,e+=s.getPrimitiveIdxHasMorph(this.Lp);for(let[t,i]of this.Mp)e+=t,e+=i.componentType.webgpu+i.compositionType.webgpu,e+=i.actualByteStride;this.Nn=e}_getFingerPrint(){return this.Nn}getRenderIndexBitSize(){return this.wp.has()?this.Bp!=null?"uint32":this.getIndexBitSize():"uint16"}get _engine(){return this.i}get _multiDrawGroup(){return this.Bp}get _multiDrawEntry(){if(!(this.Bp==null||this.Wp<0))return this.Bp.entries[this.Wp]}_setMultiDrawGroup(e,t){this.Bp=e,this.Wp=t,this.Vp=e.vertexHandles,this.calcFingerPrint()}_clearMultiDrawGroup(){this.Bp=void 0,this.Wp=-1,this.Vp=void 0,this.calcFingerPrint()}static getPrimitiveIdxHasMorph(e){return this.Qp.get(e)}static getPrimitiveHasMorph(e){return this.qp.get(e)}getIndexBitSize(){let e=this.wp.unwrapOrUndefined();if(e==null)throw new Error("indexAccessor is null");if(e.componentType===I.UnsignedShort)return"uint16";if(e.componentType===I.UnsignedInt)return"uint32";if(e.componentType===I.UnsignedByte)return"uint16";throw new Error("unknown indexAccessor.componentType")}get _vertexHandles(){return this.Vp}static get variantUpdateCount(){return this.Yp}setMaterialVariant(e,t){this.Op.set(e,t),s.Yp++}applyMaterialVariant(e){let t=this.Op.get(e);t&&(this.material=t,this.yl=e,s.Yp++)}getCurrentVariantName(){for(let[e,t]of this.Op)if(t===this.kp)return e;return""}getVariantNames(){return Array.from(this.Op.keys())}getVariantMaterial(e){return this.Op.get(e)}set material(e){this.kp=e,this.setSortKey(X,G,e.materialUID);let t=0;e.isTranslucentOpaque()?t=1:e.isBlend()&&(e.zWriteWhenBlend?t=2:t=3),this.setSortKey(Q,J,t),e._addBelongPrimitive(this),this.zp()}get material(){return this.kp}setSortKey(e,t,i){let n=i<<e;this._sortkey|=n;let g=(1<<t)-1;this._sortkey&=~(g<<e),this._sortkey|=(i&g)<<e}setRenderQueue(e){let t=(1<<K)-1,i=Math.max(0,Math.min(t,e|0));this.setSortKey(Z,K,i)}_belongToMesh(e){this.eo=e}get mesh(){return this.eo}_backupMaterial(){this._prevMaterial=new WeakRef(this.kp)}_restoreMaterial(){let e=this._prevMaterial.deref();e!=null&&(this.kp=e)}static getPrimitive(e){var t;return(t=this.zc[e])==null?void 0:t.deref()}static forEachPrimitive(e){var t;for(let i=0;i<this.zc.length;i++){let n=(t=this.zc[i])==null?void 0:t.deref();n!=null&&e(n)}}static getPrimitiveCount(){return this.Zp}onAccessorUpdated(e){this.$p=e,this.eo!=null&&this.eo._onPrimitivePositionUpdated()}setData(e,t,i,n){n!=null?this.wp=new O(n):this.wp=new D,this.Mp=e;let g=this.Mp.get(w.Position.XYZ);g._primitive=new WeakRef(this),i!=null?this.material=i:this.material=z(this.i,{isSkinning:!0,isLighting:!0}),this.Rp=t,this.setSortKey(Y,W,t.index),this.Lp=s.Zp++,s.zc[this.Lp]=new WeakRef(this),this.calcFingerPrint(),this.zp()}copyVertexData({attributes:e,attributeSemantics:t,primitiveMode:i,indices:n,material:g}){let y=0,o=4;e.forEach(r=>{y+=r.byteLength});let p=y;n!=null&&(p+=N.addPaddingBytes(n.byteLength,o));let u=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,p,o),m,f;if(n!=null){m=I.fromTypedArray(n);let r=u.takeBufferView({byteLengthToNeed:n.byteLength,byteStride:0});if(r.isErr())throw new L(r.getRnError());let c=r.get().takeAccessor({compositionType:M.Scalar,componentType:m,count:n.byteLength/m.getSizeInBytes()});if(c.isErr())throw new L(c.getRnError());f=c.get();for(let l=0;l<n.byteLength/f.componentSizeInBytes;l++)f.setScalar(l,n[l],{})}let a=u.takeBufferView({byteLengthToNeed:y,byteStride:0}).unwrapForce(),b=[],P=[];e.forEach((r,c)=>{let l=M.vectorFrom(w.toVectorComponentN(t[c]));P[c]=I.fromTypedArray(e[c]);let v=a.takeAccessor({compositionType:l,componentType:I.fromTypedArray(e[c]),count:r.byteLength/l.getNumberOfComponents()/P[c].getSizeInBytes()}).unwrapForce();v.copyFromTypedArray(r),b.push(v)});let A=new Map;for(let r=0;r<t.length;r++){let c=t[r];A.set(c,b[r])}this.setData(A,i,g,f)}static createPrimitive(e,t){let i=new s(e);return i.copyVertexData(t),i}get indicesAccessor(){return this.wp.unwrapOrUndefined()}getVertexCountAsIndicesBased(){return this.indicesAccessor?this.indicesAccessor.elementCount:this.getVertexCountAsVerticesBased()}getVertexCountAsVerticesBased(){for(let e of this.Mp.values())return e.elementCount;return 0}getTriangleCountAsIndicesBased(){if(this.indicesAccessor)switch(this.Rp){case T.Triangles:return this.indicesAccessor.elementCount/3;case T.TriangleStrip:return this.indicesAccessor.elementCount-2;case T.TriangleFan:return this.indicesAccessor.elementCount-2;default:return 0}return this.getTriangleCountAsVerticesBased()}getTriangleCountAsVerticesBased(){for(let e of this.Mp.values())switch(this.Rp){case T.Triangles:return e.elementCount/3;case T.TriangleStrip:return e.elementCount-2;case T.TriangleFan:return e.elementCount-2;default:return 0}return 0}hasIndices(){return this.wp.has()}get attributeAccessors(){let e=[];return this.Mp.forEach(t=>{e.push(t)}),e}getAttribute(e){return this.Mp.get(e)}get attributeSemantics(){let e=[];return this.Mp.forEach((t,i)=>{e.push(i)}),e}get attributeEntries(){return this.Mp.entries()}get attributeCompositionTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.compositionType)}),e}get attributeComponentTypes(){let e=[];return this.Mp.forEach(t=>{e.push(t.componentType)}),e}get primitiveMode(){return this.Rp}get primitiveUid(){return this.Lp}get positionAccessorVersion(){return this.$p}get AABB(){if(this.Hp.isVanilla()||this.positionAccessorVersion!==this.jp){let e=this.Mp.get(w.Position.XYZ),t=e.min;this.Hp.minPoint=s.Tt.setComponents(t[0],t[1],t[2]);let i=e.max;this.Hp.maxPoint=s.Tt.setComponents(i[0],i[1],i[2]),this.jp=e.version}return this.Hp}zp(){let e=this.eo;e!=null&&e._invalidateMultiDrawStructure()}setVertexAttribute(e,t){this.Mp.set(t,e),this.calcFingerPrint(),this.zp()}removeIndices(){this.wp=new D,this.calcFingerPrint(),this.zp()}setIndices(e){this.wp=new O(e),this.calcFingerPrint(),this.zp()}setBlendShapeTargets(e){s.qp.set(s.Xp,this),s.Qp.set(this.Lp,s.Xp++),this.Jp=e,this.calcFingerPrint(),this.zp()}static getMorphUniformDataTargetNumbers(){let e=[];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(i.targets.length)}return e.length===0?[0]:e}static getMorphUniformDataOffsets(){let e=[0];for(let t=0;t<s.getPrimitiveCountHasMorph();t++){let i=s.getPrimitiveHasMorph(t);e.push(e[e.length-1]+i.targets.length)}return e}static getPrimitiveCountHasMorph(){return this.Xp}getBlendShapeTargets(){return this.Jp.concat()}get targets(){return this.Jp}isBlend(){return!(this.material==null||!this.material.isBlend())}isOpaque(){return!this.isBlend()}create3DAPIVertexData(){if(this.Bp!=null||this.Vp!=null)return!1;let e=this.i.cgApiResourceRepository;return this.Vp=e.createVertexBufferAndIndexBuffer(this),!0}update3DAPIVertexData(){if(this.Bp!=null)return!0;let e=this.Vp;if(B.not.exist(this.Vp))return!1;let t=e.vboHandles.length!==this.attributeAccessors.length,i=B.exist(e.iboHandle)!==this.hasIndices();return t||i?(this.delete3DAPIVertexData(),this.create3DAPIVertexData()):(this.i.cgApiResourceRepository.updateVertexBufferAndIndexBuffer(this,e),!0)}delete3DAPIVertexData(){return this.Bp!=null||this.Vp==null?!1:(this.i.cgApiResourceRepository.deleteVertexDataResources(this.Vp),this.Vp=void 0,!0)}get vertexHandles(){return this.Vp}convertToUnindexedGeometry(){let e=this.indicesAccessor;if(e==null)return;let t=e.getTypedArray(),i=0;for(let y=0;y<this.attributeAccessors.length;y++){let p=this.attributeAccessors[y].compositionType,u=0;p.index===M.Vec4.index?u=4:p.index===M.Vec3.index?u=3:p.index===M.Vec2.index?u=2:p.index===M.Scalar.index&&(u=1),i+=t.length*u*4}let g=this.i.memoryManager.createBufferOnDemand(k.CPUGeneric,i,4).takeBufferView({byteLengthToNeed:i,byteStride:0}).unwrapForce();for(let[y,o]of this.Mp){let p=o.compositionType,u=g.takeAccessor({compositionType:p,componentType:o.componentType,count:t.length}).unwrapForce();for(let m=0;m<t.length;m++){let f=t[m];if(p.index===M.Vec4.index){let a=o.getVec4(f,{});u.setVec4(m,a.x,a.y,a.z,a.w,{})}else if(p.index===M.Vec3.index){let a=o.getVec3(f,{});u.setVec3(m,a.x,a.y,a.z,{})}else if(p.index===M.Vec2.index){let a=o.getVec2(f,{});u.setVec2(m,a.x,a.y,{})}else if(p.index===M.Scalar.index){let a=o.getScalar(f,{});u.setScalar(m,a,{})}}this.setVertexAttribute(u,y)}this.removeIndices()}castRay(e,t,i,n,g,y){let o=Number.MAX_VALUE,p=3;if(this.Rp===T.TriangleStrip)p=1;else if(this.Rp===T.Points)return{result:!1};let u=0,m=0,f=0,a=0,b=0;if(this.hasIndices()){let A=this.wp.unwrapForce();for(let r=0;r<A.elementCount-2;r++){let c=r*p;if(c+2>A.elementCount-1)break;let l=A.getScalar(c,{}),v=A.getScalar(c+1,{}),h=A.getScalar(c+2,{}),d=this.gl(e,t,r,l,v,h,i,n,g,y);B.false(d)||B.not.exist(d.data)||d.data.t<o&&(o=d.data.t,a=d.data.u,b=d.data.v,u=l,m=v,f=h)}}else{let A=0;for(let r of this.Mp.values()){A=r.elementCount;break}for(let r=0;r+2<A;r+=p){let c=r,l=r+1,v=r+2,h=this.gl(e,t,r,c,l,v,i,n,g,y);if(h.result&&B.defined(h.data)){let d=h.data.t;d<o&&(o=d,a=h.data.u,b=h.data.v,u=c,m=l,f=v)}}}if(o===Number.MAX_VALUE)return{result:!1};let P=V.fromCopy3(t.x*o+e.x,t.y*o+e.y,t.z*o+e.z);return{result:!0,data:{t:o,u:a,v:b,position:P}}}gl(e,t,i,n,g,y,o,p,u,m){if(m){let E=this.Mp.get(w.Normal.XYZ);if(E){let U=E.getVec3(i,{});if(U.dot(t)<u&&!o)return{result:!1};if(U.dot(t)>-u&&!p)return{result:!1}}}let f=this.Mp.get(w.Position.XYZ),a=f.getVec3(n,{}),b=f.getVec3(g,{}),P=f.getVec3(y,{}),A=x.zero(),r=x.zero(),c=x.zero(),l=x.zero(),v=x.zero(),h=0,d=0;x.subtractTo(b,a,A),x.subtractTo(P,a,r),x.crossTo(t,r,c);let S=V.dot(A,c);if(S>1e-4){if(x.subtractTo(e,a,l),h=V.dot(l,c),h<0||h>S)return{result:!1};if(x.crossTo(l,A,v),d=V.dot(t,v),d<0||h+d>S)return{result:!1}}else if(S<-1e-4){if(x.subtractTo(e,a,l),h=V.dot(l,c),h>0||h<S)return{result:!1};if(x.crossTo(l,A,v),d=V.dot(t,v),d>0||h+d<S)return{result:!1}}else return{result:!1};let C=1/S,R=V.dot(r,v);return R*=C,h*=C,d*=C,{result:!0,data:{t:R,u:h,v:d}}}Al(e,t,i,n,g){let y=1-n-g,o=this.Mp.get(w.Position.XYZ),p=o.getVec3(e,{}),u=o.getVec3(t,{}),m=o.getVec3(i,{}),f=V.multiply(p,y),a=V.multiply(u,n),b=V.multiply(m,g);return x.zero().add(f).add(a).add(b)}};s.Zp=0,s.zc=[],s.Qp=new Map,s.qp=new Map,s.Xp=0,s.Tt=x.zero(),s.Yp=0;var _=s;export{_ as Primitive};
@@ -1 +1 @@
1
- import{PrimitiveMode as T}from"../../definitions/PrimitiveMode.js";import{VertexAttribute as P}from"../../definitions/VertexAttribute.js";import{IShape as I}from"./IShape.js";var F=class extends I{generate(n={}){var v,w,M,A,C;let e=(v=n.radiusBottom)!=null?v:.5,r=(w=n.radiusTop)!=null?w:.5,o=(M=n.height)!=null?M:1,p=(A=n.radialSegments)!=null?A:16;if(!Number.isFinite(p)||!Number.isInteger(p))throw new Error("Cylinder radialSegments must be a finite integer.");let s=Math.max(3,p),g=(C=n.includeCaps)!=null?C:!0;if(!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(o)||e<0||r<0||e===0&&r===0||o<=0)throw new Error("Cylinder dimensions must be finite, with positive height and at least one positive radius.");let u=[],c=[],l=[],t=[],i=o/2,a=(e-r)/o;for(let h=0;h<=s;h++){let y=h/s,f=h===s?0:y*Math.PI*2,m=Math.cos(f),b=Math.sin(f),d=Math.hypot(m,a,b);u.push(e*m,-i,e*b),c.push(m/d,a/d,b/d),l.push(y,0),u.push(r*m,i,r*b),c.push(m/d,a/d,b/d),l.push(y,1)}for(let h=0;h<s;h++){let y=h*2,f=y+1,m=(h+1)*2,b=m+1;t.push(y,f,m,m,f,b)}g&&(this.nh(-i,e,-1,s,u,c,l,t),this.nh(i,r,1,s,u,c,l,t));let x=u.length/3>65536?new Uint32Array(t):new Uint16Array(t);this.copyVertexData({attributes:[new Float32Array(u),new Float32Array(c),new Float32Array(l)],attributeSemantics:[P.Position.XYZ,P.Normal.XYZ,P.Texcoord0.XY],primitiveMode:T.Triangles,indices:x,material:n.material})}nh(n,e,r,o,p,s,g,u){if(e===0)return;let c=p.length/3;p.push(0,n,0),s.push(0,r,0),g.push(.5,.5);let l=p.length/3;for(let t=0;t<o;t++){let i=t/o*Math.PI*2,a=Math.cos(i),x=Math.sin(i);p.push(e*a,n,e*x),s.push(0,r,0),g.push(a*.5+.5,x*.5+.5)}for(let t=0;t<o;t++){let i=l+t,a=l+(t+1)%o;r>0?u.push(c,a,i):u.push(c,i,a)}}};export{F as Cylinder};
1
+ import{PrimitiveMode as T}from"../../definitions/PrimitiveMode.js";import{VertexAttribute as P}from"../../definitions/VertexAttribute.js";import{IShape as I}from"./IShape.js";var F=class extends I{generate(n={}){var v,w,M,A,C;let e=(v=n.radiusBottom)!=null?v:.5,r=(w=n.radiusTop)!=null?w:.5,o=(M=n.height)!=null?M:1,p=(A=n.radialSegments)!=null?A:16;if(!Number.isFinite(p)||!Number.isInteger(p))throw new Error("Cylinder radialSegments must be a finite integer.");let s=Math.max(3,p),g=(C=n.includeCaps)!=null?C:!0;if(!Number.isFinite(e)||!Number.isFinite(r)||!Number.isFinite(o)||e<0||r<0||e===0&&r===0||o<=0)throw new Error("Cylinder dimensions must be finite, with positive height and at least one positive radius.");let u=[],c=[],l=[],t=[],i=o/2,a=(e-r)/o;for(let h=0;h<=s;h++){let y=h/s,f=h===s?0:y*Math.PI*2,m=Math.cos(f),b=Math.sin(f),d=Math.hypot(m,a,b);u.push(e*m,-i,e*b),c.push(m/d,a/d,b/d),l.push(y,0),u.push(r*m,i,r*b),c.push(m/d,a/d,b/d),l.push(y,1)}for(let h=0;h<s;h++){let y=h*2,f=y+1,m=(h+1)*2,b=m+1;t.push(y,f,m,m,f,b)}g&&(this.uh(-i,e,-1,s,u,c,l,t),this.uh(i,r,1,s,u,c,l,t));let x=u.length/3>65536?new Uint32Array(t):new Uint16Array(t);this.copyVertexData({attributes:[new Float32Array(u),new Float32Array(c),new Float32Array(l)],attributeSemantics:[P.Position.XYZ,P.Normal.XYZ,P.Texcoord0.XY],primitiveMode:T.Triangles,indices:x,material:n.material})}uh(n,e,r,o,p,s,g,u){if(e===0)return;let c=p.length/3;p.push(0,n,0),s.push(0,r,0),g.push(.5,.5);let l=p.length/3;for(let t=0;t<o;t++){let i=t/o*Math.PI*2,a=Math.cos(i),x=Math.sin(i);p.push(e*a,n,e*x),s.push(0,r,0),g.push(a*.5+.5,x*.5+.5)}for(let t=0;t<o;t++){let i=l+t,a=l+(t+1)%o;r>0?u.push(c,a,i):u.push(c,i,a)}}};export{F as Cylinder};
@@ -1 +1 @@
1
- import{PrimitiveMode as z}from"../../definitions/PrimitiveMode.js";import{VertexAttribute as b}from"../../definitions/VertexAttribute.js";import{Vector3 as t}from"../../math/Vector3.js";import{IShape as D}from"./IShape.js";var c=class c extends D{constructor(){super(...arguments);this.tm=t.fromCopyArray3([0,0,1]);this.rm=t.fromCopyArray3([0,0,0]);this.sm=1;this.am=new Float32Array(c.cm*2*c.om)}generate(r){let i=this.em();this.copyVertexData({attributes:[i],attributeSemantics:[b.Position.XYZ],primitiveMode:z.Lines,material:r==null?void 0:r.material}),this.im=this.getAttribute(b.Position.XYZ)}setWorldPositions(r,i,s){this.tm=t.fromCopyVector3(r),this.rm=t.fromCopyVector3(i),s!==void 0&&(this.sm=s),this.mm()}mm(){if(this.im==null)return;let r=this.em(),i=r.length/c.om;for(let s=0;s<i;s++){let a=s*c.om;this.im.setVec3(s,r[a],r[a+1],r[a+2],{})}}em(){let r=t.lengthBtw(this.tm,this.rm),i=this.sm,s=r/7.5,a=r-s,x=t.subtract(this.rm,this.tm),e=t.fromCopyArray3([0,1,0]);x.isEqual(t.zero())||(e=t.normalize(t.subtract(this.rm,this.tm)));let p=t.add(this.tm,t.multiply(e,a)),n=t.fromCopyArray3([0,1,0]),u=t.fromCopyArray3([0,-1,0]);Math.abs(t.dot(e,n))>.4&&(n=t.fromCopyArray3([1,0,0]),u=t.fromCopyArray3([-1,0,0])),Math.abs(t.dot(e,n))>.4&&(n=t.fromCopyArray3([0,0,1]),u=t.fromCopyArray3([0,0,-1]));let A=t.multiply(t.normalize(t.cross(e,n)),i),I=t.multiply(t.normalize(t.cross(e,A)),i),v=t.multiply(t.normalize(t.cross(e,u)),i),g=t.multiply(t.normalize(t.cross(e,v)),i),y=t.add(p,A),h=t.add(p,I),l=t.add(p,v),f=t.add(p,g),d=this.am,V=0,P=m=>{d[V++]=m.x,d[V++]=m.y,d[V++]=m.z},o=(m,w)=>{P(m),P(w)};return o(this.tm,y),o(this.tm,h),o(this.tm,l),o(this.tm,f),o(y,h),o(h,l),o(l,f),o(f,y),o(this.rm,y),o(this.rm,h),o(this.rm,l),o(this.rm,f),d}};c.cm=12,c.om=3;var C=c;export{C as Joint};
1
+ import{PrimitiveMode as z}from"../../definitions/PrimitiveMode.js";import{VertexAttribute as b}from"../../definitions/VertexAttribute.js";import{Vector3 as t}from"../../math/Vector3.js";import{IShape as D}from"./IShape.js";var c=class c extends D{constructor(){super(...arguments);this.om=t.fromCopyArray3([0,0,1]);this.im=t.fromCopyArray3([0,0,0]);this.am=1;this.ym=new Float32Array(c.pm*2*c.sm)}generate(r){let i=this.mm();this.copyVertexData({attributes:[i],attributeSemantics:[b.Position.XYZ],primitiveMode:z.Lines,material:r==null?void 0:r.material}),this.cm=this.getAttribute(b.Position.XYZ)}setWorldPositions(r,i,s){this.om=t.fromCopyVector3(r),this.im=t.fromCopyVector3(i),s!==void 0&&(this.am=s),this.hm()}hm(){if(this.cm==null)return;let r=this.mm(),i=r.length/c.sm;for(let s=0;s<i;s++){let a=s*c.sm;this.cm.setVec3(s,r[a],r[a+1],r[a+2],{})}}mm(){let r=t.lengthBtw(this.om,this.im),i=this.am,s=r/7.5,a=r-s,x=t.subtract(this.im,this.om),e=t.fromCopyArray3([0,1,0]);x.isEqual(t.zero())||(e=t.normalize(t.subtract(this.im,this.om)));let p=t.add(this.om,t.multiply(e,a)),n=t.fromCopyArray3([0,1,0]),u=t.fromCopyArray3([0,-1,0]);Math.abs(t.dot(e,n))>.4&&(n=t.fromCopyArray3([1,0,0]),u=t.fromCopyArray3([-1,0,0])),Math.abs(t.dot(e,n))>.4&&(n=t.fromCopyArray3([0,0,1]),u=t.fromCopyArray3([0,0,-1]));let A=t.multiply(t.normalize(t.cross(e,n)),i),I=t.multiply(t.normalize(t.cross(e,A)),i),v=t.multiply(t.normalize(t.cross(e,u)),i),g=t.multiply(t.normalize(t.cross(e,v)),i),y=t.add(p,A),h=t.add(p,I),l=t.add(p,v),f=t.add(p,g),d=this.ym,V=0,P=m=>{d[V++]=m.x,d[V++]=m.y,d[V++]=m.z},o=(m,w)=>{P(m),P(w)};return o(this.om,y),o(this.om,h),o(this.om,l),o(this.om,f),o(y,h),o(h,l),o(l,f),o(f,y),o(this.im,y),o(this.im,h),o(this.im,l),o(this.im,f),d}};c.pm=12,c.sm=3;var C=c;export{C as Joint};
@@ -1 +1 @@
1
- import{createMeshEntity as o}from"../components/MeshRenderer/createMeshEntity.js";import{PrimitiveMode as a}from"../definitions/PrimitiveMode.js";import{VertexAttribute as m}from"../definitions/VertexAttribute.js";import{Mesh as h}from"../geometry/Mesh.js";import{Primitive as c}from"../geometry/Primitive.js";import{Vector3 as p}from"../math/Vector3.js";import{Gizmo as d}from"./Gizmo.js";var s=class i extends d{get isSetup(){return this.hm!=null}_setup(){if(this.dm())return;this.hm=o(this.i),this.hm.tryToSetUniqueName(`AABBGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.pm.getSceneGraph()._addGizmoChild(this.hm.getSceneGraph());let r=this.hm.tryToGetMesh();i.eo=new h(this.i),i.eo.addPrimitive(i.generatePrimitive(this.i)),r.setMesh(i.eo),this.setGizmoTag(),this._update()}static generatePrimitive(r){let e=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,3,3,7,7,4,4,0,1,2,2,6,6,5,5,1,0,1,1,5,5,4,4,0,3,2,2,6,6,7,7,3]),t=1,n=new Float32Array([-t,-t,-t,t,-t,-t,t,t,-t,-t,t,-t,-t,-t,t,t,-t,t,t,t,t,-t,t,t]);return c.createPrimitive(r,{indices:e,attributeSemantics:[m.Position.XYZ],attributes:[n],primitiveMode:a.Lines})}_update(){if(this.hm==null)return;let e=this.pm.getSceneGraph().worldMergedAABBWithSkeletal;this.hm.getTransform().localPosition=e.centerPoint;let t=1e-4;this.hm.getTransform().localScale=p.fromCopyArray([Math.max(e.sizeX/2,t),Math.max(e.sizeY/2,t),Math.max(e.sizeZ/2,t)])}_destroy(){this.um()}static _cleanupForEngine(r){i.eo=void 0}};export{s as AABBGizmo};
1
+ import{createMeshEntity as o}from"../components/MeshRenderer/createMeshEntity.js";import{PrimitiveMode as a}from"../definitions/PrimitiveMode.js";import{VertexAttribute as m}from"../definitions/VertexAttribute.js";import{Mesh as h}from"../geometry/Mesh.js";import{Primitive as c}from"../geometry/Primitive.js";import{Vector3 as p}from"../math/Vector3.js";import{Gizmo as d}from"./Gizmo.js";var s=class i extends d{get isSetup(){return this.dm!=null}_setup(){if(this.lm())return;this.dm=o(this.i),this.dm.tryToSetUniqueName(`AABBGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.um.getSceneGraph()._addGizmoChild(this.dm.getSceneGraph());let r=this.dm.tryToGetMesh();i.eo=new h(this.i),i.eo.addPrimitive(i.generatePrimitive(this.i)),r.setMesh(i.eo),this.setGizmoTag(),this._update()}static generatePrimitive(r){let e=new Uint32Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,3,3,7,7,4,4,0,1,2,2,6,6,5,5,1,0,1,1,5,5,4,4,0,3,2,2,6,6,7,7,3]),t=1,n=new Float32Array([-t,-t,-t,t,-t,-t,t,t,-t,-t,t,-t,-t,-t,t,t,-t,t,t,t,t,-t,t,t]);return c.createPrimitive(r,{indices:e,attributeSemantics:[m.Position.XYZ],attributes:[n],primitiveMode:a.Lines})}_update(){if(this.dm==null)return;let e=this.um.getSceneGraph().worldMergedAABBWithSkeletal;this.dm.getTransform().localPosition=e.centerPoint;let t=1e-4;this.dm.getTransform().localScale=p.fromCopyArray([Math.max(e.sizeX/2,t),Math.max(e.sizeY/2,t),Math.max(e.sizeZ/2,t)])}_destroy(){this.gm()}static _cleanupForEngine(r){i.eo=void 0}};export{s as AABBGizmo};
@@ -1 +1 @@
1
- import{createGroupEntity as E}from"../components/SceneGraph/createGroupEntity.js";import{MeshHelper as G}from"../helpers/MeshHelperObject.js";import{createPbrUberMaterial as b}from"../helpers/materials/createPbrUberMaterial.js";import{MutableQuaternion as z}from"../math/MutableQuaternion.js";import{MutableVector3 as C}from"../math/MutableVector3.js";import{Vector3 as e}from"../math/Vector3.js";import{Vector4 as v}from"../math/Vector4.js";import{Is as m}from"../misc/Is.js";import{Gizmo as T}from"./Gizmo.js";var i=class i extends T{constructor(o,r){super(o,r.baseSceneGraph.entity),this.ah=r}get isSetup(){return m.exist(this.hm)}_setup(){if(this.dm())return;let o=this.pm.getSceneGraph();if(!o)return;this.hm=E(this.i),this.hm.tryToSetUniqueName(`CapsuleColliderGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,o._addGizmoChild(this.hm.getSceneGraph());let r=this.ah.position,c=this.ah.tail,s=e.subtract(c,r).length(),t=b(this.i,{isLighting:!1,isSkinning:!1,isMorphing:!1,maxInstancesNumber:1});t.addShaderDefine("RN_USE_WIREFRAME"),t.setParameter("wireframe",e.fromCopy3(1,0,1)),t.setParameter("baseColorFactor",v.fromCopy4(0,1,0,1));let n=G.createCapsule(this.i,{radius:this.ah.radius,height:s,widthSegments:16,heightSegments:8,material:t});n.getMesh().calcBaryCentricCoord(),n.tryToSetTag({tag:"Gizmo",value:"CapsuleCollider"}),this.hm.getSceneGraph().addChild(n.getSceneGraph()),this.ch=n,this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"CapsuleCollider"}),this._update()}_update(){if(!m.exist(this.hm)||!m.exist(this.ch))return;let o=this.ah.baseSceneGraph.matrixInner,r=this.ah.position,c=this.ah.tail,s=i.Tt,t=i.bt;o.multiplyVector3To(r,s),o.multiplyVector3To(c,t);let n=(s.x+t.x)/2,d=(s.y+t.y)/2,M=(s.z+t.z)/2;this.ch.localPosition=e.fromCopy3(n,d,M);let u=e.subtract(t,s);if(u.length()>1e-4){let g=e.normalize(u),f=e.fromCopy3(0,1,0),a=i.Cn,h=f.dot(g);if(h>.9999)a.setComponents(0,0,0,1);else if(h<-.9999)a.setComponents(1,0,0,0);else{let x=e.cross(f,g),l=e.normalize(x),y=Math.acos(h)/2,p=Math.sin(y);a.setComponents(l.x*p,l.y*p,l.z*p,Math.cos(y))}this.ch.localRotation=a}}_destroy(){this.um(),this.ch=void 0}get capsuleCollider(){return this.ah}};i.Tt=C.zero(),i.bt=C.zero(),i.Cn=z.identity();var S=i;export{S as CapsuleColliderGizmo};
1
+ import{createGroupEntity as E}from"../components/SceneGraph/createGroupEntity.js";import{MeshHelper as G}from"../helpers/MeshHelperObject.js";import{createPbrUberMaterial as b}from"../helpers/materials/createPbrUberMaterial.js";import{MutableQuaternion as z}from"../math/MutableQuaternion.js";import{MutableVector3 as C}from"../math/MutableVector3.js";import{Vector3 as e}from"../math/Vector3.js";import{Vector4 as v}from"../math/Vector4.js";import{Is as m}from"../misc/Is.js";import{Gizmo as T}from"./Gizmo.js";var i=class i extends T{constructor(o,r){super(o,r.baseSceneGraph.entity),this.ah=r}get isSetup(){return m.exist(this.dm)}_setup(){if(this.lm())return;let o=this.um.getSceneGraph();if(!o)return;this.dm=E(this.i),this.dm.tryToSetUniqueName(`CapsuleColliderGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,o._addGizmoChild(this.dm.getSceneGraph());let r=this.ah.position,c=this.ah.tail,s=e.subtract(c,r).length(),t=b(this.i,{isLighting:!1,isSkinning:!1,isMorphing:!1,maxInstancesNumber:1});t.addShaderDefine("RN_USE_WIREFRAME"),t.setParameter("wireframe",e.fromCopy3(1,0,1)),t.setParameter("baseColorFactor",v.fromCopy4(0,1,0,1));let n=G.createCapsule(this.i,{radius:this.ah.radius,height:s,widthSegments:16,heightSegments:8,material:t});n.getMesh().calcBaryCentricCoord(),n.tryToSetTag({tag:"Gizmo",value:"CapsuleCollider"}),this.dm.getSceneGraph().addChild(n.getSceneGraph()),this.ch=n,this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"CapsuleCollider"}),this._update()}_update(){if(!m.exist(this.dm)||!m.exist(this.ch))return;let o=this.ah.baseSceneGraph.matrixInner,r=this.ah.position,c=this.ah.tail,s=i.Tt,t=i.bt;o.multiplyVector3To(r,s),o.multiplyVector3To(c,t);let n=(s.x+t.x)/2,d=(s.y+t.y)/2,M=(s.z+t.z)/2;this.ch.localPosition=e.fromCopy3(n,d,M);let u=e.subtract(t,s);if(u.length()>1e-4){let g=e.normalize(u),f=e.fromCopy3(0,1,0),a=i.Cn,h=f.dot(g);if(h>.9999)a.setComponents(0,0,0,1);else if(h<-.9999)a.setComponents(1,0,0,0);else{let x=e.cross(f,g),l=e.normalize(x),y=Math.acos(h)/2,p=Math.sin(y);a.setComponents(l.x*p,l.y*p,l.z*p,Math.cos(y))}this.ch.localRotation=a}}_destroy(){this.gm(),this.ch=void 0}get capsuleCollider(){return this.ah}};i.Tt=C.zero(),i.bt=C.zero(),i.Cn=z.identity();var S=i;export{S as CapsuleColliderGizmo};
@@ -1 +1 @@
1
- import{CameraComponent as m}from"../components/Camera/CameraComponent.js";import{flattenHierarchy as y}from"../components/SceneGraph/SceneGraphOps.js";import{RnObject as f}from"../core/RnObject.js";import{CameraType as g}from"../definitions/CameraType.js";import{MutableVector3 as d}from"../math/MutableVector3.js";var o=class o extends f{constructor(t,r){super();this.mh=!1;this.i=t,this.pm=r,this.setGizmoTag()}set isVisible(t){this.uh(t)}get isVisible(){return this.mh}uh(t){this.mh=t,this.hm&&this.hm.getSceneGraph().setVisibilityRecursively(t)}um(){let t=this.hm;this.hm=void 0,t!=null&&this.i.entityRepository.getEntity(t.entityUID)!=null&&this.i.entityRepository.deleteEntityRecursively(t.entityUID)}dm(){return!!(this.isSetup||this.pm.matchTag("Being","gizmo"))}setGizmoTag(){if(this.hm){this.hm.tryToSetTag({tag:"Being",value:"gizmo"});let t=y(this.hm.getSceneGraph(),!1);for(let r of t)r.entity.tryToSetTag({tag:"Being",value:"gizmo"});this.hm.tryToSetTag({tag:"type",value:"background-assets"})}}lh(){var i;let t=(i=this.hm)==null?void 0:i.getSceneGraph();if(t==null)return;t.setWorldMatrixDirtyWithoutAABBDirty();let r=[t];for(;r.length>0;){let e=r.pop();e.matrixInner,e.entity.tryToGetMesh()!=null&&e.normalMatrixInner;for(let n of e.children)r.push(n)}}static yh(t,r,i){if(!Number.isFinite(i)||i<=0)return 1;let e=t.componentRepository.getComponent(m,m.getCurrent(t));if(e==null)return 1;let n=e.projectionMatrix.m11;if(!Number.isFinite(n)||n<=0)return 1;if(e.type===g.Orthographic){let p=i*2/n;return Number.isFinite(p)&&p>0?p:1}e.viewMatrix.multiplyVector3To(r,o.ph);let c=-o.ph.z,s=e.zNearInner,h=Number.isFinite(s)&&s>0?s:1e-4,l=Number.isFinite(c)?Math.max(c,h):h,a=i*2*l/n;return Number.isFinite(a)&&a>0?a:1}};o.ph=d.zero();var u=o;export{u as Gizmo};
1
+ import{CameraComponent as m}from"../components/Camera/CameraComponent.js";import{flattenHierarchy as y}from"../components/SceneGraph/SceneGraphOps.js";import{RnObject as f}from"../core/RnObject.js";import{CameraType as g}from"../definitions/CameraType.js";import{MutableVector3 as d}from"../math/MutableVector3.js";var o=class o extends f{constructor(t,r){super();this.lh=!1;this.i=t,this.um=r,this.setGizmoTag()}set isVisible(t){this.yh(t)}get isVisible(){return this.lh}yh(t){this.lh=t,this.dm&&this.dm.getSceneGraph().setVisibilityRecursively(t)}gm(){let t=this.dm;this.dm=void 0,t!=null&&this.i.entityRepository.getEntity(t.entityUID)!=null&&this.i.entityRepository.deleteEntityRecursively(t.entityUID)}lm(){return!!(this.isSetup||this.um.matchTag("Being","gizmo"))}setGizmoTag(){if(this.dm){this.dm.tryToSetTag({tag:"Being",value:"gizmo"});let t=y(this.dm.getSceneGraph(),!1);for(let r of t)r.entity.tryToSetTag({tag:"Being",value:"gizmo"});this.dm.tryToSetTag({tag:"type",value:"background-assets"})}}fh(){var i;let t=(i=this.dm)==null?void 0:i.getSceneGraph();if(t==null)return;t.setWorldMatrixDirtyWithoutAABBDirty();let r=[t];for(;r.length>0;){let e=r.pop();e.matrixInner,e.entity.tryToGetMesh()!=null&&e.normalMatrixInner;for(let n of e.children)r.push(n)}}static gh(t,r,i){if(!Number.isFinite(i)||i<=0)return 1;let e=t.componentRepository.getComponent(m,m.getCurrent(t));if(e==null)return 1;let n=e.projectionMatrix.m11;if(!Number.isFinite(n)||n<=0)return 1;if(e.type===g.Orthographic){let p=i*2/n;return Number.isFinite(p)&&p>0?p:1}e.viewMatrix.multiplyVector3To(r,o.ph);let c=-o.ph.z,s=e.zNearInner,h=Number.isFinite(s)&&s>0?s:1e-4,l=Number.isFinite(c)?Math.max(c,h):h,a=i*2*l/n;return Number.isFinite(a)&&a>0?a:1}};o.ph=d.zero();var u=o;export{u as Gizmo};
@@ -1 +1 @@
1
- import{createMeshEntity as M}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as C}from"../components/SceneGraph/createGroupEntity.js";import{Mesh as v}from"../geometry/Mesh.js";import{Joint as G}from"../geometry/shapes/Joint.js";import{MutableQuaternion as m}from"../math/MutableQuaternion.js";import{MutableVector3 as r}from"../math/MutableVector3.js";import{Quaternion as T}from"../math/Quaternion.js";import{Vector3 as u}from"../math/Vector3.js";import{Is as h}from"../misc/Is.js";import{Gizmo as b}from"./Gizmo.js";var e=class e extends b{constructor(){super(...arguments);this.dh=[]}get isSetup(){return h.exist(this.hm)}_setup(){if(this.dm())return;let t=this.pm.getSceneGraph();if(!t)return;this.hm=C(this.i),this.hm.tryToSetUniqueName(`JointGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t._addGizmoChild(this.hm.getSceneGraph());let n=this.Th(t);if(n.length===0)return;let i=e.bh(this.i);for(let o of n){let a=this.Eh(o.parent,o.child,i);a&&this.dh.push(a)}this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Joint"}),this._update()}_update(){if(!(!h.exist(this.hm)||this.dh.length===0))for(let t of this.dh){let n=t.parent,i=t.child;if(!i.isJoint()||!n.isJoint()){t.entity.getSceneGraph().isVisible=!1;continue}let o=i.getPositionTo(e.Ch),a=n.getPositionTo(e.vh),c=e.Gh.copyComponents(a).subtract(o),s=c.length();if(s<Number.EPSILON){t.entity.getSceneGraph().isVisible=!1;continue}t.entity.getSceneGraph().isVisible=!0,c.divide(s),T.fromToRotationTo(e.Sh,c,e.gh);let l=Math.max(s*.15,.002),y=e.Vn.setComponents(l,s,l),p=t.entity.getTransform(),f=t.localPosition.copyComponents(o),S=t.localRotation.copyComponents(e.gh),g=t.localScale.copyComponents(y);p.localPosition=f,p.localRotation=S,p.localScale=g}}_destroy(){this.um(),this.dh=[]}Th(t){let n=[];if(!t.isJoint())return n;for(let i of t.children)i.isJoint()&&n.push({parent:t,child:i});return n}static bh(t){let n=t.objectUID,i=e.fh.get(n);if(!i){i=new v(t);let o=new G(t);o.generate({}),o.setWorldPositions(e.Mh,e.Sh,1),o.setRenderQueue(7),i.addPrimitive(o),e.fh.set(n,i)}return i}Eh(t,n,i){if(!h.exist(this.hm))return;let o=M(this.i);return o.tryToSetUniqueName(`JointGizmo_segment_${t.entity.uniqueName}_${n.entity.uniqueName}`,!0),o.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,o.getMesh().setMesh(i),o.tryToSetTag({tag:"Gizmo",value:"Joint"}),this.hm.getSceneGraph().addChild(o.getSceneGraph()),{entity:o,parent:t,child:n,localPosition:r.zero(),localScale:r.one(),localRotation:m.identity()}}};e.fh=new Map,e.Sh=u.fromCopyArray3([0,1,0]),e.Mh=u.fromCopyArray3([0,0,0]),e.Ch=r.zero(),e.vh=r.zero(),e.Gh=r.zero(),e.Vn=r.one(),e.gh=m.identity();var d=e;export{d as JointGizmo};
1
+ import{createMeshEntity as M}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as C}from"../components/SceneGraph/createGroupEntity.js";import{Mesh as v}from"../geometry/Mesh.js";import{Joint as G}from"../geometry/shapes/Joint.js";import{MutableQuaternion as m}from"../math/MutableQuaternion.js";import{MutableVector3 as r}from"../math/MutableVector3.js";import{Quaternion as T}from"../math/Quaternion.js";import{Vector3 as u}from"../math/Vector3.js";import{Is as h}from"../misc/Is.js";import{Gizmo as b}from"./Gizmo.js";var e=class e extends b{constructor(){super(...arguments);this.dh=[]}get isSetup(){return h.exist(this.dm)}_setup(){if(this.lm())return;let t=this.um.getSceneGraph();if(!t)return;this.dm=C(this.i),this.dm.tryToSetUniqueName(`JointGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t._addGizmoChild(this.dm.getSceneGraph());let n=this.Eh(t);if(n.length===0)return;let i=e.Ph(this.i);for(let o of n){let a=this.xh(o.parent,o.child,i);a&&this.dh.push(a)}this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Joint"}),this._update()}_update(){if(!(!h.exist(this.dm)||this.dh.length===0))for(let t of this.dh){let n=t.parent,i=t.child;if(!i.isJoint()||!n.isJoint()){t.entity.getSceneGraph().isVisible=!1;continue}let o=i.getPositionTo(e.Gh),a=n.getPositionTo(e.Th),c=e.bh.copyComponents(a).subtract(o),s=c.length();if(s<Number.EPSILON){t.entity.getSceneGraph().isVisible=!1;continue}t.entity.getSceneGraph().isVisible=!0,c.divide(s),T.fromToRotationTo(e.Mh,c,e.Ch);let l=Math.max(s*.15,.002),y=e.Vn.setComponents(l,s,l),p=t.entity.getTransform(),f=t.localPosition.copyComponents(o),S=t.localRotation.copyComponents(e.Ch),g=t.localScale.copyComponents(y);p.localPosition=f,p.localRotation=S,p.localScale=g}}_destroy(){this.gm(),this.dh=[]}Eh(t){let n=[];if(!t.isJoint())return n;for(let i of t.children)i.isJoint()&&n.push({parent:t,child:i});return n}static Ph(t){let n=t.objectUID,i=e.Sh.get(n);if(!i){i=new v(t);let o=new G(t);o.generate({}),o.setWorldPositions(e.vh,e.Mh,1),o.setRenderQueue(7),i.addPrimitive(o),e.Sh.set(n,i)}return i}xh(t,n,i){if(!h.exist(this.dm))return;let o=M(this.i);return o.tryToSetUniqueName(`JointGizmo_segment_${t.entity.uniqueName}_${n.entity.uniqueName}`,!0),o.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,o.getMesh().setMesh(i),o.tryToSetTag({tag:"Gizmo",value:"Joint"}),this.dm.getSceneGraph().addChild(o.getSceneGraph()),{entity:o,parent:t,child:n,localPosition:r.zero(),localScale:r.one(),localRotation:m.identity()}}};e.Sh=new Map,e.Mh=u.fromCopyArray3([0,1,0]),e.vh=u.fromCopyArray3([0,0,0]),e.Gh=r.zero(),e.Th=r.zero(),e.bh=r.zero(),e.Vn=r.one(),e.Ch=m.identity();var d=e;export{d as JointGizmo};
@@ -1,22 +1,65 @@
1
1
  import { Gizmo } from './Gizmo';
2
+ /**
3
+ * Gizmo that shows the position and orientation of a light.
4
+ *
5
+ * The shape follows the light type: an arrow for directional lights, a wireframe sphere for
6
+ * point (and ambient) lights, and a cone for spot lights whose half angle follows the light's
7
+ * inner/outer cone angles. The gizmo keeps a constant on-screen size, so its world size follows
8
+ * the camera's focus distance.
9
+ *
10
+ * A light type change swaps the main shape's mesh. MeshComponent.setMesh marks the renderer for
11
+ * the Load stage and the Engine keeps that stage running until the renderer is loaded, so the
12
+ * new mesh gets its GPU vertex data even while the scene is otherwise static.
13
+ */
2
14
  export declare class LightGizmo extends Gizmo {
3
- private static __mesh;
4
15
  private static __length;
16
+ /** Radius of the point light sphere in gizmo space. */
17
+ private static __pointRadius;
18
+ /** Segments per circle of the point light sphere and of the spot cone base. */
19
+ private static __circleSegments;
20
+ /** Number of lines drawn from the spot cone apex to its base circle. */
21
+ private static __coneRadialLines;
22
+ /** Largest half angle used for the spot cone, kept below 90 degrees so that tan() stays finite. */
23
+ private static __maxConeAngle;
24
+ /** Gizmo size as a fraction of the viewport height (unit gizmo length). */
25
+ private static __screenSpaceRatio;
26
+ /** Meshes shared by every light gizmo of the same engine. */
27
+ private static __meshesMap;
28
+ private __meshes?;
29
+ /** Mesh entity whose mesh is swapped when the light type changes. */
30
+ private __mainEntity?;
31
+ /** Mesh entity that shows the inner cone of a spot light. */
32
+ private __innerConeEntity?;
33
+ /** Light type the main shape's mesh was built for. */
34
+ private __lightType?;
5
35
  /**
6
36
  * Checks whether the gizmo has been properly initialized and set up.
7
37
  * @returns True if the gizmo's top entity exists and setup is complete, false otherwise
8
38
  */
9
39
  get isSetup(): boolean;
40
+ /**
41
+ * Sets the gizmo size as a fraction of the viewport height.
42
+ * The unit gizmo length is projected to this fraction of the viewport height.
43
+ * @param val - The ratio of the viewport height (for example, 0.12 for 12%)
44
+ */
45
+ set screenSpaceRatio(val: number);
46
+ /**
47
+ * Gets the gizmo size as a fraction of the viewport height.
48
+ * @returns The ratio of the viewport height occupied by the unit gizmo length
49
+ */
50
+ get screenSpaceRatio(): number;
10
51
  /**
11
52
  * Initializes the gizmo entities and visual representation if not already done.
12
- * Creates a mesh entity with a light gizmo primitive and attaches it to the target entity.
53
+ * Creates a group entity with one mesh entity for the light shape and one for the
54
+ * inner cone of a spot light, and attaches it to the target entity.
13
55
  * @internal
14
56
  */
15
57
  _setup(): void;
16
58
  /**
17
59
  * Updates the transform properties (position, rotation, scale) of the gizmo to match the target entity.
18
- * The gizmo's position is set to either the target's position or the center of its bounding box,
19
- * and its scale is adjusted based on the target's bounding box size.
60
+ * The gizmo's position is set to either the target's position or the center of its bounding box.
61
+ * Its scale is derived from the camera so that the gizmo keeps a constant on-screen size and
62
+ * therefore follows the camera's focus distance instead of being fixed in world units.
20
63
  * @internal
21
64
  */
22
65
  _update(): void;
@@ -26,11 +69,66 @@ export declare class LightGizmo extends Gizmo {
26
69
  */
27
70
  _destroy(): void;
28
71
  /**
29
- * Generates the primitive geometry for the light gizmo visualization.
30
- * Creates a line-based representation showing a directional arrow pointing in the negative Z direction,
31
- * which is commonly used to represent light direction in 3D graphics.
32
- * @returns A primitive object containing the line geometry for the light gizmo
33
- * @private
72
+ * Creates a mesh entity as a child of the top entity.
73
+ * @param name - Name of the shape, used in the entity's unique name
74
+ * @param mesh - The mesh to assign, or undefined when the mesh is assigned later
75
+ */
76
+ private __createVisualEntity;
77
+ /**
78
+ * Applies the mesh and the cone scales that fit the current light type.
79
+ */
80
+ private __updateShape;
81
+ /**
82
+ * Scales a cone-shaped entity radially. The z axis keeps the unit height of the cone.
83
+ * A zero radius is clamped to a tiny positive value so that the world matrix stays invertible.
84
+ * @param entity - The mesh entity to scale
85
+ * @param radius - Radius of the cone base in gizmo space
86
+ */
87
+ private __setShapeRadius;
88
+ /**
89
+ * Shows or hides a shape entity. The state is compared first because setting the visibility
90
+ * bumps the scene graph update count.
91
+ * @param entity - The mesh entity to toggle
92
+ * @param visible - True to show the entity
93
+ */
94
+ private __setEntityVisible;
95
+ /**
96
+ * Returns the shared meshes of an engine, creating them on first use.
97
+ * @param engine - The engine that owns the meshes
98
+ */
99
+ private static __getMeshes;
100
+ /**
101
+ * Returns the mesh of the main shape for a light type.
102
+ * @param meshes - The shared meshes of the engine
103
+ * @param lightType - The light type to draw
104
+ */
105
+ private static __meshForType;
106
+ /**
107
+ * Converts a cone half angle to the base radius of a unit-height cone.
108
+ * @param angle - The half angle in radian
109
+ * @returns The base radius, or 0 for a non-positive or invalid angle
110
+ */
111
+ private static __calcConeRadius;
112
+ /**
113
+ * Creates a line primitive from raw position data.
114
+ * @param engine - The engine that owns the primitive
115
+ * @param positions - The vertex positions as xyz triples
116
+ */
117
+ private static __createLinePrimitive;
118
+ /**
119
+ * Generates the directional light shape: a line with an arrow pointing along the local -Z axis.
120
+ * @param engine - The engine that owns the primitive
121
+ */
122
+ private static __generateDirectionalPrimitive;
123
+ /**
124
+ * Generates the point light shape: three great circles of a wireframe sphere.
125
+ * @param engine - The engine that owns the primitive
126
+ */
127
+ private static __generatePointPrimitive;
128
+ /**
129
+ * Generates the spot light shape: a unit cone (height 1 along -Z, base radius 1).
130
+ * The entity that draws it scales the base by tan(half angle).
131
+ * @param engine - The engine that owns the primitive
34
132
  */
35
- private static __generatePrimitive;
133
+ private static __generateConePrimitive;
36
134
  }
@@ -1 +1 @@
1
- import{createMeshEntity as s}from"../components/MeshRenderer/createMeshEntity.js";import{PrimitiveMode as o}from"../definitions/PrimitiveMode.js";import{VertexAttribute as a}from"../definitions/VertexAttribute.js";import{Mesh as n}from"../geometry/Mesh.js";import{Primitive as h}from"../geometry/Primitive.js";import{Vector3 as m}from"../math/Vector3.js";import{Gizmo as l}from"./Gizmo.js";var e=class e extends l{get isSetup(){return this.hm!=null}_setup(){if(this.dm())return;this.hm=s(this.i),this.hm.tryToSetUniqueName(`LightGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.pm.getSceneGraph()._addGizmoChild(this.hm.getSceneGraph());let i=this.hm.tryToGetMesh();e.eo=new n(this.i),e.eo.addPrimitive(e.xh(this.i)),i.setMesh(e.eo),this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Light"})}_update(){if(this.hm==null)return;let i=this.pm.getSceneGraph(),t=i.worldMergedAABBWithSkeletal;t.isVanilla()?this.hm.getTransform().localPosition=i.position:this.hm.getTransform().localPosition=t.centerPoint,this.hm.getTransform().localRotation=i.rotation,this.hm.getTransform().localScale=m.fromCopyArray([Math.max(1,t.isVanilla()?1:t.sizeX/2),Math.max(1,t.isVanilla()?1:t.sizeY/2),Math.max(1,t.isVanilla()?1:t.sizeZ/2)])}_destroy(){this.um()}static xh(i){let t=new Float32Array([0,0,0,0,0,-this.Ph,0,0,-this.Ph,-.1,0,-this.Ph+.2,-.1,0,-this.Ph+.2,0,0,-this.Ph+.2]);return h.createPrimitive(i,{attributeSemantics:[a.Position.XYZ],attributes:[t],primitiveMode:o.Lines})}};e.Ph=1;var r=e;export{r as LightGizmo};
1
+ import{createMeshEntity as y}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as b}from"../components/SceneGraph/createGroupEntity.js";import{LightType as h}from"../definitions/LightType.js";import{PrimitiveMode as P}from"../definitions/PrimitiveMode.js";import{VertexAttribute as S}from"../definitions/VertexAttribute.js";import{Mesh as l}from"../geometry/Mesh.js";import{Primitive as E}from"../geometry/Primitive.js";import{Vector3 as f}from"../math/Vector3.js";import{Gizmo as v}from"./Gizmo.js";var s=class s extends v{get isSetup(){return this.dm!=null}set screenSpaceRatio(t){s.Lh=t}get screenSpaceRatio(){return s.Lh}_setup(){this.lm()||(this.dm=b(this.i),this.dm.tryToSetUniqueName(`LightGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.um.getSceneGraph()._addGizmoChild(this.dm.getSceneGraph()),this.wh=s.Oh(this.i),this.Ih=this.qh("main"),this.zh=this.qh("innerCone",this.wh.cone),this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Light"}),this._update())}_update(){if(this.dm==null||this.Ih==null)return;let t=this.um.getSceneGraph(),e=t.worldMergedAABBWithSkeletal,i=e.isVanilla()?t.position:e.centerPoint,n=this.dm.getTransform();n.localPosition=i,n.localRotation=t.rotation;let r=v.gh(this.i,i,s.Lh);n.localScale=f.fromCopy3(r,r,r),this.Wh(),this.fh()}_destroy(){this.gm(),this.wh=void 0,this.Ih=void 0,this.zh=void 0,this.Dh=void 0}qh(t,e){let i=y(this.i);return i.tryToSetUniqueName(`LightGizmo_${t}_of_${this.um.uniqueName}`,!0),e!=null&&i.getMesh().setMesh(e),this.dm.getSceneGraph().addChild(i.getSceneGraph()),i}Wh(){var n;let t=this.um.tryToGetLight(),e=(n=t==null?void 0:t.type)!=null?n:h.Directional;if(e!==this.Dh&&(this.Dh=e,this.Ih.getMesh().setMesh(s.Hh(this.wh,e))),e!==h.Spot||t==null){this.Ah(this.Ih,1),this.Ah(this.zh,0),this.jh(this.zh,!1);return}this.Ah(this.Ih,s.$h(t.outerConeAngle));let i=s.$h(t.innerConeAngle);this.Ah(this.zh,i),this.jh(this.zh,i>0)}Ah(t,e){if(t==null)return;let i=Math.max(e,1e-4);t.getTransform().localScale=f.fromCopy3(i,i,1)}jh(t,e){let i=t==null?void 0:t.getSceneGraph();i!=null&&i.isVisible!==e&&i.setVisibilityRecursively(e)}static Oh(t){let e=t.objectUID,i=s.Vh.get(e);if(i==null){let n=new l(t);n.addPrimitive(s.Xh(t));let r=new l(t);r.addPrimitive(s.Yh(t));let o=new l(t);o.addPrimitive(s.Zh(t)),i={directional:n,point:r,cone:o},s.Vh.set(e,i)}return i}static Hh(t,e){return e===h.Directional?t.directional:e===h.Spot?t.cone:t.point}static $h(t){return!Number.isFinite(t)||t<=0?0:Math.tan(Math.min(t,s.Fh))}static Uh(t,e){return E.createPrimitive(t,{attributeSemantics:[S.Position.XYZ],attributes:[new Float32Array(e)],primitiveMode:P.Lines})}static Xh(t){let e=s.kh,i=[0,0,0,0,0,-e,0,0,-e,-.1,0,-e+.2,-.1,0,-e+.2,0,0,-e+.2];return s.Uh(t,i)}static Yh(t){let e=s.Bh,i=s.Nh,n=[],r=o=>{for(let a=0;a<i;a++){let M=a/i*Math.PI*2,d=(a+1)/i*Math.PI*2,c=Math.cos(M)*e,p=Math.sin(M)*e,u=Math.cos(d)*e,m=Math.sin(d)*e;o==="xy"?n.push(c,p,0,u,m,0):o==="yz"?n.push(0,c,p,0,u,m):n.push(c,0,p,u,0,m)}};return r("xy"),r("yz"),r("zx"),s.Uh(t,n)}static Zh(t){let e=s.Nh,i=[];for(let n=0;n<e;n++){let r=n/e*Math.PI*2,o=(n+1)/e*Math.PI*2;i.push(Math.cos(r),Math.sin(r),-1,Math.cos(o),Math.sin(o),-1)}for(let n=0;n<s.Rh;n++){let r=n/s.Rh*Math.PI*2;i.push(0,0,0,Math.cos(r),Math.sin(r),-1)}return s.Uh(t,i)}};s.kh=1,s.Bh=.2,s.Nh=32,s.Rh=8,s.Fh=Math.PI/2-.01,s.Lh=.12,s.Vh=new Map;var g=s;export{g as LightGizmo};
@@ -1 +1 @@
1
- import{createMeshEntity as a}from"../components/MeshRenderer/createMeshEntity.js";import{PrimitiveMode as n}from"../definitions/PrimitiveMode.js";import{VertexAttribute as r}from"../definitions/VertexAttribute.js";import{Mesh as m}from"../geometry/Mesh.js";import{Primitive as h}from"../geometry/Primitive.js";import{Vector3 as l}from"../math/Vector3.js";import{Gizmo as p}from"./Gizmo.js";var i=class i extends p{get isSetup(){return this.hm!=null}set length(e){i.Ph=e}get length(){return i.Ph}_setup(){if(this.dm())return;this.hm=a(this.i),this.hm.tryToSetUniqueName(`LocatorGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.pm.getSceneGraph()._addGizmoChild(this.hm.getSceneGraph());let e=this.hm.tryToGetMesh();i.eo=new m(this.i),i.eo.addPrimitive(i.xh(this.i)),e.setMesh(i.eo),this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Locator"})}_update(){if(this.hm==null)return;let e=this.pm.getSceneGraph(),t=e.worldMergedAABBWithSkeletal;t.isVanilla()?this.hm.getTransform().localPosition=e.position:this.hm.getTransform().localPosition=t.centerPoint,this.hm.getTransform().localScale=l.fromCopyArray([Math.max(1,t.isVanilla()?1:t.sizeX/2),Math.max(1,t.isVanilla()?1:t.sizeY/2),Math.max(1,t.isVanilla()?1:t.sizeZ/2)])}static xh(e){let t=new Float32Array([0,0,0,this.Ph,0,0,0,0,0,0,this.Ph,0,0,0,0,0,0,this.Ph]),o=new Float32Array([1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1]);return h.createPrimitive(e,{attributeSemantics:[r.Position.XYZ,r.Color0.XYZ],attributes:[t,o],primitiveMode:n.Lines})}_destroy(){this.um()}static _cleanupForEngine(e){i.eo=void 0}};i.Ph=1;var s=i;export{s as LocatorGizmo};
1
+ import{createMeshEntity as a}from"../components/MeshRenderer/createMeshEntity.js";import{PrimitiveMode as n}from"../definitions/PrimitiveMode.js";import{VertexAttribute as r}from"../definitions/VertexAttribute.js";import{Mesh as m}from"../geometry/Mesh.js";import{Primitive as h}from"../geometry/Primitive.js";import{Vector3 as l}from"../math/Vector3.js";import{Gizmo as p}from"./Gizmo.js";var i=class i extends p{get isSetup(){return this.dm!=null}set length(e){i.kh=e}get length(){return i.kh}_setup(){if(this.lm())return;this.dm=a(this.i),this.dm.tryToSetUniqueName(`LocatorGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.um.getSceneGraph()._addGizmoChild(this.dm.getSceneGraph());let e=this.dm.tryToGetMesh();i.eo=new m(this.i),i.eo.addPrimitive(i.fm(this.i)),e.setMesh(i.eo),this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Locator"})}_update(){if(this.dm==null)return;let e=this.um.getSceneGraph(),t=e.worldMergedAABBWithSkeletal;t.isVanilla()?this.dm.getTransform().localPosition=e.position:this.dm.getTransform().localPosition=t.centerPoint,this.dm.getTransform().localScale=l.fromCopyArray([Math.max(1,t.isVanilla()?1:t.sizeX/2),Math.max(1,t.isVanilla()?1:t.sizeY/2),Math.max(1,t.isVanilla()?1:t.sizeZ/2)])}static fm(e){let t=new Float32Array([0,0,0,this.kh,0,0,0,0,0,0,this.kh,0,0,0,0,0,0,this.kh]),o=new Float32Array([1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1]);return h.createPrimitive(e,{attributeSemantics:[r.Position.XYZ,r.Color0.XYZ],attributes:[t,o],primitiveMode:n.Lines})}_destroy(){this.gm()}static _cleanupForEngine(e){i.eo=void 0}};i.kh=1;var s=i;export{s as LocatorGizmo};
@@ -1 +1 @@
1
- import{CameraComponent as E}from"../components/Camera/CameraComponent.js";import{createMeshEntity as A}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as G}from"../components/SceneGraph/createGroupEntity.js";import{AlphaMode as k}from"../definitions/AlphaMode.js";import{Mesh as P}from"../geometry/Mesh.js";import{Ring as Z}from"../geometry/shapes/Ring.js";import{createClassicUberMaterial as $}from"../helpers/materials/createClassicUberMaterial.js";import{Matrix33 as H}from"../math/Matrix33.js";import{MutableMatrix44 as I}from"../math/MutableMatrix44.js";import{MutableQuaternion as J}from"../math/MutableQuaternion.js";import{MutableVector2 as Q}from"../math/MutableVector2.js";import{MutableVector3 as f}from"../math/MutableVector3.js";import{MutableVector4 as T}from"../math/MutableVector4.js";import{Quaternion as v}from"../math/Quaternion.js";import{Vector3 as m}from"../math/Vector3.js";import{Vector4 as S}from"../math/Vector4.js";import{Is as g}from"../misc/Is.js";import{assertExist as K}from"../misc/MiscUtil.js";import{getEvent as Y,INPUT_HANDLING_STATE_GIZMO_ROTATION as D,InputManager as C}from"../system/InputManager.js";import{Gizmo as X}from"./Gizmo.js";var e=class e extends X{constructor(){super(...arguments);this.Rl=!1;this.Fl=m.zero();this.Vl=v.identity();this.Il=v.identity();this.Vh=this.Nh.bind(this);this.wh=this.Ah.bind(this);this.Xl=this.Yh.bind(this);this.Nl=!1;this.El=Q.zero();this.Cl=Q.zero();this.wl=f.zero();this.Tl=0;this.Sl=0}static Ml(t){return e.Pl.get(t.objectUID)}get isSetup(){return g.exist(this.hm)}set length(t){e.Ph=t}get length(){return e.Ph}set screenSpaceRatio(t){e.Dl=t}get screenSpaceRatio(){return e.Dl}get isVisible(){return this.mh}set isVisible(t){if(e.Ml(this.i)){if(this.mh===!1&&t===!0){let r=window;g.exist(this.i.config.eventTargetDom)&&(r=this.i.config.eventTargetDom),C.register(D,[{eventName:Y("start"),handler:this.Vh,options:{},classInstance:this,eventTargetDom:r},{eventName:Y("move"),handler:this.wh,options:{},classInstance:this,eventTargetDom:r},{eventName:Y("end"),handler:this.Xl,options:{},classInstance:this,eventTargetDom:r},{eventName:"pointerleave",handler:this.Xl,options:{},classInstance:this,eventTargetDom:r}]),this.ql=this.pm,this.Ol(),this.Ul()}this.mh===!0&&t===!1&&(C.unregister(D),this.Rl=!1,e.xl="none"),C.setActive(D,t),this.uh(t)}}setSpace(t){e.Yl=t,this.mh&&this.Ul()}_setup(){if(this.dm())return;let t=this.pm.getSceneGraph();if(!t)return;this.hm=G(this.i),this.hm.tryToSetUniqueName(`RotationGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t._addGizmoChild(this.hm.getSceneGraph());let i=e.Ml(this.i);i||(i=this.Dh(),e.Pl.set(this.i.objectUID,i)),this.Ol(),this.ql=this.pm,this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Rotation"}),this._update()}Dh(){let t=A(this.i);t.tryToSetUniqueName("RotationGizmo_xRing",!0);let i=e.Ll(this.i,S.fromCopyArray4([1,0,0,.85])),r=new P(this.i),s=e.Gl(this.i,"x",i);r.addPrimitive(s),t.getMesh().setMesh(r);let n=A(this.i);n.tryToSetUniqueName("RotationGizmo_yRing",!0);let o=e.Ll(this.i,S.fromCopyArray4([0,1,0,.85])),a=new P(this.i),c=e.Gl(this.i,"y",o);a.addPrimitive(c),n.getMesh().setMesh(a);let l=A(this.i);l.tryToSetUniqueName("RotationGizmo_zRing",!0);let h=e.Ll(this.i,S.fromCopyArray4([0,0,1,.85])),u=new P(this.i),p=e.Gl(this.i,"z",h);return u.addPrimitive(p),l.getMesh().setMesh(u),{groupEntity:G(this.i),xRingEntity:t,yRingEntity:n,zRingEntity:l,xRingMesh:r,yRingMesh:a,zRingMesh:u,xRingMaterial:i,yRingMaterial:o,zRingMaterial:h,xRingPrimitive:s,yRingPrimitive:c,zRingPrimitive:p}}_update(){if(!g.exist(this.hm))return;let t=this.pm.getSceneGraph(),i=t.worldMergedAABBWithSkeletal,r=i.isVanilla()?t.position:i.centerPoint,s=this.hm.getTransform();s.localPosition=r;let n=X.yh(this.i,r,e.Dl);s.localScale=m.fromCopy3(n,n,n),this.lh(),this.Rl&&e.xl!=="none"&&this.ql===this.pm&&(this.pm.getTransform().localRotation=v.fromCopyQuaternion(this.Vl))}_destroy(){this.um()}Ol(){let t=e.Ml(this.i);if(!g.exist(this.hm)||!t)return;let i=this.hm.getSceneGraph(),r=t.groupEntity.getSceneGraph();i.addChild(r),r.addChild(t.xRingEntity.getSceneGraph()),r.addChild(t.yRingEntity.getSceneGraph()),r.addChild(t.zRingEntity.getSceneGraph())}Ul(){let t=e.Ml(this.i);if(t)if(e.Yl==="local"){let i=e.Ql,r=this.pm.getSceneGraph().parent;g.exist(r)?r.getQuaternionRecursivelyTo(i):i.identity(),t.groupEntity.getTransform().localRotation=i}else t.groupEntity.getTransform().localRotation=e.Ql.identity()}Nh(t){this.Rl=!0,this.zl=void 0,this.El.setComponents(0,0),this.Cl.setComponents(0,0),this.Tl=0,this.Sl=0,this.wl.setComponents(0,0,0);let{xResult:i,yResult:r,zResult:s}=e.Fh(this.i,t,!0);e.xl="none";let n=e.qh([{axis:"x",result:i},{axis:"y",result:r},{axis:"z",result:s}]);if(n&&(K(n.result.data),this.Fl=m.normalize(e.Lh(n.result.data.position,n.axis)),e.xl=n.axis),e.xl==="none"){this.Rl=!1;return}t.preventDefault(),this.Hh(),this.Il=v.fromCopyQuaternion(this.pm.getTransform().localRotation),this.Vl=v.fromCopyQuaternion(this.Il),this.Qh(t,e.xl)}Ah(t){t.preventDefault(),!(g.false(this.Rl)||e.xl==="none")&&this.Xh(t)}Yh(t){t.preventDefault(),this.Rl=!1,e.xl="none",this.Oh(),this.Fl=m.zero(),this.Il=v.fromCopyQuaternion(this.pm.getTransform().localRotation),this.Vl=v.fromCopyQuaternion(this.Il),this.zl=void 0,this.El.setComponents(0,0),this.Cl.setComponents(0,0),this.wl.setComponents(0,0,0),this.Tl=0,this.Sl=0}Qh(t,i){var L;let r=e.Ml(this.i);if(!r)return;this.Cl.setComponents(0,0);let s=this.Uh(t),n=1,o=1,a=0,c=0;if(s){let R=s.getBoundingClientRect();n=R.width||s.clientWidth||1,o=R.height||s.clientHeight||1,a=t.clientX-R.left,c=t.clientY-R.top,this.zl=s}else this.zl=void 0;this.El.setComponents(a,c),this.Tl=2*Math.PI/Math.max(n,o,1),this.Sl=0;let l=this.Bh(i);m.normalizeTo(l,this.wl);let h=this.i.componentRepository.getComponent(E,E.getCurrent(this.i)),u=(L=r.groupEntity)==null?void 0:L.getSceneGraph();if(!s||!h||!u){this.Al(i);return}let p=e.Hl(i),y=m.crossTo(this.Fl,p,e.Ih);y.lengthSquared()<1e-10&&this.Wh(i,y),m.normalizeTo(y,y);let d=this.Bl(y,e.zh);if(d.lengthSquared()<1e-10&&this.jh(p,h,d),d.lengthSquared()<1e-10){this.Al(i);return}m.normalizeTo(d,d);let x=u.matrixInner.getTranslateTo(e.Rh),M=I.multiplyTo(h.projectionMatrix,h.viewMatrix,e.kl),b=M.multiplyVectorTo(e.Zl.setComponents(x.x,x.y,x.z,1),e.Jl),z=M.multiplyVectorTo(e.$l.setComponents(x.x+d.x,x.y+d.y,x.z+d.z,1),e.Kl),V=b.w,N=z.w;if(V===0||N===0){this.Al(i);return}let U=b.x/V,B=b.y/V,W=z.x/N,j=z.y/N,F=(W-U)*n*.5,q=-(j-B)*o*.5,w=Math.hypot(F,q);if(w<1e-5){this.Al(i);return}this.Cl.setComponents(F/w,q/w)}Al(t){t==="x"?this.Cl.setComponents(0,-1):t==="y"?this.Cl.setComponents(1,0):this.Cl.setComponents(1,0)}Wh(t,i){t==="x"||t==="y"?i.setComponents(0,0,1):i.setComponents(0,1,0)}jh(t,i,r){let s=this.Bl(t,e._l);if(s.lengthSquared()<1e-10){r.setComponents(1,0,0);return}m.normalizeTo(s,s),m.crossTo(s,i.directionInner,r),r.lengthSquared()<1e-10&&m.crossTo(i.upInner,s,r),r.lengthSquared()<1e-10&&this.kh(s,r)}kh(t,i){Math.abs(t.x)<.9?i.setComponents(0,-t.z,t.y):i.setComponents(-t.y,t.x,0),i.lengthSquared()<1e-10&&i.setComponents(1,0,0)}Xh(t){let i=this.zl;if(!i||this.Tl===0)return;let r=i.getBoundingClientRect();if(r.width===0||r.height===0)return;let s=t.clientX-r.left,n=t.clientY-r.top,o=s-this.El.x,a=n-this.El.y;if(this.El.setComponents(s,n),!Number.isFinite(o)||!Number.isFinite(a)||o===0&&a===0)return;let c=-o*this.Cl.x-a*this.Cl.y;if(c===0)return;let l=c*this.Tl;if(!Number.isFinite(l)||l===0)return;this.Sl+=l;let h=v.fromAxisAngle(this.wl,this.Sl);this.Vl=v.multiply(h,this.Il),this._update()}Bl(t,i){var p;let r=e.Ml(this.i),s=(p=r==null?void 0:r.groupEntity)==null?void 0:p.getSceneGraph();if(!s)return i.setComponents(t.x,t.y,t.z);let n=s.matrixInner,o=t.x,a=t.y,c=t.z,l=n.m00*o+n.m01*a+n.m02*c,h=n.m10*o+n.m11*a+n.m12*c,u=n.m20*o+n.m21*a+n.m22*c;return i.setComponents(l,h,u)}Uh(t){var r;let i=t.target;if(i!=null&&i.getBoundingClientRect||(i=(r=this.i.config.eventTargetDom)!=null?r:null),!!(i!=null&&i.getBoundingClientRect))return i}Hh(){this.Nl||(C.disableCameraController(),this.Nl=!0)}Oh(){this.Nl&&(C.enableCameraController(),this.Nl=!1)}static Lh(t,i){switch(i){case"x":return m.fromCopy3(0,t.y,t.z);case"y":return m.fromCopy3(t.x,0,t.z);default:return m.fromCopy3(t.x,t.y,0)}}Bh(t){let i=this.pm.getSceneGraph().parent;if(e.Yl==="local"||g.not.exist(i))return e.Hl(t);let r=i.matrixInner.getRotate(),s=H.fromCopy9RowMajor(r.m00,r.m01,r.m02,r.m10,r.m11,r.m12,r.m20,r.m21,r.m22);return H.transpose(s).multiplyVector(e.Hl(t))}static Hl(t){switch(t){case"x":return e.Wl;case"y":return e.Sh;default:return e.jl}}static Fh(t,i,r=!1){let s=e.Ml(t),n={result:!1};if(!s)return{xResult:n,yResult:n,zResult:n};let o=i.target.getBoundingClientRect(),a=i.target.clientWidth,c=i.target.clientHeight,l=i.clientX-o.left,h=o.height-(i.clientY-o.top),u=S.fromCopy4(0,0,a,c),p=t.componentRepository.getComponent(E,E.getCurrent(t)),y=r?e.Zh:e.$h;if(g.not.exist(p))return{xResult:n,yResult:n,zResult:n};let d=y(l,h,p,u,s.xRingEntity),x=y(l,h,p,u,s.yRingEntity),M=y(l,h,p,u,s.zRingEntity);return{xResult:d,yResult:x,zResult:M}}static $h(t,i,r,s,...n){var a,c,l,h;let o={result:!1};for(let u of n){if(g.not.exist(u))continue;let p=u.getMesh().castRayFromScreenInWorld(t,i,r,s,0);if(!p.result)continue;let y=(c=(a=p.data)==null?void 0:a.t)!=null?c:Number.POSITIVE_INFINITY,d=(h=(l=o.data)==null?void 0:l.t)!=null?h:Number.POSITIVE_INFINITY;(!o.result||y<d)&&(o=p)}return o}static Zh(t,i,r,s,...n){var a,c,l,h;let o={result:!1};for(let u of n){if(g.not.exist(u))continue;let p=u.getMesh().castRayFromScreenInLocal(t,i,r,s,0);if(!p.result)continue;let y=(c=(a=p.data)==null?void 0:a.t)!=null?c:Number.POSITIVE_INFINITY,d=(h=(l=o.data)==null?void 0:l.t)!=null?h:Number.POSITIVE_INFINITY;(!o.result||y<d)&&(o=p)}return o}static Gl(t,i,r){let s=e.Ph,n=new Z(t);return n.generate({radius:s,thickness:s*.1,segments:64,axis:i,material:r}),n}static qh(t){var r,s,n,o;let i;for(let a of t){if(!a.result.result)continue;let c=(s=(r=a.result.data)==null?void 0:r.t)!=null?s:Number.POSITIVE_INFINITY;(!i||c<((o=(n=i.result.data)==null?void 0:n.t)!=null?o:Number.POSITIVE_INFINITY))&&(i=a)}return i}static Ll(t,i){let r=$(t);return r.alphaMode=k.Blend,r.cullFace=!1,r.setParameter("diffuseColorFactor",i),r}static _cleanupForEngine(t){e.Pl.delete(t.objectUID),e.xl="none"}};e.Pl=new Map,e.xl="none",e.Yl="world",e.Ph=1,e.Dl=.08,e.Wl=m.fromCopy3(1,0,0),e.Sh=m.fromCopy3(0,1,0),e.jl=m.fromCopy3(0,0,1),e.Ge=I.zero(),e.er=I.zero(),e.kl=I.zero(),e.Zl=T.zero(),e.$l=T.zero(),e.Jl=T.zero(),e.Kl=T.zero(),e.tr=f.zero(),e.Ze=f.zero(),e.$e=f.zero(),e.Jh=f.zero(),e.Kh=f.zero(),e._h=f.zero(),e._l=f.zero(),e.Rh=f.zero(),e.Ih=f.zero(),e.zh=f.zero(),e.Ql=J.identity();var O=e;export{O as RotationGizmo};
1
+ import{CameraComponent as E}from"../components/Camera/CameraComponent.js";import{createMeshEntity as A}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as G}from"../components/SceneGraph/createGroupEntity.js";import{AlphaMode as k}from"../definitions/AlphaMode.js";import{Mesh as P}from"../geometry/Mesh.js";import{Ring as Z}from"../geometry/shapes/Ring.js";import{createClassicUberMaterial as $}from"../helpers/materials/createClassicUberMaterial.js";import{Matrix33 as H}from"../math/Matrix33.js";import{MutableMatrix44 as I}from"../math/MutableMatrix44.js";import{MutableQuaternion as J}from"../math/MutableQuaternion.js";import{MutableVector2 as Q}from"../math/MutableVector2.js";import{MutableVector3 as f}from"../math/MutableVector3.js";import{MutableVector4 as T}from"../math/MutableVector4.js";import{Quaternion as v}from"../math/Quaternion.js";import{Vector3 as m}from"../math/Vector3.js";import{Vector4 as S}from"../math/Vector4.js";import{Is as g}from"../misc/Is.js";import{assertExist as K}from"../misc/MiscUtil.js";import{getEvent as Y,INPUT_HANDLING_STATE_GIZMO_ROTATION as D,InputManager as C}from"../system/InputManager.js";import{Gizmo as X}from"./Gizmo.js";var e=class e extends X{constructor(){super(...arguments);this.Ml=!1;this.Dl=m.zero();this.zl=v.identity();this.El=v.identity();this.Kh=this._h.bind(this);this.vm=this.xm.bind(this);this.Ql=this.Cm.bind(this);this.Vl=!1;this.Rl=Q.zero();this.xl=Q.zero();this.Nl=f.zero();this.Il=0;this.Tl=0}static Cl(t){return e.Pl.get(t.objectUID)}get isSetup(){return g.exist(this.dm)}set length(t){e.kh=t}get length(){return e.kh}set screenSpaceRatio(t){e.Lh=t}get screenSpaceRatio(){return e.Lh}get isVisible(){return this.lh}set isVisible(t){if(e.Cl(this.i)){if(this.lh===!1&&t===!0){let r=window;g.exist(this.i.config.eventTargetDom)&&(r=this.i.config.eventTargetDom),C.register(D,[{eventName:Y("start"),handler:this.Kh,options:{},classInstance:this,eventTargetDom:r},{eventName:Y("move"),handler:this.vm,options:{},classInstance:this,eventTargetDom:r},{eventName:Y("end"),handler:this.Ql,options:{},classInstance:this,eventTargetDom:r},{eventName:"pointerleave",handler:this.Ql,options:{},classInstance:this,eventTargetDom:r}]),this.Fl=this.um,this.Xl(),this.Ol()}this.lh===!0&&t===!1&&(C.unregister(D),this.Ml=!1,e.vl="none"),C.setActive(D,t),this.yh(t)}}setSpace(t){e.Yl=t,this.lh&&this.Ol()}_setup(){if(this.lm())return;let t=this.um.getSceneGraph();if(!t)return;this.dm=G(this.i),this.dm.tryToSetUniqueName(`RotationGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t._addGizmoChild(this.dm.getSceneGraph());let i=e.Cl(this.i);i||(i=this.Mm(),e.Pl.set(this.i.objectUID,i)),this.Xl(),this.Fl=this.um,this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Rotation"}),this._update()}Mm(){let t=A(this.i);t.tryToSetUniqueName("RotationGizmo_xRing",!0);let i=e.ql(this.i,S.fromCopyArray4([1,0,0,.85])),r=new P(this.i),s=e.Ll(this.i,"x",i);r.addPrimitive(s),t.getMesh().setMesh(r);let n=A(this.i);n.tryToSetUniqueName("RotationGizmo_yRing",!0);let o=e.ql(this.i,S.fromCopyArray4([0,1,0,.85])),a=new P(this.i),c=e.Ll(this.i,"y",o);a.addPrimitive(c),n.getMesh().setMesh(a);let l=A(this.i);l.tryToSetUniqueName("RotationGizmo_zRing",!0);let h=e.ql(this.i,S.fromCopyArray4([0,0,1,.85])),u=new P(this.i),p=e.Ll(this.i,"z",h);return u.addPrimitive(p),l.getMesh().setMesh(u),{groupEntity:G(this.i),xRingEntity:t,yRingEntity:n,zRingEntity:l,xRingMesh:r,yRingMesh:a,zRingMesh:u,xRingMaterial:i,yRingMaterial:o,zRingMaterial:h,xRingPrimitive:s,yRingPrimitive:c,zRingPrimitive:p}}_update(){if(!g.exist(this.dm))return;let t=this.um.getSceneGraph(),i=t.worldMergedAABBWithSkeletal,r=i.isVanilla()?t.position:i.centerPoint,s=this.dm.getTransform();s.localPosition=r;let n=X.gh(this.i,r,e.Lh);s.localScale=m.fromCopy3(n,n,n),this.fh(),this.Ml&&e.vl!=="none"&&this.Fl===this.um&&(this.um.getTransform().localRotation=v.fromCopyQuaternion(this.zl))}_destroy(){this.gm()}Xl(){let t=e.Cl(this.i);if(!g.exist(this.dm)||!t)return;let i=this.dm.getSceneGraph(),r=t.groupEntity.getSceneGraph();i.addChild(r),r.addChild(t.xRingEntity.getSceneGraph()),r.addChild(t.yRingEntity.getSceneGraph()),r.addChild(t.zRingEntity.getSceneGraph())}Ol(){let t=e.Cl(this.i);if(t)if(e.Yl==="local"){let i=e.Hl,r=this.um.getSceneGraph().parent;g.exist(r)?r.getQuaternionRecursivelyTo(i):i.identity(),t.groupEntity.getTransform().localRotation=i}else t.groupEntity.getTransform().localRotation=e.Hl.identity()}_h(t){this.Ml=!0,this.Sl=void 0,this.Rl.setComponents(0,0),this.xl.setComponents(0,0),this.Il=0,this.Tl=0,this.Nl.setComponents(0,0,0);let{xResult:i,yResult:r,zResult:s}=e.Rm(this.i,t,!0);e.vl="none";let n=e.Em([{axis:"x",result:i},{axis:"y",result:r},{axis:"z",result:s}]);if(n&&(K(n.result.data),this.Dl=m.normalize(e.Im(n.result.data.position,n.axis)),e.vl=n.axis),e.vl==="none"){this.Ml=!1;return}t.preventDefault(),this.Tm(),this.El=v.fromCopyQuaternion(this.um.getTransform().localRotation),this.zl=v.fromCopyQuaternion(this.El),this.Sm(t,e.vl)}xm(t){t.preventDefault(),!(g.false(this.Ml)||e.vl==="none")&&this.bm(t)}Cm(t){t.preventDefault(),this.Ml=!1,e.vl="none",this.zm(),this.Dl=m.zero(),this.El=v.fromCopyQuaternion(this.um.getTransform().localRotation),this.zl=v.fromCopyQuaternion(this.El),this.Sl=void 0,this.Rl.setComponents(0,0),this.xl.setComponents(0,0),this.Nl.setComponents(0,0,0),this.Il=0,this.Tl=0}Sm(t,i){var L;let r=e.Cl(this.i);if(!r)return;this.xl.setComponents(0,0);let s=this.Vm(t),n=1,o=1,a=0,c=0;if(s){let R=s.getBoundingClientRect();n=R.width||s.clientWidth||1,o=R.height||s.clientHeight||1,a=t.clientX-R.left,c=t.clientY-R.top,this.Sl=s}else this.Sl=void 0;this.Rl.setComponents(a,c),this.Il=2*Math.PI/Math.max(n,o,1),this.Tl=0;let l=this.Nm(i);m.normalizeTo(l,this.Nl);let h=this.i.componentRepository.getComponent(E,E.getCurrent(this.i)),u=(L=r.groupEntity)==null?void 0:L.getSceneGraph();if(!s||!h||!u){this.wl(i);return}let p=e.Gl(i),y=m.crossTo(this.Dl,p,e.Qh);y.lengthSquared()<1e-10&&this.wm(i,y),m.normalizeTo(y,y);let d=this.Ul(y,e.Jh);if(d.lengthSquared()<1e-10&&this.Am(p,h,d),d.lengthSquared()<1e-10){this.wl(i);return}m.normalizeTo(d,d);let x=u.matrixInner.getTranslateTo(e._l),M=I.multiplyTo(h.projectionMatrix,h.viewMatrix,e.jl),b=M.multiplyVectorTo(e.kl.setComponents(x.x,x.y,x.z,1),e.$l),z=M.multiplyVectorTo(e.Zl.setComponents(x.x+d.x,x.y+d.y,x.z+d.z,1),e.Jl),V=b.w,N=z.w;if(V===0||N===0){this.wl(i);return}let U=b.x/V,B=b.y/V,W=z.x/N,j=z.y/N,F=(W-U)*n*.5,q=-(j-B)*o*.5,w=Math.hypot(F,q);if(w<1e-5){this.wl(i);return}this.xl.setComponents(F/w,q/w)}wl(t){t==="x"?this.xl.setComponents(0,-1):t==="y"?this.xl.setComponents(1,0):this.xl.setComponents(1,0)}wm(t,i){t==="x"||t==="y"?i.setComponents(0,0,1):i.setComponents(0,1,0)}Am(t,i,r){let s=this.Ul(t,e.Kl);if(s.lengthSquared()<1e-10){r.setComponents(1,0,0);return}m.normalizeTo(s,s),m.crossTo(s,i.directionInner,r),r.lengthSquared()<1e-10&&m.crossTo(i.upInner,s,r),r.lengthSquared()<1e-10&&this.Pm(s,r)}Pm(t,i){Math.abs(t.x)<.9?i.setComponents(0,-t.z,t.y):i.setComponents(-t.y,t.x,0),i.lengthSquared()<1e-10&&i.setComponents(1,0,0)}bm(t){let i=this.Sl;if(!i||this.Il===0)return;let r=i.getBoundingClientRect();if(r.width===0||r.height===0)return;let s=t.clientX-r.left,n=t.clientY-r.top,o=s-this.Rl.x,a=n-this.Rl.y;if(this.Rl.setComponents(s,n),!Number.isFinite(o)||!Number.isFinite(a)||o===0&&a===0)return;let c=-o*this.xl.x-a*this.xl.y;if(c===0)return;let l=c*this.Il;if(!Number.isFinite(l)||l===0)return;this.Tl+=l;let h=v.fromAxisAngle(this.Nl,this.Tl);this.zl=v.multiply(h,this.El),this._update()}Ul(t,i){var p;let r=e.Cl(this.i),s=(p=r==null?void 0:r.groupEntity)==null?void 0:p.getSceneGraph();if(!s)return i.setComponents(t.x,t.y,t.z);let n=s.matrixInner,o=t.x,a=t.y,c=t.z,l=n.m00*o+n.m01*a+n.m02*c,h=n.m10*o+n.m11*a+n.m12*c,u=n.m20*o+n.m21*a+n.m22*c;return i.setComponents(l,h,u)}Vm(t){var r;let i=t.target;if(i!=null&&i.getBoundingClientRect||(i=(r=this.i.config.eventTargetDom)!=null?r:null),!!(i!=null&&i.getBoundingClientRect))return i}Tm(){this.Vl||(C.disableCameraController(),this.Vl=!0)}zm(){this.Vl&&(C.enableCameraController(),this.Vl=!1)}static Im(t,i){switch(i){case"x":return m.fromCopy3(0,t.y,t.z);case"y":return m.fromCopy3(t.x,0,t.z);default:return m.fromCopy3(t.x,t.y,0)}}Nm(t){let i=this.um.getSceneGraph().parent;if(e.Yl==="local"||g.not.exist(i))return e.Gl(t);let r=i.matrixInner.getRotate(),s=H.fromCopy9RowMajor(r.m00,r.m01,r.m02,r.m10,r.m11,r.m12,r.m20,r.m21,r.m22);return H.transpose(s).multiplyVector(e.Gl(t))}static Gl(t){switch(t){case"x":return e.Bl;case"y":return e.Mh;default:return e.Wl}}static Rm(t,i,r=!1){let s=e.Cl(t),n={result:!1};if(!s)return{xResult:n,yResult:n,zResult:n};let o=i.target.getBoundingClientRect(),a=i.target.clientWidth,c=i.target.clientHeight,l=i.clientX-o.left,h=o.height-(i.clientY-o.top),u=S.fromCopy4(0,0,a,c),p=t.componentRepository.getComponent(E,E.getCurrent(t)),y=r?e.Ym:e.Dm;if(g.not.exist(p))return{xResult:n,yResult:n,zResult:n};let d=y(l,h,p,u,s.xRingEntity),x=y(l,h,p,u,s.yRingEntity),M=y(l,h,p,u,s.zRingEntity);return{xResult:d,yResult:x,zResult:M}}static Dm(t,i,r,s,...n){var a,c,l,h;let o={result:!1};for(let u of n){if(g.not.exist(u))continue;let p=u.getMesh().castRayFromScreenInWorld(t,i,r,s,0);if(!p.result)continue;let y=(c=(a=p.data)==null?void 0:a.t)!=null?c:Number.POSITIVE_INFINITY,d=(h=(l=o.data)==null?void 0:l.t)!=null?h:Number.POSITIVE_INFINITY;(!o.result||y<d)&&(o=p)}return o}static Ym(t,i,r,s,...n){var a,c,l,h;let o={result:!1};for(let u of n){if(g.not.exist(u))continue;let p=u.getMesh().castRayFromScreenInLocal(t,i,r,s,0);if(!p.result)continue;let y=(c=(a=p.data)==null?void 0:a.t)!=null?c:Number.POSITIVE_INFINITY,d=(h=(l=o.data)==null?void 0:l.t)!=null?h:Number.POSITIVE_INFINITY;(!o.result||y<d)&&(o=p)}return o}static Ll(t,i,r){let s=e.kh,n=new Z(t);return n.generate({radius:s,thickness:s*.1,segments:64,axis:i,material:r}),n}static Em(t){var r,s,n,o;let i;for(let a of t){if(!a.result.result)continue;let c=(s=(r=a.result.data)==null?void 0:r.t)!=null?s:Number.POSITIVE_INFINITY;(!i||c<((o=(n=i.result.data)==null?void 0:n.t)!=null?o:Number.POSITIVE_INFINITY))&&(i=a)}return i}static ql(t,i){let r=$(t);return r.alphaMode=k.Blend,r.cullFace=!1,r.setParameter("diffuseColorFactor",i),r}static _cleanupForEngine(t){e.Pl.delete(t.objectUID),e.vl="none"}};e.Pl=new Map,e.vl="none",e.Yl="world",e.kh=1,e.Lh=.08,e.Bl=m.fromCopy3(1,0,0),e.Mh=m.fromCopy3(0,1,0),e.Wl=m.fromCopy3(0,0,1),e.Ge=I.zero(),e.er=I.zero(),e.jl=I.zero(),e.kl=T.zero(),e.Zl=T.zero(),e.$l=T.zero(),e.Jl=T.zero(),e.tr=f.zero(),e.Ze=f.zero(),e.$e=f.zero(),e.Fm=f.zero(),e.qm=f.zero(),e.Lm=f.zero(),e.Kl=f.zero(),e._l=f.zero(),e.Qh=f.zero(),e.Jh=f.zero(),e.Hl=J.identity();var O=e;export{O as RotationGizmo};
@@ -1 +1 @@
1
- import{CameraComponent as S}from"../components/Camera/CameraComponent.js";import{createMeshEntity as C}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as J}from"../components/SceneGraph/createGroupEntity.js";import{AlphaMode as j}from"../definitions/AlphaMode.js";import{PrimitiveMode as re}from"../definitions/PrimitiveMode.js";import{VertexAttribute as K}from"../definitions/VertexAttribute.js";import{Mesh as M}from"../geometry/Mesh.js";import{Primitive as ae}from"../geometry/Primitive.js";import{Cube as z}from"../geometry/shapes/Cube.js";import{Plane as k}from"../geometry/shapes/Plane.js";import{createClassicUberMaterial as T}from"../helpers/materials/createClassicUberMaterial.js";import{MathUtil as _}from"../math/MathUtil.js";import{Matrix33 as w}from"../math/Matrix33.js";import{MutableMatrix33 as ee}from"../math/MutableMatrix33.js";import{MutableQuaternion as oe}from"../math/MutableQuaternion.js";import{MutableVector3 as L}from"../math/MutableVector3.js";import{Vector3 as o}from"../math/Vector3.js";import{Vector4 as E}from"../math/Vector4.js";import{Is as Q}from"../misc/Is.js";import{Logger as x}from"../misc/Logger.js";import{assertExist as R}from"../misc/MiscUtil.js";import{getEvent as Z,INPUT_HANDLING_STATE_GIZMO_SCALE as O,InputManager as A}from"../system/InputManager.js";import{Gizmo as te}from"./Gizmo.js";var t=class t extends te{constructor(){super(...arguments);this.lm=o.zero();this.gm=o.one();this.ym=o.one();this.Rl=!1;this.Nl=!1;this.Vh=this.Nh.bind(this);this.wh=this.Ah.bind(this);this.Xl=this.Yh.bind(this)}static Ml(e){return t.Pl.get(e.objectUID)}get isSetup(){return this.hm!=null}set length(e){t.Ph=e}get length(){return t.Ph}set screenSpaceRatio(e){t.Dl=e}get screenSpaceRatio(){return t.Dl}set isVisible(e){let i=t.Ml(this.i);if(i){if(this.mh===!1&&e===!0){let r=window;if(Q.exist(this.i.config.eventTargetDom)&&(r=this.i.config.eventTargetDom),A.register(O,[{eventName:Z("start"),handler:this.Vh,options:{},classInstance:this,eventTargetDom:r},{eventName:Z("move"),handler:this.wh,options:{},classInstance:this,eventTargetDom:r},{eventName:Z("end"),handler:this.Xl,options:{},classInstance:this,eventTargetDom:r},{eventName:"pointerleave",handler:this.Xl,options:{},classInstance:this,eventTargetDom:r}]),this.hm.getSceneGraph().addChild(i.groupEntity.getSceneGraph()),t.ql=this.pm,t.Yl==="local"){let a=t.Ql,n=this.pm.getSceneGraph();Q.exist(n)?n.getQuaternionRecursivelyTo(a):a.identity(),i.groupEntity.getTransform().localRotation=a}else t.Yl==="world"&&(i.groupEntity.getTransform().localRotation=t.Ql.identity())}this.mh===!0&&e===!1&&(A.unregister(O),this.gm=this.pm.getTransform().localScale,this.lm=o.zero(),this.Rl=!1,this.ym=this.pm.getTransform().localScale,t.xl="none"),A.setActive(O,e),this.uh(e),i.xyPlaneEntity.getSceneGraph().isVisible=!1,i.yzPlaneEntity.getSceneGraph().isVisible=!1,i.zxPlaneEntity.getSceneGraph().isVisible=!1}}setSpace(e){t.Yl=e,this.mh&&(this.isVisible=!1,this.isVisible=!0)}get isVisible(){return this.mh}_setup(){if(this.dm())return;this.hm=J(this.i),this.hm.tryToSetUniqueName(`ScaleGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.pm.getSceneGraph()._addGizmoChild(this.hm.getSceneGraph());let e=t.Ml(this.i);e||(e=this.Dh(),t.Pl.set(this.i.objectUID,e)),this.hm.getSceneGraph().addChild(e.groupEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.xCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.yCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.zCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.xyPlaneEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.yzPlaneEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.zxPlaneEntity.getSceneGraph()),t.ql=this.pm,this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Scale"})}Dh(){let e=C(this.i);e.tryToSetUniqueName("ScaleGizmo_xCube",!0),e.getTransform().localPosition=o.fromCopy3(.5,0,0);let i=new M(this.i),r=T(this.i);r.setParameter("diffuseColorFactor",E.fromCopyArray4([1,0,0,1]));let a=new z(this.i);a.generate({widthVector:o.fromCopy3(1,.05,.05),material:r}),i.addPrimitive(a),e.getMesh().setMesh(i);let n=C(this.i);n.tryToSetUniqueName("ScaleGizmo_yCube",!0),n.getTransform().localPosition=o.fromCopy3(0,.5,0);let u=new M(this.i),p=T(this.i);p.setParameter("diffuseColorFactor",E.fromCopyArray4([0,1,0,1]));let h=new z(this.i);h.generate({widthVector:o.fromCopy3(.05,1,.05),material:p}),u.addPrimitive(h),n.getMesh().setMesh(u);let y=C(this.i);y.tryToSetUniqueName("ScaleGizmo_zCube",!0),y.getTransform().localPosition=o.fromCopy3(0,0,.5);let l=new M(this.i),c=T(this.i);c.setParameter("diffuseColorFactor",E.fromCopyArray4([0,0,1,1]));let d=new z(this.i);d.generate({widthVector:o.fromCopy3(.05,.05,1),material:c}),l.addPrimitive(d),y.getMesh().setMesh(l);let m=C(this.i);m.tryToSetUniqueName("ScaleGizmo_xEdgeCube",!0),m.getTransform().localPosition=o.fromCopy3(.5,0,0);let P=new M(this.i),G=new z(this.i);G.generate({widthVector:o.fromCopy3(.15,.15,.15),material:r}),P.addPrimitive(G),m.getMesh().setMesh(P),e.addChild(m.getSceneGraph());let g=C(this.i);g.tryToSetUniqueName("ScaleGizmo_yEdgeCube",!0),g.getTransform().localPosition=o.fromCopy3(0,.5,0);let s=new M(this.i),f=new z(this.i);f.generate({widthVector:o.fromCopy3(.15,.15,.15),material:p}),s.addPrimitive(f),g.getMesh().setMesh(s),n.addChild(g.getSceneGraph());let v=C(this.i);v.tryToSetUniqueName("ScaleGizmo_zEdgeCube",!0),v.getTransform().localPosition=o.fromCopy3(0,0,.5);let b=new M(this.i),H=new z(this.i);H.generate({widthVector:o.fromCopy3(.15,.15,.15),material:c}),b.addPrimitive(H),v.getMesh().setMesh(b),y.addChild(v.getSceneGraph());let V=C(this.i);V.tryToSetUniqueName("ScaleGizmo_xyPlane",!0),V.getSceneGraph().isVisible=!1,V.getTransform().localEulerAngles=o.fromCopy3(_.degreeToRadian(90),0,0);let N=T(this.i);N.alphaMode=j.Blend,N.setParameter("diffuseColorFactor",E.fromCopyArray4([0,0,.5,0]));let q=new M(this.i),W=new k(this.i);W.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:N}),q.addPrimitive(W),V.getMesh().setMesh(q);let I=C(this.i);I.tryToSetUniqueName("ScaleGizmo_yzPlane",!0),I.getSceneGraph().isVisible=!1,I.getTransform().localEulerAngles=o.fromCopy3(0,0,_.degreeToRadian(90));let U=T(this.i);U.alphaMode=j.Blend,U.setParameter("diffuseColorFactor",E.fromCopyArray4([.5,0,0,0]));let B=new M(this.i),Y=new k(this.i);Y.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:U}),B.addPrimitive(Y),I.getMesh().setMesh(B);let D=C(this.i);D.tryToSetUniqueName("ScaleGizmo_zxPlane",!0),D.getSceneGraph().isVisible=!1;let F=T(this.i);F.setParameter("diffuseColorFactor",E.fromCopyArray4([0,.5,0,0])),F.alphaMode=j.Blend;let $=new M(this.i),X=new k(this.i);return X.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:F}),$.addPrimitive(X),D.getMesh().setMesh($),{groupEntity:J(this.i),xCubeEntity:e,yCubeEntity:n,zCubeEntity:y,xCubeMesh:i,yCubeMesh:u,zCubeMesh:l,xCubePrimitive:a,yCubePrimitive:h,zCubePrimitive:d,xEdgeCubeEntity:m,yEdgeCubeEntity:g,zEdgeCubeEntity:v,xEdgeCubeMesh:P,yEdgeCubeMesh:s,zEdgeCubeMesh:b,xEdgeCubePrimitive:G,yEdgeCubePrimitive:f,zEdgeCubePrimitive:H,xCubeMaterial:r,yCubeMaterial:p,zCubeMaterial:c,xyPlaneEntity:V,yzPlaneEntity:I,zxPlaneEntity:D,xyPlaneMesh:q,yzPlaneMesh:B,zxPlaneMesh:$,xyPlanePrimitive:W,yzPlanePrimitive:Y,zxPlanePrimitive:X,xyPlaneMaterial:N,yzPlaneMaterial:U,zxPlaneMaterial:F}}_update(){if(this.hm==null)return;let e=this.pm.getSceneGraph(),i=e.worldMergedAABBWithSkeletal,r=i.isVanilla()?e.position:i.centerPoint,a=this.hm.getTransform();a.localPosition=r;let n=te.yh(this.i,r,t.Dl);a.localScale=o.fromCopy3(n,n,n),this.lh(),this.Rl&&t.ql===this.pm&&(this.pm.getTransform().localScale=this.gm)}static xh(e){let i=new Float32Array([0,0,0,this.Ph,0,0,0,0,0,0,this.Ph,0,0,0,0,0,0,this.Ph]),r=new Float32Array([1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1]);return ae.createPrimitive(e,{attributeSemantics:[K.Position.XYZ,K.Color0.XYZ],attributes:[i,r],primitiveMode:re.Lines})}Nh(e){this.Rl=!0,t.xl="none",t.K=e.clientX,t.Z=e.clientY;let i=this.pm.getSceneGraph().matrix.getRotate(),r=o.one(),a=w.fromCopy9RowMajor(r.x*i.m00,r.x*i.m01,r.x*i.m02,r.y*i.m10,r.y*i.m11,r.y*i.m12,r.z*i.m20,r.z*i.m21,r.z*i.m22);t.Yl==="local"?a=w.transpose(a):t.Yl==="world"&&(a=ee.identity());let{xResult:n,yResult:u,zResult:p}=t.castRay(this.i,e),h=!1;if(n.result&&(R(n.data),this.lm=a.multiplyVector(n.data.position.clone()),x.default.debug(`Down:${this.lm.toStringApproximately()}`),t.xl="x",h=!0),u.result&&(R(u.data),this.lm=a.multiplyVector(u.data.position.clone()),x.default.debug(`Down:${this.lm.toStringApproximately()}`),t.xl="y",h=!0),p.result&&(R(p.data),this.lm=a.multiplyVector(p.data.position.clone()),x.default.debug(`Down:${this.lm.toStringApproximately()}`),t.xl="z",h=!0),t.xl==="none"||h===!1){this.Rl=!1;return}e.preventDefault(),this.Hh(),t.ql===this.pm&&(this.ym=this.pm.getTransform().localScale)}Ah(e){if(e.preventDefault(),Q.false(this.Rl))return;let i=t.Ml(this.i);if(!i)return;let r=e.target.getBoundingClientRect(),a=e.target.clientWidth,n=e.target.clientHeight,u=e.clientX-r.left,p=r.height-(e.clientY-r.top),h=E.fromCopy4(0,0,a,n),y=this.i.componentRepository.getComponent(S,S.getCurrent(this.i)),l=this.pm.getSceneGraph().matrix.getRotate(),c=o.one(),d=w.fromCopy9RowMajor(c.x*l.m00,c.x*l.m01,c.x*l.m02,c.y*l.m10,c.y*l.m11,c.y*l.m12,c.z*l.m20,c.z*l.m21,c.z*l.m22);t.Yl==="local"?d=w.transpose(d):t.Yl==="world"&&(d=ee.identity());let m=this.lm.clone();if(t.xl==="x"){let s=i.xyPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(f.x,m.y,m.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}if(t.xl==="y"){let s=i.xyPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(m.x,f.y,m.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}if(t.xl==="z"){let s=i.yzPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(m.x,m.y,f.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}let G=this.pm.getSceneGraph().worldMergedAABBWithSkeletal,g=o.multiplyTo(o.subtractTo(m,this.lm,t.tr),1/G.lengthCenterToCorner,t.Ze);if(x.default.debug(`${this.pm.uniqueName}: ${g.toStringApproximately()}`),t.Yl==="local")this.gm=t.$e.setComponents(Math.max(this.ym.x+g.x,.01),Math.max(this.ym.y+g.y,.01),Math.max(this.ym.z+g.z,.01));else if(t.Yl==="world"){let s=this.pm.getSceneGraph().getQuaternionRecursivelyTo(t.Ql),f=w.fromCopyQuaternion(s),b=w.transpose(f).multiplyVectorTo(g,t.$e);this.gm=t.Jh.setComponents(Math.max(this.ym.x+b.x,.01),Math.max(this.ym.y+b.y,.01),Math.max(this.ym.z+b.z,.01))}this._update()}Yh(e){e.preventDefault(),this.Rl=!1,t.xl="none",this.Oh(),t.ql===this.pm&&(this.ym=this.pm.getTransform().localScale)}Hh(){this.Nl||(A.disableCameraController(),this.Nl=!0)}Oh(){this.Nl&&(A.enableCameraController(),this.Nl=!1)}static castRay2(e,i){let r=t.Ml(e);if(!r)return{result:!1};let a=i.target.getBoundingClientRect(),n=i.target.clientWidth,u=i.target.clientHeight,p=i.clientX-a.left,h=a.height-(i.clientY-a.top),y=E.fromCopy4(0,0,n,u),l=e.componentRepository.getComponent(S,S.getCurrent(e));return r.groupEntity.getSceneGraph().castRayFromScreen(p,h,l,y,0,[])}static castRay(e,i){let r=t.Ml(e),a={result:!1};if(!r)return{xResult:a,yResult:a,zResult:a};let n=i.target.getBoundingClientRect(),u=i.target.clientWidth,p=i.target.clientHeight,h=i.clientX-n.left,y=n.height-(i.clientY-n.top),l=E.fromCopy4(0,0,u,p),c=e.componentRepository.getComponent(S,S.getCurrent(e)),d=r.xCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0),m=r.yCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0),P=r.zCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0);return{xResult:d,yResult:m,zResult:P}}_destroy(){this.um()}static _cleanupForEngine(e){t.Pl.delete(e.objectUID),t.xl="none"}};t.Pl=new Map,t.K=0,t.Z=0,t.xl="none",t.Yl="world",t.Ph=1,t.Dl=.12,t.Ql=oe.identity(),t.tr=L.zero(),t.Ze=L.zero(),t.$e=L.zero(),t.Jh=L.zero();var ie=t;export{ie as ScaleGizmo};
1
+ import{CameraComponent as S}from"../components/Camera/CameraComponent.js";import{createMeshEntity as C}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as J}from"../components/SceneGraph/createGroupEntity.js";import{AlphaMode as j}from"../definitions/AlphaMode.js";import{PrimitiveMode as re}from"../definitions/PrimitiveMode.js";import{VertexAttribute as K}from"../definitions/VertexAttribute.js";import{Mesh as M}from"../geometry/Mesh.js";import{Primitive as ae}from"../geometry/Primitive.js";import{Cube as z}from"../geometry/shapes/Cube.js";import{Plane as k}from"../geometry/shapes/Plane.js";import{createClassicUberMaterial as T}from"../helpers/materials/createClassicUberMaterial.js";import{MathUtil as _}from"../math/MathUtil.js";import{Matrix33 as w}from"../math/Matrix33.js";import{MutableMatrix33 as ee}from"../math/MutableMatrix33.js";import{MutableQuaternion as oe}from"../math/MutableQuaternion.js";import{MutableVector3 as L}from"../math/MutableVector3.js";import{Vector3 as o}from"../math/Vector3.js";import{Vector4 as E}from"../math/Vector4.js";import{Is as Q}from"../misc/Is.js";import{Logger as x}from"../misc/Logger.js";import{assertExist as R}from"../misc/MiscUtil.js";import{getEvent as Z,INPUT_HANDLING_STATE_GIZMO_SCALE as O,InputManager as A}from"../system/InputManager.js";import{Gizmo as te}from"./Gizmo.js";var t=class t extends te{constructor(){super(...arguments);this.Gm=o.zero();this.Hm=o.one();this.Um=o.one();this.Ml=!1;this.Vl=!1;this.Kh=this._h.bind(this);this.vm=this.xm.bind(this);this.Ql=this.Cm.bind(this)}static Cl(e){return t.Pl.get(e.objectUID)}get isSetup(){return this.dm!=null}set length(e){t.kh=e}get length(){return t.kh}set screenSpaceRatio(e){t.Lh=e}get screenSpaceRatio(){return t.Lh}set isVisible(e){let i=t.Cl(this.i);if(i){if(this.lh===!1&&e===!0){let r=window;if(Q.exist(this.i.config.eventTargetDom)&&(r=this.i.config.eventTargetDom),A.register(O,[{eventName:Z("start"),handler:this.Kh,options:{},classInstance:this,eventTargetDom:r},{eventName:Z("move"),handler:this.vm,options:{},classInstance:this,eventTargetDom:r},{eventName:Z("end"),handler:this.Ql,options:{},classInstance:this,eventTargetDom:r},{eventName:"pointerleave",handler:this.Ql,options:{},classInstance:this,eventTargetDom:r}]),this.dm.getSceneGraph().addChild(i.groupEntity.getSceneGraph()),t.Fl=this.um,t.Yl==="local"){let a=t.Hl,n=this.um.getSceneGraph();Q.exist(n)?n.getQuaternionRecursivelyTo(a):a.identity(),i.groupEntity.getTransform().localRotation=a}else t.Yl==="world"&&(i.groupEntity.getTransform().localRotation=t.Hl.identity())}this.lh===!0&&e===!1&&(A.unregister(O),this.Hm=this.um.getTransform().localScale,this.Gm=o.zero(),this.Ml=!1,this.Um=this.um.getTransform().localScale,t.vl="none"),A.setActive(O,e),this.yh(e),i.xyPlaneEntity.getSceneGraph().isVisible=!1,i.yzPlaneEntity.getSceneGraph().isVisible=!1,i.zxPlaneEntity.getSceneGraph().isVisible=!1}}setSpace(e){t.Yl=e,this.lh&&(this.isVisible=!1,this.isVisible=!0)}get isVisible(){return this.lh}_setup(){if(this.lm())return;this.dm=J(this.i),this.dm.tryToSetUniqueName(`ScaleGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.um.getSceneGraph()._addGizmoChild(this.dm.getSceneGraph());let e=t.Cl(this.i);e||(e=this.Mm(),t.Pl.set(this.i.objectUID,e)),this.dm.getSceneGraph().addChild(e.groupEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.xCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.yCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.zCubeEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.xyPlaneEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.yzPlaneEntity.getSceneGraph()),e.groupEntity.getSceneGraph().addChild(e.zxPlaneEntity.getSceneGraph()),t.Fl=this.um,this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Scale"})}Mm(){let e=C(this.i);e.tryToSetUniqueName("ScaleGizmo_xCube",!0),e.getTransform().localPosition=o.fromCopy3(.5,0,0);let i=new M(this.i),r=T(this.i);r.setParameter("diffuseColorFactor",E.fromCopyArray4([1,0,0,1]));let a=new z(this.i);a.generate({widthVector:o.fromCopy3(1,.05,.05),material:r}),i.addPrimitive(a),e.getMesh().setMesh(i);let n=C(this.i);n.tryToSetUniqueName("ScaleGizmo_yCube",!0),n.getTransform().localPosition=o.fromCopy3(0,.5,0);let u=new M(this.i),p=T(this.i);p.setParameter("diffuseColorFactor",E.fromCopyArray4([0,1,0,1]));let h=new z(this.i);h.generate({widthVector:o.fromCopy3(.05,1,.05),material:p}),u.addPrimitive(h),n.getMesh().setMesh(u);let y=C(this.i);y.tryToSetUniqueName("ScaleGizmo_zCube",!0),y.getTransform().localPosition=o.fromCopy3(0,0,.5);let l=new M(this.i),c=T(this.i);c.setParameter("diffuseColorFactor",E.fromCopyArray4([0,0,1,1]));let d=new z(this.i);d.generate({widthVector:o.fromCopy3(.05,.05,1),material:c}),l.addPrimitive(d),y.getMesh().setMesh(l);let m=C(this.i);m.tryToSetUniqueName("ScaleGizmo_xEdgeCube",!0),m.getTransform().localPosition=o.fromCopy3(.5,0,0);let P=new M(this.i),G=new z(this.i);G.generate({widthVector:o.fromCopy3(.15,.15,.15),material:r}),P.addPrimitive(G),m.getMesh().setMesh(P),e.addChild(m.getSceneGraph());let g=C(this.i);g.tryToSetUniqueName("ScaleGizmo_yEdgeCube",!0),g.getTransform().localPosition=o.fromCopy3(0,.5,0);let s=new M(this.i),f=new z(this.i);f.generate({widthVector:o.fromCopy3(.15,.15,.15),material:p}),s.addPrimitive(f),g.getMesh().setMesh(s),n.addChild(g.getSceneGraph());let v=C(this.i);v.tryToSetUniqueName("ScaleGizmo_zEdgeCube",!0),v.getTransform().localPosition=o.fromCopy3(0,0,.5);let b=new M(this.i),H=new z(this.i);H.generate({widthVector:o.fromCopy3(.15,.15,.15),material:c}),b.addPrimitive(H),v.getMesh().setMesh(b),y.addChild(v.getSceneGraph());let V=C(this.i);V.tryToSetUniqueName("ScaleGizmo_xyPlane",!0),V.getSceneGraph().isVisible=!1,V.getTransform().localEulerAngles=o.fromCopy3(_.degreeToRadian(90),0,0);let N=T(this.i);N.alphaMode=j.Blend,N.setParameter("diffuseColorFactor",E.fromCopyArray4([0,0,.5,0]));let q=new M(this.i),W=new k(this.i);W.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:N}),q.addPrimitive(W),V.getMesh().setMesh(q);let I=C(this.i);I.tryToSetUniqueName("ScaleGizmo_yzPlane",!0),I.getSceneGraph().isVisible=!1,I.getTransform().localEulerAngles=o.fromCopy3(0,0,_.degreeToRadian(90));let U=T(this.i);U.alphaMode=j.Blend,U.setParameter("diffuseColorFactor",E.fromCopyArray4([.5,0,0,0]));let B=new M(this.i),Y=new k(this.i);Y.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:U}),B.addPrimitive(Y),I.getMesh().setMesh(B);let D=C(this.i);D.tryToSetUniqueName("ScaleGizmo_zxPlane",!0),D.getSceneGraph().isVisible=!1;let F=T(this.i);F.setParameter("diffuseColorFactor",E.fromCopyArray4([0,.5,0,0])),F.alphaMode=j.Blend;let $=new M(this.i),X=new k(this.i);return X.generate({width:1e5,height:1e5,uSpan:1,vSpan:1,isUVRepeat:!0,flipTextureCoordinateY:!1,material:F}),$.addPrimitive(X),D.getMesh().setMesh($),{groupEntity:J(this.i),xCubeEntity:e,yCubeEntity:n,zCubeEntity:y,xCubeMesh:i,yCubeMesh:u,zCubeMesh:l,xCubePrimitive:a,yCubePrimitive:h,zCubePrimitive:d,xEdgeCubeEntity:m,yEdgeCubeEntity:g,zEdgeCubeEntity:v,xEdgeCubeMesh:P,yEdgeCubeMesh:s,zEdgeCubeMesh:b,xEdgeCubePrimitive:G,yEdgeCubePrimitive:f,zEdgeCubePrimitive:H,xCubeMaterial:r,yCubeMaterial:p,zCubeMaterial:c,xyPlaneEntity:V,yzPlaneEntity:I,zxPlaneEntity:D,xyPlaneMesh:q,yzPlaneMesh:B,zxPlaneMesh:$,xyPlanePrimitive:W,yzPlanePrimitive:Y,zxPlanePrimitive:X,xyPlaneMaterial:N,yzPlaneMaterial:U,zxPlaneMaterial:F}}_update(){if(this.dm==null)return;let e=this.um.getSceneGraph(),i=e.worldMergedAABBWithSkeletal,r=i.isVanilla()?e.position:i.centerPoint,a=this.dm.getTransform();a.localPosition=r;let n=te.gh(this.i,r,t.Lh);a.localScale=o.fromCopy3(n,n,n),this.fh(),this.Ml&&t.Fl===this.um&&(this.um.getTransform().localScale=this.Hm)}static fm(e){let i=new Float32Array([0,0,0,this.kh,0,0,0,0,0,0,this.kh,0,0,0,0,0,0,this.kh]),r=new Float32Array([1,0,0,1,0,0,0,1,0,0,1,0,0,0,1,0,0,1]);return ae.createPrimitive(e,{attributeSemantics:[K.Position.XYZ,K.Color0.XYZ],attributes:[i,r],primitiveMode:re.Lines})}_h(e){this.Ml=!0,t.vl="none",t.K=e.clientX,t.Z=e.clientY;let i=this.um.getSceneGraph().matrix.getRotate(),r=o.one(),a=w.fromCopy9RowMajor(r.x*i.m00,r.x*i.m01,r.x*i.m02,r.y*i.m10,r.y*i.m11,r.y*i.m12,r.z*i.m20,r.z*i.m21,r.z*i.m22);t.Yl==="local"?a=w.transpose(a):t.Yl==="world"&&(a=ee.identity());let{xResult:n,yResult:u,zResult:p}=t.castRay(this.i,e),h=!1;if(n.result&&(R(n.data),this.Gm=a.multiplyVector(n.data.position.clone()),x.default.debug(`Down:${this.Gm.toStringApproximately()}`),t.vl="x",h=!0),u.result&&(R(u.data),this.Gm=a.multiplyVector(u.data.position.clone()),x.default.debug(`Down:${this.Gm.toStringApproximately()}`),t.vl="y",h=!0),p.result&&(R(p.data),this.Gm=a.multiplyVector(p.data.position.clone()),x.default.debug(`Down:${this.Gm.toStringApproximately()}`),t.vl="z",h=!0),t.vl==="none"||h===!1){this.Ml=!1;return}e.preventDefault(),this.Tm(),t.Fl===this.um&&(this.Um=this.um.getTransform().localScale)}xm(e){if(e.preventDefault(),Q.false(this.Ml))return;let i=t.Cl(this.i);if(!i)return;let r=e.target.getBoundingClientRect(),a=e.target.clientWidth,n=e.target.clientHeight,u=e.clientX-r.left,p=r.height-(e.clientY-r.top),h=E.fromCopy4(0,0,a,n),y=this.i.componentRepository.getComponent(S,S.getCurrent(this.i)),l=this.um.getSceneGraph().matrix.getRotate(),c=o.one(),d=w.fromCopy9RowMajor(c.x*l.m00,c.x*l.m01,c.x*l.m02,c.y*l.m10,c.y*l.m11,c.y*l.m12,c.z*l.m20,c.z*l.m21,c.z*l.m22);t.Yl==="local"?d=w.transpose(d):t.Yl==="world"&&(d=ee.identity());let m=this.Gm.clone();if(t.vl==="x"){let s=i.xyPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(f.x,m.y,m.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}if(t.vl==="y"){let s=i.xyPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(m.x,f.y,m.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}if(t.vl==="z"){let s=i.yzPlaneEntity.getMesh().castRayFromScreenInWorld(u,p,y,h,0);if(s.result){R(s.data);let f=d.multiplyVector(s.data.position);m=o.fromCopy3(m.x,m.y,f.z),x.default.debug(`Move:${s.data.position.toStringApproximately()}`)}}let G=this.um.getSceneGraph().worldMergedAABBWithSkeletal,g=o.multiplyTo(o.subtractTo(m,this.Gm,t.tr),1/G.lengthCenterToCorner,t.Ze);if(x.default.debug(`${this.um.uniqueName}: ${g.toStringApproximately()}`),t.Yl==="local")this.Hm=t.$e.setComponents(Math.max(this.Um.x+g.x,.01),Math.max(this.Um.y+g.y,.01),Math.max(this.Um.z+g.z,.01));else if(t.Yl==="world"){let s=this.um.getSceneGraph().getQuaternionRecursivelyTo(t.Hl),f=w.fromCopyQuaternion(s),b=w.transpose(f).multiplyVectorTo(g,t.$e);this.Hm=t.Fm.setComponents(Math.max(this.Um.x+b.x,.01),Math.max(this.Um.y+b.y,.01),Math.max(this.Um.z+b.z,.01))}this._update()}Cm(e){e.preventDefault(),this.Ml=!1,t.vl="none",this.zm(),t.Fl===this.um&&(this.Um=this.um.getTransform().localScale)}Tm(){this.Vl||(A.disableCameraController(),this.Vl=!0)}zm(){this.Vl&&(A.enableCameraController(),this.Vl=!1)}static castRay2(e,i){let r=t.Cl(e);if(!r)return{result:!1};let a=i.target.getBoundingClientRect(),n=i.target.clientWidth,u=i.target.clientHeight,p=i.clientX-a.left,h=a.height-(i.clientY-a.top),y=E.fromCopy4(0,0,n,u),l=e.componentRepository.getComponent(S,S.getCurrent(e));return r.groupEntity.getSceneGraph().castRayFromScreen(p,h,l,y,0,[])}static castRay(e,i){let r=t.Cl(e),a={result:!1};if(!r)return{xResult:a,yResult:a,zResult:a};let n=i.target.getBoundingClientRect(),u=i.target.clientWidth,p=i.target.clientHeight,h=i.clientX-n.left,y=n.height-(i.clientY-n.top),l=E.fromCopy4(0,0,u,p),c=e.componentRepository.getComponent(S,S.getCurrent(e)),d=r.xCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0),m=r.yCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0),P=r.zCubeEntity.getSceneGraph().castRayFromScreen(h,y,c,l,0);return{xResult:d,yResult:m,zResult:P}}_destroy(){this.gm()}static _cleanupForEngine(e){t.Pl.delete(e.objectUID),t.vl="none"}};t.Pl=new Map,t.K=0,t.Z=0,t.vl="none",t.Yl="world",t.kh=1,t.Lh=.12,t.Hl=oe.identity(),t.tr=L.zero(),t.Ze=L.zero(),t.$e=L.zero(),t.Fm=L.zero();var ie=t;export{ie as ScaleGizmo};
@@ -1 +1 @@
1
- import{createGroupEntity as p}from"../components/SceneGraph/createGroupEntity.js";import{MeshHelper as s}from"../helpers/MeshHelperObject.js";import{createPbrUberMaterial as d}from"../helpers/materials/createPbrUberMaterial.js";import{Vector3 as h}from"../math/Vector3.js";import{Vector4 as u}from"../math/Vector4.js";import{Is as m}from"../misc/Is.js";import{Gizmo as l}from"./Gizmo.js";var c=class extends l{constructor(e,r){super(e,r.entity);this.ed=[];this.id=r}get isSetup(){return m.exist(this.hm)}get topEntity(){return this.hm}_setup(){this.dm()||(this.hm=p(this.i),this.hm.tryToSetUniqueName(`ShapeGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.pm.getSceneGraph()._addGizmoChild(this.hm.getSceneGraph()),this.kp=d(this.i,{isLighting:!1,isSkinning:!1,isMorphing:!1,maxInstancesNumber:1}),this.kp.addShaderDefine("RN_USE_WIREFRAME"),this.kp.setParameter("wireframe",h.fromCopy3(1,0,1)),this.kp.setParameter("baseColorFactor",u.fromCopy4(0,1,0,1)),this.rd(),this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"Shape"}),this._update(),this.uh(this.isVisible))}_update(){if(this.hm==null)return;let e=this.pm.getSceneGraph();this.pm.getTransform().$logic(),e.logicForce(),this.hm.getTransform().localMatrixWithoutPhysics=e.matrixInner}rebuild(){if(!(!this.isSetup||this.kp==null)){for(let e of this.ed)this.i.entityRepository.deleteEntityRecursively(e.entityUID);this.ed.length=0,this.rd(),this.uh(this.isVisible)}}_destroy(){this.um(),this.ed.length=0,this.kp=void 0}rd(){for(let[e,r]of this.id._getShapeEntries())this.od(r,e,this.kp)}od(e,r,o){let i=p(this.i);i.tryToSetUniqueName(`ShapeGizmo_${r}_of_${this.pm.uniqueName}`,!0),i.localPosition=e.localPosition,i.localRotation=e.localRotation,this.hm.addChild(i.getSceneGraph()),this.ed.push(i);let t=e.shape;if(t.type==="box")this.td(i,s.createCube(this.i,{widthVector:t.size,material:o}));else if(t.type==="sphere")this.td(i,s.createSphere(this.i,{radius:t.radius,material:o}));else if(t.type==="cylinder")this.td(i,s.createCylinder(this.i,{height:t.height,radiusBottom:t.radiusBottom,radiusTop:t.radiusTop,material:o}));else if(t.radiusBottom===t.radiusTop)this.td(i,s.createCapsule(this.i,{height:t.height,radius:t.radiusBottom,material:o}));else{this.td(i,s.createCylinder(this.i,{height:t.height,radiusBottom:t.radiusBottom,radiusTop:t.radiusTop,material:o}));let a=s.createSphere(this.i,{radius:t.radiusBottom,material:o});a.localPosition=h.fromCopy3(0,-t.height/2,0),this.td(i,a);let n=s.createSphere(this.i,{radius:t.radiusTop,material:o});n.localPosition=h.fromCopy3(0,t.height/2,0),this.td(i,n)}}td(e,r){r.getMesh().calcBaryCentricCoord(),r.tryToSetTag({tag:"Gizmo",value:"Shape"}),e.addChild(r.getSceneGraph())}};export{c as ShapeGizmo};
1
+ import{createGroupEntity as p}from"../components/SceneGraph/createGroupEntity.js";import{MeshHelper as s}from"../helpers/MeshHelperObject.js";import{createPbrUberMaterial as d}from"../helpers/materials/createPbrUberMaterial.js";import{Vector3 as h}from"../math/Vector3.js";import{Vector4 as u}from"../math/Vector4.js";import{Is as m}from"../misc/Is.js";import{Gizmo as l}from"./Gizmo.js";var c=class extends l{constructor(e,r){super(e,r.entity);this.ed=[];this.id=r}get isSetup(){return m.exist(this.dm)}get topEntity(){return this.dm}_setup(){this.lm()||(this.dm=p(this.i),this.dm.tryToSetUniqueName(`ShapeGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,this.um.getSceneGraph()._addGizmoChild(this.dm.getSceneGraph()),this.kp=d(this.i,{isLighting:!1,isSkinning:!1,isMorphing:!1,maxInstancesNumber:1}),this.kp.addShaderDefine("RN_USE_WIREFRAME"),this.kp.setParameter("wireframe",h.fromCopy3(1,0,1)),this.kp.setParameter("baseColorFactor",u.fromCopy4(0,1,0,1)),this.rd(),this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"Shape"}),this._update(),this.yh(this.isVisible))}_update(){if(this.dm==null)return;let e=this.um.getSceneGraph();this.um.getTransform().$logic(),e.logicForce(),this.dm.getTransform().localMatrixWithoutPhysics=e.matrixInner}rebuild(){if(!(!this.isSetup||this.kp==null)){for(let e of this.ed)this.i.entityRepository.deleteEntityRecursively(e.entityUID);this.ed.length=0,this.rd(),this.yh(this.isVisible)}}_destroy(){this.gm(),this.ed.length=0,this.kp=void 0}rd(){for(let[e,r]of this.id._getShapeEntries())this.od(r,e,this.kp)}od(e,r,o){let i=p(this.i);i.tryToSetUniqueName(`ShapeGizmo_${r}_of_${this.um.uniqueName}`,!0),i.localPosition=e.localPosition,i.localRotation=e.localRotation,this.dm.addChild(i.getSceneGraph()),this.ed.push(i);let t=e.shape;if(t.type==="box")this.td(i,s.createCube(this.i,{widthVector:t.size,material:o}));else if(t.type==="sphere")this.td(i,s.createSphere(this.i,{radius:t.radius,material:o}));else if(t.type==="cylinder")this.td(i,s.createCylinder(this.i,{height:t.height,radiusBottom:t.radiusBottom,radiusTop:t.radiusTop,material:o}));else if(t.radiusBottom===t.radiusTop)this.td(i,s.createCapsule(this.i,{height:t.height,radius:t.radiusBottom,material:o}));else{this.td(i,s.createCylinder(this.i,{height:t.height,radiusBottom:t.radiusBottom,radiusTop:t.radiusTop,material:o}));let a=s.createSphere(this.i,{radius:t.radiusBottom,material:o});a.localPosition=h.fromCopy3(0,-t.height/2,0),this.td(i,a);let n=s.createSphere(this.i,{radius:t.radiusTop,material:o});n.localPosition=h.fromCopy3(0,t.height/2,0),this.td(i,n)}}td(e,r){r.getMesh().calcBaryCentricCoord(),r.tryToSetTag({tag:"Gizmo",value:"Shape"}),e.addChild(r.getSceneGraph())}};export{c as ShapeGizmo};
@@ -1 +1 @@
1
- import{createMeshEntity as p}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as m}from"../components/SceneGraph/createGroupEntity.js";import{Mesh as c}from"../geometry/Mesh.js";import{Sphere as l}from"../geometry/shapes/Sphere.js";import{createPbrUberMaterial as d}from"../helpers/materials/createPbrUberMaterial.js";import{Vector3 as h}from"../math/Vector3.js";import{Vector4 as S}from"../math/Vector4.js";import{Is as s}from"../misc/Is.js";import{Gizmo as u}from"./Gizmo.js";var i=class i extends u{constructor(e,r){super(e,r.baseSceneGraph.entity),this.fm=r}get isSetup(){return s.exist(this.hm)}_setup(){if(this.dm())return;let e=this.pm.getSceneGraph();if(!e)return;this.hm=m(this.i),this.hm.tryToSetUniqueName(`SphereColliderGizmo_of_${this.pm.uniqueName}`,!0),this.hm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,e._addGizmoChild(this.hm.getSceneGraph());let r=i.bh(this.i),t=p(this.i);t.tryToSetUniqueName(`SphereColliderGizmo_sphere_${this.pm.uniqueName}`,!0),t.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t.getMesh().setMesh(r),t.tryToSetTag({tag:"Gizmo",value:"SphereCollider"}),this.hm.getSceneGraph().addChild(t.getSceneGraph()),this.Sm=t,this.setGizmoTag(),this.hm.tryToSetTag({tag:"Gizmo",value:"SphereCollider"}),this._update()}_update(){if(!s.exist(this.hm)||!s.exist(this.Sm))return;this.Sm.position=this.fm.worldPosition;let e=this.fm.radius;this.Sm.localScale=h.fromCopy3(e,e,e)}_destroy(){this.um(),this.Sm=void 0}static bh(e){let r=e.objectUID,t=i.fh.get(r);if(!t){let o=d(e,{isLighting:!1,isSkinning:!1,isMorphing:!1});o.addShaderDefine("RN_USE_WIREFRAME"),o.setParameter("wireframe",h.fromCopy3(1,0,1)),o.setParameter("baseColorFactor",S.fromCopy4(0,1,0,1)),t=new c(e);let a=new l(e);a.generate({radius:1,widthSegments:16,heightSegments:12,material:o}),t.addPrimitive(a),t._calcBaryCentricCoord(),i.fh.set(r,t)}return t}get sphereCollider(){return this.fm}};i.fh=new Map;var n=i;export{n as SphereColliderGizmo};
1
+ import{createMeshEntity as p}from"../components/MeshRenderer/createMeshEntity.js";import{createGroupEntity as m}from"../components/SceneGraph/createGroupEntity.js";import{Mesh as c}from"../geometry/Mesh.js";import{Sphere as l}from"../geometry/shapes/Sphere.js";import{createPbrUberMaterial as d}from"../helpers/materials/createPbrUberMaterial.js";import{Vector3 as h}from"../math/Vector3.js";import{Vector4 as S}from"../math/Vector4.js";import{Is as s}from"../misc/Is.js";import{Gizmo as u}from"./Gizmo.js";var i=class i extends u{constructor(e,r){super(e,r.baseSceneGraph.entity),this.jm=r}get isSetup(){return s.exist(this.dm)}_setup(){if(this.lm())return;let e=this.um.getSceneGraph();if(!e)return;this.dm=m(this.i),this.dm.tryToSetUniqueName(`SphereColliderGizmo_of_${this.um.uniqueName}`,!0),this.dm.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,e._addGizmoChild(this.dm.getSceneGraph());let r=i.Ph(this.i),t=p(this.i);t.tryToSetUniqueName(`SphereColliderGizmo_sphere_${this.um.uniqueName}`,!0),t.getSceneGraph().toMakeWorldMatrixTheSameAsLocalMatrix=!0,t.getMesh().setMesh(r),t.tryToSetTag({tag:"Gizmo",value:"SphereCollider"}),this.dm.getSceneGraph().addChild(t.getSceneGraph()),this._m=t,this.setGizmoTag(),this.dm.tryToSetTag({tag:"Gizmo",value:"SphereCollider"}),this._update()}_update(){if(!s.exist(this.dm)||!s.exist(this._m))return;this._m.position=this.jm.worldPosition;let e=this.jm.radius;this._m.localScale=h.fromCopy3(e,e,e)}_destroy(){this.gm(),this._m=void 0}static Ph(e){let r=e.objectUID,t=i.Sh.get(r);if(!t){let o=d(e,{isLighting:!1,isSkinning:!1,isMorphing:!1});o.addShaderDefine("RN_USE_WIREFRAME"),o.setParameter("wireframe",h.fromCopy3(1,0,1)),o.setParameter("baseColorFactor",S.fromCopy4(0,1,0,1)),t=new c(e);let a=new l(e);a.generate({radius:1,widthSegments:16,heightSegments:12,material:o}),t.addPrimitive(a),t._calcBaryCentricCoord(),i.Sh.set(r,t)}return t}get sphereCollider(){return this.jm}};i.Sh=new Map;var n=i;export{n as SphereColliderGizmo};