@zephyr3d/scene 0.9.4 → 0.9.6

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 (517) hide show
  1. package/dist/animation/animationmask.js +224 -0
  2. package/dist/animation/animationmask.js.map +1 -0
  3. package/dist/animation/animationset.js +268 -67
  4. package/dist/animation/animationset.js.map +1 -1
  5. package/dist/animation/animationtrack.js.map +1 -1
  6. package/dist/animation/eulerrotationtrack.js +3 -0
  7. package/dist/animation/eulerrotationtrack.js.map +1 -1
  8. package/dist/animation/fixed_geometry_cache_track.js +7 -0
  9. package/dist/animation/fixed_geometry_cache_track.js.map +1 -1
  10. package/dist/animation/ik_modifier.js.map +1 -1
  11. package/dist/animation/joint_dynamics/collision.js +6 -4
  12. package/dist/animation/joint_dynamics/collision.js.map +1 -1
  13. package/dist/animation/joint_dynamics/controller.js +390 -43
  14. package/dist/animation/joint_dynamics/controller.js.map +1 -1
  15. package/dist/animation/joint_dynamics/joint_dynamics_system.js +62 -3
  16. package/dist/animation/joint_dynamics/joint_dynamics_system.js.map +1 -1
  17. package/dist/animation/joint_dynamics/solver.js +4 -3
  18. package/dist/animation/joint_dynamics/solver.js.map +1 -1
  19. package/dist/animation/joint_dynamics/types.js.map +1 -1
  20. package/dist/animation/joint_dynamics_modifier.js +2 -0
  21. package/dist/animation/joint_dynamics_modifier.js.map +1 -1
  22. package/dist/animation/morphtarget.js +3 -72
  23. package/dist/animation/morphtarget.js.map +1 -1
  24. package/dist/animation/morphtrack.js +3 -0
  25. package/dist/animation/morphtrack.js.map +1 -1
  26. package/dist/animation/pca_geometry_cache_track.js +3 -0
  27. package/dist/animation/pca_geometry_cache_track.js.map +1 -1
  28. package/dist/animation/proptrack.js +3 -0
  29. package/dist/animation/proptrack.js.map +1 -1
  30. package/dist/animation/rotationtrack.js +3 -0
  31. package/dist/animation/rotationtrack.js.map +1 -1
  32. package/dist/animation/scaletrack.js +3 -0
  33. package/dist/animation/scaletrack.js.map +1 -1
  34. package/dist/animation/skeleton.js +254 -79
  35. package/dist/animation/skeleton.js.map +1 -1
  36. package/dist/animation/skeleton_modifier.js.map +1 -1
  37. package/dist/animation/spring_modifier.js.map +1 -1
  38. package/dist/animation/translationtrack.js +3 -0
  39. package/dist/animation/translationtrack.js.map +1 -1
  40. package/dist/app/engine.js +171 -107
  41. package/dist/app/engine.js.map +1 -1
  42. package/dist/app/scriptregistry.js +251 -80
  43. package/dist/app/scriptregistry.js.map +1 -1
  44. package/dist/asset/assetmanager.js +344 -365
  45. package/dist/asset/assetmanager.js.map +1 -1
  46. package/dist/asset/loaders/loader.js +1 -6
  47. package/dist/asset/loaders/loader.js.map +1 -1
  48. package/dist/asset/loaders/zabc/zabc_loader.js.map +1 -1
  49. package/dist/asset/model.js +1000 -131
  50. package/dist/asset/model.js.map +1 -1
  51. package/dist/avatar/wardrobe.js +474 -0
  52. package/dist/avatar/wardrobe.js.map +1 -0
  53. package/dist/index.d.ts +1126 -199
  54. package/dist/index.js +3 -2
  55. package/dist/index.js.map +1 -1
  56. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js +6 -3
  57. package/dist/material/mixins/lightmodel/pbrmetallicroughness.js.map +1 -1
  58. package/dist/material/mixins/pbr/common.js +72 -15
  59. package/dist/material/mixins/pbr/common.js.map +1 -1
  60. package/dist/material/msdf_text.js +3 -3
  61. package/dist/material/msdf_text.js.map +1 -1
  62. package/dist/material/msdf_text_sprite.js +4 -4
  63. package/dist/material/msdf_text_sprite.js.map +1 -1
  64. package/dist/material/pbrblueprint.js +102 -102
  65. package/dist/material/pbrblueprint.js.map +1 -1
  66. package/dist/render/envlight.js +54 -1
  67. package/dist/render/envlight.js.map +1 -1
  68. package/dist/render/sky.js +9 -0
  69. package/dist/render/sky.js.map +1 -1
  70. package/dist/scene/batchgroup.js +11 -13
  71. package/dist/scene/batchgroup.js.map +1 -1
  72. package/dist/scene/environment.js +15 -2
  73. package/dist/scene/environment.js.map +1 -1
  74. package/dist/scene/mesh.js +79 -16
  75. package/dist/scene/mesh.js.map +1 -1
  76. package/dist/scene/scene.js +1 -0
  77. package/dist/scene/scene.js.map +1 -1
  78. package/dist/scene/scene_node.js +203 -2
  79. package/dist/scene/scene_node.js.map +1 -1
  80. package/dist/text/font/cff_font.js +890 -0
  81. package/dist/text/font/cff_font.js.map +1 -0
  82. package/dist/text/font/font_asset.js +17 -3
  83. package/dist/text/font/font_asset.js.map +1 -1
  84. package/dist/text/msdf/generator.js.map +1 -1
  85. package/dist/text/msdf/shape.js +4 -1
  86. package/dist/text/msdf/shape.js.map +1 -1
  87. package/dist/text/runtime/msdf_text_atlas_manager.js +4 -1
  88. package/dist/text/runtime/msdf_text_atlas_manager.js.map +1 -1
  89. package/dist/utility/blueprint/material/inputs.js +1157 -1154
  90. package/dist/utility/blueprint/material/inputs.js.map +1 -1
  91. package/dist/utility/bounding_volume.js.map +1 -1
  92. package/dist/utility/pmrem.js +34 -8
  93. package/dist/utility/pmrem.js.map +1 -1
  94. package/dist/utility/serialization/manager.js +22 -9
  95. package/dist/utility/serialization/manager.js.map +1 -1
  96. package/dist/utility/serialization/scene/animation.js +700 -7
  97. package/dist/utility/serialization/scene/animation.js.map +1 -1
  98. package/dist/utility/serialization/scene/mesh.js +64 -4
  99. package/dist/utility/serialization/scene/mesh.js.map +1 -1
  100. package/dist/utility/serialization/scene/node.js +187 -8
  101. package/dist/utility/serialization/scene/node.js.map +1 -1
  102. package/dist/utility/serialization/types.js.map +1 -1
  103. package/dist/utility/textures/sheenlut.js +138 -0
  104. package/dist/utility/textures/sheenlut.js.map +1 -0
  105. package/package.json +2 -2
  106. package/dist/animation/ik/ik_chain_builder.js +0 -68
  107. package/dist/animation/ik/ik_chain_builder.js.map +0 -1
  108. package/dist/animation/ik/ik_pole_constraint.js +0 -123
  109. package/dist/animation/ik/ik_pole_constraint.js.map +0 -1
  110. package/dist/animation/ik/ik_track.js +0 -96
  111. package/dist/animation/ik/ik_track.js.map +0 -1
  112. package/dist/animation/ik_postprocessor.js +0 -71
  113. package/dist/animation/ik_postprocessor.js.map +0 -1
  114. package/dist/animation/joint_dynamics/math.js +0 -16
  115. package/dist/animation/joint_dynamics/math.js.map +0 -1
  116. package/dist/animation/manual_transform_processor.js +0 -156
  117. package/dist/animation/manual_transform_processor.js.map +0 -1
  118. package/dist/animation/skeleton_postprocessor.js +0 -50
  119. package/dist/animation/skeleton_postprocessor.js.map +0 -1
  120. package/dist/animation/spring2/collision.js +0 -469
  121. package/dist/animation/spring2/collision.js.map +0 -1
  122. package/dist/animation/spring2/constraints.js +0 -329
  123. package/dist/animation/spring2/constraints.js.map +0 -1
  124. package/dist/animation/spring2/controller.js +0 -434
  125. package/dist/animation/spring2/controller.js.map +0 -1
  126. package/dist/animation/spring2/math.js +0 -16
  127. package/dist/animation/spring2/math.js.map +0 -1
  128. package/dist/animation/spring2/solver.js +0 -624
  129. package/dist/animation/spring2/solver.js.map +0 -1
  130. package/dist/animation/spring2/spring_system.js +0 -118
  131. package/dist/animation/spring2/spring_system.js.map +0 -1
  132. package/dist/animation/spring2/types.js +0 -19
  133. package/dist/animation/spring2/types.js.map +0 -1
  134. package/dist/animation/spring_postprocessor.js +0 -54
  135. package/dist/animation/spring_postprocessor.js.map +0 -1
  136. package/dist/asset/loaders/gltf/gltf_loader.js +0 -1273
  137. package/dist/asset/loaders/gltf/gltf_loader.js.map +0 -1
  138. package/dist/asset/loaders/gltf/helpers.js +0 -331
  139. package/dist/asset/loaders/gltf/helpers.js.map +0 -1
  140. package/dist/material/sprite3d.js +0 -301
  141. package/dist/material/sprite3d.js.map +0 -1
  142. package/dist/material/sprite3d_std.js +0 -116
  143. package/dist/material/sprite3d_std.js.map +0 -1
  144. package/dist/material/sprite3dblueprint.js +0 -235
  145. package/dist/material/sprite3dblueprint.js.map +0 -1
  146. package/dist/material/sprite_sdf.js +0 -106
  147. package/dist/material/sprite_sdf.js.map +0 -1
  148. package/dist/material/terrainmaterial.js +0 -368
  149. package/dist/material/terrainmaterial.js.map +0 -1
  150. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js +0 -38
  151. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimemgr.js.map +0 -1
  152. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js +0 -10
  153. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/runtimescript.js.map +0 -1
  154. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js +0 -127
  155. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptingsystem.js.map +0 -1
  156. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js +0 -263
  157. package/dist/node_modules/@zephyr3d/runtime/dist/runtime/scriptregistry.js.map +0 -1
  158. package/dist/render/deferredlightpass.js +0 -510
  159. package/dist/render/deferredlightpass.js.map +0 -1
  160. package/dist/render/deferredshadowlightpass.js +0 -428
  161. package/dist/render/deferredshadowlightpass.js.map +0 -1
  162. package/dist/render/gbufferpass.js +0 -50
  163. package/dist/render/gbufferpass.js.map +0 -1
  164. package/dist/scene/sdftextsprite.js +0 -322
  165. package/dist/scene/sdftextsprite.js.map +0 -1
  166. package/dist/scene/sprite3d.js +0 -18
  167. package/dist/scene/sprite3d.js.map +0 -1
  168. package/dist/scene/terrain/grass.js +0 -280
  169. package/dist/scene/terrain/grass.js.map +0 -1
  170. package/dist/scene/terrain/heightfield.js +0 -475
  171. package/dist/scene/terrain/heightfield.js.map +0 -1
  172. package/dist/scene/terrain/patch.js +0 -532
  173. package/dist/scene/terrain/patch.js.map +0 -1
  174. package/dist/scene/terrain/quadtree.js +0 -461
  175. package/dist/scene/terrain/quadtree.js.map +0 -1
  176. package/dist/scene/terrain/terrain.js +0 -231
  177. package/dist/scene/terrain/terrain.js.map +0 -1
  178. package/dist/src/animation/animation.js +0 -127
  179. package/dist/src/animation/animation.js.map +0 -1
  180. package/dist/src/animation/animationset.js +0 -255
  181. package/dist/src/animation/animationset.js.map +0 -1
  182. package/dist/src/animation/animationtrack.js +0 -34
  183. package/dist/src/animation/animationtrack.js.map +0 -1
  184. package/dist/src/animation/eulerrotationtrack.js +0 -52
  185. package/dist/src/animation/eulerrotationtrack.js.map +0 -1
  186. package/dist/src/animation/morphtarget.js +0 -93
  187. package/dist/src/animation/morphtarget.js.map +0 -1
  188. package/dist/src/animation/morphtrack.js +0 -70
  189. package/dist/src/animation/morphtrack.js.map +0 -1
  190. package/dist/src/animation/proptrack.js +0 -161
  191. package/dist/src/animation/proptrack.js.map +0 -1
  192. package/dist/src/animation/rotationtrack.js +0 -51
  193. package/dist/src/animation/rotationtrack.js.map +0 -1
  194. package/dist/src/animation/scaletrack.js +0 -50
  195. package/dist/src/animation/scaletrack.js.map +0 -1
  196. package/dist/src/animation/skeleton.js +0 -204
  197. package/dist/src/animation/skeleton.js.map +0 -1
  198. package/dist/src/animation/translationtrack.js +0 -50
  199. package/dist/src/animation/translationtrack.js.map +0 -1
  200. package/dist/src/app/app.js +0 -129
  201. package/dist/src/app/app.js.map +0 -1
  202. package/dist/src/app/inputmgr.js +0 -267
  203. package/dist/src/app/inputmgr.js.map +0 -1
  204. package/dist/src/asset/assetmanager.js +0 -404
  205. package/dist/src/asset/assetmanager.js.map +0 -1
  206. package/dist/src/asset/builtin.js +0 -337
  207. package/dist/src/asset/builtin.js.map +0 -1
  208. package/dist/src/asset/loaders/dds/dds.js +0 -470
  209. package/dist/src/asset/loaders/dds/dds.js.map +0 -1
  210. package/dist/src/asset/loaders/dds/dds_loader.js +0 -28
  211. package/dist/src/asset/loaders/dds/dds_loader.js.map +0 -1
  212. package/dist/src/asset/loaders/gltf/gltf_loader.js +0 -1265
  213. package/dist/src/asset/loaders/gltf/gltf_loader.js.map +0 -1
  214. package/dist/src/asset/loaders/gltf/helpers.js +0 -327
  215. package/dist/src/asset/loaders/gltf/helpers.js.map +0 -1
  216. package/dist/src/asset/loaders/hdr/hdr.js +0 -180
  217. package/dist/src/asset/loaders/hdr/hdr.js.map +0 -1
  218. package/dist/src/asset/loaders/image/tga_Loader.js +0 -116
  219. package/dist/src/asset/loaders/image/tga_Loader.js.map +0 -1
  220. package/dist/src/asset/loaders/image/webimage_loader.js +0 -63
  221. package/dist/src/asset/loaders/image/webimage_loader.js.map +0 -1
  222. package/dist/src/asset/loaders/loader.js +0 -45
  223. package/dist/src/asset/loaders/loader.js.map +0 -1
  224. package/dist/src/asset/model.js +0 -414
  225. package/dist/src/asset/model.js.map +0 -1
  226. package/dist/src/blitter/bilateralblur.js +0 -221
  227. package/dist/src/blitter/bilateralblur.js.map +0 -1
  228. package/dist/src/blitter/blitter.js +0 -390
  229. package/dist/src/blitter/blitter.js.map +0 -1
  230. package/dist/src/blitter/box.js +0 -118
  231. package/dist/src/blitter/box.js.map +0 -1
  232. package/dist/src/blitter/copy.js +0 -22
  233. package/dist/src/blitter/copy.js.map +0 -1
  234. package/dist/src/blitter/gaussianblur.js +0 -228
  235. package/dist/src/blitter/gaussianblur.js.map +0 -1
  236. package/dist/src/camera/base.js +0 -92
  237. package/dist/src/camera/base.js.map +0 -1
  238. package/dist/src/camera/camera.js +0 -1005
  239. package/dist/src/camera/camera.js.map +0 -1
  240. package/dist/src/camera/fps.js +0 -238
  241. package/dist/src/camera/fps.js.map +0 -1
  242. package/dist/src/camera/orbit.js +0 -245
  243. package/dist/src/camera/orbit.js.map +0 -1
  244. package/dist/src/camera/orthocamera.js +0 -167
  245. package/dist/src/camera/orthocamera.js.map +0 -1
  246. package/dist/src/camera/perspectivecamera.js +0 -141
  247. package/dist/src/camera/perspectivecamera.js.map +0 -1
  248. package/dist/src/index.js +0 -120
  249. package/dist/src/index.js.map +0 -1
  250. package/dist/src/material/blinn.js +0 -81
  251. package/dist/src/material/blinn.js.map +0 -1
  252. package/dist/src/material/grassmaterial.js +0 -113
  253. package/dist/src/material/grassmaterial.js.map +0 -1
  254. package/dist/src/material/lambert.js +0 -92
  255. package/dist/src/material/lambert.js.map +0 -1
  256. package/dist/src/material/material.js +0 -301
  257. package/dist/src/material/material.js.map +0 -1
  258. package/dist/src/material/meshmaterial.js +0 -704
  259. package/dist/src/material/meshmaterial.js.map +0 -1
  260. package/dist/src/material/mixins/albedocolor.js +0 -76
  261. package/dist/src/material/mixins/albedocolor.js.map +0 -1
  262. package/dist/src/material/mixins/foliage.js +0 -47
  263. package/dist/src/material/mixins/foliage.js.map +0 -1
  264. package/dist/src/material/mixins/lightmodel/blinnphong.js +0 -112
  265. package/dist/src/material/mixins/lightmodel/blinnphong.js.map +0 -1
  266. package/dist/src/material/mixins/lightmodel/lambert.js +0 -58
  267. package/dist/src/material/mixins/lightmodel/lambert.js.map +0 -1
  268. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js +0 -178
  269. package/dist/src/material/mixins/lightmodel/pbrmetallicroughness.js.map +0 -1
  270. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js +0 -139
  271. package/dist/src/material/mixins/lightmodel/pbrspecularglossness.js.map +0 -1
  272. package/dist/src/material/mixins/lit.js +0 -476
  273. package/dist/src/material/mixins/lit.js.map +0 -1
  274. package/dist/src/material/mixins/pbr/common.js +0 -918
  275. package/dist/src/material/mixins/pbr/common.js.map +0 -1
  276. package/dist/src/material/mixins/texture.js +0 -172
  277. package/dist/src/material/mixins/texture.js.map +0 -1
  278. package/dist/src/material/mixins/vertexcolor.js +0 -56
  279. package/dist/src/material/mixins/vertexcolor.js.map +0 -1
  280. package/dist/src/material/particle.js +0 -178
  281. package/dist/src/material/particle.js.map +0 -1
  282. package/dist/src/material/pbrmr.js +0 -97
  283. package/dist/src/material/pbrmr.js.map +0 -1
  284. package/dist/src/material/pbrsg.js +0 -97
  285. package/dist/src/material/pbrsg.js.map +0 -1
  286. package/dist/src/material/shader/helper.js +0 -1209
  287. package/dist/src/material/shader/helper.js.map +0 -1
  288. package/dist/src/material/terrain-cm.js +0 -606
  289. package/dist/src/material/terrain-cm.js.map +0 -1
  290. package/dist/src/material/terrainmaterial.js +0 -375
  291. package/dist/src/material/terrainmaterial.js.map +0 -1
  292. package/dist/src/material/unlit.js +0 -41
  293. package/dist/src/material/unlit.js.map +0 -1
  294. package/dist/src/material/water.js +0 -417
  295. package/dist/src/material/water.js.map +0 -1
  296. package/dist/src/posteffect/bloom.js +0 -361
  297. package/dist/src/posteffect/bloom.js.map +0 -1
  298. package/dist/src/posteffect/compositor.js +0 -226
  299. package/dist/src/posteffect/compositor.js.map +0 -1
  300. package/dist/src/posteffect/fxaa.js +0 -273
  301. package/dist/src/posteffect/fxaa.js.map +0 -1
  302. package/dist/src/posteffect/grayscale.js +0 -69
  303. package/dist/src/posteffect/grayscale.js.map +0 -1
  304. package/dist/src/posteffect/motionblur.js +0 -96
  305. package/dist/src/posteffect/motionblur.js.map +0 -1
  306. package/dist/src/posteffect/posteffect.js +0 -126
  307. package/dist/src/posteffect/posteffect.js.map +0 -1
  308. package/dist/src/posteffect/sao.js +0 -324
  309. package/dist/src/posteffect/sao.js.map +0 -1
  310. package/dist/src/posteffect/ssr.js +0 -489
  311. package/dist/src/posteffect/ssr.js.map +0 -1
  312. package/dist/src/posteffect/taa.js +0 -172
  313. package/dist/src/posteffect/taa.js.map +0 -1
  314. package/dist/src/posteffect/tonemap.js +0 -94
  315. package/dist/src/posteffect/tonemap.js.map +0 -1
  316. package/dist/src/render/abuffer_oit.js +0 -361
  317. package/dist/src/render/abuffer_oit.js.map +0 -1
  318. package/dist/src/render/clipmap.js +0 -851
  319. package/dist/src/render/clipmap.js.map +0 -1
  320. package/dist/src/render/cluster_light.js +0 -333
  321. package/dist/src/render/cluster_light.js.map +0 -1
  322. package/dist/src/render/cull_visitor.js +0 -187
  323. package/dist/src/render/cull_visitor.js.map +0 -1
  324. package/dist/src/render/depthpass.js +0 -68
  325. package/dist/src/render/depthpass.js.map +0 -1
  326. package/dist/src/render/drawable_mixin.js +0 -227
  327. package/dist/src/render/drawable_mixin.js.map +0 -1
  328. package/dist/src/render/envlight.js +0 -463
  329. package/dist/src/render/envlight.js.map +0 -1
  330. package/dist/src/render/fbm_wavegenerator.js +0 -251
  331. package/dist/src/render/fbm_wavegenerator.js.map +0 -1
  332. package/dist/src/render/fft_wavegenerator.js +0 -1006
  333. package/dist/src/render/fft_wavegenerator.js.map +0 -1
  334. package/dist/src/render/fullscreenquad.js +0 -38
  335. package/dist/src/render/fullscreenquad.js.map +0 -1
  336. package/dist/src/render/gerstner_wavegenerator.js +0 -314
  337. package/dist/src/render/gerstner_wavegenerator.js.map +0 -1
  338. package/dist/src/render/globalbindgroup_allocator.js +0 -60
  339. package/dist/src/render/globalbindgroup_allocator.js.map +0 -1
  340. package/dist/src/render/hzb.js +0 -273
  341. package/dist/src/render/hzb.js.map +0 -1
  342. package/dist/src/render/lightpass.js +0 -172
  343. package/dist/src/render/lightpass.js.map +0 -1
  344. package/dist/src/render/objectcolorpass.js +0 -51
  345. package/dist/src/render/objectcolorpass.js.map +0 -1
  346. package/dist/src/render/primitive.js +0 -364
  347. package/dist/src/render/primitive.js.map +0 -1
  348. package/dist/src/render/render_queue.js +0 -467
  349. package/dist/src/render/render_queue.js.map +0 -1
  350. package/dist/src/render/renderbundle_wrapper.js +0 -152
  351. package/dist/src/render/renderbundle_wrapper.js.map +0 -1
  352. package/dist/src/render/renderer.js +0 -455
  353. package/dist/src/render/renderer.js.map +0 -1
  354. package/dist/src/render/renderpass.js +0 -200
  355. package/dist/src/render/renderpass.js.map +0 -1
  356. package/dist/src/render/shadowmap_pass.js +0 -56
  357. package/dist/src/render/shadowmap_pass.js.map +0 -1
  358. package/dist/src/render/sky.js +0 -1103
  359. package/dist/src/render/sky.js.map +0 -1
  360. package/dist/src/render/weightedblended_oit.js +0 -168
  361. package/dist/src/render/weightedblended_oit.js.map +0 -1
  362. package/dist/src/scene/batchgroup.js +0 -162
  363. package/dist/src/scene/batchgroup.js.map +0 -1
  364. package/dist/src/scene/environment.js +0 -209
  365. package/dist/src/scene/environment.js.map +0 -1
  366. package/dist/src/scene/graph_node.js +0 -72
  367. package/dist/src/scene/graph_node.js.map +0 -1
  368. package/dist/src/scene/light.js +0 -416
  369. package/dist/src/scene/light.js.map +0 -1
  370. package/dist/src/scene/mesh.js +0 -341
  371. package/dist/src/scene/mesh.js.map +0 -1
  372. package/dist/src/scene/octree.js +0 -649
  373. package/dist/src/scene/octree.js.map +0 -1
  374. package/dist/src/scene/particlesys.js +0 -738
  375. package/dist/src/scene/particlesys.js.map +0 -1
  376. package/dist/src/scene/raycast_visitor.js +0 -103
  377. package/dist/src/scene/raycast_visitor.js.map +0 -1
  378. package/dist/src/scene/scene.js +0 -284
  379. package/dist/src/scene/scene.js.map +0 -1
  380. package/dist/src/scene/scene_node.js +0 -732
  381. package/dist/src/scene/scene_node.js.map +0 -1
  382. package/dist/src/scene/terrain/grass.js +0 -278
  383. package/dist/src/scene/terrain/grass.js.map +0 -1
  384. package/dist/src/scene/terrain/heightfield.js +0 -475
  385. package/dist/src/scene/terrain/heightfield.js.map +0 -1
  386. package/dist/src/scene/terrain/patch.js +0 -530
  387. package/dist/src/scene/terrain/patch.js.map +0 -1
  388. package/dist/src/scene/terrain/quadtree.js +0 -461
  389. package/dist/src/scene/terrain/quadtree.js.map +0 -1
  390. package/dist/src/scene/terrain/terrain.js +0 -246
  391. package/dist/src/scene/terrain/terrain.js.map +0 -1
  392. package/dist/src/scene/terrain-cm/grass.js +0 -594
  393. package/dist/src/scene/terrain-cm/grass.js.map +0 -1
  394. package/dist/src/scene/terrain-cm/grassmaterial.js +0 -159
  395. package/dist/src/scene/terrain-cm/grassmaterial.js.map +0 -1
  396. package/dist/src/scene/terrain-cm/terrain-cm.js +0 -538
  397. package/dist/src/scene/terrain-cm/terrain-cm.js.map +0 -1
  398. package/dist/src/scene/water.js +0 -374
  399. package/dist/src/scene/water.js.map +0 -1
  400. package/dist/src/shaders/atmosphere.js +0 -957
  401. package/dist/src/shaders/atmosphere.js.map +0 -1
  402. package/dist/src/shaders/fog.js +0 -112
  403. package/dist/src/shaders/fog.js.map +0 -1
  404. package/dist/src/shaders/misc.js +0 -266
  405. package/dist/src/shaders/misc.js.map +0 -1
  406. package/dist/src/shaders/noise.js +0 -222
  407. package/dist/src/shaders/noise.js.map +0 -1
  408. package/dist/src/shaders/pbr.js +0 -51
  409. package/dist/src/shaders/pbr.js.map +0 -1
  410. package/dist/src/shaders/shadow.js +0 -636
  411. package/dist/src/shaders/shadow.js.map +0 -1
  412. package/dist/src/shaders/ssr.js +0 -490
  413. package/dist/src/shaders/ssr.js.map +0 -1
  414. package/dist/src/shaders/temporal.js +0 -215
  415. package/dist/src/shaders/temporal.js.map +0 -1
  416. package/dist/src/shaders/water.js +0 -756
  417. package/dist/src/shaders/water.js.map +0 -1
  418. package/dist/src/shadow/esm.js +0 -237
  419. package/dist/src/shadow/esm.js.map +0 -1
  420. package/dist/src/shadow/pcf_opt.js +0 -181
  421. package/dist/src/shadow/pcf_opt.js.map +0 -1
  422. package/dist/src/shadow/pcf_pd.js +0 -189
  423. package/dist/src/shadow/pcf_pd.js.map +0 -1
  424. package/dist/src/shadow/shader.js +0 -37
  425. package/dist/src/shadow/shader.js.map +0 -1
  426. package/dist/src/shadow/shadow_impl.js +0 -15
  427. package/dist/src/shadow/shadow_impl.js.map +0 -1
  428. package/dist/src/shadow/shadowmapper.js +0 -790
  429. package/dist/src/shadow/shadowmapper.js.map +0 -1
  430. package/dist/src/shadow/ssm.js +0 -159
  431. package/dist/src/shadow/ssm.js.map +0 -1
  432. package/dist/src/shadow/vsm.js +0 -297
  433. package/dist/src/shadow/vsm.js.map +0 -1
  434. package/dist/src/shapes/box.js +0 -386
  435. package/dist/src/shapes/box.js.map +0 -1
  436. package/dist/src/shapes/cylinder.js +0 -125
  437. package/dist/src/shapes/cylinder.js.map +0 -1
  438. package/dist/src/shapes/plane.js +0 -88
  439. package/dist/src/shapes/plane.js.map +0 -1
  440. package/dist/src/shapes/shape.js +0 -87
  441. package/dist/src/shapes/shape.js.map +0 -1
  442. package/dist/src/shapes/sphere.js +0 -114
  443. package/dist/src/shapes/sphere.js.map +0 -1
  444. package/dist/src/shapes/tetrahedron.js +0 -188
  445. package/dist/src/shapes/tetrahedron.js.map +0 -1
  446. package/dist/src/shapes/torus.js +0 -111
  447. package/dist/src/shapes/torus.js.map +0 -1
  448. package/dist/src/utility/aabbtree.js +0 -400
  449. package/dist/src/utility/aabbtree.js.map +0 -1
  450. package/dist/src/utility/bounding_volume.js +0 -29
  451. package/dist/src/utility/bounding_volume.js.map +0 -1
  452. package/dist/src/utility/debug.js +0 -28
  453. package/dist/src/utility/debug.js.map +0 -1
  454. package/dist/src/utility/draco/decoder.js +0 -116
  455. package/dist/src/utility/draco/decoder.js.map +0 -1
  456. package/dist/src/utility/misc.js +0 -105
  457. package/dist/src/utility/misc.js.map +0 -1
  458. package/dist/src/utility/panorama.js +0 -163
  459. package/dist/src/utility/panorama.js.map +0 -1
  460. package/dist/src/utility/pmrem.js +0 -354
  461. package/dist/src/utility/pmrem.js.map +0 -1
  462. package/dist/src/utility/rendermipmap.js +0 -115
  463. package/dist/src/utility/rendermipmap.js.map +0 -1
  464. package/dist/src/utility/serialization/json.js +0 -402
  465. package/dist/src/utility/serialization/json.js.map +0 -1
  466. package/dist/src/utility/serialization/manager.js +0 -623
  467. package/dist/src/utility/serialization/manager.js.map +0 -1
  468. package/dist/src/utility/serialization/scene/animation.js +0 -248
  469. package/dist/src/utility/serialization/scene/animation.js.map +0 -1
  470. package/dist/src/utility/serialization/scene/batch.js +0 -59
  471. package/dist/src/utility/serialization/scene/batch.js.map +0 -1
  472. package/dist/src/utility/serialization/scene/camera.js +0 -790
  473. package/dist/src/utility/serialization/scene/camera.js.map +0 -1
  474. package/dist/src/utility/serialization/scene/common.js +0 -222
  475. package/dist/src/utility/serialization/scene/common.js.map +0 -1
  476. package/dist/src/utility/serialization/scene/light.js +0 -575
  477. package/dist/src/utility/serialization/scene/light.js.map +0 -1
  478. package/dist/src/utility/serialization/scene/material.js +0 -1111
  479. package/dist/src/utility/serialization/scene/material.js.map +0 -1
  480. package/dist/src/utility/serialization/scene/mesh.js +0 -148
  481. package/dist/src/utility/serialization/scene/mesh.js.map +0 -1
  482. package/dist/src/utility/serialization/scene/misc.js +0 -39
  483. package/dist/src/utility/serialization/scene/misc.js.map +0 -1
  484. package/dist/src/utility/serialization/scene/node.js +0 -451
  485. package/dist/src/utility/serialization/scene/node.js.map +0 -1
  486. package/dist/src/utility/serialization/scene/particle.js +0 -425
  487. package/dist/src/utility/serialization/scene/particle.js.map +0 -1
  488. package/dist/src/utility/serialization/scene/primitive.js +0 -692
  489. package/dist/src/utility/serialization/scene/primitive.js.map +0 -1
  490. package/dist/src/utility/serialization/scene/scene.js +0 -704
  491. package/dist/src/utility/serialization/scene/scene.js.map +0 -1
  492. package/dist/src/utility/serialization/scene/terrain.js +0 -488
  493. package/dist/src/utility/serialization/scene/terrain.js.map +0 -1
  494. package/dist/src/utility/serialization/scene/water.js +0 -465
  495. package/dist/src/utility/serialization/scene/water.js.map +0 -1
  496. package/dist/src/utility/shprojector.js +0 -297
  497. package/dist/src/utility/shprojector.js.map +0 -1
  498. package/dist/src/utility/textures/ggxlut.js +0 -213
  499. package/dist/src/utility/textures/ggxlut.js.map +0 -1
  500. package/dist/src/utility/textures/gradientnoise.js +0 -62
  501. package/dist/src/utility/textures/gradientnoise.js.map +0 -1
  502. package/dist/src/utility/textures/randomnoise.js +0 -41
  503. package/dist/src/utility/textures/randomnoise.js.map +0 -1
  504. package/dist/src/values.js +0 -162
  505. package/dist/src/values.js.map +0 -1
  506. package/dist/utility/blueprint/material/common.js +0 -7
  507. package/dist/utility/blueprint/material/common.js.map +0 -1
  508. package/dist/utility/serialization/blueprint/constants.js +0 -255
  509. package/dist/utility/serialization/blueprint/constants.js.map +0 -1
  510. package/dist/utility/serialization/blueprint/material/constants.js +0 -203
  511. package/dist/utility/serialization/blueprint/material/constants.js.map +0 -1
  512. package/dist/utility/serialization/blueprint/material/texture.js +0 -165
  513. package/dist/utility/serialization/blueprint/material/texture.js.map +0 -1
  514. package/dist/utility/serialization/scene/cloth_script.js +0 -834
  515. package/dist/utility/serialization/scene/cloth_script.js.map +0 -1
  516. package/dist/utility/serialization/scene/spring_script.js +0 -596
  517. package/dist/utility/serialization/scene/spring_script.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"helpers.js","sources":["../../../../src/asset/loaders/gltf/helpers.ts"],"sourcesContent":["import type { Accessor, AccessorSparse } from './gltf';\r\nimport type { Nullable, TypedArray } from '@zephyr3d/base';\r\nimport type { GLTFContent } from './gltf_loader';\r\n\r\n/** @internal */\r\nexport const enum ComponentType {\r\n UNKNOWN = 0,\r\n BYTE = 5120, // GL.BYTE\r\n UBYTE = 5121, // GL.UNSIGNED_BYTE\r\n SHORT = 5122, // GL.SHORT\r\n USHORT = 5123, // GL.UNSIGNED_SHORT\r\n INT = 5124, // GL.INT\r\n UINT = 5125, // GL.UNSIGNED_INT\r\n FLOAT = 5126 // GL.FLOAT\r\n}\r\n\r\n/** @internal */\r\nexport type GLTFComponentType = 'SCALAR' | 'VEC2' | 'VEC3' | 'VEC4' | 'MAT2' | 'MAT3' | 'MAT4';\r\n\r\n/** @internal */\r\nexport class GLTFAccessor {\r\n bufferView: number;\r\n byteOffset: number;\r\n componentType: ComponentType;\r\n normalized: boolean;\r\n count: number;\r\n type: GLTFComponentType;\r\n max: number[];\r\n min: number[];\r\n sparse: AccessorSparse;\r\n name: string;\r\n private _typedView: Nullable<TypedArray>;\r\n private _filteredView: Nullable<TypedArray>;\r\n private _normalizedFilteredView: Nullable<TypedArray>;\r\n private _normalizedTypedView: Nullable<TypedArray>;\r\n constructor(accessorInfo: Accessor) {\r\n this.bufferView = accessorInfo.bufferView!;\r\n this.byteOffset = accessorInfo.byteOffset ?? 0;\r\n this.componentType = accessorInfo.componentType;\r\n this.normalized = !!accessorInfo.normalized;\r\n this.count = accessorInfo.count;\r\n this.type = accessorInfo.type;\r\n this.max = accessorInfo.max!;\r\n this.min = accessorInfo.min!;\r\n this.sparse = accessorInfo.sparse!;\r\n this.name = accessorInfo.name;\r\n this._typedView = null;\r\n this._filteredView = null;\r\n this._normalizedFilteredView = null;\r\n this._normalizedTypedView = null;\r\n }\r\n getTypedView(gltf: GLTFContent) {\r\n if (this._typedView) {\r\n return this._typedView;\r\n }\r\n\r\n if (this.bufferView !== undefined) {\r\n const bufferView = gltf.bufferViews![this.bufferView];\r\n const buffer = gltf._loadedBuffers![bufferView.buffer];\r\n const byteOffset = this.byteOffset + (bufferView.byteOffset ?? 0);\r\n\r\n const componentSize = this.getComponentSize(this.componentType);\r\n const componentCount = this.getComponentCount(this.type);\r\n\r\n let arrayLength = 0;\r\n if (bufferView.byteStride !== undefined && bufferView.byteStride !== 0) {\r\n if (componentSize !== 0) {\r\n arrayLength = (bufferView.byteStride / componentSize) * (this.count - 1) + componentCount;\r\n } else {\r\n console.warn(\"Invalid component type in accessor '\" + (this.name ? this.name : '') + \"'\");\r\n }\r\n } else {\r\n arrayLength = this.count * componentCount;\r\n }\r\n\r\n if (arrayLength * componentSize > buffer.byteLength - byteOffset) {\r\n arrayLength = (buffer.byteLength - byteOffset) / componentSize;\r\n console.warn(\"Count in accessor '\" + (this.name ? this.name : '') + \"' is too large.\");\r\n }\r\n\r\n switch (this.componentType) {\r\n case ComponentType.BYTE:\r\n this._typedView = new Int8Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.UBYTE:\r\n this._typedView = new Uint8Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.SHORT:\r\n this._typedView = new Int16Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.USHORT:\r\n this._typedView = new Uint16Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.INT:\r\n this._typedView = new Int32Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.UINT:\r\n this._typedView = new Uint32Array(buffer, byteOffset, arrayLength);\r\n break;\r\n case ComponentType.FLOAT:\r\n this._typedView = new Float32Array(buffer, byteOffset, arrayLength);\r\n break;\r\n }\r\n } else if (this.sparse !== undefined) {\r\n this._typedView = this.createView()!;\r\n }\r\n\r\n if (!this._typedView) {\r\n console.warn('Failed to convert buffer view to typed view!: ' + this.bufferView);\r\n } else if (this.sparse !== undefined) {\r\n this.applySparse(gltf, this._typedView);\r\n }\r\n\r\n return this._typedView;\r\n }\r\n\r\n // getNormalizedTypedView provides an alternative view to the accessors data,\r\n // where quantized data is already normalized. This is useful if the data is not passed\r\n // to vertexAttribPointer but used immediately (like e.g. animations)\r\n getNormalizedTypedView(gltf: GLTFContent) {\r\n if (this._normalizedTypedView) {\r\n return this._normalizedTypedView;\r\n }\r\n\r\n const typedView = this.getTypedView(gltf);\r\n this._normalizedTypedView = this.normalized\r\n ? GLTFAccessor.dequantize(typedView!, this.componentType)\r\n : typedView;\r\n return this._normalizedTypedView;\r\n }\r\n\r\n // getDeinterlacedView provides a view to the accessors data in form of\r\n // a TypedArray. In contrast to getTypedView, getDeinterlacedView deinterlaces\r\n // data, i.e. stripping padding and unrelated components from the array. It then\r\n // only contains the data of the accessor\r\n getDeinterlacedView(gltf: GLTFContent) {\r\n if (this._filteredView) {\r\n return this._filteredView;\r\n }\r\n\r\n const componentSize = this.getComponentSize(this.componentType);\r\n const componentCount = this.getComponentCount(this.type);\r\n const arrayLength = this.count * componentCount;\r\n\r\n let func:\r\n | 'getFloat32'\r\n | 'getInt8'\r\n | 'getUint8'\r\n | 'getInt16'\r\n | 'getUint16'\r\n | 'getInt32'\r\n | 'getUint32'\r\n | 'getFloat32' = 'getFloat32';\r\n switch (this.componentType) {\r\n case ComponentType.BYTE:\r\n this._filteredView = new Int8Array(arrayLength);\r\n func = 'getInt8';\r\n break;\r\n case ComponentType.UBYTE:\r\n this._filteredView = new Uint8Array(arrayLength);\r\n func = 'getUint8';\r\n break;\r\n case ComponentType.SHORT:\r\n this._filteredView = new Int16Array(arrayLength);\r\n func = 'getInt16';\r\n break;\r\n case ComponentType.USHORT:\r\n this._filteredView = new Uint16Array(arrayLength);\r\n func = 'getUint16';\r\n break;\r\n case ComponentType.INT:\r\n this._filteredView = new Int32Array(arrayLength);\r\n func = 'getInt32';\r\n break;\r\n case ComponentType.UINT:\r\n this._filteredView = new Uint32Array(arrayLength);\r\n func = 'getUint32';\r\n break;\r\n case ComponentType.FLOAT:\r\n this._filteredView = new Float32Array(arrayLength);\r\n func = 'getFloat32';\r\n break;\r\n default:\r\n return;\r\n }\r\n\r\n if (this.bufferView !== undefined) {\r\n const bufferView = gltf.bufferViews![this.bufferView];\r\n const buffer = gltf._loadedBuffers![bufferView.buffer];\r\n const byteOffset = this.byteOffset + (bufferView.byteOffset ?? 0);\r\n const stride =\r\n bufferView.byteStride !== undefined && bufferView.byteStride !== 0\r\n ? bufferView.byteStride\r\n : componentCount * componentSize;\r\n const dataView = new DataView(buffer, byteOffset, this.count * stride);\r\n for (let i = 0; i < arrayLength; ++i) {\r\n const offset = Math.floor(i / componentCount) * stride + (i % componentCount) * componentSize;\r\n this._filteredView[i] = dataView[func](offset, true);\r\n }\r\n } else if (this.sparse !== undefined) {\r\n this._filteredView = this.createView()!;\r\n }\r\n\r\n if (this.sparse !== undefined) {\r\n this.applySparse(gltf, this._filteredView);\r\n }\r\n\r\n return this._filteredView;\r\n }\r\n\r\n createView() {\r\n const size = this.count * this.getComponentCount(this.type);\r\n if (this.componentType == ComponentType.BYTE) {\r\n return new Int8Array(size);\r\n }\r\n if (this.componentType == ComponentType.UBYTE) {\r\n return new Uint8Array(size);\r\n }\r\n if (this.componentType == ComponentType.SHORT) {\r\n return new Int16Array(size);\r\n }\r\n if (this.componentType == ComponentType.USHORT) {\r\n return new Uint16Array(size);\r\n }\r\n if (this.componentType == ComponentType.INT) {\r\n return new Int32Array(size);\r\n }\r\n if (this.componentType == ComponentType.UINT) {\r\n return new Uint32Array(size);\r\n }\r\n if (this.componentType == ComponentType.FLOAT) {\r\n return new Float32Array(size);\r\n }\r\n return undefined;\r\n }\r\n\r\n // getNormalizedDeinterlacedView provides an alternative view to the accessors data,\r\n // where quantized data is already normalized. This is useful if the data is not passed\r\n // to vertexAttribPointer but used immediately (like e.g. animations)\r\n getNormalizedDeinterlacedView(gltf: GLTFContent) {\r\n if (this._normalizedFilteredView) {\r\n return this._normalizedFilteredView;\r\n }\r\n\r\n const filteredView = this.getDeinterlacedView(gltf)!;\r\n this._normalizedFilteredView = this.normalized\r\n ? GLTFAccessor.dequantize(filteredView!, this.componentType)\r\n : filteredView;\r\n return this._normalizedFilteredView;\r\n }\r\n\r\n applySparse(gltf: GLTFContent, view: TypedArray) {\r\n // Gather indices.\r\n\r\n const indicesBufferView = gltf.bufferViews![this.sparse.indices.bufferView];\r\n const indicesBuffer = gltf._loadedBuffers![indicesBufferView.buffer];\r\n const indicesByteOffset = (this.sparse.indices.byteOffset ?? 0) + (indicesBufferView.byteOffset ?? 0);\r\n\r\n const indicesComponentSize = this.getComponentSize(this.sparse.indices.componentType);\r\n let indicesComponentCount = 1;\r\n\r\n if (indicesBufferView.byteStride !== undefined && indicesBufferView.byteStride !== 0) {\r\n indicesComponentCount = indicesBufferView.byteStride / indicesComponentSize;\r\n }\r\n\r\n const indicesArrayLength = this.sparse.count * indicesComponentCount;\r\n\r\n let indicesTypedView;\r\n switch (this.sparse.indices.componentType) {\r\n case ComponentType.UBYTE:\r\n indicesTypedView = new Uint8Array(indicesBuffer, indicesByteOffset, indicesArrayLength);\r\n break;\r\n case ComponentType.USHORT:\r\n indicesTypedView = new Uint16Array(indicesBuffer, indicesByteOffset, indicesArrayLength);\r\n break;\r\n case ComponentType.UINT:\r\n indicesTypedView = new Uint32Array(indicesBuffer, indicesByteOffset, indicesArrayLength);\r\n break;\r\n }\r\n if (!indicesTypedView) {\r\n console.warn('Failed to convert sparse accessor indices to typed view!: ' + this.bufferView);\r\n return;\r\n }\r\n\r\n // Gather values.\r\n\r\n const valuesBufferView = gltf.bufferViews![this.sparse.values.bufferView];\r\n const valuesBuffer = gltf._loadedBuffers![valuesBufferView.buffer];\r\n const valuesByteOffset = (this.sparse.values.byteOffset ?? 0) + (valuesBufferView.byteOffset ?? 0);\r\n\r\n const valuesComponentSize = this.getComponentSize(this.componentType);\r\n let valuesComponentCount = this.getComponentCount(this.type);\r\n\r\n if (valuesBufferView.byteStride !== undefined && valuesBufferView.byteStride !== 0) {\r\n valuesComponentCount = valuesBufferView.byteStride / valuesComponentSize;\r\n }\r\n\r\n const valuesArrayLength = this.sparse.count * valuesComponentCount;\r\n\r\n let valuesTypedView: TypedArray;\r\n switch (this.componentType) {\r\n case ComponentType.BYTE:\r\n valuesTypedView = new Int8Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.UBYTE:\r\n valuesTypedView = new Uint8Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.SHORT:\r\n valuesTypedView = new Int16Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.USHORT:\r\n valuesTypedView = new Uint16Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.INT:\r\n valuesTypedView = new Int32Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.UINT:\r\n valuesTypedView = new Uint32Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n case ComponentType.FLOAT:\r\n valuesTypedView = new Float32Array(valuesBuffer, valuesByteOffset, valuesArrayLength);\r\n break;\r\n }\r\n\r\n // Overwrite values.\r\n\r\n for (let i = 0; i < this.sparse.count; ++i) {\r\n for (let k = 0; k < valuesComponentCount; ++k) {\r\n view[indicesTypedView[i] * valuesComponentCount + k] = valuesTypedView![i * valuesComponentCount + k];\r\n }\r\n }\r\n }\r\n\r\n // dequantize can be used to perform the normalization from WebGL2 vertexAttribPointer explicitly\r\n static dequantize(typedArray: TypedArray, componentType: ComponentType) {\r\n switch (componentType) {\r\n case ComponentType.BYTE:\r\n return new Float32Array(typedArray).map((c) => Math.max(c / 127.0, -1.0));\r\n case ComponentType.UBYTE:\r\n return new Float32Array(typedArray).map((c) => c / 255.0);\r\n case ComponentType.SHORT:\r\n return new Float32Array(typedArray).map((c) => Math.max(c / 32767.0, -1.0));\r\n case ComponentType.USHORT:\r\n return new Float32Array(typedArray).map((c) => c / 65535.0);\r\n default:\r\n return typedArray;\r\n }\r\n }\r\n\r\n getComponentCount(type: GLTFComponentType) {\r\n switch (type) {\r\n case 'SCALAR':\r\n return 1;\r\n case 'VEC2':\r\n return 2;\r\n case 'VEC3':\r\n return 3;\r\n case 'VEC4':\r\n return 4;\r\n case 'MAT2':\r\n return 4;\r\n case 'MAT3':\r\n return 9;\r\n case 'MAT4':\r\n return 16;\r\n default:\r\n return 0;\r\n }\r\n }\r\n\r\n getComponentSize(componentType: ComponentType) {\r\n switch (componentType) {\r\n case ComponentType.BYTE:\r\n case ComponentType.UBYTE:\r\n return 1;\r\n case ComponentType.SHORT:\r\n case ComponentType.USHORT:\r\n return 2;\r\n case ComponentType.INT:\r\n case ComponentType.UINT:\r\n case ComponentType.FLOAT:\r\n return 4;\r\n default:\r\n return 0;\r\n }\r\n }\r\n}\r\n"],"names":["ComponentType","GLTFAccessor","bufferView","byteOffset","componentType","normalized","count","type","max","min","sparse","name","_typedView","_filteredView","_normalizedFilteredView","_normalizedTypedView","accessorInfo","getTypedView","gltf","undefined","bufferViews","buffer","_loadedBuffers","componentSize","getComponentSize","componentCount","getComponentCount","arrayLength","byteStride","console","warn","byteLength","Int8Array","Uint8Array","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","createView","applySparse","getNormalizedTypedView","typedView","dequantize","getDeinterlacedView","func","stride","dataView","DataView","i","offset","Math","floor","size","getNormalizedDeinterlacedView","filteredView","view","indicesBufferView","indices","indicesBuffer","indicesByteOffset","indicesComponentSize","indicesComponentCount","indicesArrayLength","indicesTypedView","valuesBufferView","values","valuesBuffer","valuesByteOffset","valuesComponentSize","valuesComponentCount","valuesArrayLength","valuesTypedView","k","typedArray","map","c"],"mappings":"AAIA,iBACO,IAAWA,aAAAA,iBAAAA,SAAAA,a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,OAAO,IAAItC,YAAAA,CAAaoC,UAAYC,CAAAA,CAAAA,GAAG,CAAC,CAACC,CAAMzB,GAAAA,IAAAA,CAAK3C,GAAG,CAACoE,CAAI,GAAA,OAAA,EAAS,EAAC,CAAA,CAAA;AACxE,YAAA,KAAA,IAAA;AACE,gBAAA,OAAO,IAAItC,YAAaoC,CAAAA,UAAAA,CAAAA,CAAYC,GAAG,CAAC,CAACC,IAAMA,CAAI,GAAA,OAAA,CAAA;AACrD,YAAA;gBACE,OAAOF,UAAAA;AACX;AACF;AAEAhD,IAAAA,iBAAAA,CAAkBnB,IAAuB,EAAE;QACzC,OAAQA,IAAAA;YACN,KAAK,QAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,CAAA;YACT,KAAK,MAAA;gBACH,OAAO,EAAA;AACT,YAAA;gBACE,OAAO,CAAA;AACX;AACF;AAEAiB,IAAAA,gBAAAA,CAAiBpB,aAA4B,EAAE;QAC7C,OAAQA,aAAAA;AACN,YAAA,KAAA,IAAA;AACA,YAAA,KAAA,IAAA;gBACE,OAAO,CAAA;AACT,YAAA,KAAA,IAAA;AACA,YAAA,KAAA,IAAA;gBACE,OAAO,CAAA;AACT,YAAA,KAAA,IAAA;AACA,YAAA,KAAA,IAAA;AACA,YAAA,KAAA,IAAA;gBACE,OAAO,CAAA;AACT,YAAA;gBACE,OAAO,CAAA;AACX;AACF;AACF;;;;"}
