rhodonite 0.26.0 → 0.27.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (370) hide show
  1. package/VERSION-FILE +1 -1
  2. package/dist/esm/foundation/core/MemoryManager.d.ts +19 -0
  3. package/dist/esm/foundation/core/MemoryManager.js +2 -2
  4. package/dist/esm/foundation/definitions/ShaderSemantics.d.ts +1 -0
  5. package/dist/esm/foundation/definitions/ShaderSemantics.js +2 -2
  6. package/dist/esm/foundation/helpers/Shadow/ShadowSystem.js +1 -1
  7. package/dist/esm/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +1 -1
  8. package/dist/esm/foundation/helpers/materials/nodeBasedMaterialCommon.js +1 -1
  9. package/dist/esm/foundation/importer/DrcPointCloudImporter.js +1 -1
  10. package/dist/esm/foundation/importer/Gltf2Importer.d.ts +2 -1
  11. package/dist/esm/foundation/importer/Gltf2Importer.js +1 -1
  12. package/dist/esm/foundation/importer/GltfImporter.js +1 -1
  13. package/dist/esm/foundation/importer/RhodoniteImportExtension.js +1 -1
  14. package/dist/esm/foundation/importer/Vrm0xImporter.js +1 -1
  15. package/dist/esm/foundation/importer/VrmImporter.js +1 -1
  16. package/dist/esm/foundation/materials/contents/CustomMaterialContent.js +1 -1
  17. package/dist/esm/foundation/materials/contents/MToon0xMaterialContent.js +11 -11
  18. package/dist/esm/foundation/materials/contents/MToon1MaterialContent.js +6 -6
  19. package/dist/esm/foundation/materials/core/AbstractMaterialContent.js +1 -1
  20. package/dist/esm/foundation/materials/core/Material.d.ts +7 -2
  21. package/dist/esm/foundation/materials/core/Material.js +1 -1
  22. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGL.js +2 -2
  23. package/dist/esm/foundation/materials/core/ShaderityUtilityWebGPU.js +2 -2
  24. package/dist/esm/foundation/memory/Accessor.js +6 -6
  25. package/dist/esm/foundation/memory/BufferView.js +1 -1
  26. package/dist/esm/foundation/misc/PngDecoder.d.ts +18 -0
  27. package/dist/esm/foundation/misc/PngDecoder.js +1 -0
  28. package/dist/esm/foundation/renderer/RenderPass.d.ts +7 -0
  29. package/dist/esm/foundation/renderer/RenderPass.js +1 -1
  30. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +2 -1
  31. package/dist/esm/foundation/renderer/pipelines/ForwardRenderPipeline.js +1 -1
  32. package/dist/esm/foundation/system/Engine.js +1 -1
  33. package/dist/esm/foundation/textures/CubeTexture.d.ts +11 -2
  34. package/dist/esm/foundation/textures/CubeTexture.js +1 -1
  35. package/dist/esm/foundation/textures/RenderTargetTexture2DArray.js +1 -1
  36. package/dist/esm/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
  37. package/dist/esm/foundation/textures/RenderTargetTextureCube.js +1 -1
  38. package/dist/esm/version.js +1 -1
  39. package/dist/esm/webgl/MultiDraw.js +1 -1
  40. package/dist/esm/webgl/MultiDrawRepository.js +1 -1
  41. package/dist/esm/webgl/WebGLResourceRepository.d.ts +5 -0
  42. package/dist/esm/webgl/WebGLResourceRepository.js +3 -3
  43. package/dist/esm/webgl/WebGLStereoUtil.js +1 -1
  44. package/dist/esm/webgl/WebGLStrategyWebGL2.d.ts +19 -14
  45. package/dist/esm/webgl/WebGLStrategyWebGL2.js +67 -67
  46. package/dist/esm/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +2 -1
  47. package/dist/esm/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +1 -0
  48. package/dist/esm/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -0
  49. package/dist/esm/webgl/shaderity_shaders/common/iblDefinition.glsl.js +11 -5
  50. package/dist/esm/webgl/shaders/nodes/BlockBeginShader.js +1 -1
  51. package/dist/esm/webgl/shaders/nodes/BlockEndShader.js +1 -1
  52. package/dist/esm/webgl/shaders/nodes/ConstantVariableShader.js +5 -5
  53. package/dist/esm/webgl/shaders/nodes/RaymarchObjectIdUniform.js +3 -3
  54. package/dist/esm/webgl/shaders/nodes/SdApplyWorldMatrix.js +3 -3
  55. package/dist/esm/webgl/shaders/nodes/Texture2DShader.js +14 -14
  56. package/dist/esm/webgl/shaders/nodes/UniformDataShader.js +13 -13
  57. package/dist/esm/webgpu/GpuCullingRegistry.js +1 -1
  58. package/dist/esm/webgpu/GpuDeformRegistry.js +1 -1
  59. package/dist/esm/webgpu/WebGpuGpuTimer.js +1 -1
  60. package/dist/esm/webgpu/WebGpuResourceRepository.d.ts +6 -0
  61. package/dist/esm/webgpu/WebGpuResourceRepository.js +5 -5
  62. package/dist/esm/webgpu/WebGpuStrategyBasic.js +2 -2
  63. package/dist/esm/webgpu/WebGpuVertexDeformer.js +1 -1
  64. package/dist/esm/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +1 -0
  65. package/dist/esm/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +1 -0
  66. package/dist/esm/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +1 -0
  67. package/dist/esm/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +10 -4
  68. package/dist/esmdev/foundation/core/MemoryManager.d.ts +19 -0
  69. package/dist/esmdev/foundation/core/MemoryManager.js +28 -3
  70. package/dist/esmdev/foundation/core/RnObject.js +37 -37
  71. package/dist/esmdev/foundation/definitions/Blend.js +3 -3
  72. package/dist/esmdev/foundation/definitions/ComponentType.js +7 -7
  73. package/dist/esmdev/foundation/definitions/CompositionType.js +50 -50
  74. package/dist/esmdev/foundation/definitions/CompressionTextureType.js +6 -6
  75. package/dist/esmdev/foundation/definitions/ShaderSemantics.d.ts +1 -0
  76. package/dist/esmdev/foundation/definitions/ShaderSemantics.js +12 -7
  77. package/dist/esmdev/foundation/definitions/TextureFormat.js +3 -3
  78. package/dist/esmdev/foundation/definitions/TextureParameter.js +3 -3
  79. package/dist/esmdev/foundation/definitions/VertexAttribute.js +30 -30
  80. package/dist/esmdev/foundation/enhanced_js_objects/Array.js +2 -2
  81. package/dist/esmdev/foundation/exporter/Gltf2Exporter.js +106 -106
  82. package/dist/esmdev/foundation/geometry/ComplexVertexAttribute.js +18 -18
  83. package/dist/esmdev/foundation/geometry/Frustum.js +39 -39
  84. package/dist/esmdev/foundation/geometry/Mesh.js +205 -205
  85. package/dist/esmdev/foundation/geometry/Primitive.js +124 -124
  86. package/dist/esmdev/foundation/geometry/SimpleVertexAttribute.js +7 -7
  87. package/dist/esmdev/foundation/geometry/shapes/Cylinder.js +3 -3
  88. package/dist/esmdev/foundation/geometry/shapes/Joint.js +33 -33
  89. package/dist/esmdev/foundation/gizmos/AABBGizmo.js +12 -12
  90. package/dist/esmdev/foundation/gizmos/CapsuleColliderGizmo.js +23 -23
  91. package/dist/esmdev/foundation/gizmos/Gizmo.js +23 -23
  92. package/dist/esmdev/foundation/gizmos/JointGizmo.js +35 -35
  93. package/dist/esmdev/foundation/gizmos/LightGizmo.js +23 -23
  94. package/dist/esmdev/foundation/gizmos/LocatorGizmo.js +22 -22
  95. package/dist/esmdev/foundation/gizmos/RotationGizmo.js +197 -197
  96. package/dist/esmdev/foundation/gizmos/ScaleGizmo.js +129 -129
  97. package/dist/esmdev/foundation/gizmos/ShapeGizmo.js +43 -43
  98. package/dist/esmdev/foundation/gizmos/SphereColliderGizmo.js +24 -24
  99. package/dist/esmdev/foundation/gizmos/TranslationGizmo.js +129 -129
  100. package/dist/esmdev/foundation/helpers/BloomHelper.js +28 -28
  101. package/dist/esmdev/foundation/helpers/GaussianBlurHelper.js +18 -18
  102. package/dist/esmdev/foundation/helpers/Shadow/PointShadowMap.js +11 -11
  103. package/dist/esmdev/foundation/helpers/Shadow/ShadowMap.js +5 -5
  104. package/dist/esmdev/foundation/helpers/Shadow/ShadowSystem.js +111 -111
  105. package/dist/esmdev/foundation/helpers/materials/createNodeBasedRaymarchingMaterials.js +10 -1
  106. package/dist/esmdev/foundation/helpers/materials/nodeBasedMaterialCommon.js +11 -1
  107. package/dist/esmdev/foundation/importer/AnimationAssigner.js +44 -44
  108. package/dist/esmdev/foundation/importer/DrcPointCloudImporter.js +27 -27
  109. package/dist/esmdev/foundation/importer/Gltf2Importer.d.ts +2 -1
  110. package/dist/esmdev/foundation/importer/Gltf2Importer.js +21 -17
  111. package/dist/esmdev/foundation/importer/GltfImporter.js +22 -22
  112. package/dist/esmdev/foundation/importer/ModelConverter.js +131 -131
  113. package/dist/esmdev/foundation/importer/RhodoniteImportExtension.js +6 -6
  114. package/dist/esmdev/foundation/importer/Vrm0xImporter.js +48 -48
  115. package/dist/esmdev/foundation/importer/VrmImporter.js +10 -10
  116. package/dist/esmdev/foundation/materials/contents/CustomMaterialContent.js +37 -28
  117. package/dist/esmdev/foundation/materials/contents/DepthEncodeMaterialContent.js +2 -2
  118. package/dist/esmdev/foundation/materials/contents/MToon0xMaterialContent.js +145 -137
  119. package/dist/esmdev/foundation/materials/contents/MToon1MaterialContent.js +27 -19
  120. package/dist/esmdev/foundation/materials/contents/ShadowMapDecodeClassicMaterialContent.js +5 -5
  121. package/dist/esmdev/foundation/materials/contents/VarianceShadowMapDecodeClassicMaterialContent.js +4 -4
  122. package/dist/esmdev/foundation/materials/core/AbstractMaterialContent.js +47 -47
  123. package/dist/esmdev/foundation/materials/core/AbstractShaderNode.js +25 -25
  124. package/dist/esmdev/foundation/materials/core/DummyTextures.js +3 -3
  125. package/dist/esmdev/foundation/materials/core/Material.d.ts +7 -2
  126. package/dist/esmdev/foundation/materials/core/Material.js +113 -99
  127. package/dist/esmdev/foundation/materials/core/MaterialRepository.js +51 -51
  128. package/dist/esmdev/foundation/materials/core/ShaderGraphResolver.js +38 -38
  129. package/dist/esmdev/foundation/materials/core/ShaderHandler.js +4 -4
  130. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGL.js +14 -14
  131. package/dist/esmdev/foundation/materials/core/ShaderityUtilityWebGPU.js +15 -15
  132. package/dist/esmdev/foundation/materials/nodes/AbsShaderNode.js +13 -13
  133. package/dist/esmdev/foundation/materials/nodes/AcosShaderNode.js +13 -13
  134. package/dist/esmdev/foundation/materials/nodes/AddShaderNode.js +18 -18
  135. package/dist/esmdev/foundation/materials/nodes/AlphaTestShaderNode.js +5 -5
  136. package/dist/esmdev/foundation/materials/nodes/AndShaderNode.js +6 -6
  137. package/dist/esmdev/foundation/materials/nodes/Atan2ShaderNode.js +15 -15
  138. package/dist/esmdev/foundation/materials/nodes/AttributeColorShaderNode.js +1 -1
  139. package/dist/esmdev/foundation/materials/nodes/AttributeInstanceIdsShaderNode.js +1 -1
  140. package/dist/esmdev/foundation/materials/nodes/AttributeJointShaderNode.js +1 -1
  141. package/dist/esmdev/foundation/materials/nodes/AttributeNormalShaderNode.js +1 -1
  142. package/dist/esmdev/foundation/materials/nodes/AttributePositionShaderNode.js +2 -2
  143. package/dist/esmdev/foundation/materials/nodes/AttributeTangentShaderNode.js +1 -1
  144. package/dist/esmdev/foundation/materials/nodes/AttributeTexcoordShaderNode.js +2 -2
  145. package/dist/esmdev/foundation/materials/nodes/AttributeWeightShaderNode.js +1 -1
  146. package/dist/esmdev/foundation/materials/nodes/BlockBeginShaderNode.js +11 -11
  147. package/dist/esmdev/foundation/materials/nodes/BlockEndShaderNode.js +6 -6
  148. package/dist/esmdev/foundation/materials/nodes/BranchShaderNode.js +15 -15
  149. package/dist/esmdev/foundation/materials/nodes/CalcBitangentShaderNode.js +7 -7
  150. package/dist/esmdev/foundation/materials/nodes/CastToFloatShaderNode.js +13 -13
  151. package/dist/esmdev/foundation/materials/nodes/ClampShaderNode.js +15 -15
  152. package/dist/esmdev/foundation/materials/nodes/ClassicShaderNode.js +11 -11
  153. package/dist/esmdev/foundation/materials/nodes/ConstantScalarVariableShaderNode.js +1 -1
  154. package/dist/esmdev/foundation/materials/nodes/ConstantVariableShaderNode.js +5 -5
  155. package/dist/esmdev/foundation/materials/nodes/ConstantVector2VariableShaderNode.js +1 -1
  156. package/dist/esmdev/foundation/materials/nodes/ConstantVector3VariableShaderNode.js +1 -1
  157. package/dist/esmdev/foundation/materials/nodes/ConstantVector4VariableShaderNode.js +1 -1
  158. package/dist/esmdev/foundation/materials/nodes/CosShaderNode.js +13 -13
  159. package/dist/esmdev/foundation/materials/nodes/DiscardShaderNode.js +2 -2
  160. package/dist/esmdev/foundation/materials/nodes/DotProductShaderNode.js +10 -10
  161. package/dist/esmdev/foundation/materials/nodes/EqualShaderNode.js +10 -10
  162. package/dist/esmdev/foundation/materials/nodes/FlatShaderNode.js +5 -5
  163. package/dist/esmdev/foundation/materials/nodes/GreaterOrEqualShaderNode.js +10 -10
  164. package/dist/esmdev/foundation/materials/nodes/GreaterShaderNode.js +3 -3
  165. package/dist/esmdev/foundation/materials/nodes/GreaterThanShaderNode.js +10 -10
  166. package/dist/esmdev/foundation/materials/nodes/LengthShaderNode.js +13 -13
  167. package/dist/esmdev/foundation/materials/nodes/LessOrEqualShaderNode.js +10 -10
  168. package/dist/esmdev/foundation/materials/nodes/LessThanShaderNode.js +10 -10
  169. package/dist/esmdev/foundation/materials/nodes/MergeVectorShaderNode.js +19 -19
  170. package/dist/esmdev/foundation/materials/nodes/MinShaderNode.js +18 -18
  171. package/dist/esmdev/foundation/materials/nodes/MultiplyShaderNode.js +21 -21
  172. package/dist/esmdev/foundation/materials/nodes/NormalMatrixShaderNode.js +1 -1
  173. package/dist/esmdev/foundation/materials/nodes/NormalizeShaderNode.js +9 -9
  174. package/dist/esmdev/foundation/materials/nodes/NotEqualShaderNode.js +10 -10
  175. package/dist/esmdev/foundation/materials/nodes/OrShaderNode.js +6 -6
  176. package/dist/esmdev/foundation/materials/nodes/OutColorShaderNode.js +2 -2
  177. package/dist/esmdev/foundation/materials/nodes/OutPositionShaderNode.js +2 -2
  178. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyPropsShaderNode.js +5 -5
  179. package/dist/esmdev/foundation/materials/nodes/PbrAnisotropyRotationShaderNode.js +3 -3
  180. package/dist/esmdev/foundation/materials/nodes/PbrBaseColorPropsShaderNode.js +5 -5
  181. package/dist/esmdev/foundation/materials/nodes/PbrClearcoatPropsShaderNode.js +7 -7
  182. package/dist/esmdev/foundation/materials/nodes/PbrDiffuseTransmissionPropsShaderNode.js +6 -6
  183. package/dist/esmdev/foundation/materials/nodes/PbrEmissivePropsShaderNode.js +5 -5
  184. package/dist/esmdev/foundation/materials/nodes/PbrIridescencePropsShaderNode.js +8 -8
  185. package/dist/esmdev/foundation/materials/nodes/PbrMetallicRoughnessPropsShaderNode.js +6 -6
  186. package/dist/esmdev/foundation/materials/nodes/PbrNormalPropsShaderNode.js +11 -11
  187. package/dist/esmdev/foundation/materials/nodes/PbrOcclusionPropsShaderNode.js +4 -4
  188. package/dist/esmdev/foundation/materials/nodes/PbrShaderShaderNode.js +21 -21
  189. package/dist/esmdev/foundation/materials/nodes/PbrSheenPropsShaderNode.js +6 -6
  190. package/dist/esmdev/foundation/materials/nodes/PbrSpecularPropsShaderNode.js +6 -6
  191. package/dist/esmdev/foundation/materials/nodes/PbrTransmissionPropsShaderNode.js +4 -4
  192. package/dist/esmdev/foundation/materials/nodes/PbrVolumePropsShaderNode.js +6 -6
  193. package/dist/esmdev/foundation/materials/nodes/PremultipliedAlphaShaderNode.js +4 -4
  194. package/dist/esmdev/foundation/materials/nodes/ProcessGeometryShaderNode.js +22 -22
  195. package/dist/esmdev/foundation/materials/nodes/ProjectionMatrixShaderNode.js +1 -1
  196. package/dist/esmdev/foundation/materials/nodes/Random_HashPRNGShaderNode.js +12 -12
  197. package/dist/esmdev/foundation/materials/nodes/Random_SinHashShaderNode.js +12 -12
  198. package/dist/esmdev/foundation/materials/nodes/RemapShaderNode.js +17 -17
  199. package/dist/esmdev/foundation/materials/nodes/SinShaderNode.js +13 -13
  200. package/dist/esmdev/foundation/materials/nodes/SmoothStepShaderNode.js +15 -15
  201. package/dist/esmdev/foundation/materials/nodes/SplitVectorShaderNode.js +17 -17
  202. package/dist/esmdev/foundation/materials/nodes/StepShaderNode.js +14 -14
  203. package/dist/esmdev/foundation/materials/nodes/TanShaderNode.js +13 -13
  204. package/dist/esmdev/foundation/materials/nodes/Texture2DShaderNode.js +16 -16
  205. package/dist/esmdev/foundation/materials/nodes/TimeShaderNode.js +1 -1
  206. package/dist/esmdev/foundation/materials/nodes/TransformShaderNode.js +10 -10
  207. package/dist/esmdev/foundation/materials/nodes/UniformDataShaderNode.js +5 -5
  208. package/dist/esmdev/foundation/materials/nodes/ViewMatrixShaderNode.js +1 -1
  209. package/dist/esmdev/foundation/materials/nodes/WireframeMaterialNode.js +3 -3
  210. package/dist/esmdev/foundation/materials/nodes/WorldMatrixShaderNode.js +1 -1
  211. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXYShaderNode.js +4 -4
  212. package/dist/esmdev/foundation/materials/nodes/raymarching/BendXZShaderNode.js +4 -4
  213. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYXShaderNode.js +4 -4
  214. package/dist/esmdev/foundation/materials/nodes/raymarching/BendYZShaderNode.js +4 -4
  215. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZXShaderNode.js +4 -4
  216. package/dist/esmdev/foundation/materials/nodes/raymarching/BendZYShaderNode.js +4 -4
  217. package/dist/esmdev/foundation/materials/nodes/raymarching/InitialPositionShaderNode.js +1 -1
  218. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothIntersectionShaderNode.js +5 -5
  219. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothSubtractionShaderNode.js +5 -5
  220. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSmoothUnionShaderNode.js +5 -5
  221. package/dist/esmdev/foundation/materials/nodes/raymarching/OpSubtractionShaderNode.js +6 -6
  222. package/dist/esmdev/foundation/materials/nodes/raymarching/OpUnionShaderNode.js +6 -6
  223. package/dist/esmdev/foundation/materials/nodes/raymarching/OutDistanceShaderNode.js +15 -15
  224. package/dist/esmdev/foundation/materials/nodes/raymarching/OutShadingColorShaderNode.js +2 -2
  225. package/dist/esmdev/foundation/materials/nodes/raymarching/OutUnionShaderNode.js +15 -15
  226. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchCameraPositionShaderNode.js +2 -2
  227. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitDistanceShaderNode.js +2 -2
  228. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitNormalShaderNode.js +2 -2
  229. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchHitPositionShaderNode.js +2 -2
  230. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdShaderNode.js +2 -2
  231. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchObjectIdUniformShaderNode.js +4 -4
  232. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchRayDirectionShaderNode.js +2 -2
  233. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchTBNShaderNode.js +2 -2
  234. package/dist/esmdev/foundation/materials/nodes/raymarching/RaymarchViewDirectionShaderNode.js +2 -2
  235. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyTransformShaderNode.js +9 -9
  236. package/dist/esmdev/foundation/materials/nodes/raymarching/SdApplyWorldMatrixShaderNode.js +5 -5
  237. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarXShaderNode.js +3 -3
  238. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarYShaderNode.js +3 -3
  239. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBarZShaderNode.js +3 -3
  240. package/dist/esmdev/foundation/materials/nodes/raymarching/SdBoxShaderNode.js +3 -3
  241. package/dist/esmdev/foundation/materials/nodes/raymarching/SdCapsuleShaderNode.js +5 -5
  242. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatShaderNode.js +4 -4
  243. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXShaderNode.js +4 -4
  244. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatXYShaderNode.js +4 -4
  245. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYShaderNode.js +4 -4
  246. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatYZShaderNode.js +4 -4
  247. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZShaderNode.js +4 -4
  248. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRepeatZXShaderNode.js +4 -4
  249. package/dist/esmdev/foundation/materials/nodes/raymarching/SdRoundBoxShaderNode.js +4 -4
  250. package/dist/esmdev/foundation/materials/nodes/raymarching/SdSphereShaderNode.js +3 -3
  251. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTorusShaderNode.js +4 -4
  252. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeXShaderNode.js +3 -3
  253. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeYShaderNode.js +3 -3
  254. package/dist/esmdev/foundation/materials/nodes/raymarching/SdTubeZShaderNode.js +3 -3
  255. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistXShaderNode.js +4 -4
  256. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistYShaderNode.js +4 -4
  257. package/dist/esmdev/foundation/materials/nodes/raymarching/TwistZShaderNode.js +4 -4
  258. package/dist/esmdev/foundation/math/AABB.js +120 -120
  259. package/dist/esmdev/foundation/math/AnimatedQuaternion.js +53 -53
  260. package/dist/esmdev/foundation/math/AnimatedScalar.js +54 -54
  261. package/dist/esmdev/foundation/math/AnimatedValueEvaluationState.js +18 -18
  262. package/dist/esmdev/foundation/math/AnimatedVector2.js +54 -54
  263. package/dist/esmdev/foundation/math/AnimatedVector3.js +54 -54
  264. package/dist/esmdev/foundation/math/AnimatedVector4.js +54 -54
  265. package/dist/esmdev/foundation/math/AnimatedVectorN.js +54 -54
  266. package/dist/esmdev/foundation/math/IdentityMatrix33.js +2 -2
  267. package/dist/esmdev/foundation/math/IdentityMatrix44.js +2 -2
  268. package/dist/esmdev/foundation/math/MathClassUtil.js +3 -3
  269. package/dist/esmdev/foundation/math/Quaternion.js +13 -13
  270. package/dist/esmdev/foundation/math/Transform3D.js +72 -72
  271. package/dist/esmdev/foundation/math/shapes/MathSphere.js +7 -7
  272. package/dist/esmdev/foundation/memory/Accessor.js +369 -369
  273. package/dist/esmdev/foundation/memory/Buffer.js +39 -39
  274. package/dist/esmdev/foundation/memory/BufferView.js +29 -29
  275. package/dist/esmdev/foundation/misc/DataUtil.js +2 -2
  276. package/dist/esmdev/foundation/misc/EnumIO.js +8 -8
  277. package/dist/esmdev/foundation/misc/Logger.js +14 -14
  278. package/dist/esmdev/foundation/misc/PngDecoder.d.ts +18 -0
  279. package/dist/esmdev/foundation/misc/PngDecoder.js +113 -0
  280. package/dist/esmdev/foundation/misc/RnPromise.js +14 -14
  281. package/dist/esmdev/foundation/misc/Time.js +23 -23
  282. package/dist/esmdev/foundation/misc/WeakOption.js +14 -14
  283. package/dist/esmdev/foundation/misc/cache/Cache.js +2 -2
  284. package/dist/esmdev/foundation/misc/cache/SymbolWeakMap.js +8 -8
  285. package/dist/esmdev/foundation/physics/PhysicsWorldQuery.js +10 -10
  286. package/dist/esmdev/foundation/physics/Rapier/RapierCharacterControllerStrategy.js +186 -186
  287. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsStrategy.js +221 -221
  288. package/dist/esmdev/foundation/physics/Rapier/RapierPhysicsWorldQueryStrategy.js +3 -3
  289. package/dist/esmdev/foundation/physics/VRMSpring/CapsuleCollider.js +36 -36
  290. package/dist/esmdev/foundation/physics/VRMSpring/SphereCollider.js +26 -26
  291. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBone.js +6 -6
  292. package/dist/esmdev/foundation/physics/VRMSpring/VRMSpringBonePhysicsStrategy.js +39 -39
  293. package/dist/esmdev/foundation/renderer/Expression.js +6 -6
  294. package/dist/esmdev/foundation/renderer/Frame.js +6 -6
  295. package/dist/esmdev/foundation/renderer/FrameBuffer.js +25 -25
  296. package/dist/esmdev/foundation/renderer/RenderPass.d.ts +7 -0
  297. package/dist/esmdev/foundation/renderer/RenderPass.js +94 -86
  298. package/dist/esmdev/foundation/renderer/TemporalAA/PreviousFrameDataTracker.js +6 -6
  299. package/dist/esmdev/foundation/renderer/TemporalAA/TemporalAASystem.js +75 -75
  300. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystem.js +146 -146
  301. package/dist/esmdev/foundation/renderer/lightCluster/LightClusterSystemStub.js +3 -3
  302. package/dist/esmdev/foundation/renderer/pipelines/DeferredRenderPipeline.js +4 -4
  303. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.d.ts +2 -1
  304. package/dist/esmdev/foundation/renderer/pipelines/ForwardRenderPipeline.js +420 -420
  305. package/dist/esmdev/foundation/system/Engine.js +209 -209
  306. package/dist/esmdev/foundation/system/EventPubSub.js +8 -8
  307. package/dist/esmdev/foundation/system/InputManager.js +56 -56
  308. package/dist/esmdev/foundation/system/ModuleManager.js +3 -3
  309. package/dist/esmdev/foundation/textures/AbstractTexture.js +48 -48
  310. package/dist/esmdev/foundation/textures/CubeTexture.d.ts +11 -2
  311. package/dist/esmdev/foundation/textures/CubeTexture.js +47 -36
  312. package/dist/esmdev/foundation/textures/RenderBuffer.js +11 -11
  313. package/dist/esmdev/foundation/textures/RenderTargetTexture.js +24 -24
  314. package/dist/esmdev/foundation/textures/RenderTargetTexture2DArray.js +35 -35
  315. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.d.ts +6 -0
  316. package/dist/esmdev/foundation/textures/RenderTargetTextureCube.js +25 -19
  317. package/dist/esmdev/foundation/textures/Sampler.js +24 -24
  318. package/dist/esmdev/foundation/textures/Texture.js +83 -83
  319. package/dist/esmdev/foundation/textures/TextureArray.js +8 -8
  320. package/dist/esmdev/foundation/textures/TextureDataFloat.js +26 -26
  321. package/dist/esmdev/foundation/textures/VideoTexture.js +24 -24
  322. package/dist/esmdev/version.js +2 -2
  323. package/dist/esmdev/webgl/InstanceSidTable.js +62 -62
  324. package/dist/esmdev/webgl/MultiDraw.js +2 -2
  325. package/dist/esmdev/webgl/MultiDrawRepository.js +30 -30
  326. package/dist/esmdev/webgl/WebGLContextWrapper.js +146 -146
  327. package/dist/esmdev/webgl/WebGLGpuTimer.js +30 -30
  328. package/dist/esmdev/webgl/WebGLResourceRepository.d.ts +5 -0
  329. package/dist/esmdev/webgl/WebGLResourceRepository.js +368 -307
  330. package/dist/esmdev/webgl/WebGLStereoUtil.js +39 -39
  331. package/dist/esmdev/webgl/WebGLStrategyWebGL2.d.ts +19 -14
  332. package/dist/esmdev/webgl/WebGLStrategyWebGL2.js +294 -280
  333. package/dist/esmdev/webgl/debug/ShaderParameterDebugger.js +4 -4
  334. package/dist/esmdev/webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js +2 -2
  335. package/dist/esmdev/webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js +2 -2
  336. package/dist/esmdev/webgl/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
  337. package/dist/esmdev/webgl/shaderity_shaders/common/iblDefinition.glsl.js +2 -2
  338. package/dist/esmdev/webgl/shaders/RaymarchingShaderPart.js +4 -4
  339. package/dist/esmdev/webgl/shaders/RaymarchingShadowShaderPart.js +14 -14
  340. package/dist/esmdev/webgl/shaders/StandardShaderPart.js +3 -3
  341. package/dist/esmdev/webgl/shaders/nodes/BlockBeginShader.js +10 -10
  342. package/dist/esmdev/webgl/shaders/nodes/BlockEndShader.js +10 -10
  343. package/dist/esmdev/webgl/shaders/nodes/ConstantVariableShader.js +21 -21
  344. package/dist/esmdev/webgl/shaders/nodes/OutDistance.js +12 -12
  345. package/dist/esmdev/webgl/shaders/nodes/OutUnion.js +9 -9
  346. package/dist/esmdev/webgl/shaders/nodes/RaymarchObjectIdUniform.js +8 -8
  347. package/dist/esmdev/webgl/shaders/nodes/SdApplyTransform.js +9 -9
  348. package/dist/esmdev/webgl/shaders/nodes/SdApplyWorldMatrix.js +8 -8
  349. package/dist/esmdev/webgl/shaders/nodes/Texture2DShader.js +23 -23
  350. package/dist/esmdev/webgl/shaders/nodes/UniformDataShader.js +23 -23
  351. package/dist/esmdev/webgl/textureLoader/KTX2TextureLoader.js +24 -24
  352. package/dist/esmdev/webgpu/GpuCullingRegistry.js +91 -91
  353. package/dist/esmdev/webgpu/GpuDeformRegistry.js +53 -53
  354. package/dist/esmdev/webgpu/RangeAllocator.js +16 -16
  355. package/dist/esmdev/webgpu/WebGpuBufferArena.js +21 -21
  356. package/dist/esmdev/webgpu/WebGpuDeviceWrapper.js +7 -7
  357. package/dist/esmdev/webgpu/WebGpuGpuCulling.js +198 -198
  358. package/dist/esmdev/webgpu/WebGpuGpuTimer.js +51 -51
  359. package/dist/esmdev/webgpu/WebGpuLightClusterBuilder.js +36 -36
  360. package/dist/esmdev/webgpu/WebGpuResourceRepository.d.ts +6 -0
  361. package/dist/esmdev/webgpu/WebGpuResourceRepository.js +655 -593
  362. package/dist/esmdev/webgpu/WebGpuStrategyBasic.js +123 -123
  363. package/dist/esmdev/webgpu/WebGpuVertexDeformer.js +128 -128
  364. package/dist/esmdev/webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js +2 -2
  365. package/dist/esmdev/webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js +2 -2
  366. package/dist/esmdev/webgpu/shaderity_shaders/PbrSingleShader/PbrSingleShader.frag.js +2 -2
  367. package/dist/esmdev/webgpu/shaderity_shaders/common/iblDefinition.wgsl.js +2 -2
  368. package/dist/esmdev/xr/WebARSystem.js +69 -69
  369. package/dist/esmdev/xr/WebXRSystem.js +151 -151
  370. package/package.json +2 -1