@@ -1,301 +0,0 @@
1
- import { MeshMaterial } from './meshmaterial.js';
2
- import { ShaderHelper } from './shader/helper.js';
3
- import { MaterialVaryingFlags } from '../values.js';
4
- import { Vector4 } from '@zephyr3d/base';
5
-
6
- /**
7
- * Sprite3D material base class.
8
- *
9
- * @remarks
10
- * This material renders a camera-facing quad (billboard) in 3D space,
11
- * using UV information and an anchor point to control how the sprite
12
- * is positioned and textured.
13
- *
14
- * Derived classes can override {@link internalSetupUniforms},
15
- * {@link internalApplyUniforms} and
16
- * {@link calcFragmentColor} to provide custom
17
- * uniforms and shading logic (e.g. sampling a texture).
18
- *
19
- * @public
20
- */ class Sprite3DMaterial extends MeshMaterial {
21
- static UVINFO = this.defineInstanceUniform('uvinfo', 'vec4');
22
- static ANCHOR_ROTATION = this.defineInstanceUniform('anchorRotation', 'vec4');
23
- _uvinfo;
24
- _anchorRotation;
25
- /**
26
- * Creates a new {@link Sprite3DMaterial} instance.
27
- *
28
- * @remarks
29
- * - Default UV rectangle is the full texture [0, 0, 1, 1].
30
- * - Default anchor is the center [0.5, 0.5].
31
- * - Face culling is disabled (`cullMode = 'none'`) so the sprite
32
- * is visible from both sides.
33
- */ constructor(){
34
- super();
35
- this._uvinfo = new Vector4(0, 0, 1, 1);
36
- this._anchorRotation = new Vector4(0.5, 0.5, 0, 0);
37
- this.cullMode = 'none';
38
- }
39
- /**
40
- * Gets the UV rectangle of the sprite in the texture.
41
- *
42
- * @returns A Vector4 storing \([u0, v0, u1, v1]\).
43
- */ get uvinfo() {
44
- return this._uvinfo;
45
- }
46
- set uvinfo(value) {
47
- if (!value.equalsTo(this.uvinfo)) {
48
- this._uvinfo.set(value);
49
- this.uniformChanged();
50
- }
51
- }
52
- /**
53
- * Convenience method to set the UV rectangle via individual components.
54
- *
55
- * @param uvx0 - Left (U) coordinate.
56
- * @param uvy0 - Bottom (V) coordinate.
57
- * @param uvx1 - Right (U) coordinate.
58
- * @param uvy1 - Top (V) coordinate.
59
- */ setUVInfo(uvx0, uvy0, uvx1, uvy1) {
60
- this.uvinfo = new Vector4(uvx0, uvy0, uvx1, uvy1);
61
- }
62
- /**
63
- * Gets the sprite anchor-rotation.
64
- *
65
- * @returns The current anchor-rotation.
66
- */ get anchorRotation() {
67
- return this._anchorRotation;
68
- }
69
- set anchorRotation(value) {
70
- if (!value.equalsTo(this._anchorRotation)) {
71
- this._anchorRotation.set(value);
72
- this.uniformChanged();
73
- }
74
- }
75
- /**
76
- * Gets the sprite anchor point in normalized quad space.
77
- *
78
- * @returns The current anchor as a Vector2.
79
- */ get anchor() {
80
- return this._anchorRotation.xy();
81
- }
82
- set anchor(value) {
83
- if (value.x !== this._anchorRotation.x || value.y !== this._anchorRotation.y) {
84
- this.anchorRotation = new Vector4(value.x, value.y, this._anchorRotation.z, this._anchorRotation.w);
85
- }
86
- }
87
- /**
88
- * Gets the sprite rotation around the Z axis.
89
- *
90
- * @returns The sprite rotation.
91
- */ get rotation() {
92
- return this._anchorRotation.z;
93
- }
94
- set rotation(value) {
95
- if (value !== this._anchorRotation.z) {
96
- this.anchorRotation = new Vector4(this._anchorRotation.x, this._anchorRotation.y, value, this._anchorRotation.w);
97
- }
98
- }
99
- /**
100
- * Gets the X component of the sprite anchor.
101
- */ get anchorX() {
102
- return this._anchorRotation.x;
103
- }
104
- set anchorX(value) {
105
- if (this._anchorRotation.x !== value) {
106
- this.anchorRotation = new Vector4(value, this._anchorRotation.y, this._anchorRotation.z, this._anchorRotation.w);
107
- }
108
- }
109
- /**
110
- * Gets the Y component of the sprite anchor.
111
- */ get anchorY() {
112
- return this._anchorRotation.y;
113
- }
114
- set anchorY(value) {
115
- if (this._anchorRotation.y !== value) {
116
- this.anchorRotation = new Vector4(this._anchorRotation.x, value, this._anchorRotation.z, this._anchorRotation.w);
117
- }
118
- }
119
- /**
120
- * Convenience method to set both anchor components at once.
121
- *
122
- * @param anchorX - X coordinate of the anchor.
123
- * @param anchorY - Y coordinate of the anchor.
124
- */ setAnchor(anchorX, anchorY) {
125
- if (this._anchorRotation.x !== anchorX || this._anchorRotation.y !== anchorY) {
126
- this.anchorRotation = new Vector4(anchorX, anchorY, this._anchorRotation.z, this._anchorRotation.w);
127
- }
128
- }
129
- /**
130
- * Creates a deep copy of this material.
131
- *
132
- * @returns A new {@link Sprite3DMaterial} instance with the same properties.
133
- */ clone() {
134
- const other = new Sprite3DMaterial();
135
- other.copyFrom(this);
136
- return other;
137
- }
138
- /**
139
- * Copies all relevant state from another {@link Sprite3DMaterial}.
140
- *
141
- * @param other - The source material to copy from.
142
- */ copyFrom(other) {
143
- super.copyFrom(other);
144
- this.uvinfo = other.uvinfo;
145
- this.anchorRotation = other.anchorRotation;
146
- }
147
- /**
148
- * Builds the vertex shader for this material.
149
- *
150
- * @remarks
151
- * This method:
152
- * - Calls the base implementation.
153
- * - Computes per-vertex positions for a camera-facing quad (billboard)
154
- * based on the sprite's world transform, size, and anchor.
155
- * - Selects the correct UV coordinates for each quad corner using
156
- * the `vertexId` attribute.
157
- * - Outputs world-space position (`zWorldPos`) and UVs (`zVertexUV`)
158
- * for use in the fragment shader.
159
- *
160
- * @param scope - The current programmable builder function scope.
161
- */ vertexShader(scope) {
162
- super.vertexShader(scope);
163
- const pb = scope.$builder;
164
- scope.$inputs.vertexId = pb.float().attrib('position');
165
- if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {
166
- scope.$l.uvinfo = this.getInstancedUniform(scope, Sprite3DMaterial.UVINFO);
167
- scope.$l.anchorRotation = this.getInstancedUniform(scope, Sprite3DMaterial.ANCHOR_ROTATION);
168
- } else {
169
- scope.uvinfo = pb.vec4().uniform(2);
170
- scope.anchorRotation = pb.vec4().uniform(2);
171
- }
172
- this.internalSetupUniforms(scope);
173
- scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;
174
- scope.$l.width = pb.sqrt(pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz));
175
- scope.$l.height = pb.sqrt(pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz));
176
- const viewMatrix = ShaderHelper.getViewMatrix(scope);
177
- scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);
178
- scope.$l.axis = scope.$choice(pb.lessThan(pb.abs(scope.forward.y), 0.999), pb.vec3(0, 1, 0), pb.vec3(1, 0, 0));
179
- scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));
180
- scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));
181
- scope.$l.rotateAngle = scope.anchorRotation.z;
182
- scope.$l.c = pb.cos(scope.rotateAngle);
183
- scope.$l.s = pb.sin(scope.rotateAngle);
184
- scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));
185
- scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));
186
- scope.$l.v = pb.vec2();
187
- scope.$l.uv = pb.vec2();
188
- scope.$l.anchor = scope.anchorRotation.xy;
189
- scope.$if(pb.equal(scope.$inputs.vertexId, 0), function() {
190
- scope.v = pb.neg(scope.anchor);
191
- scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.y));
192
- }).$elseif(pb.equal(scope.$inputs.vertexId, 1), function() {
193
- scope.v = pb.sub(pb.vec2(1, 0), scope.anchor);
194
- scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.y));
195
- }).$elseif(pb.equal(scope.$inputs.vertexId, 2), function() {
196
- scope.v = pb.sub(pb.vec2(0, 1), scope.anchor);
197
- scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.w));
198
- }).$else(function() {
199
- scope.v = pb.sub(pb.vec2(1), scope.anchor);
200
- scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.w));
201
- });
202
- scope.v = pb.mul(scope.v, pb.vec2(scope.width, scope.height));
203
- scope.$outputs.zWorldPos = pb.add(scope.worldPos, pb.mul(scope.rightRot, scope.v.x), pb.mul(scope.upRot, scope.v.y));
204
- scope.$outputs.zVertexUV = scope.uv;
205
- ShaderHelper.setClipSpacePosition(scope, pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.zWorldPos, 1)));
206
- }
207
- /**
208
- * Builds the fragment shader for this material.
209
- *
210
- * @remarks
211
- * This method:
212
- * - Calls the base implementation.
213
- * - Invokes {@link Sprite3DMaterial.internalSetupUniforms} for
214
- * fragment-stage specific uniform declarations.
215
- * - Computes fragment color by calling {@link Sprite3DMaterial.calcFragmentColor}
216
- * if fragment color is needed.
217
- * - Outputs the final fragment color via {@link MeshMaterial.outputFragmentColor}.
218
- *
219
- * @param scope - The current programmable builder function scope.
220
- */ fragmentShader(scope) {
221
- super.fragmentShader(scope);
222
- this.internalSetupUniforms(scope);
223
- if (this.needFragmentColor()) {
224
- scope.$l.color = this.calcFragmentColor(scope);
225
- this.outputFragmentColor(scope, scope.$inputs.zWorldPos, scope.color);
226
- } else {
227
- this.outputFragmentColor(scope, scope.$inputs.zWorldPos, null);
228
- }
229
- }
230
- /**
231
- * Applies runtime uniform values to the given bind group before drawing.
232
- *
233
- * @remarks
234
- * This binds:
235
- * - UV information (`uvinfo`)
236
- * - Anchor (`anchor`)
237
- *
238
- * for non-instanced rendering. For instanced rendering, these values
239
- * are expected to be provided as per-instance uniforms instead.
240
- *
241
- * It also calls {@link Sprite3DMaterial.internalApplyUniforms} to allow
242
- * derived classes to bind additional resources (e.g. textures).
243
- *
244
- * @param bindGroup - The bind group to which uniforms and resources are bound.
245
- * @param ctx - The current draw context providing rendering state.
246
- * @param pass - Index of the active render pass.
247
- */ applyUniformValues(bindGroup, ctx, pass) {
248
- super.applyUniformValues(bindGroup, ctx, pass);
249
- if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {
250
- bindGroup.setValue('uvinfo', this._uvinfo);
251
- bindGroup.setValue('anchorRotation', this._anchorRotation);
252
- }
253
- this.internalApplyUniforms(bindGroup, ctx, pass);
254
- }
255
- /**
256
- * Hook for derived classes to declare additional uniforms.
257
- *
258
- * @remarks
259
- * This is invoked in both the vertex and fragment shader construction
260
- * phases, allowing subclasses to register extra uniforms or resources
261
- * needed by their custom shading logic.
262
- *
263
- * The base implementation does nothing.
264
- *
265
- * @param _scope - The current shader function scope.
266
- */ internalSetupUniforms(_scope) {}
267
- /**
268
- * Hook for derived classes to bind additional uniform values or resources.
269
- *
270
- * @remarks
271
- * This is called from {@link Sprite3DMaterial.applyUniformValues} and is
272
- * intended for subclasses to bind their own textures, samplers, or
273
- * other GPU resources.
274
- *
275
- * The base implementation does nothing.
276
- *
277
- * @param _bindGroup - The bind group used for binding uniforms and resources.
278
- * @param _ctx - The current draw context.
279
- * @param _pass - Index of the active render pass.
280
- */ internalApplyUniforms(_bindGroup, _ctx, _pass) {}
281
- /**
282
- * Computes the fragment color expression for this material.
283
- *
284
- * @remarks
285
- * The default implementation simply outputs the interpolated UV
286
- * coordinates as color \([u, v, 0, 1]\), which is mainly useful
287
- * for debugging.
288
- *
289
- * Derived classes are expected to override this method to implement
290
- * actual shading, such as sampling a texture.
291
- *
292
- * @param scope - The current shader function scope.
293
- * @returns A shader expression representing the fragment color.
294
-
295
- */ calcFragmentColor(scope) {
296
- return scope.$builder.vec4(scope.$inputs.zVertexUV, 0, 1);
297
- }
298
- }
299
-
300
- export { Sprite3DMaterial };
301
- //# sourceMappingURL=sprite3d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sprite3d.js","sources":["../../src/material/sprite3d.ts"],"sourcesContent":["import { MeshMaterial } from './meshmaterial';\r\nimport type { BindGroup, PBFunctionScope, PBInsideFunctionScope } from '@zephyr3d/device';\r\nimport { ShaderHelper } from './shader/helper';\r\nimport { MaterialVaryingFlags } from '../values';\r\nimport type { Clonable, Immutable, Vector2 } from '@zephyr3d/base';\r\nimport { Vector4 } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render';\r\n\r\n/**\r\n * Sprite3D material base class.\r\n *\r\n * @remarks\r\n * This material renders a camera-facing quad (billboard) in 3D space,\r\n * using UV information and an anchor point to control how the sprite\r\n * is positioned and textured.\r\n *\r\n * Derived classes can override {@link internalSetupUniforms},\r\n * {@link internalApplyUniforms} and\r\n * {@link calcFragmentColor} to provide custom\r\n * uniforms and shading logic (e.g. sampling a texture).\r\n *\r\n * @public\r\n */\r\nexport class Sprite3DMaterial extends MeshMaterial implements Clonable<Sprite3DMaterial> {\r\n static UVINFO = this.defineInstanceUniform('uvinfo', 'vec4');\r\n static ANCHOR_ROTATION = this.defineInstanceUniform('anchorRotation', 'vec4');\r\n private _uvinfo: Vector4;\r\n private _anchorRotation: Vector4;\r\n /**\r\n * Creates a new {@link Sprite3DMaterial} instance.\r\n *\r\n * @remarks\r\n * - Default UV rectangle is the full texture [0, 0, 1, 1].\r\n * - Default anchor is the center [0.5, 0.5].\r\n * - Face culling is disabled (`cullMode = 'none'`) so the sprite\r\n * is visible from both sides.\r\n */\r\n constructor() {\r\n super();\r\n this._uvinfo = new Vector4(0, 0, 1, 1);\r\n this._anchorRotation = new Vector4(0.5, 0.5, 0, 0);\r\n this.cullMode = 'none';\r\n }\r\n /**\r\n * Gets the UV rectangle of the sprite in the texture.\r\n *\r\n * @returns A Vector4 storing \\([u0, v0, u1, v1]\\).\r\n */\r\n get uvinfo(): Immutable<Vector4> {\r\n return this._uvinfo;\r\n }\r\n set uvinfo(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this.uvinfo)) {\r\n this._uvinfo.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Convenience method to set the UV rectangle via individual components.\r\n *\r\n * @param uvx0 - Left (U) coordinate.\r\n * @param uvy0 - Bottom (V) coordinate.\r\n * @param uvx1 - Right (U) coordinate.\r\n * @param uvy1 - Top (V) coordinate.\r\n */\r\n setUVInfo(uvx0: number, uvy0: number, uvx1: number, uvy1: number) {\r\n this.uvinfo = new Vector4(uvx0, uvy0, uvx1, uvy1);\r\n }\r\n /**\r\n * Gets the sprite anchor-rotation.\r\n *\r\n * @returns The current anchor-rotation.\r\n */\r\n get anchorRotation(): Immutable<Vector4> {\r\n return this._anchorRotation;\r\n }\r\n set anchorRotation(value: Immutable<Vector4>) {\r\n if (!value.equalsTo(this._anchorRotation)) {\r\n this._anchorRotation.set(value);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Gets the sprite anchor point in normalized quad space.\r\n *\r\n * @returns The current anchor as a Vector2.\r\n */\r\n get anchor(): Immutable<Vector2> {\r\n return this._anchorRotation.xy();\r\n }\r\n set anchor(value: Immutable<Vector2>) {\r\n if (value.x !== this._anchorRotation.x || value.y !== this._anchorRotation.y) {\r\n this.anchorRotation = new Vector4(value.x, value.y, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Gets the sprite rotation around the Z axis.\r\n *\r\n * @returns The sprite rotation.\r\n */\r\n get rotation() {\r\n return this._anchorRotation.z;\r\n }\r\n set rotation(value) {\r\n if (value !== this._anchorRotation.z) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n this._anchorRotation.y,\r\n value,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the X component of the sprite anchor.\r\n */\r\n get anchorX() {\r\n return this._anchorRotation.x;\r\n }\r\n set anchorX(value) {\r\n if (this._anchorRotation.x !== value) {\r\n this.anchorRotation = new Vector4(\r\n value,\r\n this._anchorRotation.y,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Gets the Y component of the sprite anchor.\r\n */\r\n get anchorY() {\r\n return this._anchorRotation.y;\r\n }\r\n set anchorY(value) {\r\n if (this._anchorRotation.y !== value) {\r\n this.anchorRotation = new Vector4(\r\n this._anchorRotation.x,\r\n value,\r\n this._anchorRotation.z,\r\n this._anchorRotation.w\r\n );\r\n }\r\n }\r\n /**\r\n * Convenience method to set both anchor components at once.\r\n *\r\n * @param anchorX - X coordinate of the anchor.\r\n * @param anchorY - Y coordinate of the anchor.\r\n */\r\n setAnchor(anchorX: number, anchorY: number) {\r\n if (this._anchorRotation.x !== anchorX || this._anchorRotation.y !== anchorY) {\r\n this.anchorRotation = new Vector4(anchorX, anchorY, this._anchorRotation.z, this._anchorRotation.w);\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material.\r\n *\r\n * @returns A new {@link Sprite3DMaterial} instance with the same properties.\r\n */\r\n clone() {\r\n const other = new Sprite3DMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copies all relevant state from another {@link Sprite3DMaterial}.\r\n *\r\n * @param other - The source material to copy from.\r\n */\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.uvinfo = other.uvinfo;\r\n this.anchorRotation = other.anchorRotation;\r\n }\r\n /**\r\n * Builds the vertex shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Computes per-vertex positions for a camera-facing quad (billboard)\r\n * based on the sprite's world transform, size, and anchor.\r\n * - Selects the correct UV coordinates for each quad corner using\r\n * the `vertexId` attribute.\r\n * - Outputs world-space position (`zWorldPos`) and UVs (`zVertexUV`)\r\n * for use in the fragment shader.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n vertexShader(scope: PBFunctionScope) {\r\n super.vertexShader(scope);\r\n const pb = scope.$builder;\r\n scope.$inputs.vertexId = pb.float().attrib('position');\r\n if (this.drawContext.materialFlags & MaterialVaryingFlags.INSTANCING) {\r\n scope.$l.uvinfo = this.getInstancedUniform(scope, Sprite3DMaterial.UVINFO);\r\n scope.$l.anchorRotation = this.getInstancedUniform(scope, Sprite3DMaterial.ANCHOR_ROTATION);\r\n } else {\r\n scope.uvinfo = pb.vec4().uniform(2);\r\n scope.anchorRotation = pb.vec4().uniform(2);\r\n }\r\n this.internalSetupUniforms(scope);\r\n scope.$l.worldPos = ShaderHelper.getWorldMatrix(scope)[3].xyz;\r\n scope.$l.width = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[0].xyz, ShaderHelper.getWorldMatrix(scope)[0].xyz)\r\n );\r\n scope.$l.height = pb.sqrt(\r\n pb.dot(ShaderHelper.getWorldMatrix(scope)[1].xyz, ShaderHelper.getWorldMatrix(scope)[1].xyz)\r\n );\r\n const viewMatrix = ShaderHelper.getViewMatrix(scope);\r\n scope.$l.forward = pb.vec3(viewMatrix[0].z, viewMatrix[1].z, viewMatrix[2].z);\r\n scope.$l.axis = scope.$choice(\r\n pb.lessThan(pb.abs(scope.forward.y), 0.999),\r\n pb.vec3(0, 1, 0),\r\n pb.vec3(1, 0, 0)\r\n );\r\n scope.$l.right = pb.normalize(pb.cross(scope.axis, scope.forward));\r\n scope.$l.up = pb.normalize(pb.cross(scope.forward, scope.right));\r\n scope.$l.rotateAngle = scope.anchorRotation.z;\r\n scope.$l.c = pb.cos(scope.rotateAngle);\r\n scope.$l.s = pb.sin(scope.rotateAngle);\r\n scope.$l.rightRot = pb.add(pb.mul(scope.up, scope.s), pb.mul(scope.right, scope.c));\r\n scope.$l.upRot = pb.sub(pb.mul(scope.up, scope.c), pb.mul(scope.right, scope.s));\r\n scope.$l.v = pb.vec2();\r\n scope.$l.uv = pb.vec2();\r\n scope.$l.anchor = scope.anchorRotation.xy;\r\n scope\r\n .$if(pb.equal(scope.$inputs.vertexId, 0), function () {\r\n scope.v = pb.neg(scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 1), function () {\r\n scope.v = pb.sub(pb.vec2(1, 0), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.y));\r\n })\r\n .$elseif(pb.equal(scope.$inputs.vertexId, 2), function () {\r\n scope.v = pb.sub(pb.vec2(0, 1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.x, pb.sub(1, scope.uvinfo.w));\r\n })\r\n .$else(function () {\r\n scope.v = pb.sub(pb.vec2(1), scope.anchor);\r\n scope.uv = pb.vec2(scope.uvinfo.z, pb.sub(1, scope.uvinfo.w));\r\n });\r\n scope.v = pb.mul(scope.v, pb.vec2(scope.width, scope.height));\r\n scope.$outputs.zWorldPos = pb.add(\r\n scope.worldPos,\r\n pb.mul(scope.rightRot, scope.v.x),\r\n pb.mul(scope.upRot, scope.v.y)\r\n );\r\n scope.$outputs.zVertexUV = scope.uv;\r\n ShaderHelper.setClipSpacePosition(\r\n scope,\r\n pb.mul(ShaderHelper.getViewProjectionMatrix(scope), pb.vec4(scope.$outputs.zWorldPos, 1))\r\n );\r\n }\r\n /**\r\n * Builds the fragment shader for this material.\r\n *\r\n * @remarks\r\n * This method:\r\n * - Calls the base implementation.\r\n * - Invokes {@link Sprite3DMaterial.internalSetupUniforms} for\r\n * fragment-stage specific uniform declarations.\r\n * - Computes fragment color by calling {@link Sprite3DMaterial.calcFragmentColor}\r\n * if fragment color is needed.\r\n * - Outputs the final fragment color via {@link MeshMaterial.outputFragmentColor}.\r\n *\r\n * @param scope - The current programmable builder function scope.\r\n */\r\n fragmentShader(scope: PBFunctionScope) {\r\n super.fragmentShader(scope);\r\n this.internalSetupUniforms(scope);\r\n if (this.needFragmentColor()) {\r\n scope.$l.color = this.calcFragmentColor(scope);\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, scope.color);\r\n } else {\r\n this.outputFragmentColor(scope, scope.$inputs.zWorldPos, null);\r\n }\r\n }\r\n /**\r\n * Applies runtime uniform values to the given bind group before drawing.\r\n *\r\n * @remarks\r\n * This binds:\r\n * - UV information (`uvinfo`)\r\n * - Anchor (`anchor`)\r\n *\r\n * for non-instanced rendering. For instanced rendering, these values\r\n * are expected to be provided as per-instance uniforms instead.\r\n *\r\n * It also calls {@link Sprite3DMaterial.internalApplyUniforms} to allow\r\n * derived classes to bind additional resources (e.g. textures).\r\n *\r\n * @param bindGroup - The bind group to which uniforms and resources are bound.\r\n * @param ctx - The current draw context providing rendering state.\r\n * @param pass - Index of the active render pass.\r\n */\r\n applyUniformValues(bindGroup: BindGroup, ctx: DrawContext, pass: number) {\r\n super.applyUniformValues(bindGroup, ctx, pass);\r\n if (!(ctx.materialFlags & MaterialVaryingFlags.INSTANCING)) {\r\n bindGroup.setValue('uvinfo', this._uvinfo);\r\n bindGroup.setValue('anchorRotation', this._anchorRotation);\r\n }\r\n this.internalApplyUniforms(bindGroup, ctx, pass);\r\n }\r\n /**\r\n * Hook for derived classes to declare additional uniforms.\r\n *\r\n * @remarks\r\n * This is invoked in both the vertex and fragment shader construction\r\n * phases, allowing subclasses to register extra uniforms or resources\r\n * needed by their custom shading logic.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _scope - The current shader function scope.\r\n */\r\n protected internalSetupUniforms(_scope: PBInsideFunctionScope) {}\r\n /**\r\n * Hook for derived classes to bind additional uniform values or resources.\r\n *\r\n * @remarks\r\n * This is called from {@link Sprite3DMaterial.applyUniformValues} and is\r\n * intended for subclasses to bind their own textures, samplers, or\r\n * other GPU resources.\r\n *\r\n * The base implementation does nothing.\r\n *\r\n * @param _bindGroup - The bind group used for binding uniforms and resources.\r\n * @param _ctx - The current draw context.\r\n * @param _pass - Index of the active render pass.\r\n */\r\n protected internalApplyUniforms(_bindGroup: BindGroup, _ctx: DrawContext, _pass: number) {}\r\n /**\r\n * Computes the fragment color expression for this material.\r\n *\r\n * @remarks\r\n * The default implementation simply outputs the interpolated UV\r\n * coordinates as color \\([u, v, 0, 1]\\), which is mainly useful\r\n * for debugging.\r\n *\r\n * Derived classes are expected to override this method to implement\r\n * actual shading, such as sampling a texture.\r\n *\r\n * @param scope - The current shader function scope.\r\n * @returns A shader expression representing the fragment color.\r\n\r\n */\r\n protected calcFragmentColor(scope: PBInsideFunctionScope) {\r\n return scope.$builder.vec4(scope.$inputs.zVertexUV, 0, 1);\r\n }\r\n}\r\n"],"names":["Sprite3DMaterial","MeshMaterial","UVINFO","defineInstanceUniform","ANCHOR_ROTATION","_uvinfo","_anchorRotation","Vector4","cullMode","uvinfo","value","equalsTo","set","uniformChanged","setUVInfo","uvx0","uvy0","uvx1","uvy1","anchorRotation","anchor","xy","x","y","z","w","rotation","anchorX","anchorY","setAnchor","clone","other","copyFrom","vertexShader","scope","pb","$builder","$inputs","vertexId","float","attrib","drawContext","materialFlags","MaterialVaryingFlags","INSTANCING","$l","getInstancedUniform","vec4","uniform","internalSetupUniforms","worldPos","ShaderHelper","getWorldMatrix","xyz","width","sqrt","dot","height","viewMatrix","getViewMatrix","forward","vec3","axis","$choice","lessThan","abs","right","normalize","cross","up","rotateAngle","c","cos","s","sin","rightRot","add","mul","upRot","sub","v","vec2","uv","$if","equal","neg","$elseif","$else","$outputs","zWorldPos","zVertexUV","setClipSpacePosition","getViewProjectionMatrix","fragmentShader","needFragmentColor","color","calcFragmentColor","outputFragmentColor","applyUniformValues","bindGroup","ctx","pass","setValue","internalApplyUniforms","_scope","_bindGroup","_ctx","_pass"],"mappings":";;;;;AAQA;;;;;;;;;;;;;;IAeO,MAAMA,gBAAyBC,SAAAA,YAAAA,CAAAA;AACpC,IAAA,OAAOC,SAAS,IAAI,CAACC,qBAAqB,CAAC,UAAU,MAAQ,CAAA;AAC7D,IAAA,OAAOC,kBAAkB,IAAI,CAACD,qBAAqB,CAAC,kBAAkB,MAAQ,CAAA;IACtEE,OAAiB;IACjBC,eAAyB;AACjC;;;;;;;;AAQC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;AACL,QAAA,IAAI,CAACD,OAAO,GAAG,IAAIE,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAG,EAAA,CAAA,CAAA;AACpC,QAAA,IAAI,CAACD,eAAe,GAAG,IAAIC,OAAQ,CAAA,GAAA,EAAK,KAAK,CAAG,EAAA,CAAA,CAAA;QAChD,IAAI,CAACC,QAAQ,GAAG,MAAA;AAClB;AACA;;;;AAIC,MACD,IAAIC,MAA6B,GAAA;QAC/B,OAAO,IAAI,CAACJ,OAAO;AACrB;IACA,IAAII,MAAAA,CAAOC,KAAyB,EAAE;AACpC,QAAA,IAAI,CAACA,KAAMC,CAAAA,QAAQ,CAAC,IAAI,CAACF,MAAM,CAAG,EAAA;AAChC,YAAA,IAAI,CAACJ,OAAO,CAACO,GAAG,CAACF,KAA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AAAA,SAAAA,CAAUG,QAAQ,CAAC,gBAAkB,EAAA,IAAI,CAAChG,eAAe,CAAA;AAC3D;AACA,QAAA,IAAI,CAACiG,qBAAqB,CAACJ,SAAAA,EAAWC,GAAKC,EAAAA,IAAAA,CAAAA;AAC7C;AACA;;;;;;;;;;;AAWC,MACD,qBAAUpD,CAAsBuD,MAA6B,EAAE;AAC/D;;;;;;;;;;;;;MAcUD,sBAAsBE,UAAqB,EAAEC,IAAiB,EAAEC,KAAa,EAAE;AACzF;;;;;;;;;;;;;;MAeUX,iBAAkB9D,CAAAA,KAA4B,EAAE;QACxD,OAAOA,KAAAA,CAAME,QAAQ,CAACW,IAAI,CAACb,MAAMG,OAAO,CAACqD,SAAS,EAAE,CAAG,EAAA,CAAA,CAAA;AACzD;AACF;;;;"}
@@ -1,116 +0,0 @@
1
- import { DRef } from '@zephyr3d/base';
2
- import { Sprite3DMaterial } from './sprite3d.js';
3
- import { fetchSampler } from '../utility/misc.js';
4
-
5
- /**
6
- * Standard Sprite3D material
7
- * @public
8
- */ class StandardSprite3DMaterial extends Sprite3DMaterial {
9
- static FEATURE_SPRITE_TEXTURE = this.defineFeature();
10
- _texture;
11
- /**
12
- * Creates a new instance of {@link StandardSprite3DMaterial}.
13
- *
14
- * @remarks
15
- * By default, no sprite texture is assigned and the material renders
16
- * as solid white until a texture is set.
17
- */ constructor(){
18
- super();
19
- this._texture = new DRef();
20
- }
21
- /**
22
- * Gets the 2D texture used by this sprite material.
23
- *
24
- * @returns The current sprite texture, or `null` if no texture is assigned.
25
- */ get spriteTexture() {
26
- return this._texture.get();
27
- }
28
- set spriteTexture(tex) {
29
- tex = tex ?? null;
30
- if (tex !== this._texture.get()) {
31
- this._texture.set(tex);
32
- this.useFeature(StandardSprite3DMaterial.FEATURE_SPRITE_TEXTURE, !!tex);
33
- this.uniformChanged();
34
- }
35
- }
36
- /**
37
- * Creates a deep copy of this material instance.
38
- *
39
- * @remarks
40
- * The new instance will copy all relevant state from this material,
41
- * including the assigned sprite texture reference.
42
- *
43
- * @returns A new {@link StandardSprite3DMaterial} instance with the same settings.
44
- */ clone() {
45
- const other = new StandardSprite3DMaterial();
46
- other.copyFrom(this);
47
- return other;
48
- }
49
- /**
50
- * Copies the state from another {@link StandardSprite3DMaterial} into this instance.
51
- *
52
- * @param other - The source material to copy from.
53
- */ copyFrom(other) {
54
- super.copyFrom(other);
55
- this.spriteTexture = other.spriteTexture;
56
- }
57
- /**
58
- * Applies runtime uniform values to the given bind group before drawing.
59
- *
60
- * @remarks
61
- * This method is called by the rendering pipeline to bind GPU resources
62
- * (such as textures and samplers) associated with this material.
63
- *
64
- * @param bindGroup - The bind group to which uniforms and resources are bound.
65
- * @param ctx - The current draw context providing rendering-state information.
66
- *
67
- */ internalApplyUniforms(bindGroup, ctx) {
68
- if (this.spriteTexture && this.needFragmentColor(ctx)) {
69
- bindGroup.setTexture('zSpriteTexture', this.spriteTexture, fetchSampler('clamp_linear'));
70
- }
71
- }
72
- /**
73
- * Declares and configures shader uniforms for this material in the current scope.
74
- *
75
- * @remarks
76
- * This is executed during shader construction. If the active shader stage
77
- * is a fragment shader, and the material requires fragment color and has
78
- * a sprite texture assigned, a 2D texture uniform named `zSpriteTexture`
79
- * is added to the program.
80
- *
81
- * @param scope - The current shader function scope used to build the program.
82
- */ internalSetupUniforms(scope) {
83
- const pb = scope.$builder;
84
- if (pb.shaderKind === 'fragment' && this.spriteTexture && this.needFragmentColor()) {
85
- scope.zSpriteTexture = pb.tex2D().uniform(2);
86
- }
87
- }
88
- /**
89
- * Computes the fragment color expression for this material within the shader.
90
- *
91
- * @remarks
92
- * - If a sprite texture is assigned, this samples the texture using
93
- * the interpolated vertex UV coordinates (`zVertexUV`).
94
- * - If no texture is assigned, this returns a solid white color.
95
- *
96
- * @param scope - The current shader function scope providing inputs and uniforms.
97
- * @returns A shader expression representing the computed fragment color.
98
- */ calcFragmentColor(scope) {
99
- const pb = scope.$builder;
100
- return this.spriteTexture ? pb.textureSample(scope.zSpriteTexture, scope.$inputs.zVertexUV) : pb.vec4(1);
101
- }
102
- /**
103
- * Releases resources held by this material instance.
104
- *
105
- * @remarks
106
- * This is called when the material is disposed. It forwards the dispose
107
- * call to the internal texture reference so that the associated GPU
108
- * resource can be released.
109
- */ onDispose() {
110
- super.onDispose();
111
- this._texture.dispose();
112
- }
113
- }
114
-
115
- export { StandardSprite3DMaterial };
116
- //# sourceMappingURL=sprite3d_std.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sprite3d_std.js","sources":["../../src/material/sprite3d_std.ts"],"sourcesContent":["import type { BindGroup, PBInsideFunctionScope, Texture2D } from '@zephyr3d/device';\r\nimport type { Clonable } from '@zephyr3d/base';\r\nimport { DRef } from '@zephyr3d/base';\r\nimport type { DrawContext } from '../render/drawable';\r\nimport { Sprite3DMaterial } from './sprite3d';\r\nimport { fetchSampler } from '../utility/misc';\r\n\r\n/**\r\n * Standard Sprite3D material\r\n * @public\r\n */\r\nexport class StandardSprite3DMaterial extends Sprite3DMaterial implements Clonable<StandardSprite3DMaterial> {\r\n static FEATURE_SPRITE_TEXTURE = this.defineFeature();\r\n protected _texture: DRef<Texture2D>;\r\n /**\r\n * Creates a new instance of {@link StandardSprite3DMaterial}.\r\n *\r\n * @remarks\r\n * By default, no sprite texture is assigned and the material renders\r\n * as solid white until a texture is set.\r\n */\r\n constructor() {\r\n super();\r\n this._texture = new DRef();\r\n }\r\n /**\r\n * Gets the 2D texture used by this sprite material.\r\n *\r\n * @returns The current sprite texture, or `null` if no texture is assigned.\r\n */\r\n get spriteTexture() {\r\n return this._texture.get();\r\n }\r\n set spriteTexture(tex) {\r\n tex = tex ?? null;\r\n if (tex !== this._texture.get()) {\r\n this._texture.set(tex);\r\n this.useFeature(StandardSprite3DMaterial.FEATURE_SPRITE_TEXTURE, !!tex);\r\n this.uniformChanged();\r\n }\r\n }\r\n /**\r\n * Creates a deep copy of this material instance.\r\n *\r\n * @remarks\r\n * The new instance will copy all relevant state from this material,\r\n * including the assigned sprite texture reference.\r\n *\r\n * @returns A new {@link StandardSprite3DMaterial} instance with the same settings.\r\n */\r\n clone() {\r\n const other = new StandardSprite3DMaterial();\r\n other.copyFrom(this);\r\n return other;\r\n }\r\n /**\r\n * Copies the state from another {@link StandardSprite3DMaterial} into this instance.\r\n *\r\n * @param other - The source material to copy from.\r\n */\r\n copyFrom(other: this) {\r\n super.copyFrom(other);\r\n this.spriteTexture = other.spriteTexture;\r\n }\r\n /**\r\n * Applies runtime uniform values to the given bind group before drawing.\r\n *\r\n * @remarks\r\n * This method is called by the rendering pipeline to bind GPU resources\r\n * (such as textures and samplers) associated with this material.\r\n *\r\n * @param bindGroup - The bind group to which uniforms and resources are bound.\r\n * @param ctx - The current draw context providing rendering-state information.\r\n *\r\n */\r\n protected internalApplyUniforms(bindGroup: BindGroup, ctx: DrawContext) {\r\n if (this.spriteTexture && this.needFragmentColor(ctx)) {\r\n bindGroup.setTexture('zSpriteTexture', this.spriteTexture, fetchSampler('clamp_linear'));\r\n }\r\n }\r\n /**\r\n * Declares and configures shader uniforms for this material in the current scope.\r\n *\r\n * @remarks\r\n * This is executed during shader construction. If the active shader stage\r\n * is a fragment shader, and the material requires fragment color and has\r\n * a sprite texture assigned, a 2D texture uniform named `zSpriteTexture`\r\n * is added to the program.\r\n *\r\n * @param scope - The current shader function scope used to build the program.\r\n */\r\n protected internalSetupUniforms(scope: PBInsideFunctionScope) {\r\n const pb = scope.$builder;\r\n if (pb.shaderKind === 'fragment' && this.spriteTexture && this.needFragmentColor()) {\r\n scope.zSpriteTexture = pb.tex2D().uniform(2);\r\n }\r\n }\r\n /**\r\n * Computes the fragment color expression for this material within the shader.\r\n *\r\n * @remarks\r\n * - If a sprite texture is assigned, this samples the texture using\r\n * the interpolated vertex UV coordinates (`zVertexUV`).\r\n * - If no texture is assigned, this returns a solid white color.\r\n *\r\n * @param scope - The current shader function scope providing inputs and uniforms.\r\n * @returns A shader expression representing the computed fragment color.\r\n */\r\n protected calcFragmentColor(scope: PBInsideFunctionScope) {\r\n const pb = scope.$builder;\r\n return this.spriteTexture ? pb.textureSample(scope.zSpriteTexture, scope.$inputs.zVertexUV) : pb.vec4(1);\r\n }\r\n /**\r\n * Releases resources held by this material instance.\r\n *\r\n * @remarks\r\n * This is called when the material is disposed. It forwards the dispose\r\n * call to the internal texture reference so that the associated GPU\r\n * resource can be released.\r\n */\r\n protected onDispose() {\r\n super.onDispose();\r\n this._texture.dispose();\r\n }\r\n}\r\n"],"names":["StandardSprite3DMaterial","Sprite3DMaterial","FEATURE_SPRITE_TEXTURE","defineFeature","_texture","DRef","spriteTexture","get","tex","set","useFeature","uniformChanged","clone","other","copyFrom","internalApplyUniforms","bindGroup","ctx","needFragmentColor","setTexture","fetchSampler","internalSetupUniforms","scope","pb","$builder","shaderKind","zSpriteTexture","tex2D","uniform","calcFragmentColor","textureSample","$inputs","zVertexUV","vec4","onDispose","dispose"],"mappings":";;;;AAOA;;;IAIO,MAAMA,wBAAiCC,SAAAA,gBAAAA,CAAAA;AAC5C,IAAA,OAAOC,sBAAyB,GAAA,IAAI,CAACC,aAAa,EAAG;IAC3CC,QAA0B;AACpC;;;;;;AAMC,MACD,WAAc,EAAA;QACZ,KAAK,EAAA;QACL,IAAI,CAACA,QAAQ,GAAG,IAAIC,IAAAA,EAAAA;AACtB;AACA;;;;AAIC,MACD,IAAIC,aAAgB,GAAA;AAClB,QAAA,OAAO,IAAI,CAACF,QAAQ,CAACG,GAAG,EAAA;AAC1B;IACA,IAAID,aAAAA,CAAcE,GAAG,EAAE;AACrBA,QAAAA,GAAAA,GAAMA,GAAO,IAAA,IAAA;AACb,QAAA,IAAIA,QAAQ,IAAI,CAACJ,QAAQ,CAACG,GAAG,EAAI,EAAA;AAC/B,YAAA,IAAI,CAACH,QAAQ,CAACK,GAAG,CAACD,GAAAA,CAAAA;AAClB,YAAA,IAAI,CAACE,UAAU,CAACV,yBAAyBE,sBAAsB,EAAE,CAAC,CAACM,GAAAA,CAAAA;AACnE,YAAA,IAAI,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