@@ -1 +1 @@
1
- import{VrmComponent as G}from"../components/index.js";import{ConstraintComponent as R}from"../components/Constraint/index.js";import{PhysicsComponent as v}from"../components/Physics/PhysicsComponent.js";import{VrmAimConstraint as A}from"../constraints/VrmAimConstraint.js";import{VrmRollConstraint as B}from"../constraints/VrmRollConstraint.js";import{VrmRotationConstraint as M}from"../constraints/VrmRotationConstraint.js";import{TextureParameter as C}from"../definitions/TextureParameter.js";import{Vector3 as y}from"../math/Vector3.js";import{Is as c}from"../misc/Is.js";import{CapsuleCollider as I}from"../physics/VRMSpring/CapsuleCollider.js";import{SphereCollider as O}from"../physics/VRMSpring/SphereCollider.js";import{VRMColliderGroup as b}from"../physics/VRMSpring/VRMColliderGroup.js";import{VRMSpring as L}from"../physics/VRMSpring/VRMSpring.js";import{VRMSpringBone as _}from"../physics/VRMSpring/VRMSpringBone.js";import{VRMSpringBonePhysicsStrategy as P}from"../physics/VRMSpring/VRMSpringBonePhysicsStrategy.js";import{RenderPass as H}from"../renderer/RenderPass.js";import{Sampler as j}from"../textures/Sampler.js";import{Texture as S}from"../textures/Texture.js";import{Gltf2Importer as D}from"./Gltf2Importer.js";import{ModelConverter as E}from"./ModelConverter.js";var T=class w{constructor(){}static async Hd(t,e,n){var m,o,d,x,u,f,h,V;let s=(d=(o=(m=e.asset.extras)==null?void 0:m.rnLoaderOptions)==null?void 0:o.defaultMaterialHelperArgumentArray)!=null?d:[{}],a=await this._createTextures(t,e),i=this._createSamplers(t,e);c.exist(s)&&(s[0].textures=(x=s[0].textures)!=null?x:a,s[0].samplers=(u=s[0].samplers)!=null?u:i,s[0].isLighting=(f=s[0].isLighting)!=null?f:!0);let r=this.Zd(e,a.length),p;if(r){n[1]=(h=n[1])!=null?h:new H(t);let g=n[1];g.toClearColorBuffer=!1,g.toClearDepthBuffer=!1,e.extensions.VRM={},e.extensions.VRM.rnExtension={renderPassOutline:g},p=await E.convertToRhodoniteObject(t,e),g.addEntities([p])}else p=await E.convertToRhodoniteObject(t,e);let l=n[0];l.tryToSetUniqueName("VRM Main RenderPass",!0),l.addEntities([p]),this._readSpringBone(t,e),this._readVRMHumanoidInfo(e,p),this._readExpressions(e,p),this._readConstraints(e),((V=e.asset.extras)==null?void 0:V.rnLoaderOptions)!=null&&(e.asset.extras.rnLoaderOptions.defaultMaterialHelperArgumentArray=[])}static _readConstraints(t){var e,n;for(let s=0;s<t.nodes.length;s++){let i=(n=(e=t.nodes[s].extensions)==null?void 0:e.VRMC_node_constraint)==null?void 0:n.constraint;if(c.exist(i)){if(c.exist(i.roll)){let r=i.roll,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new B(l,r.rollAxis,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}else if(c.exist(i.aim)){let r=i.aim,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new A(l,r.aimAxis,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}else if(c.exist(i.rotation)){let r=i.rotation,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new M(l,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}}}}static _readExpressions(t,e){var i,r,p,l,m;let n=[],s=[(r=(i=t.extensions.VRMC_vrm)==null?void 0:i.expressions)==null?void 0:r.preset,(l=(p=t.extensions.VRMC_vrm)==null?void 0:p.expressions)==null?void 0:l.custom];if(s.every(c.not.exist))return;for(let o of s)if(!c.not.exist(o))for(let d in o){let x=o[d],u=[];c.exist(x.morphTargetBinds)&&(u=x.morphTargetBinds.map(h=>({entityIdx:t.extras.rnEntities[h.node].entityUID,blendShapeIdx:h.index,weight:h.weight})));let f={name:d,isBinary:(m=x.isBinary)!=null?m:!1,binds:u};n.push(f)}let a=e.engine.entityRepository.addComponentToEntity(G,e);a.getVrm().setVrmExpressions(n),a.getVrm()._version="1.0"}static _readVRMHumanoidInfo(t,e){let n=t.extensions.VRMC_vrm.humanoid.humanBones,s=new Map;for(let a in n){let i=n[a];s.set(a,i.node)}e!=null&&e.tryToSetTag({tag:"humanoid_map_name_nodeId",value:s})}static _readSpringBone(t,e){var a,i;let n=[];if(c.exist((a=e.extensions.VRMC_springBone)==null?void 0:a.colliderGroups))for(let r in e.extensions.VRMC_springBone.colliderGroups){let p=e.extensions.VRMC_springBone.colliderGroups[r],l=new b;n.push(l);for(let m of p.colliders){let o=e.extensions.VRMC_springBone.colliders[m],d=e.asset.extras.rnEntities[o.node].getSceneGraph();if(c.exist(o.shape.sphere)){let x=new O(t,y.fromCopyArray([o.shape.sphere.offset[0],o.shape.sphere.offset[1],o.shape.sphere.offset[2]]),o.shape.sphere.radius,d);l.sphereColliders.push(x)}else if(c.exist(o.shape.capsule)){let x=new I(t,y.fromCopyArray([o.shape.capsule.offset[0],o.shape.capsule.offset[1],o.shape.capsule.offset[2]]),o.shape.capsule.radius,y.fromCopyArray([o.shape.capsule.tail[0],o.shape.capsule.tail[1],o.shape.capsule.tail[2]]),d);l.capsuleColliders.push(x)}}}let s=[];if(c.exist((i=e.extensions.VRMC_springBone)==null?void 0:i.springs))for(let r of e.extensions.VRMC_springBone.springs){let p=r.joints[0],l=e.asset.extras.rnEntities[p.node],m=new L(l.getSceneGraph());m.tryToSetUniqueName(r.name,!0);let o=c.exist(r.colliderGroups)?r.colliderGroups:[];m.colliderGroups=o.map(x=>n[x]);let d=[];for(let x in r.joints){let u=r.joints[x],f=e.asset.extras.rnEntities[u.node],h=new _(f);h.dragForce=c.exist(u.dragForce)?u.dragForce:.4,h.stiffnessForce=c.exist(u.stiffness)?u.stiffness:1,h.gravityPower=c.exist(u.gravityPower)?u.gravityPower:1,h.gravityDir=c.exist(u.gravityDir)?y.fromCopyArray3([u.gravityDir[0],u.gravityDir[1],u.gravityDir[2]]):y.fromCopyArray3([0,-1,0]),h.hitRadius=c.exist(u.hitRadius)?u.hitRadius:.02,m.bones.push(h),d.push(f)}r.center!=null&&r.center!==-1&&(m.center=e.asset.extras.rnEntities[r.center].getSceneGraph()),this.zd(m,l,d),s.push(m)}for(let r of s)this.qd(r,r.rootBone)}static zd(t,e,n){let a=e.getSceneGraph().children;if(!n.includes(e)){let i=new _(e);t.bones.push(i),n.push(e)}for(let i of a)this.zd(t,i.entity,n)}static qd(t,e){let n=e.entity,a=n.engine.entityRepository.addComponentToEntity(v,n).getPhysics(),i=new P;i.setSpring(t),a.setStrategy(i)}static async _createTextures(t,e){e.textures||(e.textures=[]);let n=e.textures,s=[];for(let r=0;r<n.length;r++){let p=await E._createTexture(t,n[r].sourceObject,e);s[r]=p}let a=new S(t);await a.generate1x1TextureFrom(),a.markAsDummyTexture(),s.push(a);let i=new S(t);return await i.generate1x1TextureFrom("rgba(0, 0, 0, 1)"),i.markAsDummyTexture(),s.push(i),s}static _createSamplers(t,e){e.textures||(e.textures=[]);let n=e.textures,s=[];for(let i=0;i<n.length;i++){let r=E._createSampler(t,n[i].samplerObject);s[i]=r}let a=new j(t,{wrapS:C.ClampToEdge,wrapT:C.ClampToEdge,minFilter:C.Linear,magFilter:C.Linear});return a.create(),s.push(a),s.push(a),s}static Zd(t,e){var s;let n=!1;for(let a of t.materials){let i=(s=a.extensions)==null?void 0:s.VRMC_materials_mtoon;if(i==null)continue;c.not.exist(a.extras)&&(a.extras={});let r=i.outlineWidthMode;(r==="worldCoordinates"||r==="screenCoordinates")&&(n=!0)}return n}static _getOptions(t){if(t!=null){for(let e in t.files){let n=e.split(".vrm")[0];if(n){let s=t.files[e];t.files[`${n}.glb`]=s,delete t.files[e]}}t.Pd=!0,t.defaultMaterialHelperArgumentArray==null&&(t.defaultMaterialHelperArgumentArray=[{}]),t.defaultMaterialHelperArgumentArray[0].isMorphing||(t.maxMorphTargetNumber=0)}else t={files:{},loaderExtension:void 0,defaultMaterialHelperName:void 0,defaultMaterialHelperArgumentArray:[{isLighting:!0,isMorphing:!0,isSkinning:!0}],statesOfElements:[{targets:[],states:{enable:[],functions:{}},isTransparent:!0,opacity:1,isTextureImageToLoadPreMultipliedAlpha:!1}],Pd:!0,__importedType:"vrm1"};return t}static async importJsonOfVRM(t,e){e=this._getOptions(e);let n=await D.importFromUrl(t,e);return w._readVRMHumanoidInfo(n),n}};export{T as VrmImporter};
1
+ import{VrmComponent as G}from"../components/index.js";import{ConstraintComponent as R}from"../components/Constraint/index.js";import{PhysicsComponent as v}from"../components/Physics/PhysicsComponent.js";import{VrmAimConstraint as A}from"../constraints/VrmAimConstraint.js";import{VrmRollConstraint as B}from"../constraints/VrmRollConstraint.js";import{VrmRotationConstraint as M}from"../constraints/VrmRotationConstraint.js";import{TextureParameter as C}from"../definitions/TextureParameter.js";import{Vector3 as y}from"../math/Vector3.js";import{Is as c}from"../misc/Is.js";import{CapsuleCollider as I}from"../physics/VRMSpring/CapsuleCollider.js";import{SphereCollider as O}from"../physics/VRMSpring/SphereCollider.js";import{VRMColliderGroup as b}from"../physics/VRMSpring/VRMColliderGroup.js";import{VRMSpring as L}from"../physics/VRMSpring/VRMSpring.js";import{VRMSpringBone as _}from"../physics/VRMSpring/VRMSpringBone.js";import{VRMSpringBonePhysicsStrategy as P}from"../physics/VRMSpring/VRMSpringBonePhysicsStrategy.js";import{RenderPass as H}from"../renderer/RenderPass.js";import{Sampler as j}from"../textures/Sampler.js";import{Texture as S}from"../textures/Texture.js";import{Gltf2Importer as D}from"./Gltf2Importer.js";import{ModelConverter as E}from"./ModelConverter.js";var T=class w{constructor(){}static async Sd(t,e,n){var m,o,d,x,u,f,h,V;let s=(d=(o=(m=e.asset.extras)==null?void 0:m.rnLoaderOptions)==null?void 0:o.defaultMaterialHelperArgumentArray)!=null?d:[{}],a=await this._createTextures(t,e),i=this._createSamplers(t,e);c.exist(s)&&(s[0].textures=(x=s[0].textures)!=null?x:a,s[0].samplers=(u=s[0].samplers)!=null?u:i,s[0].isLighting=(f=s[0].isLighting)!=null?f:!0);let r=this.Zd(e,a.length),p;if(r){n[1]=(h=n[1])!=null?h:new H(t);let g=n[1];g.toClearColorBuffer=!1,g.toClearDepthBuffer=!1,e.extensions.VRM={},e.extensions.VRM.rnExtension={renderPassOutline:g},p=await E.convertToRhodoniteObject(t,e),g.addEntities([p])}else p=await E.convertToRhodoniteObject(t,e);let l=n[0];l.tryToSetUniqueName("VRM Main RenderPass",!0),l.addEntities([p]),this._readSpringBone(t,e),this._readVRMHumanoidInfo(e,p),this._readExpressions(e,p),this._readConstraints(e),((V=e.asset.extras)==null?void 0:V.rnLoaderOptions)!=null&&(e.asset.extras.rnLoaderOptions.defaultMaterialHelperArgumentArray=[])}static _readConstraints(t){var e,n;for(let s=0;s<t.nodes.length;s++){let i=(n=(e=t.nodes[s].extensions)==null?void 0:e.VRMC_node_constraint)==null?void 0:n.constraint;if(c.exist(i)){if(c.exist(i.roll)){let r=i.roll,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new B(l,r.rollAxis,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}else if(c.exist(i.aim)){let r=i.aim,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new A(l,r.aimAxis,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}else if(c.exist(i.rotation)){let r=i.rotation,p=t.extras.rnEntities[s],l=t.extras.rnEntities[r.source],m=p.engine.entityRepository.addComponentToEntity(R,p),o=new M(l,c.exist(r.weight)?r.weight:1,m);m.getConstraint().setConstraint(o)}}}}static _readExpressions(t,e){var i,r,p,l,m;let n=[],s=[(r=(i=t.extensions.VRMC_vrm)==null?void 0:i.expressions)==null?void 0:r.preset,(l=(p=t.extensions.VRMC_vrm)==null?void 0:p.expressions)==null?void 0:l.custom];if(s.every(c.not.exist))return;for(let o of s)if(!c.not.exist(o))for(let d in o){let x=o[d],u=[];c.exist(x.morphTargetBinds)&&(u=x.morphTargetBinds.map(h=>({entityIdx:t.extras.rnEntities[h.node].entityUID,blendShapeIdx:h.index,weight:h.weight})));let f={name:d,isBinary:(m=x.isBinary)!=null?m:!1,binds:u};n.push(f)}let a=e.engine.entityRepository.addComponentToEntity(G,e);a.getVrm().setVrmExpressions(n),a.getVrm()._version="1.0"}static _readVRMHumanoidInfo(t,e){let n=t.extensions.VRMC_vrm.humanoid.humanBones,s=new Map;for(let a in n){let i=n[a];s.set(a,i.node)}e!=null&&e.tryToSetTag({tag:"humanoid_map_name_nodeId",value:s})}static _readSpringBone(t,e){var a,i;let n=[];if(c.exist((a=e.extensions.VRMC_springBone)==null?void 0:a.colliderGroups))for(let r in e.extensions.VRMC_springBone.colliderGroups){let p=e.extensions.VRMC_springBone.colliderGroups[r],l=new b;n.push(l);for(let m of p.colliders){let o=e.extensions.VRMC_springBone.colliders[m],d=e.asset.extras.rnEntities[o.node].getSceneGraph();if(c.exist(o.shape.sphere)){let x=new O(t,y.fromCopyArray([o.shape.sphere.offset[0],o.shape.sphere.offset[1],o.shape.sphere.offset[2]]),o.shape.sphere.radius,d);l.sphereColliders.push(x)}else if(c.exist(o.shape.capsule)){let x=new I(t,y.fromCopyArray([o.shape.capsule.offset[0],o.shape.capsule.offset[1],o.shape.capsule.offset[2]]),o.shape.capsule.radius,y.fromCopyArray([o.shape.capsule.tail[0],o.shape.capsule.tail[1],o.shape.capsule.tail[2]]),d);l.capsuleColliders.push(x)}}}let s=[];if(c.exist((i=e.extensions.VRMC_springBone)==null?void 0:i.springs))for(let r of e.extensions.VRMC_springBone.springs){let p=r.joints[0],l=e.asset.extras.rnEntities[p.node],m=new L(l.getSceneGraph());m.tryToSetUniqueName(r.name,!0);let o=c.exist(r.colliderGroups)?r.colliderGroups:[];m.colliderGroups=o.map(x=>n[x]);let d=[];for(let x in r.joints){let u=r.joints[x],f=e.asset.extras.rnEntities[u.node],h=new _(f);h.dragForce=c.exist(u.dragForce)?u.dragForce:.4,h.stiffnessForce=c.exist(u.stiffness)?u.stiffness:1,h.gravityPower=c.exist(u.gravityPower)?u.gravityPower:1,h.gravityDir=c.exist(u.gravityDir)?y.fromCopyArray3([u.gravityDir[0],u.gravityDir[1],u.gravityDir[2]]):y.fromCopyArray3([0,-1,0]),h.hitRadius=c.exist(u.hitRadius)?u.hitRadius:.02,m.bones.push(h),d.push(f)}r.center!=null&&r.center!==-1&&(m.center=e.asset.extras.rnEntities[r.center].getSceneGraph()),this.zd(m,l,d),s.push(m)}for(let r of s)this.qd(r,r.rootBone)}static zd(t,e,n){let a=e.getSceneGraph().children;if(!n.includes(e)){let i=new _(e);t.bones.push(i),n.push(e)}for(let i of a)this.zd(t,i.entity,n)}static qd(t,e){let n=e.entity,a=n.engine.entityRepository.addComponentToEntity(v,n).getPhysics(),i=new P;i.setSpring(t),a.setStrategy(i)}static async _createTextures(t,e){e.textures||(e.textures=[]);let n=e.textures,s=[];for(let r=0;r<n.length;r++){let p=await E._createTexture(t,n[r].sourceObject,e);s[r]=p}let a=new S(t);await a.generate1x1TextureFrom(),a.markAsDummyTexture(),s.push(a);let i=new S(t);return await i.generate1x1TextureFrom("rgba(0, 0, 0, 1)"),i.markAsDummyTexture(),s.push(i),s}static _createSamplers(t,e){e.textures||(e.textures=[]);let n=e.textures,s=[];for(let i=0;i<n.length;i++){let r=E._createSampler(t,n[i].samplerObject);s[i]=r}let a=new j(t,{wrapS:C.ClampToEdge,wrapT:C.ClampToEdge,minFilter:C.Linear,magFilter:C.Linear});return a.create(),s.push(a),s.push(a),s}static Zd(t,e){var s;let n=!1;for(let a of t.materials){let i=(s=a.extensions)==null?void 0:s.VRMC_materials_mtoon;if(i==null)continue;c.not.exist(a.extras)&&(a.extras={});let r=i.outlineWidthMode;(r==="worldCoordinates"||r==="screenCoordinates")&&(n=!0)}return n}static _getOptions(t){if(t!=null){for(let e in t.files){let n=e.split(".vrm")[0];if(n){let s=t.files[e];t.files[`${n}.glb`]=s,delete t.files[e]}}t.Pd=!0,t.defaultMaterialHelperArgumentArray==null&&(t.defaultMaterialHelperArgumentArray=[{}]),t.defaultMaterialHelperArgumentArray[0].isMorphing||(t.maxMorphTargetNumber=0)}else t={files:{},loaderExtension:void 0,defaultMaterialHelperName:void 0,defaultMaterialHelperArgumentArray:[{isLighting:!0,isMorphing:!0,isSkinning:!0}],statesOfElements:[{targets:[],states:{enable:[],functions:{}},isTransparent:!0,opacity:1,isTextureImageToLoadPreMultipliedAlpha:!1}],Pd:!0,__importedType:"vrm1"};return t}static async importJsonOfVRM(t,e){e=this._getOptions(e);let n=await D.importFromUrl(t,e);return w._readVRMHumanoidInfo(n),n}};export{T as VrmImporter};
@@ -1 +1 @@
1
- import{HdriFormat as y}from"../../definitions/HdriFormat.js";import{ShaderSemantics as s}from"../../definitions/ShaderSemantics.js";import{TextureParameter as b}from"../../definitions/TextureParameter.js";import{MutableVector2 as M}from"../../math/MutableVector2.js";import{MutableVector4 as g}from"../../math/MutableVector4.js";import{getSharedSampler as C}from"../../textures/Sampler.js";import{AbstractMaterialContent as x}from"../core/AbstractMaterialContent.js";var v=class S extends x{constructor(i,{name:r,isMorphing:n,isSkinning:a,isLighting:u,vertexShader:m,pixelShader:d,additionalShaderSemanticInfo:l,vertexShaderWebGpu:o,pixelShaderWebGpu:f,definitions:t=[]}){super(r,{isMorphing:n,isSkinning:a,isLighting:u},void 0,void 0,i);this.eb=-1;this.rb=new Float64Array(6);let p=this.doShaderReflection(i,m,d,o,f,t);this.Qd=C(i,{minFilter:b.Linear,magFilter:b.Linear,wrapS:b.ClampToEdge,wrapT:b.ClampToEdge,wrapR:b.ClampToEdge}),this.Kd=C(i,{minFilter:b.LinearMipmapLinear,magFilter:b.Linear,wrapS:b.ClampToEdge,wrapT:b.ClampToEdge,wrapR:b.ClampToEdge}),this.setShaderSemanticsInfoArray(p.concat(l))}_setInternalSettingParametersToGpuWebGpu({material:i,args:r}){let{mipmapLevelNumber:n,meshRenderComponent:a,diffuseHdriType:u,specularHdriType:m,diffuseContribution:d,specularContribution:l}=S.tb(r),o=x.ib;o.x=n,o.y=d,o.z=l,o.w=a.rotationOfCubeMap,i.setParameter("iblParameter",o);let f=x.nb;f.x=u,f.y=m,i.setParameter("hdriFormat",f);let t=r.entity.tryToGetMeshRenderer();if(t!=null&&t.diffuseCubeMap!=null&&t.specularCubeMap!=null){let T=g.zero(),h=M.zero();T.x=t.specularCubeMap.mipmapLevelNumber,T.y=t.diffuseCubeMapContribution,T.z=t.specularCubeMapContribution,T.w=t.rotationOfCubeMap,i.setParameter("iblParameter",T),h.x=t.diffuseCubeMap.hdriFormat.index,h.y=t.specularCubeMap.hdriFormat.index,i.setParameter("hdriFormat",h)}let p=t==null?void 0:t.diffuseCubeMap,e=t==null?void 0:t.specularCubeMap;p!=null&&p.isTextureReady&&i.setTextureParameter(s.DiffuseEnvTexture.str,p,this.Qd),e!=null&&e.isTextureReady&&i.setTextureParameter(s.SpecularEnvTexture.str,e,this.Kd);let c=t==null?void 0:t.sheenCubeMap;c!=null&&c.isTextureReady?i.setTextureParameter(s.SheenEnvTexture.str,c,this.Kd):e!=null&&e.isTextureReady&&i.setTextureParameter(s.SheenEnvTexture.str,e,this.Kd)}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:i,material:r,shaderProgram:n,firstTime:a,args:u}){let{mipmapLevelNumber:m,meshRenderComponent:d,diffuseHdriType:l,specularHdriType:o,diffuseContribution:f,specularContribution:t}=S.tb(u),p=d.rotationOfCubeMap,e=this.rb;if(this.Yd===r&&this.eb===r.stateVersion&&e[0]===m&&e[1]===f&&e[2]===t&&e[3]===p&&e[4]===l&&e[5]===o)return;let c=x.ib;c.x=m,c.y=f,c.z=t,c.w=p,r.setParameter("iblParameter",c);let T=x.nb;T.x=l,T.y=o,r.setParameter("hdriFormat",T),this.Yd=r,this.eb=r.stateVersion,e[0]=m,e[1]=f,e[2]=t,e[3]=p,e[4]=l,e[5]=o}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:i,material:r,shaderProgram:n,args:a}){var o,f,t,p;let u=i.webglResourceRepository,m=r.getTextureParameter(s.DiffuseEnvTexture.str);if(m!=null){let e=m[0];(o=a.diffuseCube)!=null&&o.isTextureReady?(u.setUniform1iForTexture(n,s.DiffuseEnvTexture.str,[e,a.diffuseCube,this.Qd]),r.setTextureParameter(s.DiffuseEnvTexture.str,a.diffuseCube,this.Qd)):u.setUniform1iForTexture(n,s.DiffuseEnvTexture.str,[e,i.dummyTextures.dummyBlackCubeTexture])}let d=r.getTextureParameter(s.SpecularEnvTexture.str);if(d!=null){let e=d[0];(f=a.specularCube)!=null&&f.isTextureReady?(u.setUniform1iForTexture(n,s.SpecularEnvTexture.str,[e,a.specularCube,this.Kd]),r.setTextureParameter(s.SpecularEnvTexture.str,a.specularCube,this.Kd)):u.setUniform1iForTexture(n,s.SpecularEnvTexture.str,[e,i.dummyTextures.dummyBlackCubeTexture])}let l=r.getTextureParameter(s.SheenEnvTexture.str);if(l!=null){let e=l[0];(t=a.sheenCube)!=null&&t.isTextureReady?(u.setUniform1iForTexture(n,s.SheenEnvTexture.str,[e,a.sheenCube,this.Kd]),r.setTextureParameter(s.SheenEnvTexture.str,a.sheenCube,this.Kd)):(p=a.specularCube)!=null&&p.isTextureReady?(u.setUniform1iForTexture(n,s.SheenEnvTexture.str,[e,a.specularCube,this.Kd]),r.setTextureParameter(s.SheenEnvTexture.str,a.specularCube,this.Kd)):u.setUniform1iForTexture(n,s.SheenEnvTexture.str,[e,i.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerPrimitive({shaderProgram:i,args:r}){let n=r.entity.tryToGetBlendShape();this.setMorphInfo(i,r.entity.getMesh(),r.primitive,n)}static tb(i){let r=1;i.specularCube&&(r=i.specularCube.mipmapLevelNumber);let n=i.entity.getMeshRenderer(),a=y.LDR_SRGB.index,u=y.LDR_SRGB.index;n.diffuseCubeMap&&(a=n.diffuseCubeMap.hdriFormat.index),n.specularCubeMap&&(u=n.specularCubeMap.hdriFormat.index);let m=n.diffuseCubeMap!=null?n.diffuseCubeMapContribution:0,d=n.specularCubeMap!=null?n.specularCubeMapContribution:0;return{mipmapLevelNumber:r,meshRenderComponent:n,diffuseHdriType:a,specularHdriType:u,diffuseContribution:m,specularContribution:d}}};export{v as CustomMaterialContent};
1
+ import{HdriFormat as v}from"../../definitions/HdriFormat.js";import{ShaderSemantics as a}from"../../definitions/ShaderSemantics.js";import{TextureParameter as T}from"../../definitions/TextureParameter.js";import{MutableVector2 as E}from"../../math/MutableVector2.js";import{MutableVector4 as P}from"../../math/MutableVector4.js";import{getSharedSampler as C}from"../../textures/Sampler.js";import{AbstractMaterialContent as h}from"../core/AbstractMaterialContent.js";var M=class y extends h{constructor(e,{name:r,isMorphing:u,isSkinning:i,isLighting:o,vertexShader:m,pixelShader:l,additionalShaderSemanticInfo:d,vertexShaderWebGpu:b,pixelShaderWebGpu:p,definitions:f=[]}){super(r,{isMorphing:u,isSkinning:i,isLighting:o},void 0,void 0,e);this.tb=-1;this.ib=new Float64Array(7);let t=this.doShaderReflection(e,m,l,b,p,f);this.Yd=C(e,{minFilter:T.Linear,magFilter:T.Linear,wrapS:T.ClampToEdge,wrapT:T.ClampToEdge,wrapR:T.ClampToEdge}),this.Qd=C(e,{minFilter:T.LinearMipmapLinear,magFilter:T.Linear,wrapS:T.ClampToEdge,wrapT:T.ClampToEdge,wrapR:T.ClampToEdge}),this.setShaderSemanticsInfoArray(t.concat(d))}_setInternalSettingParametersToGpuWebGpu({material:e,args:r}){let{mipmapLevelNumber:u,iblMipLevelSkip:i,meshRenderComponent:o,diffuseHdriType:m,specularHdriType:l,diffuseContribution:d,specularContribution:b}=y.rb(r),p=h.nb;p.x=u,p.y=d,p.z=b,p.w=o.rotationOfCubeMap,e.setParameter("iblParameter",p),e.setParameter("iblMipLevelSkip",i);let f=h.sb;f.x=m,f.y=l,e.setParameter("hdriFormat",f);let t=r.entity.tryToGetMeshRenderer();if(t!=null&&t.diffuseCubeMap!=null&&t.specularCubeMap!=null){let x=P.zero(),S=E.zero();x.x=t.specularCubeMap.mipmapLevelNumber,x.y=t.diffuseCubeMapContribution,x.z=t.specularCubeMapContribution,x.w=t.rotationOfCubeMap,e.setParameter("iblParameter",x),e.setParameter("iblMipLevelSkip",t.specularCubeMap.iblMipLevelSkip),S.x=t.diffuseCubeMap.hdriFormat.index,S.y=t.specularCubeMap.hdriFormat.index,e.setParameter("hdriFormat",S)}let s=t==null?void 0:t.diffuseCubeMap,n=t==null?void 0:t.specularCubeMap;s!=null&&s.isTextureReady&&e.setTextureParameter(a.DiffuseEnvTexture.str,s,this.Yd),n!=null&&n.isTextureReady&&e.setTextureParameter(a.SpecularEnvTexture.str,n,this.Qd);let c=t==null?void 0:t.sheenCubeMap;c!=null&&c.isTextureReady?e.setTextureParameter(a.SheenEnvTexture.str,c,this.Qd):n!=null&&n.isTextureReady&&e.setTextureParameter(a.SheenEnvTexture.str,n,this.Qd)}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:e,material:r,shaderProgram:u,firstTime:i,args:o}){let{mipmapLevelNumber:m,iblMipLevelSkip:l,meshRenderComponent:d,diffuseHdriType:b,specularHdriType:p,diffuseContribution:f,specularContribution:t}=y.rb(o),s=d.rotationOfCubeMap,n=this.ib;if(this.eb===r&&this.tb===r.stateVersion&&n[0]===m&&n[1]===f&&n[2]===t&&n[3]===s&&n[4]===b&&n[5]===p&&n[6]===l)return;let c=h.nb;c.x=m,c.y=f,c.z=t,c.w=s,r.setParameter("iblParameter",c),r.setParameter("iblMipLevelSkip",l);let x=h.sb;x.x=b,x.y=p,r.setParameter("hdriFormat",x),this.eb=r,this.tb=r.stateVersion,n[0]=m,n[1]=f,n[2]=t,n[3]=s,n[4]=b,n[5]=p,n[6]=l}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:e,material:r,shaderProgram:u,args:i}){var b,p,f,t;let o=e.webglResourceRepository,m=r.getTextureParameter(a.DiffuseEnvTexture.str);if(m!=null){let s=m[0];(b=i.diffuseCube)!=null&&b.isTextureReady?(o.setUniform1iForTexture(u,a.DiffuseEnvTexture.str,[s,i.diffuseCube,this.Yd]),r.setTextureParameter(a.DiffuseEnvTexture.str,i.diffuseCube,this.Yd)):o.setUniform1iForTexture(u,a.DiffuseEnvTexture.str,[s,e.dummyTextures.dummyBlackCubeTexture])}let l=r.getTextureParameter(a.SpecularEnvTexture.str);if(l!=null){let s=l[0];(p=i.specularCube)!=null&&p.isTextureReady?(o.setUniform1iForTexture(u,a.SpecularEnvTexture.str,[s,i.specularCube,this.Qd]),r.setTextureParameter(a.SpecularEnvTexture.str,i.specularCube,this.Qd)):o.setUniform1iForTexture(u,a.SpecularEnvTexture.str,[s,e.dummyTextures.dummyBlackCubeTexture])}let d=r.getTextureParameter(a.SheenEnvTexture.str);if(d!=null){let s=d[0];(f=i.sheenCube)!=null&&f.isTextureReady?(o.setUniform1iForTexture(u,a.SheenEnvTexture.str,[s,i.sheenCube,this.Qd]),r.setTextureParameter(a.SheenEnvTexture.str,i.sheenCube,this.Qd)):(t=i.specularCube)!=null&&t.isTextureReady?(o.setUniform1iForTexture(u,a.SheenEnvTexture.str,[s,i.specularCube,this.Qd]),r.setTextureParameter(a.SheenEnvTexture.str,i.specularCube,this.Qd)):o.setUniform1iForTexture(u,a.SheenEnvTexture.str,[s,e.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerPrimitive({shaderProgram:e,args:r}){let u=r.entity.tryToGetBlendShape();this.setMorphInfo(e,r.entity.getMesh(),r.primitive,u)}static rb(e){let r=1,u=0;e.specularCube&&(r=e.specularCube.mipmapLevelNumber,u=e.specularCube.iblMipLevelSkip);let i=e.entity.getMeshRenderer(),o=v.LDR_SRGB.index,m=v.LDR_SRGB.index;i.diffuseCubeMap&&(o=i.diffuseCubeMap.hdriFormat.index),i.specularCubeMap&&(m=i.specularCubeMap.hdriFormat.index);let l=i.diffuseCubeMap!=null?i.diffuseCubeMapContribution:0,d=i.specularCubeMap!=null?i.specularCubeMapContribution:0;return{mipmapLevelNumber:r,iblMipLevelSkip:u,meshRenderComponent:i,diffuseHdriType:o,specularHdriType:m,diffuseContribution:l,specularContribution:d}}};export{M as CustomMaterialContent};
@@ -1,18 +1,18 @@
1
- import{GL_DST_ALPHA as V,GL_DST_COLOR as M,GL_ONE as W,GL_ONE_MINUS_DST_ALPHA as v,GL_ONE_MINUS_DST_COLOR as B,GL_ONE_MINUS_SRC_ALPHA as D,GL_ONE_MINUS_SRC_COLOR as U,GL_SRC_ALPHA as k,GL_SRC_ALPHA_SATURATE as H,GL_SRC_COLOR as X,GL_ZERO as P}from"../../../types/index.js";import z from"../../../webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js";import q from"../../../webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js";import Y from"../../../webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js";import Z from"../../../webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.wgsl.js";import{CameraComponent as F}from"../../components/Camera/CameraComponent.js";import{WellKnownComponentTIDs as J}from"../../components/WellKnownComponentTIDs.js";import{HdriFormat as O,ProcessApproach as K,TextureParameter as _}from"../../definitions/index.js";import{AlphaMode as N}from"../../definitions/AlphaMode.js";import{Blend as R}from"../../definitions/Blend.js";import{ComponentType as i}from"../../definitions/ComponentType.js";import{CompositionType as r}from"../../definitions/CompositionType.js";import{ShaderSemantics as E,ShaderSemanticsClass as s}from"../../definitions/ShaderSemantics.js";import{ShaderType as a}from"../../definitions/ShaderType.js";import{MutableVector2 as j}from"../../math/MutableVector2.js";import{MutableVector4 as Q}from"../../math/MutableVector4.js";import{Scalar as l}from"../../math/Scalar.js";import{Vector3 as g}from"../../math/Vector3.js";import{Vector4 as w}from"../../math/Vector4.js";import{Sampler as G}from"../../textures/Sampler.js";import{AbstractMaterialContent as C}from"../core/AbstractMaterialContent.js";var $=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?z:void 0,ee=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?q:void 0,te=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?Y:void 0,ie=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?Z:void 0,t=class t extends C{constructor(n,e,o,m,p,u,h,y,x,b,T,f,c){var S,A,L;super(f,{isMorphing:u,isSkinning:h,isLighting:y});this.n_=!1;this.t_={};this.a_={};this.i_={};let d=this.doShaderReflection(n,ee,$,ie,te,c);switch(this.Qd=new G(n,{minFilter:_.Linear,magFilter:_.Linear,wrapS:_.ClampToEdge,wrapT:_.ClampToEdge,wrapR:_.ClampToEdge}),this.Kd=new G(n,{minFilter:_.LinearMipmapLinear,magFilter:_.Linear,wrapS:_.ClampToEdge,wrapT:_.ClampToEdge,wrapR:_.ClampToEdge}),this.Qd.created||this.Qd.create(),this.Kd.created||this.Kd.create(),o!=null?(this.t_=o.floatProperties,this.a_=o.vectorProperties,this.i_=JSON.parse(JSON.stringify(o.textureProperties))):(this.t_._BlendMode=0,this.t_._BumpScale=1,this.t_._CullMode=2,this.t_._Cutoff=.5,this.t_._DebugMode=0,this.t_._DstBlend=0,this.t_._IndirectLightIntensity=.1,this.t_._LightColorAttenuation=0,this.t_._OutlineColorMode=0,this.t_._OutlineCullMode=1,this.t_._OutlineLightingMix=1,this.t_._OutlineScaledMaxDistance=1,this.t_._OutlineWidth=.5,this.t_._OutlineWidthMode=0,this.t_._ReceiveShadowRate=1,this.t_._RimFresnelPower=1,this.t_._RimLift=0,this.t_._RimLightingMix=0,this.t_._ShadeShift=0,this.t_._ShadeToony=.9,this.t_._ShadingGradeRate=1,this.t_._SrcBlend=1,this.t_._ZWrite=1,this.t_._UvAnimScrollX=0,this.t_._UvAnimScrollY=0,this.t_._UvAnimRotation=0,this.a_._Color=[1,1,1,1],this.a_._EmissionColor=[0,0,0],this.a_._OutlineColor=[0,0,0,1],this.a_._ShadeColor=[.97,.81,.86,1],this.a_._RimColor=[0,0,0]),b&&(this.t_._DebugMode=b),d.push({semantic:"cutoff",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._Cutoff),min:0,max:1},{semantic:"litColor",componentType:i.Float,compositionType:r.Vec4,stage:a.PixelShader,initialValue:w.fromCopyArray(this.a_._Color),min:0,max:1},{semantic:"shadeColor",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,initialValue:g.fromCopyArray(this.a_._ShadeColor),min:0,max:1},{semantic:"bumpScale",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._BumpScale),min:0,max:1},{semantic:"receiveShadowRate",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._ReceiveShadowRate),min:0,max:1},{semantic:"shadingGradeRate",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._ShadingGradeRate),min:0,max:1},{semantic:"shadeShift",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._ShadeShift),min:0,max:1},{semantic:"shadeToony",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._ShadeToony),min:0,max:1},{semantic:"lightColorAttenuation",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._LightColorAttenuation),min:0,max:1},{semantic:"indirectLightIntensity",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._IndirectLightIntensity),min:0,max:1},{semantic:"rimColor",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,initialValue:g.fromCopyArray(this.a_._RimColor),min:0,max:1},{semantic:"rimLightingMix",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._RimLightingMix),min:0,max:1},{semantic:"rimFresnelPower",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._RimFresnelPower),min:0,max:1},{semantic:"rimLift",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._RimLift),min:0,max:1},{semantic:"cameraUp",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,soloDatum:!0,initialValue:g.fromCopyArray([0,1,0]),min:0,max:1},{semantic:"emissionColor",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,initialValue:g.fromCopyArray(this.a_._EmissionColor),min:0,max:1},{semantic:"uvAnimationScrollXSpeedFactor",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,isInternalSetting:!1,initialValue:l.fromCopyNumber((S=this.t_._UvAnimScrollX)!=null?S:0),min:0,max:1},{semantic:"uvAnimationScrollYSpeedFactor",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,isInternalSetting:!1,initialValue:l.fromCopyNumber((A=this.t_._UvAnimScrollY)!=null?A:0),min:0,max:1},{semantic:"uvAnimationRotationSpeedFactor",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,isInternalSetting:!1,initialValue:l.fromCopyNumber((L=this.t_._UvAnimRotation)!=null?L:0),min:0,max:1},{semantic:"wireframe",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,initialValue:g.fromCopyArray([0,0,1]),min:0,max:10},{semantic:"makeOutputSrgb",compositionType:r.Scalar,componentType:i.Bool,stage:a.PixelShader,min:0,max:1,initialValue:l.fromCopyNumber(T?1:0)}),this.t_._DebugMode){case 1:this.r_+=`#define RN_MTOON_DEBUG_NORMAL
1
+ import{GL_DST_ALPHA as M,GL_DST_COLOR as V,GL_ONE as v,GL_ONE_MINUS_DST_ALPHA as W,GL_ONE_MINUS_DST_COLOR as B,GL_ONE_MINUS_SRC_ALPHA as D,GL_ONE_MINUS_SRC_COLOR as k,GL_SRC_ALPHA as U,GL_SRC_ALPHA_SATURATE as H,GL_SRC_COLOR as X,GL_ZERO as P}from"../../../types/index.js";import z from"../../../webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.glsl.js";import q from"../../../webgl/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.glsl.js";import Y from"../../../webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.frag.wgsl.js";import Z from"../../../webgpu/shaderity_shaders/MToon0xSingleShader/MToon0xSingleShader.vert.wgsl.js";import{CameraComponent as F}from"../../components/Camera/CameraComponent.js";import{WellKnownComponentTIDs as J}from"../../components/WellKnownComponentTIDs.js";import{HdriFormat as O,ProcessApproach as K,TextureParameter as S}from"../../definitions/index.js";import{AlphaMode as E}from"../../definitions/AlphaMode.js";import{Blend as N}from"../../definitions/Blend.js";import{ComponentType as r}from"../../definitions/ComponentType.js";import{CompositionType as a}from"../../definitions/CompositionType.js";import{ShaderSemantics as A,ShaderSemanticsClass as o}from"../../definitions/ShaderSemantics.js";import{ShaderType as n}from"../../definitions/ShaderType.js";import{MutableVector2 as j}from"../../math/MutableVector2.js";import{MutableVector4 as Q}from"../../math/MutableVector4.js";import{Scalar as p}from"../../math/Scalar.js";import{Vector3 as C}from"../../math/Vector3.js";import{Vector4 as w}from"../../math/Vector4.js";import{Sampler as G}from"../../textures/Sampler.js";import{AbstractMaterialContent as R}from"../core/AbstractMaterialContent.js";var $=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?z:void 0,ee=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?q:void 0,ie=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?Y:void 0,te=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?Z:void 0,i=class i extends R{constructor(t,e,s,m,c,u,d,_,x,b,g,y,f){var h,T,L;super(y,{isMorphing:u,isSkinning:d,isLighting:_});this.n_=!1;this.i_={};this.a_={};this.t_={};let l=this.doShaderReflection(t,ee,$,te,ie,f);switch(this.Yd=new G(t,{minFilter:S.Linear,magFilter:S.Linear,wrapS:S.ClampToEdge,wrapT:S.ClampToEdge,wrapR:S.ClampToEdge}),this.Qd=new G(t,{minFilter:S.LinearMipmapLinear,magFilter:S.Linear,wrapS:S.ClampToEdge,wrapT:S.ClampToEdge,wrapR:S.ClampToEdge}),this.Yd.created||this.Yd.create(),this.Qd.created||this.Qd.create(),s!=null?(this.i_=s.floatProperties,this.a_=s.vectorProperties,this.t_=JSON.parse(JSON.stringify(s.textureProperties))):(this.i_._BlendMode=0,this.i_._BumpScale=1,this.i_._CullMode=2,this.i_._Cutoff=.5,this.i_._DebugMode=0,this.i_._DstBlend=0,this.i_._IndirectLightIntensity=.1,this.i_._LightColorAttenuation=0,this.i_._OutlineColorMode=0,this.i_._OutlineCullMode=1,this.i_._OutlineLightingMix=1,this.i_._OutlineScaledMaxDistance=1,this.i_._OutlineWidth=.5,this.i_._OutlineWidthMode=0,this.i_._ReceiveShadowRate=1,this.i_._RimFresnelPower=1,this.i_._RimLift=0,this.i_._RimLightingMix=0,this.i_._ShadeShift=0,this.i_._ShadeToony=.9,this.i_._ShadingGradeRate=1,this.i_._SrcBlend=1,this.i_._ZWrite=1,this.i_._UvAnimScrollX=0,this.i_._UvAnimScrollY=0,this.i_._UvAnimRotation=0,this.a_._Color=[1,1,1,1],this.a_._EmissionColor=[0,0,0],this.a_._OutlineColor=[0,0,0,1],this.a_._ShadeColor=[.97,.81,.86,1],this.a_._RimColor=[0,0,0]),b&&(this.i_._DebugMode=b),l.push({semantic:"cutoff",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._Cutoff),min:0,max:1},{semantic:"litColor",componentType:r.Float,compositionType:a.Vec4,stage:n.PixelShader,initialValue:w.fromCopyArray(this.a_._Color),min:0,max:1},{semantic:"shadeColor",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,initialValue:C.fromCopyArray(this.a_._ShadeColor),min:0,max:1},{semantic:"bumpScale",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._BumpScale),min:0,max:1},{semantic:"receiveShadowRate",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._ReceiveShadowRate),min:0,max:1},{semantic:"shadingGradeRate",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._ShadingGradeRate),min:0,max:1},{semantic:"shadeShift",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._ShadeShift),min:0,max:1},{semantic:"shadeToony",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._ShadeToony),min:0,max:1},{semantic:"lightColorAttenuation",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._LightColorAttenuation),min:0,max:1},{semantic:"indirectLightIntensity",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._IndirectLightIntensity),min:0,max:1},{semantic:"rimColor",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,initialValue:C.fromCopyArray(this.a_._RimColor),min:0,max:1},{semantic:"rimLightingMix",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._RimLightingMix),min:0,max:1},{semantic:"rimFresnelPower",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._RimFresnelPower),min:0,max:1},{semantic:"rimLift",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._RimLift),min:0,max:1},{semantic:"cameraUp",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,soloDatum:!0,initialValue:C.fromCopyArray([0,1,0]),min:0,max:1},{semantic:"emissionColor",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,initialValue:C.fromCopyArray(this.a_._EmissionColor),min:0,max:1},{semantic:"uvAnimationScrollXSpeedFactor",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,isInternalSetting:!1,initialValue:p.fromCopyNumber((h=this.i_._UvAnimScrollX)!=null?h:0),min:0,max:1},{semantic:"uvAnimationScrollYSpeedFactor",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,isInternalSetting:!1,initialValue:p.fromCopyNumber((T=this.i_._UvAnimScrollY)!=null?T:0),min:0,max:1},{semantic:"uvAnimationRotationSpeedFactor",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,isInternalSetting:!1,initialValue:p.fromCopyNumber((L=this.i_._UvAnimRotation)!=null?L:0),min:0,max:1},{semantic:"wireframe",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,initialValue:C.fromCopyArray([0,0,1]),min:0,max:10},{semantic:"makeOutputSrgb",compositionType:a.Scalar,componentType:r.Bool,stage:n.PixelShader,min:0,max:1,initialValue:p.fromCopyNumber(g?1:0)}),this.i_._DebugMode){case 1:this.r_+=`#define RN_MTOON_DEBUG_NORMAL
2
2
  `;break;case 2:this.r_+=`#define RN_MTOON_DEBUG_LITSHADERATE
3
3
  `;break}if(e){switch(this.r_+=`#define RN_MTOON_IS_OUTLINE
4
- `,this.t_._OutlineWidthMode){case 0:this.r_+=`#define RN_MTOON_OUTLINE_NONE
4
+ `,this.i_._OutlineWidthMode){case 0:this.r_+=`#define RN_MTOON_OUTLINE_NONE
5
5
  `;break;case 1:this.r_+=`#define RN_MTOON_OUTLINE_WIDTH_WORLD
6
6
  `;break;case 2:this.r_+=`#define RN_MTOON_OUTLINE_WIDTH_SCREEN
7
- `,this.n_=!0;break}switch(this.t_._OutlineColorMode){case 0:this.r_+=`#define RN_MTOON_OUTLINE_COLOR_FIXED
7
+ `,this.n_=!0;break}switch(this.i_._OutlineColorMode){case 0:this.r_+=`#define RN_MTOON_OUTLINE_COLOR_FIXED
8
8
  `;break;case 1:this.r_+=`#define RN_MTOON_OUTLINE_COLOR_MIXED
9
- `;break}d.push({semantic:"outlineWidth",componentType:i.Float,compositionType:r.Scalar,stage:a.VertexShader,initialValue:l.fromCopyNumber(this.t_._OutlineWidth),min:0,max:1},{semantic:"outlineScaledMaxDistance",componentType:i.Float,compositionType:r.Scalar,stage:a.VertexShader,initialValue:l.fromCopyNumber(this.t_._OutlineScaledMaxDistance),min:0,max:1},{semantic:"outlineColor",componentType:i.Float,compositionType:r.Vec3,stage:a.PixelShader,initialValue:w.fromCopyArray(this.a_._OutlineColor),min:0,max:1},{semantic:"outlineLightingMix",componentType:i.Float,compositionType:r.Scalar,stage:a.PixelShader,initialValue:l.fromCopyNumber(this.t_._OutlineLightingMix),min:0,max:1},{semantic:"aspect",componentType:i.Float,compositionType:r.Scalar,stage:a.VertexShader,isInternalSetting:!0,soloDatum:!0,initialValue:l.fromCopyNumber(1),min:0,max:1})}y&&(this.r_+=`#define RN_IS_LIGHTING
10
- `),h&&(this.r_+=`#define RN_IS_SKINNING
9
+ `;break}l.push({semantic:"outlineWidth",componentType:r.Float,compositionType:a.Scalar,stage:n.VertexShader,initialValue:p.fromCopyNumber(this.i_._OutlineWidth),min:0,max:1},{semantic:"outlineScaledMaxDistance",componentType:r.Float,compositionType:a.Scalar,stage:n.VertexShader,initialValue:p.fromCopyNumber(this.i_._OutlineScaledMaxDistance),min:0,max:1},{semantic:"outlineColor",componentType:r.Float,compositionType:a.Vec3,stage:n.PixelShader,initialValue:w.fromCopyArray(this.a_._OutlineColor),min:0,max:1},{semantic:"outlineLightingMix",componentType:r.Float,compositionType:a.Scalar,stage:n.PixelShader,initialValue:p.fromCopyNumber(this.i_._OutlineLightingMix),min:0,max:1},{semantic:"aspect",componentType:r.Float,compositionType:a.Scalar,stage:n.VertexShader,isInternalSetting:!0,soloDatum:!0,initialValue:p.fromCopyNumber(1),min:0,max:1})}_&&(this.r_+=`#define RN_IS_LIGHTING
10
+ `),d&&(this.r_+=`#define RN_IS_SKINNING
11
11
  `),u&&(this.r_+=`#define RN_IS_MORPHING
12
12
  `),x&&(this.r_+=`#define RN_USE_TANGENT_ATTRIBUTE
13
- `),this.i_._BumpMap>=0&&(this.r_+=`#define RN_MTOON_HAS_BUMPMAP
14
- `),this.i_._OutlineWidthTexture>=0&&(this.r_+=`#define RN_MTOON_HAS_OUTLINE_WIDTH_TEXTURE
15
- `),m=[n.dummyTextures.dummyWhiteTexture,n.dummyTextures.dummyBlackTexture],this.i_._BumpMap=0,this.i_._EmissionMap=1,this.i_._MainTex=0,this.i_._OutlineWidthTexture=0,this.i_._UvAnimMaskTexture=0,this.i_._ReceiveShadowTexture=0,this.i_._RimTexture=1,this.i_._ShadeTexture=0,this.i_._ShadingGradeTexture=0,this.i_._SphereAdd=1,this.o_(m,p,d,e),this.setShaderSemanticsInfoArray(d)}o_(n,e,o,m){o.push({semantic:"litColorTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[1,n[this.i_._MainTex],e[this.i_._MainTex]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"shadeColorTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[2,n[this.i_._ShadeTexture],e[this.i_._ShadeTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"receiveShadowTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[3,n[this.i_._ReceiveShadowTexture],e[this.i_._ReceiveShadowTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"shadingGradeTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[4,n[this.i_._ShadingGradeTexture],e[this.i_._ShadingGradeTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"rimTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[5,n[this.i_._RimTexture],e[this.i_._RimTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"matCapTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[9,n[this.i_._SphereAdd],e[this.i_._SphereAdd]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"emissionTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[10,n[this.i_._EmissionMap],e[this.i_._EmissionMap]],min:0,max:Number.MAX_SAFE_INTEGER}),o.push({semantic:"normalTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[11,n[this.i_._BumpMap],e[this.i_._BumpMap]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"uvAnimationMaskTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.PixelShader,initialValue:[12,n[this.i_._UvAnimMaskTexture],e[this.i_._UvAnimMaskTexture]],min:0,max:Number.MAX_SAFE_INTEGER}),m&&o.push({semantic:"outlineWidthTexture",componentType:i.Int,compositionType:r.Texture2D,stage:a.VertexShader,initialValue:[13,n[this.i_._OutlineWidthTexture],e[this.i_._OutlineWidthTexture]],min:0,max:Number.MAX_SAFE_INTEGER})}setMaterialParameters(n,e,o){if(this.t_._BlendMode!==0){switch(this.t_._BlendMode){case 1:this.r_+=`#define RN_ALPHATEST_ON
16
- `,e.alphaMode=N.Mask;break;case 2:this.r_+=`#define RN_ALPHABLEND_ON
17
- `,e.alphaMode=N.Blend;break;case 3:this.r_+=`#define RN_ALPHABLEND_ON
18
- `,e.alphaMode=N.Blend;break}let m=32774,p=t.s_(n),u=t.unityBlendEnumCorrespondence(this.t_._SrcBlend),h=t.unityBlendEnumCorrespondence(this.t_._DstBlend);e.setBlendEquationMode(R.from(m),p!=null?R.from(p):void 0),e.setBlendFuncFactor(R.from(u),R.from(h))}if(o)switch(this.t_._OutlineCullMode){case 0:e.cullFace=!1;break;case 1:e.cullFace=!0,e.cullFaceBack=!1;break;case 2:e.cullFace=!0,e.cullFaceBack=!0;break}else switch(this.t_._CullMode){case 0:e.cullFace=!1;break;case 1:e.cullFace=!0,e.cullFaceBack=!1;break;case 2:e.cullFace=!0,e.cullFaceBack=!0;break}e.zWriteWhenBlend=this.t_._ZWrite===1}static s_(n){if(n.engineState.currentProcessApproach===K.WebGPU)return 32776;let o=n.webglResourceRepository.currentWebGLContextWrapper,m=o.getRawContextAsWebGL2();return o.isWebGL2?m.MAX:o.webgl1ExtBM?o.webgl1ExtBM.MAX_EXT:m.FUNC_ADD}_setInternalSettingParametersToGpuWebGpu({engine:n,material:e,args:o}){let m=n.componentRepository.getComponentFromComponentTID(J.CameraComponentTID,o.cameraComponentSid);e.setParameter("cameraUp",m.upInner),this.n_&&e.setParameter("aspect",m.aspect);let{mipmapLevelNumber:p,meshRenderComponent:u,diffuseHdriType:h,specularHdriType:y,diffuseContribution:x,specularContribution:b}=t.tb(o),T=C.ib;T.x=p,T.y=x,T.z=b,T.w=u.rotationOfCubeMap,e.setParameter("iblParameter",T);let f=C.nb;f.x=h,f.y=y,e.setParameter("hdriFormat",f);let c=o.entity.tryToGetMeshRenderer();if(c!=null&&c.diffuseCubeMap!=null&&c.specularCubeMap!=null){let d=Q.zero(),S=j.zero();d.x=c.specularCubeMap.mipmapLevelNumber,d.y=c.diffuseCubeMapContribution,d.z=c.specularCubeMapContribution,d.w=c.rotationOfCubeMap,e.setParameter("iblParameter",d),S.x=c.diffuseCubeMap.hdriFormat.index,S.y=c.specularCubeMap.hdriFormat.index,e.setParameter("hdriFormat",S)}}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:n,material:e,shaderProgram:o,args:m}){var h;let p=n.webglResourceRepository,u=e.getTextureParameter(E.DiffuseEnvTexture.str);if(u!=null){let y=u[0];(h=m.diffuseCube)!=null&&h.isTextureReady?p.setUniform1iForTexture(o,E.DiffuseEnvTexture.str,[y,m.diffuseCube,this.Qd]):p.setUniform1iForTexture(o,E.DiffuseEnvTexture.str,[y,n.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:n,material:e,shaderProgram:o,firstTime:m,args:p}){let u=p.renderPass.cameraComponent;u==null&&(u=n.componentRepository.getComponent(F,F.getCurrent(n))),e.setParameter("cameraUp",u.upInner),this.n_&&e.setParameter("aspect",u.aspect);let{mipmapLevelNumber:h,meshRenderComponent:y,diffuseHdriType:x,specularHdriType:b,diffuseContribution:T,specularContribution:f}=t.tb(p),c=C.ib;c.x=h,c.y=T,c.z=f,c.w=y.rotationOfCubeMap,e.setParameter("iblParameter",c);let d=C.nb;d.x=x,d.y=b,e.setParameter("hdriFormat",d);let S=p.entity.tryToGetBlendShape();this.setMorphInfo(o,p.entity.getMesh(),p.primitive,S)}static unityBlendEnumCorrespondence(n){let e=P;switch(n){case 0:e=P;break;case 1:e=W;break;case 2:e=M;break;case 3:e=X;break;case 4:e=B;break;case 5:e=k;break;case 6:e=U;break;case 7:e=V;break;case 8:e=v;break;case 9:e=H;break;case 10:e=D;break}return e}static tb(n){let e=1;n.specularCube&&(e=n.specularCube.mipmapLevelNumber);let o=n.entity.getMeshRenderer(),m=O.LDR_SRGB.index,p=O.LDR_SRGB.index;o.diffuseCubeMap&&(m=o.diffuseCubeMap.hdriFormat.index),o.specularCubeMap&&(p=o.specularCubeMap.hdriFormat.index);let u=o.diffuseCubeMap!=null?o.diffuseCubeMapContribution:0,h=o.specularCubeMap!=null?o.specularCubeMapContribution:0;return{mipmapLevelNumber:e,meshRenderComponent:o,diffuseHdriType:m,specularHdriType:p,diffuseContribution:u,specularContribution:h}}};t._Cutoff=new s({str:"cutoff"}),t._Color=new s({str:"litColor"}),t._ShadeColor=new s({str:"shadeColor"}),t._litColorTexture=new s({str:"litColorTexture"}),t._shadeColorTexture=new s({str:"shadeColorTexture"}),t._BumpScale=new s({str:"normalScale"}),t._normalTexture=new s({str:"normalTexture"}),t._ReceiveShadowRate=new s({str:"receiveShadowRate"}),t._receiveShadowTexture=new s({str:"receiveShadowTexture"}),t._ShadingGradeRate=new s({str:"shadingGradeRate"}),t._shadingGradeTexture=new s({str:"shadingGradeTexture"}),t._ShadeShift=new s({str:"shadeShift"}),t._ShadeToony=new s({str:"shadeToony"}),t._LightColorAttenuation=new s({str:"lightColorAttenuation"}),t._AmbientColor=new s({str:"ambientColor"}),t._IndirectLightIntensity=new s({str:"indirectLightIntensity"}),t._rimTexture=new s({str:"rimTexture"}),t._RimColor=new s({str:"rimColor"}),t._RimLightingMix=new s({str:"rimLightingMix"}),t._RimFresnelPower=new s({str:"rimFresnelPower"}),t._RimLift=new s({str:"rimLift"}),t._matCapTexture=new s({str:"matCapTexture"}),t._EmissionColor=new s({str:"emissionColor"}),t._emissionTexture=new s({str:"emissionTexture"}),t._OutlineWidthTexture=new s({str:"outlineWidthTexture"}),t._OutlineWidth=new s({str:"outlineWidth"}),t._OutlineScaledMaxDistance=new s({str:"outlineScaledMaxDistance"}),t._OutlineColor=new s({str:"outlineColor"}),t._OutlineLightingMix=new s({str:"outlineLightingMix"}),t.Aspect=new s({str:"aspect"}),t.CameraUp=new s({str:"cameraUp"});var I=t;export{I as MToon0xMaterialContent};
13
+ `),this.t_._BumpMap>=0&&(this.r_+=`#define RN_MTOON_HAS_BUMPMAP
14
+ `),this.t_._OutlineWidthTexture>=0&&(this.r_+=`#define RN_MTOON_HAS_OUTLINE_WIDTH_TEXTURE
15
+ `),m=[t.dummyTextures.dummyWhiteTexture,t.dummyTextures.dummyBlackTexture],this.t_._BumpMap=0,this.t_._EmissionMap=1,this.t_._MainTex=0,this.t_._OutlineWidthTexture=0,this.t_._UvAnimMaskTexture=0,this.t_._ReceiveShadowTexture=0,this.t_._RimTexture=1,this.t_._ShadeTexture=0,this.t_._ShadingGradeTexture=0,this.t_._SphereAdd=1,this.o_(m,c,l,e),this.setShaderSemanticsInfoArray(l)}o_(t,e,s,m){s.push({semantic:"litColorTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[1,t[this.t_._MainTex],e[this.t_._MainTex]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"shadeColorTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[2,t[this.t_._ShadeTexture],e[this.t_._ShadeTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"receiveShadowTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[3,t[this.t_._ReceiveShadowTexture],e[this.t_._ReceiveShadowTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"shadingGradeTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[4,t[this.t_._ShadingGradeTexture],e[this.t_._ShadingGradeTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"rimTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[5,t[this.t_._RimTexture],e[this.t_._RimTexture]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"matCapTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[9,t[this.t_._SphereAdd],e[this.t_._SphereAdd]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"emissionTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[10,t[this.t_._EmissionMap],e[this.t_._EmissionMap]],min:0,max:Number.MAX_SAFE_INTEGER}),s.push({semantic:"normalTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[11,t[this.t_._BumpMap],e[this.t_._BumpMap]],min:0,max:Number.MAX_SAFE_INTEGER},{semantic:"uvAnimationMaskTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.PixelShader,initialValue:[12,t[this.t_._UvAnimMaskTexture],e[this.t_._UvAnimMaskTexture]],min:0,max:Number.MAX_SAFE_INTEGER}),m&&s.push({semantic:"outlineWidthTexture",componentType:r.Int,compositionType:a.Texture2D,stage:n.VertexShader,initialValue:[13,t[this.t_._OutlineWidthTexture],e[this.t_._OutlineWidthTexture]],min:0,max:Number.MAX_SAFE_INTEGER})}setMaterialParameters(t,e,s){if(this.i_._BlendMode!==0){switch(this.i_._BlendMode){case 1:this.r_+=`#define RN_ALPHATEST_ON
16
+ `,e.alphaMode=E.Mask;break;case 2:this.r_+=`#define RN_ALPHABLEND_ON
17
+ `,e.alphaMode=E.Blend;break;case 3:this.r_+=`#define RN_ALPHABLEND_ON
18
+ `,e.alphaMode=E.Blend;break}let m=32774,c=i.s_(t),u=i.unityBlendEnumCorrespondence(this.i_._SrcBlend),d=i.unityBlendEnumCorrespondence(this.i_._DstBlend);e.setBlendEquationMode(N.from(m),c!=null?N.from(c):void 0),e.setBlendFuncFactor(N.from(u),N.from(d))}if(s)switch(this.i_._OutlineCullMode){case 0:e.cullFace=!1;break;case 1:e.cullFace=!0,e.cullFaceBack=!1;break;case 2:e.cullFace=!0,e.cullFaceBack=!0;break}else switch(this.i_._CullMode){case 0:e.cullFace=!1;break;case 1:e.cullFace=!0,e.cullFaceBack=!1;break;case 2:e.cullFace=!0,e.cullFaceBack=!0;break}e.zWriteWhenBlend=this.i_._ZWrite===1}static s_(t){if(t.engineState.currentProcessApproach===K.WebGPU)return 32776;let s=t.webglResourceRepository.currentWebGLContextWrapper,m=s.getRawContextAsWebGL2();return s.isWebGL2?m.MAX:s.webgl1ExtBM?s.webgl1ExtBM.MAX_EXT:m.FUNC_ADD}_setInternalSettingParametersToGpuWebGpu({engine:t,material:e,args:s}){let m=t.componentRepository.getComponentFromComponentTID(J.CameraComponentTID,s.cameraComponentSid);e.setParameter("cameraUp",m.upInner),this.n_&&e.setParameter("aspect",m.aspect);let{mipmapLevelNumber:c,iblMipLevelSkip:u,meshRenderComponent:d,diffuseHdriType:_,specularHdriType:x,diffuseContribution:b,specularContribution:g}=i.rb(s),y=R.nb;y.x=c,y.y=b,y.z=g,y.w=d.rotationOfCubeMap,e.setParameter("iblParameter",y),e.setParameter("iblMipLevelSkip",u);let f=R.sb;f.x=_,f.y=x,e.setParameter("hdriFormat",f);let l=s.entity.tryToGetMeshRenderer();if(l!=null&&l.diffuseCubeMap!=null&&l.specularCubeMap!=null){let h=Q.zero(),T=j.zero();h.x=l.specularCubeMap.mipmapLevelNumber,h.y=l.diffuseCubeMapContribution,h.z=l.specularCubeMapContribution,h.w=l.rotationOfCubeMap,e.setParameter("iblParameter",h),e.setParameter("iblMipLevelSkip",l.specularCubeMap.iblMipLevelSkip),T.x=l.diffuseCubeMap.hdriFormat.index,T.y=l.specularCubeMap.hdriFormat.index,e.setParameter("hdriFormat",T)}}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:t,material:e,shaderProgram:s,args:m}){var d;let c=t.webglResourceRepository,u=e.getTextureParameter(A.DiffuseEnvTexture.str);if(u!=null){let _=u[0];(d=m.diffuseCube)!=null&&d.isTextureReady?c.setUniform1iForTexture(s,A.DiffuseEnvTexture.str,[_,m.diffuseCube,this.Yd]):c.setUniform1iForTexture(s,A.DiffuseEnvTexture.str,[_,t.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:t,material:e,shaderProgram:s,firstTime:m,args:c}){let u=c.renderPass.cameraComponent;u==null&&(u=t.componentRepository.getComponent(F,F.getCurrent(t))),e.setParameter("cameraUp",u.upInner),this.n_&&e.setParameter("aspect",u.aspect);let{mipmapLevelNumber:d,iblMipLevelSkip:_,meshRenderComponent:x,diffuseHdriType:b,specularHdriType:g,diffuseContribution:y,specularContribution:f}=i.rb(c),l=R.nb;l.x=d,l.y=y,l.z=f,l.w=x.rotationOfCubeMap,e.setParameter("iblParameter",l),e.setParameter("iblMipLevelSkip",_);let h=R.sb;h.x=b,h.y=g,e.setParameter("hdriFormat",h);let T=c.entity.tryToGetBlendShape();this.setMorphInfo(s,c.entity.getMesh(),c.primitive,T)}static unityBlendEnumCorrespondence(t){let e=P;switch(t){case 0:e=P;break;case 1:e=v;break;case 2:e=V;break;case 3:e=X;break;case 4:e=B;break;case 5:e=U;break;case 6:e=k;break;case 7:e=M;break;case 8:e=W;break;case 9:e=H;break;case 10:e=D;break}return e}static rb(t){let e=1,s=0;t.specularCube&&(e=t.specularCube.mipmapLevelNumber,s=t.specularCube.iblMipLevelSkip);let m=t.entity.getMeshRenderer(),c=O.LDR_SRGB.index,u=O.LDR_SRGB.index;m.diffuseCubeMap&&(c=m.diffuseCubeMap.hdriFormat.index),m.specularCubeMap&&(u=m.specularCubeMap.hdriFormat.index);let d=m.diffuseCubeMap!=null?m.diffuseCubeMapContribution:0,_=m.specularCubeMap!=null?m.specularCubeMapContribution:0;return{mipmapLevelNumber:e,iblMipLevelSkip:s,meshRenderComponent:m,diffuseHdriType:c,specularHdriType:u,diffuseContribution:d,specularContribution:_}}};i._Cutoff=new o({str:"cutoff"}),i._Color=new o({str:"litColor"}),i._ShadeColor=new o({str:"shadeColor"}),i._litColorTexture=new o({str:"litColorTexture"}),i._shadeColorTexture=new o({str:"shadeColorTexture"}),i._BumpScale=new o({str:"normalScale"}),i._normalTexture=new o({str:"normalTexture"}),i._ReceiveShadowRate=new o({str:"receiveShadowRate"}),i._receiveShadowTexture=new o({str:"receiveShadowTexture"}),i._ShadingGradeRate=new o({str:"shadingGradeRate"}),i._shadingGradeTexture=new o({str:"shadingGradeTexture"}),i._ShadeShift=new o({str:"shadeShift"}),i._ShadeToony=new o({str:"shadeToony"}),i._LightColorAttenuation=new o({str:"lightColorAttenuation"}),i._AmbientColor=new o({str:"ambientColor"}),i._IndirectLightIntensity=new o({str:"indirectLightIntensity"}),i._rimTexture=new o({str:"rimTexture"}),i._RimColor=new o({str:"rimColor"}),i._RimLightingMix=new o({str:"rimLightingMix"}),i._RimFresnelPower=new o({str:"rimFresnelPower"}),i._RimLift=new o({str:"rimLift"}),i._matCapTexture=new o({str:"matCapTexture"}),i._EmissionColor=new o({str:"emissionColor"}),i._emissionTexture=new o({str:"emissionTexture"}),i._OutlineWidthTexture=new o({str:"outlineWidthTexture"}),i._OutlineWidth=new o({str:"outlineWidth"}),i._OutlineScaledMaxDistance=new o({str:"outlineScaledMaxDistance"}),i._OutlineColor=new o({str:"outlineColor"}),i._OutlineLightingMix=new o({str:"outlineLightingMix"}),i.Aspect=new o({str:"aspect"}),i.CameraUp=new o({str:"cameraUp"});var I=i;export{I as MToon0xMaterialContent};
@@ -1,6 +1,6 @@
1
- import T from"../../../webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js";import R from"../../../webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js";import M from"../../../webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js";import y from"../../../webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js";import{HdriFormat as h}from"../../definitions/HdriFormat.js";import{ShaderSemantics as b}from"../../definitions/ShaderSemantics.js";import{TextureParameter as p}from"../../definitions/TextureParameter.js";import{MutableVector2 as G}from"../../math/MutableVector2.js";import{MutableVector4 as x}from"../../math/MutableVector4.js";import{Sampler as g}from"../../textures/Sampler.js";import{AbstractMaterialContent as c}from"../core/AbstractMaterialContent.js";var P=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?T:void 0,L=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?R:void 0,E=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?M:void 0,N=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?y:void 0,S=class _ extends c{constructor(e,i,r,n,t,s,m){super(i,{isMorphing:r,isSkinning:n,isLighting:t});let u=this.doShaderReflection(e,L,P,N,E,m);this.Qd=new g(e,{minFilter:p.Linear,magFilter:p.Linear,wrapS:p.ClampToEdge,wrapT:p.ClampToEdge,wrapR:p.ClampToEdge}),this.Kd=new g(e,{minFilter:p.LinearMipmapLinear,magFilter:p.Linear,wrapS:p.ClampToEdge,wrapT:p.ClampToEdge,wrapR:p.ClampToEdge}),this.Qd.created||this.Qd.create(),this.Kd.created||this.Kd.create(),t&&(this.r_+=`#define RN_IS_LIGHTING
2
- `),n&&(this.r_+=`#define RN_IS_SKINNING
3
- `),r&&(this.r_+=`#define RN_IS_MORPHING
4
- `),s&&(this.r_+=`#define RN_MTOON_IS_OUTLINE
5
- `),this.setShaderSemanticsInfoArray(u)}setMaterialParameters(e,i,r){i?(e.cullFace=!0,e.cullFaceBack=!1):r.doubleSided?e.cullFace=!1:(e.cullFace=!0,e.cullFaceBack=!0),r.alphaMode==="MASK"&&(this.r_+=`#define RN_ALPHATEST_ON
6
- `)}_setInternalSettingParametersToGpuWebGpu({material:e,args:i}){let{mipmapLevelNumber:r,meshRenderComponent:n,diffuseHdriType:t,specularHdriType:s,diffuseContribution:m,specularContribution:u}=_.tb(i),d=c.ib;d.x=r,d.y=m,d.z=u,d.w=n.rotationOfCubeMap,e.setParameter("iblParameter",d);let l=c.nb;l.x=t,l.y=s,e.setParameter("hdriFormat",l);let a=i.entity.tryToGetMeshRenderer();if(a!=null&&a.diffuseCubeMap!=null&&a.specularCubeMap!=null){let o=x.zero(),f=G.zero();o.x=a.specularCubeMap.mipmapLevelNumber,o.y=a.diffuseCubeMapContribution,o.z=a.specularCubeMapContribution,o.w=a.rotationOfCubeMap,e.setParameter("iblParameter",o),f.x=a.diffuseCubeMap.hdriFormat.index,f.y=a.specularCubeMap.hdriFormat.index,e.setParameter("hdriFormat",f)}}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:e,material:i,shaderProgram:r,args:n}){var m;let t=e.webglResourceRepository,s=i.getTextureParameter(b.DiffuseEnvTexture.str);if(s!=null){let u=s[0];(m=n.diffuseCube)!=null&&m.isTextureReady?t.setUniform1iForTexture(r,b.DiffuseEnvTexture.str,[u,n.diffuseCube,this.Qd]):t.setUniform1iForTexture(r,b.DiffuseEnvTexture.str,[u,e.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:e,material:i,shaderProgram:r,firstTime:n,args:t}){let{mipmapLevelNumber:s,meshRenderComponent:m,diffuseHdriType:u,specularHdriType:d,diffuseContribution:l,specularContribution:a}=_.tb(t),o=c.ib;o.x=s,o.y=l,o.z=a,o.w=m.rotationOfCubeMap,i.setParameter("iblParameter",o);let f=c.nb;f.x=u,f.y=d,i.setParameter("hdriFormat",f);let C=t.entity.tryToGetBlendShape();this.setMorphInfo(r,t.entity.getMesh(),t.primitive,C)}static tb(e){let i=1;e.specularCube&&(i=e.specularCube.mipmapLevelNumber);let r=e.entity.getMeshRenderer(),n=h.LDR_SRGB.index,t=h.LDR_SRGB.index;r.diffuseCubeMap&&(n=r.diffuseCubeMap.hdriFormat.index),r.specularCubeMap&&(t=r.specularCubeMap.hdriFormat.index);let s=r.diffuseCubeMap!=null?r.diffuseCubeMapContribution:0,m=r.specularCubeMap!=null?r.specularCubeMapContribution:0;return{mipmapLevelNumber:i,meshRenderComponent:r,diffuseHdriType:n,specularHdriType:t,diffuseContribution:s,specularContribution:m}}};export{S as MToon1MaterialContent};
1
+ import T from"../../../webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.glsl.js";import R from"../../../webgl/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.glsl.js";import y from"../../../webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.frag.wgsl.js";import G from"../../../webgpu/shaderity_shaders/MToon1SingleShader/MToon1SingleShader.vert.wgsl.js";import{HdriFormat as h}from"../../definitions/HdriFormat.js";import{ShaderSemantics as _}from"../../definitions/ShaderSemantics.js";import{TextureParameter as u}from"../../definitions/TextureParameter.js";import{MutableVector2 as L}from"../../math/MutableVector2.js";import{MutableVector4 as P}from"../../math/MutableVector4.js";import{Sampler as g}from"../../textures/Sampler.js";import{AbstractMaterialContent as b}from"../core/AbstractMaterialContent.js";var x=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?T:void 0,v=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?R:void 0,E=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?y:void 0,N=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?G:void 0,C=class S extends b{constructor(e,t,i,r,n,o,s){super(t,{isMorphing:i,isSkinning:r,isLighting:n});let m=this.doShaderReflection(e,v,x,N,E,s);this.Yd=new g(e,{minFilter:u.Linear,magFilter:u.Linear,wrapS:u.ClampToEdge,wrapT:u.ClampToEdge,wrapR:u.ClampToEdge}),this.Qd=new g(e,{minFilter:u.LinearMipmapLinear,magFilter:u.Linear,wrapS:u.ClampToEdge,wrapT:u.ClampToEdge,wrapR:u.ClampToEdge}),this.Yd.created||this.Yd.create(),this.Qd.created||this.Qd.create(),n&&(this.r_+=`#define RN_IS_LIGHTING
2
+ `),r&&(this.r_+=`#define RN_IS_SKINNING
3
+ `),i&&(this.r_+=`#define RN_IS_MORPHING
4
+ `),o&&(this.r_+=`#define RN_MTOON_IS_OUTLINE
5
+ `),this.setShaderSemanticsInfoArray(m)}setMaterialParameters(e,t,i){t?(e.cullFace=!0,e.cullFaceBack=!1):i.doubleSided?e.cullFace=!1:(e.cullFace=!0,e.cullFaceBack=!0),i.alphaMode==="MASK"&&(this.r_+=`#define RN_ALPHATEST_ON
6
+ `)}_setInternalSettingParametersToGpuWebGpu({material:e,args:t}){let{mipmapLevelNumber:i,iblMipLevelSkip:r,meshRenderComponent:n,diffuseHdriType:o,specularHdriType:s,diffuseContribution:m,specularContribution:c}=S.rb(t),l=b.nb;l.x=i,l.y=m,l.z=c,l.w=n.rotationOfCubeMap,e.setParameter("iblParameter",l),e.setParameter("iblMipLevelSkip",r);let f=b.sb;f.x=o,f.y=s,e.setParameter("hdriFormat",f);let a=t.entity.tryToGetMeshRenderer();if(a!=null&&a.diffuseCubeMap!=null&&a.specularCubeMap!=null){let p=P.zero(),d=L.zero();p.x=a.specularCubeMap.mipmapLevelNumber,p.y=a.diffuseCubeMapContribution,p.z=a.specularCubeMapContribution,p.w=a.rotationOfCubeMap,e.setParameter("iblParameter",p),e.setParameter("iblMipLevelSkip",a.specularCubeMap.iblMipLevelSkip),d.x=a.diffuseCubeMap.hdriFormat.index,d.y=a.specularCubeMap.hdriFormat.index,e.setParameter("hdriFormat",d)}}_setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:e,material:t,shaderProgram:i,args:r}){var s;let n=e.webglResourceRepository,o=t.getTextureParameter(_.DiffuseEnvTexture.str);if(o!=null){let m=o[0];(s=r.diffuseCube)!=null&&s.isTextureReady?n.setUniform1iForTexture(i,_.DiffuseEnvTexture.str,[m,r.diffuseCube,this.Yd]):n.setUniform1iForTexture(i,_.DiffuseEnvTexture.str,[m,e.dummyTextures.dummyBlackCubeTexture])}}_setInternalSettingParametersToGpuWebGLPerMaterial({engine:e,material:t,shaderProgram:i,firstTime:r,args:n}){let{mipmapLevelNumber:o,iblMipLevelSkip:s,meshRenderComponent:m,diffuseHdriType:c,specularHdriType:l,diffuseContribution:f,specularContribution:a}=S.rb(n),p=b.nb;p.x=o,p.y=f,p.z=a,p.w=m.rotationOfCubeMap,t.setParameter("iblParameter",p),t.setParameter("iblMipLevelSkip",s);let d=b.sb;d.x=c,d.y=l,t.setParameter("hdriFormat",d);let M=n.entity.tryToGetBlendShape();this.setMorphInfo(i,n.entity.getMesh(),n.primitive,M)}static rb(e){let t=1,i=0;e.specularCube&&(t=e.specularCube.mipmapLevelNumber,i=e.specularCube.iblMipLevelSkip);let r=e.entity.getMeshRenderer(),n=h.LDR_SRGB.index,o=h.LDR_SRGB.index;r.diffuseCubeMap&&(n=r.diffuseCubeMap.hdriFormat.index),r.specularCubeMap&&(o=r.specularCubeMap.hdriFormat.index);let s=r.diffuseCubeMap!=null?r.diffuseCubeMapContribution:0,m=r.specularCubeMap!=null?r.specularCubeMapContribution:0;return{mipmapLevelNumber:t,iblMipLevelSkip:i,meshRenderComponent:r,diffuseHdriType:n,specularHdriType:o,diffuseContribution:s,specularContribution:m}}};export{C as MToon1MaterialContent};
@@ -1 +1 @@
1
- import x from"../../../_deps/shaderity.js";import{RnObject as P}from"../../core/RnObject.js";import{CompositionType as I}from"../../definitions/CompositionType.js";import{ProcessApproach as v}from"../../definitions/ProcessApproach.js";import{ShaderType as f}from"../../definitions/ShaderType.js";import{MutableMatrix44 as _}from"../../math/MutableMatrix44.js";import{MutableVector2 as O}from"../../math/MutableVector2.js";import{MutableVector4 as G}from"../../math/MutableVector4.js";import{Vector3 as W}from"../../math/Vector3.js";import{Logger as V}from"../../misc/Logger.js";import{ShaderityUtilityWebGL as D}from"./ShaderityUtilityWebGL.js";import{ShaderityUtilityWebGPU as U}from"./ShaderityUtilityWebGPU.js";var l=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?D:void 0,S=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?U:void 0,y=x.default||x,i=class i extends P{constructor(e,{isMorphing:t=!1,isSkinning:a=!1,isLighting:n=!1}={},r,o,s){super();this.aS=[];this.r_="";this.shaderType=f.VertexAndPixelShader;this.pS="";this.nS="";this.tS=e,s&&(this._engine=s),this.kx=t,this.cS=a,this.ix=n,this.fS=i.hS++,this.setVertexShaderityObject(r,s),this.setPixelShaderityObject(o,s)}get isMultiDrawCompatible(){return!0}static mS(e){let t=i.iS.get(e);return t||(t=new Map,i.iS.set(e,t)),t}static dS(e){let t=i.oS.get(e);return t||(t=new Map,i.oS.set(e,t)),t}static lS(e){let t=i.sS.get(e);return t||(t=new Map,i.sS.set(e,t)),t}setVertexShaderityObject(e,t){if(e){let a=t!=null?t:this._engine;a&&i.mS(a.objectUID).set(this.tS,e)}}setPixelShaderityObject(e,t){if(e){let a=t!=null?t:this._engine;a&&i.dS(a.objectUID).set(this.tS,e)}}makeMaterialSemanticsVariantName(){let e="";for(let t of this.aS)e+=`${t.semantic}_`;this.nS=`semanticsVariation_${e}`,this.pS=`${this.tS}_${this.nS}`}getMaterialSemanticsVariantName(){return this.pS}getMaterialVariationIdentifier(){return this.nS}getBaseMaterialName(){return this.tS.replace(/__$/,"")}get vertexShaderityObject(){if(this._engine)return i.mS(this._engine.objectUID).get(this.tS)}get pixelShaderityObject(){if(this._engine)return i.dS(this._engine.objectUID).get(this.tS)}getDefinitions(){return this.r_}static getMaterialNode(e){return i.materialNodes[e]}get _semanticsInfoArray(){return this.aS}get isSkinning(){return this.cS}get isMorphing(){return this.kx}get isLighting(){return this.ix}setShaderSemanticsInfoArray(e){let t=new Map;for(let r of e)t.set(r.semantic,r);let a=[];for(let r of t.values())a.push(r);let n=new Set;n.add(0),a.forEach(r=>{if(I.isTexture(r.compositionType)){let o=r.initialValue[0];o>0&&n.add(o)}}),a.forEach(r=>{if(I.isTexture(r.compositionType)&&r.initialValue[0]<0){let s=-1;for(let p=1;p<32;p++)if(!n.has(p)){s=p;break}s===-1&&V.default.warn(`All texture slots (1-31) are occupied. Cannot assign a valid slot for semantic "${r.semantic}". This may cause rendering issues.`),r.initialValue[0]=s,n.add(s)}}),this.aS=a,this.makeMaterialSemanticsVariantName()}setupBasicInfo(e,t,a,n,r,o){let s=t.entity.tryToGetBlendShape();this.setMorphInfo(a,t.entity.getMesh(),t.primitive,s)}setWorldMatrix(e,t){e._gl.uniformMatrix4fv(e.worldMatrix,!1,t._v)}setNormalMatrix(e,t){e._gl.uniformMatrix3fv(e.normalMatrix,!1,t._v)}setIsBillboard(e,t){e._gl.uniform1i(e.isBillboard,t?1:0)}setIsVisible(e,t){e._gl.uniform1i(e.isVisible,t?1:0)}setViewInfo(e,t,a,n){let r,o;if(a){let s=t.entity.engine._webXRSystemIfEnabled;s!=null&&s.isWebXRMode&&(r=s._getViewMatrixAt(n),o=s._getCameraWorldPositionAt(n))}else t?(o=t.worldPosition,r=t.viewMatrix):(r=_.identity(),o=W.fromCopyArray([0,0,10]));e._gl.uniformMatrix4fv(e.viewMatrix,!1,r._v),e._gl.uniform3fv(e.viewPosition,o._v)}setProjection(e,t,a,n){let r;if(a){let o=t.entity.engine._webXRSystemIfEnabled;o!=null&&o.isWebXRMode&&(r=o._getProjectMatrixAt(n))}else t?r=t.projectionMatrix:r=_.identity();e._gl.uniformMatrix4fv(e.projectionMatrix,!1,r._v)}setMorphInfo(e,t,a,n){if(!this.kx||a.targets.length===0)return;let r=a.constructor.getPrimitiveIdxHasMorph(a.primitiveUid);e._gl.uniform1i(e.currentPrimitiveIdx,r)}_setInternalSettingParametersToGpuWebGLPerShaderProgram(e){}_setInternalSettingParametersToGpuWebGLPerMaterial(e){}_setInternalSettingParametersToGpuWebGLPerPrimitive(e){}_setInternalSettingParametersToGpuWebGpu(e){}getDefinition(){return""}doShaderReflection(e,t,a,n,r,o){this._engine=e;let s=o.join(""),p=i.lS(e.objectUID),M=p.get(this.tS+s);if(M!=null)return M.concat();let u,b;if(e.processApproach===v.WebGPU){let c=y.processPragma(n,!1,o),m=y.processPragma(r,!1,o);u=S.getShaderDataReflection(e,c),b=S.getShaderDataReflection(e,m);let h=S.getShaderDataReflection(e,n),g=S.getShaderDataReflection(e,r);this.setVertexShaderityObject(h.shaderityObject,e),this.setPixelShaderityObject(g.shaderityObject,e)}else{let c=y.processPragma(t,!0,o),m=y.processPragma(a,!0,o);u=l.getShaderDataReflection(e,c),b=l.getShaderDataReflection(e,m);let h=l.getShaderDataReflection(e,t),g=l.getShaderDataReflection(e,a);this.setVertexShaderityObject(h.shaderityObject,e),this.setPixelShaderityObject(g.shaderityObject,e)}let d=[];for(let c of u.shaderSemanticsInfoArray)c.stage=f.VertexShader,d.push(c);for(let c of b.shaderSemanticsInfoArray){let m=d.find(h=>h.semantic===c.semantic);m?m.stage=f.VertexAndPixelShader:(c.stage=f.PixelShader,d.push(c))}return p.set(this.tS+s,d),d.concat()}static _cleanupForEngine(e){i.iS.delete(e.objectUID),i.oS.delete(e.objectUID),i.sS.delete(e.objectUID)}};i.materialNodes=[],i.ib=G.zero(),i.nb=O.zero(),i.hS=0,i.iS=new Map,i.oS=new Map,i.sS=new Map;var j=i;export{j as AbstractMaterialContent};
1
+ import x from"../../../_deps/shaderity.js";import{RnObject as P}from"../../core/RnObject.js";import{CompositionType as I}from"../../definitions/CompositionType.js";import{ProcessApproach as v}from"../../definitions/ProcessApproach.js";import{ShaderType as f}from"../../definitions/ShaderType.js";import{MutableMatrix44 as _}from"../../math/MutableMatrix44.js";import{MutableVector2 as O}from"../../math/MutableVector2.js";import{MutableVector4 as G}from"../../math/MutableVector4.js";import{Vector3 as W}from"../../math/Vector3.js";import{Logger as V}from"../../misc/Logger.js";import{ShaderityUtilityWebGL as D}from"./ShaderityUtilityWebGL.js";import{ShaderityUtilityWebGPU as U}from"./ShaderityUtilityWebGPU.js";var l=typeof __RN_WEBGL__=="undefined"||__RN_WEBGL__?D:void 0,S=typeof __RN_WEBGPU__=="undefined"||__RN_WEBGPU__?U:void 0,y=x.default||x,i=class i extends P{constructor(e,{isMorphing:t=!1,isSkinning:a=!1,isLighting:n=!1}={},r,o,s){super();this.aS=[];this.r_="";this.shaderType=f.VertexAndPixelShader;this.pS="";this.nS="";this.tS=e,s&&(this._engine=s),this.kx=t,this.cS=a,this.ix=n,this.fS=i.hS++,this.setVertexShaderityObject(r,s),this.setPixelShaderityObject(o,s)}get isMultiDrawCompatible(){return!0}static mS(e){let t=i.iS.get(e);return t||(t=new Map,i.iS.set(e,t)),t}static dS(e){let t=i.oS.get(e);return t||(t=new Map,i.oS.set(e,t)),t}static lS(e){let t=i.sS.get(e);return t||(t=new Map,i.sS.set(e,t)),t}setVertexShaderityObject(e,t){if(e){let a=t!=null?t:this._engine;a&&i.mS(a.objectUID).set(this.tS,e)}}setPixelShaderityObject(e,t){if(e){let a=t!=null?t:this._engine;a&&i.dS(a.objectUID).set(this.tS,e)}}makeMaterialSemanticsVariantName(){let e="";for(let t of this.aS)e+=`${t.semantic}_`;this.nS=`semanticsVariation_${e}`,this.pS=`${this.tS}_${this.nS}`}getMaterialSemanticsVariantName(){return this.pS}getMaterialVariationIdentifier(){return this.nS}getBaseMaterialName(){return this.tS.replace(/__$/,"")}get vertexShaderityObject(){if(this._engine)return i.mS(this._engine.objectUID).get(this.tS)}get pixelShaderityObject(){if(this._engine)return i.dS(this._engine.objectUID).get(this.tS)}getDefinitions(){return this.r_}static getMaterialNode(e){return i.materialNodes[e]}get _semanticsInfoArray(){return this.aS}get isSkinning(){return this.cS}get isMorphing(){return this.kx}get isLighting(){return this.ix}setShaderSemanticsInfoArray(e){let t=new Map;for(let r of e)t.set(r.semantic,r);let a=[];for(let r of t.values())a.push(r);let n=new Set;n.add(0),a.forEach(r=>{if(I.isTexture(r.compositionType)){let o=r.initialValue[0];o>0&&n.add(o)}}),a.forEach(r=>{if(I.isTexture(r.compositionType)&&r.initialValue[0]<0){let s=-1;for(let p=1;p<32;p++)if(!n.has(p)){s=p;break}s===-1&&V.default.warn(`All texture slots (1-31) are occupied. Cannot assign a valid slot for semantic "${r.semantic}". This may cause rendering issues.`),r.initialValue[0]=s,n.add(s)}}),this.aS=a,this.makeMaterialSemanticsVariantName()}setupBasicInfo(e,t,a,n,r,o){let s=t.entity.tryToGetBlendShape();this.setMorphInfo(a,t.entity.getMesh(),t.primitive,s)}setWorldMatrix(e,t){e._gl.uniformMatrix4fv(e.worldMatrix,!1,t._v)}setNormalMatrix(e,t){e._gl.uniformMatrix3fv(e.normalMatrix,!1,t._v)}setIsBillboard(e,t){e._gl.uniform1i(e.isBillboard,t?1:0)}setIsVisible(e,t){e._gl.uniform1i(e.isVisible,t?1:0)}setViewInfo(e,t,a,n){let r,o;if(a){let s=t.entity.engine._webXRSystemIfEnabled;s!=null&&s.isWebXRMode&&(r=s._getViewMatrixAt(n),o=s._getCameraWorldPositionAt(n))}else t?(o=t.worldPosition,r=t.viewMatrix):(r=_.identity(),o=W.fromCopyArray([0,0,10]));e._gl.uniformMatrix4fv(e.viewMatrix,!1,r._v),e._gl.uniform3fv(e.viewPosition,o._v)}setProjection(e,t,a,n){let r;if(a){let o=t.entity.engine._webXRSystemIfEnabled;o!=null&&o.isWebXRMode&&(r=o._getProjectMatrixAt(n))}else t?r=t.projectionMatrix:r=_.identity();e._gl.uniformMatrix4fv(e.projectionMatrix,!1,r._v)}setMorphInfo(e,t,a,n){if(!this.kx||a.targets.length===0)return;let r=a.constructor.getPrimitiveIdxHasMorph(a.primitiveUid);e._gl.uniform1i(e.currentPrimitiveIdx,r)}_setInternalSettingParametersToGpuWebGLPerShaderProgram(e){}_setInternalSettingParametersToGpuWebGLPerMaterial(e){}_setInternalSettingParametersToGpuWebGLPerPrimitive(e){}_setInternalSettingParametersToGpuWebGpu(e){}getDefinition(){return""}doShaderReflection(e,t,a,n,r,o){this._engine=e;let s=o.join(""),p=i.lS(e.objectUID),M=p.get(this.tS+s);if(M!=null)return M.concat();let u,b;if(e.processApproach===v.WebGPU){let c=y.processPragma(n,!1,o),m=y.processPragma(r,!1,o);u=S.getShaderDataReflection(e,c),b=S.getShaderDataReflection(e,m);let h=S.getShaderDataReflection(e,n),g=S.getShaderDataReflection(e,r);this.setVertexShaderityObject(h.shaderityObject,e),this.setPixelShaderityObject(g.shaderityObject,e)}else{let c=y.processPragma(t,!0,o),m=y.processPragma(a,!0,o);u=l.getShaderDataReflection(e,c),b=l.getShaderDataReflection(e,m);let h=l.getShaderDataReflection(e,t),g=l.getShaderDataReflection(e,a);this.setVertexShaderityObject(h.shaderityObject,e),this.setPixelShaderityObject(g.shaderityObject,e)}let d=[];for(let c of u.shaderSemanticsInfoArray)c.stage=f.VertexShader,d.push(c);for(let c of b.shaderSemanticsInfoArray){let m=d.find(h=>h.semantic===c.semantic);m?m.stage=f.VertexAndPixelShader:(c.stage=f.PixelShader,d.push(c))}return p.set(this.tS+s,d),d.concat()}static _cleanupForEngine(e){i.iS.delete(e.objectUID),i.oS.delete(e.objectUID),i.sS.delete(e.objectUID)}};i.materialNodes=[],i.nb=G.zero(),i.sb=O.zero(),i.hS=0,i.iS=new Map,i.oS=new Map,i.sS=new Map;var j=i;export{j as AbstractMaterialContent};
@@ -218,13 +218,18 @@ export declare class Material extends RnObject {
218
218
  getShaderProgramUid(primitive: Primitive): CGAPIResourceHandle;
219
219
  /**
220
220
  * Adds a primitive to the list of primitives that belong to this material.
221
+ *
222
+ * The primitive is held weakly: a material that stays reachable (for example a shared material) must not
223
+ * keep the primitives assigned to it, and with them their CPU vertex data, alive after they are destroyed.
221
224
  * @internal Called from Primitive class only
222
225
  * @param primitive - The primitive to add
223
226
  */
224
227
  _addBelongPrimitive(primitive: Primitive): void;
225
228
  /**
226
- * Gets all primitives that belong to this material.
227
- * @returns A Map of primitive UIDs to Primitive objects
229
+ * Gets all primitives that belong to this material and are still alive.
230
+ *
231
+ * Entries whose primitive has been collected are pruned while resolving the map.
232
+ * @returns A Map of primitive UIDs to the live Primitive objects
228
233
  */
229
234
  getBelongPrimitives(): Map<number, Primitive>;
230
235
  /**
@@ -1 +1 @@
1
- import{Component as p}from"../../core/Component.js";import{RnObject as b}from"../../core/RnObject.js";import{TextureParameter as d}from"../../definitions/index.js";import{AlphaMode as m}from"../../definitions/AlphaMode.js";import{Blend as o}from"../../definitions/Blend.js";import{CompositionType as c}from"../../definitions/CompositionType.js";import{ShaderType as g}from"../../definitions/ShaderType.js";import{AnimatedQuaternion as P}from"../../math/AnimatedQuaternion.js";import{AnimatedScalar as S}from"../../math/AnimatedScalar.js";import{AnimatedVector2 as _}from"../../math/AnimatedVector2.js";import{AnimatedVector3 as y}from"../../math/AnimatedVector3.js";import{AnimatedVector4 as F}from"../../math/AnimatedVector4.js";import{AnimatedVectorN as M}from"../../math/AnimatedVectorN.js";import{MathClassUtil as v}from"../../math/MathClassUtil.js";import{Is as V}from"../../misc/Is.js";import{Logger as R}from"../../misc/Logger.js";import{Sampler as T}from"../../textures/Sampler.js";import{_createProgramAsSingleOperationByUpdatedSources as I,_createProgramAsSingleOperationWebGL as A,_createProgramAsSingleOperationWebGpu as C}from"./ShaderHandler.js";var f=class extends b{constructor(e,t,r,i,a,s){super();this._allFieldVariables=new Map;this._autoFieldVariablesOnly=new Map;this._autoTextureFieldVariablesOnly=new Map;this._autoUniformFieldVariablesOnly=new Map;this._allFieldsInfo=new Map;this._g=new Map;this._shaderProgramUidMap=new Map;this._shaderProgramComponentStateVersionMap=new Map;this.yg=-1;this.Mg=-1;this.vg=m.Opaque;this.zWriteWhenBlend=!1;this.colorWriteMask=[!0,!0,!0,!0];this.isTranslucent=!1;this.cullFace=!0;this.cullFrontFaceCCW=!0;this.cullFaceBack=!0;this.Vg=!1;this.hg=o.EquationFuncAdd;this.mg=o.EquationFuncAdd;this.ug=o.One;this.pg=o.OneMinusSrcAlpha;this.dg=o.One;this.gg=o.OneMinusSrcAlpha;this.yf=0;this.Rg=0;this.cg=0;this.Nn="";this.lg=new Set;this.Ag="";this.Cg=-1;this.Pg="";this.Ug=-1;this.i=e,this._materialContent=s,this.Fg=t,this.yg=r,this.Mg=i,this.og=a}addShaderDefine(e){this.lg.add(e),this.makeShadersInvalidate()}removeShaderDefine(e){this.lg.delete(e),this.makeShadersInvalidate()}getShaderDefines(){return this.lg}isShaderDefine(e){return this.lg.has(e)}calcFingerPrint(){let e="";e+=this.alphaMode.index,e+=this.blendFuncSrcFactor.webgpu,e+=this.blendFuncDstFactor.webgpu,e+=this.blendFuncAlphaSrcFactor.webgpu,e+=this.blendFuncAlphaDstFactor.webgpu,e+=this.blendEquationMode.webgpu,e+=this.blendEquationModeAlpha.webgpu,e+=this.cullFace?"1":"0",e+=this.cullFrontFaceCCW?"1":"0",e+=this.cullFaceBack?"1":"0",e!==this.Nn&&(this.Nn=e,this.bg())}bg(){this.Rg++,this.i.materialRepository._incrementBindingStateVersion()}_getFingerPrint(){return this.Nn}_getTextureBindingSignature(){var t,r,i,a,s;if(this.Cg===this.yf)return this.Ag;let e="";for(let[n,l]of this._autoTextureFieldVariablesOnly){let h=l.value;e+=`${n}:${h[0]}:${(r=(t=h[1])==null?void 0:t._textureResourceUid)!=null?r:-1}:${(a=(i=h[2])==null?void 0:i._samplerResourceUid)!=null?a:-1};`}for(let[n,l]of this._autoUniformFieldVariablesOnly){let h=l.value,u=(s=h==null?void 0:h._v)!=null?s:h;e+=`${n}:${Array.isArray(u)||ArrayBuffer.isView(u)?Array.from(u).join(","):String(u)};`}return this.Ag=e,this.Cg=this.yf,e}_getMultiDrawStateKey(){return this.Ug===this.yf?this.Pg:(this.Pg=`${this.og}|${this._materialContent.getMaterialSemanticsVariantName()}|${[...this.lg].sort().join(",")}|${this.Nn}|${this._getTextureBindingSignature()}`,this.Ug=this.yf,this.Pg)}_isAnimatedValue(e){return e instanceof S||e instanceof _||e instanceof y||e instanceof F||e instanceof P||e instanceof M}setParameter(e,t){let r=this._allFieldsInfo.get(e);if(r!=null){let i;r.soloDatum?i=this.i.materialRepository._soloDatumFields.get(this.og).get(e):i=this._allFieldVariables.get(e),this._isAnimatedValue(t)?(t.setFloat32Array(i.value._v),i.value=t,this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()):v._setForce(i.value,t)&&(this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint())}}setTextureParameter(e,t,r){if(V.not.exist(r)&&(r=new T(this.i,{magFilter:d.Linear,minFilter:d.Linear,wrapS:d.Repeat,wrapT:d.Repeat})),r.created||r.create(),this._allFieldsInfo.has(e)){let i=this._allFieldVariables.get(e);if(i.value[1]===t&&i.value[2]===r)return;let a={value:[i.value[0],t,r],info:i.info};this._allFieldVariables.set(e,a),i.info.isInternalSetting||(this._autoFieldVariablesOnly.set(e,a),c.isTexture(i.info.compositionType)&&this._autoTextureFieldVariablesOnly.set(e,a)),(e==="diffuseColorTexture"||e==="baseColorTexture")&&t.isTransparent&&(this.alphaMode=m.Blend),this.yf++,this.cg++,this.i.materialRepository._incrementStateVersion(),this.i.materialRepository._incrementBindingStateVersion(),this.calcFingerPrint()}}getTextureParameter(e){if(this._allFieldsInfo.has(e))return this._allFieldVariables.get(e).value}setTextureParameterAsPromise(e,t){t.then(r=>{if(this._allFieldsInfo.has(e)){let i=this._allFieldVariables.get(e);if(i.value[1]===r)return;let a={value:[i.value[0],r],info:i.info};this._allFieldVariables.set(e,a),i.info.isInternalSetting||(this._autoFieldVariablesOnly.set(e,a),c.isTexture(i.info.compositionType)&&this._autoTextureFieldVariablesOnly.set(e,a)),(e==="diffuseColorTexture"||e==="baseColorTexture")&&r.isTransparent&&(this.alphaMode=m.Blend)}this.yf++,this.cg++,this.i.materialRepository._incrementStateVersion(),this.i.materialRepository._incrementBindingStateVersion(),this.calcFingerPrint()})}getParameter(e){var r,i;let t=this._allFieldsInfo.get(e);if(t!=null)return t.soloDatum?(r=this.i.materialRepository._soloDatumFields.get(this.og).get(e))==null?void 0:r.value:(i=this._allFieldVariables.get(e))==null?void 0:i.value}isShaderProgramReady(e){let t=e._getFingerPrint();return this._shaderProgramComponentStateVersionMap.get(t)!==p.getStateVersion(this.i)?(this._shaderProgramUidMap.delete(t),this._shaderProgramComponentStateVersionMap.delete(t),!1):this._shaderProgramUidMap.has(t)}_setUniformLocationsOfMaterialNodes(e){let t=this.i.webglResourceRepository,r=[];if(this._materialContent!=null){let a=this._materialContent._semanticsInfoArray;r=r.concat(a)}let i=this._shaderProgramUidMap.get(e._getFingerPrint());t.setupUniformLocations(this.i.config,i,r)}getShaderProgramUid(e){var r;let t=e._getFingerPrint();return(r=this._shaderProgramUidMap.get(t))!=null?r:-1}_addBelongPrimitive(e){this._g.set(e.primitiveUid,e)}getBelongPrimitives(){return this._g}_createProgramWebGL(e,t,r,i,a,s,n){let[l,h]=A(e,this,t,r,i,a,s,n),u=n._getFingerPrint();return this._shaderProgramUidMap.set(u,l),this._shaderProgramComponentStateVersionMap.set(u,p.getStateVersion(e)),this.i.materialRepository._incrementStateVersion(),[l,h]}_createProgramWebGpu(e,t,r,i,a,s,n){let l=C(e,this,t,r,i,a,s,n),h=t._getFingerPrint();this._shaderProgramUidMap.set(h,l),this._shaderProgramComponentStateVersionMap.set(h,p.getStateVersion(e)),this.i.materialRepository._incrementStateVersion()}_createProgramByUpdatedSources(e,t,r){let[i,a]=I(this.i,this,t,this._materialContent,e,r),s=t._getFingerPrint();return this._shaderProgramUidMap.set(s,i),this._shaderProgramComponentStateVersionMap.set(s,p.getStateVersion(this.i)),i>0,this.i.materialRepository._incrementStateVersion(),[i,a]}_setupBasicUniformsLocations(e){let t=this.i.webglResourceRepository,r=e._getFingerPrint(),i=this._shaderProgramUidMap.get(r);t.setupBasicUniformLocations(i)}_setupAdditionalUniformLocations(e,t){let r=this.i.webglResourceRepository,i=t._getFingerPrint(),a=this._shaderProgramUidMap.get(i);r.setupUniformLocations(this.i.config,a,e)}_setInternalSettingParametersToGpuWebGpu({engine:e,material:t,args:r}){this._materialContent._setInternalSettingParametersToGpuWebGpu({engine:e,material:t,args:r})}_setParametersToGpuWebGL({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}){this.Gg(i,r),this._materialContent._setInternalSettingParametersToGpuWebGLPerMaterial({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}),this.wg({shaderProgram:r,firstTime:i})}_setParametersToGpuWebGLPerShaderProgram({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}){this._materialContent._setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:e,material:t,shaderProgram:r,firstTime:i,args:a})}_setParametersToGpuWebGLPerPrimitive({material:e,shaderProgram:t,firstTime:r,args:i}){this._materialContent._setInternalSettingParametersToGpuWebGLPerPrimitive({material:e,shaderProgram:t,firstTime:r,args:i})}_setParametersToGpuWebGLWithOutInternalSetting({shaderProgram:e,firstTime:t}){this.Gg(t,e),this.wg({shaderProgram:e,firstTime:t})}_getProperties(e,t,r){let i="",a="";return this._allFieldsInfo.forEach(n=>{(n.stage===g.VertexShader||n.stage===g.VertexAndPixelShader)&&(i+=r(e,this.og,n)),(n.stage===g.PixelShader||n.stage===g.VertexAndPixelShader)&&(a+=r(e,this.og,n))}),[i,a]=e.globalDataRepository._addPropertiesStr(i,a,t),{vertexPropertiesStr:i,pixelPropertiesStr:a}}Gg(e,t){let r=this.i.webglResourceRepository;for(let[,i]of this._autoTextureFieldVariablesOnly){let a=i.info;e?r.setUniform1iForTexture(t,a.semantic,i.value):r.bindTexture(a,i.value)}for(let[,i]of this._autoUniformFieldVariablesOnly){let a=i.info;a.needUniformInDataTextureMode&&r.setUniformValue(t,a.semantic,e,i.value)}}wg({shaderProgram:e,firstTime:t}){let r=this.i.webglResourceRepository,i=this.og,a=this.i.materialRepository._soloDatumFields.get(i);if(a==null)return;let s=a.values();for(let n of s){let l=n.info;c.isTexture(l.compositionType)&&(l.isInternalSetting||(t?r.setUniformValue(e,l.semantic,t,n.value):r.bindTexture(l,n.value)))}}setBlendEquationMode(e,t){this.hg=e,this.mg=t!=null?t:e,this.Sg(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}Sg(){(this.hg===o.Min||this.hg===o.Max)&&(this.pg=o.One,this.ug=o.One),(this.mg===o.Min||this.mg===o.Max)&&(this.gg=o.One,this.dg=o.One)}setBlendFuncSeparateFactor(e,t,r,i){this.ug=e,this.pg=t,this.dg=r,this.gg=i,this.Sg(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}setBlendFuncFactor(e,t){this.ug=e,this.pg=t,this.dg=e,this.gg=t,this.Sg(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}isBlend(){return this.alphaMode===m.Blend}isTranslucentOpaque(){return!!(this.alphaMode!==m.Blend&&this.isTranslucent)}isBlendOrTranslucent(){return!!(this.alphaMode===m.Blend||this.isTranslucent)}isOpaque(){return this.alphaMode===m.Opaque}isMask(){return this.alphaMode===m.Mask}set alphaToCoverage(e){e&&this.alphaMode===m.Blend&&R.default.warn("If you set alphaToCoverage = true on a material whose AlphaMode is Translucent, you may get drawing problems."),this.Vg=e,this.makeShadersInvalidate(),this.calcFingerPrint()}get alphaToCoverage(){return this.Vg}get materialTID(){return this.Fg}get fieldsInfoArray(){return Array.from(this._allFieldsInfo.values())}get blendEquationMode(){return this.hg}get blendEquationModeAlpha(){return this.mg}get blendFuncSrcFactor(){return this.ug}get blendFuncDstFactor(){return this.pg}get blendFuncAlphaSrcFactor(){return this.dg}get blendFuncAlphaDstFactor(){return this.gg}get alphaMode(){return this.vg}set alphaMode(e){this.vg=e,this.calcFingerPrint(),this.makeShadersInvalidate()}get materialUID(){return this.yg}get materialSID(){return this.Mg}get isSkinning(){return this._materialContent.isSkinning}get isMorphing(){return this._materialContent.isMorphing}get isLighting(){return this._materialContent.isLighting}get materialTypeName(){return this.og}get baseMaterialName(){return this._materialContent.getBaseMaterialName()}get materialVariationIdentifier(){return this._materialContent.getMaterialVariationIdentifier()}get stateVersion(){return this.yf}makeShadersInvalidate(){this._shaderProgramUidMap.clear(),this._shaderProgramComponentStateVersionMap.clear(),this.yf++,this.bg(),this.i.materialRepository._incrementStateVersion()}updateStateVersion(){this.yf++,this.bg(),this.i.materialRepository._incrementStateVersion()}get pipelineStateVersion(){return this.Rg}get textureStateVersion(){return this.cg}get shaderNodeJson(){return this.fg}set shaderNodeJson(e){this.fg=e}get shaderNodeUniforms(){return this.Tg}set shaderNodeUniforms(e){this.Tg=e}get isNodeBasedMaterial(){return this.fg!=null}get shaderNodeFileName(){return this.Ig}set shaderNodeFileName(e){this.Ig=e}};export{f as Material};
1
+ import{Component as p}from"../../core/Component.js";import{RnObject as b}from"../../core/RnObject.js";import{TextureParameter as d}from"../../definitions/index.js";import{AlphaMode as m}from"../../definitions/AlphaMode.js";import{Blend as o}from"../../definitions/Blend.js";import{CompositionType as c}from"../../definitions/CompositionType.js";import{ShaderType as g}from"../../definitions/ShaderType.js";import{AnimatedQuaternion as P}from"../../math/AnimatedQuaternion.js";import{AnimatedScalar as S}from"../../math/AnimatedScalar.js";import{AnimatedVector2 as _}from"../../math/AnimatedVector2.js";import{AnimatedVector3 as y}from"../../math/AnimatedVector3.js";import{AnimatedVector4 as F}from"../../math/AnimatedVector4.js";import{AnimatedVectorN as M}from"../../math/AnimatedVectorN.js";import{MathClassUtil as v}from"../../math/MathClassUtil.js";import{Is as V}from"../../misc/Is.js";import{Logger as R}from"../../misc/Logger.js";import{Sampler as T}from"../../textures/Sampler.js";import{_createProgramAsSingleOperationByUpdatedSources as I,_createProgramAsSingleOperationWebGL as A,_createProgramAsSingleOperationWebGpu as U}from"./ShaderHandler.js";var f=class extends b{constructor(e,t,r,i,a,s){super();this._allFieldVariables=new Map;this._autoFieldVariablesOnly=new Map;this._autoTextureFieldVariablesOnly=new Map;this._autoUniformFieldVariablesOnly=new Map;this._allFieldsInfo=new Map;this.cg=new Map;this._shaderProgramUidMap=new Map;this._shaderProgramComponentStateVersionMap=new Map;this.yg=-1;this.Mg=-1;this.vg=m.Opaque;this.zWriteWhenBlend=!1;this.colorWriteMask=[!0,!0,!0,!0];this.isTranslucent=!1;this.cullFace=!0;this.cullFrontFaceCCW=!0;this.cullFaceBack=!0;this.Vg=!1;this.hg=o.EquationFuncAdd;this.mg=o.EquationFuncAdd;this.ug=o.One;this.pg=o.OneMinusSrcAlpha;this.dg=o.One;this.gg=o.OneMinusSrcAlpha;this.yf=0;this.Rg=0;this.fg=0;this.Nn="";this.lg=new Set;this.Ag="";this.Ug=-1;this.Sg="";this.Cg=-1;this.i=e,this._materialContent=s,this.Fg=t,this.yg=r,this.Mg=i,this.og=a}addShaderDefine(e){this.lg.add(e),this.makeShadersInvalidate()}removeShaderDefine(e){this.lg.delete(e),this.makeShadersInvalidate()}getShaderDefines(){return this.lg}isShaderDefine(e){return this.lg.has(e)}calcFingerPrint(){let e="";e+=this.alphaMode.index,e+=this.blendFuncSrcFactor.webgpu,e+=this.blendFuncDstFactor.webgpu,e+=this.blendFuncAlphaSrcFactor.webgpu,e+=this.blendFuncAlphaDstFactor.webgpu,e+=this.blendEquationMode.webgpu,e+=this.blendEquationModeAlpha.webgpu,e+=this.cullFace?"1":"0",e+=this.cullFrontFaceCCW?"1":"0",e+=this.cullFaceBack?"1":"0",e!==this.Nn&&(this.Nn=e,this.Pg())}Pg(){this.Rg++,this.i.materialRepository._incrementBindingStateVersion()}_getFingerPrint(){return this.Nn}_getTextureBindingSignature(){var t,r,i,a,s;if(this.Ug===this.yf)return this.Ag;let e="";for(let[n,l]of this._autoTextureFieldVariablesOnly){let h=l.value;e+=`${n}:${h[0]}:${(r=(t=h[1])==null?void 0:t._textureResourceUid)!=null?r:-1}:${(a=(i=h[2])==null?void 0:i._samplerResourceUid)!=null?a:-1};`}for(let[n,l]of this._autoUniformFieldVariablesOnly){let h=l.value,u=(s=h==null?void 0:h._v)!=null?s:h;e+=`${n}:${Array.isArray(u)||ArrayBuffer.isView(u)?Array.from(u).join(","):String(u)};`}return this.Ag=e,this.Ug=this.yf,e}_getMultiDrawStateKey(){return this.Cg===this.yf?this.Sg:(this.Sg=`${this.og}|${this._materialContent.getMaterialSemanticsVariantName()}|${[...this.lg].sort().join(",")}|${this.Nn}|${this._getTextureBindingSignature()}`,this.Cg=this.yf,this.Sg)}_isAnimatedValue(e){return e instanceof S||e instanceof _||e instanceof y||e instanceof F||e instanceof P||e instanceof M}setParameter(e,t){let r=this._allFieldsInfo.get(e);if(r!=null){let i;r.soloDatum?i=this.i.materialRepository._soloDatumFields.get(this.og).get(e):i=this._allFieldVariables.get(e),this._isAnimatedValue(t)?(t.setFloat32Array(i.value._v),i.value=t,this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()):v._setForce(i.value,t)&&(this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint())}}setTextureParameter(e,t,r){if(V.not.exist(r)&&(r=new T(this.i,{magFilter:d.Linear,minFilter:d.Linear,wrapS:d.Repeat,wrapT:d.Repeat})),r.created||r.create(),this._allFieldsInfo.has(e)){let i=this._allFieldVariables.get(e);if(i.value[1]===t&&i.value[2]===r)return;let a={value:[i.value[0],t,r],info:i.info};this._allFieldVariables.set(e,a),i.info.isInternalSetting||(this._autoFieldVariablesOnly.set(e,a),c.isTexture(i.info.compositionType)&&this._autoTextureFieldVariablesOnly.set(e,a)),(e==="diffuseColorTexture"||e==="baseColorTexture")&&t.isTransparent&&(this.alphaMode=m.Blend),this.yf++,this.fg++,this.i.materialRepository._incrementStateVersion(),this.i.materialRepository._incrementBindingStateVersion(),this.calcFingerPrint()}}getTextureParameter(e){if(this._allFieldsInfo.has(e))return this._allFieldVariables.get(e).value}setTextureParameterAsPromise(e,t){t.then(r=>{if(this._allFieldsInfo.has(e)){let i=this._allFieldVariables.get(e);if(i.value[1]===r)return;let a={value:[i.value[0],r],info:i.info};this._allFieldVariables.set(e,a),i.info.isInternalSetting||(this._autoFieldVariablesOnly.set(e,a),c.isTexture(i.info.compositionType)&&this._autoTextureFieldVariablesOnly.set(e,a)),(e==="diffuseColorTexture"||e==="baseColorTexture")&&r.isTransparent&&(this.alphaMode=m.Blend)}this.yf++,this.fg++,this.i.materialRepository._incrementStateVersion(),this.i.materialRepository._incrementBindingStateVersion(),this.calcFingerPrint()})}getParameter(e){var r,i;let t=this._allFieldsInfo.get(e);if(t!=null)return t.soloDatum?(r=this.i.materialRepository._soloDatumFields.get(this.og).get(e))==null?void 0:r.value:(i=this._allFieldVariables.get(e))==null?void 0:i.value}isShaderProgramReady(e){let t=e._getFingerPrint();return this._shaderProgramComponentStateVersionMap.get(t)!==p.getStateVersion(this.i)?(this._shaderProgramUidMap.delete(t),this._shaderProgramComponentStateVersionMap.delete(t),!1):this._shaderProgramUidMap.has(t)}_setUniformLocationsOfMaterialNodes(e){let t=this.i.webglResourceRepository,r=[];if(this._materialContent!=null){let a=this._materialContent._semanticsInfoArray;r=r.concat(a)}let i=this._shaderProgramUidMap.get(e._getFingerPrint());t.setupUniformLocations(this.i.config,i,r)}getShaderProgramUid(e){var r;let t=e._getFingerPrint();return(r=this._shaderProgramUidMap.get(t))!=null?r:-1}_addBelongPrimitive(e){this.cg.set(e.primitiveUid,new WeakRef(e))}getBelongPrimitives(){let e=new Map;for(let[t,r]of this.cg){let i=r.deref();i!=null?e.set(t,i):this.cg.delete(t)}return e}_createProgramWebGL(e,t,r,i,a,s,n){let[l,h]=A(e,this,t,r,i,a,s,n),u=n._getFingerPrint();return this._shaderProgramUidMap.set(u,l),this._shaderProgramComponentStateVersionMap.set(u,p.getStateVersion(e)),this.i.materialRepository._incrementStateVersion(),[l,h]}_createProgramWebGpu(e,t,r,i,a,s,n){let l=U(e,this,t,r,i,a,s,n),h=t._getFingerPrint();this._shaderProgramUidMap.set(h,l),this._shaderProgramComponentStateVersionMap.set(h,p.getStateVersion(e)),this.i.materialRepository._incrementStateVersion()}_createProgramByUpdatedSources(e,t,r){let[i,a]=I(this.i,this,t,this._materialContent,e,r),s=t._getFingerPrint();return this._shaderProgramUidMap.set(s,i),this._shaderProgramComponentStateVersionMap.set(s,p.getStateVersion(this.i)),i>0,this.i.materialRepository._incrementStateVersion(),[i,a]}_setupBasicUniformsLocations(e){let t=this.i.webglResourceRepository,r=e._getFingerPrint(),i=this._shaderProgramUidMap.get(r);t.setupBasicUniformLocations(i)}_setupAdditionalUniformLocations(e,t){let r=this.i.webglResourceRepository,i=t._getFingerPrint(),a=this._shaderProgramUidMap.get(i);r.setupUniformLocations(this.i.config,a,e)}_setInternalSettingParametersToGpuWebGpu({engine:e,material:t,args:r}){this._materialContent._setInternalSettingParametersToGpuWebGpu({engine:e,material:t,args:r})}_setParametersToGpuWebGL({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}){this.Gg(i,r),this._materialContent._setInternalSettingParametersToGpuWebGLPerMaterial({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}),this.wg({shaderProgram:r,firstTime:i})}_setParametersToGpuWebGLPerShaderProgram({engine:e,material:t,shaderProgram:r,firstTime:i,args:a}){this._materialContent._setInternalSettingParametersToGpuWebGLPerShaderProgram({engine:e,material:t,shaderProgram:r,firstTime:i,args:a})}_setParametersToGpuWebGLPerPrimitive({material:e,shaderProgram:t,firstTime:r,args:i}){this._materialContent._setInternalSettingParametersToGpuWebGLPerPrimitive({material:e,shaderProgram:t,firstTime:r,args:i})}_setParametersToGpuWebGLWithOutInternalSetting({shaderProgram:e,firstTime:t}){this.Gg(t,e),this.wg({shaderProgram:e,firstTime:t})}_getProperties(e,t,r){let i="",a="";return this._allFieldsInfo.forEach(n=>{(n.stage===g.VertexShader||n.stage===g.VertexAndPixelShader)&&(i+=r(e,this.og,n)),(n.stage===g.PixelShader||n.stage===g.VertexAndPixelShader)&&(a+=r(e,this.og,n))}),[i,a]=e.globalDataRepository._addPropertiesStr(i,a,t),{vertexPropertiesStr:i,pixelPropertiesStr:a}}Gg(e,t){let r=this.i.webglResourceRepository;for(let[,i]of this._autoTextureFieldVariablesOnly){let a=i.info;e?r.setUniform1iForTexture(t,a.semantic,i.value):r.bindTexture(a,i.value)}for(let[,i]of this._autoUniformFieldVariablesOnly){let a=i.info;a.needUniformInDataTextureMode&&r.setUniformValue(t,a.semantic,e,i.value)}}wg({shaderProgram:e,firstTime:t}){let r=this.i.webglResourceRepository,i=this.og,a=this.i.materialRepository._soloDatumFields.get(i);if(a==null)return;let s=a.values();for(let n of s){let l=n.info;c.isTexture(l.compositionType)&&(l.isInternalSetting||(t?r.setUniformValue(e,l.semantic,t,n.value):r.bindTexture(l,n.value)))}}setBlendEquationMode(e,t){this.hg=e,this.mg=t!=null?t:e,this._g(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}_g(){(this.hg===o.Min||this.hg===o.Max)&&(this.pg=o.One,this.ug=o.One),(this.mg===o.Min||this.mg===o.Max)&&(this.gg=o.One,this.dg=o.One)}setBlendFuncSeparateFactor(e,t,r,i){this.ug=e,this.pg=t,this.dg=r,this.gg=i,this._g(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}setBlendFuncFactor(e,t){this.ug=e,this.pg=t,this.dg=e,this.gg=t,this._g(),this.yf++,this.i.materialRepository._incrementStateVersion(),this.calcFingerPrint()}isBlend(){return this.alphaMode===m.Blend}isTranslucentOpaque(){return!!(this.alphaMode!==m.Blend&&this.isTranslucent)}isBlendOrTranslucent(){return!!(this.alphaMode===m.Blend||this.isTranslucent)}isOpaque(){return this.alphaMode===m.Opaque}isMask(){return this.alphaMode===m.Mask}set alphaToCoverage(e){e&&this.alphaMode===m.Blend&&R.default.warn("If you set alphaToCoverage = true on a material whose AlphaMode is Translucent, you may get drawing problems."),this.Vg=e,this.makeShadersInvalidate(),this.calcFingerPrint()}get alphaToCoverage(){return this.Vg}get materialTID(){return this.Fg}get fieldsInfoArray(){return Array.from(this._allFieldsInfo.values())}get blendEquationMode(){return this.hg}get blendEquationModeAlpha(){return this.mg}get blendFuncSrcFactor(){return this.ug}get blendFuncDstFactor(){return this.pg}get blendFuncAlphaSrcFactor(){return this.dg}get blendFuncAlphaDstFactor(){return this.gg}get alphaMode(){return this.vg}set alphaMode(e){this.vg=e,this.calcFingerPrint(),this.makeShadersInvalidate()}get materialUID(){return this.yg}get materialSID(){return this.Mg}get isSkinning(){return this._materialContent.isSkinning}get isMorphing(){return this._materialContent.isMorphing}get isLighting(){return this._materialContent.isLighting}get materialTypeName(){return this.og}get baseMaterialName(){return this._materialContent.getBaseMaterialName()}get materialVariationIdentifier(){return this._materialContent.getMaterialVariationIdentifier()}get stateVersion(){return this.yf}makeShadersInvalidate(){this._shaderProgramUidMap.clear(),this._shaderProgramComponentStateVersionMap.clear(),this.yf++,this.Pg(),this.i.materialRepository._incrementStateVersion()}updateStateVersion(){this.yf++,this.Pg(),this.i.materialRepository._incrementStateVersion()}get pipelineStateVersion(){return this.Rg}get textureStateVersion(){return this.fg}get shaderNodeJson(){return this.bg}set shaderNodeJson(e){this.bg=e}get shaderNodeUniforms(){return this.Tg}set shaderNodeUniforms(e){this.Tg=e}get isNodeBasedMaterial(){return this.bg!=null}get shaderNodeFileName(){return this.Ig}set shaderNodeFileName(e){this.Ig=e}};export{f as Material};
@@ -1,2 +1,2 @@
1
- import d from"../../../_deps/shaderity.js";import{BlendShapeComponent as A}from"../../components/BlendShape/BlendShapeComponent.js";import{WellKnownComponentTIDs as O}from"../../components/WellKnownComponentTIDs.js";import{ComponentType as h}from"../../definitions/ComponentType.js";import{CompositionType as i}from"../../definitions/CompositionType.js";import{ShaderType as T}from"../../definitions/ShaderType.js";import{VertexAttribute as V}from"../../definitions/VertexAttribute.js";import{MutableMatrix22 as C}from"../../math/MutableMatrix22.js";import{MutableMatrix33 as g}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as F}from"../../math/MutableMatrix44.js";import{MutableScalar as l}from"../../math/MutableScalar.js";import{MutableVector2 as S}from"../../math/MutableVector2.js";import{MutableVector3 as N}from"../../math/MutableVector3.js";import{MutableVector4 as x}from"../../math/MutableVector4.js";import{Logger as y}from"../../misc/Logger.js";var b=d.default||d,M=class{static fillTemplate(r,e,o,u){let n=b.fillTemplate(e,u),a=r.webglResourceRepository,s=a.currentWebGLContextWrapper;if(s==null)return n;let t=s.getMaxTextureSize(),m=o.constructor.getMorphUniformDataOffsets(),p={WellKnownComponentTIDs:O,widthOfDataTexture:`const int widthOfDataTexture = ${t};`,dataUBODefinition:a.getGlslDataUBODefinitionString(),dataUBOVec4Size:a.getGlslDataUBOVec4SizeString(),maxMorphOffsetsDataNumber:`${Math.max(Math.ceil(m[m.length-1]/4),1)}`,maxMorphWeightsDataNumber:`${A._getMorphWeightsVec4Count(r)}`};return b.fillTemplate(n,p)}static transformWebGLVersion(r,e){return e?b.transformToGLSLES3(r):b.transformToGLSLES1(r,!0)}static getAttributeReflection(r){let e=b.createReflectionObject(r);this.ab(e),e.reflect();let o=e.attributesNames,u=e.attributesSemantics.map((s,t)=>{let m=V.fromString(s);return m===void 0&&y.default.error(`Unknown vertex attribute semantic: name=${o[t]}, semantic=${s}`),m}),n=e.attributesTypes.map(s=>i.fromGlslString(s)),a=e.attributesTypes.map(s=>h.fromGlslString(s));return{names:o,semantics:u,compositions:n,components:a}}static ab(r){let e=new Map;e.set("instanceids","INSTANCE"),e.set("barycentriccoord","BARY_CENTRIC_COORD"),r.addAttributeSemanticsMap(e)}static getShaderDataReflection(r,e){let o=this.ob(e),u=e.code.split(/\r\n|\n/),n=[],a=[];for(let s of u){let t=/^(?![/])[\t ]*uniform[\t ]+(\w+)[\t ]+(\w+);[\t ]*(\/\/)*[\t ]*(.*)/,m=s.match(t);if(m){let p=m[1],f=m[2],c=m[4];if(this.sb(c)){n.push(s);continue}let w=this.mb(r,p,f,c,e.isFragmentShader);a.push(w)}else n.push(s)}return o.code=n.join(`
2
- `),{shaderSemanticsInfoArray:a,shaderityObject:o}}static ob(r){return{code:r.code,shaderStage:r.shaderStage,isFragmentShader:r.shaderStage==="fragment"}}static sb(r){let e=r.match(/skipProcess[\t ]*=[\t ]*(\w+)[,\t ]*/);return(e==null?void 0:e[1])==="true"}static mb(r,e,o,u,n){let a=h.fromGlslString(e),s=i.fromGlslString(e),t=n?T.PixelShader:T.VertexShader;o=o.match(/u_(\w+)/)[1];let p={semantic:o,compositionType:s,componentType:a,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:t};return this.ub(r,p,u),p}static ub(r,e,o){let u=o.match(/soloDatum[\t ]*=[\t ]*(\w+)[,\t ]*/),n=!1;(u==null?void 0:u[1])==="true"&&(n=!0),e.soloDatum=n;let a=o.match(/isInternalSetting[\t ]*=[\t ]*(\w+)[,\t ]*/),s=!1;(a==null?void 0:a[1])==="true"&&(s=!0),e.isInternalSetting=s;let t=o.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(t){let c=t[1];e.initialValue=this.pb(r,e,c)}else e.initialValue=this.cb(r,e);let m=o.match(/needUniformInDataTextureMode[\t ]*=[\t ]*(.+)[,\t ]*/);if(m){let c=!1;(m==null?void 0:m[1])==="true"&&(c=!0),e.needUniformInDataTextureMode=c}let p=o.match(/max[\t ]*=[\t ]*(.+)[,\t ]*/);p&&(e.max=Number.parseFloat(p[1]));let f=o.match(/min[\t ]*=[\t ]*(.+)[,\t ]*/);f&&(e.min=Number.parseFloat(f[1]))}static pb(r,e,o){let u=o.match(/\(([\d\w., ]+)\)/),n=s=>{e.compositionType!==s&&y.default.error(`component number of initialValue is invalid:${e.semantic}`)},a;if(u){let t=u[1].split(",");switch(t.length){case 1:n(i.Scalar),t[0]==="true"?a=new l(new Float32Array([1])):t[0]==="false"?a=new l(new Float32Array([0])):a=new l(new Float32Array([Number.parseFloat(t[0])]));break;case 2:if(e.compositionType===i.Texture2D||e.compositionType===i.Texture2DShadow){let m=t[1].charAt(0).toUpperCase()+t[1].slice(1);a=[Number.parseInt(t[0],10),r.dummyTextures[`dummy${m}Texture`]]}else if(e.compositionType===i.TextureCube){let m=t[1].charAt(0).toUpperCase()+t[1].slice(1);a=[Number.parseInt(t[0],10),r.dummyTextures[`dummy${m}CubeTexture`]]}else n(i.Vec2),a=S.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1])]);break;case 3:n(i.Vec3),a=N.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2])]);break;case 4:n(i.Vec4),a=x.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3])]);break;case 9:n(i.Mat3),a=g.fromCopy9RowMajor(Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3]),Number.parseFloat(t[4]),Number.parseFloat(t[5]),Number.parseFloat(t[6]),Number.parseFloat(t[7]),Number.parseFloat(t[8]));break;case 16:n(i.Mat4),a=F.fromCopy16RowMajor(Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3]),Number.parseFloat(t[4]),Number.parseFloat(t[5]),Number.parseFloat(t[6]),Number.parseFloat(t[7]),Number.parseFloat(t[8]),Number.parseFloat(t[9]),Number.parseFloat(t[10]),Number.parseFloat(t[11]),Number.parseFloat(t[12]),Number.parseFloat(t[13]),Number.parseFloat(t[14]),Number.parseFloat(t[15]));break;default:y.default.error("Invalid format")}}else n(i.Scalar),o==="true"?a=new l(new Float32Array([1])):o==="false"?a=new l(new Float32Array([0])):a=new l(new Float32Array([Number.parseFloat(o)]));return a}static cb(r,e){if(e.compositionType===i.Scalar)return new l(new Float32Array([0]));if(e.compositionType===i.Vec2)return S.zero();if(e.compositionType===i.Vec3)return N.zero();if(e.compositionType===i.Vec4)return x.zero();if(e.compositionType===i.Mat2)return C.identity();if(e.compositionType===i.Mat3)return g.identity();if(e.compositionType===i.Mat4)return F.identity();if(e.compositionType===i.Texture2D)return[0,r.dummyTextures.dummyWhiteTexture];if(e.compositionType===i.Texture2DShadow)return[0,r.dummyTextures.dummyWhiteTexture];if(e.compositionType===i.TextureCube)return[0,r.dummyTextures.dummyBlackTexture];y.default.warn("initial value is not found")}};export{M as ShaderityUtilityWebGL};
1
+ import d from"../../../_deps/shaderity.js";import{BlendShapeComponent as A}from"../../components/BlendShape/BlendShapeComponent.js";import{WellKnownComponentTIDs as O}from"../../components/WellKnownComponentTIDs.js";import{ComponentType as h}from"../../definitions/ComponentType.js";import{CompositionType as i}from"../../definitions/CompositionType.js";import{ShaderType as T}from"../../definitions/ShaderType.js";import{VertexAttribute as V}from"../../definitions/VertexAttribute.js";import{MutableMatrix22 as C}from"../../math/MutableMatrix22.js";import{MutableMatrix33 as g}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as F}from"../../math/MutableMatrix44.js";import{MutableScalar as l}from"../../math/MutableScalar.js";import{MutableVector2 as S}from"../../math/MutableVector2.js";import{MutableVector3 as N}from"../../math/MutableVector3.js";import{MutableVector4 as x}from"../../math/MutableVector4.js";import{Logger as y}from"../../misc/Logger.js";var b=d.default||d,M=class{static fillTemplate(r,e,o,u){let n=b.fillTemplate(e,u),a=r.webglResourceRepository,s=a.currentWebGLContextWrapper;if(s==null)return n;let t=s.getMaxTextureSize(),m=o.constructor.getMorphUniformDataOffsets(),p={WellKnownComponentTIDs:O,widthOfDataTexture:`const int widthOfDataTexture = ${t};`,dataUBODefinition:a.getGlslDataUBODefinitionString(),dataUBOVec4Size:a.getGlslDataUBOVec4SizeString(),maxMorphOffsetsDataNumber:`${Math.max(Math.ceil(m[m.length-1]/4),1)}`,maxMorphWeightsDataNumber:`${A._getMorphWeightsVec4Count(r)}`};return b.fillTemplate(n,p)}static transformWebGLVersion(r,e){return e?b.transformToGLSLES3(r):b.transformToGLSLES1(r,!0)}static getAttributeReflection(r){let e=b.createReflectionObject(r);this.ab(e),e.reflect();let o=e.attributesNames,u=e.attributesSemantics.map((s,t)=>{let m=V.fromString(s);return m===void 0&&y.default.error(`Unknown vertex attribute semantic: name=${o[t]}, semantic=${s}`),m}),n=e.attributesTypes.map(s=>i.fromGlslString(s)),a=e.attributesTypes.map(s=>h.fromGlslString(s));return{names:o,semantics:u,compositions:n,components:a}}static ab(r){let e=new Map;e.set("instanceids","INSTANCE"),e.set("barycentriccoord","BARY_CENTRIC_COORD"),r.addAttributeSemanticsMap(e)}static getShaderDataReflection(r,e){let o=this.ob(e),u=e.code.split(/\r\n|\n/),n=[],a=[];for(let s of u){let t=/^(?![/])[\t ]*uniform[\t ]+(\w+)[\t ]+(\w+);[\t ]*(\/\/)*[\t ]*(.*)/,m=s.match(t);if(m){let p=m[1],f=m[2],c=m[4];if(this.mb(c)){n.push(s);continue}let w=this.ub(r,p,f,c,e.isFragmentShader);a.push(w)}else n.push(s)}return o.code=n.join(`
2
+ `),{shaderSemanticsInfoArray:a,shaderityObject:o}}static ob(r){return{code:r.code,shaderStage:r.shaderStage,isFragmentShader:r.shaderStage==="fragment"}}static mb(r){let e=r.match(/skipProcess[\t ]*=[\t ]*(\w+)[,\t ]*/);return(e==null?void 0:e[1])==="true"}static ub(r,e,o,u,n){let a=h.fromGlslString(e),s=i.fromGlslString(e),t=n?T.PixelShader:T.VertexShader;o=o.match(/u_(\w+)/)[1];let p={semantic:o,compositionType:s,componentType:a,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:t};return this.pb(r,p,u),p}static pb(r,e,o){let u=o.match(/soloDatum[\t ]*=[\t ]*(\w+)[,\t ]*/),n=!1;(u==null?void 0:u[1])==="true"&&(n=!0),e.soloDatum=n;let a=o.match(/isInternalSetting[\t ]*=[\t ]*(\w+)[,\t ]*/),s=!1;(a==null?void 0:a[1])==="true"&&(s=!0),e.isInternalSetting=s;let t=o.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(t){let c=t[1];e.initialValue=this.cb(r,e,c)}else e.initialValue=this.lb(r,e);let m=o.match(/needUniformInDataTextureMode[\t ]*=[\t ]*(.+)[,\t ]*/);if(m){let c=!1;(m==null?void 0:m[1])==="true"&&(c=!0),e.needUniformInDataTextureMode=c}let p=o.match(/max[\t ]*=[\t ]*(.+)[,\t ]*/);p&&(e.max=Number.parseFloat(p[1]));let f=o.match(/min[\t ]*=[\t ]*(.+)[,\t ]*/);f&&(e.min=Number.parseFloat(f[1]))}static cb(r,e,o){let u=o.match(/\(([\d\w., ]+)\)/),n=s=>{e.compositionType!==s&&y.default.error(`component number of initialValue is invalid:${e.semantic}`)},a;if(u){let t=u[1].split(",");switch(t.length){case 1:n(i.Scalar),t[0]==="true"?a=new l(new Float32Array([1])):t[0]==="false"?a=new l(new Float32Array([0])):a=new l(new Float32Array([Number.parseFloat(t[0])]));break;case 2:if(e.compositionType===i.Texture2D||e.compositionType===i.Texture2DShadow){let m=t[1].charAt(0).toUpperCase()+t[1].slice(1);a=[Number.parseInt(t[0],10),r.dummyTextures[`dummy${m}Texture`]]}else if(e.compositionType===i.TextureCube){let m=t[1].charAt(0).toUpperCase()+t[1].slice(1);a=[Number.parseInt(t[0],10),r.dummyTextures[`dummy${m}CubeTexture`]]}else n(i.Vec2),a=S.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1])]);break;case 3:n(i.Vec3),a=N.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2])]);break;case 4:n(i.Vec4),a=x.fromCopyArray([Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3])]);break;case 9:n(i.Mat3),a=g.fromCopy9RowMajor(Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3]),Number.parseFloat(t[4]),Number.parseFloat(t[5]),Number.parseFloat(t[6]),Number.parseFloat(t[7]),Number.parseFloat(t[8]));break;case 16:n(i.Mat4),a=F.fromCopy16RowMajor(Number.parseFloat(t[0]),Number.parseFloat(t[1]),Number.parseFloat(t[2]),Number.parseFloat(t[3]),Number.parseFloat(t[4]),Number.parseFloat(t[5]),Number.parseFloat(t[6]),Number.parseFloat(t[7]),Number.parseFloat(t[8]),Number.parseFloat(t[9]),Number.parseFloat(t[10]),Number.parseFloat(t[11]),Number.parseFloat(t[12]),Number.parseFloat(t[13]),Number.parseFloat(t[14]),Number.parseFloat(t[15]));break;default:y.default.error("Invalid format")}}else n(i.Scalar),o==="true"?a=new l(new Float32Array([1])):o==="false"?a=new l(new Float32Array([0])):a=new l(new Float32Array([Number.parseFloat(o)]));return a}static lb(r,e){if(e.compositionType===i.Scalar)return new l(new Float32Array([0]));if(e.compositionType===i.Vec2)return S.zero();if(e.compositionType===i.Vec3)return N.zero();if(e.compositionType===i.Vec4)return x.zero();if(e.compositionType===i.Mat2)return C.identity();if(e.compositionType===i.Mat3)return g.identity();if(e.compositionType===i.Mat4)return F.identity();if(e.compositionType===i.Texture2D)return[0,r.dummyTextures.dummyWhiteTexture];if(e.compositionType===i.Texture2DShadow)return[0,r.dummyTextures.dummyWhiteTexture];if(e.compositionType===i.TextureCube)return[0,r.dummyTextures.dummyBlackTexture];y.default.warn("initial value is not found")}};export{M as ShaderityUtilityWebGL};
@@ -1,2 +1,2 @@
1
- import N from"../../../_deps/shaderity.js";import{BlendShapeComponent as k}from"../../components/BlendShape/BlendShapeComponent.js";import{TextureParameter as c}from"../../definitions/index.js";import{ComponentType as w}from"../../definitions/ComponentType.js";import{CompositionType as i}from"../../definitions/CompositionType.js";import{ShaderType as g}from"../../definitions/ShaderType.js";import{MutableMatrix22 as I}from"../../math/MutableMatrix22.js";import{MutableMatrix33 as M}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as A}from"../../math/MutableMatrix44.js";import{MutableScalar as y}from"../../math/MutableScalar.js";import{MutableVector2 as V}from"../../math/MutableVector2.js";import{MutableVector3 as C}from"../../math/MutableVector3.js";import{MutableVector4 as E}from"../../math/MutableVector4.js";import{Logger as T}from"../../misc/Logger.js";import{Sampler as O}from"../../textures/Sampler.js";var v=N.default||N,D=class{static fillTemplate(r,t,n,o){let a=v.fillTemplate(t,o),s=n.constructor.getMorphUniformDataOffsets(),e={maxMorphOffsetsDataNumber:`${Math.max(Math.ceil(s[s.length-1]/4),1)}`,maxMorphWeightsDataNumber:`${k._getMorphWeightsVec4Count(r)}`};return v.fillTemplate(a,e)}static getShaderDataReflection(r,t){let n=this.ob(t),o=new Map,a=t.code.split(/\r\n|\n/),s=[],e=[];for(let m of a){let u=/^[\t ]*\/\/[\t ]*#param[\t ]+(\w+)[ \t]*:[\t ]*([\w><]+);[\t ]*(\/\/)*[\t ]*(.*)/,p=m.match(u),f=/^[\t ]*@group\(1\) @binding\((\d+)\)[ \t]*var[ \t]*(\w+)[ \t]*:[ \t]*([\w><]+);[\t ]*\/\/*[\t ]*(.*)/,l=m.match(f),j=/^[\t ]*@group\(2\) @binding\((\d+)\)[ \t]*var[ \t]*(\w+)[ \t]*:[ \t]*sampler;/,S=m.match(j);if(p){let b=p[2],d=p[1],h=p[4],F=this.mb(r,b,d,h,t.isFragmentShader);e.push(F)}else if(l){let b=Number.parseInt(l[1],10),d=l[2],h=l[3],F=l[4],x=this.lb(r,h,d,b,F,t.isFragmentShader);o.set(b,x),e.push(x)}else if(S){let b=Number.parseInt(S[1],10);if(o.has(b)){let d=o.get(b);if(d){let h=new O(r,{magFilter:c.Linear,minFilter:c.Linear,wrapS:c.Repeat,wrapT:c.Repeat,wrapR:c.Repeat,anisotropy:!1});d.initialValue[2]=h}}}else s.push(m)}return n.code=s.join(`
2
- `),{shaderSemanticsInfoArray:e,shaderityObject:n}}static lb(r,t,n,o,a,s){let e=w.Int,m=i.Texture2D;t.indexOf("texture_2d")!==-1?m=i.Texture2D:t.indexOf("texture_cube")!==-1&&(m=i.TextureCube);let u=s?g.PixelShader:g.VertexShader,p={semantic:n,compositionType:m,componentType:e,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:u},f=a.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(f){let l=f[1];p.initialValue=this.fb(r,p,o,l)}else p.initialValue=this.cb(r,p);return p}static mb(r,t,n,o,a){let s=w.fromWgslString(t),e=i.fromWgslString(t),m=a?g.PixelShader:g.VertexShader,u={semantic:n,compositionType:e,componentType:s,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:m};return this.ub(r,u,o),u}static ub(r,t,n){let o=n.match(/soloDatum[\t ]*=[\t ]*(\w+)[,\t ]*/),a=!1;(o==null?void 0:o[1])==="true"&&(a=!0),t.soloDatum=a;let s=n.match(/isInternalSetting[\t ]*=[\t ]*(\w+)[,\t ]*/),e=!1;(s==null?void 0:s[1])==="true"&&(e=!0),t.isInternalSetting=e;let m=n.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(m){let l=m[1];t.initialValue=this.pb(t,l)}else t.initialValue=this.cb(r,t);let u=n.match(/needUniformInDataTextureMode[\t ]*=[\t ]*(.+)[,\t ]*/);if(u){let l=!1;(u==null?void 0:u[1])==="true"&&(l=!0),t.needUniformInDataTextureMode=l}let p=n.match(/max[\t ]*=[\t ]*(.+)[,\t ]*/);p&&(t.max=Number.parseFloat(p[1]));let f=n.match(/min[\t ]*=[\t ]*(.+)[,\t ]*/);f&&(t.min=Number.parseFloat(f[1]))}static fb(r,t,n,o){let a,s=new O(r,{magFilter:c.Linear,minFilter:c.Linear,wrapS:c.ClampToEdge,wrapT:c.ClampToEdge,wrapR:c.ClampToEdge,anisotropy:!1});if(t.compositionType===i.Texture2D||t.compositionType===i.Texture2DShadow){let e=o.charAt(0).toUpperCase()+o.slice(1);a=[n,r.dummyTextures[`dummy${e}Texture`],s]}else if(t.compositionType===i.TextureCube){let e=o.charAt(0).toUpperCase()+o.slice(1);a=[n,r.dummyTextures[`dummy${e}CubeTexture`],s]}return a}static pb(r,t){let n=t.match(/\(([\d\w., ]+)\)/),o=s=>{r.compositionType!==s&&T.default.error(`component number of initialValue is invalid:${r.semantic}`)},a;if(n){let e=n[1].split(",");switch(e.length){case 1:o(i.Scalar),e[0]==="true"?a=new y(new Float32Array([1])):e[0]==="false"?a=new y(new Float32Array([0])):a=new y(new Float32Array([Number.parseFloat(e[0])]));break;case 2:o(i.Vec2),a=V.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1])]);break;case 3:o(i.Vec3),a=C.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2])]);break;case 4:o(i.Vec4),a=E.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3])]);break;case 9:o(i.Mat3),a=M.fromCopy9RowMajor(Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3]),Number.parseFloat(e[4]),Number.parseFloat(e[5]),Number.parseFloat(e[6]),Number.parseFloat(e[7]),Number.parseFloat(e[8]));break;case 16:o(i.Mat4),a=A.fromCopy16RowMajor(Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3]),Number.parseFloat(e[4]),Number.parseFloat(e[5]),Number.parseFloat(e[6]),Number.parseFloat(e[7]),Number.parseFloat(e[8]),Number.parseFloat(e[9]),Number.parseFloat(e[10]),Number.parseFloat(e[11]),Number.parseFloat(e[12]),Number.parseFloat(e[13]),Number.parseFloat(e[14]),Number.parseFloat(e[15]));break;default:T.default.error("Invalid format")}}else o(i.Scalar),t==="true"?a=new y(new Float32Array([1])):t==="false"?a=new y(new Float32Array([0])):a=new y(new Float32Array([Number.parseFloat(t)]));return a}static cb(r,t){if(t.compositionType===i.Scalar)return new y(new Float32Array([0]));if(t.compositionType===i.Vec2)return V.zero();if(t.compositionType===i.Vec3)return C.zero();if(t.compositionType===i.Vec4)return E.zero();if(t.compositionType===i.Mat2)return I.identity();if(t.compositionType===i.Mat3)return M.identity();if(t.compositionType===i.Mat4)return A.identity();if(t.compositionType===i.Texture2D)return[0,r.dummyTextures.dummyWhiteTexture];if(t.compositionType===i.Texture2DShadow)return[0,r.dummyTextures.dummyWhiteTexture];if(t.compositionType===i.TextureCube)return[0,r.dummyTextures.dummyBlackTexture];T.default.warn("initial value is not found")}static ob(r){return{code:r.code,shaderStage:r.shaderStage,isFragmentShader:r.shaderStage==="fragment"}}};export{D as ShaderityUtilityWebGPU};
1
+ import N from"../../../_deps/shaderity.js";import{BlendShapeComponent as k}from"../../components/BlendShape/BlendShapeComponent.js";import{TextureParameter as c}from"../../definitions/index.js";import{ComponentType as w}from"../../definitions/ComponentType.js";import{CompositionType as i}from"../../definitions/CompositionType.js";import{ShaderType as g}from"../../definitions/ShaderType.js";import{MutableMatrix22 as I}from"../../math/MutableMatrix22.js";import{MutableMatrix33 as M}from"../../math/MutableMatrix33.js";import{MutableMatrix44 as A}from"../../math/MutableMatrix44.js";import{MutableScalar as y}from"../../math/MutableScalar.js";import{MutableVector2 as V}from"../../math/MutableVector2.js";import{MutableVector3 as C}from"../../math/MutableVector3.js";import{MutableVector4 as E}from"../../math/MutableVector4.js";import{Logger as T}from"../../misc/Logger.js";import{Sampler as O}from"../../textures/Sampler.js";var v=N.default||N,D=class{static fillTemplate(r,t,n,o){let a=v.fillTemplate(t,o),s=n.constructor.getMorphUniformDataOffsets(),e={maxMorphOffsetsDataNumber:`${Math.max(Math.ceil(s[s.length-1]/4),1)}`,maxMorphWeightsDataNumber:`${k._getMorphWeightsVec4Count(r)}`};return v.fillTemplate(a,e)}static getShaderDataReflection(r,t){let n=this.ob(t),o=new Map,a=t.code.split(/\r\n|\n/),s=[],e=[];for(let m of a){let u=/^[\t ]*\/\/[\t ]*#param[\t ]+(\w+)[ \t]*:[\t ]*([\w><]+);[\t ]*(\/\/)*[\t ]*(.*)/,p=m.match(u),f=/^[\t ]*@group\(1\) @binding\((\d+)\)[ \t]*var[ \t]*(\w+)[ \t]*:[ \t]*([\w><]+);[\t ]*\/\/*[\t ]*(.*)/,l=m.match(f),j=/^[\t ]*@group\(2\) @binding\((\d+)\)[ \t]*var[ \t]*(\w+)[ \t]*:[ \t]*sampler;/,S=m.match(j);if(p){let b=p[2],d=p[1],h=p[4],F=this.ub(r,b,d,h,t.isFragmentShader);e.push(F)}else if(l){let b=Number.parseInt(l[1],10),d=l[2],h=l[3],F=l[4],x=this.fb(r,h,d,b,F,t.isFragmentShader);o.set(b,x),e.push(x)}else if(S){let b=Number.parseInt(S[1],10);if(o.has(b)){let d=o.get(b);if(d){let h=new O(r,{magFilter:c.Linear,minFilter:c.Linear,wrapS:c.Repeat,wrapT:c.Repeat,wrapR:c.Repeat,anisotropy:!1});d.initialValue[2]=h}}}else s.push(m)}return n.code=s.join(`
2
+ `),{shaderSemanticsInfoArray:e,shaderityObject:n}}static fb(r,t,n,o,a,s){let e=w.Int,m=i.Texture2D;t.indexOf("texture_2d")!==-1?m=i.Texture2D:t.indexOf("texture_cube")!==-1&&(m=i.TextureCube);let u=s?g.PixelShader:g.VertexShader,p={semantic:n,compositionType:m,componentType:e,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:u},f=a.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(f){let l=f[1];p.initialValue=this.bb(r,p,o,l)}else p.initialValue=this.lb(r,p);return p}static ub(r,t,n,o,a){let s=w.fromWgslString(t),e=i.fromWgslString(t),m=a?g.PixelShader:g.VertexShader,u={semantic:n,compositionType:e,componentType:s,min:-Number.MAX_VALUE,max:Number.MAX_VALUE,isInternalSetting:!1,stage:m};return this.pb(r,u,o),u}static pb(r,t,n){let o=n.match(/soloDatum[\t ]*=[\t ]*(\w+)[,\t ]*/),a=!1;(o==null?void 0:o[1])==="true"&&(a=!0),t.soloDatum=a;let s=n.match(/isInternalSetting[\t ]*=[\t ]*(\w+)[,\t ]*/),e=!1;(s==null?void 0:s[1])==="true"&&(e=!0),t.isInternalSetting=e;let m=n.match(/initialValue[\t ]*=[\t ]*(.+)[,\t ]*/);if(m){let l=m[1];t.initialValue=this.cb(t,l)}else t.initialValue=this.lb(r,t);let u=n.match(/needUniformInDataTextureMode[\t ]*=[\t ]*(.+)[,\t ]*/);if(u){let l=!1;(u==null?void 0:u[1])==="true"&&(l=!0),t.needUniformInDataTextureMode=l}let p=n.match(/max[\t ]*=[\t ]*(.+)[,\t ]*/);p&&(t.max=Number.parseFloat(p[1]));let f=n.match(/min[\t ]*=[\t ]*(.+)[,\t ]*/);f&&(t.min=Number.parseFloat(f[1]))}static bb(r,t,n,o){let a,s=new O(r,{magFilter:c.Linear,minFilter:c.Linear,wrapS:c.ClampToEdge,wrapT:c.ClampToEdge,wrapR:c.ClampToEdge,anisotropy:!1});if(t.compositionType===i.Texture2D||t.compositionType===i.Texture2DShadow){let e=o.charAt(0).toUpperCase()+o.slice(1);a=[n,r.dummyTextures[`dummy${e}Texture`],s]}else if(t.compositionType===i.TextureCube){let e=o.charAt(0).toUpperCase()+o.slice(1);a=[n,r.dummyTextures[`dummy${e}CubeTexture`],s]}return a}static cb(r,t){let n=t.match(/\(([\d\w., ]+)\)/),o=s=>{r.compositionType!==s&&T.default.error(`component number of initialValue is invalid:${r.semantic}`)},a;if(n){let e=n[1].split(",");switch(e.length){case 1:o(i.Scalar),e[0]==="true"?a=new y(new Float32Array([1])):e[0]==="false"?a=new y(new Float32Array([0])):a=new y(new Float32Array([Number.parseFloat(e[0])]));break;case 2:o(i.Vec2),a=V.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1])]);break;case 3:o(i.Vec3),a=C.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2])]);break;case 4:o(i.Vec4),a=E.fromCopyArray([Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3])]);break;case 9:o(i.Mat3),a=M.fromCopy9RowMajor(Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3]),Number.parseFloat(e[4]),Number.parseFloat(e[5]),Number.parseFloat(e[6]),Number.parseFloat(e[7]),Number.parseFloat(e[8]));break;case 16:o(i.Mat4),a=A.fromCopy16RowMajor(Number.parseFloat(e[0]),Number.parseFloat(e[1]),Number.parseFloat(e[2]),Number.parseFloat(e[3]),Number.parseFloat(e[4]),Number.parseFloat(e[5]),Number.parseFloat(e[6]),Number.parseFloat(e[7]),Number.parseFloat(e[8]),Number.parseFloat(e[9]),Number.parseFloat(e[10]),Number.parseFloat(e[11]),Number.parseFloat(e[12]),Number.parseFloat(e[13]),Number.parseFloat(e[14]),Number.parseFloat(e[15]));break;default:T.default.error("Invalid format")}}else o(i.Scalar),t==="true"?a=new y(new Float32Array([1])):t==="false"?a=new y(new Float32Array([0])):a=new y(new Float32Array([Number.parseFloat(t)]));return a}static lb(r,t){if(t.compositionType===i.Scalar)return new y(new Float32Array([0]));if(t.compositionType===i.Vec2)return V.zero();if(t.compositionType===i.Vec3)return C.zero();if(t.compositionType===i.Vec4)return E.zero();if(t.compositionType===i.Mat2)return I.identity();if(t.compositionType===i.Mat3)return M.identity();if(t.compositionType===i.Mat4)return A.identity();if(t.compositionType===i.Texture2D)return[0,r.dummyTextures.dummyWhiteTexture];if(t.compositionType===i.Texture2DShadow)return[0,r.dummyTextures.dummyWhiteTexture];if(t.compositionType===i.TextureCube)return[0,r.dummyTextures.dummyBlackTexture];T.default.warn("initial value is not found")}static ob(r){return{code:r.code,shaderStage:r.shaderStage,isFragmentShader:r.shaderStage==="fragment"}}};export{D as ShaderityUtilityWebGPU};
@@ -1,12 +1,12 @@
1
- import{ComponentType as o}from"../definitions/ComponentType.js";import{CompositionType as g}from"../definitions/CompositionType.js";import{Matrix33 as z}from"../math/Matrix33.js";import{MutableMatrix44 as w}from"../math/MutableMatrix44.js";import{MutableVector2 as L}from"../math/MutableVector2.js";import{MutableVector3 as X}from"../math/MutableVector3.js";import{MutableVector4 as O}from"../math/MutableVector4.js";import{Vector2 as M}from"../math/Vector2.js";import{Vector3 as N}from"../math/Vector3.js";import{Vector4 as T}from"../math/Vector4.js";import{Is as C}from"../misc/Is.js";import{Logger as V}from"../misc/Logger.js";var a=class a{constructor({bufferView:s,byteOffsetInBufferView:e,compositionType:h,componentType:t,byteStride:i,count:r,raw:c,max:u,min:y,arrayLength:_,normalized:A}){this.p_=g.Unknown;this.c_=o.Unknown;this.Vb=0;this.Cb=new Float32Array;this.vb=0;this.hb=0;this.ny=O.fromCopyArray([-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]);this.sy=O.fromCopyArray([Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE]);this.Ib=1;this.Nb=!1;this.gb=!0;this.Mb=0;var I,B,S,f,n,m,x,E;this.Bb=s,this.Ab=s.byteOffsetInRawArrayBufferOfBuffer+e,this.p_=h,this.c_=t,this.Vb=r,this.Ib=_,C.exist(u)&&this.ny.setComponents((I=u[0])!=null?I:-Number.MAX_VALUE,(B=u[1])!=null?B:-Number.MAX_VALUE,(S=u[2])!=null?S:-Number.MAX_VALUE,(f=u[3])!=null?f:-Number.MAX_VALUE),C.exist(y)&&this.sy.setComponents((n=y[0])!=null?n:Number.MAX_VALUE,(m=y[1])!=null?m:Number.MAX_VALUE,(x=y[2])!=null?x:Number.MAX_VALUE,(E=y[3])!=null?E:Number.MAX_VALUE),C.exist(u)&&C.exist(y)&&(this.gb=!1),this.Fp=c,this.Nb=A,this.hb=i,this.hb===0&&(this.hb=this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()*this.Ib);let p=this.getTypedArrayClass(this.c_);this.Ob=p;let b=this.hb-this.p_.getNumberOfComponents()*this.c_.getSizeInBytes(),l=this.Fp.byteLength-this.Ab,v=this.byteStride*this.Vb-b;l<v&&V.default.error(`Requesting a data size that exceeds the remaining capacity of the buffer: ${this.bufferView.buffer.name}.
1
+ import{ComponentType as o}from"../definitions/ComponentType.js";import{CompositionType as g}from"../definitions/CompositionType.js";import{Matrix33 as z}from"../math/Matrix33.js";import{MutableMatrix44 as w}from"../math/MutableMatrix44.js";import{MutableVector2 as L}from"../math/MutableVector2.js";import{MutableVector3 as X}from"../math/MutableVector3.js";import{MutableVector4 as O}from"../math/MutableVector4.js";import{Vector2 as M}from"../math/Vector2.js";import{Vector3 as N}from"../math/Vector3.js";import{Vector4 as T}from"../math/Vector4.js";import{Is as C}from"../misc/Is.js";import{Logger as V}from"../misc/Logger.js";var a=class a{constructor({bufferView:s,byteOffsetInBufferView:e,compositionType:h,componentType:t,byteStride:i,count:r,raw:c,max:u,min:y,arrayLength:_,normalized:A}){this.p_=g.Unknown;this.c_=o.Unknown;this.Ab=0;this.Ob=new Float32Array;this.Ib=0;this.hb=0;this.ny=O.fromCopyArray([-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]);this.sy=O.fromCopyArray([Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE]);this.Bb=1;this.Tb=!1;this.Vb=!0;this.Nb=0;var I,B,S,f,n,m,x,E;this.Cb=s,this._b=s.byteOffsetInRawArrayBufferOfBuffer+e,this.p_=h,this.c_=t,this.Ab=r,this.Bb=_,C.exist(u)&&this.ny.setComponents((I=u[0])!=null?I:-Number.MAX_VALUE,(B=u[1])!=null?B:-Number.MAX_VALUE,(S=u[2])!=null?S:-Number.MAX_VALUE,(f=u[3])!=null?f:-Number.MAX_VALUE),C.exist(y)&&this.sy.setComponents((n=y[0])!=null?n:Number.MAX_VALUE,(m=y[1])!=null?m:Number.MAX_VALUE,(x=y[2])!=null?x:Number.MAX_VALUE,(E=y[3])!=null?E:Number.MAX_VALUE),C.exist(u)&&C.exist(y)&&(this.Vb=!1),this.Fp=c,this.Tb=A,this.hb=i,this.hb===0&&(this.hb=this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()*this.Bb);let p=this.getTypedArrayClass(this.c_);this.Mb=p;let b=this.hb-this.p_.getNumberOfComponents()*this.c_.getSizeInBytes(),l=this.Fp.byteLength-this._b,v=this.byteStride*this.Ab-b;l<v&&V.default.error(`Requesting a data size that exceeds the remaining capacity of the buffer: ${this.bufferView.buffer.name}.
2
2
  Exceeded Size: ${v-l}
3
3
  this.__raw.byteLength: ${this.Fp.byteLength}
4
4
  this.__byteOffsetInRawArrayBufferOfBuffer: ${this.byteOffsetInRawArrayBufferOfBuffer}
5
5
  this.byteStride: ${this.byteStride}
6
- this.__count: ${this.Vb}
7
- this.__raw.byteLength - this.__byteOffsetInRawArrayBufferOfBuffer: ${this.Fp.byteLength-this.Ab}
8
- this.byteStride * this.__count: ${this.byteStride*this.Vb}
6
+ this.__count: ${this.Ab}
7
+ this.__raw.byteLength - this.__byteOffsetInRawArrayBufferOfBuffer: ${this.Fp.byteLength-this._b}
8
+ this.byteStride * this.__count: ${this.byteStride*this.Ab}
9
9
  maxExceededSizeOnAoS: ${b}
10
- `),this.Sb=new DataView(this.Fp,this.Ab,Math.min(this.hb*this.Vb,this.Fp.byteLength-this.Ab)),this.Ab%p.BYTES_PER_ELEMENT===0?this.Cb=new p(this.Fp,this.Ab,this.p_.getNumberOfComponents()*this.Vb):(V.default.warn(`This Accessor's byteOffsetInRawArrayBufferOfBuffer is not aligned with the typedArrayClass's BYTES_PER_ELEMENT. So we need to copy the buffer.
10
+ `),this.vb=new DataView(this.Fp,this._b,Math.min(this.hb*this.Ab,this.Fp.byteLength-this._b)),this._b%p.BYTES_PER_ELEMENT===0?this.Ob=new p(this.Fp,this._b,this.p_.getNumberOfComponents()*this.Ab):(V.default.warn(`This Accessor's byteOffsetInRawArrayBufferOfBuffer is not aligned with the typedArrayClass's BYTES_PER_ELEMENT. So we need to copy the buffer.
11
11
  So the typedArray data got by getTypedArray() is copied data, not reference to the original buffer.
12
- `),this.Tb()),this.bb=this.Sb[this.getDataViewGetter(this.c_)].bind(this.Sb),this.yb=this.Sb[this.getDataViewSetter(this.c_)].bind(this.Sb)}Tb(){let s=this.getTypedArrayClass(this.c_),e=this.Fp.slice(this.Ab,this.Ab+this.p_.getNumberOfComponents()*this.Vb*s.BYTES_PER_ELEMENT);this.Cb=new s(e)}_b(){var s;this.Mb++,this._primitive!=null&&((s=this._primitive.deref())==null||s.onAccessorUpdated(this.Mb))}getTypedArrayClass(s){switch(s){case o.Byte:return Int8Array;case o.UnsignedByte:return Uint8Array;case o.Short:return Int16Array;case o.UnsignedShort:return Uint16Array;case o.Int:return Int32Array;case o.UnsignedInt:return Uint32Array;case o.Float:return Float32Array;case o.Double:return Float64Array;default:V.default.error("Unexpected ComponentType!");return}}getDataViewGetter(s){switch(s){case o.Byte:return"getInt8";case o.UnsignedByte:return"getUint8";case o.Short:return"getInt16";case o.UnsignedShort:return"getUint16";case o.Int:return"getInt32";case o.UnsignedInt:return"getUint32";case o.Float:return"getFloat32";case o.Double:return"getFloat64";default:return V.default.error("Unexpected ComponentType!"),"unknown"}}getDataViewSetter(s){switch(s){case o.Byte:return"setInt8";case o.UnsignedByte:return"setUint8";case o.Short:return"setInt16";case o.UnsignedShort:return"setUint16";case o.Int:return"setInt32";case o.UnsignedInt:return"setUint32";case o.Float:return"setFloat32";case o.Double:return"setFloat64";default:V.default.error("Unexpected ComponentType!")}}takeOne(){let s=this.Fp;this.vb>=this.Vb&&V.default.error("You are trying to allocate more than you have secured.");let e=new this.Ob(s,this.Ab+this.hb*this.vb,this.p_.getNumberOfComponents()*this.Ib);return e._accessor=this,e._idx_of_accessor=this.vb,this.vb+=1,e}_takeExistedOne(s){let e=this.Fp;s>=this.Vb&&V.default.error("You are trying to allocate more than you have secured.");let h=new this.Ob(e,this.Ab+this.hb*s,this.p_.getNumberOfComponents()*this.Ib);return h._accessor=this,h._idx_of_accessor=s,h}get takenCount(){return this.vb}get numberOfComponents(){return this.p_.getNumberOfComponents()}get componentSizeInBytes(){return this.c_.getSizeInBytes()}get elementSizeInBytes(){return this.numberOfComponents*this.componentSizeInBytes}get elementCount(){return this.Vb}get byteLength(){return this.hb*this.Vb}get componentType(){return this.c_}get compositionType(){return this.p_}getTypedArray(){return this.Cb}setTypedArray(s){if(s.buffer!==this.Fp){if(this.p_===g.Scalar)for(let e=0;e<this.Vb;e++)this.setScalar(e,s[e],{endian:!0});else if(this.p_===g.Vec2)for(let e=0;e<this.Vb;e++)this.setVec2(e,s[e*2],s[e*2+1],{endian:!0});else if(this.p_===g.Vec3)for(let e=0;e<this.Vb;e++)this.setVec3(e,s[e*3],s[e*3+1],s[e*3+2],{endian:!0});else if(this.p_===g.Vec4)for(let e=0;e<this.Vb;e++)this.setVec4(e,s[e*4],s[e*4+1],s[e*4+2],s[e*4+3],{endian:!0});else if(this.p_===g.Mat3)for(let e=0;e<this.Vb;e++)this.setMat3(e,s[e*9],s[e*9+1],s[e*9+2],s[e*9+3],s[e*9+4],s[e*9+5],s[e*9+6],s[e*9+7],s[e*9+8],{endian:!0});else if(this.p_===g.Mat4)for(let e=0;e<this.Vb;e++)this.setMat4(e,s[e*16],s[e*16+1],s[e*16+2],s[e*16+3],s[e*16+4],s[e*16+5],s[e*16+6],s[e*16+7],s[e*16+8],s[e*16+9],s[e*16+10],s[e*16+11],s[e*16+12],s[e*16+13],s[e*16+14],s[e*16+15],{endian:!0});else throw new Error("Unexpected CompositionType!");this.Tb()}}getUint8Array(){return new Uint8Array(this.bufferView.buffer.getArrayBuffer(),this.byteOffsetInRawArrayBufferOfBuffer,this.byteLength)}get isAoS(){return!this.isSoA}get isSoA(){return this.byteStride===this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()}get byteStride(){return this.hb}getScalar(s,{indicesAccessor:e,endian:h=!0}){let t=s;return e&&(t=e.getScalar(s,{})),this.bb(this.hb*t,h)}getScalarAt(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;return h&&(i=h.getScalar(s,{})),this.bb(this.hb*i+e,t)}getVec2AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h)]}getVec3AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h)]}getVec4AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h)]}getMat3AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h),this.bb(this.hb*t+4*i,h),this.bb(this.hb*t+5*i,h),this.bb(this.hb*t+6*i,h),this.bb(this.hb*t+7*i,h),this.bb(this.hb*t+8*i,h)]}getMat4AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h),this.bb(this.hb*t+4*i,h),this.bb(this.hb*t+5*i,h),this.bb(this.hb*t+6*i,h),this.bb(this.hb*t+7*i,h),this.bb(this.hb*t+8*i,h),this.bb(this.hb*t+9*i,h),this.bb(this.hb*t+10*i,h),this.bb(this.hb*t+11*i,h),this.bb(this.hb*t+12*i,h),this.bb(this.hb*t+13*i,h),this.bb(this.hb*t+14*i,h),this.bb(this.hb*t+15*i,h)]}getVec2(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return M.fromCopyArray2([this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h)])}getVec3(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return N.fromCopyArray([this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h)])}getVec4(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return T.fromCopyArray([this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h)])}getMat3(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return z.fromCopy9RowMajor(this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h),this.bb(this.hb*t+4*i,h),this.bb(this.hb*t+5*i,h),this.bb(this.hb*t+6*i,h),this.bb(this.hb*t+7*i,h),this.bb(this.hb*t+8*i,h))}getMat4(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return w.fromCopy16RowMajor(this.bb(this.hb*t,h),this.bb(this.hb*t+1*i,h),this.bb(this.hb*t+2*i,h),this.bb(this.hb*t+3*i,h),this.bb(this.hb*t+4*i,h),this.bb(this.hb*t+5*i,h),this.bb(this.hb*t+6*i,h),this.bb(this.hb*t+7*i,h),this.bb(this.hb*t+8*i,h),this.bb(this.hb*t+9*i,h),this.bb(this.hb*t+10*i,h),this.bb(this.hb*t+11*i,h),this.bb(this.hb*t+12*i,h),this.bb(this.hb*t+13*i,h),this.bb(this.hb*t+14*i,h),this.bb(this.hb*t+15*i,h))}getVec2To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.bb(this.hb*i,t),this.bb(this.hb*i+1*r,t))}getVec3To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.bb(this.hb*i,t),this.bb(this.hb*i+1*r,t),this.bb(this.hb*i+2*r,t))}getVec4To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.bb(this.hb*i,t),this.bb(this.hb*i+1*r,t),this.bb(this.hb*i+2*r,t),this.bb(this.hb*i+3*r,t))}getMat3To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.bb(this.hb*i,t),this.bb(this.hb*i+1*r,t),this.bb(this.hb*i+2*r,t),this.bb(this.hb*i+3*r,t),this.bb(this.hb*i+4*r,t),this.bb(this.hb*i+5*r,t),this.bb(this.hb*i+6*r,t),this.bb(this.hb*i+7*r,t),this.bb(this.hb*i+8*r,t))}getMat4To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.bb(this.hb*i,t),this.bb(this.hb*i+1*r,t),this.bb(this.hb*i+2*r,t),this.bb(this.hb*i+3*r,t),this.bb(this.hb*i+4*r,t),this.bb(this.hb*i+5*r,t),this.bb(this.hb*i+6*r,t),this.bb(this.hb*i+7*r,t),this.bb(this.hb*i+8*r,t),this.bb(this.hb*i+9*r,t),this.bb(this.hb*i+10*r,t),this.bb(this.hb*i+11*r,t),this.bb(this.hb*i+12*r,t),this.bb(this.hb*i+13*r,t),this.bb(this.hb*i+14*r,t),this.bb(this.hb*i+15*r,t))}setScalar(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{})),this.yb(this.hb*i,e,t),this.gb=!0,this._b()}setVec2(s,e,h,{indicesAccessor:t,endian:i=!0}){let r=s;t&&(r=t.getScalar(s,{}));let c=this.componentSizeInBytes;this.yb(this.hb*r,e,i),this.yb(this.hb*r+1*c,h,i),this.gb=!0,this._b()}setVec3(s,e,h,t,{indicesAccessor:i,endian:r=!0}){let c=s;i&&(c=i.getScalar(s,{}));let u=this.componentSizeInBytes;this.yb(this.hb*c,e,r),this.yb(this.hb*c+1*u,h,r),this.yb(this.hb*c+2*u,t,r),this.gb=!0,this._b()}setVec4(s,e,h,t,i,{indicesAccessor:r,endian:c=!0}){let u=s;r&&(u=r.getScalar(s,{}));let y=this.componentSizeInBytes;this.yb(this.hb*u,e,c),this.yb(this.hb*u+1*y,h,c),this.yb(this.hb*u+2*y,t,c),this.yb(this.hb*u+3*y,i,c),this.gb=!0,this._b()}setMat3(s,e,h,t,i,r,c,u,y,_,{indicesAccessor:A,endian:p=!0}){let b=s;A&&(b=A.getScalar(s,{}));let l=this.componentSizeInBytes;this.yb(this.hb*b,e,p),this.yb(this.hb*b+1*l,h,p),this.yb(this.hb*b+2*l,t,p),this.yb(this.hb*b+3*l,i,p),this.yb(this.hb*b+4*l,r,p),this.yb(this.hb*b+5*l,c,p),this.yb(this.hb*b+6*l,u,p),this.yb(this.hb*b+7*l,y,p),this.yb(this.hb*b+8*l,_,p),this.gb=!0,this._b()}setMat4(s,e,h,t,i,r,c,u,y,_,A,p,b,l,v,I,B,{indicesAccessor:S,endian:f=!0}){let n=s;S&&(n=S.getScalar(s,{}));let m=this.componentSizeInBytes;this.yb(this.hb*n,e,f),this.yb(this.hb*n+1*m,h,f),this.yb(this.hb*n+2*m,t,f),this.yb(this.hb*n+3*m,i,f),this.yb(this.hb*n+4*m,r,f),this.yb(this.hb*n+5*m,c,f),this.yb(this.hb*n+6*m,u,f),this.yb(this.hb*n+7*m,y,f),this.yb(this.hb*n+8*m,_,f),this.yb(this.hb*n+9*m,A,f),this.yb(this.hb*n+10*m,p,f),this.yb(this.hb*n+11*m,b,f),this.yb(this.hb*n+12*m,l,f),this.yb(this.hb*n+13*m,v,f),this.yb(this.hb*n+14*m,I,f),this.yb(this.hb*n+15*m,B,f),this.gb=!0,this._b()}setVec2AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.yb(this.hb*i,e.x,t),this.yb(this.hb*i+1*r,e.y,t),this.gb=!0,this._b()}setVec3AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.yb(this.hb*i,e.x,t),this.yb(this.hb*i+1*r,e.y,t),this.yb(this.hb*i+2*r,e.z,t),this.gb=!0,this._b()}setVec4AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.yb(this.hb*i,e.x,t),this.yb(this.hb*i+1*r,e.y,t),this.yb(this.hb*i+2*r,e.z,t),this.yb(this.hb*i+3*r,e.w,t),this.gb=!0,this._b()}setMat4AsMatrix44(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.yb(this.hb*i,e._v[0],t),this.yb(this.hb*i+1*r,e._v[1],t),this.yb(this.hb*i+2*r,e._v[2],t),this.yb(this.hb*i+3*r,e._v[3],t),this.yb(this.hb*i+4*r,e._v[4],t),this.yb(this.hb*i+5*r,e._v[5],t),this.yb(this.hb*i+6*r,e._v[6],t),this.yb(this.hb*i+7*r,e._v[7],t),this.yb(this.hb*i+8*r,e._v[8],t),this.yb(this.hb*i+9*r,e._v[9],t),this.yb(this.hb*i+10*r,e._v[10],t),this.yb(this.hb*i+11*r,e._v[11],t),this.yb(this.hb*i+12*r,e._v[12],t),this.yb(this.hb*i+13*r,e._v[13],t),this.yb(this.hb*i+14*r,e._v[14],t),this.yb(this.hb*i+15*r,e._v[15],t),this.gb=!0,this._b()}copyFromTypedArray(s){let e=this.numberOfComponents;for(let h=0;h<s.byteLength/this.componentSizeInBytes;h++){let t=Math.floor(h/e),i=t*e;switch(e){case 1:this.setScalar(t,s[i+0],{});break;case 2:this.setVec2(t,s[i+0],s[i+1],{});break;case 3:this.setVec3(t,s[i+0],s[i+1],s[i+2],{});break;case 4:this.setVec4(t,s[i+0],s[i+1],s[i+2],s[i+3],{});break;default:throw new Error("Other than vectors are currently not supported.")}}this.gb=!0,this._b()}setScalarAt(s,e,h,{indicesAccessor:t,endian:i=!0}){let r=s;t&&(r=t.getScalar(s,{})),this.yb(this.hb*r+e,h,i),this.gb=!0,this._b()}setElementFromSameCompositionAccessor(s,e,h){let t=h!=null?h:s;this.compositionType.getNumberOfComponents()===1?this.setScalar(s,e.getScalar(t,{}),{}):this.compositionType.getNumberOfComponents()===2?this.setVec2AsVector(s,e.getVec2(t,{}),{}):this.compositionType.getNumberOfComponents()===3?this.setVec3AsVector(s,e.getVec3(t,{}),{}):this.compositionType.getNumberOfComponents()===4&&this.setVec4AsVector(s,e.getVec4(t,{}),{}),this.gb=!0,this._b()}copyBuffer(s){new Uint8Array(this.Fp).set(new Uint8Array(s.Fp,s.Ab,s.byteLength),this.Ab),this.gb=!0,this._b()}setElementFromAccessor(s,e,h){let t=h!=null?h:s;if(this.compositionType.getNumberOfComponents()===1)e.compositionType.getNumberOfComponents()===1?this.setScalar(s,e.getScalar(t,{}),{}):e.compositionType.getNumberOfComponents()===2?this.setScalar(s,e.getVec2(t,{}).x,{}):e.compositionType.getNumberOfComponents()===3?this.setScalar(s,e.getVec3(t,{}).x,{}):e.compositionType.getNumberOfComponents()===4&&this.setScalar(s,e.getVec4(t,{}).x,{});else if(this.compositionType.getNumberOfComponents()===2){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec2(s,i,0,{})}else if(e.compositionType.getNumberOfComponents()===2)this.setVec2AsVector(s,e.getVec2(t,{}),{});else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec2(s,i.x,i.y,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec2(s,i.x,i.y,{})}}else if(this.compositionType.getNumberOfComponents()===3){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec3(s,i,0,0,{})}else if(e.compositionType.getNumberOfComponents()===2){let i=e.getVec2(t,{});this.setVec3(s,i.x,i.y,0,{})}else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec3AsVector(s,i,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec3(s,i.x,i.y,i.z,{})}}else if(this.compositionType.getNumberOfComponents()===4){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec4(s,i,0,0,0,{})}else if(e.compositionType.getNumberOfComponents()===2){let i=e.getVec2(t,{});this.setVec4(s,i.x,i.y,0,0,{})}else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec4(s,i.x,i.y,i.z,0,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec4AsVector(s,i,{})}}this.gb=!0,this._b()}addElementFromSameCompositionAccessor(s,e,h,t){let i=t!=null?t:s;this.compositionType.getNumberOfComponents()===1?this.setScalar(s,this.getScalar(s,{})+h*e.getScalar(i,{}),{}):this.compositionType.getNumberOfComponents()===2?this.setVec2AsVector(s,M.add(this.getVec2(s,{}),M.multiply(e.getVec2(i,{}),h)),{}):this.compositionType.getNumberOfComponents()===3?this.setVec3AsVector(s,N.add(this.getVec3(s,{}),N.multiply(e.getVec3(i,{}),h)),{}):this.compositionType.getNumberOfComponents()===4&&this.setVec4AsVector(s,T.add(this.getVec4(s,{}),T.multiply(e.getVec4(i,{}),h)),{}),this.gb=!0,this._b()}get arrayBufferOfBufferView(){return this.Fp}get dataViewOfBufferView(){return this.Sb}get byteOffsetInBufferView(){return this.Ab-this.Bb.byteOffsetInRawArrayBufferOfBuffer}get byteOffsetInBuffer(){return this.Ab-this.Bb.buffer.byteOffsetInRawArrayBuffer}get byteOffsetInRawArrayBufferOfBuffer(){return this.Ab}get bufferView(){return this.Bb}setMinMax(s,e){let h=this.compositionType.getNumberOfComponents();h===1?(this.sy._v[0]=s[0],this.ny._v[0]=e[0]):h===2?(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.ny._v[0]=e[0],this.ny._v[1]=e[1]):h===3?(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.sy._v[2]=s[2],this.ny._v[0]=e[0],this.ny._v[1]=e[1],this.ny._v[2]=e[2]):h===4&&(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.sy._v[2]=s[2],this.sy._v[3]=s[3],this.ny._v[0]=e[0],this.ny._v[1]=e[1],this.ny._v[2]=e[2],this.ny._v[3]=e[3]),this.gb=!1}get min(){this.gb&&this.xb();let s=this.compositionType.getNumberOfComponents();return s===4?[this.sy._v[0],this.sy._v[1],this.sy._v[2],this.sy._v[3]]:s===3?[this.sy._v[0],this.sy._v[1],this.sy._v[2]]:s===2?[this.sy._v[0],this.sy._v[1]]:[this.sy._v[0]]}get max(){this.gb&&this.xb();let s=this.compositionType.getNumberOfComponents();return s===4?[this.ny._v[0],this.ny._v[1],this.ny._v[2],this.ny._v[3]]:s===3?[this.ny._v[0],this.ny._v[1],this.ny._v[2]]:s===2?[this.ny._v[0],this.ny._v[1]]:[this.ny._v[0]]}get normalized(){return this.Nb}xb(){let s=this.compositionType.getNumberOfComponents();if(s===4){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.Zl;for(let h=0;h<this.elementCount;h++){this.getVec4To(h,e,{});for(let t=0;t<4;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===3){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.tr;for(let h=0;h<this.elementCount;h++){this.getVec3To(h,e,{});for(let t=0;t<3;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===2){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.Eb;for(let h=0;h<this.elementCount;h++){this.getVec2To(h,e,{});for(let t=0;t<2;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===1){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let e=0;e<this.elementCount;e++){let h=this.getScalar(e,{});this.ny._v[0]<h&&(this.ny._v[0]=h),h<this.sy._v[0]&&(this.sy._v[0]=h)}}this.gb=!1}get isMinMaxDirty(){return this.gb}get version(){return this.Mb}get actualByteStride(){return this.hb===0?this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()*this.Ib:this.hb}isSame(s){return this.byteLength===s.byteLength&&this.byteOffsetInRawArrayBufferOfBuffer===s.byteOffsetInRawArrayBufferOfBuffer&&this.bufferView.buffer.getArrayBuffer()===s.bufferView.buffer.getArrayBuffer()}};a.Zl=O.zero(),a.tr=X.zero(),a.Eb=L.zero();var U=a;export{U as Accessor};
12
+ `),this.xb()),this.yb=this.vb[this.getDataViewGetter(this.c_)].bind(this.vb),this.gb=this.vb[this.getDataViewSetter(this.c_)].bind(this.vb)}xb(){let s=this.getTypedArrayClass(this.c_),e=this.Fp.slice(this._b,this._b+this.p_.getNumberOfComponents()*this.Ab*s.BYTES_PER_ELEMENT);this.Ob=new s(e)}Sb(){var s;this.Nb++,this._primitive!=null&&((s=this._primitive.deref())==null||s.onAccessorUpdated(this.Nb))}getTypedArrayClass(s){switch(s){case o.Byte:return Int8Array;case o.UnsignedByte:return Uint8Array;case o.Short:return Int16Array;case o.UnsignedShort:return Uint16Array;case o.Int:return Int32Array;case o.UnsignedInt:return Uint32Array;case o.Float:return Float32Array;case o.Double:return Float64Array;default:V.default.error("Unexpected ComponentType!");return}}getDataViewGetter(s){switch(s){case o.Byte:return"getInt8";case o.UnsignedByte:return"getUint8";case o.Short:return"getInt16";case o.UnsignedShort:return"getUint16";case o.Int:return"getInt32";case o.UnsignedInt:return"getUint32";case o.Float:return"getFloat32";case o.Double:return"getFloat64";default:return V.default.error("Unexpected ComponentType!"),"unknown"}}getDataViewSetter(s){switch(s){case o.Byte:return"setInt8";case o.UnsignedByte:return"setUint8";case o.Short:return"setInt16";case o.UnsignedShort:return"setUint16";case o.Int:return"setInt32";case o.UnsignedInt:return"setUint32";case o.Float:return"setFloat32";case o.Double:return"setFloat64";default:V.default.error("Unexpected ComponentType!")}}takeOne(){let s=this.Fp;this.Ib>=this.Ab&&V.default.error("You are trying to allocate more than you have secured.");let e=new this.Mb(s,this._b+this.hb*this.Ib,this.p_.getNumberOfComponents()*this.Bb);return e._accessor=this,e._idx_of_accessor=this.Ib,this.Ib+=1,e}_takeExistedOne(s){let e=this.Fp;s>=this.Ab&&V.default.error("You are trying to allocate more than you have secured.");let h=new this.Mb(e,this._b+this.hb*s,this.p_.getNumberOfComponents()*this.Bb);return h._accessor=this,h._idx_of_accessor=s,h}get takenCount(){return this.Ib}get numberOfComponents(){return this.p_.getNumberOfComponents()}get componentSizeInBytes(){return this.c_.getSizeInBytes()}get elementSizeInBytes(){return this.numberOfComponents*this.componentSizeInBytes}get elementCount(){return this.Ab}get byteLength(){return this.hb*this.Ab}get componentType(){return this.c_}get compositionType(){return this.p_}getTypedArray(){return this.Ob}setTypedArray(s){if(s.buffer!==this.Fp){if(this.p_===g.Scalar)for(let e=0;e<this.Ab;e++)this.setScalar(e,s[e],{endian:!0});else if(this.p_===g.Vec2)for(let e=0;e<this.Ab;e++)this.setVec2(e,s[e*2],s[e*2+1],{endian:!0});else if(this.p_===g.Vec3)for(let e=0;e<this.Ab;e++)this.setVec3(e,s[e*3],s[e*3+1],s[e*3+2],{endian:!0});else if(this.p_===g.Vec4)for(let e=0;e<this.Ab;e++)this.setVec4(e,s[e*4],s[e*4+1],s[e*4+2],s[e*4+3],{endian:!0});else if(this.p_===g.Mat3)for(let e=0;e<this.Ab;e++)this.setMat3(e,s[e*9],s[e*9+1],s[e*9+2],s[e*9+3],s[e*9+4],s[e*9+5],s[e*9+6],s[e*9+7],s[e*9+8],{endian:!0});else if(this.p_===g.Mat4)for(let e=0;e<this.Ab;e++)this.setMat4(e,s[e*16],s[e*16+1],s[e*16+2],s[e*16+3],s[e*16+4],s[e*16+5],s[e*16+6],s[e*16+7],s[e*16+8],s[e*16+9],s[e*16+10],s[e*16+11],s[e*16+12],s[e*16+13],s[e*16+14],s[e*16+15],{endian:!0});else throw new Error("Unexpected CompositionType!");this.xb()}}getUint8Array(){return new Uint8Array(this.bufferView.buffer.getArrayBuffer(),this.byteOffsetInRawArrayBufferOfBuffer,this.byteLength)}get isAoS(){return!this.isSoA}get isSoA(){return this.byteStride===this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()}get byteStride(){return this.hb}getScalar(s,{indicesAccessor:e,endian:h=!0}){let t=s;return e&&(t=e.getScalar(s,{})),this.yb(this.hb*t,h)}getScalarAt(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;return h&&(i=h.getScalar(s,{})),this.yb(this.hb*i+e,t)}getVec2AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h)]}getVec3AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h)]}getVec4AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h)]}getMat3AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h),this.yb(this.hb*t+4*i,h),this.yb(this.hb*t+5*i,h),this.yb(this.hb*t+6*i,h),this.yb(this.hb*t+7*i,h),this.yb(this.hb*t+8*i,h)]}getMat4AsArray(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return[this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h),this.yb(this.hb*t+4*i,h),this.yb(this.hb*t+5*i,h),this.yb(this.hb*t+6*i,h),this.yb(this.hb*t+7*i,h),this.yb(this.hb*t+8*i,h),this.yb(this.hb*t+9*i,h),this.yb(this.hb*t+10*i,h),this.yb(this.hb*t+11*i,h),this.yb(this.hb*t+12*i,h),this.yb(this.hb*t+13*i,h),this.yb(this.hb*t+14*i,h),this.yb(this.hb*t+15*i,h)]}getVec2(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return M.fromCopyArray2([this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h)])}getVec3(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return N.fromCopyArray([this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h)])}getVec4(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return T.fromCopyArray([this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h)])}getMat3(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return z.fromCopy9RowMajor(this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h),this.yb(this.hb*t+4*i,h),this.yb(this.hb*t+5*i,h),this.yb(this.hb*t+6*i,h),this.yb(this.hb*t+7*i,h),this.yb(this.hb*t+8*i,h))}getMat4(s,{indicesAccessor:e,endian:h=!0}){let t=s;e&&(t=e.getScalar(s,{}));let i=this.componentSizeInBytes;return w.fromCopy16RowMajor(this.yb(this.hb*t,h),this.yb(this.hb*t+1*i,h),this.yb(this.hb*t+2*i,h),this.yb(this.hb*t+3*i,h),this.yb(this.hb*t+4*i,h),this.yb(this.hb*t+5*i,h),this.yb(this.hb*t+6*i,h),this.yb(this.hb*t+7*i,h),this.yb(this.hb*t+8*i,h),this.yb(this.hb*t+9*i,h),this.yb(this.hb*t+10*i,h),this.yb(this.hb*t+11*i,h),this.yb(this.hb*t+12*i,h),this.yb(this.hb*t+13*i,h),this.yb(this.hb*t+14*i,h),this.yb(this.hb*t+15*i,h))}getVec2To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.yb(this.hb*i,t),this.yb(this.hb*i+1*r,t))}getVec3To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.yb(this.hb*i,t),this.yb(this.hb*i+1*r,t),this.yb(this.hb*i+2*r,t))}getVec4To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.yb(this.hb*i,t),this.yb(this.hb*i+1*r,t),this.yb(this.hb*i+2*r,t),this.yb(this.hb*i+3*r,t))}getMat3To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.yb(this.hb*i,t),this.yb(this.hb*i+1*r,t),this.yb(this.hb*i+2*r,t),this.yb(this.hb*i+3*r,t),this.yb(this.hb*i+4*r,t),this.yb(this.hb*i+5*r,t),this.yb(this.hb*i+6*r,t),this.yb(this.hb*i+7*r,t),this.yb(this.hb*i+8*r,t))}getMat4To(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;return e.setComponents(this.yb(this.hb*i,t),this.yb(this.hb*i+1*r,t),this.yb(this.hb*i+2*r,t),this.yb(this.hb*i+3*r,t),this.yb(this.hb*i+4*r,t),this.yb(this.hb*i+5*r,t),this.yb(this.hb*i+6*r,t),this.yb(this.hb*i+7*r,t),this.yb(this.hb*i+8*r,t),this.yb(this.hb*i+9*r,t),this.yb(this.hb*i+10*r,t),this.yb(this.hb*i+11*r,t),this.yb(this.hb*i+12*r,t),this.yb(this.hb*i+13*r,t),this.yb(this.hb*i+14*r,t),this.yb(this.hb*i+15*r,t))}setScalar(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{})),this.gb(this.hb*i,e,t),this.Vb=!0,this.Sb()}setVec2(s,e,h,{indicesAccessor:t,endian:i=!0}){let r=s;t&&(r=t.getScalar(s,{}));let c=this.componentSizeInBytes;this.gb(this.hb*r,e,i),this.gb(this.hb*r+1*c,h,i),this.Vb=!0,this.Sb()}setVec3(s,e,h,t,{indicesAccessor:i,endian:r=!0}){let c=s;i&&(c=i.getScalar(s,{}));let u=this.componentSizeInBytes;this.gb(this.hb*c,e,r),this.gb(this.hb*c+1*u,h,r),this.gb(this.hb*c+2*u,t,r),this.Vb=!0,this.Sb()}setVec4(s,e,h,t,i,{indicesAccessor:r,endian:c=!0}){let u=s;r&&(u=r.getScalar(s,{}));let y=this.componentSizeInBytes;this.gb(this.hb*u,e,c),this.gb(this.hb*u+1*y,h,c),this.gb(this.hb*u+2*y,t,c),this.gb(this.hb*u+3*y,i,c),this.Vb=!0,this.Sb()}setMat3(s,e,h,t,i,r,c,u,y,_,{indicesAccessor:A,endian:p=!0}){let b=s;A&&(b=A.getScalar(s,{}));let l=this.componentSizeInBytes;this.gb(this.hb*b,e,p),this.gb(this.hb*b+1*l,h,p),this.gb(this.hb*b+2*l,t,p),this.gb(this.hb*b+3*l,i,p),this.gb(this.hb*b+4*l,r,p),this.gb(this.hb*b+5*l,c,p),this.gb(this.hb*b+6*l,u,p),this.gb(this.hb*b+7*l,y,p),this.gb(this.hb*b+8*l,_,p),this.Vb=!0,this.Sb()}setMat4(s,e,h,t,i,r,c,u,y,_,A,p,b,l,v,I,B,{indicesAccessor:S,endian:f=!0}){let n=s;S&&(n=S.getScalar(s,{}));let m=this.componentSizeInBytes;this.gb(this.hb*n,e,f),this.gb(this.hb*n+1*m,h,f),this.gb(this.hb*n+2*m,t,f),this.gb(this.hb*n+3*m,i,f),this.gb(this.hb*n+4*m,r,f),this.gb(this.hb*n+5*m,c,f),this.gb(this.hb*n+6*m,u,f),this.gb(this.hb*n+7*m,y,f),this.gb(this.hb*n+8*m,_,f),this.gb(this.hb*n+9*m,A,f),this.gb(this.hb*n+10*m,p,f),this.gb(this.hb*n+11*m,b,f),this.gb(this.hb*n+12*m,l,f),this.gb(this.hb*n+13*m,v,f),this.gb(this.hb*n+14*m,I,f),this.gb(this.hb*n+15*m,B,f),this.Vb=!0,this.Sb()}setVec2AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.gb(this.hb*i,e.x,t),this.gb(this.hb*i+1*r,e.y,t),this.Vb=!0,this.Sb()}setVec3AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.gb(this.hb*i,e.x,t),this.gb(this.hb*i+1*r,e.y,t),this.gb(this.hb*i+2*r,e.z,t),this.Vb=!0,this.Sb()}setVec4AsVector(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.gb(this.hb*i,e.x,t),this.gb(this.hb*i+1*r,e.y,t),this.gb(this.hb*i+2*r,e.z,t),this.gb(this.hb*i+3*r,e.w,t),this.Vb=!0,this.Sb()}setMat4AsMatrix44(s,e,{indicesAccessor:h,endian:t=!0}){let i=s;h&&(i=h.getScalar(s,{}));let r=this.componentSizeInBytes;this.gb(this.hb*i,e._v[0],t),this.gb(this.hb*i+1*r,e._v[1],t),this.gb(this.hb*i+2*r,e._v[2],t),this.gb(this.hb*i+3*r,e._v[3],t),this.gb(this.hb*i+4*r,e._v[4],t),this.gb(this.hb*i+5*r,e._v[5],t),this.gb(this.hb*i+6*r,e._v[6],t),this.gb(this.hb*i+7*r,e._v[7],t),this.gb(this.hb*i+8*r,e._v[8],t),this.gb(this.hb*i+9*r,e._v[9],t),this.gb(this.hb*i+10*r,e._v[10],t),this.gb(this.hb*i+11*r,e._v[11],t),this.gb(this.hb*i+12*r,e._v[12],t),this.gb(this.hb*i+13*r,e._v[13],t),this.gb(this.hb*i+14*r,e._v[14],t),this.gb(this.hb*i+15*r,e._v[15],t),this.Vb=!0,this.Sb()}copyFromTypedArray(s){let e=this.numberOfComponents;for(let h=0;h<s.byteLength/this.componentSizeInBytes;h++){let t=Math.floor(h/e),i=t*e;switch(e){case 1:this.setScalar(t,s[i+0],{});break;case 2:this.setVec2(t,s[i+0],s[i+1],{});break;case 3:this.setVec3(t,s[i+0],s[i+1],s[i+2],{});break;case 4:this.setVec4(t,s[i+0],s[i+1],s[i+2],s[i+3],{});break;default:throw new Error("Other than vectors are currently not supported.")}}this.Vb=!0,this.Sb()}setScalarAt(s,e,h,{indicesAccessor:t,endian:i=!0}){let r=s;t&&(r=t.getScalar(s,{})),this.gb(this.hb*r+e,h,i),this.Vb=!0,this.Sb()}setElementFromSameCompositionAccessor(s,e,h){let t=h!=null?h:s;this.compositionType.getNumberOfComponents()===1?this.setScalar(s,e.getScalar(t,{}),{}):this.compositionType.getNumberOfComponents()===2?this.setVec2AsVector(s,e.getVec2(t,{}),{}):this.compositionType.getNumberOfComponents()===3?this.setVec3AsVector(s,e.getVec3(t,{}),{}):this.compositionType.getNumberOfComponents()===4&&this.setVec4AsVector(s,e.getVec4(t,{}),{}),this.Vb=!0,this.Sb()}copyBuffer(s){new Uint8Array(this.Fp).set(new Uint8Array(s.Fp,s._b,s.byteLength),this._b),this.Vb=!0,this.Sb()}setElementFromAccessor(s,e,h){let t=h!=null?h:s;if(this.compositionType.getNumberOfComponents()===1)e.compositionType.getNumberOfComponents()===1?this.setScalar(s,e.getScalar(t,{}),{}):e.compositionType.getNumberOfComponents()===2?this.setScalar(s,e.getVec2(t,{}).x,{}):e.compositionType.getNumberOfComponents()===3?this.setScalar(s,e.getVec3(t,{}).x,{}):e.compositionType.getNumberOfComponents()===4&&this.setScalar(s,e.getVec4(t,{}).x,{});else if(this.compositionType.getNumberOfComponents()===2){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec2(s,i,0,{})}else if(e.compositionType.getNumberOfComponents()===2)this.setVec2AsVector(s,e.getVec2(t,{}),{});else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec2(s,i.x,i.y,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec2(s,i.x,i.y,{})}}else if(this.compositionType.getNumberOfComponents()===3){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec3(s,i,0,0,{})}else if(e.compositionType.getNumberOfComponents()===2){let i=e.getVec2(t,{});this.setVec3(s,i.x,i.y,0,{})}else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec3AsVector(s,i,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec3(s,i.x,i.y,i.z,{})}}else if(this.compositionType.getNumberOfComponents()===4){if(e.compositionType.getNumberOfComponents()===1){let i=e.getScalar(t,{});this.setVec4(s,i,0,0,0,{})}else if(e.compositionType.getNumberOfComponents()===2){let i=e.getVec2(t,{});this.setVec4(s,i.x,i.y,0,0,{})}else if(e.compositionType.getNumberOfComponents()===3){let i=e.getVec3(t,{});this.setVec4(s,i.x,i.y,i.z,0,{})}else if(e.compositionType.getNumberOfComponents()===4){let i=e.getVec4(t,{});this.setVec4AsVector(s,i,{})}}this.Vb=!0,this.Sb()}addElementFromSameCompositionAccessor(s,e,h,t){let i=t!=null?t:s;this.compositionType.getNumberOfComponents()===1?this.setScalar(s,this.getScalar(s,{})+h*e.getScalar(i,{}),{}):this.compositionType.getNumberOfComponents()===2?this.setVec2AsVector(s,M.add(this.getVec2(s,{}),M.multiply(e.getVec2(i,{}),h)),{}):this.compositionType.getNumberOfComponents()===3?this.setVec3AsVector(s,N.add(this.getVec3(s,{}),N.multiply(e.getVec3(i,{}),h)),{}):this.compositionType.getNumberOfComponents()===4&&this.setVec4AsVector(s,T.add(this.getVec4(s,{}),T.multiply(e.getVec4(i,{}),h)),{}),this.Vb=!0,this.Sb()}get arrayBufferOfBufferView(){return this.Fp}get dataViewOfBufferView(){return this.vb}get byteOffsetInBufferView(){return this._b-this.Cb.byteOffsetInRawArrayBufferOfBuffer}get byteOffsetInBuffer(){return this._b-this.Cb.buffer.byteOffsetInRawArrayBuffer}get byteOffsetInRawArrayBufferOfBuffer(){return this._b}get bufferView(){return this.Cb}setMinMax(s,e){let h=this.compositionType.getNumberOfComponents();h===1?(this.sy._v[0]=s[0],this.ny._v[0]=e[0]):h===2?(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.ny._v[0]=e[0],this.ny._v[1]=e[1]):h===3?(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.sy._v[2]=s[2],this.ny._v[0]=e[0],this.ny._v[1]=e[1],this.ny._v[2]=e[2]):h===4&&(this.sy._v[0]=s[0],this.sy._v[1]=s[1],this.sy._v[2]=s[2],this.sy._v[3]=s[3],this.ny._v[0]=e[0],this.ny._v[1]=e[1],this.ny._v[2]=e[2],this.ny._v[3]=e[3]),this.Vb=!1}get min(){this.Vb&&this.Eb();let s=this.compositionType.getNumberOfComponents();return s===4?[this.sy._v[0],this.sy._v[1],this.sy._v[2],this.sy._v[3]]:s===3?[this.sy._v[0],this.sy._v[1],this.sy._v[2]]:s===2?[this.sy._v[0],this.sy._v[1]]:[this.sy._v[0]]}get max(){this.Vb&&this.Eb();let s=this.compositionType.getNumberOfComponents();return s===4?[this.ny._v[0],this.ny._v[1],this.ny._v[2],this.ny._v[3]]:s===3?[this.ny._v[0],this.ny._v[1],this.ny._v[2]]:s===2?[this.ny._v[0],this.ny._v[1]]:[this.ny._v[0]]}get normalized(){return this.Tb}Eb(){let s=this.compositionType.getNumberOfComponents();if(s===4){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.Zl;for(let h=0;h<this.elementCount;h++){this.getVec4To(h,e,{});for(let t=0;t<4;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===3){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.tr;for(let h=0;h<this.elementCount;h++){this.getVec3To(h,e,{});for(let t=0;t<3;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===2){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);let e=a.Ub;for(let h=0;h<this.elementCount;h++){this.getVec2To(h,e,{});for(let t=0;t<2;t++)this.ny._v[t]<e._v[t]&&(this.ny._v[t]=e._v[t]),e._v[t]<this.sy._v[t]&&(this.sy._v[t]=e._v[t])}}else if(s===1){this.ny.setComponents(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),this.sy.setComponents(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE);for(let e=0;e<this.elementCount;e++){let h=this.getScalar(e,{});this.ny._v[0]<h&&(this.ny._v[0]=h),h<this.sy._v[0]&&(this.sy._v[0]=h)}}this.Vb=!1}get isMinMaxDirty(){return this.Vb}get version(){return this.Nb}get actualByteStride(){return this.hb===0?this.p_.getNumberOfComponents()*this.c_.getSizeInBytes()*this.Bb:this.hb}isSame(s){return this.byteLength===s.byteLength&&this.byteOffsetInRawArrayBufferOfBuffer===s.byteOffsetInRawArrayBufferOfBuffer&&this.bufferView.buffer.getArrayBuffer()===s.bufferView.buffer.getArrayBuffer()}};a.Zl=O.zero(),a.tr=X.zero(),a.Ub=L.zero();var U=a;export{U as Accessor};
@@ -1,4 +1,4 @@
1
- import{Err as h,Ok as m}from"../misc/index.js";import{Accessor as p}from"./Accessor.js";var c=class{constructor({buffer:e,byteOffsetInBuffer:n,defaultByteStride:t,byteLength:r,raw:s}){this.Oy=0;this.Ay=0;this.Ry=0;this.mf=[];this.Cy=e,this.Ly=n,this.Ab=e.byteOffsetInRawArrayBuffer+n,this.gy=r,this.Oy=t,this.Fp=s}get defaultByteStride(){return this.Oy}get byteLength(){return this.gy}get byteOffsetInBuffer(){return this.Ab-this.Cy.byteOffsetInRawArrayBuffer}get byteOffsetInRawArrayBufferOfBuffer(){return this.Ab}get buffer(){return this.Cy}get isSoA(){return!this.isAoS}get isAoS(){for(let e of this.mf)if(e.isAoS)return!0;return!1}getUint8Array(){return new Uint8Array(this.Fp,this.Ab,this.gy)}takeAccessor({compositionType:e,componentType:n,count:t,byteStride:r=this.defaultByteStride,max:s,min:f,arrayLength:i=1,normalized:o=!1}){return this.$y({compositionType:e,componentType:n,count:t,byteStride:r,max:s,min:f,normalized:o,arrayLength:i})}takeAccessorWithByteOffset({compositionType:e,componentType:n,count:t,byteOffsetInBufferView:r,byteStride:s=this.defaultByteStride,max:f,min:i,normalized:o=!1}){return this.Ey({compositionType:e,componentType:n,count:t,byteStride:s,byteOffsetInBufferView:r,max:f,min:i,normalized:o})}$y({compositionType:e,componentType:n,count:t,byteStride:r,max:s,min:f,arrayLength:i,normalized:o}){let u=this.Ay,y=r;if(y===0&&(y=e.getNumberOfComponents()*n.getSizeInBytes()*i),this.Ay+y*(t-1)+n.getSizeInBytes()*e.getNumberOfComponents()>this.byteLength){let B=`The size of the Accessor you are trying to take exceeds the byte length left in the BufferView.
1
+ import{Err as h,Ok as m}from"../misc/index.js";import{Accessor as p}from"./Accessor.js";var c=class{constructor({buffer:e,byteOffsetInBuffer:n,defaultByteStride:t,byteLength:r,raw:s}){this.Oy=0;this.Ay=0;this.Ry=0;this.mf=[];this.Cy=e,this.Ly=n,this._b=e.byteOffsetInRawArrayBuffer+n,this.gy=r,this.Oy=t,this.Fp=s}get defaultByteStride(){return this.Oy}get byteLength(){return this.gy}get byteOffsetInBuffer(){return this._b-this.Cy.byteOffsetInRawArrayBuffer}get byteOffsetInRawArrayBufferOfBuffer(){return this._b}get buffer(){return this.Cy}get isSoA(){return!this.isAoS}get isAoS(){for(let e of this.mf)if(e.isAoS)return!0;return!1}getUint8Array(){return new Uint8Array(this.Fp,this._b,this.gy)}takeAccessor({compositionType:e,componentType:n,count:t,byteStride:r=this.defaultByteStride,max:s,min:f,arrayLength:i=1,normalized:o=!1}){return this.$y({compositionType:e,componentType:n,count:t,byteStride:r,max:s,min:f,normalized:o,arrayLength:i})}takeAccessorWithByteOffset({compositionType:e,componentType:n,count:t,byteOffsetInBufferView:r,byteStride:s=this.defaultByteStride,max:f,min:i,normalized:o=!1}){return this.Ey({compositionType:e,componentType:n,count:t,byteStride:s,byteOffsetInBufferView:r,max:f,min:i,normalized:o})}$y({compositionType:e,componentType:n,count:t,byteStride:r,max:s,min:f,arrayLength:i,normalized:o}){let u=this.Ay,y=r;if(y===0&&(y=e.getNumberOfComponents()*n.getSizeInBytes()*i),this.Ay+y*(t-1)+n.getSizeInBytes()*e.getNumberOfComponents()>this.byteLength){let B=`The size of the Accessor you are trying to take exceeds the byte length left in the BufferView.
2
2
  BufferView.byteLength: ${this.byteLength}, BufferView.takenSizeInByte: ${this.Ay}, Accessor.byteStride: ${r}, Accessor.count: ${t};
3
3
  byteSizeToTake: ${y*t}, the byte length left in the Buffer: ${this.byteLength-this.Ay}`;return new h({message:B,error:void 0})}let a=new p({bufferView:this,byteOffsetInBufferView:u,compositionType:e,componentType:n,byteStride:r,count:t,raw:this.Fp,max:s,min:f,arrayLength:i,normalized:o});return this.mf.push(a),this.Ay+=y*t,new m(a)}Ey({compositionType:e,componentType:n,count:t,byteStride:r,byteOffsetInBufferView:s,max:f,min:i,normalized:o}){if(this.Ay+r*(t-1)+n.getSizeInBytes()*e.getNumberOfComponents()>this.byteLength){let y=`The size of the Accessor you are trying to take exceeds the byte length left in the BufferView.
4
4
  BufferView.byteLength: ${this.byteLength}, BufferView.takenSizeInByte: ${this.Ay}, Accessor.byteStride: ${r}, Accessor.count: ${t};